diff --git a/.gitignore b/.gitignore
index a344fd2a..44e45c2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,4 @@ wms/gary2.php
wms/chinese.php
phpinfo.php
wms/account_receivable_sql_file.sql
+wms/account_receivable_maintainance_sql.sql
diff --git a/wms/T8_Authorization_from_bpm.php b/wms/T8_Authorization_from_bpm.php
index 7d2ca5a8..0c81c268 100644
--- a/wms/T8_Authorization_from_bpm.php
+++ b/wms/T8_Authorization_from_bpm.php
@@ -4,9 +4,8 @@
// $user_password = "M012290493119";
// echo $validation = get_Auth($user_id, $user_password);
-
-// function get_Auth($user_id = "M0000", $user_password = "M012290493119")
-function get_Auth($user_id = "ADMIN", $user_password = "chi")
+// function get_Auth($user_id = "ADMIN", $user_password = "chi")
+function get_Auth($user_id = "M0000", $user_password = "M012290493119")
{
$currentTime = time();
$twoMinutesLater = $currentTime - (2 * 60);
@@ -14,14 +13,14 @@ function get_Auth($user_id = "ADMIN", $user_password = "chi")
// $now = gmdate("YmdHis");
$now = gmdate("YmdHis", strtotime("-2 minutes"));
$data = "$user_id." . $now;
- // $sign = hash_hmac('SHA256', $data, 'A21181F1EE4966D3', false);
- $sign = hash_hmac('SHA256', $data, 'A733DAD19527399E', false);
+ $sign = hash_hmac('SHA256', $data, '91EB2CB12C3F8211', false);
+ // $sign = hash_hmac('SHA256', $data, 'A733DAD19527399E', false); 普來特富
// echo $sign;
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
- // $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; -----
- $apiurl = 'http://101.132.66.206:880/twWebAPI/GetAuth';
+ $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
+ // $apiurl = 'http://101.132.66.206:880/twWebAPI/GetAuth'; 普來特富
// $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
@@ -31,7 +30,7 @@ function get_Auth($user_id = "ADMIN", $user_password = "chi")
"Pwd: $user_password",
"TimestampUTC: $now",
"Sign: $sign",
- "GroupId:ceshi"
+ "GroupId:MASADA"
];
$ch = curl_init();
diff --git a/wms/account-receivable-maintainance-index.php b/wms/account-receivable-maintainance-index.php
new file mode 100644
index 00000000..5295d065
--- /dev/null
+++ b/wms/account-receivable-maintainance-index.php
@@ -0,0 +1,523 @@
+ 0) {
+ $column_str = "('$user_id'" . ",'";
+ $column_str .= implode("','", $follower);
+ $column_str .= "')";
+ $sql .= " OR siam.PersonId IN $column_str OR cd.LeaderId = '$user_id')";
+ } else {
+ $sql .= " OR cd.LeaderId = '$user_id')";
+ };
+}
+if (!is_null($start_date)) {
+ $start_date = (int)date('Ymd', strtotime($start_date));
+ $sql .= " AND siam.CU_ContractStart >= $start_date ";
+}
+if (!is_null($end_date)) {
+ $end_date = (int)date('Ymd', strtotime($end_date));
+ $sql .= " AND siam.CU_ContractStart <= $end_date ";
+}
+if (!is_null($start_SignDate)) {
+ $start_SignDate = (int)date('Ymd', strtotime($start_SignDate));
+ $sql .= " AND siam.BillDate >= $start_SignDate ";
+}
+if (!is_null($end_SignDate)) {
+ $end_SignDate = (int)date('Ymd', strtotime($end_SignDate));
+ $sql .= " AND siam.BillDate <= $end_SignDate ";
+}
+$sql .= " GROUP BY
+siam.PersonId,
+cp.PersonName,
+cd.DeptId,
+cd.DeptName,
+cd.LeaderId,
+lcp.PersonName,
+siam.BizPartnerId,
+cbp.BizPartnerName,
+siamd.RowCode,
+siam.BillNo,
+siamd.ProjectId,
+siamd.CU_EstPayDate,
+siamd.UnTransCheckBLAmtWTax,
+siamd.HadTransCheckBLAmtWTax,
+siamd.OAmountWithTax,
+siamd.CU_MaterialId,
+acb_tmp.BillNo2,
+acb_tmp.RowCode2,
+acb_tmp.checkOAmount,
+asim.BillNo,
+asim.InvoiceName,
+asim.OAmountWithTax,
+asi.InvoiceNo,
+asi.InvoiceTime,
+writeoff.BillDate
+ORDER BY
+siam.PersonId ASC,
+siam.BillNo ASC,
+siamd.RowCode ASC";
+
+$query_T8 = $conn->query($sql);
+$rows = $query_T8->fetchAll(PDO::FETCH_ASSOC);
+$today = strtotime(date('Ymt'));
+$table = "";
+for ($i = 0; $i < count($rows); $i++) {
+ $row = $rows[$i];
+ $tmpname = $row['ProjectId'] . $row['RowCode'];
+ $data[$tmpname] = $row;
+ $data[$tmpname]['CU_EstPayDate'] = date('Y-m-d', strtotime($row['CU_EstPayDate']));
+ $data[$tmpname]['havetopay'] = strtotime($row['CU_EstPayDate']) > $today ? '--' : 'V';
+ $datahavetopay = $row['CU_EstPayDate'] > $today ? 0 : 1;
+ $data[$tmpname]['collecttime'] = collect_month(strtotime($row['CU_EstPayDate']));
+ $invoicedate = is_null($row['InvoiceTime']) ? null : date('Y-m-d', strtotime($row['InvoiceTime']));
+ $tableinvoice_state = is_null($invoicedate) ? 0 : 1;
+ $contract_no = $row['ProjectId'];
+ $facility_no = $row['CU_MaterialId'];
+ $RowCode = $row['RowCode'];
+ $BillNo = $row['BillNo'];
+ $receivable_date = date('Y-m-d', strtotime($row['CU_EstPayDate']));
+ $budget = $row['OAmountWithTax'];
+ $invoiceNo = $row['InvoiceNo'];
+ $invoice_budget = is_null($row['InvoiceOAmount']) ? 0 : $row['InvoiceOAmount'];
+ $table_writeoff_date = is_null($row['WriteOffDate']) ? null : date('Y-m-d', strtotime($row['WriteOffDate']));
+ $table_writeoff_amount = is_null($row['TotalCurrStandOffOAmount']) ? 0 : $row['TotalCurrStandOffOAmount'];
+ $table1 = "INSERT INTO account_receivable_maintainance(
+ `contract_no`,
+ `facility_no`,
+ `RowCode`,
+ `BillNo`,
+ `receivable_date`,
+ `budget`,
+ `receivable`,
+ `invoice_state`,
+ `invoice_budget`,
+ `received_budget`
+ ";
+ $table2 = ") VALUES(
+ '$contract_no',
+ '$facility_no',
+ '$RowCode',
+ '$BillNo',
+ '$receivable_date',
+ $budget,
+ $datahavetopay,
+ $tableinvoice_state,
+ $invoice_budget,
+ $table_writeoff_amount
+ ";
+ $table1 .= is_null($invoicedate) ? "" : ",`invoice_date`";
+ $table2 .= is_null($invoicedate) ? "" : ",'$invoicedate'";
+ $table1 .= is_null($table_writeoff_date) ? "" : ",`received_date`";
+ $table2 .= is_null($table_writeoff_date) ? "" : ",'$table_writeoff_date'";
+ $table1 .= is_null($invoiceNo) ? "" : ",`invoice_no`";
+ $table2 .= is_null($invoiceNo) ? "" : ",'$invoiceNo'";
+ $table .= $table1 . $table2 . "); \n";
+}
+// $file_path = 'account_receivable_maintainance_sql.sql';
+// if (file_put_contents($file_path, $table) !== false) {
+// echo "SQL文件已成功生成:{$file_path}";
+// } else {
+// echo "生成SQL文件时出现错误。";
+// }
+
+// foreach ($data as $key => $row) {
+// echo $key . "
";
+// print_r($row);
+// echo "
------------
";
+// }
+// exit();
+?>
+
+
+
合約號 | +序號 | +作番號 | +部門 | +主管 | +契約員 | +客戶名稱 | + +應收日期 | +是否應收 | +應收金額 | + +已收金額 | +催收金額 | +催收次數 | +
---|---|---|---|---|---|---|---|---|---|---|---|---|
= $row['ProjectId']; ?> | += $row['RowCode']; ?> | += $row['CU_MaterialId']; ?> | += $row['DeptId'] . " " . $row['DeptName']; ?> |
+ = $row['LeaderId'] . " " . $row['LeaderName']; ?> |
+ = $row['PersonId'] . " " . $row['PersonName']; ?> |
+ = $row['BizPartnerId'] . " " . $row['BizPartnerName']; ?> |
+
+ = $row['CU_EstPayDate']; ?> | += $row['havetopay']; ?> | += number_format(round($row['OAmountWithTax'])); ?> | + += is_null($row['TotalCurrStandOffOAmount']) ? 0 : number_format(round($row['TotalCurrStandOffOAmount'])); ?> | += ($row['havetopay'] == "V")? (number_format(round($row['OAmountWithTax'] - $row['TotalCurrStandOffOAmount']))) :0; ?> | += (($row['havetopay'] == "V") && ($row['OAmountWithTax'] - $row['TotalCurrStandOffOAmount'] >1))? $row['collecttime']:0; ?> | +