<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<?php
  if(!isset($_SESSION["intLine"]))
  {
?>
<center><h4 class="text-red">ไม่พบข้อมูล</h4></center>
<?php
  exit();
  }
  $year = date('Y')+543;
  $month = date('m');
?>
<?php
	function DateThai($strDate)
	{
		$strYear = date("Y",strtotime($strDate))+543;
		$strMonth = date("n",strtotime($strDate));
		$strDay = date("d",strtotime($strDate));
		$strMonthCut = Array("","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
		$strMonthThai = $strMonthCut[$strMonth];
		return "$strMonthThai";
	}
	$M2 = DateThai($month);
?>
<center>
  <table id="example2s" class="table table-bordered table-striped">
  <thead>
    <tr class="text-green">
      <td style="width:10%;"><center>รหัสพนักงาน</center></td>
      <td style="width:10%;"><center>ชื่อ-นามสกุล</center></td>
      <td style="width:10%;"><center>ตำแหน่ง</center></td>
      <td style="width:10%;"><center>แผนก</center></td>
      <td style="width:10%;"><center>ฝ่าย</center></td>
      <td style="width:10%;"><center>สาขา</center></td>
      <td style="width:3%;"><center>ปริ้น</center></td>
      <td style="width:3%;"><center>ลบ</center></td>
    </tr>
  </thead>
  <tbody>
    <?php
      for($i=0;$i<=(int)$_SESSION["intLine"];$i++)
      {
      if($_SESSION["EMP_ID"][$i] != "")
      {
      $EMP_ID = $_SESSION["EMP_ID"][$i];
      $sql = "SELECT [EHONGDB].[dbo].[EMPLOYEE].*,[EHONGDB].[dbo].[EMP_POSITION].*,[EHONGDB].[dbo].[BRANCH].*,[EHONGDB].[dbo].[EMP_FACTION].*,[EHONGDB].[dbo].[DEPARTMENT].*,[EHONGDB].[dbo].[DEPARTMENT].*
      FROM [EHONGDB].[dbo].[EMPLOYEE],[EHONGDB].[dbo].[EMP_POSITION],[EHONGDB].[dbo].[BRANCH],[EHONGDB].[dbo].[EMP_FACTION],[EHONGDB].[dbo].[DEPARTMENT]
      WHERE EMPLOYEE.BR_ID = BRANCH.BR_ID AND EMPLOYEE.PO_ID = EMP_POSITION.PO_ID AND EMPLOYEE.DP_ID = DEPARTMENT.DP_ID AND EMPLOYEE.FC_ID = EMP_FACTION.FC_ID
      AND EMP_ID = '$EMP_ID'";
      $select=$conn->prepare($sql);
      $select->execute();
      $fetch=$select->fetch();
      // echo $_SESSION["EMP_ID"][$i];
    ?>
    <tr>
      <td><center><?php echo "$fetch[US_NAME]";?></center></td>
      <td><center><?php echo "$fetch[TNAME]";?><?php echo "$fetch[FNAME]";?> <?php echo "$fetch[LNAME]";?></center></td>
      <td><center><?php echo "$fetch[PO_NAME]";?></center></td>
      <td><center><?php echo "$fetch[DP_NAME]";?></center></td>
      <td><center><?php echo "$fetch[FC_NAME]";?></center></td>
      <td><center><?php echo "$fetch[BR_ID]";?> : <?php echo "$fetch[BR_NAME]";?></center></td>
      <td><center><a target="_blank" href="print_pdf.php?EMP_ID=<?php echo $fetch["EMP_ID"];?>"><i class="fa fa-print" aria-hidden="true"></i></a></center></td>
      <td><center><a href="delete.php?Line=<?php echo $i;?>"><i class="fa fa-trash" aria-hidden="true"></i></a></center></td>
    </tr>
  <?php } } ?>
  </thead>
  </table>
</center>
</body>
</html>
