<!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';
?>
</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_1.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 $calcdate2; ?></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="" style="background-color:black; color:#fff; text-align:center;"><b>No.</b></th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;"><b>บริษัทที่จำหน่าย</b></th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;"><b>จำนวนคัน</b></th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;"><b>ค่าใช้จ่ายพรบที่เบิก (บาท)</b></th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;"><b>เลขที่เช็ค</b></th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;"><b>หมายเหตุ</b></th>
                    <th rowspan="" style="background-color:black; color:#fff; text-align:center;"><b>ใบรับรองแทนใบเสร็จรับเงิน</b></th>
                  </tr>
                </thead>
                <tbody style="white-space: nowrap">
                  <?php
                   $sql = "SELECT
                       CROP_NAME as AX
                      ,COUNT(CROP_NAME) as BX
                      ,SUM(FEE_PRICE) as CX
                    from [EHONGDB].[dbo].[reg_billdata] a
                    left outer join [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)
                    where a.status<>'V' and fee_no='11'
                    and a.bill_date between '$DMY_1' and '$DMY_2'
                    GROUP by CROP_NAME
                    ORDER by CROP_NAME";
                  // echo $sql;
                  $select=$conn->prepare($sql);
                  $select->execute();
                  $item = 1;
                  $BX1 = 0;
                  $CX1 = 0;
                  while($fetch=$select->fetch()){
                  $BX1  += $fetch['BX'];
                  $CX1  += $fetch['CX'];
                  ?>
                  <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['AX']; ?></td>
                    <td style="background-color:; color:red; text-align:center;"><?php echo number_format($fetch['BX']); ?></td>
                    <td style="background-color:; color:blue; text-align:right;"><?php echo number_format($fetch['CX'],2); ?></td>
                    <td style="background-color:; color:; text-align:center;"><?php ?></td>
                    <td style="background-color:; color:; text-align:center;"><?php ?></td>
                    <td style="background-color:; color:; text-align:center;"><a href="#" class="text-red">พิมพ์</a></td>
                  </tr>
                  <?php $item++; } ?>
                </tbody>
                <tbody>
                <tr>
                  <td style="background-color:; color:; text-align:right;"></td>
                  <td style="background-color:; color:; text-align:;">ค่าเครื่องเขียน พ.ร.บ.</td>
                  <td style="background-color:; color:red; text-align:center;"><?php //echo number_format($fetch['BX']); ?></td>
                  <td style="background-color:; color:blue; text-align:right;"><?php //echo number_format($fetch['CX'],2); ?></td>
                  <td style="background-color:; color:; text-align:center;"><?php  ?></td>
                  <td style="background-color:; color:; text-align:center;"><?php ?></td>
                  <td style="background-color:; color:; text-align:center;"><a href="#" class="text-red">พิมพ์</a></td>
                </tr>
                <tr>
                  <td style="background-color:; color:; text-align:right;"></td>
                  <td style="background-color:; color:; text-align:;">รายได้ค่าเครื่องเขียน</td>
                  <td style="background-color:; color:red; text-align:center;"><?php //echo number_format($fetch['BX']); ?></td>
                  <td style="background-color:; color:blue; text-align:right;"><?php //echo number_format($fetch['CX'],2); ?></td>
                  <td style="background-color:; color:; text-align:center;"><?php  ?></td>
                  <td style="background-color:; color:; text-align:center;"><?php ?></td>
                  <td style="background-color:; color:; text-align:center;"><a href="#" class="text-red">พิมพ์</a></td>
                </tr>
                <tr>
                  <td style="background-color:; color:; text-align:right;"></td>
                  <td style="background-color:; color:; text-align:;">ค่านายหน้า</td>
                  <td style="background-color:; color:red; text-align:center;"><?php //echo number_format($fetch['BX']); ?></td>
                  <td style="background-color:; color:blue; text-align:right;"><?php //echo number_format($SUMB10,2); ?></td>
                  <td style="background-color:; color:; text-align:center;"><?php  ?></td>
                  <td style="background-color:; color:; text-align:center;"><?php ?></td>
                  <td style="background-color:; color:; text-align:center;"><a href="#" class="text-red">พิมพ์</a></td>
                </tr>
              </tbody>
                <tfoot>
                  <td colspan="2" style="background-color:black; color:#fff; text-align:center;"><b>รวม</b></td>
                  <td colspan="" style="background-color:black; color:#fff; text-align:center;"><b><?php echo number_format($BX1); ?></b></td>
                  <td colspan="" style="background-color:black; color:#fff; text-align:right;"><b><?php echo number_format($CX1,2); ?></b></td>
                  <td colspan="" style="background-color:black; color:#fff; text-align:;"><b></b></td>
                  <td colspan="" style="background-color:black; color:#fff; text-align:;"><b></b></td>
                  <td colspan="" style="background-color:black; color:#fff; text-align:;"><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>
