Path : /var/www/html/smart_kpp2_bk17 มีค 69/modules/idocument/
File Upload :
Current File : /var/www/html/smart_kpp2_bk17 มีค 69/modules/idocument/viewlist.php

<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.' );
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="data1">
    <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'];
  ?>
        <?php echo $datarow['subject'];?><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>


<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>



  </div>
</div>   
<script>
$(document).ready(function() {
    $('#DocumentList').DataTable();
} );
</script>