diff --git a/wms/T8_APItest.php b/wms/T8_APItest.php index a6febca7..c2fe6d18 100644 --- a/wms/T8_APItest.php +++ b/wms/T8_APItest.php @@ -3,70 +3,72 @@ include "T8_Authorization.php"; echo "ii"; ?> \ No newline at end of file diff --git a/wms/T8_Authorization.php b/wms/T8_Authorization.php index d906dbbc..a1a756ce 100644 --- a/wms/T8_Authorization.php +++ b/wms/T8_Authorization.php @@ -1,21 +1,23 @@ \ No newline at end of file diff --git a/wms/T8_Authorization_from_bpm.php b/wms/T8_Authorization_from_bpm.php index 125ee65e..05069bca 100644 --- a/wms/T8_Authorization_from_bpm.php +++ b/wms/T8_Authorization_from_bpm.php @@ -5,16 +5,18 @@ $user_password = "M012290493119"; function get_Auth($user_id = "M0000", $user_password = "M012290493119") { + $currentTime = time(); + $twoMinutesLater = $currentTime - (2 * 60); - $now = gmdate("YmdHis"); + $now = gmdate("YmdHis", $twoMinutesLater); $data = "$user_id." . $now; $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); - // $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; + // $apiurl = 'https://erp.masada.com.tw:880/twWebAPI/GetAuth'; // $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; - $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; - // $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; + // $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; + $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; $headerParam = [ "UserId: $user_id", @@ -29,15 +31,21 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119") curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam); $response = curl_exec($ch); + echo $response; if ($response === false) { - echo 'Curl error: ' . curl_error($ch); + echo '123Curl error: ' . curl_error($ch); } else { // print_r($response); // exit; $result = json_decode($response, true); $validation = $result['Data']['CHI_Authorization']; + echo '
'; + print_r($result); + echo ''; return $validation; } curl_close($ch); } +// $data = []; +// get_Auth(); diff --git a/wms/account-receivable-excel.php b/wms/account-receivable-excel.php index 891156a6..58d53f1d 100644 --- a/wms/account-receivable-excel.php +++ b/wms/account-receivable-excel.php @@ -13,6 +13,7 @@ $Bill = json_decode(file_get_contents("php://input"), true); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); // file_put_contents('account-receivable.txt', json_encode($Bill)); +// file_put_contents('account-receivable.txt', json_encode($Bill)); if ($type == 'facility') { $colomnHeader = [ '作番號', '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', @@ -24,7 +25,7 @@ if ($type == 'facility') { '官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數', '交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已收金額', '交車款催收金額', '交車款催收次數', '尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已收金額', '尾款催收金額', '尾款催收次數', - '作番狀態', '合約-設備金額','合約-安裝金額','作番合約總金額', '作番總應收金額' + '作番狀態', '合約-設備金額', '合約-安裝金額', '作番合約總金額', '作番總應收金額' ]; $sheet->fromArray($colomnHeader, NULL, 'A1'); $rowIndex = 2; @@ -34,7 +35,7 @@ if ($type == 'facility') { $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', '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) { $sheet->getColumnDimension($col)->setAutoSize(true); @@ -48,26 +49,26 @@ if ($type == 'facility') { } else { $colomnHeader = [ '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', - '訂金', '訂金目前應收', '訂金已開票金額','訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數', - '二次款', '二次款目前應收', '二次款已開票金額','二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數', - '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額','貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數', - '安裝款', '安裝款目前應收', '安裝款已開票金額','安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數', - '試車款', '試車款目前應收', '試車款已開票金額','試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數', - '官檢款', '官檢款目前應收', '官檢款已開票金額','官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數', - '交車款', '交車款目前應收', '交車款已開票金額','交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數', - '尾款', '尾款目前應收', '尾款已開票金額','尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數', - '合約設備金額','合約安裝金額','合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態' + '訂金', '訂金目前應收', '訂金已開票金額', '訂金未開票金額', '訂金已收金額', '訂金催收金額', '訂金最大催收次數', '訂金最小催收次數', + '二次款', '二次款目前應收', '二次款已開票金額', '二次款未開票金額', '二次款已收金額', '二次款催收金額', '二次款最大催收次數', '二次款最小催收次數', + '貨抵工地款', '貨抵工地款目前應收', '貨抵工地款已開票金額', '貨抵工地款未開票金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款最大催收次數', '貨抵工地款最小催收次數', + '安裝款', '安裝款目前應收', '安裝款已開票金額', '安裝款未開票金額', '安裝款已收金額', '安裝款催收金額', '安裝款最大催收次數', '安裝款最小催收次數', + '試車款', '試車款目前應收', '試車款已開票金額', '試車款未開票金額', '試車款已收金額', '試車款催收金額', '試車款最大催收次數', '試車款最小催收次數', + '官檢款', '官檢款目前應收', '官檢款已開票金額', '官檢款未開票金額', '官檢款已收金額', '官檢款催收金額', '官檢款最大催收次數', '官檢款最小催收次數', + '交車款', '交車款目前應收', '交車款已開票金額', '交車款未開票金額', '交車款已收金額', '交車款催收金額', '交車款最大催收次數', '交車款最小催收次數', + '尾款', '尾款目前應收', '尾款已開票金額', '尾款未開票金額', '尾款已收金額', '尾款催收金額', '尾款最大催收次數', '尾款最小催收次數', + '合約設備金額', '合約安裝金額', '合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態' ]; $sheet->fromArray($colomnHeader, NULL, 'A1'); $rowIndex = 2; foreach ($Bill as $key => $value) { - $sheet->fromArray($value, NULL, 'A' . $rowIndex); + $sheet->fromArray($value, NULL, 'A' . $rowIndex, true); $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', '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', - 'CA','CB','CC' + 'CA', 'CB', 'CC' ]; foreach ($column as $col) { if ($col == 'CB') { diff --git a/wms/account-receivable-index-ing.php b/wms/account-receivable-index-ing.php index a3312ef3..c41dd958 100644 --- a/wms/account-receivable-index-ing.php +++ b/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 .= " WHERE salesid = '$user_id'"; $sql_contract_budget .= " AND (PersonId = '$user_id'"; + $sql_contract_budget .= " AND (PersonId = '$user_id'"; if (count($follower) > 0) { $column_str = "('$user_id'" . ",'"; $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 .= " 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)"; } else { $sql_contract .= ")"; // $sql_received .= ")"; $sql_opening .= ")"; $sql .= " ORDER BY contractno"; $sql_contract_budget .= ")"; + $sql_contract_budget .= ")"; }; } else { $sql .= " ORDER BY contractno"; $sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId"; + $sql_contract_budget .= "ORDER BY BillNo, CU_MaterialId"; } $contract = $conn->query($sql_contract); @@ -211,6 +215,7 @@ foreach ($contract as $cont) { $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_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天')) { $arrayData[$BillNo]['second'][0] = $PayStage; @@ -401,6 +406,7 @@ foreach ($wipwhole_array as $wip) { if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") { $facility_status = ""; array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']); + array_push($arrayData[$wip['contractno']]['total_list'], $wip['facilityno']); $today = strtotime(date('Ymd')); $contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]); $month = collect_month($contractday); @@ -409,6 +415,7 @@ foreach ($wipwhole_array as $wip) { if ($today > $contractday) { $arrayData[$wip['contractno']]['sign_num'] += 1; 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] . "已過)
'; + // print_r($sql_get); + // echo ''; + + $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" => "結案不同意"]; -#可編輯的列 -// $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], + foreach ($res_get as $key => $data) { + // 結案隱藏 + if ($data['flow_code'] !== 'Z') { + $test = $data['form_key']; + // $sql = "SELECT mid FROM pricereview_sign WHERE id = $test"; + // $result = mysqli_fetch_all(mysqli_query($link, $sql), MYSQLI_ASSOC); + // echo '
'; + // print_r($result); + // echo ''; + $id[] = $test; + } + } + $inClause = implode(',', $id); +} + -// ]; +#可編輯的列 +$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(); @@ -45,7 +88,7 @@ $res = mysqli_query($link, $sql); $row = mysqli_fetch_row($res); $user_department_id = $row[0]; 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 = []; @@ -55,32 +98,49 @@ while ($row = mysqli_fetch_row($res)) { $elevator_brand_arr[$row[0]] = $row[1]; } mysqli_free_result($res); - -$sql = "SELECT - apply_key, - vol_no, - address, -case_name, -brand , -num , -salesman as salesman_id, -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, -status, -f_return_content('payment_kind',payment_kind ) payment_kind FROM $table - where 1=1 $where ORDER BY vol_no"; +if (!empty($res_get)) { + $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 form_key IN ($inClause) "; +} else { + $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); // echo '
'; -// print_r($sql); +// print_r($data); // echo ''; - - ?> - - - - + echo "
評審單號 | -卷號 | -現場地址 | -現場名稱 | -電梯品牌 | -電梯台數 | -營業員 | -保養方式 | -契約期限開始 | -契約期限結束 | -契約性質 | -加盟公司名稱 | -加盟公司電話 | - -是否結案 | -合約下載 | -
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= $row['apply_key'] ?> | -- | - | - | - | - | - | - | - | - | - | - | + ?> - - | - |
-
-
-
-
- 待簽核 - - - -- - - - 下載 - - |
-
'; + // print_r($result); + // echo ''; + return $result; + } + } + + curl_close($ch); +} +// T8API($data); diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 15443309..3b00d2a9 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -327,7 +327,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c // $stmt->bindParam(':CreateTime', $createTime); // $stmt->execute(); - // T8insert($_POST, $facilityno); + T8insert($_POST, $facilityno); header('Content-Type: application/json'); $jsonData = json_encode($files); @@ -344,7 +344,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c function T8insert($data, $facilityno) { require_once("../connt8.php"); - // include "../../T8_Authorization.php"; + // 引入 T8 API 連線 + require_once("./T8salIncomeApply.php"); $contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號 $address = !empty($data['address']) ? $data['address'] : null; // 客戶地址 @@ -360,6 +361,7 @@ function T8insert($data, $facilityno) $num = !empty($data['num']) ? $data['num'] : null; // 電梯數量 $elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯 $area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。 + $payType = !empty($data['payType']) ? $data['payType'] : null; $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; @@ -372,7 +374,9 @@ function T8insert($data, $facilityno) $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $date = date('Y-m-sH-s-i'); + $date_1 = date('Y-m-s'); $createTime = str_replace("-", '', $date); + $insertTime = str_replace('-', '', $date_1); $beginDate = str_replace("-", '', $contract_begin_date); $endDate = str_replace("-", '', $contract_end_date); if ($contractno == '') { @@ -464,23 +468,25 @@ function T8insert($data, $facilityno) $type = 'C5'; } } - // echo '
'; - // print_r($type); - // echo ''; - - // //新增於 comProject。合約 table - $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed) - VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,:ValidityToDate,:CreateTime,:CreatorId,1)"; + $sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId"; $stmt = $connT8->prepare($sql); $stmt->bindParam(':ProjectId', $contractno); - $stmt->bindParam(':ProjectName', $customer); - $stmt->bindParam(':TypeId', $type); - $stmt->bindParam(':ValidityFromDate', $beginDate); - $stmt->bindParam(':ValidityToDate', $endDate); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->bindParam(':CreatorId', $user_id); $stmt->execute(); - + $resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (empty($resultProject)) { + //新增於 comProject。合約 table + $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed) + VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,:ValidityToDate,:CreateTime,:CreatorId,1)"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':ProjectId', $contractno); + $stmt->bindParam(':ProjectName', $customer); + $stmt->bindParam(':TypeId', $type); + $stmt->bindParam(':ValidityFromDate', $beginDate); + $stmt->bindParam(':ValidityToDate', $endDate); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->execute(); + } // // 新增電梯數 foreach ($elevators as $index => $elevator) { @@ -515,36 +521,76 @@ function T8insert($data, $facilityno) $stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreateTime', $createTime); $stmt->execute(); - } + // 分期代碼計算 + $IncomeId = [ + 'A40006' => 1, + 'A40007' => 4, + 'A40003' => 12, + 'A40004' => 6, + 'A40005' => 2 + ]; + //分幾期 => 總共保養月 / 分期月 + $SQuantity = $elevator['maintain_months'] / $IncomeId[$payType]; + + // 依每台電梯去加入各個的付款項 + for ($i = 1; $i <= $IncomeId[$payType]; $i++) { + $rows_data = [ + "BillNo" => "$contractno", + "IncomeId" => "$payType", + "TaxId" => "ST005", + "RowCode" => $i, + "RowNo" => $i, + "ItemType" => 1, + "SPrice" => $elevator['sold_price'], + "SQuantity" => $SQuantity, + "ProjectId" => "$contractno", + "FromSourceTag" => 0, + "CU_MaterialId" => "$facilityno[$index]" + ]; + $salIncomeApplyDetail_rows[] = $rows_data; + } + } -?> - -commit(); + + + // $insertime = settype($insertTime, 'integer'); + $salIncomeApplyMaster_rows = [ + "BillNo" => "$contractno", + "BillDate" => $insertTime, + "OrgId" => "1000", + "FOrgId" => "1000", + "TypeId" => "RAS", + "BpOrgId" => "1000", + "BizPartnerId" => "$contractno", + "CurrId" => "TWD", + "CurrOAmount" => 1, + "CurrLAmount" => 1, + "PersonId" => "$salesman", + "DtOrgId" => "1000", + "DueToId" => "$contractno", + "TaxId" => "ST005", + "CompId" => "1001", + "CreatorId" => "$user_id" + ]; + + $salIncomeApplyMaster = [ + 'name' => "salIncomeApplyMaster", + 'rows' => [$salIncomeApplyMaster_rows] + ]; + + $salIncomeApplyDetail = [ + 'name' => "salIncomeApplyDetail", + 'rows' => $salIncomeApplyDetail_rows + ]; + $API_body[] = $salIncomeApplyMaster; + $API_body[] = $salIncomeApplyDetail; + // 呼叫 API + $result = T8API($API_body); + + if ($result['Status'] == 'Error') { + http_response_code(404); + die('Error!:' . $result['ErrorMsg']); + } } diff --git a/wms/contract/api/test.json b/wms/contract/api/test.json new file mode 100644 index 00000000..04729705 --- /dev/null +++ b/wms/contract/api/test.json @@ -0,0 +1,186 @@ +[ + { + "name": "salIncomeApplyMaster", + "rows": [ + { + "BillNo": "B23100060", + "BillDate": "20240122", + "OrgId": "1000", + "FOrgId": "1000", + "TypeId": "RAS", + "BpOrgId": "1000", + "BizPartnerId": "B23100060", + "CurrId": "TWD", + "CurrOAmount": 1, + "CurrLAmount": 1, + "PersonId": "M0065", + "DtOrgId": "1000", + "DueToId": "B23100060", + "TaxId": "ST005", + "CompId": "1001", + "CreatorId": "M0225" + } + ] + }, + { + "name": "salIncomeApplyDetail", + "rows": [ + { + "BillNo": "B23100060", + "IncomeId": "A40003", + "TaxId": "ST005", + "RowCode": 1, + "RowNo": 1, + "ItemType": 1, + "SPrice": 1250, + "SQuantity": 1, + "ProjectId": "B23100060", + "FromSourceTag": 0, + "CU_MaterialId": "4TH53801" + }, + { + "BillNo": "B23100060", + "IncomeId": "A40003", + "TaxId": "ST005", + "RowCode": 2, + "RowNo": 2, + "ItemType": 1, + "SPrice": 1250, + "SQuantity": 1, + "ProjectId": "B23100060", + "FromSourceTag": 0, + "CU_MaterialId": "4TH53801" + }, + { + "BillNo": "B23100060", + "IncomeId": "A40003", + "TaxId": "ST005", + "RowCode": 3, + "RowNo": 3, + "ItemType": 1, + "SPrice": 1250, + "SQuantity": 1, + "ProjectId": "B23100060", + "FromSourceTag": 0, + "CU_MaterialId": "4TH53801" + }, + { + "BillNo": "B23100060", + "IncomeId": "A40003", + "TaxId": "ST005", + "RowCode": 4, + "RowNo": 4, + "ItemType": 1, + "SPrice": 1250, + "SQuantity": 1, + "ProjectId": "B23100060", + "FromSourceTag": 0, + "CU_MaterialId": "4TH53801" + }, + { + "BillNo": "B23100060", + "IncomeId": "A40003", + "TaxId": "ST005", + "RowCode": 5, + "RowNo": 5, + "ItemType": 1, + "SPrice": 1250, + "SQuantity": 1, + "ProjectId": "B23100060", + "FromSourceTag": 0, + "CU_MaterialId": "4TH53801" + }, + { + "BillNo": "B23100060", + "IncomeId": "A40003", + "TaxId": "ST005", + "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, + "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" + } + ] + } +] \ No newline at end of file diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index 7ca38a2f..39354c9b 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -1,77 +1,86 @@ +require_once('../../T8_Authorization_from_bpm.php'); +require_once('../connt8.php'); +$sql = "SELECT * FROM salIncomeApplyMaster WHERE BillNo = '3TX10701' "; +$stmt = $connT8->prepare($sql); +$stmt->execute(); +$result = $stmt->fetchAll(PDO::FETCH_ASSOC); +echo '
'; +print_r($result); +echo ''; +// $date = date("Y-m-d"); +// $date1 = str_replace('-', '', $date); - - \ No newline at end of file +// echo '
'; +// print_r($arr); +// echo ''; +// $validation = get_Auth(); +// $data = [ +// [ +// "name" => "OtherStockOutMtable", +// "rows" => [ +// [ +// "BillNo" => "00850110", // 單據編號 varchar(20) +// "BillDate" => 20210427, // 單據日期 int +// "OrgId" => "1000", //組織 varchar(20) +// "FOrgId" => "1000", //核算組織 varchar(20) +// "TypeId" => "OS", //單據類型 varchar(10) +// "BizPartnerId" => "", //往來對象(供應商) 可為空 +// "PersonId" => "C0003", // 經辦人員 varchar(20) +// "DeptId" => "250", // 經辦部門 varchar(20) +// "CompId" => "1001" // 公司 varchar(20) +// ] +// ] +// ], [ +// "name" => "OtherStockOutDetail", +// "rows" => [ +// [ +// "BillNo" => "00850110", //單據編號 varchar(20) +// "RowCode" => 1, // 序號 int(10) +// "MaterialId" => "MX00021003", // 產品代碼 -> 產品集成 varchar(40) +// "SupplyOrgId" => "1000", // 供貨組織代碼 varchar(20) +// "SQuantity" => 1, // 交易數量 numeric(19) +// "WarehouseId" => "100" // 倉庫代碼 varchar(20) +// ] +// ] +// ] +// ]; +// $data = file_get_contents('test.json'); +// echo '
'; +// print_r($data); +// echo ''; +// $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKOTHERSTOCKOUT/PostERPData'; +// $header = [ +// "CHI_Authorization :" . $validation +// ]; +// $ch = curl_init(); +// curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL +// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); +// curl_setopt($ch, CURLOPT_HTTPHEADER, $header); +// curl_setopt($ch, CURLOPT_POST, 1); +// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); + +// $response = curl_exec($ch); +// if ($response === false) { +// echo 'Curl error: ' . curl_error($ch); +// } else { +// $result = json_decode($response, true); +// if ($result['Status'] == 'Error') { +// echo '
'; +// print_r($result); +// echo ''; +// echo 'API 傳入錯誤,' . $result['ErrorMsg']; +// } else { +// echo '
'; +// print_r($result['Status']); +// echo ''; +// return $result; +// } +// } + +// curl_close($ch); diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index 2f526c2f..9837868d 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -964,7 +964,7 @@ const contractInput = () => { num: '', //電梯數量 disabled: false, //資料庫是否有電梯數量資料 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 - payType: '' + payType: '' //付款方式 }, customize: false, step: 1, @@ -1037,7 +1037,7 @@ const contractInput = () => { this.data.disabled = (res.data.num > 0) ? true : false; this.data.elevators = res.data.elevators let cityIndex = this.data.address.indexOf('市'); - console.log(cityIndex); + // console.log(cityIndex); if (cityIndex == -1) { // cityIndex = this.data.address.indexOf('縣'); } @@ -1122,7 +1122,7 @@ const contractInput = () => { form.append('files[]', this.data.files[i]); } axios.post('./api/postContractData.php', form).then(res => { - console.log(res); + // console.log(res); if (res.status === 200) { alert('儲存成功'); this.step = 1 diff --git a/wms/frame/api_getdata.php b/wms/frame/api_getdata.php index 20d779e5..c19b8758 100644 --- a/wms/frame/api_getdata.php +++ b/wms/frame/api_getdata.php @@ -166,6 +166,7 @@ function get_pending($token) $res = mysqli_query($link, $sql); while ($row = mysqli_fetch_row($res)) { + // print_r($row); $data[$i]["sid"] = $row[0]; $data[$i]["sname"] = $row[1]; $data[$i]["fid"] = $row[2]; diff --git a/wms/frame/pending.php b/wms/frame/pending.php index dc552e06..c98d40df 100644 --- a/wms/frame/pending.php +++ b/wms/frame/pending.php @@ -1,110 +1,136 @@ - - - - - - -
";
elseif ($ustatus == "N") $str = "";
$str .= " " . $accountname_arr[$uperson] . " " . $udtte; } else { - if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 3) && (in_array($user_id, $ss_arr["sign_nt"]))) { + // if ($user_id == 'test03') { + + if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 3) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST03') { $str = ""; $str = "待簽核"; $str = "" . $str . ""; @@ -435,7 +500,7 @@ if ($data) : elseif ($ustatus == "N") $str = ""; $str .= " " . $accountname_arr[$uperson] . " " . $udtte; } else { - if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 4) && (in_array($user_id, $ss_arr["sign_nt"]))) { + if (($data["status"] == "YS") && ($ss_arr["sign_st"] == 4) && (in_array($user_id, $ss_arr["sign_nt"])) || $user_id == 'TEST05') { $str = ""; $str = "待簽核"; $str = "" . $str . ""; diff --git a/wms/mkt/pricereview-record-check.php b/wms/mkt/pricereview-record-check.php index 094273da..5f27183e 100644 --- a/wms/mkt/pricereview-record-check.php +++ b/wms/mkt/pricereview-record-check.php @@ -25,21 +25,25 @@ if (isset($_POST['status'])) { if ($st == 1) { $sql = "sign1 = '$checker,$status,$check_date', sign1_note = '$sign_note'"; } elseif ($st == 2) { - if ($sign_now > 1) { - echo ""; - exit; - } - $sign2_ori_arr = explode("<##>", $sign2_ori); - $sign2_upd_arr = []; - foreach ($sign2_ori_arr as $k => $v) { - list($a, $b, $c) = explode(",", $v); - if ($a == $checker) $sign2_upd_arr[$k] = $checker.",".$status.",".$check_date; - else $sign2_upd_arr[$k] = $v; + if ($user_id == 'TEST02') { + $sql = "sign2 = '$checker,$status,$check_date', sign2_note = '$sign_note'"; + } else { + if ($sign_now > 1) { + echo ""; + exit; + } + $sign2_ori_arr = explode("<##>", $sign2_ori); + $sign2_upd_arr = []; + foreach ($sign2_ori_arr as $k => $v) { + list($a, $b, $c) = explode(",", $v); + if ($a == $checker) $sign2_upd_arr[$k] = $checker . "," . $status . "," . $check_date; + else $sign2_upd_arr[$k] = $v; + } + $sql = "sign2 = '" . implode("<##>", $sign2_upd_arr) . "', sign2_note = '$sign_note'"; } - $sql = "sign2 = '".implode("<##>", $sign2_upd_arr)."', sign2_note = '$sign_note'"; } elseif ($st == 3) { $sql = "sign3 = '$checker,$status,$check_date', sign3_note = '$sign_note'"; } else { @@ -48,7 +52,7 @@ if (isset($_POST['status'])) { if ($status == "N") { $sql2 .= "status = 'YN'"; $end_flow = 1; - } elseif ($sign_total == ($sign_now+1)) { + } elseif ($sign_total == ($sign_now + 1)) { if ($user_id == "M0006") { $final_price_total = str_replace(",", "", $final_price_total); if ($final_price_total > 0) { @@ -60,11 +64,10 @@ if (isset($_POST['status'])) { $sql2 .= "status = 'YY'"; } $end_flow = 1; - }elseif($status == 'YY'){ + } elseif ($status == 'YY') { $sql2 .= "status = 'YY'"; $end_flow = 1; - } - else { + } else { $do_assign = 1; } if ($item_no_all) { @@ -106,9 +109,9 @@ if (isset($_POST['status'])) { $next_signer[] = substr($v, 0, 5); } } elseif (strlen($row[1]) == 8) { - $next_signer = substr(str_replace(",","",$row[1]), 1); + $next_signer = substr(str_replace(",", "", $row[1]), 1); } elseif (strlen($row[2]) == 8) { - $next_signer = substr(str_replace(",","",$row[2]), 1); + $next_signer = substr(str_replace(",", "", $row[2]), 1); } do_assign("prm01", $id, $contractno_h, $next_signer, $st); @@ -117,11 +120,11 @@ if (isset($_POST['status'])) { $ret = accountid2email($next_signer); if (!empty($ret)) { foreach ($ret as $uid => $uemail) { - $mail_list[] = [$uid, $uemail]; + $mail_list[] = [$uid, $uemail]; } - include dirname(__DIR__)."/class/Cmail.php"; + include dirname(__DIR__) . "/class/Cmail.php"; $sendmail = new Cmail; - $title = "【新梯價審通知】卷號:".$contractno_h; + $title = "【新梯價審通知】卷號:" . $contractno_h; $content = " 您有待簽核案件,請至客戶管理 > 價格審查_新梯,點擊「待簽核」進行作業,謝謝! "; //print_r($mail_list); $sendmail->sendx($title, $content, $mail_list); @@ -131,13 +134,13 @@ if (isset($_POST['status'])) { end_flow("prm", "prm01", $id, $contractno_h); } } - + mysqli_close($link); echo ""; } diff --git a/wms/mkt/pricereview_mi-api.php b/wms/mkt/pricereview_mi-api.php index 6df7af5b..a25b920a 100644 --- a/wms/mkt/pricereview_mi-api.php +++ b/wms/mkt/pricereview_mi-api.php @@ -1,4 +1,5 @@ 'ok', 'err' => ''); 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) { $$k = htmlspecialchars(stripslashes(trim($v))); } @@ -33,17 +35,19 @@ try { if (strpos($pa, ",")) list($id, $opt) = explode(",", $pa); else $id = $pa; - $person2weight_arr = [ "6" => "450", - "8" => "550", - "9" => "600", - "10" => "700", - "11" => "750", - "12" => "800", - "13" => "900", - "15" => "1000", - "17" => "1150", - "20" => "1350", - "24" => "1600"]; + $person2weight_arr = [ + "6" => "450", + "8" => "550", + "9" => "600", + "10" => "700", + "11" => "750", + "12" => "800", + "13" => "900", + "15" => "1000", + "17" => "1150", + "20" => "1350", + "24" => "1600" + ]; $elev_arr = $elev_opt_arr = $pv_arr = $opt_elev_arr = $mi_arr = []; $i = $weight = $elev_qty_all = 0; @@ -84,7 +88,7 @@ try { $special_fee = $row[0]; mysqli_free_result($res); $specarr[0] = "服務費"; - $specarr[1] = round($special_fee/$elev_qty_all, 0); + $specarr[1] = round($special_fee / $elev_qty_all, 0); // 電梯所屬OPTION $opt_sel_id_arr = []; @@ -102,7 +106,7 @@ try { $opt_sel_id_arr[] = $row[0]; } } - + /* $pv_arr["price_id"] = $row[1]; $pv_arr["item_spec"] = $row[2]; @@ -114,7 +118,6 @@ try { $elev_opt_arr[$v][] = $pv_arr; } */ - } mysqli_free_result($res); $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); while ($row = mysqli_fetch_row($res)) { $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]; $j++; } @@ -155,57 +158,57 @@ try { $sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'"; $res_i = mysqli_query($link, $sql3); 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 ($row_i[note] between min_floors and max_floors) "; $res_d = mysqli_query($link, $sql4); 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"]; - $polishing_amt += 3000*$row_i["note"]; + $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"]; } mysqli_free_result($res_d); } mysqli_free_result($res_i); } - $dismantle_fee = round($dismantle_amt/$elev_qty_all, 0); - $polishing_fee = round($polishing_amt/$elev_qty_all, 0); + $dismantle_fee = round($dismantle_amt / $elev_qty_all, 0); + $polishing_fee = round($polishing_amt / $elev_qty_all, 0); //print_r($elev_arr); //print_r($opt_elev_arr); //print_r($opt_nosel_id_arr); //print_r($mn_elev_arr); //print_r($ex_arr);exit; - + foreach ($elev_arr as $item_no => $v) { // 電梯MI $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[floors] between o.min_floors and o.max_floors) "; $sql2 .= "and ($v[speed] between o.min_speed and o.max_speed) "; 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); if ($row_e = mysqli_fetch_assoc($res_e)) { // 加價:先不納入 $row_e["option_price"] = 0; // 基准采购成本+±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 = $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"]); // 安裝 @@ -261,25 +264,26 @@ try { $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 .= "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 ($v[item_weight] between o.min_weight and o.max_weight) and o.open_kind = '".$v["item_op"]."'"; + $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"] . "'"; + $res_om = mysqli_query($link, $sql4); if ($row_om = mysqli_fetch_assoc($res_om)) { $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"] == "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的電梯總台數 $myelev_qty = 0; foreach ($opt_elev_arr[$val]["elev_no"] as $pval) { $myelev_qty += $elev_arr[$pval]["item_qty"]; } // 分配: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總金額 - + $oparr[$j][1] = $option_amt; } else { $oparr[$j][1] = 0; @@ -301,8 +305,8 @@ try { $myelev_qty += $elev_arr[$pval]["item_qty"]; } // 分配:延保總價除以電梯總台數 - $mn_amt += round(0+($mn_elev_arr[$val]["item_price_bp"]/$myelev_qty), 0); - $mnarr[$j][0] = $mn_elev_arr[$val]["item_spec"]."保養費"; + $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][1] = $mn_amt; $mn_fee += $mn_amt; $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][1] = $row_e["purchase_cost"]; @@ -348,23 +352,23 @@ try { $mi_arr[$i][5] = $profit_amt; $mi_arr[$i][6] = $quotation; */ - $mi_arr[$i][1] = 0+$equipment_ntd; - $mi_arr[$i][2] = 0+$customs; - $mi_arr[$i][3] = 0+$row_e["unloading"]; - $mi_arr[$i][4] = 0+$row_e["transport_site"]; - $mi_arr[$i][5] = 0+$install_price; - $mi_arr[$i][6] = 0+$row_e["free1y"]; - $mi_arr[$i][7] = 0+$woods; + $mi_arr[$i][1] = 0 + $equipment_ntd; + $mi_arr[$i][2] = 0 + $customs; + $mi_arr[$i][3] = 0 + $row_e["unloading"]; + $mi_arr[$i][4] = 0 + $row_e["transport_site"]; + $mi_arr[$i][5] = 0 + $install_price; + $mi_arr[$i][6] = 0 + $row_e["free1y"]; + $mi_arr[$i][7] = 0 + $woods; $mi_arr[$i][8] = $row_e["equipment"]; - $mi_arr[$i][9] = 0+$row_e["option_price"]; - $mi_arr[$i][10] = 0+$dismantle_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][13] = $option_fee+$ex_fee+$mn_fee+$special_fee; + $mi_arr[$i][9] = 0 + $row_e["option_price"]; + $mi_arr[$i][10] = 0 + $dismantle_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][13] = $option_fee + $ex_fee + $mn_fee + $special_fee; $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][17] = 0+$mn_fee; + $mi_arr[$i][17] = 0 + $mn_fee; $mi_arr[$i][18] = $mnarr; $mi_arr[$i][19] = $specarr; $i++; @@ -374,11 +378,10 @@ try { } $rarr["content"] = $mi_arr; -}catch(\Exception $e) { +} catch (\Exception $e) { $rarr['st'] = 'err'; $rarr['err'] = $e->getMessage(); } echo json_encode($rarr, JSON_UNESCAPED_UNICODE); exit; -?> \ No newline at end of file diff --git a/wms/mkt/pricereview_renovate-index.php b/wms/mkt/pricereview_renovate-index.php index 5cbdb6ac..b25e5f4f 100644 --- a/wms/mkt/pricereview_renovate-index.php +++ b/wms/mkt/pricereview_renovate-index.php @@ -6,6 +6,56 @@ $accountname_arr = accountid2name(); $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 ''; + // print_r($sql_get); + // echo ''; + 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 ' '; + // print_r($result); + // echo ''; + $id[] = $test; + } + } + + + $inClause = implode(',', $id); +} + + + + // 設置一個空陣列來放資料 $data = array(); // sql語法存在變數中 @@ -17,12 +67,18 @@ if ($user_id == "M0024" || $user_id == "M0107" || $user_id == "M0012" || $user_i if ($user_id == "M0008") { $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") { // $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"; else $sql = "select * from pricereview_main $sql_cmd and status like 'Y%' and ekind = '汰改' order by id"; - +// echo ' '; +// print_r($sql); +// echo ''; $data = mysqli_query($link, $sql); diff --git a/wms/schedule-index.php b/wms/schedule-index.php index f518ea14..d4cb5a0c 100644 --- a/wms/schedule-index.php +++ b/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 desc"; +$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc"; if (!$page_close) $sql .= " limit $page_from, $page_each"; //echo $sql; diff --git a/wms/sign/list.php b/wms/sign/list.php index 16d1966b..7b4ab5b0 100644 --- a/wms/sign/list.php +++ b/wms/sign/list.php @@ -73,32 +73,27 @@ $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 - 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 +$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 + and b.flow_id NOT IN ('wws04') $where_system_id $where_flow_id -"; -//echo $sql_get; + "; +// echo ' '; +// print_r($sql_get); +// echo ''; + +$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); $system_name_opt = array_map(function ($item) { |