<?php
include '_connect.php';

$DMY_1 = $_GET['DMY_1'];
$DMY_2 = $_GET['DMY_2'];
$CROP_NAME1 = $_GET['CROP_NAME1'];
if ($_GET['STATUSXS'] == '1') {
  $STATUSXS = "";
}
else {
  $STATUSXS = "and ACT_DATE is NULL";
}
$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 bill_no as reg_bill_no,plcno,plcdate,plcexp from [EHONGDB].[dbo].[reg_billdatadocument] WHERE FEE_NO = '11' and (plcno is not null) ) ax1 on(ax1.reg_bill_no=a.bill_no)
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 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();
while($fetch=$select->fetch()){
  include 'act_sum_1.php';
if ($FEE_STATUSX == "04") {
  echo "$CROP_NAME<br>";

}
}
 ?>
