<link href="https://fonts.googleapis.com/css?family=Sarabun&display=swap" rel="stylesheet">
<link rel="stylesheet" href="modules/idocument/css/dataTables.bootstrap.min.css">
<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
require_once "modules/$_REQUEST[option]/time_inc.php";
$user=$_SESSION['login_user_id'];
foreach($_REQUEST as $key=>$value)
{
$$key=$value;
}
?>
<br>
<div class="container">
<div class="panel panel-success">
<div class="panel-heading">
<h2 class="panel-title"><span class='glyphicon glyphicon-list-alt' aria-hidden='true'> </span> ลงความเห็น/สั่งการ</h2>
</div>
<div class="panel-body">
<?php
if(!isset($_GET['action'])){
?>
<table class="table table-hover table-striped" id="data1">
<thead>
<tr>
<th><center>ที่</center></th>
<th><center>เลขที่</center></th>
<th><center>เรื่อง</center></th>
<th><center>เรื่อง</center></th>
<th><center>เรียน</center></th>
<th><center>ลงความเห็น/สั่งการ</center></th>
<th><center>สะถานะ</center></th>
<!--th>สถานะ</th-->
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM `idocument_sendto` where person_id = '". $_SESSION['login_user_id'] ."' and `status` IN (1,2,3) Order By id Desc";
//echo $sql;
$dbquery = mysqli_query($connect,$sql);
$row = 1;
if($dbquery){
while($datarow = mysqli_fetch_assoc($dbquery)){
$xx = $datarow['person_id'];
//echo $datarow['document_id'];
$sqlID = "SELECT * FROM `idocument_main` where id = '". $datarow['document_id'] ."' and pre_doc_id = '1' ";
//echo $sqlID;
$dbqueryID = mysqli_query($connect,$sqlID);
$dataRowDetail = mysqli_fetch_assoc($dbqueryID)
?>
<tr>
<td><?php echo $row;?></td>
<td><?php echo $dataRowDetail['book_no'];?></td>
<td>
<?php
$book_type = $dataRowDetail['book_type'];
if($book_type == 0){
$type = "<span class='pull-right badge' style='background-color:back;''>ปกติ</span>";
}
if($book_type == 1){
$type = "<span class='pull-right badge' style='background-color:orange;''>ด่วน</span>";
}
if($book_type == 2){
$type = "<span class='pull-right badge' style='background-color:red;''>ด่วนที่สุด</span>";
}
if($book_type == 3){
$type = "<span class='pull-right badge' style='background-color:DeepPink;''>ลับ</span>";
}
echo $type;
?>
</td>
<td>
<?php
//บุคลากรเขต
$officer=$dataRowDetail['officer']; //ผู้เสนอ
$sql_person = "select * from person_main where person_id='$officer'";
$dbquery_person = mysqli_query($connect,$sql_person);
$result_person = mysqli_fetch_array($dbquery_person);
$total_pid = mysqli_num_rows($dbquery_person);
$position_code = $result_person['position_code'];
$department = $result_person['department'];
$pic = $result_person['pic'];
$fullname=$result_person['prename'].$result_person['name']." ".$result_person['surname'];
$responsible=$result_person['responsible'];
//หาตำแหน่ง
$sql_position = "select * from person_position where position_code='$position_code' ";
$dbquery_position = mysqli_query($connect,$sql_position);
$result_position = mysqli_fetch_array($dbquery_position);
$position_name = $result_position['position_name'];
//หาหน่วยงาน
$sql_workgroup = "select * from system_workgroup where workgroup='$department' ";
$dbquery_workgroup = mysqli_query($connect,$sql_workgroup);
$result_workgroup = mysqli_fetch_array($dbquery_workgroup);
$g_name = $result_workgroup['workgroup_desc2'];
?>
<?php echo $dataRowDetail['subject'];?><br>โดย : <?php echo $fullname?><br>กลุ่ม/หน่วย : <?php echo $g_name?></td>
<th><font size="2"><?php echo $dataRowDetail['book_to'];?></font></th>
<?php
$book_status = $dataRowDetail['book_status'];
if($book_status == 5 | $book_status == 40) { ?>
<th><center>
<a href="?option=<?php echo $_REQUEST['option'];?>&task=book_pass&action=comment&id=<?php echo $dataRowDetail['id'];?>" ><font color="#4682B4"><span class='glyphicon glyphicon-ok-sign' aria-hidden='true'></span></font></a></center>
</th>
<?php
} else {
?>
<th><center>
<a href="?option=<?php echo $_REQUEST['option'];?>&task=book_pass&action=comment&id=<?php echo $dataRowDetail['id'];?>" ><span class='glyphicon glyphicon-list-alt' aria-hidden='true'></span></a></center>
</th>
<?php
}
$book_status = $dataRowDetail['book_status'];
if($book_status == 1){
$commenttext = "กำลังดำเนินการ";
$badge = "#b783f9";
}
if($book_status == 2){
$commenttext = "รอ รอง ผอ.สพป. ลงนาม";
$badge = "DodgerBlue";
}
if($book_status == 3){
$commenttext = "รอ ผอ.สพป. ลงนาม";
$badge = "fuchsia";
}
if($book_status == 40){
$commenttext = "ลงนามแล้ว";
$badge = "green";
}
if($book_status == 5){
$commenttext = "รอง ปฏิบัติราชการแทน<br>ลงนามแล้ว";
$badge = "#B8288C";
}
if($book_status == 99){
$commenttext = "คืนเรื่อง";
$badge = "red";
}
?>
<th><span class="pull-right badge" style="background-color:<?php echo $badge;?>;"><?php echo $commenttext;?></span></center></th>
</tr>
<?php
$row++;
}
}
?>
</tbody>
</table>
<script src="modules/idocument/css/jquery.dataTables.min.js"></script>
<script src="modules/idocument/css/dataTables.bootstrap.min.js"></script>
<script>
$(function () {
$('#data1').DataTable({
"oLanguage": {
"sLengthMenu": "แสดง _MENU_ เร็คคอร์ด ต่อหน้า",
"sZeroRecords": "ไม่เจอข้อมูลที่ค้นหา",
"sInfo": "แสดง _START_ ถึง _END_ ของ _TOTAL_ เร็คคอร์ด",
"sInfoEmpty": "แสดง 0 ถึง 0 ของ 0 เร็คคอร์ด",
"sInfoFiltered": "(จากเร็คคอร์ดทั้งหมด _MAX_ เร็คคอร์ด)",
"sSearch": "ค้นหา :",
"oPaginate": {
"sFirst": "เริ่มต้น",
"sPrevious": "ก่อนหน้า",
"sNext": "ถัดไป",
"sLast": "สุดท้าย"
}
},
"iDisplayLength" : 10,
"aLengthMenu" : [[10, 15, 25, 50, 100, -1], [10, 15, 25, 50, 100, "ทั้งหมด"]],
"sPaginationType" : "simple_numbers",
});
} );
</script>
<script type="text/javascript">
$(document).ready(function() {
$('#DocumentLoad').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "server_processing.php",
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
// Total over all pages
total = api
.column( 5 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
pageTotal = api
.column( 5, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 5 ).footer() ).html(
'$'+pageTotal +' total'
);
}
} );
} );
</script>
<?php
}
?>
<?php
if(isset($_GET['action'])){
?>
<div class="col-sm-8">
<?php
$id = $_REQUEST['id'];
$sql = "Select * From idocument_main where id = $id";
$dbquery = mysqli_query($connect,$sql);
$dataDisplay = mysqli_fetch_assoc($dbquery);
?>
<font face="Sarabun" >
<table width="100%" border="0">
<tr>
<td width="60">
<img = src="./pdf/krut.png" border="0" width="60">
</td>
<td align = "center" valign="middle" colspan="3">
<strong><font face="Sarabun" size="5">บันทึกข้อความ</strong>
</td>
</tr>
<tr>
<td colspan="4">
<p>
<strong><font face="Sarabun" size="3">ส่วนราชการ </strong> <font face="Sarabun" size="3"><?php echo $dataDisplay['workgroup_txt'];?>
</p>
</td>
</tr>
<tr>
<td valign="middle" colspan="2">
<p>
<strong><font face="Sarabun" size="3">ที่ </strong><font face="Sarabun" size="2"><?php echo $dataDisplay['book_no'];?>
</p>
</td>
<td valign="middle" align="center" colspan="2">
<p>
<strong><font face="Sarabun" size="3">วันที่ </strong><font face="Sarabun" size="2"><?php echo thai_dateBook($dataDisplay['book_date']);?>
</p>
</td>
</tr>
<tr>
<td colspan="4" style="border-bottom: 1px solid">
<p>
<strong><font face="Sarabun" size="3">เรื่อง </strong><font face="Sarabun" size="3"> <?php echo $dataDisplay['subject'];?>
</p>
</td>
</tr>
<tr>
<td colspan="4" style="">
<p><br>
<strong><font face="Sarabun" size="3">เรียน </strong><font face="Sarabun" size="3"><?php echo $dataDisplay['book_to'];?>
</p>
</td>
</tr>
<?php
//Check Ref doc
$sql = "Select * From idocument_files Where document_id = '$id' and docType = 'ref'";
$result = mysqli_query($connect,$sql);
if($result->num_rows > 0){
$i = 1;
echo' <tr>
<td valign="top" width ="120"><strong>อ้างถึง</strong>
</td>
<td colspan="3" style="">
<p>';
while ($row = $result->fetch_assoc()) {
if(!empty($row['file_name'])){
if(empty($row['file_des'])){
echo $i.". <a target='_blank' href='".$row['file_name'] ."'>เอกสารหนังสืออ้างถึง</a><br>";
}else{
echo $i.". <a target='_blank' href='".$row['file_name'] ."'>".$row['file_des']."</a><br>";
}
}else{
echo $i.". ". $row['file_des']."<br>";
}
$i++;
}
echo' </p>
</td>
</tr>';
}
?>
<?php
//Check Ref doc
$sql = "Select * From idocument_files Where document_id = '$id' and docType = 'attach'";
$result = mysqli_query($connect,$sql);
if($result->num_rows > 0){
$i = 1;
echo' <tr>
<td valign="top" width ="120"><strong>สิ่งที่ส่งมาด้วย</strong>
</td>
<td colspan="3" style="">
<p>';
while ($row = $result->fetch_assoc()) {
if(!empty($row['file_name'])){
if(empty($row['file_des'])){
echo $i.". <a target='_blank' href='".$row['file_name'] ."'>เอกสารสิ่งที่ส่งมาด้วย</a><br>";
}else{
echo $i.". <a target='_blank' href='".$row['file_name'] ."'>".$row['file_des']."</a><br>";
}
}else{
echo $i.". ". $row['file_des']."<br>";
}
$i++;
}
echo' </p>
</td>
</tr>';
}
?>
<?php
//Check Ref doc
$sql = "Select * From idocument_files Where document_id = '$id' and docType = 'sent'";
$result = mysqli_query($connect,$sql);
if($result->num_rows > 0){
$i = 1;
echo' <tr>
<td valign="top" width ="120"><strong>ร่างหนังสือส่ง</strong>
</td>
<td colspan="3" style="">
<p>';
while ($row = $result->fetch_assoc()) {
if(!empty($row['file_name'])){
if(empty($row['file_des'])){
echo $i.". <a target='_blank' href='".$row['file_name'] ."'>ร่างหนังสือส่ง</a><br>";
}else{
// echo $i.". <a target='_blank' href='".$row['file_name'] ."'>".$row['file_des']."</a><br>";
$s = $_SESSION['login_user_id'] .".png";
$filename = basename($row['file_name']);
//echo $s;
?>
<!--a target='_blank' href="<?php echo $row['file_name'];?>"> <?php echo $i.". ".$row['file_des'];?></a-->
<a target='_blank' class="btn btn-sm btn-info" href="modules/idocument/pdf2/pdfeditor.php?f=../upload_files/<?php echo $filename;?>&n=<?php echo $filename;?>&d=<?php echo $filename;?>&s=<?php echo $s;?>"> <?php echo $i.". ".$row['file_des'];?> <i class="fa fa-pencil-square-o"></i></a>
<!--a target='_blank' class="btn btn-success" href="modules/idocument/pdf2/uploads/<?php echo $filename;?>"> <i class="fa fa-check-square-o"></i></a-->
<a class="btn btn-success btn-sm" href="modules/idocument/pdf2/uploads/<?php echo $filename;?>?t=<?php echo time(); ?>" target="_blank"> <i class="fa fa-check-square-o"></i> เปิดไฟล์ PDF </a>
<?php }
}else{
echo $i.". ". $row['file_des']."<br>";
}
$i++;
}
echo' </p>
</td>
</tr>';
}
?>
<tr>
<td colspan="4" style="">
<p>
<font face="Sarabun" size="2"><?php echo $dataDisplay['content1'];?>
</p>
</td>
</tr>
<tr>
<td colspan="4" style="">
<p>
<font face="Sarabun" size="2"><?php echo $dataDisplay['content2'];?>
</p>
</td>
</tr>
<tr>
<td colspan="4" style="">
<p>
<?php
$lines = explode("\n", $dataDisplay['content3']);
$isFirstLine = true;
foreach ($lines as $line) {
$formattedLine = str_replace(" ", " ", trim($line));
if (!empty($formattedLine)) {
if ($isFirstLine) {
// บรรทัดแรกเป็นหัวข้อ
echo ' ' . htmlspecialchars($formattedLine) . '';
$isFirstLine = false;
} else {
// บรรทัดอื่นเป็นย่อหน้าปกติ
echo '<p> ' . htmlspecialchars($formattedLine) . '</p>';
}
}
}
?>
<!-- <font face="Sarabun" size="2"><?php echo $dataDisplay['content3'];?> -->
</p>
</td>
</tr>
<tr>
<td colspan="3" style="text-align:center;"><br><!-- <font face="Sarabun" size="2">ตรวจสอบเสนอ -->
<br>
<?php
// Add signature
$sigFile = "./signature/". $dataDisplay['officer'] .".png";
//$sigFile = "./signature/3350100788990.png";
if(file_exists($sigFile)){
echo "<img src='". $sigFile ."' border='0' width='120'>";
}
?>
<br><font face="Sarabun" size="2">
(<?php echo $dataDisplay['officer_name'];?>)
<br><font face="Sarabun" size="2">
<?php echo $dataDisplay['officer_position'];?>
<br><font face="Sarabun" size="2">
<?php echo thai_dateBook($dataDisplay['book_date']);?>
</td>
<td style=""></td>
</tr>
</table>
<br /><br />
<?php
$sqlComment = "Select * From idocument_comment where document_id = $id Order by id";
//echo $sqlComment;
$dbqueryComment = mysqli_query($connect,$sqlComment);
if(mysqli_num_rows($dbqueryComment)==0){
}else{
while($commentData = mysqli_fetch_array($dbqueryComment)){
if($commentData['comments_type'] == 88) {
$comments_type = "ปฏิบัติราชการ/รักษาการแทน ";
} else {
$comments_type = "";
}
$fullname = '( '. $commentData['person_comments_name'].' )<br>
'. $commentData['person_comments_position'].'
'. $comments_type.'<br>
'. thai_dateBook($commentData['comments_date']);
//'. thai_dateBook(date("Y-m-d",$commentData['comments_date']));
//echo "$b[$ii]";
if($commentData['comments_select'] == ""){
$commenttext = "";
}
if($commentData['comments_select'] == 0){
$commenttext0 = "- เพื่อโปรดทราบ<br>";
}
if($commentData['comments_select'] == 1){
$commenttext1 = "- เพื่อโปรดพิจารณา<br>";
}
if($commentData['comments_select'] >= 2){
$a = $commentData['comments_select'];
$b = explode("|", $a);
for($ii=0;$ii<count($b);$ii++)
{
if($b[$ii] == 0){
$commenttext0 = "";
}
if($b[$ii] == 0){
$commenttext1 = "";
}
if($b[$ii] == 2){
$commenttext2 = "- ทราบ <br>";
}
if($b[$ii] == 3){
$commenttext3 = "- ลงนามแล้ว <br>";
}
if($b[$ii] == 4){
$commenttext4 = "- อนุญาต <br>";
}
if($b[$ii] == 5){
$commenttext5 = "- ไม่อนุญาต <br>";
}
if($b[$ii] == 6){
$commenttext6 = "- อนุมัติ <br>";
}
if($b[$ii] == 7){
$commenttext7 = "- ไม่อนุมัติ <br>";
}
if($b[$ii] == 8){
$commenttext8 = "- ชอบ/ให้ดำเนินการตามเสนอ";
}
if($b[$ii] == 99){
$commenttext9 = "- คืนเรื่อง";
}
//echo "$b[$ii]";
}
}
$comment = $commenttext.$commenttext0.$commenttext1.$commenttext2.$commenttext3.$commenttext4.$commenttext5.$commenttext6.$commenttext7.$commenttext8.$commenttext9;
if(!empty($commentData['comments_etctxt'])){
$comment = $comment.'<br>
- '. $commentData['comments_etctxt'];
}
echo "<div class='col-sm-4'>";
echo "<font face='Sarabun' size='2'>".$comment;
echo "<p align=center>";
// Add signature
$sigFileComment = "./signature/". $commentData['person_comments_id'] .".png";
//$sigFile = "./signature/3340100679937.png";
if(file_exists($sigFileComment)){
echo "<img src='". $sigFileComment ."' border='0' width='120'>";
}
echo "<br>".$fullname;
echo "</p>";
echo "</div>";
}
}
?>
</font>
</div>
<div class="col-sm-4">
<div class="row">
</font>
<?php
if($_SESSION['position_code'] == 1){
require_once "modules/$_REQUEST[option]/book_pass_form_comment3.php";
}elseif ($_SESSION['position_code'] == 2) {
require_once "modules/$_REQUEST[option]/book_pass_form_comment2.php";
}elseif ($_SESSION['position_code'] == 3){
require_once "modules/$_REQUEST[option]/book_pass_form_comment1.php";
}
//print_r($_SESSION);
?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>