Browse Source

合併衝突

main
Cheng 1 year ago
parent
commit
7275655cac
  1. 27
      wms/account-receivable-excel.php
  2. 368
      wms/account-receivable-index-ing.php
  3. 367
      wms/account-receivable-index.php
  4. 22906
      wms/account_receivable_sql_file.sql
  5. BIN
      wms/assemble_warehouse.xlsx
  6. 370
      wms/cont/sign_list.php
  7. 25
      wms/contract/api/T8salIncomeApply.php
  8. 912
      wms/contract/api/postContractData.php
  9. 173
      wms/contract/api/test.json
  10. 133
      wms/contract/api/testT8API.php
  11. 1
      wms/frame/api_getdata.php
  12. 196
      wms/frame/pending.php
  13. 4
      wms/fun_global.php
  14. 3
      wms/mkt/pricereview-check.php
  15. 64
      wms/mkt/pricereview-index.php
  16. 111
      wms/mkt/pricereview_mi-api.php
  17. 58
      wms/mkt/pricereview_renovate-index.php
  18. 1
      wms/schedule-index.php
  19. 61
      wms/sign/list.php

27
wms/account-receivable-excel.php

@ -13,6 +13,7 @@ $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 = [
'作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', '作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
@ -24,7 +25,7 @@ if ($type == 'facility') {
'官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數', '官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數',
'交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已收金額', '交車款催收金額', '交車款催收次數', '交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已收金額', '交車款催收金額', '交車款催收次數',
'尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已收金額', '尾款催收金額', '尾款催收次數', '尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已收金額', '尾款催收金額', '尾款催收次數',
'作番狀態', '合約-設備金額','合約-安裝金額','作番合約總金額', '作番總應收金額' '作番狀態', '合約-設備金額', '合約-安裝金額', '作番合約總金額', '作番總應收金額'
]; ];
$sheet->fromArray($colomnHeader, NULL, 'A1'); $sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2; $rowIndex = 2;
@ -34,7 +35,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'
]; ];
foreach ($column as $col) { foreach ($column as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true); $sheet->getColumnDimension($col)->setAutoSize(true);
@ -48,26 +49,26 @@ if ($type == 'facility') {
} else { } else {
$colomnHeader = [ $colomnHeader = [
'合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金', '訂金目前應收', '訂金已開票金額','訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數', '訂金', '訂金目前應收', '訂金已開票金額', '訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數',
'二次款', '二次款目前應收', '二次款已開票金額','二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數', '二次款', '二次款目前應收', '二次款已開票金額', '二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數',
'貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額','貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數', '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額', '貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數',
'安裝款', '安裝款目前應收', '安裝款已開票金額','安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數', '安裝款', '安裝款目前應收', '安裝款已開票金額', '安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數',
'試車款', '試車款目前應收', '試車款已開票金額','試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數', '試車款', '試車款目前應收', '試車款已開票金額', '試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數',
'官檢款', '官檢款目前應收', '官檢款已開票金額','官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數', '官檢款', '官檢款目前應收', '官檢款已開票金額', '官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數',
'交車款', '交車款目前應收', '交車款已開票金額','交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數', '交車款', '交車款目前應收', '交車款已開票金額', '交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數',
'尾款', '尾款目前應收', '尾款已開票金額','尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數', '尾款', '尾款目前應收', '尾款已開票金額', '尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數',
'合約設備金額','合約安裝金額','合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態' '合約設備金額', '合約安裝金額', '合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態'
]; ];
$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); $sheet->fromArray($value, NULL, 'A' . $rowIndex, true);
$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'
]; ];
foreach ($column as $col) { foreach ($column as $col) {
if ($col == 'CB') { if ($col == 'CB') {

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

@ -103,6 +103,7 @@ 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);
@ -112,16 +113,19 @@ 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);
@ -211,6 +215,7 @@ 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;
@ -401,6 +406,7 @@ 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);
@ -409,6 +415,7 @@ 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;
//二次款 //二次款
@ -419,6 +426,7 @@ 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;
//貨抵工地款 //貨抵工地款
@ -431,6 +439,7 @@ 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;
@ -444,6 +453,7 @@ 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;
@ -458,6 +468,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']]['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;
@ -476,6 +488,7 @@ 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));
@ -490,14 +503,19 @@ 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']);
@ -507,6 +525,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']]['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));
@ -518,8 +538,11 @@ 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);
@ -591,16 +614,22 @@ 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'])));
@ -678,14 +707,19 @@ 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'])));
@ -741,12 +775,16 @@ 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);
@ -794,10 +832,13 @@ 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']);
@ -827,11 +868,14 @@ 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>";
@ -870,6 +914,30 @@ 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')))));
@ -894,6 +962,25 @@ 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) {
@ -1262,6 +1349,284 @@ 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();
@ -1289,6 +1654,8 @@ 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天") {
@ -1332,6 +1699,7 @@ foreach ($arrayData as $key => $value) {
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']) 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'])
]; ];
//['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 催收次數
foreach ($value['facility'] as $valkey => $val) { foreach ($value['facility'] as $valkey => $val) {

367
wms/account-receivable-index.php

@ -103,6 +103,7 @@ 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);
@ -118,10 +119,13 @@ if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql_opening .= ")"; $sql_opening .= ")";
$sql .= " ORDER BY contractno"; $sql .= " ORDER BY contractno";
$sql_contract_budget .= ")"; $sql_contract_budget .= ")";
$sql_contract_budget .= ")";
}; };
} else {
} 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);
@ -211,6 +215,7 @@ 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;
@ -401,6 +406,7 @@ 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);
@ -409,6 +415,7 @@ 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;
//二次款 //二次款
@ -419,6 +426,7 @@ 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;
//貨抵工地款 //貨抵工地款
@ -431,6 +439,7 @@ 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;
@ -444,6 +453,7 @@ 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;
@ -458,6 +468,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']]['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;
@ -476,6 +488,7 @@ 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));
@ -490,14 +503,19 @@ 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']);
@ -507,6 +525,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']]['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));
@ -518,8 +538,11 @@ 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);
@ -591,16 +614,22 @@ 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'])));
@ -741,12 +770,16 @@ 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);
@ -794,10 +827,13 @@ 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']);
@ -827,11 +863,14 @@ 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>";
@ -870,6 +909,30 @@ 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')))));
@ -894,6 +957,25 @@ 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) {
@ -1262,6 +1344,284 @@ 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();
@ -1332,6 +1692,7 @@ foreach ($arrayData as $key => $value) {
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']) 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'])
]; ];
//['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 催收次數
foreach ($value['facility'] as $valkey => $val) { foreach ($value['facility'] as $valkey => $val) {
@ -1389,6 +1750,7 @@ $average_A40001 = round($sum_A40001 / $sum_facility, 2);
$average_A40008 = round($sum_A40008 / $sum_facility, 2); $average_A40008 = round($sum_A40008 / $sum_facility, 2);
$average_budget = round($sum_total_budget / $sum_facility, 2); $average_budget = round($sum_total_budget / $sum_facility, 2);
$total_data = json_encode($excel_aray);
$total_data = json_encode($excel_aray); $total_data = json_encode($excel_aray);
$boga_data = json_encode($boga_array); $boga_data = json_encode($boga_array);
$exclude_boga_data = json_encode($exclude_boga_array); $exclude_boga_data = json_encode($exclude_boga_array);
@ -1448,6 +1810,7 @@ $facility_exclude_boga_data = json_encode($facility_exclude_boga_array);
<button type="button" style="width: 12%;" onclick="downloadFacilityData('ExcludeData')" class="btn btn-info btn-md">不含寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button> <button type="button" style="width: 12%;" onclick="downloadFacilityData('ExcludeData')" class="btn btn-info btn-md">不含寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" style="width: 12%;" onclick="downloadFacilityData('BogaData')" class="btn btn-warning btn-md">寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button> <button type="button" style="width: 12%;" onclick="downloadFacilityData('BogaData')" class="btn btn-warning btn-md">寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button>
</div> </div>
</div> </div>
@ -1642,11 +2005,13 @@ include "./footer.php";
} }
xhr.send(JSON.stringify({ xhr.send(JSON.stringify({
Bill: <?= $total_data ?> Bill: <?= $total_data ?>
Bill: <?= $total_data ?>
})); }));
} }
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);
@ -1675,9 +2040,11 @@ include "./footer.php";
if (content == 'AllData') { if (content == 'AllData') {
var BillData = <?= $facility_data ?>; var BillData = <?= $facility_data ?>;
var filename = "作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; var filename = "作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
} else if (content == 'ExcludeData') {
} else if (content == 'ExcludeData') { } else if (content == 'ExcludeData') {
var BillData = <?= $facility_exclude_boga_data ?>; var BillData = <?= $facility_exclude_boga_data ?>;
var filename = "不含寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; var filename = "不含寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
} else if (content == 'BogaData') {
} else if (content == 'BogaData') { } else if (content == 'BogaData') {
var BillData = <?= $facility_boga_data ?>; var BillData = <?= $facility_boga_data ?>;
var filename = "寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; var filename = "寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";

22906
wms/account_receivable_sql_file.sql

File diff suppressed because it is too large

BIN
wms/assemble_warehouse.xlsx

Binary file not shown.

370
wms/cont/sign_list.php

@ -3,34 +3,77 @@ require_once "../header.php";
// 載入db.php來連結資料庫 // 載入db.php來連結資料庫
$table = 'con_maintance_examine_apply'; $table = 'con_maintance_examine_apply';
$para = "function_name=pricereview&" . $token_link; // 待我簽核進入
if (!empty($_GET['system_id']) && !empty($_GET['flow_id'])) {
$system_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['system_id'] : @$_POST['system_id'];
$where_system_id = " and a.system_id like '" . $system_id . "%'";
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id'];
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'";
$sql_get = "SELECT d.form_id,c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner,
concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name ,
flow_name,c.update_date ,c.create_date,b.path,d.flow_code FROM system_main a,flow_main b ,subflow
c,flow d
WHERE a.system_id=b.system_id
AND b.flow_id=d.flow_id
AND c.current_assigner='$user_id'
AND d.flow_id=b.flow_id
AND c.form_key=d.form_key
$where_system_id
$where_flow_id
";
// echo '<pre>';
// print_r($sql_get);
// echo '</pre>';
$result = mysqli_query($link, $sql_get);
if ($result == false) {
die(mysqli_error($link));
}
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC);
$status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"];
#可編輯的列 foreach ($res_get as $key => $data) {
// $editableColumn = [ // 結案隱藏
// 'apply_key' => [ if ($data['flow_code'] !== 'Z') {
// 'label' => "評審單號", "value" => "", "tag" => 'text', $test = $data['form_key'];
// 'attr' => [ // $sql = "SELECT mid FROM pricereview_sign WHERE id = $test";
// 'readonly=true ', // $result = mysqli_fetch_all(mysqli_query($link, $sql), MYSQLI_ASSOC);
// 'class' => 'form-control form-control-sm' // echo '<pre>';
// ] // print_r($result);
// ], // echo '</pre>';
// 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], $id[] = $test;
// 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], }
// 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], }
// 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']], $inClause = implode(',', $id);
// 'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], }
// 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
// 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']],
// 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
// 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
// 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']],
// 'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
// 'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
// //'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt],
// ]; #可編輯的列
$editableColumn = [
'apply_key' => [
'label' => "評審單號", "value" => "", "tag" => 'text',
'attr' => [
'readonly=true ',
'class' => 'form-control form-control-sm'
]
],
'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']],
'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']],
'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']],
'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
//'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt],
];
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
@ -45,7 +88,7 @@ $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$user_department_id = $row[0]; $user_department_id = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "M0225") $where = ""; if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") $where = "";
// 電梯廠牌 // 電梯廠牌
$elevator_brand_arr = []; $elevator_brand_arr = [];
@ -55,32 +98,49 @@ while ($row = mysqli_fetch_row($res)) {
$elevator_brand_arr[$row[0]] = $row[1]; $elevator_brand_arr[$row[0]] = $row[1];
} }
mysqli_free_result($res); mysqli_free_result($res);
if (!empty($res_get)) {
$sql = "SELECT $sql = "SELECT
apply_key, apply_key,
vol_no, vol_no,
address, address,
case_name, case_name,
brand , brand ,
num , num ,
salesman as salesman_id, f_return_name(salesman) salesman,
f_return_name(salesman) salesman, f_return_content('maintain_kind',maintain_kind ) maintain_kind,
f_return_content('maintain_kind',maintain_kind ) maintain_kind, date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date,
date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, date_format(contract_end_date,'%Y/%m/%d') contract_end_date ,
date_format(contract_end_date,'%Y/%m/%d') contract_end_date , f_return_content('contract_kind',contract_kind ) contract_kind,
f_return_content('contract_kind',contract_kind ) contract_kind, platform_company,
platform_company, platforom_company_tel,
platforom_company_tel, form_key,
form_key,
status, f_return_content('payment_kind',payment_kind ) payment_kind FROM $table WHERE form_key IN ($inClause) ";
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table } else {
where 1=1 $where ORDER BY vol_no"; $sql = "SELECT
apply_key,
vol_no,
address,
case_name,
brand ,
num ,
f_return_name(salesman) salesman,
f_return_content('maintain_kind',maintain_kind ) maintain_kind,
date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date,
date_format(contract_end_date,'%Y/%m/%d') contract_end_date ,
f_return_content('contract_kind',contract_kind ) contract_kind,
platform_company,
platforom_company_tel,
form_key,
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table
where 1=1 $where ORDER BY vol_no";
}
// echo $sql;
$data = mysqli_query($link, $sql); $data = mysqli_query($link, $sql);
// echo '<pre>'; // echo '<pre>';
// print_r($sql); // print_r($data);
// echo '</pre>'; // echo '</pre>';
?> ?>
<?php <?php
@ -96,175 +156,59 @@ if ($data) :
} }
?> ?>
<!-- <link rel="stylesheet" href="common.css"> --> <link rel="stylesheet" href="common.css">
<style>
#table_index2 {
table-layout: fixed;
width: 100%;
}
#table_index2_filter {
float: right;
}
#table_index2_paginate {
float: right;
}
div.dataTables_scrollHead table.dataTable {
margin-bottom: 0 !important;
border-bottom-width: 0;
}
div.dataTables_scrollBody table.dataTable {
border-top-width: 0;
}
/*
.col-sm-12 {
width: auto;
}
*/
img {
width: 125px;
}
.width_style_1 {
width: 125px;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
div a:hover {
text-decoration: none;
}
.btn-sm {
font-size: 14px;
margin: 2px 0;
line-height: 90%;
}
.glyphicon-ok,
.glyphicon-ban-circle {
font-size: 130%;
}
.btn-secondary {
color: #fff;
background-color: #6c757d;
border-color: #6c757d;
}
.btn-secondary:hover { <div style="overflow-x:auto;">
color: #fff; <form method='get' action='#'>
background-color: #5a6268; <table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'>
border-color: #545b62; <thead>
} <tr>
<td colspan="8">
.applybtn { <h3 style='text-align:center'>(契約)價審單查詢</h3>
color: #fff; </td>
background-color: #1484c4; </tr>
display: block;
border-radius: 4px;
padding: 4px 2px;
font-size: 13px;
} </thead>
</table>
<table id="table_index" class="table table-striped table-bordered" style="width:98%">
<thead>
<?php
echo "<tr>";
foreach ($editableColumn as $key => $val) {
echo "<th>" . $val['label'] . "</th>";
}
echo "<th>是否結案</th>";
// echo "<th>刪除</th>";
echo "</tr>";
?>
</thead>
<tbody>
<?php foreach ($data as $row) : ?>
<tr>
<?php
foreach ($editableColumn as $key => $val) {
if ($key == 'apply_key') {
echo "<td> <a href='query_form.php?apply_key=$row[$key]&token=" . $_GET['token'] . "'>" . $row[$key] . "</td>";
} elseif ($key == 'brand') {
echo "<td>" . (!empty($row[$key]) ? $elevator_brand_arr[$row[$key]] : "") . "</td>";
} else {
echo "<td>" . $row[$key] . "</td>";
}
}
//list($signer)=DB::fields(");
//echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ."
list($signer) = mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='" . $row['form_key'] . "'"));
.applybtn:hover { echo "<td>" . (empty($signer) ? "結案" : "N") . "</td>";
background-color: #1494f9;
color: #fff;
}
</style>
<script>
$(function() {
$('#table_index2').DataTable({
"scrollX": true,
"pageLength": 50
});
/*
var api = $('#table_index').dataTable().api();
//var order = api.order();
//console.log(order);
api
.order([0, "desc"])
.draw();
*/
});
</script>
<link rel="stylesheet" href="../crm/common.css">
<div style="overflow-x:auto; white-space:nowrap;"> ?>
<table id="table_index2" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>評審單號</th>
<th>卷號</th>
<th>現場地址</th>
<th>現場名稱</th>
<th>電梯品牌</th>
<th>電梯台數</th>
<th>營業員</th>
<th>保養方式</th>
<th>契約期限開始</th>
<th>契約期限結束</th>
<th>契約性質</th>
<th>加盟公司名稱</th>
<th>加盟公司電話</th>
<!-- <th>加盟公司電話</th> -->
<th>是否結案</th>
<th>合約下載</th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $row) :
$oneself = ($row['salesman'] == $user_id) ? 1 : 0;
?>
<tr>
<td><a href="query_form.php?apply_key=<?= $row['apply_key'] ?>&token=<?= $_GET['token'] ?>"><?= $row['apply_key'] ?></a></td>
<td><?php echo $row['vol_no'] ?></td>
<td><?php echo $row['address'] ?></td>
<td><?php echo $row['case_name'] ?></td>
<td><?php echo $row['brand'] ?></td>
<td><?php echo $row['num'] ?></td>
<td><?php echo $row['salesman'] ?></td>
<td><?php echo $row['maintain_kindd'] ?></td>
<td><?php echo $row['contract_begin_date'] ?></td>
<td><?php echo $row['contract_end_date'] ?></td>
<td><?php echo $row['contract_kind'] ?></td>
<td><?php echo $row['platform_company'] ?></td>
<td><?php echo $row['platforom_company_tel'] ?></td>
<?php list($signer) = mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='" . $row['form_key'] . "'")); ?> </tr>
<td><?php echo empty($signer) ? '結案' : 'N' ?></td> <?php endforeach; ?>
<td> </tbody>
<a class="applybtn" href="../contract-repair/contract_maintance.php?apply_key=<?php echo $row['apply_key'] . '&' . $para; ?>"> </table>
<?php if (($row['status'] == 'YY' && $oneself)) {
echo '申請';
} else {
echo '檢視';
} ?>
</a>
<?php if ($row['status'] == 'YY' && ($user_id == "M0060" || $user_id == "M0107" || $user_id == "M0174" || $user_id == 'M0225') && $row['applystatus'] == 1) : ?>
<a class="applybtn" href="../contract-repaire/contract_maintance.php?id=<?php echo $row['id'] . '&' . $para; ?>">待簽核</a><br>
<?php endif; ?>
<?php if ($row['status'] != 'Y1') : ?>
<span style="font-size:13px;font-weight:600">--</span>
<?php endif; ?>
<?php if (($row['status'] === 'YY' && $row['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060")) || $user_id == "M0174" || $user_id == 'M0225') : ?>
<a class="applybtn" href="../contract-repair/contract-download.php?apply_key=<?php echo $row['apply_key'] . '&' . $para ?>">下載</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div> </div>
<?php <?php

25
wms/contract/api/T8salIncomeApply.php

@ -3,9 +3,9 @@ require_once("../../T8_Authorization_from_bpm.php");
function T8API($data) function T8API($data)
{ {
echo '<pre>'; // echo '<pre>';
print_r(json_encode($data)); // print_r(json_encode($data));
echo '</pre>'; // echo '</pre>';
$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
$validation = get_Auth(); $validation = get_Auth();
@ -16,19 +16,24 @@ function T8API($data)
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch); $response = curl_exec($ch);
if ($response === false) { if ($response === false) {
echo 'Curl error: ' . curl_error($ch); echo 'Curl error: ' . curl_error($ch);
} else { } else {
$result = json_decode($response, true); $result = json_decode($response, true);
// $validation = $result['Data']['CHI_Authorization']; // 若 API 傳入失敗。
echo '<pre>'; if ($result['Status'] == 'Erroe') {
print_r($result); echo 'API傳入失敗,' . $result['ErrorMsg'];
echo '</pre>'; return $result;
return $result; } else {
// echo '<pre>';
// print_r($result);
// echo '</pre>';
return $result;
}
} }
curl_close($ch); curl_close($ch);

912
wms/contract/api/postContractData.php

@ -8,343 +8,345 @@ include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei'); ini_set('date.timezone', 'Asia/Taipei');
//保養簽回 //保養簽回
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') {
// try { try {
$created_at = date('Y-m-d H:i:s'); $created_at = date('Y-m-d H:i:s');
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; $total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null;
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null; $vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null; $mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null;
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null; $opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null;
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null; $phone = !empty($_POST['phone']) ? $_POST['phone'] : null;
$email = !empty($_POST['email']) ? $_POST['email'] : null; $email = !empty($_POST['email']) ? $_POST['email'] : null;
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null; $mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null;
$mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null; $mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null;
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null; $salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null; $contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null;
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null; $contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null;
$address = !empty($_POST['address']) ? $_POST['address'] : null; $address = !empty($_POST['address']) ? $_POST['address'] : null;
$area = !empty($_POST['area']) ? $_POST['area'] : null; $area = !empty($_POST['area']) ? $_POST['area'] : null;
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null; $customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null; $partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null;
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null; $partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null;
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null; $partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null;
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null; $partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null; $user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null;
$num = !empty($_POST['num']) ? $_POST['num'] : null; $num = !empty($_POST['num']) ? $_POST['num'] : null;
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; $files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$payType = !empty($_POST['payType']) ? $_POST['payType'] : null; $payType = !empty($_POST['payType']) ? $_POST['payType'] : null;
// validate // validate
$fail_arr = []; $fail_arr = [];
if ($contractno === '') return $fail_arr[] = '合約號為必填'; if ($contractno === '') return $fail_arr[] = '合約號為必填';
if ($total_price == '') $fail_arr[] = '合約總價為必填'; if ($total_price == '') $fail_arr[] = '合約總價為必填';
if ($vat == '') $fail_arr[] = '統一編號為必填'; if ($vat == '') $fail_arr[] = '統一編號為必填';
if ($mtype == '') $fail_arr[] = '維修型態為必填'; if ($mtype == '') $fail_arr[] = '維修型態為必填';
if ($phone == '') $fail_arr[] = '客戶電話為必填'; if ($phone == '') $fail_arr[] = '客戶電話為必填';
if ($email == '') $fail_arr[] = 'Email為必填'; if ($email == '') $fail_arr[] = 'Email為必填';
if ($mworker == '') $fail_arr[] = '保養員為必填'; if ($mworker == '') $fail_arr[] = '保養員為必填';
if ($mcycle == '') $fail_arr[] = '保養頻率為必填'; if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
if ($salesman == '') $fail_arr[] = '營業員為必填'; if ($salesman == '') $fail_arr[] = '營業員為必填';
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填'; if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填';
if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填'; if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填';
if ($address == '') $fail_arr[] = '地址為必填'; if ($address == '') $fail_arr[] = '地址為必填';
if ($area == '') $fail_arr[] = '區域為必填'; if ($area == '') $fail_arr[] = '區域為必填';
if ($customer == '') $fail_arr[] = '客戶為必填'; if ($customer == '') $fail_arr[] = '客戶為必填';
if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
if ($num == '') $fail_arr[] = '電梯數量為必填'; if ($num == '') $fail_arr[] = '電梯數量為必填';
if ($payType == '') $fail_arr[] = '付款方式為必填'; if ($payType == '') $fail_arr[] = '付款方式為必填';
if (count($fail_arr) > 0) { if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity"); header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr); echo json_encode($fail_arr);
exit(); exit();
} }
//create account table //create account table
$accounttype = "A"; $accounttype = "A";
$accountid = $vat; $accountid = $vat;
$pwd = "123"; $pwd = "123";
$name = $partyA; $name = $partyA;
$tel = $phone ?? ''; $tel = $phone ?? '';
$repairerid = $mworker; $repairerid = $mworker;
$creater = $user_id; $creater = $user_id;
$create_at = date('Y-m-d H:i:s'); $create_at = date('Y-m-d H:i:s');
// $conn->beginTransaction(); $conn->beginTransaction();
// $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
// $stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':accounttype', $accounttype); $stmt->bindParam(':accounttype', $accounttype);
// $stmt->bindParam(':accountid', $accountid); $stmt->bindParam(':accountid', $accountid);
// $stmt->bindParam(':pwd', $pwd); $stmt->bindParam(':pwd', $pwd);
// $stmt->bindParam(':name', $name); $stmt->bindParam(':name', $name);
// $stmt->bindParam(':tel', $tel); $stmt->bindParam(':tel', $tel);
// $stmt->bindParam(':address', $address); $stmt->bindParam(':address', $address);
// $stmt->bindParam(':email', $email); $stmt->bindParam(':email', $email);
// $stmt->bindParam(':repairerid', $repairerid); $stmt->bindParam(':repairerid', $repairerid);
// $stmt->bindParam(':creater', $creater); $stmt->bindParam(':creater', $creater);
// $stmt->bindParam(':create_at', $create_at); $stmt->bindParam(':create_at', $create_at);
// $stmt->execute(); $stmt->execute();
//create contract table //create contract table
$contracttype = $mtype; $contracttype = $mtype;
$company = $partyA; $company = $partyA;
$taxid = $vat; $taxid = $vat;
$tel = $phone; $tel = $phone;
$promiser = $partyA; $promiser = $partyA;
$contractperson = $partyA; $contractperson = $partyA;
$contractaddress = $address; $contractaddress = $address;
$contracttel = $phone; $contracttel = $phone;
$contractemail = $email; $contractemail = $email;
$contract_employee = $salesman; $contract_employee = $salesman;
$start_date = $contract_begin_date; $start_date = $contract_begin_date;
$end_date = $contract_end_date; $end_date = $contract_end_date;
// $sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; $sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)";
// $stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':contracttype', $contracttype); $stmt->bindParam(':contracttype', $contracttype);
// $stmt->bindParam(':contractno', $contractno); $stmt->bindParam(':contractno', $contractno);
// $stmt->bindParam(':company', $company); $stmt->bindParam(':company', $company);
// $stmt->bindParam(':taxid', $taxid); $stmt->bindParam(':taxid', $taxid);
// $stmt->bindParam(':address', $address); $stmt->bindParam(':address', $address);
// $stmt->bindParam(':tel', $tel); $stmt->bindParam(':tel', $tel);
// $stmt->bindParam(':promiser', $promiser); $stmt->bindParam(':promiser', $promiser);
// $stmt->bindParam(':contractperson', $contractperson); $stmt->bindParam(':contractperson', $contractperson);
// $stmt->bindParam(':contractaddress', $contractaddress); $stmt->bindParam(':contractaddress', $contractaddress);
// $stmt->bindParam(':contracttel', $contracttel); $stmt->bindParam(':contracttel', $contracttel);
// $stmt->bindParam(':contractemail', $contractemail); $stmt->bindParam(':contractemail', $contractemail);
// $stmt->bindParam(':contract_employee', $contract_employee); $stmt->bindParam(':contract_employee', $contract_employee);
// $stmt->bindParam(':start_date', $start_date); $stmt->bindParam(':start_date', $start_date);
// $stmt->bindParam(':end_date', $end_date); $stmt->bindParam(':end_date', $end_date);
// $stmt->bindParam(':creater', $creater); $stmt->bindParam(':creater', $creater);
// $stmt->bindParam(':create_at', $create_at); $stmt->bindParam(':create_at', $create_at);
// $stmt->execute(); $stmt->execute();
//create facility table //create facility table
$createFacilityNo = new CreateFacilityNo(); $createFacilityNo = new CreateFacilityNo();
$dailyNecessities = [ $dailyNecessities = [
'MAE100' => 'X', 'MAE100' => 'X',
'MAM200' => 'W', 'MAM200' => 'W',
'MAH100' => 'H', 'MAH100' => 'H',
'MAQ100' => 'Z', 'MAQ100' => 'Z',
'MAF100' => 'F', 'MAF100' => 'F',
'MAZ100' => 'B', 'MAZ100' => 'B',
]; ];
$facility_arr = []; $facility_arr = [];
foreach ($elevators as $elevator) { foreach ($elevators as $elevator) {
$facility_arr[] = $dailyNecessities[$elevator['spec']]; $facility_arr[] = $dailyNecessities[$elevator['spec']];
}
echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// if ($user_id == 'M0225') {
// echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit();
// }
echo json_encode($facilityno);
echo '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $mworker);
$stmt->execute();
$worker = $stmt->fetch(PDO::FETCH_ASSOC);
$customerid = $vat;
$define = "B";
$repairtype = $mtype;
$repairerid = $mworker;
$repairername = $worker['name'];
// foreach ($elevators as $idx => $elevator) {
// $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate)
// VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)";
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':contractno', $contractno);
// $stmt->bindParam(':define', $define);
// $stmt->bindParam(':facilityno', $facilityno[$idx]);
// $stmt->bindParam(':latitude', $elevator['latitude']);
// $stmt->bindParam(':longitude', $elevator['longitude']);
// $stmt->bindParam(':customerid', $customerid);
// $stmt->bindParam(':weight', $elevator['weight']);
// $stmt->bindParam(':numberofpassenger', $elevator['persons']);
// $stmt->bindParam(':numberofstop', $elevator['stop']);
// $stmt->bindParam(':numberoffloor', $elevator['floors']);
// $stmt->bindParam(':opentype', $elevator['opendoor']);
// $stmt->bindParam(':speed', $elevator['speed']);
// $stmt->bindParam(':repairtype', $repairtype);
// $stmt->bindParam(':maintainance', $elevator['maintainance']);
// $stmt->bindParam(':facility_kind', $elevator['spec']);
// $stmt->bindParam(':address', $address);
// $stmt->bindParam(':repairerid', $repairerid);
// $stmt->bindParam(':repairername', $repairername);
// $stmt->bindParam(':creater', $creater);
// $stmt->bindParam(':create_at', $create_at);
// $stmt->bindParam(':area', $area);
// $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
// $stmt->bindParam(':licensedate', $elevator['useful_date']);
// $result = $stmt->execute();
// }
//create schedule table
$comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
$comboArr = json_decode($comboNo->getComboNo(), true);
// foreach ($facilityno as $no) {
// foreach ($comboArr as $combo) {
// $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':contractno', $contractno);
// $stmt->bindParam(':facilityno', $no);
// $stmt->bindParam(':combono', $combo[0]);
// $stmt->bindParam(':repairerid', $repairerid);
// $stmt->bindParam(':repairername', $repairername);
// $stmt->bindParam(':duedate', $combo[1]);
// $stmt->bindParam(':creater', $creater);
// $stmt->bindParam(':create_at', $create_at);
// $result = $stmt->execute();
// }
// }
// create contract_b_signed_back table
$contract_type = $mtype;
$company = $customer;
$customer_no = $vat;
$salesperson = $salesman;
$customer_phone = $phone;
$customer_email = $email;
$repairman = $mworker;
$cycle = $mcycle;
$contact_person = $partyA;
$contact_address = $partyAaddress;
$contact_phone = $partyAphone;
$contract_email = $partyAemail;
$elevators_number = $num;
$bonus = 1000;
$max_bonus = 2000;
if (!empty($files)) {
$englisharr = range('a', 'z');
$file = $_FILES['files'];
$file_name = $file['name'];
$file_type = $file['type'];
$tmp_name = $file['tmp_name'];
$file_size = $file['size'];
$error = $file['error'];
$newfiles = [];
foreach ($files as $file) {
$i = 0; //新陣列的索引編號
foreach ($file as $key => $val) {
$newfiles[$i]['name'] = $files['name'][$key];
$newfiles[$i]['type'] = $files['type'][$key];
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
$newfiles[$i]['error'] = $files['error'][$key];
$newfiles[$i]['size'] = $files['size'][$key];
$i++;
} //foreach 第2層 end
} }
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) echo json_encode($facility_arr);
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 // 電梯做番號
$path = '../images/contracts/'; $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
if (!file_exists($path)) { // if ($user_id == 'M0225') {
mkdir($path); // echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit();
// }
echo json_encode($facilityno);
echo '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $mworker);
$stmt->execute();
$worker = $stmt->fetch(PDO::FETCH_ASSOC);
$customerid = $vat;
$define = "B";
$repairtype = $mtype;
$repairerid = $mworker;
$repairername = $worker['name'];
foreach ($elevators as $idx => $elevator) {
$sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate)
VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':define', $define);
$stmt->bindParam(':facilityno', $facilityno[$idx]);
$stmt->bindParam(':latitude', $elevator['latitude']);
$stmt->bindParam(':longitude', $elevator['longitude']);
$stmt->bindParam(':customerid', $customerid);
$stmt->bindParam(':weight', $elevator['weight']);
$stmt->bindParam(':numberofpassenger', $elevator['persons']);
$stmt->bindParam(':numberofstop', $elevator['stop']);
$stmt->bindParam(':numberoffloor', $elevator['floors']);
$stmt->bindParam(':opentype', $elevator['opendoor']);
$stmt->bindParam(':speed', $elevator['speed']);
$stmt->bindParam(':repairtype', $repairtype);
$stmt->bindParam(':maintainance', $elevator['maintainance']);
$stmt->bindParam(':facility_kind', $elevator['spec']);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':repairername', $repairername);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->bindParam(':area', $area);
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
$stmt->bindParam(':licensedate', $elevator['useful_date']);
$result = $stmt->execute();
} }
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
$datetime = (string)date('YmdHis'); //create schedule table
$files_id = 'b' . $datetime; // 保養=>b + 日期時間
foreach ($newfiles as $key => $file) { $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
$randNum = rand(1000, 9999); $comboArr = json_decode($comboNo->getComboNo(), true);
$randEnglish = $englisharr[rand(0, 25)]; foreach ($facilityno as $no) {
$file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; foreach ($comboArr as $combo) {
$msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
if ($msg == 1) {
$msg = '檔案傳送成功!';
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':files_id', $files_id); $stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':file_name', $file_name); $stmt->bindParam(':facilityno', $no);
$stmt->bindParam(':file_mime', $file['type']); $stmt->bindParam(':combono', $combo[0]);
$stmt->bindParam(':file_size', $file['size']); $stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':created_at', $created_at); $stmt->bindParam(':repairername', $repairername);
$stmt->bindParam(':created_by', $user_id); $stmt->bindParam(':duedate', $combo[1]);
$stmt->execute(); $stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$result = $stmt->execute();
}
}
// create contract_b_signed_back table
$contract_type = $mtype;
$company = $customer;
$customer_no = $vat;
$salesperson = $salesman;
$customer_phone = $phone;
$customer_email = $email;
$repairman = $mworker;
$cycle = $mcycle;
$contact_person = $partyA;
$contact_address = $partyAaddress;
$contact_phone = $partyAphone;
$contract_email = $partyAemail;
$elevators_number = $num;
$bonus = 1000;
$max_bonus = 2000;
if (!empty($files)) {
$englisharr = range('a', 'z');
$file = $_FILES['files'];
$file_name = $file['name'];
$file_type = $file['type'];
$tmp_name = $file['tmp_name'];
$file_size = $file['size'];
$error = $file['error'];
$newfiles = [];
foreach ($files as $file) {
$i = 0; //新陣列的索引編號
foreach ($file as $key => $val) {
$newfiles[$i]['name'] = $files['name'][$key];
$newfiles[$i]['type'] = $files['type'][$key];
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
$newfiles[$i]['error'] = $files['error'][$key];
$newfiles[$i]['size'] = $files['size'][$key];
$i++;
} //foreach 第2層 end
}
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型
$path = '../images/contracts/';
if (!file_exists($path)) {
mkdir($path);
} }
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>'; $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
$src_name = $path . $file['name']; $datetime = (string)date('YmdHis');
if (file_exists($src_name)) { $files_id = 'b' . $datetime; // 保養=>b + 日期時間
//副檔名 foreach ($newfiles as $key => $file) {
$extname = pathinfo($src_name, PATHINFO_EXTENSION); $randNum = rand(1000, 9999);
//主檔名 $randEnglish = $englisharr[rand(0, 25)];
$basename = basename($src_name, '.' . $extname); $file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name'];
$msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name);
if ($msg == 1) {
$msg = '檔案傳送成功!';
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':files_id', $files_id);
$stmt->bindParam(':file_name', $file_name);
$stmt->bindParam(':file_mime', $file['type']);
$stmt->bindParam(':file_size', $file['size']);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $user_id);
$stmt->execute();
}
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>';
$src_name = $path . $file['name'];
if (file_exists($src_name)) {
//副檔名
$extname = pathinfo($src_name, PATHINFO_EXTENSION);
//主檔名
$basename = basename($src_name, '.' . $extname);
}
} }
} else {
$files = null;
} }
} else { $sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
$files = null;
}
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :payType ,:customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :payType ,:customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(":contract_no", $contractno); $stmt->bindParam(":contract_no", $contractno);
$stmt->bindParam(":contract_type", $contract_type); $stmt->bindParam(":contract_type", $contract_type);
$stmt->bindParam(":company", $company); $stmt->bindParam(":company", $company);
$stmt->bindParam(":customer_no", $customer_no); $stmt->bindParam(":customer_no", $customer_no);
$stmt->bindParam(":salesperson", $salesperson); $stmt->bindParam(":salesperson", $salesperson);
$stmt->bindParam(":contract_start_date", $contract_begin_date); $stmt->bindParam(":contract_start_date", $contract_begin_date);
$stmt->bindParam(":contract_end_date", $contract_end_date); $stmt->bindParam(":contract_end_date", $contract_end_date);
$stmt->bindParam(":total_price", $total_price); $stmt->bindParam(":total_price", $total_price);
$stmt->bindParam(":customer_phone", $customer_phone); $stmt->bindParam(":customer_phone", $customer_phone);
$stmt->bindParam(":customer_email", $customer_email); $stmt->bindParam(":customer_email", $customer_email);
$stmt->bindParam(":repairman", $repairman); $stmt->bindParam(":repairman", $repairman);
$stmt->bindParam(":cycle", $cycle); $stmt->bindParam(":cycle", $cycle);
$stmt->bindParam(":contact_person", $contact_person); $stmt->bindParam(":contact_person", $contact_person);
$stmt->bindParam(":contact_address", $contact_address); $stmt->bindParam(":contact_address", $contact_address);
$stmt->bindParam(":contact_phone", $contact_phone); $stmt->bindParam(":contact_phone", $contact_phone);
$stmt->bindParam(":contact_email", $contact_email); $stmt->bindParam(":contact_email", $contact_email);
$stmt->bindParam(":elevators_number", $elevators_number); $stmt->bindParam(":elevators_number", $elevators_number);
$stmt->bindParam(":area", $area); $stmt->bindParam(":area", $area);
$stmt->bindParam(":address", $address); $stmt->bindParam(":address", $address);
$stmt->bindParam(":files_id", $files_id); $stmt->bindParam(":files_id", $files_id);
$stmt->bindParam(":bonus", $bonus); $stmt->bindParam(":bonus", $bonus);
$stmt->bindParam(":max_bonus", $max_bonus); $stmt->bindParam(":max_bonus", $max_bonus);
$stmt->bindParam(":created_at", $created_at); $stmt->bindParam(":created_at", $created_at);
$stmt->bindParam(":created_by", $user_id); $stmt->bindParam(":created_by", $user_id);
$stmt->bindParam(':payType', $payType); $stmt->bindParam(':payType', $payType);
$stmt->execute();
// $date = date('Y-m-sH-s-i');
// $createTime = str_replace("-", '', $date);
// $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
// $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->bindParam(':PersonId', $salesman);
// $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':InvoiceAddress', $address);
// $stmt->bindParam(':CreateTime', $createTime);
$stmt->execute(); // $stmt->execute();
T8insert($_POST, $facilityno);
// $date = date('Y-m-sH-s-i'); header('Content-Type: application/json');
// $createTime = str_replace("-", '', $date); $jsonData = json_encode($files);
// $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
// $stmt = $connT8->prepare($sql); $conn->commit();
// $stmt->bindParam(':BizPartnerId', $contractno); } catch (PDOException $e) {
// $stmt->bindParam(':PersonId', $salesman); $conn->rollback();
// $stmt->bindParam(':CreatorId', $user_id); http_response_code(404);
// $stmt->bindParam(':InvoiceAddress', $address); echo $e->getMessage();
// $stmt->bindParam(':CreateTime', $createTime); die('Error!:' . $e->getMessage());
}
// $stmt->execute();
T8insert($_POST, $facilityno);
// header('Content-Type: application/json');
// $jsonData = json_encode($files);
// $conn->commit();
// } catch (PDOException $e) {
// $conn->rollback();
// http_response_code(404);
// echo $e->getMessage();
// die('Error!:' . $e->getMessage());
// }
}; };
function T8insert($data, $facilityno) function T8insert($data, $facilityno)
{ {
require_once("../connt8.php"); require_once("../connt8.php");
// 引入 T8 API 連線
require_once("./T8salIncomeApply.php"); require_once("./T8salIncomeApply.php");
$contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號 $contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號
$address = !empty($data['address']) ? $data['address'] : null; // 客戶地址 $address = !empty($data['address']) ? $data['address'] : null; // 客戶地址
$customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱 $customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱
@ -372,7 +374,7 @@ function T8insert($data, $facilityno)
$stmt->execute(); $stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC); $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$date = date('Y-m-sH-s-i'); $date = date('Y-m-sH-s-i');
$date_1 = date('Y-m-sH-s'); $date_1 = date('Y-m-s');
$createTime = str_replace("-", '', $date); $createTime = str_replace("-", '', $date);
$insertTime = str_replace('-', '', $date_1); $insertTime = str_replace('-', '', $date_1);
$beginDate = str_replace("-", '', $contract_begin_date); $beginDate = str_replace("-", '', $contract_begin_date);
@ -381,78 +383,78 @@ function T8insert($data, $facilityno)
echo 'Error'; echo 'Error';
exit; exit;
} }
// if (empty($result)) { if (empty($result)) {
// // 若 客戶資料為空,新增一筆到 comCustomer // 若 客戶資料為空,新增一筆到 comCustomer
// // 新增客戶資料 // 新增客戶資料
// $sql = "INSERT INTO comBusinessPartner $sql = "INSERT INTO comBusinessPartner
// (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId) (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId)
// VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')"; VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')";
// $stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':BizPartnerId', $contractno); $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->bindParam(':BizPartnerName', $partyA); $stmt->bindParam(':BizPartnerName', $partyA);
// $stmt->bindParam(':WorkTelNo', $phone); $stmt->bindParam(':WorkTelNo', $phone);
// $stmt->bindParam(':TaxNo', $vat); $stmt->bindParam(':TaxNo', $vat);
// $stmt->bindParam(':EnterpriseName', $customer); //企業名稱 $stmt->bindParam(':EnterpriseName', $customer); //企業名稱
// $stmt->bindParam(':ContactAddress', $partyAaddress); $stmt->bindParam(':ContactAddress', $partyAaddress);
// $stmt->bindParam(':EMail', $email); $stmt->bindParam(':EMail', $email);
// $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
// $stmt->execute(); $stmt->execute();
// $sql = "INSERT INTO comCustomer $sql = "INSERT INTO comCustomer
// (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime) (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)
// VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)"; VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
// $stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':BizPartnerId', $contractno); $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->bindParam(':PersonId', $salesman); $stmt->bindParam(':PersonId', $salesman);
// $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':InvoiceAddress', $address); $stmt->bindParam(':InvoiceAddress', $address);
// $stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
// $stmt->execute(); $stmt->execute();
// } else { } else {
// // // 若客戶資料不為空,更新該客戶資訊。 // // 若客戶資料不為空,更新該客戶資訊。
// $sql = "UPDATE comCustomer SET $sql = "UPDATE comCustomer SET
// PersonId=:PersonId, PersonId=:PersonId,
// InvoiceAddress=:InvoiceAddress, InvoiceAddress=:InvoiceAddress,
// LastOperatorId=:LastOperatorId, LastOperatorId=:LastOperatorId,
// LastOperateTime=:LastOperateTime LastOperateTime=:LastOperateTime
// WHERE BizPartnerId=:BizPartnerId WHERE BizPartnerId=:BizPartnerId
// "; ";
// $stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':PersonId', $salesman); $stmt->bindParam(':PersonId', $salesman);
// $stmt->bindParam(':InvoiceAddress', $address); $stmt->bindParam(':InvoiceAddress', $address);
// $stmt->bindParam(':LastOperatorId', $user_id); $stmt->bindParam(':LastOperatorId', $user_id);
// $stmt->bindParam(':LastOperateTime', $createTime); $stmt->bindParam(':LastOperateTime', $createTime);
// $stmt->bindParam(':BizPartnerId', $contractno); $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->execute(); $stmt->execute();
// $sql = "UPDATE comBusinessPartner SET $sql = "UPDATE comBusinessPartner SET
// BizPartnerName=:BizPartnerName, BizPartnerName=:BizPartnerName,
// WorkTelNo=:WorkTelNo, WorkTelNo=:WorkTelNo,
// TaxNo=:TaxNo, TaxNo=:TaxNo,
// EnterpriseName=:EnterpriseName, EnterpriseName=:EnterpriseName,
// ContactAddress=:ContactAddress, ContactAddress=:ContactAddress,
// EMail=:EMail, EMail=:EMail,
// LastOperatorId=:LastOperatorId, LastOperatorId=:LastOperatorId,
// LastOperateTime=:LastOperateTime LastOperateTime=:LastOperateTime
// WHERE BizPartnerId = :BizPartnerId WHERE BizPartnerId = :BizPartnerId
// "; ";
// $stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':BizPartnerName', $partyA); $stmt->bindParam(':BizPartnerName', $partyA);
// $stmt->bindParam(':WorkTelNo', $phone); $stmt->bindParam(':WorkTelNo', $phone);
// $stmt->bindParam(':TaxNo', $vat); $stmt->bindParam(':TaxNo', $vat);
// $stmt->bindParam(':EnterpriseName', $customer); $stmt->bindParam(':EnterpriseName', $customer);
// $stmt->bindParam(':ContactAddress', $partyAaddress); $stmt->bindParam(':ContactAddress', $partyAaddress);
// $stmt->bindParam(':EMail', $email); $stmt->bindParam(':EMail', $email);
// $stmt->bindParam(':LastOperatorId', $user_id); $stmt->bindParam(':LastOperatorId', $user_id);
// $stmt->bindParam(':LastOperateTime', $createTime); $stmt->bindParam(':LastOperateTime', $createTime);
// $stmt->bindParam(':BizPartnerId', $contractno); $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->execute(); $stmt->execute();
// } }
// echo '<pre>'; // echo '<pre>';
// print_r($elevators['maintainance']); // print_r($elevators['maintainance']);
// echo '</pre>'; // echo '</pre>';
@ -466,22 +468,25 @@ function T8insert($data, $facilityno)
$type = 'C5'; $type = 'C5';
} }
} }
// echo '<pre>'; $sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId";
// print_r($type); $stmt = $connT8->prepare($sql);
// echo '</pre>'; $stmt->bindParam(':ProjectId', $contractno);
$stmt->execute();
// //新增於 comProject。合約 table $resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC);
// $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed) if (empty($resultProject)) {
// VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,:ValidityToDate,:CreateTime,:CreatorId,1)"; //新增於 comProject。合約 table
// $stmt = $connT8->prepare($sql); $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed)
// $stmt->bindParam(':ProjectId', $contractno); VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,:ValidityToDate,:CreateTime,:CreatorId,1)";
// $stmt->bindParam(':ProjectName', $customer); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':TypeId', $type); $stmt->bindParam(':ProjectId', $contractno);
// $stmt->bindParam(':ValidityFromDate', $beginDate); $stmt->bindParam(':ProjectName', $customer);
// $stmt->bindParam(':ValidityToDate', $endDate); $stmt->bindParam(':TypeId', $type);
// $stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':ValidityFromDate', $beginDate);
// $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':ValidityToDate', $endDate);
// $stmt->execute(); $stmt->bindParam(':CreateTime', $createTime);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->execute();
}
// // 新增電梯數 // // 新增電梯數
foreach ($elevators as $index => $elevator) { foreach ($elevators as $index => $elevator) {
@ -489,35 +494,35 @@ function T8insert($data, $facilityno)
// print_r($elevator); // print_r($elevator);
// echo '</pre>'; // echo '</pre>';
// $sql = "INSERT INTO comMaterial $sql = "INSERT INTO comMaterial
// (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime) (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime)
// VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)"; VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)";
// $stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':MaterialId', $facilityno[$index]); $stmt->bindParam(':MaterialId', $facilityno[$index]);
// $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
// $stmt->execute(); $stmt->execute();
// $sql = "INSERT INTO comMaterialGroup $sql = "INSERT INTO comMaterialGroup
// (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime) (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime)
// VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)"; VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)";
// $stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':MaterialId', $facilityno[$index]); $stmt->bindParam(':MaterialId', $facilityno[$index]);
// $stmt->bindParam(':MaterialName', $customer); $stmt->bindParam(':MaterialName', $customer);
// $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
// $stmt->execute(); $stmt->execute();
// $sql = "INSERT INTO comMaterialPurchases $sql = "INSERT INTO comMaterialPurchases
// (Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime) (Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
// VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)"; VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)";
// $stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':MaterialId', $facilityno[$index]); $stmt->bindParam(':MaterialId', $facilityno[$index]);
// $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
// $stmt->execute(); $stmt->execute();
// $arr = []; // 分期代碼計算
$IncomeId = [ $IncomeId = [
'A40006' => 1, 'A40006' => 1,
'A40007' => 4, 'A40007' => 4,
@ -525,28 +530,35 @@ function T8insert($data, $facilityno)
'A40004' => 6, 'A40004' => 6,
'A40005' => 2 'A40005' => 2
]; ];
$SQuantity = $elevator['maintain_months'] / $IncomeId[$payType]; //分幾期 => 總共保養月 / 分期月 //分幾期 => 總共保養月 / 分期月
$SQuantity = $elevator['maintain_months'] / $IncomeId[$payType];
// 依每台電梯去加入各個的付款項
for ($i = 1; $i <= $IncomeId[$payType]; $i++) { for ($i = 1; $i <= $IncomeId[$payType]; $i++) {
$rows_data = [ $rows_data = [
"BillNo" => " $contractno ", "BillNo" => "$contractno",
"IncomeId" => " $payType ", "IncomeId" => "$payType",
"TaxId" => "ST005", "TaxId" => "ST005",
"RowCode" => $i, "RowCode" => $i,
"RowNo" => $i, "RowNo" => $i,
"ItemType" => 1, "ItemType" => 1,
"SPrice" => $elevator['sold_price'], "SPrice" => $elevator['sold_price'],
"SQuantity" => $SQuantity, "SQuantity" => $SQuantity,
"ProjectId" => " $contractno ", "ProjectId" => "$contractno",
"FromSourceTag" => 0, "FromSourceTag" => 0,
"CU_MaterialId" => " $facilityno[$index] " "CU_MaterialId" => "$facilityno[$index]"
]; ];
$salIncomeApplyDetail_rows[] = $rows_data; $salIncomeApplyDetail_rows[] = $rows_data;
} }
} }
$connT8->commit();
// $insertime = settype($insertTime, 'integer');
$salIncomeApplyMaster_rows = [ $salIncomeApplyMaster_rows = [
"BillNo" => "$contractno", "BillNo" => "$contractno",
"BillDate" => $date_1, "BillDate" => $insertTime,
"OrgId" => "1000", "OrgId" => "1000",
"FOrgId" => "1000", "FOrgId" => "1000",
"TypeId" => "RAS", "TypeId" => "RAS",
@ -574,7 +586,11 @@ function T8insert($data, $facilityno)
]; ];
$API_body[] = $salIncomeApplyMaster; $API_body[] = $salIncomeApplyMaster;
$API_body[] = $salIncomeApplyDetail; $API_body[] = $salIncomeApplyDetail;
T8API($API_body); // 呼叫 API
// json_encode($API_body); $result = T8API($API_body);
// $connT8->commit();
if ($result['Status'] == 'Error') {
http_response_code(404);
die('Error!:' . $result['ErrorMsg']);
}
} }

