<?php // error_reporting(0); ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>EHONGMD | ตรวจสอบ ทะเบียนภาษี, พ.ร.บ. ไกล้หมดอายุ</title>
  <link rel="shortcut icon" href="dist/img/logo_1.png" />
  <?php
    include '_plugin.php';
    include '_connect.php';
  ?>
</head>
<body class="hold-transition skin-red sidebar-mini">
<div class="wrapper">
  <?php
    include '_header.php';
    include '_menu.php';
  ?>
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
      <!-- ค้นหา -->
      <!-- ตาราง -->
      <script src="bower_components/jquery/dist/jquery.min.js"></script>
      <script language="JavaScript">
      	function ClickCheckAll(vol)
      	{

      		var i=1;
      		for(i=1;i<=document.frmMain.hdnCount.value;i++)
      		{
      			if(vol.checked == true)
      			{
      				eval("document.frmMain.chk"+i+".checked=true");
      			}
      			else
      			{
      				eval("document.frmMain.chk"+i+".checked=false");
      			}
      		}
      	}

      	function onDelete()
      	{
      		if(confirm('ต้องการส่งข้อมูลที่เลือกนี้หรือไม่?')==true)
      		{
      			return true;
      		}
      		else
      		{
      			return false;
      		}
      	}
      </script>
      <?php
        include 'expiration.date.sum.php'
      ?>
      <div class="col-md-12">
        <div class="box box-success">
          <div class="box-header">
            <h3 class="box-title"><p class="text-success">ตรวจสอบ "<?php echo $name; ?>"</p></h3>
          </div>
          <div class="box-body">
            <div class="form-group">
              <!-- example31 -->
              <div style="overflow-x:auto;">
              <form class="" action="expiration.date.link.php" method="POST" name="frmMain" OnSubmit="return onDelete();" target="_blank">
              <input type="submit" name="expiration.date.link.php" class="btn btn-success" value="ส่งข้อมูล"> <hr>
              <table id="example" class="table table-striped table-bordered" style="width:100%;">
                <thead style="white-space: nowrap">
                  <tr >
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">NO.</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;"><input name="CheckAll" type="checkbox" id="CheckAll" value="Y" onClick="ClickCheckAll(this);"></th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">วันที่</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">เลขที่สัญญา</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">ชื่อ-สกุล ลูกค้า</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">เลขเครื่อง</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">เลขตัวถัง</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">เลขทะเบียน</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">ทะเบียนหมดอายุ</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">พ.ร.บ.</th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;">พ.ร.บ. หมดอายุ</th>
                  </tr>
                </thead>
                <tbody style="white-space: nowrap">
                  <?php
                  $sql = "$sql_ex";
                  // echo $sql;
                  $select=$conn->prepare($sql);
                  $select->execute();
                  $item = 1;
                  $i = 0;
                  while($fetch=$select->fetch()){
                    $i++;
                    if ($status == "1" || $status == "s1" || $status == "3" || $status == "s3") {
                      $REG_EXPIRE1 = substr($fetch['REG_EXPIRE'],0,4)+543; $REG_EXPIRE2 = substr($fetch['REG_EXPIRE'],5,2); $REG_EXPIRE3 = substr($fetch['REG_EXPIRE'],8,2);
                      $date = $REG_EXPIRE3."/".$REG_EXPIRE2."/".$REG_EXPIRE1;
                    }
                    if ($status == "2" || $status == "s2" || $status == "4" || $status == "s4") {
                      $PLC_EXPIRE1 = substr($fetch['PLC_EXPIRE'],0,4)+543; $PLC_EXPIRE2 = substr($fetch['PLC_EXPIRE'],5,2); $PLC_EXPIRE3 = substr($fetch['PLC_EXPIRE'],8,2);
                      $date = $PLC_EXPIRE3."/".$PLC_EXPIRE2."/".$PLC_EXPIRE1;
                    }
                    if ($fetch['REG_EXPIRE'] != '') {
                      $REG_EXPIRE1 = substr($fetch['REG_EXPIRE'],0,4)+543; $REG_EXPIRE2 = substr($fetch['REG_EXPIRE'],5,2); $REG_EXPIRE3 = substr($fetch['REG_EXPIRE'],8,2);
                      $REG_EXPIRE = $REG_EXPIRE3."/".$REG_EXPIRE2."/".$REG_EXPIRE1;
                    } else {
                      $REG_EXPIRE = "";
                    }
                    if ($fetch['PLC_EXPIRE'] != '') {
                      $PLC_EXPIRE1 = substr($fetch['PLC_EXPIRE'],0,4)+543; $PLC_EXPIRE2 = substr($fetch['PLC_EXPIRE'],5,2); $PLC_EXPIRE3 = substr($fetch['PLC_EXPIRE'],8,2);
                      $PLC_EXPIRE = $PLC_EXPIRE3."/".$PLC_EXPIRE2."/".$PLC_EXPIRE1;
                    } else {
                      $PLC_EXPIRE = "";
                    }
                  ?>
                  <tr>
                    <td style="background-color:; color:; text-align:;"><?php echo number_format($item); ?>.</td>
                    <td style="background-color:; color:; text-align:;">
                      <input type="checkbox" name="chkDel[]" id="chk<?php echo $i;?>" value="<?php echo $fetch['CT_NO'];?>">
                    </td>
                    <td style="background-color:; color:red; text-align:;"><?php echo $date; ?></td>
                    <td style="background-color:; color:; text-align:;"> <a href="http://192.168.10.51/xehong-linux/index.php?sid=hps&fid=view&ct_no=<?php echo $fetch['CT_NO']; ?>" target="_blank"><?php echo $fetch['CT_NO']; ?></a></td>
                    <td style="background-color:; color:; text-align:;"><?php echo $fetch['PS_NAME']; ?></td>
                    <td style="background-color:; color:; text-align:;"><?php echo $fetch['SERIAL_NO']; ?></td>
                    <td style="background-color:; color:; text-align:;"><?php echo $fetch['PSERIAL_NO']; ?></td>
                    <td style="background-color:; color:Blue; text-align:;"><?php echo $fetch['REG_NO']; ?></td>
                    <td style="background-color:; color:Blue; text-align:;"><?php echo $REG_EXPIRE; ?></td>
                    <td style="background-color:; color:Blue; text-align:;"><?php echo $fetch['XPLC_NO']; ?></td>
                    <td style="background-color:; color:Blue; text-align:;"><?php echo $PLC_EXPIRE; ?></td>
                  </tr>
                  <?php $item++; } ?>
                </tbody>
            </table>
            <input type="hidden" name="hdnCount" value="<?php echo $i;?>">
            </form>
            </div>
            </div>
          </div>
        </div>
      </div>
      </div>
    </section>
  </div>
</div>

<?php
// include '_footer.php';
// include '_form.php';
?>
<div class="control-sidebar-bg"></div>
<?php
  include '_script_2.php';
  include 'scroll.php';
?>
</body>
</html>
