<!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="" 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 * FROM [CONFIG].[dbo].[ACT_RECEIPT]
                    WHERE ACT_DATE BETWEEN '$DMY_1' and '$DMY_2'";
                    // echo $sql;
                    $select=$conn->prepare($sql);
                    $select->execute();
                    $item = 1;
                    $SUMX_PRICE = '0';
                    $REG_PRICE = '0';
                    $SUM_PAPER = '0';
                    $SUM_PANCIL = '0';
                    $SUM_BROKER = '0';
                    while($fetch=$select->fetch()){
                      if ($fetch['ACT_DATE'] != '') {
                        $BILL_DATE1 = substr($fetch['ACT_DATE'],0,4)+543; $BILL_DATE2 = substr($fetch['ACT_DATE'],5,2); $BILL_DATE3 = substr($fetch['ACT_DATE'],8,2);
                        $BILL_DATE = $BILL_DATE3."/".$BILL_DATE2."/".$BILL_DATE1;
                      } else {
                        $BILL_DATE = '';
                      }
                      $SUM_PAPER += $fetch['SUM_PAPER'];
                      $SUM_PANCIL += $fetch['SUM_PANCIL'];
                      $SUM_BROKER += $fetch['SUM_BROKER'];
                      $SUMX_PRICE += $fetch['SUMX_PRICE'];
                      $SUM_PRICE += $fetch['SUM_PRINCE'];
                      $REG_PRICE += $fetch['REG_PRICE'];
                      $SUMREG_PRICE = $REG_PRICE+$SUM_PAPER+$SUM_PANCIL-$SUM_BROKER;
                  ?>
                  <tr>
                    <td style="background-color:; color:; text-align:right;"><?php echo $item; ?>.</td>
                    <!-- <td style="background-color:; color:; text-align:center;"><a href="act_searchprint.php" class="text-red" target="_blank"><i class="fa fa-search-plus" aria-hidden="true"></i></a></td> -->
                    <td style="background-color:; color:; text-align:;"><?php echo $fetch['CROP_NAME']; ?></td>
                    <td style="background-color:; color:red; text-align:center;"><a href="act_index_5.php?DMY_1=<?php echo $DMY_1; ?>&DMY_2=<?php echo $DMY_2; ?>&ACT_NO=<?php echo $fetch['ACT_NO'] ?>" target="_blank"><?php echo number_format($fetch['SUMX_PRICE'],2); ?></a></td>
                    <td style="background-color:; color:blue; text-align:right;"><?php echo number_format($fetch['REG_PRICE'],2); ?></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:blue;"><?php echo $fetch['ACT_NO']; ?></a></td>
                    <td style="background-color:; color:; text-align:center;"><?php ?></td>
                  </tr>
                  <?php $item++; } ?>
                  <tr>
                    <td style="background-color:; color:; text-align:right;"></td>
                    <td style="background-color:; color:; text-align:;">ค่ากระดาษ</td>
                    <td style="background-color:; color:blue; text-align:right;"></td>
                    <td style="background-color:; color:blue; text-align:right;"><?php echo number_format($SUM_PAPER,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:blue; text-align:right;"></td>
                    <td style="background-color:; color:blue; text-align:right;"><?php echo number_format($SUM_PANCIL,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>
                </form>
                <tr>
                  <td style="background-color:; color:; text-align:right;"></td>
                  <td style="background-color:; color:; text-align:;">ค่านายหน้า</td>
                  <td style="background-color:; color:blue; text-align:right;"><?php ?></td>
                  <td style="background-color:; color:red; text-align:right;">-<?php echo number_format($SUM_BROKER,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($SUMX_PRICE,2); ?></b></td>
                  <td colspan="" style="background-color:black; color:#fff; text-align:right;"><b><?php echo number_format($SUMREG_PRICE,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>
                </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>