173
wms/contract/api/test.json

@ -4,7 +4,7 @@
"rows": [ "rows": [
{ {
"BillNo": "B23100060", "BillNo": "B23100060",
"BillDate": "2024-01-5215-52", "BillDate": "20240122",
"OrgId": "1000", "OrgId": "1000",
"FOrgId": "1000", "FOrgId": "1000",
"TypeId": "RAS", "TypeId": "RAS",
@ -26,89 +26,160 @@
"name": "salIncomeApplyDetail", "name": "salIncomeApplyDetail",
"rows": [ "rows": [
{ {
"BillNo": " B23100060 ", "BillNo": "B23100060",
"IncomeId": " A40007 ", "IncomeId": "A40003",
"TaxId": "ST005", "TaxId": "ST005",
"RowCode": 1, "RowCode": 1,
"RowNo": 1, "RowNo": 1,
"ItemType": 1, "ItemType": 1,
"SPrice": 1250, "SPrice": 1250,
"SQuantity": 3, "SQuantity": 1,
"ProjectId": " B23100060 ", "ProjectId": "B23100060",
"FromSourceTag": 0, "FromSourceTag": 0,
"CU_MaterialId": " 4TZ53201 " "CU_MaterialId": "4TH53801"
}, },
{ {
"BillNo": " B23100060 ", "BillNo": "B23100060",
"IncomeId": " A40007 ", "IncomeId": "A40003",
"TaxId": "ST005", "TaxId": "ST005",
"RowCode": 2, "RowCode": 2,
"RowNo": 2, "RowNo": 2,
"ItemType": 1, "ItemType": 1,
"SPrice": 1250, "SPrice": 1250,
"SQuantity": 3, "SQuantity": 1,
"ProjectId": " B23100060 ", "ProjectId": "B23100060",
"FromSourceTag": 0, "FromSourceTag": 0,
"CU_MaterialId": " 4TZ53201 " "CU_MaterialId": "4TH53801"
}, },
{ {
"BillNo": " B23100060 ", "BillNo": "B23100060",
"IncomeId": " A40007 ", "IncomeId": "A40003",
"TaxId": "ST005", "TaxId": "ST005",
"RowCode": 3, "RowCode": 3,
"RowNo": 3, "RowNo": 3,
"ItemType": 1, "ItemType": 1,
"SPrice": 1250, "SPrice": 1250,
"SQuantity": 3, "SQuantity": 1,
"ProjectId": " B23100060 ", "ProjectId": "B23100060",
"FromSourceTag": 0, "FromSourceTag": 0,
"CU_MaterialId": " 4TZ53201 " "CU_MaterialId": "4TH53801"
}, },
{ {
"BillNo": " B23100060 ", "BillNo": "B23100060",
"IncomeId": " A40007 ", "IncomeId": "A40003",
"TaxId": "ST005", "TaxId": "ST005",
"RowCode": 4, "RowCode": 4,
"RowNo": 4, "RowNo": 4,
"ItemType": 1, "ItemType": 1,
"SPrice": 1250, "SPrice": 1250,
"SQuantity": 3, "SQuantity": 1,
"ProjectId": " B23100060 ", "ProjectId": "B23100060",
"FromSourceTag": 0, "FromSourceTag": 0,
"CU_MaterialId": " 4TZ53201 " "CU_MaterialId": "4TH53801"
} },
]
}
]
[
{
"name": "OtherStockOutMtable",
"rows": [
{ {
"BillNo": "Z001", "BillNo": "B23100060",
"BillDate": 20210427, "IncomeId": "A40003",
"OrgId": "1000", "TaxId": "ST005",
"FOrgId": "1000", "RowCode": 5,
"TypeId": "OD", "RowNo": 5,
"BizPartnerId": "Z001", "ItemType": 1,
"PersonId": "Z001", "SPrice": 1250,
"DeptId": "T001", "SQuantity": 1,
"CompId": "1000" "ProjectId": "B23100060",
} "FromSourceTag": 0,
] "CU_MaterialId": "4TH53801"
}, },
{
"name": "OtherStockOutDetail",
"rows": [
{ {
"BillNo": "Z001", "BillNo": "B23100060",
"RowCode": 1, "IncomeId": "A40003",
"MaterialId": "Z001", "TaxId": "ST005",
"SupplyOrgId": "1000", "RowCode": 6,
"RowNo": 6,
"ItemType": 1,
"SPrice": 1250,
"SQuantity": 1,
"ProjectId": "B23100060",
"FromSourceTag": 0,
"CU_MaterialId": "4TH53801"
},
{
"BillNo": "B23100060",
"IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 7,
"RowNo": 7,
"ItemType": 1,
"SPrice": 1250,
"SQuantity": 1,
"ProjectId": "B23100060",
"FromSourceTag": 0,
"CU_MaterialId": "4TH53801"
},
{
"BillNo": "B23100060",
"IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 8,
"RowNo": 8,
"ItemType": 1,
"SPrice": 1250,
"SQuantity": 1,
"ProjectId": "B23100060",
"FromSourceTag": 0,
"CU_MaterialId": "4TH53801"
},
{
"BillNo": "B23100060",
"IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 9,
"RowNo": 9,
"ItemType": 1,
"SPrice": 1250,
"SQuantity": 1,
"ProjectId": "B23100060",
"FromSourceTag": 0,
"CU_MaterialId": "4TH53801"
},
{
"BillNo": "B23100060",
"IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 10,
"RowNo": 10,
"ItemType": 1,
"SPrice": 1250,
"SQuantity": 1, "SQuantity": 1,
"WarehouseId": "10" "ProjectId": "B23100060",
"FromSourceTag": 0,
"CU_MaterialId": "4TH53801"
},
{
"BillNo": "B23100060",
"IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 11,
"RowNo": 11,
"ItemType": 1,
"SPrice": 1250,
"SQuantity": 1,
"ProjectId": "B23100060",
"FromSourceTag": 0,
"CU_MaterialId": "4TH53801"
},
{
"BillNo": "B23100060",
"IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 12,
"RowNo": 12,
"ItemType": 1,
"SPrice": 1250,
"SQuantity": 1,
"ProjectId": "B23100060",
"FromSourceTag": 0,
"CU_MaterialId": "4TH53801"
} }
] ]
} }

133
wms/contract/api/testT8API.php

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

1
wms/frame/api_getdata.php

@ -166,6 +166,7 @@ function get_pending($token)
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
// print_r($row);
$data[$i]["sid"] = $row[0]; $data[$i]["sid"] = $row[0];
$data[$i]["sname"] = $row[1]; $data[$i]["sname"] = $row[1];
$data[$i]["fid"] = $row[2]; $data[$i]["fid"] = $row[2];

196
wms/frame/pending.php

@ -3,108 +3,134 @@ $token = $_REQUEST["token"];
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" /> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
<title>待我簽核</title> <title>待我簽核</title>
<link rel="stylesheet" href="css/plugins/fontawesome-free/css/all.min.css"> <link rel="stylesheet" href="css/plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="css/dist/css/adminlte.min.css"> <link rel="stylesheet" href="css/dist/css/adminlte.min.css">
<script src="../css/jquery.min.js"></script> <script src="../css/jquery.min.js"></script>
<script src="../css/bootstrap.min.js"></script> <script src="../css/bootstrap.min.js"></script>
<style> <style>
.content-wrapper { .content-wrapper {
background-color: #fff; background-color: #fff;
} }
.col-lg-6 {
padding:8px 0 0 0!important; .col-lg-6 {
} padding: 8px 0 0 0 !important;
.card { }
height: 90vh;
line-height: 14 px; .card {
font-size: 14px; height: 90vh;
} line-height: 14 px;
.card-header { font-size: 14px;
background-color: #f4f6f9; }
padding-left: 16px;
} .card-header {
.card-body ol { background-color: #f4f6f9;
font-size: 14px; padding-left: 16px;
margin-left: -30px; }
}
.nav-pills .nav-link { .card-body ol {
color: #446887; font-size: 14px;
} margin-left: -30px;
h5 svg { }
vertical-align: baseline;
} .nav-pills .nav-link {
h5 a { color: #446887;
color: #000; }
}
@media screen and (max-width: 992px){ h5 svg {
.card { vertical-align: baseline;
height: 95vh; }
}
} h5 a {
</style> color: #000;
}
@media screen and (max-width: 992px) {
.card {
height: 95vh;
}
}
</style>
</head> </head>
<body> <body>
<div class="wrapper"> <div class="wrapper">
<!-- Content Wrapper. Contains page content --> <!-- Content Wrapper. Contains page content -->
<div class="content-wrapper"> <div class="content-wrapper">
<!-- Main content --> <!-- Main content -->
<div class="content"> <div class="content">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<!-- /.col-md-6 --> <!-- /.col-md-6 -->
<div class="col-lg-6"> <div class="col-lg-6">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h5 class="card-title m-0"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16"><path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/><path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/></svg> <h5 class="card-title m-0"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<a href="/wms/sign/list.php?function_name=show&token=<?php echo $token; ?>" target="_parent">待我簽核</a></h5> <path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z" />
</div> <path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z" />
<div class="card-body p-0"> </svg>
Loading... <a href="/wms/sign/list.php?function_name=show&token=<?php echo $token; ?>" target="_parent">待我簽核</a>
</h5>
</div>
<div class="card-body p-0">
Loading...
</div>
</div>
</div> </div>
<!-- /.col-md-6 -->
</div> </div>
</div> <!-- /.row -->
<!-- /.col-md-6 --> </div><!-- /.container-fluid -->
</div>
<!-- /.row -->
</div><!-- /.container-fluid -->
</div> </div>
<!-- /.content --> <!-- /.content -->
</div> </div>
<!-- /.content-wrapper --> <!-- /.content-wrapper -->
</div> </div>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
here(); here();
}); });
function here() { function here() {
var URL = 'api_getdata.php'; var URL = 'api_getdata.php';
$.ajax({ $.ajax({
type: "GET", type: "GET",
data: {p: 'pending', token: '<?php echo $token; ?>'}, data: {
url: URL, p: 'pending',
success: function (msg) { token: '<?php echo $token; ?>'
var obj = JSON.parse(msg); },
console.log(obj); url: URL,
var myhtml = ''; success: function(msg) {
if (obj.st == 'ok') { var obj = JSON.parse(msg);
myhtml += '<ul class="nav nav-pills flex-column">'; console.log(msg);
for (i=1; i<=Object.keys(obj.content).length; i++) { var myhtml = '';
myhtml += '<li class="nav-item"><a href="/wms/sign/list.php?system_id='+obj.content[i].sid+'&flow_id='+obj.content[i].fid+'&function_name=show&token=<?php echo $token; ?>" class="nav-link" target="_parent">'+obj.content[i].sname+' > '+obj.content[i].fname+'('+obj.content[i].cnt+')</a></li>'; if (obj.st == 'ok') {
myhtml += '<ul class="nav nav-pills flex-column">';
for (i = 1; i <= Object.keys(obj.content).length; i++) {
if (obj.content[i].fname == '新梯價審流程') {
myhtml += '<li class="nav-item"><a href="/wms/mkt/pricereview-index.php?system_id=' + obj.content[i].sid + '&flow_id=' + obj.content[i].fid + '&function_name=show&token=<?php echo $token; ?>" class="nav-link" target="_parent">' + obj.content[i].sname + ' > ' + obj.content[i].fname + '(' + obj.content[i].cnt + ')</a></li>';
} else if (obj.content[i].fname == '汰改價審流程') {
myhtml += '<li class="nav-item"><a href="/wms/mkt/pricereview_renovate-index.php?system_id=' + obj.content[i].sid + '&flow_id=' + obj.content[i].fid + '&function_name=show&token=<?php echo $token; ?>" class="nav-link" target="_parent">' + obj.content[i].sname + ' > ' + obj.content[i].fname + '(' + obj.content[i].cnt + ')</a></li>';
} else if (obj.content[i].fname == '契约價審流程') {
myhtml += '<li class="nav-item"><a href="/wms/cont/sign_list.php?system_id=' + obj.content[i].sid + '&flow_id=' + obj.content[i].fid + '&function_name=show&token=<?php echo $token; ?>" class="nav-link" target="_parent">' + obj.content[i].sname + ' > ' + obj.content[i].fname + '(' + obj.content[i].cnt + ')</a></li>';
} else {
myhtml += '<li class="nav-item"><a href="/wms/sign/sign_list.php?system_id=' + obj.content[i].sid + '&flow_id=' + obj.content[i].fid + '&function_name=show&token=<?php echo $token; ?>" class="nav-link" target="_parent">' + obj.content[i].sname + ' > ' + obj.content[i].fname + '(' + obj.content[i].cnt + ')</a></li>';
}
}
if (Object.keys(obj.content).length == 6) {
myhtml += '<li class="nav-item"><a href="/wms/sign/list.php?function_name=show&token=<?php echo $token; ?>" class="nav-link" target="_parent">.... 顯示更多</a></li>';
}
myhtml += '</ul>';
$('.card-body').empty().append(myhtml);
}
} }
if (Object.keys(obj.content).length == 6) { })
myhtml += '<li class="nav-item"><a href="/wms/sign/list.php?function_name=show&token=<?php echo $token; ?>" class="nav-link" target="_parent">.... 顯示更多</a></li>';
}
myhtml += '</ul>';
$('.card-body').empty().append(myhtml);
}
} }
}) </script>
}
</script>
</body> </body>
</html> </html>

