<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>EHONGMD</title>
  <?php
  error_reporting(0);
  // error_reporting(E_ALL);
  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">
      <!-- ค้นหา -->
      <!-- ตาราง -->
      <?php include 'act_search_2.php' ?>

      <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 class="text-warning">วันที่ <?php echo $calcdate; ?> ถึงวันที่ <?php echo $calcdate25; ?></p>
          </div>
          <div class="box-body">
            <div class="form-group">
              <table id="example" class="table table-striped table-bordered" style="width:100%">
                <thead style="white-space: nowrap">
                  <tr>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>No.</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>#สัญญา</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>ชื่อลูกค้า</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>เลขเครื่อง</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>บริษัทที่เป็นเจ้าของรถ</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>บริษัทที่บันทึกบัญชี</b></th>

                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>ประเภท</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>วันที่รับเงิน</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>เลขที่ใบเสร็จ</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>สถานะ</b></th>

                    <th colspan="5" style="background-color:red; color:#fff; text-align:center;"><b>รวม</b></th>
                    <th colspan="5" style="background-color:PaleGreen; color:#000; text-align:center;"><b>บริษัท มดแดงลิสซิ่ง จำกัด</b></th>
                    <th colspan="5" style="background-color:Orange; color:#000; text-align:center;"><b>บริษัท อีฮงฮอนด้า จำกัด</b></th>
                    <th colspan="5" style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b>บริษัท อีฮงมดแดงยามาฮ่า จำกัด</b></th>
                    <th colspan="5" style="background-color:GoldenRod; color:#000; text-align:center;"><b>บริษัท อีฮงมดแดงคาวาซากิ จำกัด</b></th>
                    <th colspan="5" style="background-color:Gainsboro; color:#000; text-align:center;"><b>บริษัท อีฮงพยัคฆ์</b></th>
                    <th colspan="5" style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b>บริษัท อีฮงมดแดงมอเตอร์ไบค์ จำกัด</b></th>
                    <th colspan="5" style="background-color:MediumTurquoise; color:#000; text-align:center;"><b>บริษัท มดแดงมอเตอร์เมค จำกัด</b></th>
                    <th colspan="5" style="background-color:PeachPuff; color:#000; text-align:center;"><b>บริษัท อีฮงมดแดงมอเตอร์ ลิส จำกัด</b></th>
                    <th colspan="5" style="background-color:Maroon; color:#fff; text-align:center;"><b>บริษัท มีสติมอเตอร์ จำกัด</b></th>
                    <th rowspan="2" style="background-color:black; color:#fff; text-align:center;"><b>หมายเหตุ</b></th>
                  </tr>
                  <tr>
                    <th rowspan="" style="background-color:red; color:#fff; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:red; color:#fff; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:red; color:#fff; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:red; color:#fff; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:red; color:#fff; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:PaleGreen; color:#000; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:PaleGreen; color:#000; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:PaleGreen; color:#000; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:PaleGreen; color:#000; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:PaleGreen; color:#000; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:Orange; color:#000; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:Orange; color:#000; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:Orange; color:#000; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:Orange; color:#000; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:Orange; color:#000; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:GoldenRod; color:#000; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:GoldenRod; color:#000; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:GoldenRod; color:#000; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:GoldenRod; color:#000; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:GoldenRod; color:#000; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:Gainsboro; color:#000; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:Gainsboro; color:#000; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:Gainsboro; color:#000; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:Gainsboro; color:#000; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:Gainsboro; color:#000; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:MediumTurquoise; color:#000; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:MediumTurquoise; color:#000; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:MediumTurquoise; color:#000; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:MediumTurquoise; color:#000; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:MediumTurquoise; color:#000; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:PeachPuff; color:#000; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:PeachPuff; color:#000; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:PeachPuff; color:#000; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:PeachPuff; color:#000; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:PeachPuff; color:#000; text-align:center;"><b>VAT</b></th>

                    <th rowspan="" style="background-color:Maroon; color:#fff; text-align:center;"><b>เงินเรียกเก็บ</b></th>
                    <th rowspan="" style="background-color:Maroon; color:#fff; text-align:center;"><b>ค่าพรบ</b></th>
                    <th rowspan="" style="background-color:Maroon; color:#fff; text-align:center;"><b>ค่านายหน้า</b></th>
                    <th rowspan="" style="background-color:Maroon; color:#fff; text-align:center;"><b>รายได้</b></th>
                    <th rowspan="" style="background-color:Maroon; color:#fff; text-align:center;"><b>VAT</b></th>
                  </tr>
                </thead>
                <tbody style="white-space: nowrap">
                  <?php
                  $sql = "SELECT a.bill_no as xbill_no,a.bill_date as xbill_date,*,a.rectime as xrectime from [EHONGDB].[dbo].[reg_billdata] a
                  left outer join(SELECT * FROM [EHONGDB].[dbo].[reg_bill]) b on(a.bill_no=b.bill_no)
                  left outer join(SELECT * FROM [EHONGDB].[dbo].[BRANCH]) c on (a.BR_ID=c.BR_ID)
                  left outer join(SELECT * FROM [EHONGDB].[dbo].[REG_GWORK]) d on(b.g_id=d.G_ID)
                  left outer join(SELECT BILL_NO as EBILL_NO,ACT_DATE,ACT_NO FROM [CONFIG].[dbo].[ACT_EXPOST]) e on(a.bill_no=e.EBILL_NO)
                  left outer JOIN(SELECT BILL_NO as sBILL_NO,ACT_STATUS,ACT_USDATE FROM CONFIG.dbo.ACT_STATUSEXPOST) dx on(a.bill_no=dx.sBILL_NO)
                  where a.status<>'V' and fee_no='11' and a.bill_date between '$DMY_1' and '$DMY_2'
                  order by a.rectime,a.br_id,a.bill_date";
                    // echo $sql;
                    $select=$conn->prepare($sql);
                    $select->execute();
                    $item = 1;
                    $B10 = '10.00';
                    $SUMFEE_SUMPRICE = '0';
                    $SUMFEE_PRICE = '0';
                    $SUMB10 = '0';
                    $SUM_x1 = '0';
                    $SUM_x2 = '0';
                    $SUM1_FEE_SUMPRICE = '0'; $SUM2_FEE_SUMPRICE = '0'; $SUM3_FEE_SUMPRICE = '0'; $SUM4_FEE_SUMPRICE = '0'; $SUM5_FEE_SUMPRICE = '0'; $SUM6_FEE_SUMPRICE = '0'; $SUM7_FEE_SUMPRICE = '0'; $SUM8_FEE_SUMPRICE = '0'; $SUM9_FEE_SUMPRICE = '0';
                    $SUM1_FEE_PRICE = '0'; $SUM2_FEE_PRICE = '0'; $SUM3_FEE_PRICE = '0'; $SUM4_FEE_PRICE = '0'; $SUM5_FEE_PRICE = '0'; $SUM6_FEE_PRICE = '0'; $SUM7_FEE_PRICE = '0'; $SUM8_FEE_PRICE = '0'; $SUM9_FEE_PRICE = '0';
                    $SUM1_B10 = '0'; $SUM2_B10 = '0'; $SUM3_B10 = '0'; $SUM4_B10 = '0'; $SUM5_B10 = '0'; $SUM6_B10 = '0'; $SUM7_B10 = '0'; $SUM8_B10 = '0'; $SUM9_B10 = '0';
                    $SUM1_SUM_1 = '0'; $SUM2_SUM_1 = '0'; $SUM3_SUM_1 = '0'; $SUM4_SUM_1 = '0'; $SUM5_SUM_1 = '0'; $SUM6_SUM_1 = '0'; $SUM7_SUM_1 = '0'; $SUM8_SUM_1 = '0'; $SUM9_SUM_1 = '0';
                    $SUM1_SUM_2 = '0'; $SUM2_SUM_2 = '0'; $SUM3_SUM_2 = '0'; $SUM4_SUM_2 = '0'; $SUM5_SUM_2 = '0'; $SUM6_SUM_2 = '0'; $SUM7_SUM_2 = '0'; $SUM8_SUM_2 = '0'; $SUM9_SUM_2 = '0';
                    while($fetch=$select->fetch()){
                      if ($fetch['BILL_DATE'] != '') {
                        $BILL_DATE1 = substr($fetch['BILL_DATE'],0,4)+543; $BILL_DATE2 = substr($fetch['BILL_DATE'],5,2); $BILL_DATE3 = substr($fetch['BILL_DATE'],8,2);
                        $BILL_DATE = $BILL_DATE3."/".$BILL_DATE2."/".$BILL_DATE1;
                      } else {
                        $BILL_DATE = '';
                      }
                    $FEE_PRICE = number_format($fetch['FEE_PRICE']-$B10,2);
                    // $FEE_SUMPRICE = number_format($fetch['FEE_SUMPRICE'],2);
                    // $FEE_SUMPRICE = number_format(350,2);
                    if ($fetch['FEE_SUMPRICE'] != '0') {
                      if ($fetch['CC_SIZE'] < '75') {
                        $FEE_SUMPRICE = number_format(190,2);
                      }
                      if ($fetch['CC_SIZE'] >= '75') {
                        $FEE_SUMPRICE = number_format(350,2);
                      }
                      if ($fetch['CC_SIZE'] > '125') {
                        $FEE_SUMPRICE = number_format(450,2);
                      }
                      if ($fetch['CC_SIZE'] > '150') {
                        $FEE_SUMPRICE = number_format(700,2);
                      }
                      $SUM_1 = number_format(($FEE_SUMPRICE-$B10-$FEE_PRICE)/1.07,2);
                      $SUM_2 = number_format(($SUM_1*0.07),2);
                      $SUMFEE_SUMPRICE += $FEE_SUMPRICE;
                      $SUM_x1 += $SUM_1;
                      $SUM_x2 += $SUM_2;
                    }
                    else {
                      $FEE_SUMPRICE = '';
                      $SUM_1 = '';
                      $SUM_2 = '';
                    }
                    if ($FEE_SUMPRICE != "") {
                      $COLOR = 'green';
                      $STATUS = 'ได้รับเงินแล้ว';
                    }
                    else {
                      $COLOR = 'red';
                      $STATUS = 'ยังไม่ได้รับเงิน';
                    }
                    include 'act_sum_1.php';
                    ?>
                  <tr>
                    <td style="background-color:; color:; text-align:right;"><?php echo number_format($item); ?>.</td>
                    <td style="background-color:; color:; text-align:;"><?php echo $fetch['CT_NO']; ?></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 $CROP_NAME_S; ?></td>
                    <td style="background-color:; color:blue; text-align:;"><?php echo $CROP_NAME; ?></td>

                    <td style="background-color:; color:red; text-align:;"><?php echo $FEE_STATUSX." : ".$FEE_STATUSX1; ?></td>
                    <td style="background-color:; color:; text-align:;"><?php echo $BILL_DATE; ?></td>
                    <!-- <td style="background-color:; color:; text-align:center;"> <a href="act_echoprint.php?ACT_NO=<?php echo $fetch['ACT_NO']; ?>" target="_blank" style="color:green;"><?php echo $fetch['ACT_NO']; ?></a></td> -->
                    <td style="background-color:; color:; text-align:;"><a class="text-red" href="http://192.168.10.51/xehong-linux/printrx.php?sid=sale&fid=payregbillnew&flg=1&bill_no=<?php echo $BILL_NO; ?>" target='_blank'><?php echo $fetch['BILL_NO']; ?></a></td>
                    <td rowspan="" style="background-color:; color:<?php echo $COLOR; ?>; text-align:;"><?php echo $STATUS; ?></td>

                    <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                    <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                    <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                    <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                    <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>

                    <?php
                    if ($CROP_NAME == "บริษัท มดแดงลิสซิ่ง จำกัด") {
                      $SUM1_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM1_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM1_B10 += str_replace(',','',$B10);
                      $SUM1_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM1_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท อีฮงฮอนด้า จำกัด") {
                      $SUM2_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM2_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM2_B10 += str_replace(',','',$B10);
                      $SUM2_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM2_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท อีฮงมดแดงยามาฮ่า จำกัด") {
                      $SUM3_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM3_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM3_B10 += str_replace(',','',$B10);
                      $SUM3_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM3_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท อีฮงคาวาซากิ") {
                      $SUM4_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM4_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM4_B10 += str_replace(',','',$B10);
                      $SUM4_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM4_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท อีฮงพยัคฆ์") {
                      $SUM5_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM5_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM5_B10 += str_replace(',','',$B10);
                      $SUM5_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM5_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท อีฮงมดแดงมอเตอร์ไบค์ จำกัด") {
                      $SUM6_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM6_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM6_B10 += str_replace(',','',$B10);
                      $SUM6_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM6_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท มดแดงมอเตอร์เมค จำกัด") {
                      $SUM7_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM7_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM7_B10 += str_replace(',','',$B10);
                      $SUM7_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM7_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท อีฮงมดแดงมอเตอร์ ลิส จำกัด") {
                      $SUM8_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM8_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM8_B10 += str_replace(',','',$B10);
                      $SUM8_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM8_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <?php
                    if ($CROP_NAME == "บริษัท มีสติมอเตอร์ จำกัด") {
                      $SUM9_FEE_SUMPRICE += str_replace(',','',$FEE_SUMPRICE);
                      $SUM9_FEE_PRICE += str_replace(',','',$FEE_PRICE);
                      $SUM9_B10 += str_replace(',','',$B10);
                      $SUM9_SUM_1 += str_replace(',','',$SUM_1);
                      $SUM9_SUM_2 += str_replace(',','',$SUM_2);
                    ?>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_SUMPRICE; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $FEE_PRICE; ?></td>
                      <td style="background-color:; color:green; text-align:;"><?php echo $B10; ?></td>
                      <td style="background-color:; color:blue; text-align:;"><?php echo $SUM_1; ?></td>
                      <td style="background-color:; color:red; text-align:;"><?php echo $SUM_2; ?></td>
                    <?php } else { ?>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                      <td style="background-color:; color:; text-align:center;"></td>
                    <?php } ?>

                    <td style="background-color:; color:; text-align:center;"></td>
                  </tr>
                <?php $item++; } ?>
                </tbody>
                <tfoot>
                  <td colspan="10" style="background-color:black; color:#fff; text-align:center;"><b>รวม</b></td>

                  <td style="background-color:red; color:#fff; text-align:center;"><b><?php echo number_format($SUMFEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:red; color:#fff; text-align:center;"><b><?php echo number_format($SUMFEE_PRICE,2); ?></b></td>
                  <td style="background-color:red; color:#fff; text-align:center;"><b><?php echo number_format($SUMB10,2); ?></b></td>
                  <td style="background-color:red; color:#fff; text-align:center;"><b><?php echo number_format($SUM_x1,2); ?></b></td>
                  <td style="background-color:red; color:#fff; text-align:center;"><b><?php echo number_format($SUM_x2,2); ?></b></td>

                  <td style="background-color:PaleGreen; color:#000; text-align:center;"><b><?php echo number_format($SUM1_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:PaleGreen; color:#000; text-align:center;"><b><?php echo number_format($SUM1_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:PaleGreen; color:#000; text-align:center;"><b><?php echo number_format($SUM1_B10,2); ?></b></td>
                  <td style="background-color:PaleGreen; color:#000; text-align:center;"><b><?php echo number_format($SUM1_SUM_1,2); ?></b></td>
                  <td style="background-color:PaleGreen; color:#000; text-align:center;"><b><?php echo number_format($SUM1_SUM_2,2); ?></b></td>

                  <td style="background-color:Orange; color:#000; text-align:center;"><b><?php echo number_format($SUM2_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:Orange; color:#000; text-align:center;"><b><?php echo number_format($SUM2_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:Orange; color:#000; text-align:center;"><b><?php echo number_format($SUM2_B10,2); ?></b></td>
                  <td style="background-color:Orange; color:#000; text-align:center;"><b><?php echo number_format($SUM2_SUM_1,2); ?></b></td>
                  <td style="background-color:Orange; color:#000; text-align:center;"><b><?php echo number_format($SUM2_SUM_2,2); ?></b></td>

                  <td style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b><?php echo number_format($SUM3_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b><?php echo number_format($SUM3_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b><?php echo number_format($SUM3_B10,2); ?></b></td>
                  <td style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b><?php echo number_format($SUM3_SUM_1,2); ?></b></td>
                  <td style="background-color:DeepSkyBlue; color:#000; text-align:center;"><b><?php echo number_format($SUM3_SUM_2,2); ?></b></td>

                  <td style="background-color:GoldenRod; color:#000; text-align:center;"><b><?php echo number_format($SUM4_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:GoldenRod; color:#000; text-align:center;"><b><?php echo number_format($SUM4_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:GoldenRod; color:#000; text-align:center;"><b><?php echo number_format($SUM4_B10,2); ?></b></td>
                  <td style="background-color:GoldenRod; color:#000; text-align:center;"><b><?php echo number_format($SUM4_SUM_1,2); ?></b></td>
                  <td style="background-color:GoldenRod; color:#000; text-align:center;"><b><?php echo number_format($SUM4_SUM_2,2); ?></b></td>

                  <td style="background-color:Gainsboro; color:#000; text-align:center;"><b><?php echo number_format($SUM5_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:Gainsboro; color:#000; text-align:center;"><b><?php echo number_format($SUM5_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:Gainsboro; color:#000; text-align:center;"><b><?php echo number_format($SUM5_B10,2); ?></b></td>
                  <td style="background-color:Gainsboro; color:#000; text-align:center;"><b><?php echo number_format($SUM5_SUM_1,2); ?></b></td>
                  <td style="background-color:Gainsboro; color:#000; text-align:center;"><b><?php echo number_format($SUM5_SUM_2,2); ?></b></td>

                  <td style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b><?php echo number_format($SUM6_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b><?php echo number_format($SUM6_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b><?php echo number_format($SUM6_B10,2); ?></b></td>
                  <td style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b><?php echo number_format($SUM6_SUM_1,2); ?></b></td>
                  <td style="background-color:RebeccaPurple; color:#fff; text-align:center;"><b><?php echo number_format($SUM6_SUM_2,2); ?></b></td>


                  <td style="background-color:MediumTurquoise; color:#000; text-align:center;"><b><?php echo number_format($SUM7_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:MediumTurquoise; color:#000; text-align:center;"><b><?php echo number_format($SUM7_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:MediumTurquoise; color:#000; text-align:center;"><b><?php echo number_format($SUM7_B10,2); ?></b></td>
                  <td style="background-color:MediumTurquoise; color:#000; text-align:center;"><b><?php echo number_format($SUM7_SUM_1,2); ?></b></td>
                  <td style="background-color:MediumTurquoise; color:#000; text-align:center;"><b><?php echo number_format($SUM7_SUM_2,2); ?></b></td>


                  <td style="background-color:PeachPuff; color:#000;"><b><?php echo number_format($SUM8_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:PeachPuff; color:#000;"><b><?php echo number_format($SUM8_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:PeachPuff; color:#000;"><b><?php echo number_format($SUM8_B10,2); ?></b></td>
                  <td style="background-color:PeachPuff; color:#000;"><b><?php echo number_format($SUM8_SUM_1,2); ?></b></td>
                  <td style="background-color:PeachPuff; color:#000;"><b><?php echo number_format($SUM8_SUM_2,2); ?></b></td>

                  <td style="background-color:Maroon; color:#fff;"><b><?php echo number_format($SUM9_FEE_SUMPRICE,2); ?></b></td>
                  <td style="background-color:Maroon; color:#fff;"><b><?php echo number_format($SUM9_FEE_PRICE,2); ?></b></td>
                  <td style="background-color:Maroon; color:#fff;"><b><?php echo number_format($SUM9_B10,2); ?></b></td>
                  <td style="background-color:Maroon; color:#fff;"><b><?php echo number_format($SUM9_SUM_1,2); ?></b></td>
                  <td style="background-color:Maroon; color:#fff;"><b><?php echo number_format($SUM9_SUM_2,2); ?></b></td>

                  <td colspan="" style="background-color:black; color:#fff; text-align:center;"><b></b></td>
                </tfoot>
            </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'; ?>
<?php include 'scroll0.php' ?>
</body>
</html>
