<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>EHONGMD</title>
  <?php
  include '_plugin.php';
  include '_connect.php';
  ?>
  <script src="bower_components/jquery/dist/jquery.min.js"></script>

</head>
<body class="hold-transition skin-blue sidebar-mini">

<style media="screen">
div.ex1 {
  height: 550px;
  overflow-y: scroll;
}
table{
  /* font: 12px; */
}
</style>

<div class="wrapper">

<?php
include '_header.php';
include '_menu.php';
?>
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
      <!-- ค้นหา -->
      <?php
      $CROP_NO_1 = $_POST['CROP_NO_1'];
      $DMY_11 = $_POST['DMY_1']." 00:00:00.000";
      $DMY_21 = $_POST['DMY_2']." 00:00:00.000";
      ?>
      <?php
      include '_connect.php';
      $_month_name = array("01"=>"มกราคม",  "02"=>"กุมภาพันธ์",  "03"=>"มีนาคม",
         "04"=>"เมษายน",  "05"=>"พฤษภาคม",  "06"=>"มิถุนายน",
         "07"=>"กรกฎาคม",  "08"=>"สิงหาคม",  "09"=>"กันยายน",
         "10"=>"ตุลาคม", "11"=>"พฤศจิกายน",  "12"=>"ธันวาคม");
      $m = date('m');
      include 'reg_search_1.3.php'
      ?>
      <?php
      $CHK_BERG1 = substr($DMY_11,0,4)+543; $CHK_BERG2 = substr($DMY_11,5,2); $CHK_BERG3 = substr($DMY_11,8,2);
      $CHK_BERG12a = $CHK_BERG3." ". $_month_name[$CHK_BERG2]." ".$CHK_BERG1;

      $CHK_BERG11 = substr($DMY_21,0,4)+543; $CHK_BERG21 = substr($DMY_21,5,2); $CHK_BERG31 = substr($DMY_21,8,2);
      $CHK_BERG12b = " ถึงวันที่ ".$CHK_BERG31." ". $_month_name[$CHK_BERG21]." ".$CHK_BERG11;

      if ($CROP_NO_1 != '') {
        $CROP_NO_11 = "and c.REG_CROPNO = '$CROP_NO_1'";
      }
      if ($CROP_NO_1 == '') {
        $CROP_NO_11 = "";
      }

      $sql_CNO = "SELECT * FROM EHONGDB.dbo.CROPORATION WHERE CROP_NO = '$CROP_NO_1' ";
      $select_CNO=$conn->prepare($sql_CNO);
      $select_CNO->execute();
      $fetch_CNO=$select_CNO->fetch();
      // $CROP_NO_S = $fetch_CNO['CROP_NO'];
      if ($fetch_CNO['CROP_NO'] == '') { $CROP_NO_12 = 'ทั้งหมด'; }
      else { $CROP_NO_12 = $fetch_CNO['CROP_NAME']; }
      $code = "a.CHK_BERG BETWEEN '$DMY_11' and '$DMY_21' $CROP_NO_11 ";
      $code2 = "and a.FEE_NO = '00' ";

      ?>
      <!-- ตาราง -->
      <div class="col-md-12">
        <div class="box box-success">
          <div class="box-header">
            <h3 class="box-title"><p class="text-success">รายงานการจ่ายเงินเจ้าหน้าที่ขนส่ง</p></h3>
            <p><?php echo "บริษัท : ".$CROP_NO_12;?><br> <?php echo "สำหรับงวด เริ่ม ".$CHK_BERG12a.$CHK_BERG12b; ?></p>
          </div>
          <div class="box-body">
            <div class="form-group ex1" style="overflow-x:auto; overflow-y:10%;">
              <table id="example31" class="table table-striped table-bordered" style="width:100%" >
                <thead>
                <tr style="white-space: nowrap;">
                  <td width="" rowspan="3" > <div align="center"><b>No.</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>วันที่จ่ายเงิน</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>เลขที่เช็ค</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>เลขที่บัญชีที่จ่ายเงิน</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>วันที่ได้รับเล่มทะเบียน</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>เลขที่เอกสารจ่ายเงิน</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>ชื่อลูกค้า</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>เลขที่เครื่อง</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>ยี่ห้อรถ</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>บริษัท</div></td>
                  <td width="" rowspan="3" > <div align="center"><b>พนักงานมดแดง</div></td>
                  <td width="" colspan="22" align="center" class="" style="background-color:green; color:#fff;"> <div align="center"><b>ประเภทค่าใช้จ่ายจดทะเบียน</div></td>
                  <td width="" rowspan="3" style="background-color:ForestGreen; color:#fff;"><b>รวม</b></td>
                  <td width="" rowspan="3" > <div align="center"><b>หมายเหตุ</b></div></td>
                </tr>
                <tr style="white-space: nowrap;">
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:red; color:#fff;"> <div align="center"><b>มหาสารคาม</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:DarkCyan; color:#fff;"> <div align="center"><b>นครราชสีมา</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:SaddleBrown; color:#fff;"> <div align="center"><b>หนองบัวลำภู</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:Purple; color:#fff;"> <div align="center"><b>บุรีรัมย์</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:LightSlateGrey; color:#fff;"> <div align="center"><b>ชัยภูมิ</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:red; color:#fff;"> <div align="center"><b>ขอนแก่น</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:DarkCyan; color:#fff;"> <div align="center"><b>ร้อยเอ็ด</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:SaddleBrown; color:#fff;"> <div align="center"><b>การฬสินธุ์</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:Purple; color:#fff;"> <div align="center"><b>เลย</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:LightSlateGrey; color:#fff;"> <div align="center"><b>สุรินทร์</div></td>
                  <td width="" colspan="2" align="center" class="sticky0" style="background-color:red; color:#fff;"> <div align="center"><b>อุดรธานี</div></td>
                </tr>
                <tr style="white-space: nowrap;">
                  <td align="center" class="sticky1" style="background-color:red; color:#fff;">นายสุพจน์ ยอดสวาท</td>
                  <td align="center" class="sticky1" style="background-color:red; color:#fff;">นายชนะชัย เตียวปิยะกุล</td>
                  <td align="center" class="sticky1" style="background-color:DarkCyan; color:#fff;">นายบรรจบ บุญเหาะ</td>
                  <td align="center" class="sticky1" style="background-color:DarkCyan; color:#fff;">นายเจต วรรณบวร</td>
                  <td align="center" class="sticky1" style="background-color:SaddleBrown; color:#fff;">นายชุมพล เดชะหุล</td>
                  <td align="center" class="sticky1" style="background-color:SaddleBrown; color:#fff;">นายศราวุธ เวชกุล</td>
                  <td align="center" class="sticky1" style="background-color:Purple; color:#fff;">นายสมเกียรติ เสทือนวงษ์</td>
                  <td align="center" class="sticky1" style="background-color:Purple; color:#fff;">นางสุวคนธ์ นิลศิริ</td>
                  <td align="center" class="sticky1" style="background-color:LightSlateGrey; color:#fff;">นายสมบัติ สุดชารี</td>
                  <td align="center" class="sticky1" style="background-color:LightSlateGrey; color:#fff;">นายสาคร พิมชาติ</td>
                  <td align="center" class="sticky1" style="background-color:red; color:#fff;">นายณัฐณชัย ทองคำ</td>
                  <td align="center" class="sticky1" style="background-color:red; color:#fff;">นางประภัสสร อัคพิน</td>
                  <td align="center" class="sticky1" style="background-color:DarkCyan; color:#fff;">นายสุริยา ตาลห่อ</td>
                  <td align="center" class="sticky1" style="background-color:DarkCyan; color:#fff;">นางสาวช่อชบา พุ่มดอกไม้</td>
                  <td align="center" class="sticky1" style="background-color:SaddleBrown; color:#fff;">นายพรชัย จันทพรม</td>
                  <td align="center" class="sticky1" style="background-color:SaddleBrown; color:#fff;">นางสาคร ถิ่นละออ</td>
                  <td align="center" class="sticky1" style="background-color:Purple; color:#fff;">นายปัญญา นันทะคำ</td>
                  <td align="center" class="sticky1" style="background-color:Purple; color:#fff;">นางรัชดาภรณ์ สุขสมกมล</td>
                  <td align="center" class="sticky1" style="background-color:LightSlateGrey; color:#fff;">นางธวัลรัตน์ สุภาพรม</td>
                  <td align="center" class="sticky1" style="background-color:LightSlateGrey; color:#fff;">นางธวัลรัตน์ สุภาพรม</td>
                  <td align="center" class="sticky1" style="background-color:red; color:#fff;">นางพิมพ์ชนา บุญตา</td>
                  <td align="center" class="sticky1" style="background-color:red; color:#fff;">นางพิมพ์ชนา บุญตา</td>
                </tr>
                </thead>
                <tbody style="white-space: nowrap;">
                  <?php
                  $sql = "SELECT DISTINCT a.BILL_NO, a.CHK_BERG as cb_date, a.BG_PROV as prov_no1, a.FEE_COST as FEE_COST1, a.BR_ID,
                  b.PR_NAME, b.PR_CODE,
                  c.REG_NO, c.REG_CROPNO, c.FEE_NO, c.REG_DATE1, c.REG_BREG, c.REG_BILLBREG, c.REG_BILLBREGTRANSPORT, c.REG_BILLUSER1, c.REG_BILLUSER2, c.REG_PROVINCE, c.REG_USERBREG,
                  d.BILL_NO, d.PS_NAME, d.CROP_NAME, d.BRAND_NAME, d.SERIAL_NO, d.PSERIAL_NO,
                  e.tsp_no, e.tsp_open, e.tsp_registrar1, e.tsp_registrar,
                  f.FEE_NO, f.FEE_NAME,
                  g.xcorp_no,
                  h.BR_ID, h.BR_NAME
                  FROM EHONGDB.dbo.REG_BILLDATADOCUMENT a
                  LEFT OUTER JOIN (SELECT * FROM [EHONGDB].[dbo].[PROV]) b ON (a.BG_PROV = b.PR_CODE)
                  LEFT OUTER JOIN (SELECT * FROM [CONFIG].[dbo].[REG_BILLDATA_V1]) c ON (a.BILL_NO=c.BILL_NO) AND (a.FEE_NO=c.FEE_NO)
                  LEFT OUTER JOIN (SELECT * FROM [EHONGDB].[dbo].[REG_BILL]) d ON (a.BILL_NO=d.BILL_NO)
                  LEFT OUTER JOIN (SELECT * FROM [CONFIG].[dbo].[tsp_transport]) e ON (a.BG_PROV=e.tsp_no)
                  LEFT OUTER JOIN (SELECT * FROM [EHONGDB].[dbo].[REG_FEEDATA]) f ON (a.FEE_NO=f.FEE_NO)
                  LEFT OUTER JOIN (SELECT * FROM [EHONGDB].[dbo].[REG_BILLDATA]) g ON (a.BILL_NO=g.BILL_NO)
                  LEFT OUTER JOIN (SELECT * FROM [EHONGDB].[dbo].[BRANCH]) h ON (a.BR_ID=h.BR_ID)
                  WHERE $code and (a.status<>'V') and (a.chkdate2 is not null and a.chkstatus2='C') and (a.acpdate is not null) and (a.chk_berg is not null) and c.REG_STATUS = 'Y'
                  and (a.FEE_NO = 02)
                  ORDER BY b.PR_CODE,a.CHK_BERG";
                  $select=$conn->prepare($sql);
                  $select->execute();
                  // echo $sql;
                  $item = 1;
                  $FEE_NO_02 = "0"; $FEE_NO_XX = "0";
                  $REG_BU130 = 0; $REG_BU230 = 0; $REG_BU330 = 0;
                  $REG_BU131 = 0; $REG_BU231 = 0; $REG_BU331 = 0;
                  $REG_BU132 = 0; $REG_BU232 = 0; $REG_BU332 = 0;
                  $REG_BU136 = 0; $REG_BU236 = 0; $REG_BU336 = 0;
                  $REG_BU139 = 0; $REG_BU239 = 0; $REG_BU339 = 0;
                  $REG_BU140 = 0; $REG_BU240 = 0; $REG_BU340 = 0;
                  $REG_BU141 = 0; $REG_BU241 = 0; $REG_BU341 = 0;
                  $REG_BU142 = 0; $REG_BU242 = 0; $REG_BU342 = 0;
                  $REG_BU144 = 0; $REG_BU244 = 0; $REG_BU344 = 0;
                  $REG_BU145 = 0; $REG_BU245 = 0; $REG_BU345 = 0;
                  $REG_BU146 = 0; $REG_BU246 = 0; $REG_BU346 = 0;
                  $REG_BILLBREGTRANSPORT = 0;
                  while($fetch=$select->fetch())
                  {
                    if ($fetch['cb_date'] != '') {
                      $CHK_BERG1 = substr($fetch['cb_date'],0,4)+543; $CHK_BERG2 = substr($fetch['cb_date'],5,2); $CHK_BERG3 = substr($fetch['cb_date'],8,2);
                      $CHK_BERG = $CHK_BERG3." ". $_month_name[$CHK_BERG2]." ".$CHK_BERG1;
                    } else {
                      $CHK_BERG = '';
                    }
                    $FEE_NO_XX += str_replace( ',', '', $fetch['REG_BILLBREG']);
                  ?>
                  <tr>
                    <td style="text-align: center;"><?=$item."."?></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><?php echo $CHK_BERG; ?></td>
                    <td class="text-blue"><?php echo  $fetch['BILL_NO']; ?></td>
                    <td><?php echo $fetch['PS_NAME']; ?></td>
                    <td><?php echo $fetch['PSERIAL_NO']; ?></td>
                    <td><?php echo $fetch['BRAND_NAME']; ?></td>
                    <td><?php echo $fetch['CROP_NAME']; ?></td>
                    <td><?php echo $fetch['tsp_open']; ?></td>
                    <!-- มหาสารคาม -->
                    <?php if ($fetch['REG_PROVINCE'] == '44') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU144 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU244 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU344 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:red;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:red;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:red;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- นครราชสีมา -->
                    <?php if ($fetch['REG_PROVINCE'] == '30') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU130 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU230 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU330 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:DarkCyan;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:DarkCyan;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:DarkCyan;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- หนองบัวลำภู -->
                    <?php if ($fetch['REG_PROVINCE'] == '39') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU139 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU239 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU339 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:SaddleBrown;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:SaddleBrown;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:SaddleBrown;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- บุรีรัมย์ -->
                    <?php if ($fetch['REG_PROVINCE'] == '31') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU131 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU231 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU331 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:Purple;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:Purple;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:Purple;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- ชัยภูมิ -->
                    <?php if ($fetch['REG_PROVINCE'] == '36') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU136 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU236 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU336 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:LightSlateGrey;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:LightSlateGrey;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:LightSlateGrey;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- ขอนแก่น -->
                    <?php if ($fetch['REG_PROVINCE'] == '40') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU140 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU240 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU340 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:red;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:red;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:red;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- ร้อยเอ็ด -->
                    <?php if ($fetch['REG_PROVINCE'] == '45') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU145 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU245 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU345 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:DarkCyan;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:DarkCyan;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:DarkCyan;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- การฬสินธุ์ -->
                    <?php if ($fetch['REG_PROVINCE'] == '46') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU146 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU246 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU346 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:SaddleBrown;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:SaddleBrown;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:SaddleBrown;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- เลย -->
                    <?php if ($fetch['REG_PROVINCE'] == '42') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU142 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU242 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU342 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:Purple;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:Purple;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:Purple;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- สุรินทร์ -->
                    <?php if ($fetch['REG_PROVINCE'] == '32') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU132 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU232 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU332 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:LightSlateGrey;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:LightSlateGrey;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:LightSlateGrey;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <!-- อุดรธานี -->
                    <?php if ($fetch['REG_PROVINCE'] == '41') { $REG_BILLUSER1 = $fetch['REG_BILLUSER1']; $REG_BILLUSER2 = $fetch['REG_BILLUSER2']; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2;
                      $REG_BU141 += str_replace( ',', '', $fetch['REG_BILLUSER1']); $REG_BU241 += str_replace( ',', '', $fetch['REG_BILLUSER2']); $REG_BU341 += str_replace( ',', '', $REG_SUMBILL); ?>
                    <td align="center" style="color:red;"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center" style="color:red;"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center" style="color:red;"><b><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } else { $REG_BILLUSER1 = '0.00'; $REG_BILLUSER2 = '0.00'; $REG_SUMBILL = $REG_BILLUSER1+$REG_BILLUSER2; ?>
                    <td align="center"><?php echo $REG_BILLUSER1; ?></td>
                    <td align="center"><?php echo $REG_BILLUSER2; ?></td>
                    <!-- <td align="center"><?php echo number_format($REG_SUMBILL,2); ?></td> -->
                    <?php } ?>
                    <td align="center" style="background-color:ForestGreen; color:#fff;"><b><?php echo $fetch['REG_BILLBREGTRANSPORT']; ?></td>
                    <td><center></center></td>
                  </tr>
                  <?php
                    $REG_BILLBREGTRANSPORT += str_replace( ',', '', $fetch['REG_BILLBREGTRANSPORT']);
                    $item++; }
                  ?>
                  </tbody>
                  <tbody>
                  <!-- <tr>
                    <td><center><b>รวม</center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td><center></center></td>
                    <td width=""><b><center><?php echo number_format($FEE_NO_02,2) ?></center></b></td>
                    <td style="text-align:right" class="text-green" width=""><b><?php echo number_format($FEE_NO_XX,2) ?></b></td>
                    <td><center></center></td>
                  </tr> -->
                  <tr>
                    <tr>
                     <td align="center" class="sticky-col first-col" style="background-color:DodgerBlue; color:#fff;" colspan="11">รวม</td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU144,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU244,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU130,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU230,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU139,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU239,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU131,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU231,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU136,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU236,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU140,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU240,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU145,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU245,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU146,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU246,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU142,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU242,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU132,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU232,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU141,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"><b><?php echo number_format($REG_BU241,2); ?></td>
                     <td align="center" style="background-color:ForestGreen; color:#fff;"><b><?php echo number_format($REG_BILLBREGTRANSPORT,2); ?></td>
                     <td align="center" style="background-color:DodgerBlue; color:#fff;"></td>
                  </tr>
                  </tr>
                </tbody>
              </table>
            </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'; ?>
<!-- <script>
    var myApp = new function () {
        this.printTable = function () {
            var tab = document.getElementById('tab');
            var win = window.open('', '', 'height=700,width=1200');
            win.document.write(tab.outerHTML);
            win.document.close();
            win.print();
            // tab.style.font = "bold 2px arial,serif";
            // tab.style.backgroundColor = "#FF0000";
            // win.close();
        }
    }
</script> -->
</body>
</html>