4
wms/fun_global.php

@ -108,11 +108,11 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee)
$ret[4] = "M0006,,"; // 總經理 $ret[4] = "M0006,,"; // 總經理
} }
} }
return $ret;
} }
} }
mysqli_free_result($res); mysqli_free_result($res);
return $ret;
} }
/** /**
* 汰改(契約)價審簽核順位 * 汰改(契約)價審簽核順位

3
wms/mkt/pricereview-check.php

@ -58,7 +58,7 @@ foreach ($res as $data) {
mysqli_free_result($res_a); mysqli_free_result($res_a);
// 瀏覽MI權限 // 瀏覽MI權限
$depart_id = accountidToDepartId($user_id); $depart_id = accountidToDepartId($user_id);
if ($depart_id == "320" || $depart_id == "321" || $depart_id == "20") $viewmi = 1; if ($depart_id == "320" || $depart_id == "321" || $depart_id == "20" || $user_id == 'TEST04') $viewmi = 1;
else $viewmi = 0; else $viewmi = 0;
$sql = "select * from pricereview_sign where mid = '$id'"; $sql = "select * from pricereview_sign where mid = '$id'";
@ -258,6 +258,7 @@ foreach ($res as $data) {
function getMI(id) { function getMI(id) {
var formdata = new FormData(); var formdata = new FormData();
formdata.append('pa', id); formdata.append('pa', id);
// formdata.append('user_id', <?= $user_id ?>);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {

64
wms/mkt/pricereview-index.php

@ -5,8 +5,61 @@ include "../header.php";
$accountname_arr = accountid2name(); $accountname_arr = accountid2name();
$status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"]; $status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"];
$pricereviewID = $_GET['id'];
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
// 從待我簽核進來
if (!empty($_GET['system_id']) && !empty($_GET['flow_id'])) {
$system_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['system_id'] : @$_POST['system_id'];
$where_system_id = " and a.system_id like '" . $system_id . "%'";
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id'];
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'";
$sql_get = "SELECT d.form_id,c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner,
concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name ,
flow_name,c.update_date ,c.create_date,b.path,d.flow_code FROM system_main a,flow_main b ,subflow
c,flow d
WHERE a.system_id=b.system_id
AND b.flow_id=d.flow_id
AND c.current_assigner='$user_id'
AND d.flow_id=b.flow_id
AND c.form_key=d.form_key
$where_system_id
$where_flow_id
";
echo '<pre>';
print_r($sql_get);
echo '</pre>';
$result = mysqli_query($link, $sql_get);
if ($result == false) {
die(mysqli_error($link));
}
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC);
foreach ($res_get as $key => $data) {
// 結案隱藏
if ($data['flow_code'] !== 'Z') {
$test = $data['form_id'];
// $sql = "SELECT mid FROM pricereview_sign WHERE id = $test";
// $result = mysqli_fetch_all(mysqli_query($link, $sql), MYSQLI_ASSOC);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
$id[] = $test;
}
}
$inClause = implode(',', $id);
// echo '<pre>';
// print_r($inClause);
// echo '</pre>';
}
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id, "pricereview_main .creater"); $sql_cmd = sql_myself($user_id, "pricereview_main .creater");
@ -23,6 +76,14 @@ if ($user_id == "M0060") {
if (empty($sql_cmd)) $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id"; if (empty($sql_cmd)) $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
else $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on contract_new_apply.mid = pricereview_main.id $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id"; else $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on contract_new_apply.mid = pricereview_main.id $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
if (!empty($res_get)) {
$sql = "SELECT pricereview_main.*,contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress
from pricereview_main
left join contract_new_apply on contract_new_apply.mid = pricereview_main.id
$sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.id IN ($inClause) AND pricereview_main.ekind = '新梯' order by pricereview_main.id";
// echo $sql;
}
$data = mysqli_query($link, $sql); $data = mysqli_query($link, $sql);
$para = "function_name=pricereview&" . $token_link; $para = "function_name=pricereview&" . $token_link;
@ -162,6 +223,7 @@ if ($data) :
<tbody> <tbody>
<?php <?php
foreach ($data as $data) : foreach ($data as $data) :
$sign1 = $sign2 = $sign3 = $sign4 = ""; $sign1 = $sign2 = $sign3 = $sign4 = "";
$oneself = ($data["creater"] == $user_id) ? 1 : 0; // 是否為營業員本人 $oneself = ($data["creater"] == $user_id) ? 1 : 0; // 是否為營業員本人
// 簽核狀況 // 簽核狀況

111
wms/mkt/pricereview_mi-api.php

@ -1,4 +1,5 @@
<?php <?php
/** /**
* by單台計算MI * by單台計算MI
* @url /wms/mkt/pricereview_mi-api.php * @url /wms/mkt/pricereview_mi-api.php
@ -22,8 +23,9 @@ ob_end_clean();
$rarr = array('st' => 'ok', 'err' => ''); $rarr = array('st' => 'ok', 'err' => '');
try { try {
if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty");
if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty");
$user_id = empty($_POST['user_id']) ? '' : $_POST['user_id'];
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
@ -33,17 +35,19 @@ try {
if (strpos($pa, ",")) list($id, $opt) = explode(",", $pa); if (strpos($pa, ",")) list($id, $opt) = explode(",", $pa);
else $id = $pa; else $id = $pa;
$person2weight_arr = [ "6" => "450", $person2weight_arr = [
"8" => "550", "6" => "450",
"9" => "600", "8" => "550",
"10" => "700", "9" => "600",
"11" => "750", "10" => "700",
"12" => "800", "11" => "750",
"13" => "900", "12" => "800",
"15" => "1000", "13" => "900",
"17" => "1150", "15" => "1000",
"20" => "1350", "17" => "1150",
"24" => "1600"]; "20" => "1350",
"24" => "1600"
];
$elev_arr = $elev_opt_arr = $pv_arr = $opt_elev_arr = $mi_arr = []; $elev_arr = $elev_opt_arr = $pv_arr = $opt_elev_arr = $mi_arr = [];
$i = $weight = $elev_qty_all = 0; $i = $weight = $elev_qty_all = 0;
@ -84,7 +88,7 @@ try {
$special_fee = $row[0]; $special_fee = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
$specarr[0] = "服務費"; $specarr[0] = "服務費";
$specarr[1] = round($special_fee/$elev_qty_all, 0); $specarr[1] = round($special_fee / $elev_qty_all, 0);
// 電梯所屬OPTION // 電梯所屬OPTION
$opt_sel_id_arr = []; $opt_sel_id_arr = [];
@ -114,7 +118,6 @@ try {
$elev_opt_arr[$v][] = $pv_arr; $elev_opt_arr[$v][] = $pv_arr;
} }
*/ */
} }
mysqli_free_result($res); mysqli_free_result($res);
$opt_nosel_id_arr = array_diff(array_keys($opt_elev_arr), $opt_sel_id_arr); $opt_nosel_id_arr = array_diff(array_keys($opt_elev_arr), $opt_sel_id_arr);
@ -143,7 +146,7 @@ try {
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
$exarr[$j][0] = $row[1]; $exarr[$j][0] = $row[1];
$exarr[$j][1] = round($row[2]/$elev_qty_all, 0); $exarr[$j][1] = round($row[2] / $elev_qty_all, 0);
$ex_fee += $exarr[$j][1]; $ex_fee += $exarr[$j][1];
$j++; $j++;
} }
@ -155,20 +158,20 @@ try {
$sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'"; $sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'";
$res_i = mysqli_query($link, $sql3); $res_i = mysqli_query($link, $sql3);
while ($row_i = mysqli_fetch_assoc($res_i)) { while ($row_i = mysqli_fetch_assoc($res_i)) {
$sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '".$row_i["item_spec"]."' "; $sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '" . $row_i["item_spec"] . "' ";
$sql4 .= "and version_date = '2023-09-04'"; $sql4 .= "and version_date = '2023-09-04'";
$sql4 .= "and ($row_i[note] between min_floors and max_floors) "; $sql4 .= "and ($row_i[note] between min_floors and max_floors) ";
$res_d = mysqli_query($link, $sql4); $res_d = mysqli_query($link, $sql4);
if ($row_d = mysqli_fetch_assoc($res_d)) { if ($row_d = mysqli_fetch_assoc($res_d)) {
$dismantle_amt += ($row_d["price"] + $row_d["price_plus"]*($row_i["note"] - $row_d["min_floors"]))*$row_i["item_qty"]; $dismantle_amt += ($row_d["price"] + $row_d["price_plus"] * ($row_i["note"] - $row_d["min_floors"])) * $row_i["item_qty"];
$polishing_amt += 3000*$row_i["note"]; $polishing_amt += 3000 * $row_i["note"];
} }
mysqli_free_result($res_d); mysqli_free_result($res_d);
} }
mysqli_free_result($res_i); mysqli_free_result($res_i);
} }
$dismantle_fee = round($dismantle_amt/$elev_qty_all, 0); $dismantle_fee = round($dismantle_amt / $elev_qty_all, 0);
$polishing_fee = round($polishing_amt/$elev_qty_all, 0); $polishing_fee = round($polishing_amt / $elev_qty_all, 0);
//print_r($elev_arr); //print_r($elev_arr);
//print_r($opt_elev_arr); //print_r($opt_elev_arr);
@ -179,33 +182,33 @@ try {
foreach ($elev_arr as $item_no => $v) { foreach ($elev_arr as $item_no => $v) {
// 電梯MI // 電梯MI
$sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r "; $sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r ";
$sql2 .= "where o.quotation_no = r.quotation_no and o.elevator_type = '".$v['etype']."' "; $sql2 .= "where o.quotation_no = r.quotation_no and o.elevator_type = '" . $v['etype'] . "' ";
$sql2 .= "and ($v[item_weight] between o.min_weight and o.max_weight) "; $sql2 .= "and ($v[item_weight] between o.min_weight and o.max_weight) ";
$sql2 .= "and ($v[floors] between o.min_floors and o.max_floors) "; $sql2 .= "and ($v[floors] between o.min_floors and o.max_floors) ";
$sql2 .= "and ($v[speed] between o.min_speed and o.max_speed) "; $sql2 .= "and ($v[speed] between o.min_speed and o.max_speed) ";
if ($v["etype"] == "MAQ100" || $v["etype"] == "MAP100") { if ($v["etype"] == "MAQ100" || $v["etype"] == "MAP100") {
$sql2 .= "and (o.model_no = '".$v["persons"]."') "; $sql2 .= "and (o.model_no = '" . $v["persons"] . "') ";
} }
$res_e = mysqli_query($link, $sql2); $res_e = mysqli_query($link, $sql2);
if ($row_e = mysqli_fetch_assoc($res_e)) { if ($row_e = mysqli_fetch_assoc($res_e)) {
// 加價:先不納入 // 加價:先不納入
$row_e["option_price"] = 0; $row_e["option_price"] = 0;
// 基准采购成本+±1停材料费+设计费+出口费用 // 基准采购成本+±1停材料费+设计费+出口费用
$part1 = $row_e["purchase_cost"]+($v["floors"]-$row_e["base_floor"])*$row_e["material_plus"]+$row_e["design"]*$row_e["design_hour"]+$row_e["export_fee"]; $part1 = $row_e["purchase_cost"] + ($v["floors"] - $row_e["base_floor"]) * $row_e["material_plus"] + $row_e["design"] * $row_e["design_hour"] + $row_e["export_fee"];
// 利潤 // 利潤
$profit = round($part1*$row_e["profit"]+$row_e["equip_profit"], 0); $profit = round($part1 * $row_e["profit"] + $row_e["equip_profit"], 0);
// 設備 // 設備
$equipment_ntd = round(($part1+$profit)*$row_e["equipment"], 0); $equipment_ntd = round(($part1 + $profit) * $row_e["equipment"], 0);
// 報關+運輸 // 報關+運輸
$customs = round($equipment_ntd*$row_e["shipping"], 0)+$row_e["customs_shipping"]; $customs = round($equipment_ntd * $row_e["shipping"], 0) + $row_e["customs_shipping"];
// 安裝基價 // 安裝基價
$install_base = $row_e["install_price"]+$row_e["trial_price"]+$row_e["install_coef"]*$row_e["install_plus"]+$row_e["trial_coef"]*$row_e["trial_plus"]; $install_base = $row_e["install_price"] + $row_e["trial_price"] + $row_e["install_coef"] * $row_e["install_plus"] + $row_e["trial_coef"] * $row_e["trial_plus"];
// 安裝成本 // 安裝成本
$install_price = round($install_base+($row_e["install_plus"]+$row_e["trial_plus"])*($v["floors"]-$row_e["base_floor"]), 0); $install_price = round($install_base + ($row_e["install_plus"] + $row_e["trial_plus"]) * ($v["floors"] - $row_e["base_floor"]), 0);
// 起吊+木箱+耗材 // 起吊+木箱+耗材
$woods = $row_e["crane"]+$row_e["wooden_box"]+$row_e["consume"]+$row_e["consumables"]; $woods = $row_e["crane"] + $row_e["wooden_box"] + $row_e["consume"] + $row_e["consumables"];
// MI // MI
$mi = $equipment_ntd+$customs+$row_e["unloading"]+$row_e["transport_site"]+$install_price+$row_e["free1y"]+$woods+$row_e["option_price"]; $mi = $equipment_ntd + $customs + $row_e["unloading"] + $row_e["transport_site"] + $install_price + $row_e["free1y"] + $woods + $row_e["option_price"];
/* /*
$install_price = $row_e["install_price"] + $row_e["install_plus"]*($floors - $row_e["min_floors"]); // 安裝 $install_price = $row_e["install_price"] + $row_e["install_plus"]*($floors - $row_e["min_floors"]); // 安裝
@ -261,23 +264,24 @@ try {
$sql4 = "select o.base_floor, o.base_floor_plus, o.price, r.equipment, p.price 'OP' "; $sql4 = "select o.base_floor, o.base_floor_plus, o.price, r.equipment, p.price 'OP' ";
$sql4 .= "from option_mi o, elevator_quotation_rule r, option_price p "; $sql4 .= "from option_mi o, elevator_quotation_rule r, option_price p ";
$sql4 .= "where o.quotation_no = r.quotation_no and o.option_price_id = p.id "; $sql4 .= "where o.quotation_no = r.quotation_no and o.option_price_id = p.id ";
$sql4 .= "and o.option_price_id = ".$opt_elev_arr[$val]["price_id"]." "; $sql4 .= "and o.option_price_id = " . $opt_elev_arr[$val]["price_id"] . " ";
$sql4 .= "and ($v[item_weight] between o.min_weight and o.max_weight) and o.open_kind = '".$v["item_op"]."'"; $sql4 .= "and ($v[item_weight] between o.min_weight and o.max_weight) and o.open_kind = '" . $v["item_op"] . "'";
$res_om = mysqli_query($link, $sql4); $res_om = mysqli_query($link, $sql4);
if ($row_om = mysqli_fetch_assoc($res_om)) { if ($row_om = mysqli_fetch_assoc($res_om)) {
$row_om['price'] = (int)ceil($row_om['price']); $row_om['price'] = (int)ceil($row_om['price']);
$plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"])*$row_om["base_floor_plus"] : 0; $plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"]) * $row_om["base_floor_plus"] : 0;
// 特例 // 特例
if ($opt_elev_arr[$val]["price_id"] == "256" && ($v["floors"] < $row_om["base_floor"])) $row_om["price"] = 9815; if ($opt_elev_arr[$val]["price_id"] == "256" && ($v["floors"] < $row_om["base_floor"])) $row_om["price"] = 9815;
if ($opt_elev_arr[$val]["price_id"] == "266" && $v["floors"] >= 20) $plus += 44.8; // 15层,14.6元/层(19层内,跳20层再追加44.8元) if ($opt_elev_arr[$val]["price_id"] == "266" && $v["floors"] >= 20) $plus += 44.8; // 15层,14.6元/层(19层内,跳20层再追加44.8元)
if ($row_om["price"] == 0) $row_om["price"] = $row_om["OP"]*0.6; // 實體且沒成本的:抓牌價6成 if ($row_om["price"] == 0) $row_om["price"] = $row_om["OP"] * 0.6; // 實體且沒成本的:抓牌價6成
// 含此option的電梯總台數 // 含此option的電梯總台數
$myelev_qty = 0; $myelev_qty = 0;
foreach ($opt_elev_arr[$val]["elev_no"] as $pval) { foreach ($opt_elev_arr[$val]["elev_no"] as $pval) {
$myelev_qty += $elev_arr[$pval]["item_qty"]; $myelev_qty += $elev_arr[$pval]["item_qty"];
} }
// 分配:OPTION數量除以電梯總台數 // 分配:OPTION數量除以電梯總台數
$option_amt = round(0+($row_om["price"]+$plus)*($opt_elev_arr[$val]["item_qty"]/$myelev_qty)*$row_om["equipment"], 0); $option_amt = round(0 + ($row_om["price"] + $plus) * ($opt_elev_arr[$val]["item_qty"] / $myelev_qty) * $row_om["equipment"], 0);
$option_fee += $option_amt; // option總金額 $option_fee += $option_amt; // option總金額
$oparr[$j][1] = $option_amt; $oparr[$j][1] = $option_amt;
@ -301,8 +305,8 @@ try {
$myelev_qty += $elev_arr[$pval]["item_qty"]; $myelev_qty += $elev_arr[$pval]["item_qty"];
} }
// 分配:延保總價除以電梯總台數 // 分配:延保總價除以電梯總台數
$mn_amt += round(0+($mn_elev_arr[$val]["item_price_bp"]/$myelev_qty), 0); $mn_amt += round(0 + ($mn_elev_arr[$val]["item_price_bp"] / $myelev_qty), 0);
$mnarr[$j][0] = $mn_elev_arr[$val]["item_spec"]."保養費"; $mnarr[$j][0] = $mn_elev_arr[$val]["item_spec"] . "保養費";
$mnarr[$j][1] = $mn_amt; $mnarr[$j][1] = $mn_amt;
$mn_fee += $mn_amt; $mn_fee += $mn_amt;
$j++; $j++;
@ -338,7 +342,7 @@ try {
*/ */
// 拆台數 // 拆台數
for ($n = 0; $n<$v["item_qty"]; $n++) { for ($n = 0; $n < $v["item_qty"]; $n++) {
$mi_arr[$i][0] = $mi + $dismantle_fee + $polishing_fee + $option_fee + $ex_fee + $mn_fee; $mi_arr[$i][0] = $mi + $dismantle_fee + $polishing_fee + $option_fee + $ex_fee + $mn_fee;
/* /*
$mi_arr[$i][1] = $row_e["purchase_cost"]; $mi_arr[$i][1] = $row_e["purchase_cost"];
@ -348,23 +352,23 @@ try {
$mi_arr[$i][5] = $profit_amt; $mi_arr[$i][5] = $profit_amt;
$mi_arr[$i][6] = $quotation; $mi_arr[$i][6] = $quotation;
*/ */
$mi_arr[$i][1] = 0+$equipment_ntd; $mi_arr[$i][1] = 0 + $equipment_ntd;
$mi_arr[$i][2] = 0+$customs; $mi_arr[$i][2] = 0 + $customs;
$mi_arr[$i][3] = 0+$row_e["unloading"]; $mi_arr[$i][3] = 0 + $row_e["unloading"];
$mi_arr[$i][4] = 0+$row_e["transport_site"]; $mi_arr[$i][4] = 0 + $row_e["transport_site"];
$mi_arr[$i][5] = 0+$install_price; $mi_arr[$i][5] = 0 + $install_price;
$mi_arr[$i][6] = 0+$row_e["free1y"]; $mi_arr[$i][6] = 0 + $row_e["free1y"];
$mi_arr[$i][7] = 0+$woods; $mi_arr[$i][7] = 0 + $woods;
$mi_arr[$i][8] = $row_e["equipment"]; $mi_arr[$i][8] = $row_e["equipment"];
$mi_arr[$i][9] = 0+$row_e["option_price"]; $mi_arr[$i][9] = 0 + $row_e["option_price"];
$mi_arr[$i][10] = 0+$dismantle_fee; $mi_arr[$i][10] = 0 + $dismantle_fee;
$mi_arr[$i][11] = 0+$polishing_fee; $mi_arr[$i][11] = 0 + $polishing_fee;
$mi_arr[$i][12] = $mi_arr[$i][1]+$mi_arr[$i][2]+$mi_arr[$i][3]+$mi_arr[$i][4]+$mi_arr[$i][5]+$mi_arr[$i][6]+$mi_arr[$i][7]+$mi_arr[$i][9]+$mi_arr[$i][10]+$mi_arr[$i][11]; $mi_arr[$i][12] = $mi_arr[$i][1] + $mi_arr[$i][2] + $mi_arr[$i][3] + $mi_arr[$i][4] + $mi_arr[$i][5] + $mi_arr[$i][6] + $mi_arr[$i][7] + $mi_arr[$i][9] + $mi_arr[$i][10] + $mi_arr[$i][11];
$mi_arr[$i][13] = $option_fee+$ex_fee+$mn_fee+$special_fee; $mi_arr[$i][13] = $option_fee + $ex_fee + $mn_fee + $special_fee;
$mi_arr[$i][14] = $oparr; $mi_arr[$i][14] = $oparr;
$mi_arr[$i][15] = 0+$ex_fee; $mi_arr[$i][15] = 0 + $ex_fee;
$mi_arr[$i][16] = $exarr; $mi_arr[$i][16] = $exarr;
$mi_arr[$i][17] = 0+$mn_fee; $mi_arr[$i][17] = 0 + $mn_fee;
$mi_arr[$i][18] = $mnarr; $mi_arr[$i][18] = $mnarr;
$mi_arr[$i][19] = $specarr; $mi_arr[$i][19] = $specarr;
$i++; $i++;
@ -374,11 +378,10 @@ try {
} }
$rarr["content"] = $mi_arr; $rarr["content"] = $mi_arr;
}catch(\Exception $e) { } catch (\Exception $e) {
$rarr['st'] = 'err'; $rarr['st'] = 'err';
$rarr['err'] = $e->getMessage(); $rarr['err'] = $e->getMessage();
} }
echo json_encode($rarr, JSON_UNESCAPED_UNICODE); echo json_encode($rarr, JSON_UNESCAPED_UNICODE);
exit; exit;
?>

58
wms/mkt/pricereview_renovate-index.php

@ -6,6 +6,56 @@ $accountname_arr = accountid2name();
$status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"]; $status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"];
// 待我簽核跳
if (!empty($_GET['system_id']) && !empty($_GET['flow_id'])) {
$system_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['system_id'] : @$_POST['system_id'];
$where_system_id = " and a.system_id like '" . $system_id . "%'";
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id'];
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'";
$sql_get = "SELECT d.form_id,c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner,
concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name ,
flow_name,c.update_date ,c.create_date,b.path,d.flow_code FROM system_main a,flow_main b ,subflow
c,flow d
WHERE a.system_id=b.system_id
AND b.flow_id=d.flow_id
AND c.current_assigner='$user_id'
AND d.flow_id=b.flow_id
AND c.form_key=d.form_key
$where_system_id
$where_flow_id
";
$result = mysqli_query($link, $sql_get);
if ($result == false) {
die(mysqli_error($link));
}
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC);
// echo '<pre>';
// print_r($sql_get);
// echo '</pre>';
foreach ($res_get as $key => $data) {
// 結案隱藏
if ($data['flow_code'] !== 'Z') {
$test = $data['form_id'];
// $sql = "SELECT mid FROM pricereview_sign WHERE id = $test";
// $result = mysqli_fetch_all(mysqli_query($link, $sql), MYSQLI_ASSOC);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
$id[] = $test;
}
}
$inClause = implode(',', $id);
}
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
@ -17,12 +67,18 @@ if ($user_id == "M0024" || $user_id == "M0107" || $user_id == "M0012" || $user_i
if ($user_id == "M0008") { if ($user_id == "M0008") {
$sql_cmd = "where creater in (select accountid from account where department_id like '5%')"; $sql_cmd = "where creater in (select accountid from account where department_id like '5%')";
} }
if (!empty($res_get)) {
$sql_cmd = "where id IN ($inClause)";
}
// if ($user_id == "M0060") { // if ($user_id == "M0060") {
// $sql_cmd = "where creater in (select accountid from account where (department_id like '3%' or department_id like '5%'))"; // $sql_cmd = "where creater in (select accountid from account where (department_id like '3%' or department_id like '5%'))";
// } // }
if (empty($sql_cmd)) $sql = "select * from pricereview_main where status like 'Y%' and ekind = '汰改' order by id"; if (empty($sql_cmd)) $sql = "select * from pricereview_main where status like 'Y%' and ekind = '汰改' order by id";
else $sql = "select * from pricereview_main $sql_cmd and status like 'Y%' and ekind = '汰改' order by id"; else $sql = "select * from pricereview_main $sql_cmd and status like 'Y%' and ekind = '汰改' order by id";
// echo '<pre>';
// print_r($sql);
// echo '</pre>';
$data = mysqli_query($link, $sql); $data = mysqli_query($link, $sql);

1
wms/schedule-index.php

@ -39,6 +39,7 @@ if (!empty($sql_cmd2)) {
//$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id"; //$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc"; $sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
if (!$page_close) $sql .= " limit $page_from, $page_each"; if (!$page_close) $sql .= " limit $page_from, $page_each";
//echo $sql; //echo $sql;

61
wms/sign/list.php

@ -73,32 +73,26 @@ $where_system_id = " and a.system_id like '" . $system_id . "%'";
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id']; $flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id'];
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'"; $where_flow_id = " and b.flow_id like '" . $flow_id . "%'";
$sql_get = " $sql_get = "SELECT d.form_id,c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner,
select concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name ,
c.form_key, flow_name,c.update_date ,c.create_date,b.path,d.flow_code FROM system_main a,flow_main b ,subflow
a.system_id, c,flow d
b.flow_id , WHERE a.system_id=b.system_id
a.system_name, AND b.flow_id=d.flow_id
c.current_assigner, AND c.current_assigner='$user_id'
concat( AND d.flow_id=b.flow_id
c.current_assigner , AND c.form_key=d.form_key
'-',f_return_name(c.current_assigner)
) current_assigner_name ,
flow_name,
c.update_date ,
c.create_date,
b.path,
d.flow_code
from system_main a,flow_main b ,subflow c,flow d
where a.system_id=b.system_id
and b.flow_id=d.flow_id
and c.current_assigner='$user_id'
and d.flow_id=b.flow_id
and c.form_key=d.form_key
$where_system_id $where_system_id
$where_flow_id $where_flow_id
"; ";
//echo $sql_get; // echo '<pre>';
// print_r($sql_get);
// echo '</pre>';
$result = mysqli_query($link, $sql_get);
if ($result == false) {
die(mysqli_error($link));
}
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC); $res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC);
$system_name_opt = array_map(function ($item) { $system_name_opt = array_map(function ($item) {
@ -211,6 +205,25 @@ $flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR));
<tbody> <tbody>
<?php <?php
foreach ($res_get as $key => $data) {
if ($data['flow_code'] !== 'Z') {
$test = $data['form_id'];
$sql = "SELECT mid FROM pricereview_sign WHERE id = $test";
$result = mysqli_fetch_all(mysqli_query($link, $sql), MYSQLI_ASSOC);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
$id[] = $result[0]['mid'];
}
}
$inClause = implode(',', $id);
echo '<pre>';
print_r($inClause);
echo '</pre>';
$rowspan = 1; $rowspan = 1;
foreach ($res_get as $key => $data) : foreach ($res_get as $key => $data) :
//嘗試將已結案隱藏起來 : 測試使用者體驗 //嘗試將已結案隱藏起來 : 測試使用者體驗

Loading…
Cancel
Save