@ -136,7 +136,6 @@ for ($i = 0; $i < count($rows); $i++) {
$tmpname = $row['ProjectId'] . $row['RowCode'];
$tmpname = $row['ProjectId'] . $row['RowCode'];
$data[$tmpname] = $row;
$data[$tmpname] = $row;
$data[$tmpname]['CU_EstPayDate'] = date('Y-m-d', strtotime($row['CU_EstPayDate']));
$data[$tmpname]['CU_EstPayDate'] = date('Y-m-d', strtotime($row['CU_EstPayDate']));
$receivable_date = $data[$tmpname]['CU_EstPayDate'];
$data[$tmpname]['havetopay'] = strtotime($row['CU_EstPayDate']) > $today ? '--' : 'V';
$data[$tmpname]['havetopay'] = strtotime($row['CU_EstPayDate']) > $today ? '--' : 'V';
$datahavetopay = strtotime($row['CU_EstPayDate']) > $today ? 0 : 1;
$datahavetopay = strtotime($row['CU_EstPayDate']) > $today ? 0 : 1;
$data[$tmpname]['collecttime'] = collect_month(strtotime($row['CU_EstPayDate']));
$data[$tmpname]['collecttime'] = collect_month(strtotime($row['CU_EstPayDate']));
@ -152,19 +151,19 @@ for ($i = 0; $i < count($rows); $i++) {
$facility_no = $row['CU_MaterialId'];
$facility_no = $row['CU_MaterialId'];
$RowCode = $row['RowCode'];
$RowCode = $row['RowCode'];
$BillNo = $row['BillNo'];
$BillNo = $row['BillNo'];
$data[$tmpname]['receivable_date'] = date('Y-m-d', strtotime($row['CU_EstPayDate']));
$data[$tmpname]['receivable_date'] = (is_null($row['CU_EstPayDate'])) ? null : date('Y-m-d', strtotime($row['CU_EstPayDate']));
$budget = $row['OAmountWithTax'];
$receivable_date = (is_null($data[$tmpname]['receivable_date'])) ? null : $data[$tmpname]['receivable_date'];
$budget = (is_null($row['OAmountWithTax'])) ? 0 : $row['OAmountWithTax'];
$invoiceNo = $row['InvoiceNo'];
$invoiceNo = $row['InvoiceNo'];
$tableinvoice_state = is_null($invoiceNo) ? 0 : 1;
$tableinvoice_state = is_null($invoiceNo) ? 0 : 1;
$data[$tmpname]['invoice_budget'] = is_null($row['InvoiceOAmount']) ? 0 : $row['InvoiceOAmount'];
$data[$tmpname]['invoice_budget'] = is_null($row['InvoiceOAmount']) ? 0 : $row['InvoiceOAmount'];
$invoice_budget = $data[$tmpname]['invoice_budget'];
$invoice_budget = (is_null($data[$tmpname]['invoice_budget'])) ? 0 : $data[$tmpname]['invoice_budget'];
$table_writeoff = ($data[$tmpname]['WriteOff'] =='V') ? 1 : 0;
$table_writeoff = ($data[$tmpname]['WriteOff'] =='V') ? 1 : 0;
$table1 = "INSERT INTO account_receivable_maintainance(
$table1 = "INSERT INTO account_receivable_maintainance(
`contract_no`,
`contract_no`,
`facility_no`,
`facility_no`,
`RowCode`,
`RowCode`,
`BillNo`,
`BillNo`,
`receivable_date`,
`budget`,
`budget`,
`receivable`,
`receivable`,
`invoice_state`,
`invoice_state`,
@ -176,25 +175,27 @@ for ($i = 0; $i < count($rows); $i++) {
'$facility_no',
'$facility_no',
'$RowCode',
'$RowCode',
'$BillNo',
'$BillNo',
'$receivable_date',
$budget,
$budget,
$datahavetopay,
$datahavetopay,
$tableinvoice_state,
$tableinvoice_state,
$invoice_budget,
$invoice_budget,
$table_writeoff
$table_writeoff
";
";
$table1 .= is_null($receivable_date) ? "" : ",`receivable_date`";
$table2 .= is_null($receivable_date) ? "" : ",'$receivable_date'";
$table1 .= is_null($invoicedate) ? "" : ",`invoice_date`";
$table1 .= is_null($invoicedate) ? "" : ",`invoice_date`";
$table2 .= is_null($invoicedate) ? "" : ",'$invoicedate'";
$table2 .= is_null($invoicedate) ? "" : ",'$invoicedate'";
$table1 .= is_null($invoiceNo) ? "" : ",`invoice_no`";
$table1 .= is_null($invoiceNo) ? "" : ",`invoice_no`";
$table2 .= is_null($invoiceNo) ? "" : ",'$invoiceNo'";
$table2 .= is_null($invoiceNo) ? "" : ",'$invoiceNo'";
$table .= $table1 . $table2 . "); \n";
$table .= $table1 . $table2 . "); \n";
}
}
// $file_path = 'account_receivable_maintainance_sql.sql';
// if (file_put_contents($file_path, $table) !== false) {
$file_path = 'account_receivable_maintainance_sql.sql';
// echo "SQL文件已成功生成:{$file_path}";
if (file_put_contents($file_path, $table) !== false) {
// } else {
echo "SQL文件已成功生成:{$file_path}";
// echo "生成SQL文件时出现错误。";
}else{
// }
"fail";
}
// foreach ($data as $key => $row) {
// foreach ($data as $key => $row) {
// echo $key . "< br > ";
// echo $key . "< br > ";