10994015 1 year ago
parent
commit
0f577d08e4
  1. 37
      wms/account-receivable-excel.php
  2. BIN
      wms/account-receivable-facility.xlsx
  3. 566
      wms/account-receivable-index-ing.php
  4. 876
      wms/account-receivable-index.php
  5. BIN
      wms/account-receivable-test.xlsx
  6. 13
      wms/cont/apply_form.php
  7. 140
      wms/contract/api/testT8API.php
  8. 2
      wms/contract/contract-download.php
  9. 579
      wms/contract/contract-new-apply.php
  10. 37
      wms/crm/crmm03-edit.php
  11. 2
      wms/crm/crmm06-edit.php
  12. 6
      wms/fun_global.php
  13. 4
      wms/mkt/pricereview-index.php

37
wms/account-receivable-excel.php

@ -13,10 +13,9 @@ $Bill = json_decode(file_get_contents("php://input"), true);
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet(); $sheet = $spreadsheet->getActiveSheet();
// file_put_contents('account-receivable.txt', json_encode($Bill)); // file_put_contents('account-receivable.txt', json_encode($Bill));
// file_put_contents('account-receivable.txt', json_encode($Bill));
if ($type == 'facility') { if ($type == 'facility') {
$colomnHeader = [ $colomnHeader = [
'作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', 'T8單據日期','作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金名稱', '訂金合約金額', '訂金應收日期', '訂金目前應收金額', '訂金已收金額', '訂金催收金額', '訂金催收次數', '訂金名稱', '訂金合約金額', '訂金應收日期', '訂金目前應收金額', '訂金已收金額', '訂金催收金額', '訂金催收次數',
'二次款名稱', '二次款合約金額', '二次款應收日期', '二次款目前應收金額', '二次款已收金額', '二次款催收金額', '二次款催收次數', '二次款名稱', '二次款合約金額', '二次款應收日期', '二次款目前應收金額', '二次款已收金額', '二次款催收金額', '二次款催收次數',
'貨抵工地款名稱', '貨抵工地款合約金額', '貨抵工地款應收日期', '貨抵工地款目前應收金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款催收次數', '貨抵工地款名稱', '貨抵工地款合約金額', '貨抵工地款應收日期', '貨抵工地款目前應收金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款催收次數',
@ -25,7 +24,7 @@ if ($type == 'facility') {
'官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數', '官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數',
'交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已收金額', '交車款催收金額', '交車款催收次數', '交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已收金額', '交車款催收金額', '交車款催收次數',
'尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已收金額', '尾款催收金額', '尾款催收次數', '尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已收金額', '尾款催收金額', '尾款催收次數',
'作番狀態', '合約-設備金額', '合約-安裝金額', '作番合約總金額', '作番總應收金額' '作番狀態', '合約-設備金額','合約-安裝金額','作番合約總金額', '作番總應收金額'
]; ];
$sheet->fromArray($colomnHeader, NULL, 'A1'); $sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2; $rowIndex = 2;
@ -35,7 +34,7 @@ if ($type == 'facility') {
$column = [ $column = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR' 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP','BQ','BR','BK'
]; ];
foreach ($column as $col) { foreach ($column as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true); $sheet->getColumnDimension($col)->setAutoSize(true);
@ -48,32 +47,32 @@ if ($type == 'facility') {
$writer->save($excelFileName); $writer->save($excelFileName);
} else { } else {
$colomnHeader = [ $colomnHeader = [
'合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', 'T8單據日期','合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金', '訂金目前應收', '訂金已開票金額', '訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數', '訂金', '訂金目前應收', '訂金已開票金額','訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數',
'二次款', '二次款目前應收', '二次款已開票金額', '二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數', '二次款', '二次款目前應收', '二次款已開票金額','二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數',
'貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額', '貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數', '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額','貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數',
'安裝款', '安裝款目前應收', '安裝款已開票金額', '安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數', '安裝款', '安裝款目前應收', '安裝款已開票金額','安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數',
'試車款', '試車款目前應收', '試車款已開票金額', '試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數', '試車款', '試車款目前應收', '試車款已開票金額','試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數',
'官檢款', '官檢款目前應收', '官檢款已開票金額', '官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數', '官檢款', '官檢款目前應收', '官檢款已開票金額','官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數',
'交車款', '交車款目前應收', '交車款已開票金額', '交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數', '交車款', '交車款目前應收', '交車款已開票金額','交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數',
'尾款', '尾款目前應收', '尾款已開票金額', '尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數', '尾款', '尾款目前應收', '尾款已開票金額','尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數',
'合約設備金額', '合約安裝金額', '合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態' '合約設備金額','合約安裝金額','合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態'
]; ];
$sheet->fromArray($colomnHeader, NULL, 'A1'); $sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2; $rowIndex = 2;
foreach ($Bill as $key => $value) { foreach ($Bill as $key => $value) {
$sheet->fromArray($value, NULL, 'A' . $rowIndex, true); $sheet->fromArray($value, NULL, 'A' . $rowIndex);
$column = [ $column = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ',
'CA', 'CB', 'CC' 'CA','CB','CC','CD'
]; ];
foreach ($column as $col) { foreach ($column as $col) {
if ($col == 'CB') { if ($col == 'CC') {
$sheet->getColumnDimension('CB')->setWidth(40); $sheet->getColumnDimension('CC')->setWidth(40);
$sheet->getStyle('CB')->getAlignment()->setWrapText(true); $sheet->getStyle('CC')->getAlignment()->setWrapText(true);
} else { } else {
$sheet->getColumnDimension($col)->setAutoSize(true); $sheet->getColumnDimension($col)->setAutoSize(true);
} }

BIN
wms/account-receivable-facility.xlsx

Binary file not shown.

566
wms/account-receivable-index-ing.php

@ -1,15 +1,6 @@
<?php <?php
include "header.php"; include "header.php";
$sum_facility = 0;
$sum_A40001 = 0;
$sum_A40008 = 0;
$sum_total_budget = 0;
$average_budget = 0;
$average_A40001 = 0;
$average_A40008 = 0;
$follower = find_follow($user_id); $follower = find_follow($user_id);
$arrayData = []; $arrayData = [];
$receivable_array = []; $receivable_array = [];
@ -49,7 +40,7 @@ LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) "; WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) ";
// T8 銷售訂單 作番金額 // T8 銷售訂單 作番金額
$sql_contract_budget = "SELECT A.BillNo, A.OAmountWithTax,A.CU_MaterialId, A.MaterialId FROM salSalesOrderDetail AS A $sql_contract_budget = "SELECT A.BillNo, A.OAmountWithTax,A.CU_MaterialId FROM salSalesOrderDetail AS A
LEFT JOIN salSalesOrder AS B ON A.BillNo=B.BillNo LEFT JOIN salSalesOrder AS B ON A.BillNo=B.BillNo
WHERE B.ModeId='M' AND A.ItemType=1 "; WHERE B.ModeId='M' AND A.ItemType=1 ";
@ -103,7 +94,6 @@ if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql_opening .= " OR person_id = '$user_id'"; $sql_opening .= " OR person_id = '$user_id'";
$sql .= " WHERE salesid = '$user_id'"; $sql .= " WHERE salesid = '$user_id'";
$sql_contract_budget .= " AND (PersonId = '$user_id'"; $sql_contract_budget .= " AND (PersonId = '$user_id'";
$sql_contract_budget .= " AND (PersonId = '$user_id'";
if (count($follower) > 0) { if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'"; $column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower); $column_str .= implode("','", $follower);
@ -113,19 +103,16 @@ if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql_opening .= " OR person_id IN $column_str)"; $sql_opening .= " OR person_id IN $column_str)";
$sql .= " OR salesid IN $column_str ORDER BY contractno"; $sql .= " OR salesid IN $column_str ORDER BY contractno";
$sql_contract_budget .= " OR PersonId IN $column_str ORDER BY BillNo, CU_MaterialId)"; $sql_contract_budget .= " OR PersonId IN $column_str ORDER BY BillNo, CU_MaterialId)";
$sql_contract_budget .= " OR PersonId IN $column_str ORDER BY BillNo, CU_MaterialId)";
} else { } else {
$sql_contract .= ")"; $sql_contract .= ")";
// $sql_received .= ")"; // $sql_received .= ")";
$sql_opening .= ")"; $sql_opening .= ")";
$sql .= " ORDER BY contractno"; $sql .= " ORDER BY contractno";
$sql_contract_budget .= ")"; $sql_contract_budget .= ")";
$sql_contract_budget .= ")";
}; };
} else { } else {
$sql .= " ORDER BY contractno"; $sql .= " ORDER BY contractno";
$sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId"; $sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId";
$sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId";
} }
$contract = $conn->query($sql_contract); $contract = $conn->query($sql_contract);
@ -142,16 +129,10 @@ foreach ($contract_budget_data as $cont) {
$contract_budget[$cont['BillNo']]['total'] = $cont['OAmountWithTax']; $contract_budget[$cont['BillNo']]['total'] = $cont['OAmountWithTax'];
} }
if (isset($contract_budget[$cont['BillNo']][$cont['CU_MaterialId']])) { if (isset($contract_budget[$cont['BillNo']][$cont['CU_MaterialId']])) {
$contract_budget[$cont['BillNo']][$cont['CU_MaterialId']]['total'] += $cont['OAmountWithTax']; $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']] += $cont['OAmountWithTax'];
} else { } else {
$contract_budget[$cont['BillNo']][$cont['CU_MaterialId']]['total'] = $cont['OAmountWithTax']; $contract_budget[$cont['BillNo']][$cont['CU_MaterialId']] = $cont['OAmountWithTax'];
}; };
if (isset($contract_budget[$cont['BillNo']][$cont['MaterialId']])) {
$contract_budget[$cont['BillNo']][$cont['MaterialId']] += $cont['OAmountWithTax'];
} else {
$contract_budget[$cont['BillNo']][$cont['MaterialId']] = $cont['OAmountWithTax'];
}
$contract_budget[$cont['BillNo']][$cont['CU_MaterialId']][$cont['MaterialId']] = $cont['OAmountWithTax'];
} }
/* 計算比例 /* 計算比例
@ -166,8 +147,8 @@ function get_ratio($facility_list, $contract_no, $contract_budget)
return 0; return 0;
} else { } else {
foreach ($facility_list as $every) { foreach ($facility_list as $every) {
if (isset($contract_budget[$contract_no][$every]['total']) && isset($contract_budget[$contract_no]['total'])) { if (isset($contract_budget[$contract_no][$every]) && isset($contract_budget[$contract_no]['total'])) {
$ratio += $contract_budget[$contract_no][$every]['total'] / $contract_budget[$contract_no]['total']; $ratio += $contract_budget[$contract_no][$every] / $contract_budget[$contract_no]['total'];
} }
} }
return $ratio; return $ratio;
@ -215,7 +196,6 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['facilities'] = ""; $arrayData[$BillNo]['facilities'] = "";
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['sign_num'] = $arrayData[$BillNo]['receivable_budget'] = 0; $arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['sign_num'] = $arrayData[$BillNo]['receivable_budget'] = 0;
$arrayData[$BillNo]['total_list'] = $arrayData[$BillNo]['sign_list'] = $arrayData[$BillNo]['second_list'] = $arrayData[$BillNo]['arrive_list'] = $arrayData[$BillNo]['install_list'] = $arrayData[$BillNo]['tryrun_list'] = $arrayData[$BillNo]['check_list'] = $arrayData[$BillNo]['delivery_list'] = $arrayData[$BillNo]['final_list'] = []; $arrayData[$BillNo]['total_list'] = $arrayData[$BillNo]['sign_list'] = $arrayData[$BillNo]['second_list'] = $arrayData[$BillNo]['arrive_list'] = $arrayData[$BillNo]['install_list'] = $arrayData[$BillNo]['tryrun_list'] = $arrayData[$BillNo]['check_list'] = $arrayData[$BillNo]['delivery_list'] = $arrayData[$BillNo]['final_list'] = [];
$arrayData[$BillNo]['total_list'] = $arrayData[$BillNo]['sign_list'] = $arrayData[$BillNo]['second_list'] = $arrayData[$BillNo]['arrive_list'] = $arrayData[$BillNo]['install_list'] = $arrayData[$BillNo]['tryrun_list'] = $arrayData[$BillNo]['check_list'] = $arrayData[$BillNo]['delivery_list'] = $arrayData[$BillNo]['final_list'] = [];
} }
if (stristr($PayStage, '二次款') || (stristr($PayStage, '出貨前') && $PayStage != "寶佳出貨前30天") || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後10天')) { if (stristr($PayStage, '二次款') || (stristr($PayStage, '出貨前') && $PayStage != "寶佳出貨前30天") || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後10天')) {
$arrayData[$BillNo]['second'][0] = $PayStage; $arrayData[$BillNo]['second'][0] = $PayStage;
@ -305,16 +285,12 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']][4] = $wip['name']; $arrayData[$wip['contractno']][4] = $wip['name'];
$arrayData[$wip['contractno']][10] = $wip['contractno']; $arrayData[$wip['contractno']][10] = $wip['contractno'];
$arrayData[$wip['contractno']]['total_facility_num'] += 1; $arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['A40001'] = $contract_budget[$wip['contractno']]['A40001'];
$arrayData[$wip['contractno']]['A40008'] = $contract_budget[$wip['contractno']]['A40008'];
// [合約號]['facility'][作番號]['no'] // [合約號]['facility'][作番號]['no']
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['no'] = $wip['facilityno']; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['no'] = $wip['facilityno'];
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = ""; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = "";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['total_budget'] = 0; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['total_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['receivable_budget'] = 0; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['receivable_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['collect_budget'] = 0; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['collect_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40001'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40001']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40001'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40001'] : 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['A40008'] = (isset($contract_budget[$wip['contractno']][$wip['facilityno']]['A40008']) && !is_null($contract_budget[$wip['contractno']][$wip['facilityno']]['A40008'])) ? $contract_budget[$wip['contractno']][$wip['facilityno']]['A40008'] : 0;
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期] // [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期] // [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
@ -406,7 +382,6 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") { if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") {
$facility_status = ""; $facility_status = "";
array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']);
$today = strtotime(date('Ymd')); $today = strtotime(date('Ymd'));
$contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]); $contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($contractday); $month = collect_month($contractday);
@ -415,7 +390,6 @@ foreach ($wipwhole_array as $wip) {
if ($today > $contractday) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過) <br>"; $facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
//二次款 //二次款
@ -426,7 +400,6 @@ foreach ($wipwhole_array as $wip) {
if ($today > $contractday) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過) <br>"; $facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
//貨抵工地款 //貨抵工地款
@ -439,7 +412,6 @@ foreach ($wipwhole_array as $wip) {
if ($today > $contractday) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過) <br>"; $facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
@ -453,7 +425,6 @@ foreach ($wipwhole_array as $wip) {
if ($today > $contractday) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過) <br>"; $facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
@ -468,8 +439,6 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['delivery_num'] += 1; $arrayData[$wip['contractno']]['delivery_num'] += 1;
array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>"; $facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
@ -488,7 +457,6 @@ foreach ($wipwhole_array as $wip) {
} else { } else {
$signtime = strtotime($arrayData[$wip['contractno']]['sign'][2]); $signtime = strtotime($arrayData[$wip['contractno']]['sign'][2]);
array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']);
$month = collect_month($signtime); $month = collect_month($signtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = strval(date('Ymd', $signtime)); $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = strval(date('Ymd', $signtime));
@ -503,19 +471,14 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>"; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") { if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") {
$estimate_delivery_time = strtotime($wip['delivery_date']); $estimate_delivery_time = strtotime($wip['delivery_date']);
@ -525,8 +488,6 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['delivery_num'] += 1; $arrayData[$wip['contractno']]['delivery_num'] += 1;
array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
} }
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $arrivetime)); $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $arrivetime));
@ -538,11 +499,8 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['delivery_num'] += 1; $arrayData[$wip['contractno']]['delivery_num'] += 1;
array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['delivery_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['final_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['check_num'] += 1; $arrayData[$wip['contractno']]['check_num'] += 1;
array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']); $arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']);
$deliverytime = strtotime($wip['delivery_date']); $deliverytime = strtotime($wip['delivery_date']);
$month = collect_month($deliverytime); $month = collect_month($deliverytime);
@ -614,22 +572,16 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>"; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['check_num'] += 1; $arrayData[$wip['contractno']]['check_num'] += 1;
array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['check_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) { if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date']))); array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date']))); array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
@ -707,19 +659,14 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>"; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['tryrun_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date']))); array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date']))); array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
@ -775,16 +722,12 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>"; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['install_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
$installtime = strtotime($wip['install_end_date']); $installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime); $month = collect_month($installtime);
@ -832,13 +775,10 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>"; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['arrive_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']); $estimate_delivery_time = strtotime($wip['real_arrival_date']);
@ -868,14 +808,11 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (已達二次款收款條件) <br>"; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['second_list'], $wip['facilityno']);
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
} else { } else {
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']); array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
array_push($arrayData[$wip['contractno']]['sign_list'], $wip['facilityno']);
if ($wip['real_contract_arrival_date'] != NULL) { if ($wip['real_contract_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>"; $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>"; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>";
@ -914,30 +851,6 @@ foreach ($wipwhole_array as $wip) {
// } // }
// } // }
// foreach ($arrayData as $key => $value) {
// echo $key."<br>";
// print_r($value['total_list']);
// echo " / 總 ";
// print_r($value['sign_list']);
// echo " / 訂金 <br>";
// print_r($value['arrive_list']);
// echo " / 貨抵 ";
// print_r($value['install_list']);
// echo " / 安裝 <br>";
// print_r($value['tryrun_list']);
// echo " / 試車 ";
// print_r($value['check_list']);
// echo " / 官檢 <br>";
// print_r($value['delivery_list']);
// echo " / 移交 ";
// print_r($value['final_list']);
// echo " / 結案 <br>";
// echo "---------------------------<br>";
// foreach($value['sign_list'] as $fac){
// echo $fac."=========";
// }
// }
// 計算每個合約的應收款、作番總數 // 計算每個合約的應收款、作番總數
$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d'))))); $today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d')))));
@ -962,33 +875,14 @@ foreach ($arrayData as &$value) {
$value['final'][3] = $value['final'][1] * $final_ratio; $value['final'][3] = $value['final'][1] * $final_ratio;
$value['receivable_budget'] = $value['sign'][3] + $value['second'][3] + $value['arrive'][3] + $value['install'][3] + $value['tryrun'][3] + $value['check'][3] + $value['delivery'][3] + $value['final'][3]; $value['receivable_budget'] = $value['sign'][3] + $value['second'][3] + $value['arrive'][3] + $value['install'][3] + $value['tryrun'][3] + $value['check'][3] + $value['delivery'][3] + $value['final'][3];
} }
//['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
$sign_ratio = get_ratio($value['sign_list'], $value[10], $contract_budget);
$value['sign'][3] = $value['sign'][1] * $sign_ratio;
$second_ratio = get_ratio($value['second_list'], $value[10], $contract_budget);
$value['second'][3] = $value['second'][1] * $second_ratio;
$arrive_ratio = get_ratio($value['arrive_list'], $value[10], $contract_budget);
$value['arrive'][3] = $value['arrive'][1] * $arrive_ratio;
$install_ratio = get_ratio($value['install_list'], $value[10], $contract_budget);
$value['install'][3] = $value['install'][1] * $install_ratio;
$tryrun_ratio = get_ratio($value['tryrun_list'], $value[10], $contract_budget);
$value['tryrun'][3] = $value['tryrun'][1] * $tryrun_ratio;
$check_ratio = get_ratio($value['check_list'], $value[10], $contract_budget);
$value['check'][3] = $value['check'][1] * $check_ratio;
$delivery_ratio = get_ratio($value['delivery_list'], $value[10], $contract_budget);
$value['delivery'][3] = $value['delivery'][1] * $delivery_ratio;
$final_ratio = get_ratio($value['final_list'], $value[10], $contract_budget);
$value['final'][3] = $value['final'][1] * $final_ratio;
$value['receivable_budget'] = $value['sign'][3] + $value['second'][3] + $value['arrive'][3] + $value['install'][3] + $value['tryrun'][3] + $value['check'][3] + $value['delivery'][3] + $value['final'][3];
}
//['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 //['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
// 計算每台作番金額與各階段應收金額 // 計算每台作番金額與各階段應收金額
foreach ($value['facility'] as &$val) { foreach ($value['facility'] as &$val) {
foreach ($contractstage as $stage) { foreach ($contractstage as $stage) {
if (isset($value[$stage][0]) && !empty($value[$stage][0])) { if (isset($value[$stage][0]) && !empty($value[$stage][0])) {
$val[$stage][0] = $value[$stage][0]; $val[$stage][0] = $value[$stage][0];
if (isset($contract_budget[$value[10]]['total']) && isset($contract_budget[$value[10]][$val['no']]['total'])) { if (isset($contract_budget[$value[10]]['total']) && isset($contract_budget[$value[10]][$val['no']])) {
$ratio = $contract_budget[$value[10]][$val['no']]['total'] / $contract_budget[$value[10]]['total']; $ratio = $contract_budget[$value[10]][$val['no']] / $contract_budget[$value[10]]['total'];
} else { } else {
$ratio = 0; $ratio = 0;
} }
@ -1349,284 +1243,6 @@ foreach ($arrayData as $key => &$data) {
$data['final'][7] = 0; $data['final'][7] = 0;
} }
} }
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 4 已收金額 5 催收金額 6 已開發票金額 7 未開發票金額 min 最早應收月份 max 最晚應收月份
foreach ($arrayData as $key => &$data) {
$tmp_data = $data['received_budget'];
$tmp_invoice = $data['invoice_budget'];
if ($data['sign'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['sign'][3]) >= 0) {
$data['sign'][4] = $data['sign'][3];
$tmp_data -= $data['sign'][3];
} else {
$data['sign'][4] = $tmp_data;
$tmp_data = 0;
}
$data['sign'][5] = $data['sign'][3] - $data['sign'][4];
} else {
$data['sign'][4] = 0;
$data['sign'][5] = $data['sign'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['sign'][3]) >= 0) {
$data['sign'][6] = $data['sign'][3];
$tmp_invoice -= $data['sign'][3];
} else {
$data['sign'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['sign'][7] = $data['sign'][3] - $data['sign'][6];
} else {
$data['sign'][6] = 0;
$data['sign'][7] = $data['sign'][3];
}
} else {
$data['sign'][4] = 0;
$data['sign'][5] = 0;
$data['sign'][6] = 0;
$data['sign'][7] = 0;
}
if ($data['second'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['second'][3]) >= 0) {
$data['second'][4] = $data['second'][3];
$tmp_data -= $data['second'][3];
} else {
$data['second'][4] = $tmp_data;
$tmp_data = 0;
}
$data['second'][5] = $data['second'][3] - $data['second'][4];
} else {
$data['second'][4] = 0;
$data['second'][5] = $data['second'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['second'][3]) >= 0) {
$data['second'][6] = $data['second'][3];
$tmp_invoice -= $data['second'][3];
} else {
$data['second'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['second'][7] = $data['second'][3] - $data['second'][6];
} else {
$data['second'][6] = 0;
$data['second'][7] = $data['second'][3];
}
} else {
$data['second'][4] = 0;
$data['second'][5] = 0;
$data['second'][6] = 0;
$data['second'][7] = 0;
}
if ($data['arrive'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['arrive'][1]) >= 0) {
$data['arrive'][4] = $data['arrive'][3];
$tmp_data -= $data['arrive'][3];
} else {
$data['arrive'][4] = $tmp_data;
$tmp_data = 0;
}
$data['arrive'][5] = $data['arrive'][3] - $data['arrive'][4];
} else {
$data['arrive'][4] = 0;
$data['arrive'][5] = $data['arrive'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['arrive'][3]) >= 0) {
$data['arrive'][6] = $data['arrive'][3];
$tmp_invoice -= $data['arrive'][3];
} else {
$data['arrive'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['arrive'][7] = $data['arrive'][3] - $data['arrive'][6];
} else {
$data['arrive'][6] = 0;
$data['arrive'][7] = $data['arrive'][3];
}
} else {
$data['arrive'][4] = 0;
$data['arrive'][5] = 0;
$data['arrive'][6] = 0;
$data['arrive'][7] = 0;
}
if ($data['install'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['install'][1]) >= 0) {
$data['install'][4] = $data['install'][3];
$tmp_data -= $data['install'][3];
} else {
$data['install'][4] = $tmp_data;
$tmp_data = 0;
}
$data['install'][5] = $data['install'][3] - $data['install'][4];
} else {
$data['install'][4] = 0;
$data['install'][5] = $data['install'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['install'][3]) >= 0) {
$data['install'][6] = $data['install'][3];
$tmp_invoice -= $data['install'][3];
} else {
$data['install'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['install'][7] = $data['install'][3] - $data['install'][6];
} else {
$data['install'][6] = 0;
$data['install'][7] = $data['install'][3];
}
} else {
$data['install'][4] = 0;
$data['install'][5] = 0;
$data['install'][6] = 0;
$data['install'][7] = 0;
}
if ($data['tryrun'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['tryrun'][1]) >= 0) {
$data['tryrun'][4] = $data['tryrun'][3];
$tmp_data -= $data['tryrun'][3];
} else {
$data['tryrun'][4] = $tmp_data;
$tmp_data = 0;
}
$data['tryrun'][5] = $data['tryrun'][3] - $data['tryrun'][4];
} else {
$data['tryrun'][4] = 0;
$data['tryrun'][5] = $data['tryrun'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['tryrun'][3]) >= 0) {
$data['tryrun'][6] = $data['tryrun'][3];
$tmp_invoice -= $data['tryrun'][3];
} else {
$data['tryrun'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['tryrun'][7] = $data['tryrun'][3] - $data['tryrun'][6];
} else {
$data['tryrun'][6] = 0;
$data['tryrun'][7] = $data['tryrun'][3];
}
} else {
$data['tryrun'][4] = 0;
$data['tryrun'][5] = 0;
$data['tryrun'][6] = 0;
$data['tryrun'][7] = 0;
}
if ($data['check'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['check'][1]) >= 0) {
$data['check'][4] = $data['check'][3];
$tmp_data -= $data['check'][3];
} else {
$data['check'][4] = $tmp_data;
$tmp_data = 0;
}
$data['check'][5] = $data['check'][3] - $data['check'][4];
} else {
$data['check'][4] = 0;
$data['check'][5] = $data['check'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['check'][3]) >= 0) {
$data['check'][6] = $data['check'][3];
$tmp_invoice -= $data['check'][3];
} else {
$data['check'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['check'][7] = $data['check'][3] - $data['check'][6];
} else {
$data['check'][6] = 0;
$data['check'][7] = $data['check'][3];
}
} else {
$data['check'][4] = 0;
$data['check'][5] = 0;
$data['check'][6] = 0;
$data['check'][7] = 0;
}
if ($data['delivery'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['delivery'][1]) >= 0) {
$data['delivery'][4] = $data['delivery'][3];
$tmp_data -= $data['delivery'][3];
} else {
$data['delivery'][4] = $tmp_data;
$tmp_data = 0;
}
$data['delivery'][5] = $data['delivery'][3] - $data['delivery'][4];
} else {
$data['delivery'][4] = 0;
$data['delivery'][5] = $data['delivery'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['delivery'][3]) >= 0) {
$data['delivery'][6] = $data['delivery'][3];
$tmp_invoice -= $data['delivery'][3];
} else {
$data['delivery'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['delivery'][7] = $data['delivery'][3] - $data['delivery'][6];
} else {
$data['delivery'][6] = 0;
$data['delivery'][7] = $data['delivery'][3];
}
} else {
$data['delivery'][4] = 0;
$data['delivery'][5] = 0;
$data['delivery'][6] = 0;
$data['delivery'][7] = 0;
}
if ($data['final'][3] > 0) {
if ($tmp_data > 0) {
if (($tmp_data - $data['final'][1]) >= 0) {
$data['final'][4] = $data['final'][3];
$tmp_data -= $data['final'][3];
} else {
$data['final'][4] = $tmp_data;
$tmp_data = 0;
}
$data['final'][5] = $data['final'][3] - $data['final'][4];
} else {
$data['final'][4] = 0;
$data['final'][5] = $data['final'][3];
}
if ($tmp_invoice > 0) {
if (($tmp_invoice - $data['final'][3]) >= 0) {
$data['final'][6] = $data['final'][3];
$tmp_invoice -= $data['final'][3];
} else {
$data['final'][6] = $tmp_invoice;
$tmp_invoice = 0;
}
$data['final'][7] = $data['final'][3] - $data['final'][6];
} else {
$data['final'][6] = 0;
$data['final'][7] = $data['final'][3];
}
} else {
$data['final'][4] = 0;
$data['final'][5] = 0;
$data['final'][6] = 0;
$data['final'][7] = 0;
}
}
//產生excel的array //產生excel的array
$excel_aray = array(); $excel_aray = array();
@ -1636,10 +1252,7 @@ $facility_array = array();
$facility_boga_array = array(); $facility_boga_array = array();
$facility_exclude_boga_array = array(); $facility_exclude_boga_array = array();
foreach ($arrayData as $key => $value) { foreach ($arrayData as $key => $value) {
$sum_A40001 += $value['A40001'];
$sum_A40008 += $value['A40008'];
$sum_total_budget += $value['total_budget'];
$sum_facility += $value['total_facility_num'];
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0; $value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0; $value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
$value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0; $value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0;
@ -1654,51 +1267,48 @@ foreach ($arrayData as $key => $value) {
$value[$i]['min'] = (empty($value[$i]['min']) || is_null($value[$i]['min'])) ? 0 : $value[$i]['min']; $value[$i]['min'] = (empty($value[$i]['min']) || is_null($value[$i]['min'])) ? 0 : $value[$i]['min'];
$value[$i][4] = (isset($value[$i][4])) ? $value[$i][4] : 0; $value[$i][4] = (isset($value[$i][4])) ? $value[$i][4] : 0;
$value[$i][5] = (isset($value[$i][5])) ? $value[$i][5] : 0; $value[$i][5] = (isset($value[$i][5])) ? $value[$i][5] : 0;
$value[$i][4] = (isset($value[$i][4])) ? $value[$i][4] : 0;
$value[$i][5] = (isset($value[$i][5])) ? $value[$i][5] : 0;
}; };
if ($value['sign'][0] == "寶佳出貨前30天") { if ($value['sign'][0] == "寶佳出貨前30天") {
$boga_array[$key] = [ $boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
number_format(round($value['sign'][1])), number_format(round($value['sign'][3])), number_format(round($value['sign'][6])), number_format(round($value['sign'][7])), number_format(round($value['sign'][4])), number_format(round($value['sign'][5])), $value['sign']['max'], $value['sign']['min'], round($value['sign'][1]), round($value['sign'][3]), round($value['sign'][6]), round($value['sign'][7]), round($value['sign'][4]), round($value['sign'][5]), $value['sign']['max'], $value['sign']['min'],
number_format(round($value['second'][1])), number_format(round($value['second'][3])), number_format(round($value['second'][6])), number_format(round($value['second'][7])), number_format(round($value['second'][4])), number_format(round($value['second'][5])), $value['second']['max'], $value['second']['min'], round($value['second'][1]), round($value['second'][3]), round($value['second'][6]), round($value['second'][7]), round($value['second'][4]), round($value['second'][5]), $value['second']['max'], $value['second']['min'],
number_format(round($value['arrive'][1])), number_format(round($value['arrive'][3])), number_format(round($value['arrive'][6])), number_format(round($value['arrive'][7])), number_format(round($value['arrive'][4])), number_format(round($value['arrive'][5])), $value['arrive']['max'], $value['arrive']['min'], round($value['arrive'][1]), round($value['arrive'][3]), round($value['arrive'][6]), round($value['arrive'][7]), round($value['arrive'][4]), round($value['arrive'][5]), $value['arrive']['max'], $value['arrive']['min'],
number_format(round($value['install'][1])), number_format(round($value['install'][3])), number_format(round($value['install'][6])), number_format(round($value['install'][7])), number_format(round($value['install'][4])), number_format(round($value['install'][5])), $value['install']['max'], $value['install']['min'], round($value['install'][1]), round($value['install'][3]), round($value['install'][6]), round($value['install'][7]), round($value['install'][4]), round($value['install'][5]), $value['install']['max'], $value['install']['min'],
number_format(round($value['tryrun'][1])), number_format(round($value['tryrun'][3])), number_format(round($value['tryrun'][6])), number_format(round($value['tryrun'][7])), number_format(round($value['tryrun'][4])), number_format(round($value['tryrun'][5])), $value['tryrun']['max'], $value['tryrun']['min'], round($value['tryrun'][1]), round($value['tryrun'][3]), round($value['tryrun'][6]), round($value['tryrun'][7]), round($value['tryrun'][4]), round($value['tryrun'][5]), $value['tryrun']['max'], $value['tryrun']['min'],
number_format(round($value['check'][1])), number_format(round($value['check'][3])), number_format(round($value['check'][6])), number_format(round($value['check'][7])), number_format(round($value['check'][4])), number_format(round($value['check'][5])), $value['check']['max'], $value['check']['min'], round($value['check'][1]), round($value['check'][3]), round($value['check'][6]), round($value['check'][7]), round($value['check'][4]), round($value['check'][5]), $value['check']['max'], $value['check']['min'],
number_format(round($value['delivery'][1])), number_format(round($value['delivery'][3])), number_format(round($value['delivery'][6])), number_format(round($value['delivery'][7])), number_format(round($value['delivery'][4])), number_format(round($value['delivery'][5])), $value['delivery']['max'], $value['delivery']['min'], round($value['delivery'][1]), round($value['delivery'][3]), round($value['delivery'][6]), round($value['delivery'][7]), round($value['delivery'][4]), round($value['delivery'][5]), $value['delivery']['max'], $value['delivery']['min'],
number_format(round($value['final'][1])), number_format(round($value['final'][3])), number_format(round($value['final'][6])), number_format(round($value['final'][7])), number_format(round($value['final'][4])), number_format(round($value['final'][5])), $value['final']['max'], $value['final']['min'], round($value['final'][1]), round($value['final'][3]), round($value['final'][6]), round($value['final'][7]), round($value['final'][4]), round($value['final'][5]), $value['final']['max'], $value['final']['min'],
number_format(round($value['A40001'])), number_format(round($value['A40008'])), number_format(round($value['total_budget'])), number_format(round($value['receivable_budget'])), number_format(round($value['invoice_budget'])), number_format(round($value['received_budget'])), $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities']) round($value['total_budget']), round($value['receivable_budget']), round($value['invoice_budget']), round($value['received_budget']), $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
]; ];
} else { } else {
$exclude_boga_array[$key] = [ $exclude_boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
number_format(round($value['sign'][1])), number_format(round($value['sign'][3])), number_format(round($value['sign'][6])), number_format(round($value['sign'][7])), number_format(round($value['sign'][4])), number_format(round($value['sign'][5])), $value['sign']['max'], $value['sign']['min'], round($value['sign'][1]), round($value['sign'][3]), round($value['sign'][6]), round($value['sign'][7]), round($value['sign'][4]), round($value['sign'][5]), $value['sign']['max'], $value['sign']['min'],
number_format(round($value['second'][1])), number_format(round($value['second'][3])), number_format(round($value['second'][6])), number_format(round($value['second'][7])), number_format(round($value['second'][4])), number_format(round($value['second'][5])), $value['second']['max'], $value['second']['min'], round($value['second'][1]), round($value['second'][3]), round($value['second'][6]), round($value['second'][7]), round($value['second'][4]), round($value['second'][5]), $value['second']['max'], $value['second']['min'],
number_format(round($value['arrive'][1])), number_format(round($value['arrive'][3])), number_format(round($value['arrive'][6])), number_format(round($value['arrive'][7])), number_format(round($value['arrive'][4])), number_format(round($value['arrive'][5])), $value['arrive']['max'], $value['arrive']['min'], round($value['arrive'][1]), round($value['arrive'][3]), round($value['arrive'][6]), round($value['arrive'][7]), round($value['arrive'][4]), round($value['arrive'][5]), $value['arrive']['max'], $value['arrive']['min'],
number_format(round($value['install'][1])), number_format(round($value['install'][3])), number_format(round($value['install'][6])), number_format(round($value['install'][7])), number_format(round($value['install'][4])), number_format(round($value['install'][5])), $value['install']['max'], $value['install']['min'], round($value['install'][1]), round($value['install'][3]), round($value['install'][6]), round($value['install'][7]), round($value['install'][4]), round($value['install'][5]), $value['install']['max'], $value['install']['min'],
number_format(round($value['tryrun'][1])), number_format(round($value['tryrun'][3])), number_format(round($value['tryrun'][6])), number_format(round($value['tryrun'][7])), number_format(round($value['tryrun'][4])), number_format(round($value['tryrun'][5])), $value['tryrun']['max'], $value['tryrun']['min'], round($value['tryrun'][1]), round($value['tryrun'][3]), round($value['tryrun'][6]), round($value['tryrun'][7]), round($value['tryrun'][4]), round($value['tryrun'][5]), $value['tryrun']['max'], $value['tryrun']['min'],
number_format(round($value['check'][1])), number_format(round($value['check'][3])), number_format(round($value['check'][6])), number_format(round($value['check'][7])), number_format(round($value['check'][4])), number_format(round($value['check'][5])), $value['check']['max'], $value['check']['min'], round($value['check'][1]), round($value['check'][3]), round($value['check'][6]), round($value['check'][7]), round($value['check'][4]), round($value['check'][5]), $value['check']['max'], $value['check']['min'],
number_format(round($value['delivery'][1])), number_format(round($value['delivery'][3])), number_format(round($value['delivery'][6])), number_format(round($value['delivery'][7])), number_format(round($value['delivery'][4])), number_format(round($value['delivery'][5])), $value['delivery']['max'], $value['delivery']['min'], round($value['delivery'][1]), round($value['delivery'][3]), round($value['delivery'][6]), round($value['delivery'][7]), round($value['delivery'][4]), round($value['delivery'][5]), $value['delivery']['max'], $value['delivery']['min'],
number_format(round($value['final'][1])), number_format(round($value['final'][3])), number_format(round($value['final'][6])), number_format(round($value['final'][7])), number_format(round($value['final'][4])), number_format(round($value['final'][5])), $value['final']['max'], $value['final']['min'], round($value['final'][1]), round($value['final'][3]), round($value['final'][6]), round($value['final'][7]), round($value['final'][4]), round($value['final'][5]), $value['final']['max'], $value['final']['min'],
number_format(round($value['A40001'])), number_format(round($value['A40008'])), number_format(round($value['total_budget'])), number_format(round($value['receivable_budget'])), number_format(round($value['invoice_budget'])), number_format(round($value['received_budget'])), $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities']) round($value['total_budget']), round($value['receivable_budget']), round($value['invoice_budget']), round($value['received_budget']), $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
]; ];
} }
$excel_aray[$key] = [ $excel_aray[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
number_format(round($value['sign'][1])), number_format(round($value['sign'][3])), number_format(round($value['sign'][6])), number_format(round($value['sign'][7])), number_format(round($value['sign'][4])), number_format(round($value['sign'][5])), $value['sign']['max'], $value['sign']['min'], round($value['sign'][1]), round($value['sign'][3]), round($value['sign'][6]), round($value['sign'][7]), round($value['sign'][4]), round($value['sign'][5]), $value['sign']['max'], $value['sign']['min'],
number_format(round($value['second'][1])), number_format(round($value['second'][3])), number_format(round($value['second'][6])), number_format(round($value['second'][7])), number_format(round($value['second'][4])), number_format(round($value['second'][5])), $value['second']['max'], $value['second']['min'], round($value['second'][1]), round($value['second'][3]), round($value['second'][6]), round($value['second'][7]), round($value['second'][4]), round($value['second'][5]), $value['second']['max'], $value['second']['min'],
number_format(round($value['arrive'][1])), number_format(round($value['arrive'][3])), number_format(round($value['arrive'][6])), number_format(round($value['arrive'][7])), number_format(round($value['arrive'][4])), number_format(round($value['arrive'][5])), $value['arrive']['max'], $value['arrive']['min'], round($value['arrive'][1]), round($value['arrive'][3]), round($value['arrive'][6]), round($value['arrive'][7]), round($value['arrive'][4]), round($value['arrive'][5]), $value['arrive']['max'], $value['arrive']['min'],
number_format(round($value['install'][1])), number_format(round($value['install'][3])), number_format(round($value['install'][6])), number_format(round($value['install'][7])), number_format(round($value['install'][4])), number_format(round($value['install'][5])), $value['install']['max'], $value['install']['min'], round($value['install'][1]), round($value['install'][3]), round($value['install'][6]), round($value['install'][7]), round($value['install'][4]), round($value['install'][5]), $value['install']['max'], $value['install']['min'],
number_format(round($value['tryrun'][1])), number_format(round($value['tryrun'][3])), number_format(round($value['tryrun'][6])), number_format(round($value['tryrun'][7])), number_format(round($value['tryrun'][4])), number_format(round($value['tryrun'][5])), $value['tryrun']['max'], $value['tryrun']['min'], round($value['tryrun'][1]), round($value['tryrun'][3]), round($value['tryrun'][6]), round($value['tryrun'][7]), round($value['tryrun'][4]), round($value['tryrun'][5]), $value['tryrun']['max'], $value['tryrun']['min'],
number_format(round($value['check'][1])), number_format(round($value['check'][3])), number_format(round($value['check'][6])), number_format(round($value['check'][7])), number_format(round($value['check'][4])), number_format(round($value['check'][5])), $value['check']['max'], $value['check']['min'], round($value['check'][1]), round($value['check'][3]), round($value['check'][6]), round($value['check'][7]), round($value['check'][4]), round($value['check'][5]), $value['check']['max'], $value['check']['min'],
number_format(round($value['delivery'][1])), number_format(round($value['delivery'][3])), number_format(round($value['delivery'][6])), number_format(round($value['delivery'][7])), number_format(round($value['delivery'][4])), number_format(round($value['delivery'][5])), $value['delivery']['max'], $value['delivery']['min'], round($value['delivery'][1]), round($value['delivery'][3]), round($value['delivery'][6]), round($value['delivery'][7]), round($value['delivery'][4]), round($value['delivery'][5]), $value['delivery']['max'], $value['delivery']['min'],
number_format(round($value['final'][1])), number_format(round($value['final'][3])), number_format(round($value['final'][6])), number_format(round($value['final'][7])), number_format(round($value['final'][4])), number_format(round($value['final'][5])), $value['final']['max'], $value['final']['min'], round($value['final'][1]), round($value['final'][3]), round($value['final'][6]), round($value['final'][7]), round($value['final'][4]), round($value['final'][5]), $value['final']['max'], $value['final']['min'],
number_format(round($value['A40001'])), number_format(round($value['A40008'])), number_format(round($value['total_budget'])), number_format(round($value['receivable_budget'])), number_format(round($value['invoice_budget'])), number_format(round($value['received_budget'])), $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities']) round($value['total_budget']), round($value['receivable_budget']), round($value['invoice_budget']), round($value['received_budget']), $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
]; ];
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 //['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數 //[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
@ -1714,48 +1324,45 @@ foreach ($arrayData as $key => $value) {
} }
$facility_array[$valkey] = [ $facility_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), $val['sign'][6], $val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
$val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), $val['second'][6], $val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
$val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), $val['arrive'][6], $val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
$val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), $val['install'][6], $val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
$val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), $val['tryrun'][6], $val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
$val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), $val['check'][6], $val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
$val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), $val['delivery'][6], $val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
$val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), $val['final'][6], $val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
str_replace('<br>', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget'])) str_replace('<br>', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
]; ];
if ($value['sign'][0] == "寶佳出貨前30天") { if ($value['sign'][0] == "寶佳出貨前30天") {
$facility_boga_array[$valkey] = [ $facility_boga_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), $val['sign'][6], $val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
$val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), $val['second'][6], $val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
$val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), $val['arrive'][6], $val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
$val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), $val['install'][6], $val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
$val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), $val['tryrun'][6], $val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
$val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), $val['check'][6], $val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
$val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), $val['delivery'][6], $val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
$val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), $val['final'][6], $val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
str_replace('<br>', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget'])) str_replace('<br>', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
]; ];
} else { } else {
$facility_exclude_boga_array[$valkey] = [ $facility_exclude_boga_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], $valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$val['sign'][0], number_format(round($val['sign'][1])), $val['sign'][2], number_format(round($val['sign'][3])), number_format(round($val['sign'][4])), number_format(round($val['sign'][5])), $val['sign'][6], $val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
$val['second'][0], number_format(round($val['second'][1])), $val['second'][2], number_format(round($val['second'][3])), number_format(round($val['second'][4])), number_format(round($val['second'][5])), $val['second'][6], $val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
$val['arrive'][0], number_format(round($val['arrive'][1])), $val['arrive'][2], number_format(round($val['arrive'][3])), number_format(round($val['arrive'][4])), number_format(round($val['arrive'][5])), $val['arrive'][6], $val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
$val['install'][0], number_format(round($val['install'][1])), $val['install'][2], number_format(round($val['install'][3])), number_format(round($val['install'][4])), number_format(round($val['install'][5])), $val['install'][6], $val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
$val['tryrun'][0], number_format(round($val['tryrun'][1])), $val['tryrun'][2], number_format(round($val['tryrun'][3])), number_format(round($val['tryrun'][4])), number_format(round($val['tryrun'][5])), $val['tryrun'][6], $val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
$val['check'][0], number_format(round($val['check'][1])), $val['check'][2], number_format(round($val['check'][3])), number_format(round($val['check'][4])), number_format(round($val['check'][5])), $val['check'][6], $val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
$val['delivery'][0], number_format(round($val['delivery'][1])), $val['delivery'][2], number_format(round($val['delivery'][3])), number_format(round($val['delivery'][4])), number_format(round($val['delivery'][5])), $val['delivery'][6], $val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
$val['final'][0], number_format(round($val['final'][1])), $val['final'][2], number_format(round($val['final'][3])), number_format(round($val['final'][4])), number_format(round($val['final'][5])), $val['final'][6], $val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
str_replace('<br>', '; ', $val['status']), number_format(round($val['A40001'])), number_format(round($val['A40008'])), number_format(round($val['total_budget'])), number_format(round($val['receivable_budget'])) str_replace('<br>', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
]; ];
} }
} }
} }
$average_A40001 = round($sum_A40001 / $sum_facility, 2);
$average_A40008 = round($sum_A40008 / $sum_facility, 2);
$average_budget = round($sum_total_budget / $sum_facility, 2);
$total_data = json_encode($excel_aray); $total_data = json_encode($excel_aray);
$boga_data = json_encode($boga_array); $boga_data = json_encode($boga_array);
@ -1819,51 +1426,6 @@ $facility_exclude_boga_data = json_encode($facility_exclude_boga_array);
</div> </div>
</div> </div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong>合約 (新梯)統整資訊</strong></h3>
</div>
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<label for="sum_total_budget">合約總金額</label>
<input type="text" class="form-control" id="sum_total_budget" name="sum_total_budget" value="<?= number_format($sum_total_budget) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_A40001">合約設備總金額</label>
<input type="text" class="form-control" id="sum_A40001" name="sum_A40001" value="<?= number_format($sum_A40001) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_A40008">合約安裝總金額</label>
<input type="text" class="form-control" id="sum_A40008" name="sum_A40008" value="<?= number_format($sum_A40008) ?>" disabled>
</div>
<div class="col-md-3">
<label for="sum_facility">總台數</label>
<input type="text" class="form-control" id="sum_facility" name="sum_facility" value="<?= number_format($sum_facility) ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="average_budget">平均金額</label>
<input type="text" class="form-control" id="average_budget" name="average_budget" value="<?= number_format($average_budget) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_A40001">設備平均金額</label>
<input type="text" class="form-control" id="average_A40001" name="average_A40001" value="<?= number_format($average_A40001) ?>" disabled>
</div>
<div class="col-md-3">
<label for="average_A40008">安裝平均金額</label>
<input type="text" class="form-control" id="average_A40008" name="average_A40008" value="<?= number_format($average_A40008) ?>" disabled>
</div>
</div>
</form>
</div>
<?php
include "./footer.php";
?>
<div style="width:98%;margin:1% ;overflow-x: auto;"> <div style="width:98%;margin:1% ;overflow-x: auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;"> <table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead> <thead>
@ -1973,6 +1535,7 @@ include "./footer.php";
<script> <script>
function showContract(BillNo) { function showContract(BillNo) {
window.open('account-receivable-contract.php?BillNo=' + BillNo + '&<?= $token_link ?>', '發票範例', config = 'height=600, width=1200'); window.open('account-receivable-contract.php?BillNo=' + BillNo + '&<?= $token_link ?>', '發票範例', config = 'height=600, width=1200');
console.log(BillNo);
} }
function test() { function test() {
@ -2015,6 +1578,7 @@ include "./footer.php";
} }
function bogaData() { function bogaData() {
console.log(<?= $boga_data ?>);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?type=boga&<?= $token_link ?>"; var url = window.location.origin + "/wms/account-receivable-excel.php?type=boga&<?= $token_link ?>";
xhr.open('POST', url, true); xhr.open('POST', url, true);

876
wms/account-receivable-index.php

File diff suppressed because it is too large

BIN
wms/account-receivable-test.xlsx

Binary file not shown.

13
wms/cont/apply_form.php

@ -67,11 +67,10 @@ $subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key);
$wf->setFormData(['discount' => 100]); $wf->setFormData(['discount' => 100]);
$flowName = $wf->getFlowName(); $flowName = $wf->getFlowName();
$assigner = $wf->getAssignerList(); $assigner = $wf->getAssignerList();
$assign_status = $wf->getAssignStatus($assigner); $assign_status = $wf->getAssignStatus($assigner);
echo '<pre>'; // echo '<pre>';
print_r($assigner); // print_r($assign_status);
echo '</pre>'; // echo '</pre>';
$if_show_assign = true; $if_show_assign = true;
//加載流程圖 //加載流程圖
//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); //$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID());
@ -247,8 +246,8 @@ if ($result['department_id'] == '511') {
$managerid = 'M0137'; $managerid = 'M0137';
$managername = '劉永德'; $managername = '劉永德';
} else if ($result['department_id'] == '512') { } else if ($result['department_id'] == '512') {
$managerid = 'M0137'; $managerid = 'M0054';
$managername = '劉永德'; $managername = '陳志文';
} else if ($result['department_id'] == '513') { } else if ($result['department_id'] == '513') {
$managerid = 'M0086'; $managerid = 'M0086';
$managername = '李烘銘'; $managername = '李烘銘';
@ -662,7 +661,7 @@ if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' |
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan='18' ;><button onClick='addRow()' type="button" style='float:right' class="btn btn-link btn-md">+新增</button></td> <td colspan='18'><button onClick='addRow()' type="button" style='float:right' class="btn btn-link btn-md">+新增</button></td>
</tr> </tr>
<!-- <tr style='margin-top:0px;text-align:center'> --> <!-- <tr style='margin-top:0px;text-align:center'> -->
<?php <?php

140
wms/contract/api/testT8API.php

@ -1,86 +1,66 @@
<?php <?php
require_once('../../T8_Authorization_from_bpm.php'); require_once('../../T8_Authorization_from_bpm.php');
require_once('../connt8.php'); require_once('../connt8.php');
$sql = "SELECT * FROM salIncomeApplyMaster WHERE BillNo = '3TX10701' ";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '<pre>';
print_r($result);
echo '</pre>';
// $date = date("Y-m-d");
// $date1 = str_replace('-', '', $date);
// $arr = [ $validation = get_Auth();
// "date" => $date1 $data = [
// ]; [
"name" => "OtherStockOutMtable",
"rows" => [
[
"BillNo" => "00850110", // 單據編號 varchar(20)
"BillDate" => 20210427, // 單據日期 int
"OrgId" => "1000", //組織 varchar(20)
"FOrgId" => "1000", //核算組織 varchar(20)
"TypeId" => "OS", //單據類型 varchar(10)
"BizPartnerId" => "", //往來對象(供應商) 可為空
"PersonId" => "C0003", // 經辦人員 varchar(20)
"DeptId" => "250", // 經辦部門 varchar(20)
"CompId" => "1001" // 公司 varchar(20)
]
]
], [
"name" => "OtherStockOutDetail",
"rows" => [
[
"BillNo" => "00850110", //單據編號 varchar(20)
"RowCode" => 1, // 序號 int(10)
"MaterialId" => "MX00021003", // 產品代碼 -> 產品集成 varchar(40)
"SupplyOrgId" => "1000", // 供貨組織代碼 varchar(20)
"SQuantity" => 1, // 交易數量 numeric(19)
"WarehouseId" => "100" // 倉庫代碼 varchar(20)
]
]
]
];
$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKOTHERSTOCKOUT/PostERPData';
$header = [
"CHI_Authorization :" . $validation
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
// echo '<pre>'; $response = curl_exec($ch);
// print_r($arr); if ($response === false) {
// echo '</pre>'; echo 'Curl error: ' . curl_error($ch);
// $validation = get_Auth(); } else {
// $data = [ $result = json_decode($response, true);
// [ if ($result['Status'] == 'Error') {
// "name" => "OtherStockOutMtable", echo '<pre>';
// "rows" => [ print_r($result);
// [ echo '</pre>';
// "BillNo" => "00850110", // 單據編號 varchar(20) echo 'API 傳入錯誤,' . $result['ErrorMsg'];
// "BillDate" => 20210427, // 單據日期 int } else {
// "OrgId" => "1000", //組織 varchar(20) echo '<pre>';
// "FOrgId" => "1000", //核算組織 varchar(20) print_r($result['Status']);
// "TypeId" => "OS", //單據類型 varchar(10) echo '</pre>';
// "BizPartnerId" => "", //往來對象(供應商) 可為空 return $result;
// "PersonId" => "C0003", // 經辦人員 varchar(20) }
// "DeptId" => "250", // 經辦部門 varchar(20) }
// "CompId" => "1001" // 公司 varchar(20)
// ]
// ]
// ], [
// "name" => "OtherStockOutDetail",
// "rows" => [
// [
// "BillNo" => "00850110", //單據編號 varchar(20)
// "RowCode" => 1, // 序號 int(10)
// "MaterialId" => "MX00021003", // 產品代碼 -> 產品集成 varchar(40)
// "SupplyOrgId" => "1000", // 供貨組織代碼 varchar(20)
// "SQuantity" => 1, // 交易數量 numeric(19)
// "WarehouseId" => "100" // 倉庫代碼 varchar(20)
// ]
// ]
// ]
// ];
// $data = file_get_contents('test.json');
// echo '<pre>';
// print_r($data);
// echo '</pre>';
// $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKOTHERSTOCKOUT/PostERPData';
// $header = [
// "CHI_Authorization :" . $validation
// ];
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
// curl_setopt($ch, CURLOPT_POST, 1);
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
// $response = curl_exec($ch); curl_close($ch);
// if ($response === false) {
// echo 'Curl error: ' . curl_error($ch);
// } else {
// $result = json_decode($response, true);
// if ($result['Status'] == 'Error') {
// echo '<pre>';
// print_r($result);
// echo '</pre>';
// echo 'API 傳入錯誤,' . $result['ErrorMsg'];
// } else {
// echo '<pre>';
// print_r($result['Status']);
// echo '</pre>';
// return $result;
// }
// }
// curl_close($ch);

2
wms/contract/contract-download.php

@ -26,7 +26,7 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
$contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); $contracts = $stmt->fetchAll(PDO::FETCH_ASSOC);
$contract = $contracts[0]; $contract = $contracts[0];
$contract_apply_id = $contract['id']; $contract_apply_id = $contract['id'];
if (($contract['status'] !== "YY" && $user_id != 'M0107') && $user_id != 'M0174' && $user_id != 'M0225') { if (($contract['status'] !== "YY" && $user_id != 'M0107' && $user_id != "TEST02" && $user_id == "TEST01") && $user_id != 'M0174' && $user_id != 'M0225') {
echo '<script type="text/javascript"> echo '<script type="text/javascript">
alert("非法訪問。"); alert("非法訪問。");
window.history.back(); window.history.back();

579
wms/contract/contract-new-apply.php

@ -1,8 +1,8 @@
<?php <?php
include_once("../header.php"); include_once("../header.php");
require_once("./conn.php"); require_once("./conn.php");
if(!(isset($_GET['id']) && !empty($_GET['id']))){ if (!(isset($_GET['id']) && !empty($_GET['id']))) {
$para = "function_name=pricereview&".$token_link; $para = "function_name=pricereview&" . $token_link;
echo "<script>alert('非法訪問!!!');</script>"; echo "<script>alert('非法訪問!!!');</script>";
echo "<script>window.history.go(-1);</script>"; echo "<script>window.history.go(-1);</script>";
exit; exit;
@ -15,25 +15,25 @@ LEFT JOIN account AS person_account ON contract_new_apply.review_person_id = per
LEFT JOIN account AS person_final_account ON contract_new_apply.review_final_person_id = person_final_account.accountid LEFT JOIN account AS person_final_account ON contract_new_apply.review_final_person_id = person_final_account.accountid
WHERE contract_new_apply.mid = :mid"; WHERE contract_new_apply.mid = :mid";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid',$id); $stmt->bindParam(':mid', $id);
$stmt->execute(); $stmt->execute();
$contract_new_apply = $stmt->fetch(PDO::FETCH_ASSOC); $contract_new_apply = $stmt->fetch(PDO::FETCH_ASSOC);
$contract = $contract_new_apply; $contract = $contract_new_apply;
$isFirst = empty($contract_new_apply) ? 1 : 0; $isFirst = empty($contract_new_apply) ? 1 : 0;
if(empty($contract_new_apply)){ if (empty($contract_new_apply)) {
$sql_str = "SELECT pricereview_main.contractno, pricereview_main.ekind, pricereview_main.person, pricereview_main.company, pricereview_main.case_name, pricereview_main.address, pricereview_main.price_lowest, pricereview_main.price_total, pricereview_main.price_rate, pricereview_main.status as priceview_status, pricereview_main.id as mainid, account.name as accountname $sql_str = "SELECT pricereview_main.contractno, pricereview_main.ekind, pricereview_main.person, pricereview_main.company, pricereview_main.case_name, pricereview_main.address, pricereview_main.price_lowest, pricereview_main.price_total, pricereview_main.price_rate, pricereview_main.status as priceview_status, pricereview_main.id as mainid, account.name as accountname
FROM pricereview_main FROM pricereview_main
JOIN account ON pricereview_main.person = account.accountid JOIN account ON pricereview_main.person = account.accountid
WHERE pricereview_main.id = :id"; WHERE pricereview_main.id = :id";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id',$id); $stmt->bindParam(':id', $id);
$stmt->execute(); $stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC); $contract = $stmt->fetch(PDO::FETCH_ASSOC);
// print_r($contract); // print_r($contract);
$accounttype = "M"; $accounttype = "M";
$sql_str = "SELECT * FROM account WHERE accounttype = :accounttype"; $sql_str = "SELECT * FROM account WHERE accounttype = :accounttype";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype',$accounttype); $stmt->bindParam(':accounttype', $accounttype);
$stmt->execute(); $stmt->execute();
$persons = $stmt->fetchAll(PDO::FETCH_ASSOC); $persons = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC"; $sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC";
@ -50,7 +50,7 @@ if(empty($contract_new_apply)){
$stmt->execute(); $stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC); $items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$total_items = 0; $total_items = 0;
foreach($items as $item){ foreach ($items as $item) {
$total_items += $item['item_qty']; $total_items += $item['item_qty'];
} }
$sql_str = "SELECT * FROM pricereview_pay WHERE mid = :mid ORDER BY pay_kind ASC"; $sql_str = "SELECT * FROM pricereview_pay WHERE mid = :mid ORDER BY pay_kind ASC";
@ -60,15 +60,14 @@ if(empty($contract_new_apply)){
$pays = $stmt->fetchAll(PDO::FETCH_ASSOC); $pays = $stmt->fetchAll(PDO::FETCH_ASSOC);
$price_a = 0; $price_a = 0;
$price_b = 0; $price_b = 0;
foreach($pays as $pay){ foreach ($pays as $pay) {
if($pay['pay_kind'] <= 4){ if ($pay['pay_kind'] <= 4) {
$price_a = $price_a + $pay['pay_amount']; $price_a = $price_a + $pay['pay_amount'];
}else{ } else {
$price_b = $price_b + $pay['pay_amount']; $price_b = $price_b + $pay['pay_amount'];
} }
} }
} else {
}else{
$mid = $contract['mid']; $mid = $contract['mid'];
$contract_new_apply_id = $contract_new_apply['id']; $contract_new_apply_id = $contract_new_apply['id'];
$sql_str = "SELECT * FROM contract_new_apply_pays WHERE mid = :mid ORDER BY pay_kind ASC"; $sql_str = "SELECT * FROM contract_new_apply_pays WHERE mid = :mid ORDER BY pay_kind ASC";
@ -84,10 +83,10 @@ if(empty($contract_new_apply)){
$items = $stmt->fetchAll(PDO::FETCH_ASSOC); $items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$price_a = 0; $price_a = 0;
$price_b = 0; $price_b = 0;
foreach($pays as $pay){ foreach ($pays as $pay) {
if($pay['pay_kind'] <= 4){ if ($pay['pay_kind'] <= 4) {
$price_a = $price_a + $pay['pay_amount']; $price_a = $price_a + $pay['pay_amount'];
}else{ } else {
$price_b = $price_b + $pay['pay_amount']; $price_b = $price_b + $pay['pay_amount'];
} }
} }
@ -112,7 +111,7 @@ $person = $contract['person'];
<script defer src="./js/alpinejs/cdn.min.js"></script> <script defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js"></script> <script src="./js/axios/axios.min.js"></script>
<div class="contract-new-apply-component" x-data="contractNewApply"> <div class="contract-new-apply-component" x-data="contractNewApply">
<div class="form" method="post" id="form" enctype="multipart/form-data" > <div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name='form_name' value="main_form" /> <input type="hidden" name='form_name' value="main_form" />
<div> <div>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> <table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
@ -142,7 +141,7 @@ $person = $contract['person'];
</td> </td>
<td style="vertical-align: middle">統一編號/身分證字號</td> <td style="vertical-align: middle">統一編號/身分證字號</td>
<td> <td>
<input class="form-control disabled_select" type="text" x-model="data.vat" disabled > <input class="form-control disabled_select" type="text" x-model="data.vat" disabled>
<p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">合約書申請日期</td> <td style="vertical-align: middle">合約書申請日期</td>
@ -161,41 +160,41 @@ $person = $contract['person'];
<tr> <tr>
<td style="vertical-align: middle">案件名稱</td> <td style="vertical-align: middle">案件名稱</td>
<td style="vertical-align: middle" colspan="3"> <td style="vertical-align: middle" colspan="3">
<input class="form-control disabled_select" type="text" x-model="data.case_name" disabled > <input class="form-control disabled_select" type="text" x-model="data.case_name" disabled>
<p class="alerttext" x-show="data.case_name==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.case_name==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">立約人</td> <td style="vertical-align: middle">立約人</td>
<td style="vertical-align: middle"> <td style="vertical-align: middle">
<input class="form-control disabled_select" type="text" x-model="data.company" disabled> <input class="form-control disabled_select" type="text" x-model="data.company" disabled>
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">負責人</td> <td style="vertical-align: middle">負責人</td>
<td style="vertical-align: middle"> <td style="vertical-align: middle">
<input class="form-control disabled_select" type="text" x-model="data.manager" disabled > <input class="form-control disabled_select" type="text" x-model="data.manager" disabled>
<p class="alerttext" x-show="data.manager==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.manager==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align: middle">含稅給約總價</td> <td style="vertical-align: middle">含稅給約總價</td>
<td colspan="3" style="vertical-align: middle"> <td colspan="3" style="vertical-align: middle">
<input class="form-control disabled_select lock" type="number" x-model="data.total_price" > <input class="form-control disabled_select lock" type="number" x-model="data.total_price">
<p class="alerttext" x-show="data.total_price==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.total_price==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">含稅貸款(A)</td> <td style="vertical-align: middle">含稅貸款(A)</td>
<td style="vertical-align: middle"> <td style="vertical-align: middle">
<input class="form-control disabled_select lock" type="number" x-model="data.price_a" > <input class="form-control disabled_select lock" type="number" x-model="data.price_a">
<p class="alerttext" x-show="data.price_a==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.price_a==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">含稅安裝款(A)</td> <td style="vertical-align: middle">含稅安裝款(A)</td>
<td style="vertical-align: middle"> <td style="vertical-align: middle">
<input class="form-control disabled_select lock" type="number" x-model="data.price_b" > <input class="form-control disabled_select lock" type="number" x-model="data.price_b">
<p class="alerttext" x-show="data.price_b==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.price_b==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align: middle">聯絡地址</td> <td style="vertical-align: middle">聯絡地址</td>
<td style="vertical-align: middle" colspan=3> <td style="vertical-align: middle" colspan=3>
<input class="form-control disabled_select" type="text" x-model="data.address" disabled> <input class="form-control disabled_select" type="text" x-model="data.address" disabled>
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">免保期限</td> <td style="vertical-align: middle">免保期限</td>
@ -226,16 +225,16 @@ $person = $contract['person'];
</td> --> </td> -->
<td style="vertical-align: middle">完工期限</td> <td style="vertical-align: middle">完工期限</td>
<td style="vertical-align: middle" colspan=7> <td style="vertical-align: middle" colspan=7>
<div class="ui labeled input"> <div class="ui labeled input">
<div class="ui label"> <div class="ui label">
乙方應於貨抵工地後每台 乙方應於貨抵工地後每台
</div> </div>
<input type="text" placeholder="30" style="width:45px;padding:0 12px;" x-model="data.workdeadline_a"> <input type="text" placeholder="30" style="width:45px;padding:0 12px;" x-model="data.workdeadline_a">
<div class="ui label"> <div class="ui label">
日內安裝完成 日內安裝完成
</div>
<div class="note label" x-show="data.workdeadline_note && data.workdeadline_note != 'null'" style="font-size:14px;color:#BD0606" x-text="'說明:' + data.workdeadline_note"></div>
</div> </div>
<div class="note label" x-show="data.workdeadline_note && data.workdeadline_note != 'null'" style="font-size:14px;color:#BD0606" x-text="'說明:' + data.workdeadline_note"></div>
</div>
<!-- <input class="form-control disabled_select" type="text" x-model="data.deadline" > --> <!-- <input class="form-control disabled_select" type="text" x-model="data.deadline" > -->
<p class="alerttext" x-show="data.deadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.deadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
@ -244,7 +243,7 @@ $person = $contract['person'];
<tr> <tr>
<td style="vertical-align: middle">交貨地點</td> <td style="vertical-align: middle">交貨地點</td>
<td style="vertical-align: middle" colspan=3> <td style="vertical-align: middle" colspan=3>
<input class="form-control disabled_select" type="text" x-model="data.tradeaddress" > <input class="form-control disabled_select" type="text" x-model="data.tradeaddress">
<p class="alerttext" x-show="data.tradeaddress==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.tradeaddress==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">交貨期限</td> <td style="vertical-align: middle">交貨期限</td>
@ -282,25 +281,27 @@ $person = $contract['person'];
</thead> </thead>
<tbody style="font-weight: bolder;margin-bottom: 20px"> <tbody style="font-weight: bolder;margin-bottom: 20px">
<template x-for="(item, idx) in data.items"> <template x-for="(item, idx) in data.items">
<tr> <tr>
<td style="vertical-align: middle"><p x-text="idx+1"></p></td> <td style="vertical-align: middle">
<td colspan="3" style="vertical-align: middle"> <p x-text="idx+1"></p>
<input class="form-control disabled_select lock" type="text" x-model="item.item_spec" > </td>
<p class="alerttext" x-show="data.item_spec==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <td colspan="3" style="vertical-align: middle">
</td> <input class="form-control disabled_select lock" type="text" x-model="item.item_spec">
<td style="vertical-align: middle"> <p class="alerttext" x-show="data.item_spec==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<span x-text="item.item_qty + '台'" style="padding:0 20px"></span> </td>
</td> <td style="vertical-align: middle">
<td colspan="3" style="vertical-align: middle"> <span x-text="item.item_qty + '台'" style="padding:0 20px"></span>
<input class="form-control disabled_select lock" type="number" x-model="item.item_price_ct" > </td>
<p class="alerttext" x-show="data.item_price_ct==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <td colspan="3" style="vertical-align: middle">
</td> <input class="form-control disabled_select lock" type="number" x-model="item.item_price_ct">
</tr> <p class="alerttext" x-show="data.item_price_ct==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
</template> </template>
<tr> <tr>
<td colspan=4></td> <td colspan=4></td>
<td>電梯總數</td> <td>電梯總數</td>
<td colspan='3'> <span x-text="data.total_items + '台'" style="padding:0 20px"></span></td> <td colspan='3'> <span x-text="data.total_items + '台'" style="padding:0 20px"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -334,99 +335,99 @@ $person = $contract['person'];
</td> </td>
</tr> </tr>
</thead> </thead>
<tbody style="font-weight: bolder;margin-bottom: 20px" > <tbody style="font-weight: bolder;margin-bottom: 20px">
<?php <?php
$day = 0; $day = 0;
$styles = [ $styles = [
1=> "訂金", 1 => "訂金",
2=> "二次款", 2 => "二次款",
3=>"貨到款", 3 => "貨到款",
4=>"", 4 => "",
5=>"安裝款", 5 => "安裝款",
6=>"尾款", 6 => "尾款",
7=>"", 7 => "",
]; ];
$paydate = [ $paydate = [
1=>"合約日", 1 => "合約日",
2=>"合約日", 2 => "合約日",
3=>"出貨日", 3 => "出貨日",
4=>"", 4 => "",
5=>"竣檢日", 5 => "竣檢日",
6=>"交車日", 6 => "交車日",
7=>"" 7 => ""
]; ];
?>
<?php foreach($pays as $pay):
if($pay['pay_scale'] == 0) continue;
?> ?>
<tr> <?php foreach ($pays as $pay) :
<td> if ($pay['pay_scale'] == 0) continue;
<p style='text-align:center'><?php echo ($pay['pay_kind'] <=4) ? "銷售" : "按裝"; ?></p> ?>
</td> <tr>
<td> <td>
<p style='text-align:center'><?php echo $styles[$pay['pay_kind']]; ?></p> <p style='text-align:center'><?php echo ($pay['pay_kind'] <= 4) ? "銷售" : "按裝"; ?></p>
</td> </td>
<td> <td>
<?php if($pay['pay_kind'] == 1){ ?> <p style='text-align:center'><?php echo $styles[$pay['pay_kind']]; ?></p>
<template x-if="pays[1] > 0"> </td>
<p style='text-align:center'>簽約後<span x-text="pays[1]"></span>天付訂金</p> <td>
</template> <?php if ($pay['pay_kind'] == 1) { ?>
<template x-if="pays[1] <= 0"> <template x-if="pays[1] > 0">
<p style='text-align:center'>簽約後付訂金</p> <p style='text-align:center'>簽約後<span x-text="pays[1]"></span>天付訂金</p>
</template> </template>
<?php } elseif($pay['pay_kind'] == 2){ ?> <template x-if="pays[1] <= 0">
<template x-if="pays[2] > 0"> <p style='text-align:center'>簽約後付訂金</p>
<p style='text-align:center'>簽約後<span x-text="pays[2]"></span>天付二次款</p> </template>
</template> <?php } elseif ($pay['pay_kind'] == 2) { ?>
<template x-if="pays[2] <= 0"> <template x-if="pays[2] > 0">
<p style='text-align:center'>簽約後付二次款</p> <p style='text-align:center'>簽約後<span x-text="pays[2]"></span>天付二次款</p>
</template> </template>
<?php } elseif($pay['pay_kind'] == 3){ ?> <template x-if="pays[2] <= 0">
<p style='text-align:center'>貨抵工地付貨到款</p> <p style='text-align:center'>簽約後付二次款</p>
<?php } elseif($pay['pay_kind'] == 5){ ?> </template>
<template x-if="pays[5] > 0"> <?php } elseif ($pay['pay_kind'] == 3) { ?>
<p style='text-align:center'>安裝完成後<span x-text="pays[5]"></span>天收款</p> <p style='text-align:center'>貨抵工地付貨到款</p>
</template> <?php } elseif ($pay['pay_kind'] == 5) { ?>
<template x-if="pays[5] <= 0"> <template x-if="pays[5] > 0">
<p style='text-align:center'>安裝完成後收款</p> <p style='text-align:center'>安裝完成後<span x-text="pays[5]"></span>天收款</p>
</template> </template>
<?php } elseif($pay['pay_kind'] == 6){ ?> <template x-if="pays[5] <= 0">
<template x-if="pays[6] > 0"> <p style='text-align:center'>安裝完成後收款</p>
<p style='text-align:center'>交車後<span x-text="pays[6]"></span>天付尾款</p> </template>
</template> <?php } elseif ($pay['pay_kind'] == 6) { ?>
<template x-if="pays[6] <= 0"> <template x-if="pays[6] > 0">
<p style='text-align:center'>交車後付尾款</p> <p style='text-align:center'>交車後<span x-text="pays[6]"></span>天付尾款</p>
</template> </template>
<?php } else{ ?> <template x-if="pays[6] <= 0">
<p style='text-align:center'>-</p> <p style='text-align:center'>交車後付尾款</p>
<?php } ?> </template>
</td> <?php } else { ?>
<td> <p style='text-align:center'>-</p>
<p style='text-align:center'><?php echo $paydate[$pay['pay_kind']]; ?></p> <?php } ?>
</td> </td>
<td> <td>
<div class="ui labeled input"> <p style='text-align:center'><?php echo $paydate[$pay['pay_kind']]; ?></p>
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind'];?>].condition_date" disabled > </td>
<div class="ui label"> <td>
<div class="ui labeled input">
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind']; ?>].condition_date" disabled>
<div class="ui label">
</div>
</div> </div>
</div> </td>
</td> <td>
<td> <div class="ui labeled input">
<div class="ui labeled input"> <input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind']; ?>].pay_period" disabled>
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind'];?>].pay_period" disabled > <div class="ui label">
<div class="ui label">
</div>
</div> </div>
</div> </td>
</td> <td>
<td> <p style='text-align:center' x-text="pays[<?php echo $pay['pay_kind']; ?>].scale + '%'"><?php echo $pay['pay_scale'] ?>%</p>
<p style='text-align:center' x-text="pays[<?php echo $pay['pay_kind'];?>].scale + '%'"><?php echo $pay['pay_scale'] ?>%</p> </td>
</td> <td>
<td> <p style='text-align:center' x-text="localnumber(data.total_price * pays[<?php echo $pay['pay_kind']; ?>].scale/100)"></p>
<p style='text-align:center' x-text="localnumber(data.total_price * pays[<?php echo $pay['pay_kind'];?>].scale/100)"></p> </td>
</td> </tr>
</tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
@ -459,15 +460,15 @@ $person = $contract['person'];
</td> </td>
<td colspan="1">附件上傳</td> <td colspan="1">附件上傳</td>
<td colspan="4"> <td colspan="4">
<?php if($status < 1): ?> <?php if ($status < 1) : ?>
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> <input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
<?php endif; ?> <?php endif; ?>
<template x-for="file in data.originfiles"> <template x-for="file in data.originfiles">
<template x-if="file"> <template x-if="file">
<div> <div>
<a :href="'./images/contracts_new_files/' + file.file_name" download x-text="file.file_name" ></a> <a :href="'./images/contracts_new_files/' + file.file_name" download x-text="file.file_name"></a>
<?php if($status <= 0): ?> <?php if ($status <= 0) : ?>
<span @click="removeFile(file.id)" style="margin-left:10px;cursor:pointer;color:#f019">X</span> <span @click="removeFile(file.id)" style="margin-left:10px;cursor:pointer;color:#f019">X</span>
<?php endif; ?> <?php endif; ?>
</div> </div>
</template> </template>
@ -492,43 +493,43 @@ $person = $contract['person'];
<td>結果</td> <td>結果</td>
<td colspan=2>意見</td> <td colspan=2>意見</td>
<td>時間</td> <td>時間</td>
<td colspan=2><?php if(($user_id === "M0174" || $user_id === "M0107" || $user_id === "M0060") && $status == 1): ?>審核意見<?php endif; ?></td> <td colspan=2><?php if (($user_id === "M0174" || $user_id === "M0107" || $user_id === "M0060" || $user_id == "TEST02" || $user_id == "TEST03") && $status == 1) : ?>審核意見<?php endif; ?></td>
</tr> </tr>
<tr> <tr>
<td>營業員</td> <td>營業員</td>
<td><span x-text="data.salesmanname + '(' + data.salesman + ')'"></span></td> <td><span x-text="data.salesmanname + '(' + data.salesman + ')'"></span></td>
<td> <td>
<?php if($status >= 1): ?><span class="successtext">已送審</span><?php endif; ?> <?php if ($status >= 1) : ?><span class="successtext">已送審</span><?php endif; ?>
<?php if($status == 0): ?><span class="readtext">暫存</span><?php endif; ?> <?php if ($status == 0) : ?><span class="readtext">暫存</span><?php endif; ?>
<?php if($status == -1): ?><span class="">未提交</span><?php endif; ?> <?php if ($status == -1) : ?><span class="">未提交</span><?php endif; ?>
</td> </td>
<td colspan=2>---</td> <td colspan=2>---</td>
<td><?php echo ($contract['submit_date']) ?? "---"; ?> </td> <td><?php echo ($contract['submit_date']) ?? "---"; ?> </td>
<td colspan=2 rowspan="3"> <td colspan=2 rowspan="3">
<?php if(($user_id === "M0174" || $user_id === "M0107" || $user_id === "M0060") && $status == 1): ?> <?php if (($user_id === "M0174" || $user_id === "M0107" || $user_id === "M0060" || $user_id == "TEST02" || $user_id == "TEST03") && $status == 1) : ?>
<textarea class="form-control opinion" x-model="data.review_comment"></textarea> <textarea class="form-control opinion" x-model="data.review_comment"></textarea>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>業務承辦人</td> <td>業務承辦人</td>
<td><span><?php echo (!isset($contract['review_person_name']) || empty($contract['review_person_name'])) ? "---" : $contract['review_person_name'] ."(".$contract['review_person_id'].")"; ?></span></td> <td><span><?php echo (!isset($contract['review_person_name']) || empty($contract['review_person_name'])) ? "---" : $contract['review_person_name'] . "(" . $contract['review_person_id'] . ")"; ?></span></td>
<td> <td>
<?php if(($status == 1 || $status == 3) && $progress >= 2): ?><span class="successtext">已同意</span><?php endif; ?> <?php if (($status == 1 || $status == 3) && $progress >= 2) : ?><span class="successtext">已同意</span><?php endif; ?>
<?php if($status == 2): ?><span class="failtext">結案不同意</span><?php endif; ?> <?php if ($status == 2) : ?><span class="failtext">結案不同意</span><?php endif; ?>
<?php if($status < 2 && $progress < 2): ?><span>---</span><?php endif; ?> <?php if ($status < 2 && $progress < 2) : ?><span>---</span><?php endif; ?>
</td> </td>
<td colspan=2><?php echo $contract['review_comment'] ?? "---"; ?></td> <td colspan=2><?php echo $contract['review_comment'] ?? "---"; ?></td>
<td><?php echo $contract['review_date'] ?? "---"; ?></td> <td><?php echo $contract['review_date'] ?? "---"; ?></td>
</tr> </tr>
<tr> <tr>
<td>業務部協理</td> <td>業務部協理</td>
<td><span><?php echo (!isset($contract['review_final_person_name']) || empty($contract['review_final_person_name'])) ? "---" : $contract['review_final_person_name'] ."(".$contract['review_final_person_id'].")"; ?></span></td> <td><span><?php echo (!isset($contract['review_final_person_name']) || empty($contract['review_final_person_name'])) ? "---" : $contract['review_final_person_name'] . "(" . $contract['review_final_person_id'] . ")"; ?></span></td>
<td> <td>
<?php if($status == 3): ?><span class="successtext">結案同意</span><?php endif; ?> <?php if ($status == 3) : ?><span class="successtext">結案同意</span><?php endif; ?>
<?php if($status == 2): ?><span class="failtext">結案不同意</span><?php endif; ?> <?php if ($status == 2) : ?><span class="failtext">結案不同意</span><?php endif; ?>
<?php if($status < 2): ?><span>---</span><?php endif; ?> <?php if ($status < 2) : ?><span>---</span><?php endif; ?>
</td> </td>
<td colspan=2><?php echo $contract['review_final_comment'] ?? "---"; ?></td> <td colspan=2><?php echo $contract['review_final_comment'] ?? "---"; ?></td>
<td><?php echo $contract['review_final_date'] ?? "---"; ?></td> <td><?php echo $contract['review_final_date'] ?? "---"; ?></td>
</tr> </tr>
@ -538,7 +539,7 @@ $person = $contract['person'];
<template x-if="false"> <template x-if="false">
<span class="failtext">已退件</span> <span class="failtext">已退件</span>
</template> </template>
<?php if($status == 1): ?> <?php if ($status == 1) : ?>
<span class="readtext">審核中...</span> <span class="readtext">審核中...</span>
<?php endif; ?> <?php endif; ?>
<template x-if="false"> <template x-if="false">
@ -550,155 +551,155 @@ $person = $contract['person'];
</tr> --> </tr> -->
</tbody> </tbody>
</table> </table>
<button @click="window.history.go(-1)" type="button" class="btn btn-primary btn-lg pull-right savebtn" >回前頁</button> <button @click="window.history.go(-1)" type="button" class="btn btn-primary btn-lg pull-right savebtn">回前頁</button>
<?php if(($isFirst == 1 && ($person == $user_id || $user_id == "M0174")) || ($isFirst==0 && $status == 0 && ($person == $user_id || $user_id == "M0174"))): ?> <?php if (($isFirst == 1 && ($person == $user_id || $user_id == "M0174")) || ($isFirst == 0 && $status == 0 && ($person == $user_id || $user_id == "M0174"))) : ?>
<button x-show="true" x-on:click="submit()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> <button x-show="true" x-on:click="submit()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading"> <template x-if="!isLoading">
<span>送審</span> <span>送審</span>
</template> </template>
<template x-if="isLoading"> <template x-if="isLoading">
<div class="loader"></div> <div class="loader"></div>
</template> </template>
</button> </button>
<button x-show="true" x-on:click="storageFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> <button x-show="true" x-on:click="storageFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading"> <template x-if="!isLoading">
<span>暫存</span> <span>暫存</span>
</template> </template>
<template x-if="isLoading"> <template x-if="isLoading">
<div class="loader"></div> <div class="loader"></div>
</template> </template>
</button> </button>
<?php endif; ?> <?php endif; ?>
<?php if($status == 1 && (($user_id == "M0107" && $contract['progress'] <= 1 ) || ($user_id == "M0060" && $contract['progress'] == 2 ) || $user_id == "M0174")): ?> <?php if ($status == 1 && ((($user_id == "M0107" || $user_id == "TEST02") && $contract['progress'] <= 1) || (($user_id == "M0060" || $user_id == "TEST03") && $contract['progress'] == 2) || $user_id == "M0174")) : ?>
<button x-show="true" x-on:click="agree()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> <button x-show="true" x-on:click="agree()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading"> <template x-if="!isLoading">
<span> <span>
<?php <?php
if($user_id === "M0107" && $contract['progress'] <= 1 ){ if (($user_id === "M0107" || $user_id == "TEST02") && $contract['progress'] <= 1) {
echo "同意(上呈)"; echo "同意(上呈)";
}elseif($user_id === "M0060" && $contract['progress'] == 2){ } elseif (($user_id === "M0060" || $user_id == "TEST03") && $contract['progress'] == 2) {
echo "同意(結案)"; echo "同意(結案)";
} }
?> ?>
</span> </span>
</template> </template>
<template x-if="isLoading"> <template x-if="isLoading">
<div class="loader"></div> <div class="loader"></div>
</template> </template>
</button> </button>
<button x-show="true" x-on:click="disagree()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> <button x-show="true" x-on:click="disagree()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading"> <template x-if="!isLoading">
<span>不同意(退回)</span> <span>不同意(退回)</span>
</template> </template>
<template x-if="isLoading"> <template x-if="isLoading">
<div class="loader"></div> <div class="loader"></div>
</template> </template>
</button> </button>
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </div>
</div> </div>
<script src="./js/jquery/jquery-3.1.1.min.js"></script> <script src="./js/jquery/jquery-3.1.1.min.js"></script>
<script src="semantic/dist/semantic.min.js" ></script> <script src="semantic/dist/semantic.min.js"></script>
<script src="./js/alpine.js"></script> <script src="./js/alpine.js"></script>
<script> <script>
window.onload = ()=>{ window.onload = () => {
const lock = document.getElementsByClassName('lock'); const lock = document.getElementsByClassName('lock');
for(let i=0;i<lock.length;i++){ for (let i = 0; i < lock.length; i++) {
lock[i].disabled = true lock[i].disabled = true
} }
} }
</script> </script>
<?php if(empty($contract_new_apply)): ?> <?php if (empty($contract_new_apply)) : ?>
<script> <script>
const contractno = '<?php echo $contract['contractno'] ?? ''; ?>'; const contractno = '<?php echo $contract['contractno'] ?? ''; ?>';
const salesman = '<?php echo $contract['person'] ?? ''; ?>'; const salesman = '<?php echo $contract['person'] ?? ''; ?>';
const salesmanname = '<?php echo $contract['accountname'] ?? ''; ?>'; const salesmanname = '<?php echo $contract['accountname'] ?? ''; ?>';
const apply_date = '<?php echo date('Y-m-d') ?>'; const apply_date = '<?php echo date('Y-m-d') ?>';
const case_name = '<?php echo $contract['case_name'] ?? ''; ?>'; const case_name = '<?php echo $contract['case_name'] ?? ''; ?>';
const company = '<?php echo $contract['company'] ?? ''; ?>'; const company = '<?php echo $contract['company'] ?? ''; ?>';
const manager = '<?php echo $customer['manager'] ?? ''; ?>'; const manager = '<?php echo $customer['manager'] ?? ''; ?>';
const vat = '<?php echo $customer['uscc'] ?? ''; ?>'; const vat = '<?php echo $customer['uscc'] ?? ''; ?>';
const price_total = <?php echo $contract['price_total'] ?? ''; ?>; const price_total = <?php echo $contract['price_total'] ?? ''; ?>;
const address = '<?php echo $contract['address'] ?? ''; ?>'; const address = '<?php echo $contract['address'] ?? ''; ?>';
const price_a = <?php echo $price_a ?? ''; ?>; const price_a = <?php echo $price_a ?? ''; ?>;
const price_b = <?php echo $price_b ?? ''; ?>; const price_b = <?php echo $price_b ?? ''; ?>;
const items = [...<?php echo json_encode($items) ?? [];?>]; const items = [...<?php echo json_encode($items) ?? []; ?>];
const user_id = '<?php echo $user_id ?>'; const user_id = '<?php echo $user_id ?>';
const mid = '<?php echo $_GET['id']; ?>'; const mid = '<?php echo $_GET['id']; ?>';
const pays = [...<?php echo json_encode($pays) ?? []; ?>]; const pays = [...<?php echo json_encode($pays) ?? []; ?>];
const secondPayDeadline = ''; const secondPayDeadline = '';
const tradeaddress = '<?php echo $contract['address'] ?? ''; ?>'; const tradeaddress = '<?php echo $contract['address'] ?? ''; ?>';
const tradedeadline = 180 const tradedeadline = 180
const freedeadline = 18; const freedeadline = 18;
const regulations = 10; const regulations = 10;
const workdeadline_a = 60; const workdeadline_a = 60;
const workdeadline_b = 7; const workdeadline_b = 7;
const workdeadline_note = ''; const workdeadline_note = '';
const total_items = <?php echo $total_items ?? ''; ?>; const total_items = <?php echo $total_items ?? ''; ?>;
const isFirst = <?php echo $isFirst; ?>; const isFirst = <?php echo $isFirst; ?>;
const originfiles = []; const originfiles = [];
const description = ''; const description = '';
const contractstatus = null; const contractstatus = null;
const progress = 0; const progress = 0;
</script> </script>
<?php else: ?> <?php else : ?>
<script> <script>
const contractno = '<?php echo $contract['contractno'] ?? ''; ?>'; const contractno = '<?php echo $contract['contractno'] ?? ''; ?>';
const salesman = '<?php echo $contract['person'] ?? ''; ?>'; const salesman = '<?php echo $contract['person'] ?? ''; ?>';
const salesmanname = '<?php echo $contract['personname'] ?? ''; ?>'; const salesmanname = '<?php echo $contract['personname'] ?? ''; ?>';
const apply_date = '<?php echo date('Y-m-d') ?>'; const apply_date = '<?php echo date('Y-m-d') ?>';
const case_name = '<?php echo $contract['case_name'] ?? ''; ?>'; const case_name = '<?php echo $contract['case_name'] ?? ''; ?>';
const company = '<?php echo $contract['customer'] ?? ''; ?>'; const company = '<?php echo $contract['customer'] ?? ''; ?>';
const manager = '<?php echo $contract['manager'] ?? ''; ?>'; const manager = '<?php echo $contract['manager'] ?? ''; ?>';
const vat = '<?php echo $contract['vat'] ?? ''; ?>'; const vat = '<?php echo $contract['vat'] ?? ''; ?>';
const price_total = <?php echo $contract['total_price'] ?? ''; ?>; const price_total = <?php echo $contract['total_price'] ?? ''; ?>;
const address = '<?php echo $contract['contact_address'] ?? ''; ?>'; const address = '<?php echo $contract['contact_address'] ?? ''; ?>';
const price_a = <?php echo $contract['buy_fee'] ?? ''; ?>; const price_a = <?php echo $contract['buy_fee'] ?? ''; ?>;
const price_b = <?php echo $contract['install_fee'] ?? ''; ?>; const price_b = <?php echo $contract['install_fee'] ?? ''; ?>;
const items = [...<?php echo json_encode($items) ?? []; ?>]; const items = [...<?php echo json_encode($items) ?? []; ?>];
const user_id = '<?php echo $user_id ?? ''; ?>'; const user_id = '<?php echo $user_id ?? ''; ?>';
const mid = '<?php echo $_GET['id']; ?>'; const mid = '<?php echo $_GET['id']; ?>';
const pays = [...<?php echo json_encode($pays) ?? []; ?>]; const pays = [...<?php echo json_encode($pays) ?? []; ?>];
const isFirst = <?php echo $isFirst; ?>; const isFirst = <?php echo $isFirst; ?>;
const tradeaddress = '<?php echo $contract['trade_address'] ?? ''; ?>'; const tradeaddress = '<?php echo $contract['trade_address'] ?? ''; ?>';
const tradedeadline = '<?php echo $contract['tradedeadline'] ?? ''; ?>'; const tradedeadline = '<?php echo $contract['tradedeadline'] ?? ''; ?>';
const freedeadline = '<?php echo $contract['freedeadline'] ?? ''; ?>'; const freedeadline = '<?php echo $contract['freedeadline'] ?? ''; ?>';
const regulations = '<?php echo $contract['test_time'] ?? ''; ?>'; const regulations = '<?php echo $contract['test_time'] ?? ''; ?>';
const workdeadline_a = '<?php echo $contract['workdeadline_a'] ?? ''; ?>'; const workdeadline_a = '<?php echo $contract['workdeadline_a'] ?? ''; ?>';
const workdeadline_b = '<?php echo $contract['workdeadline_b'] ?? ''; ?>'; const workdeadline_b = '<?php echo $contract['workdeadline_b'] ?? ''; ?>';
const workdeadline_note = '<?php echo $contract['workdeadline_note'] ?? ''; ?>'; const workdeadline_note = '<?php echo $contract['workdeadline_note'] ?? ''; ?>';
const secondPayDeadline = <?php echo $secondPayDeadline ?? ''; ?>; const secondPayDeadline = <?php echo $secondPayDeadline ?? ''; ?>;
const total_items = <?php echo $contract['total_items'] ?? ''; ?>; const total_items = <?php echo $contract['total_items'] ?? ''; ?>;
const contract_new_apply_id = <?php echo $contract_new_apply_id; ?>; const contract_new_apply_id = <?php echo $contract_new_apply_id; ?>;
const originfiles = [...<?php echo json_encode($files) ?? []; ?>]; const originfiles = [...<?php echo json_encode($files) ?? []; ?>];
const description = '<?php echo $contract['description']; ?>'; const description = '<?php echo $contract['description']; ?>';
const contractstatus = <?php echo $contract['status']; ?>; const contractstatus = <?php echo $contract['status']; ?>;
const progress = <?php echo $contract['progress']; ?>; const progress = <?php echo $contract['progress']; ?>;
</script> </script>
<?php endif; ?> <?php endif; ?>
<?php if($status > 0 ||( $person != $user_id && $user_id != "M0174")): ?> <?php if ($status > 0 || ($person != $user_id && $user_id != "M0174")) : ?>
<script> <script>
window.onload = ()=>{ window.onload = () => {
const input = document.querySelectorAll('input'); const input = document.querySelectorAll('input');
const alerttext = document.querySelectorAll('p.alerttext'); const alerttext = document.querySelectorAll('p.alerttext');
const select = document.querySelectorAll('select'); const select = document.querySelectorAll('select');
const textarea = document.querySelectorAll('textarea'); const textarea = document.querySelectorAll('textarea');
for(let i=0;i<input.length;i++){ for (let i = 0; i < input.length; i++) {
input[i].disabled = true input[i].disabled = true
} }
for(let i=0;i<select.length;i++){ for (let i = 0; i < select.length; i++) {
select[i].disabled = true select[i].disabled = true
} }
for(let i=0;i<textarea.length;i++){ for (let i = 0; i < textarea.length; i++) {
textarea[i].disabled = true textarea[i].disabled = true
}
for (let i = 0; i < alerttext.length; i++) {
alerttext[i].style.display = "none"
}
} }
for(let i=0;i<alerttext.length;i++){ </script>
alerttext[i].style.display = "none"
}
}
</script>
<?php endif; ?> <?php endif; ?>

37
wms/crm/crmm03-edit.php

@ -18,14 +18,14 @@ $customer_source_opt = DB::result($sql);
$sql = "select code_name value ,content label from code where field_name='elevator_kind'"; $sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql); $elevator_kind_opt = DB::result($sql);
#4.營業員 #4.營業員
$sql = "select employee_no value ,name label from employee where depart_no in ('320','311','312','313','314','511','512','513','514')"; $sql = "select employee_no value ,name label from employee where depart_no in ('320','311','312','313','314','511','512','513','514','322','515')";
$salesman_opt = DB::result($sql); $salesman_opt = DB::result($sql);
#5.有望客戶狀態 #5.有望客戶狀態
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'"; $sql = "select code_name value ,content label from code where field_name='hope_customer_status'";
$hope_customer_status_opt = DB::result($sql); $hope_customer_status_opt = DB::result($sql);
#6.是否汰改 #6.是否汰改
$is_renovation_opt = ["N"=>"新梯(M)", "Y"=>"汰改(T)"]; $is_renovation_opt = ["N" => "新梯(M)", "Y" => "汰改(T)"];
/* /*
['label' => '是', 'value' => 'Y'], ['label' => '是', 'value' => 'Y'],
['label' => '否', 'value' => 'N'], ['label' => '否', 'value' => 'N'],
@ -55,11 +55,11 @@ $hope_elevator_customer_column = [
'manager' => ['label' => "負責人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], 'manager' => ['label' => "負責人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'source' => ['label' => "客戶來源", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $customer_source_opt], 'source' => ['label' => "客戶來源", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $customer_source_opt],
'address' => ['label' => "地址", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], 'address' => ['label' => "地址", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
// 'company' => ['label' => "公司名稱", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], // 'company' => ['label' => "公司名稱", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'case_name' => ['label' => "案件名稱", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], 'case_name' => ['label' => "案件名稱", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
//統編/身份證字號 //統編/身份證字號
'uscc' => ['label' => "統編/身份證", "tag" => 'text', 'attr' => [ 'class' => 'form-control form-control-sm']], 'uscc' => ['label' => "統編/身份證", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'linkman' => ['label' => "業主方聯係人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], 'linkman' => ['label' => "業主方聯係人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'lm_tel' => ['label' => "市話/手機", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], 'lm_tel' => ['label' => "市話/手機", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
@ -82,11 +82,11 @@ $data = [
$table_hope_project_elevator_spec = 'hope_project_elevator_spec'; $table_hope_project_elevator_spec = 'hope_project_elevator_spec';
$hope_project_elevator_spec_columm = [ $hope_project_elevator_spec_columm = [
'specifications' => ['label' => "規格", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'specifications[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], 'specifications' => ['label' => "規格", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'specifications[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt],
'person' => ['label' => "人乘/載重", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'person[]', 'class' => 'form-control form-control-sm'],'options' => $person_opt], 'person' => ['label' => "人乘/載重", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'person[]', 'class' => 'form-control form-control-sm'], 'options' => $person_opt],
//'weight' => ['label' => "載重(KG)", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'gt=0', 'min=0', 'class' => 'form-control form-control-sm']], //'weight' => ['label' => "載重(KG)", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'gt=0', 'min=0', 'class' => 'form-control form-control-sm']],
'stop' => ['label' => "停數", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'min=1', 'class' => 'form-control form-control-sm']], 'stop' => ['label' => "停數", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'min=1', 'class' => 'form-control form-control-sm']],
'open' => ['label' => "開門方式", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'open[]', 'class' => 'form-control form-control-sm'], 'options' => $open_kind_opt], 'open' => ['label' => "開門方式", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'open[]', 'class' => 'form-control form-control-sm'], 'options' => $open_kind_opt],
'speed' => ['label' => "速度(m/min)", "tag" => 'select', 'attr' => ['name' => 'speed[]', 'class' => 'form-control form-control-sm'],'options' => $speed_opt], 'speed' => ['label' => "速度(m/min)", "tag" => 'select', 'attr' => ['name' => 'speed[]', 'class' => 'form-control form-control-sm'], 'options' => $speed_opt],
'spec_num' => ['label' => "數量", "tag" => 'digits', 'attr' => ['name' => 'spec_num[]', 'min=1', 'class' => 'form-control form-control-sm']], 'spec_num' => ['label' => "數量", "tag" => 'digits', 'attr' => ['name' => 'spec_num[]', 'min=1', 'class' => 'form-control form-control-sm']],
'spec_price' => ['label' => "單價", "tag" => 'number', 'attr' => ['name' => 'spec_price[]', 'min=0', 'class' => 'form-control form-control-sm']], 'spec_price' => ['label' => "單價", "tag" => 'number', 'attr' => ['name' => 'spec_price[]', 'min=0', 'class' => 'form-control form-control-sm']],
@ -184,13 +184,13 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>"></script> <script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" />
<style> <style>
label { label {
margin-right:10px; margin-right: 10px;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("input[name=is_renovation]").click(function(){ $("input[name=is_renovation]").click(function() {
if ($(this).val() == "Y") { if ($(this).val() == "Y") {
var volNo = "<?php echo get_sequnece_no('rt_vol_no', date('ym')); ?>"; var volNo = "<?php echo get_sequnece_no('rt_vol_no', date('ym')); ?>";
} else if ($(this).val() == "N") { } else if ($(this).val() == "N") {
@ -215,8 +215,8 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
return value > param; return value > param;
}, $.validator.format("輸入值必須大於0")); }, $.validator.format("輸入值必須大於0"));
$('#cmecTbody').on('click', 'input[name^=spec_num]', function(){ $('#cmecTbody').on('click', 'input[name^=spec_num]', function() {
$(this).unbind().keyup(function(){ $(this).unbind().keyup(function() {
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
sumNum(); sumNum();
}); });
@ -226,8 +226,8 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
}); });
sumNum = function() { sumNum = function() {
var numAll = 0; var numAll = 0;
$("input[name^=spec_num]").each(function(){ $("input[name^=spec_num]").each(function() {
numAll += Number($(this).val().replace(/[,]+/g,"")); numAll += Number($(this).val().replace(/[,]+/g, ""));
}); });
$('#num').val(numAll); $('#num').val(numAll);
} }
@ -249,7 +249,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
} }
selectHpeoRow = function(obj) { selectHpeoRow = function(obj) {
var id = $(obj).parent().parent().find('td:nth-child(1)>div').text(); var id = $(obj).parent().parent().find('td:nth-child(1)>div').text();
var spec = $(obj).parent().parent().find('td:nth-child(2)>div').text(); var spec = $(obj).parent().parent().find('td:nth-child(2)>div').text();
var memo = $(obj).parent().parent().find('td:nth-child(3)>div').text(); var memo = $(obj).parent().parent().find('td:nth-child(3)>div').text();
var optional = $(obj).parent().parent().find('td:nth-child(4)>div').text(); var optional = $(obj).parent().parent().find('td:nth-child(4)>div').text();
@ -261,7 +261,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
//').last() //').last()
var tr = $('#hpeoTbody tr').last(); var tr = $('#hpeoTbody tr').last();
$(tr).children('td').each(function(i) { $(tr).children('td').each(function(i) {
$(this).find("input[name^='id']").val(id.trim()); $(this).find("input[name^='id']").val(id.trim());
$(this).find("input[name^='spec']").val(spec.trim()); $(this).find("input[name^='spec']").val(spec.trim());
$(this).find("input[name^='memo']").val(memo.trim()); $(this).find("input[name^='memo']").val(memo.trim());
$(this).find("input[name^='optional']").val(optional.trim()); $(this).find("input[name^='optional']").val(optional.trim());
@ -312,7 +312,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
if ($val['tag'] == 'select') { if ($val['tag'] == 'select') {
$_input = FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']); $_input = FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']);
} elseif ($val['tag'] == 'radio') { } elseif ($val['tag'] == 'radio') {
$_input = FormHelper::collectionRadios("$key", $val['options'],""); $_input = FormHelper::collectionRadios("$key", $val['options'], "");
} else { } else {
$_input = FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); $_input = FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
} }
@ -345,8 +345,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
</div> </div>
<div class="col-12 " style="padding:0"> <div class="col-12 " style="padding:0">
<textarea class='form-control textarea' id="progress_status" name="progress_status" <textarea class='form-control textarea' id="progress_status" name="progress_status" value='' rows='6'></textarea>
value='' rows='6'></textarea>
</div> </div>
</div> </div>
<div id="elevator_list_area" class="row "> <div id="elevator_list_area" class="row ">

2
wms/crm/crmm06-edit.php

@ -19,7 +19,7 @@ $customer_source_opt = DB::result($sql);
$sql = "select code_name value ,content label from code where field_name='elevator_kind'"; $sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql); $elevator_kind_opt = DB::result($sql);
#4.營業員 #4.營業員
$sql = "select employee_no value ,name label from employee where depart_no in ('511','512','513','514')"; $sql = "select employee_no value ,name label from employee where depart_no in ('511','512','513','514','515')";
$salesman_opt = DB::result($sql); $salesman_opt = DB::result($sql);
#5.有望客戶狀態 #5.有望客戶狀態
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'"; $sql = "select code_name value ,content label from code where field_name='hope_customer_status'";

6
wms/fun_global.php

@ -97,6 +97,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee)
$ret[3] = "test03,,"; $ret[3] = "test03,,";
$ret[4] = "test05,,"; $ret[4] = "test05,,";
return $ret; return $ret;
exit;
} else { } else {
if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") { if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") {
$ret[1] = $row["manager"] . ",,"; $ret[1] = $row["manager"] . ",,";
@ -130,12 +131,13 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) { if ($row = mysqli_fetch_assoc($res)) {
if ($row["manager"] == "M0001") return; // 董事長略過 if ($row["manager"] == "M0001") return; // 董事長略過
if ($row["manager"] == "TEST04" || $user_id = 'TEST01') { if ($row["manager"] == "TEST04" || $user_id == 'TEST01') {
$ret[1] = "test04,,"; $ret[1] = "test04,,";
$ret[2] = "test02,,"; $ret[2] = "test02,,";
$ret[3] = "test03,,"; $ret[3] = "test03,,";
$ret[4] = "test05,,"; $ret[4] = "test05,,";
return $ret; return $ret;
exit();
} else { } else {
if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") { if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") {
$ret[1] = $row["manager"]; $ret[1] = $row["manager"];
@ -144,7 +146,7 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
} }
} }
} }
$ret[1] = "M0029"; // $ret[1] = "M0029";
mysqli_free_result($res); mysqli_free_result($res);
$ret[2] = 'M0012'; $ret[2] = 'M0012';
if ($renovate_flag == "REN") { if ($renovate_flag == "REN") {

4
wms/mkt/pricereview-index.php

@ -550,14 +550,14 @@ if ($data) :
<?php endif; ?> <?php endif; ?>
<?php if ($data['status'] == 'YY' && (($user_id == "M0060" && $data['applyprogress'] == 2) || (($user_id == "M0107" || $user_id == "M0175") && $data['applyprogress'] <= 1) || $user_id == "M0174" || $user_id == 'M0225') && $data['applystatus'] == 1) : ?> <?php if ($data['status'] == 'YY' && ((($user_id == "M0060" || $user_id === "TEST03") && $data['applyprogress'] == 2) || (($user_id == "M0107" || $user_id == "M0175" || $user_id == "TEST02") && $data['applyprogress'] <= 1) || $user_id == "M0174" || $user_id == 'M0225') && $data['applystatus'] == 1) : ?>
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">待簽核</a><br> <a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">待簽核</a><br>
<?php endif; ?> <?php endif; ?>
<?php if ($data['status'] != 'YY') : ?> <?php if ($data['status'] != 'YY') : ?>
<span style="font-size:13px;font-weight:600">--</span> <span style="font-size:13px;font-weight:600">--</span>
<?php endif; ?> <?php endif; ?>
<!-- 工號M0107、M0174有所有權限 --> <!-- 工號M0107、M0174有所有權限 -->
<?php if (($data['status'] === 'YY' && $data['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0175")) || $user_id == "M0174" || $user_id == 'M0225') : ?> <?php if (($data['status'] === 'YY' && $data['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0175" || $user_id === "TEST02")) || $user_id == "M0174" || $user_id == 'M0225') : ?>
<a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載</a> <a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載</a>
<?php endif; ?> <?php endif; ?>
</td> </td>

Loading…
Cancel
Save