<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
foreach($_REQUEST as $key=>$value)
{
$$key=$value;
}
?>
<br>
<div class="container">
<div class="panel panel-warning">
<div class="panel-heading">
<h3 class="panel-title"><span class='glyphicon glyphicon-list-alt' aria-hidden='true'> </span> รายการบันทึกเสนอ</h3>
</div>
<div class="panel-body">
<table class="table table-hover table-striped">
<thead>
<tr>
<th width="5%">ที่</th>
<th>เลขที่</th>
<th width="3%"></th>
<th width="40%">เรื่อง</th>
<th width="25%">เรียน</th>
<th width="10%">แก้ไข/จดหมาย/ออกเลขหนังสือส่ง</th>
<th>สถานะ</th>
</tr>
</thead>
<tbody>
<?php
//บุคลากรเขต
$user=$_SESSION['login_user_id'];
$sql_person = "select * from person_main where person_id='$user'";
$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'];
if($position_code <= 2 and $department ==0){
$g_name="ผู้บริหาร สพท.";
}
?>
<?php
$sql = "SELECT * FROM `idocument_main` where officer = '". $_SESSION['login_user_id'] ."' Order By id Desc";
$dbquery = mysqli_query($connect,$sql);
$row = 1;
while($datarow = mysqli_fetch_assoc($dbquery)){
?>
<tr>
<td><?php echo $row;?></td>
<td><?php echo $datarow['book_no'];?></td>
<td>
<?php
$book_type = $datarow['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><b><a href="?option=<?php echo $option;?>&task=detail&id=<?php echo $datarow['id'];?>" title = "รายละเอียด"><?php echo $datarow['subject'];?></a></b><br>โดย : <?php echo $fullname?><br>กลุ่ม/หน่วย : <?php echo $g_name?></td>
<th><?php echo $datarow['book_to'];?></th>
<th>
<!-- <a href="?option=<?php //echo $option;?>&task=detail&id=<?php //echo $datarow['id'];?>" class="btn btn-info" title = "รายละเอียด"><i class="glyphicon glyphicon-search"></i></a>
-->
<!--a href="#" class="btn btn-warning" ><i class="glyphicon glyphicon-menu-right"></i></a-->
<?php
$book_status = $datarow['book_status'];
if($book_status <= 1 or $book_status == 99) { //แก้ไขได้เมื่อยังไม่ผ่าน ผอ.กลุ่ม หรือคืนเรื่อง
?>
<a href="?option=<?php echo $option;?>&task=edit&id=<?php echo $datarow['id'];?>&book_status1=<?php echo $datarow['book_status'];?>" class="btn btn-warning" title = "แก้ไข"><i class="glyphicon glyphicon-edit"></i></a>
<?php
}
?>
<?php //ส่งจดหมาย เมื่อ ผอ.หรือรอง ลงนามแล้ว
// $book_status = $datarow['book_status']; //สถานะการลงนาม
$ref_id_mail = $datarow['ref_id_mail']; //ref_id mail
//ลงนามแล้ว
if($book_status == 5 or $book_status == 40){
$status_idoc = '1'; //ลงนาม
}else{
$status_idoc = '0'; //ยังไม่ลงนาม
}
?>
<?php
if($status_idoc =='1' and $ref_id_mail =='') { //ลงนามแล้ว ยังไม่ส่ง mail
//echo $url="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
?>
<a href="?option=mail&id_doc=<?php echo $datarow['id'];?>&task=main/send2&index=1" class="btn btn-danger" title = "ยังไม่ส่งจดหมาย"><i class="glyphicon glyphicon-envelope"></i></a>
<?php
}
?>
<?php
if($status_idoc =='1' and $ref_id_mail >'') { //ลงนามแล้ว ส่ง mail แล้ว
//เช็คข้อมูลใน mail
$sql1 = "select * from mail_main where ref_id='$ref_id_mail' ";
$dbquery1 = mysqli_query($connect,$sql1);
$result1 = mysqli_fetch_array($dbquery1);
$ms_id=$result1['ms_id']; //id ของ mail
//เช็คการเปิดอ่าน mail
$sql2 = "select * from mail_sendto_answer where ref_id='$ref_id_mail' and answer='1'";
$dbquery2 = mysqli_query($connect,$sql2);
$result2 = mysqli_fetch_array($dbquery2);
$read_num=mysqli_num_rows($dbquery2); //เช็คจำนวนที่เปิดอ่าน mail
if($read_num == 0){
$icon="glyphicon glyphicon-envelope";
}else{
$icon="fas fa-envelope-open";
}
?><script src='https://kit.fontawesome.com/a076d05399.js'></script>
<a href="?option=mail&task=main/send&index=7&id=<?php echo $ms_id?>" class="btn btn-success" title = "ส่งจดหมายแล้ว เปิดอ่าน <?php echo $read_num?> คน" target="_BLANK"><i class="<?php echo $icon?>"></i></a>
<?php
}
?>
<?php
if($status_idoc =='1') { //ลงนามแล้ว
//echo $url="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
?>
<a href="?option=bookregister&id_doc=<?php echo $datarow['id'];?>&task=main/send&index=1" class="btn btn-info" title = "ออกเลขหนังสือนำส่ง"><i class="glyphicon glyphicon-book"></i></a>
<?php
}
?>
</th>
<th>
<?php
$pre_doc_id = $datarow['pre_doc_id'];
$book_status = $datarow['book_status'];
if($pre_doc_id == 0){ ?>
<span class="pull-right badge" style="background-color:Back;">ฉบับร่าง</span>
<?php
}
?>
<?php
if($book_status == 0){
$commenttext = "รอดำเนินการ";
$badge = "orange";
}
if($book_status == 1){
$commenttext = "กำลังดำเนินการ";
$badge = "#b783f9";
}
if($book_status == 2){
$commenttext = "รอ รอง ผอ.สพป. ลงนาม";
$badge = "DodgerBlue";
}
if($book_status == 3){
$commenttext = "รอ ผอ.สพป. ลงนาม";
$badge = "DodgerBlue";
}
if($book_status == 40){
$commenttext = "ผอ.สพป.ลงนามแล้ว";
$badge = "green";
}
if($datarow['book_status'] == 4){
$commenttext = "อนุญาต";
$badge = "green";
}
if($datarow['book_status'] == 41){
$commenttext = "อนุญาต/อนุมัติ";
$badge = "green";
}
if($datarow['book_status'] == 5){
$commenttext = "รอง ผอ.ลงนามแล้ว<br>ปฏิบัติราชการแทน";
$badge = "green";
}
if($datarow['book_status'] == 51){
$commenttext = "ไม่อนุญาต/ไม่อนุมัติ";
$badge = "red";
}
if($datarow['book_status'] == 6){
$commenttext = "อนุมัติ";
$badge = "green";
}
if($datarow['book_status'] == 7){
$commenttext = "ไม่อนุมัติ";
$badge = "red";
}
if($datarow['book_status'] == 8){
$commenttext = "ชอบ/ดำเนินการตามเสนอ";
$badge = "green";
}
if($datarow['book_status'] == 99){
$commenttext = "คืนเรื่องแก้ไข";
$badge = "red";
}
?>
<span class="pull-right badge" style="background-color:<?php echo $badge;?>;"><?php echo $commenttext;?></span>
<?php
$row++;
}
?>
</th>
</tr>
</tbody>
</table>
</div>
</div>
</div>