Path : /var/www/html/smart_kpp2_v2/modules/idocument/
File Upload :
Current File : /var/www/html/smart_kpp2_v2/modules/idocument/viewlist.php

<?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" id="DocumentList">
    <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>พิมพ์ PDF</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']; //ตำแหน่ง 1=ผอ.เขต 2=รอง ผอ.เขต
$department = $result_person['department'];
$pic = $result_person['pic'];
$fullname=$result_person['prename'].$result_person['name']." ".$result_person['surname'];
$responsible=$result_person['responsible'];
?>

<?php
if($position_code == '1' or $position_code == '2'){ //ผอ.เขต รอง
$sql = "SELECT * FROM `idocument_main` where (book_status=5 or book_status=40) Order By id Desc";
}else{ //ตัวเอง
$sql = "SELECT * FROM `idocument_main` WHERE officer ='$user' and  (book_status=5 or book_status=40) Order By id Desc";
} 

$dbquery = mysqli_query($connect,$sql);
$row = 1;
while($datarow = mysqli_fetch_assoc($dbquery)){
?>
      <tr>
        <td width="5%"><?php echo $row;?></td>
        <td width="10%"><?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>
         <?php    
//บุคลากรเขต
$officer=$datarow['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'];

  if($position_code <= 2 and $department ==0){
    $g_name="ผู้บริหาร สพท.";
  }
  ?>
        <b><?php echo $datarow['subject'];?></b><br>โดย : <?php echo $fullname?><br>กลุ่ม/หน่วย : <?php echo $g_name?></td>
        <!--th><?php echo $datarow['book_to'];?></th-->
        <th width="25%"><?php echo $datarow['book_to'];?></th>
        <th>
			<a href="?option=<?php echo $option;?>&task=detail&id=<?php echo $datarow['id'];?>" class="btn btn-success" ><i class="glyphicon glyphicon-search"></i></a>
			<!--a href="#" class="btn btn-warning" ><i class="glyphicon glyphicon-menu-right"></i></a-->
			<!--a href="#" class="btn btn-info " ><i class="glyphicon glyphicon-edit"></i></a-->
        </th>
        <!--th><a href="./pdf/display.php?id=<?php echo $datarow['id'];?>&comment=1" target="_blank"><img src="modules/idocument/images/fill-pdf-forms.png" width=35 border=0></a></th!-->
      </tr>
<?php
$row++;
}
?>        
    </tbody>
  </table>
    </div>
  </div>
</div>   
<script>
$(document).ready(function() {
    $('#DocumentList').DataTable();
} );
</script>