diff --git a/wms/api/bpm/draw_update.php b/wms/api/bpm/draw_update.php new file mode 100644 index 00000000..f22bbc31 --- /dev/null +++ b/wms/api/bpm/draw_update.php @@ -0,0 +1,8 @@ + true +], JSON_UNESCAPED_UNICODE); + + +?> diff --git a/wms/estimated_shipping_date_report.php b/wms/estimated_shipping_date_report.php index 606b06b7..920a7ecf 100644 --- a/wms/estimated_shipping_date_report.php +++ b/wms/estimated_shipping_date_report.php @@ -8,8 +8,8 @@ use PhpOffice\PhpSpreadsheet\Style\Fill; include "header.php"; -$start_y = empty($_POST['start_month']) ? '2023' : substr($_POST['start_month'], 0, 4); -$end_y = empty($_POST['end_month']) ? '2023' : substr($_POST['end_month'], 0, 4); +$start_y = empty($_POST['start_month']) ? date("Y") : substr($_POST['start_month'], 0, 4); +$end_y = empty($_POST['end_month']) ? date("Y") : substr($_POST['end_month'], 0, 4); $start_m = empty($_POST['start_month']) ? '01' : substr($_POST['start_month'], 5, 2); $end_m = empty($_POST['end_month']) ? '12' : substr($_POST['end_month'], 5, 2); @@ -29,8 +29,8 @@ $sql = " w.contract_type FROM wipwholestatus AS w WHERE status = '1' - AND real_contract_arrival_date >= '$start_y-$start_m-1' - AND real_contract_arrival_date <= '$end_y-$end_m-31' + AND DATE_FORMAT(real_contract_arrival_date, '%Y-%m-%d') >= '$start_y-$start_m-01' + AND DATE_FORMAT(real_contract_arrival_date, '%Y-%m-%d') <= '$end_y-$end_m-31' ) AS this_order WHERE 1 = 1 GROUP BY this_order.contract_type, @@ -38,6 +38,7 @@ $sql = " this_order.date_year, this_order.date_month "; + $result = mysqli_query($link, $sql); $data = []; while ($row = $result->fetch_assoc()) { @@ -286,7 +287,8 @@ function alpha2num($a) return $n - 1; } if ($_SERVER["REQUEST_METHOD"] == 'POST') { - if ($_POST['excel_output'] == 'excel_output') { + $excel_output = !empty($_POST['excel_output']) ? $_POST['excel_output'] : ''; + if ($excel_output == 'excel_output') { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setTitle('出貨總表'); diff --git a/wms/maintainance_contract_payment_status.php b/wms/maintainance_contract_payment_status.php new file mode 100644 index 00000000..4c4cda2a --- /dev/null +++ b/wms/maintainance_contract_payment_status.php @@ -0,0 +1,399 @@ +query($sql); + +function getContractnoDetails($link, $user_id, $contractno = null) +{ + $sql = " + SELECT + c.contractno + FROM contract AS c + LEFT JOIN con_maintance_examine_apply AS cmea + ON c.contractno = cmea.vol_no + WHERE 1 = 1 + AND cmea.salesman IN (" . getAccountids($link, $user_id) . ") + "; + if (!empty($contractno)) { + $sql .= " + AND c.contractno = '$contractno' + "; + } + $result = mysqli_query($link, $sql); + $data = []; + foreach ($result as $row) { + array_push($data, $row['contractno']); + } + return "'" . implode("','", $data) . "'"; +} + +function getSalesmanNo($link, $contractno) +{ + $sql = " + SELECT + cmea.salesman + FROM contract AS c + LEFT JOIN con_maintance_examine_apply AS cmea + ON c.contractno = cmea.vol_no + WHERE 1 = 1 + AND c.contractno IN ('$contractno') + "; + $result = mysqli_query($link, $sql); + $data = []; + foreach ($result as $row) + return $row['salesman']; + return ""; +} +function getSalesmanName($link, $contractno) +{ + $sql = " + SELECT + a.name + FROM contract AS c + LEFT JOIN con_maintance_examine_apply AS cmea + ON c.contractno = cmea.vol_no + LEFT JOIN account AS a + ON cmea.salesman = a.accountid + WHERE 1 = 1 + AND c.contractno IN ('$contractno') + "; + $result = mysqli_query($link, $sql); + $data = []; + foreach ($result as $row) + return $row['name']; + return ""; +} + +function getAccountids($link, $user_id) +{ + $sql = " + SELECT + accountid + FROM account + WHERE 1 = 1 + AND (accountid = '$user_id' + OR accountid IN ( + SELECT + accountid + FROM account + WHERE 1 = 1 + AND manager = '$user_id' + AND accounttype IN ('B','E','M','W') + ) + ) + "; + $result = mysqli_query($link, $sql); + $data = []; + foreach ($result as $row) { + array_push($data, $row['accountid']); + } + return "'" . implode("','", $data) . "'"; +} + +function checkArCheckBillStatus($row) +{ + $CU_EstPayDate = $row['CU_EstPayDate']; + $BillNo2 = $row['BillNo2']; + if (substr($CU_EstPayDate, 0, 6) <= date("Ym")) { + if (empty($BillNo2)) { + return "未轉應收確認單"; + } else { + return "已轉應收確認單"; + } + } else { + return "時間未到"; + } +} + +function arSellInvoiceMaterial($row) +{ + + $CU_EstPayDate = $row['CU_EstPayDate']; + $InvoiceName = $row['InvoiceName']; + + if (substr($CU_EstPayDate, 0, 6) <= date("Ym")) { + if (empty($InvoiceName)) { + return "未開發票"; + } else { + return "已開發票"; + } + } else { + return "時間未到"; + } +} + +function checkArWriteOffBill($conn, $row) +{ + $BillNo = $row['BillNo2']; + + $sql = " + SELECT + * + -- a.BillNo, + -- a.WriteOffBizPartnerId, + -- a.PayWriteOffOAmount, + -- b.FromBillDate AS ReceivedDate, + -- b.CurrWOFeeOAmt AS Fee, + -- c.OrderBillNo, + -- c.checkBillNo, + -- c.InvoiceNo, + -- c.BillDate AS CheckBillDate + FROM arWriteOffBill AS a + LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo + LEFT JOIN + (SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail + LEFT JOIN + (SELECT + arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo + FROM arCheckBill + LEFT JOIN arCheckBillInvInfo + ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 + ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c + ON a.BillNo=c.BillNo + WHERE c.checkBillNo = '$BillNo' + "; + + $del = $conn->query($sql); + $i = 0; + foreach ($del as $row) + $i++; + if (empty($i)) { + return "未收款"; + } else { + return "已收款"; + } +} + +?> + + + + + + + + +
營業人員/契約人員 | +合約號 | +標示號 | +電梯編號 | +預計請款日 | +催收次數 | +應收申請單狀態 | +請款金額(未轉應收) | +請款金額(已轉應收) | +應收申請單號 | +發票狀態 | +發票單標示號 | +發票單號 | +發票明細 | +發票金額 | +發票號碼 | +核銷 | + +
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ "; + echo getSalesmanName($link, $row['BillNo']); + ?> + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | ++ + | +