diff --git a/prv/pricereview-record-submit.php b/prv/pricereview-record-submit.php index f86c6126..aa7b13e4 100644 --- a/prv/pricereview-record-submit.php +++ b/prv/pricereview-record-submit.php @@ -1,58 +1,60 @@ - $v) { - $$k = htmlspecialchars(stripslashes(trim($v))); - } - - $maintance_contract_id=$_POST['maintance_contract_id']; - $sitename=$_POST['sitename']; - $contractor=$_POST['contractor']; - $contractsnum=$_POST['contractsnum']; - $siteaddress=$_POST['siteaddress']; - $startdate=$_POST['startdate']; - $enddate=$_POST['enddate']; - $contractsigningperiod=$startdate.'_'.$enddate; - $pricereviewer=$_POST['pricereviewer']; - $contracttype=$_POST['contracttype']; - $Maintenanceoperationcategory=$_POST['Maintenanceoperationcategory']; - $contractsigningnature=$_POST['contractsigningnature']; - $contractsignname=$_POST['contractsignname']; - - $servicefee=$_POST['servicefee']; - $managebili=$_POST['managebili']; - - $creater = $_POST['creater']; - $create_at = date('Y/m/d H:i:s'); - $updatee_at=date('Y/m/d H:i:s'); - - $db_query = "insert into maintance_contract_info(maintance_contract_id,sitename,contractor,contractsnum,siteaddress"; - $db_query .= ",contractsigningperiod,pricereviewer,contracttype,Maintenanceoperationcategory,contractsigningnature,contractsignname"; - $db_query .= ",creater,create_at,updatee_at,servicefee,managebili) values ("; - $db_query .= "'$maintance_contract_id', '$sitename', '$contractor', '$contractsnum', '$siteaddress', '$contractsigningperiod',"; - $db_query .= "'$pricereviewer', '$contracttype', '$Maintenanceoperationcategory', '$contractsigningnature','$contractsignname',"; - $db_query .= "'$creater', '$create_at', '$updatee_at','$servicefee','$managebili')"; - - $result = mysqli_query($link, $db_query); - if ($mid = mysqli_insert_id($link)) { - header("Location: pricereview-index.php?account=".$_POST['account']); - if (mysqli_affected_rows($link) > 0) { - echo ""; - //header("Location: pricereview-index.php"); - } else { - echo ""; - } - } else { - echo ""; - } - - mysqli_close($link); -} + + + $v) { + $$k = htmlspecialchars(stripslashes(trim($v))); + } + + $maintance_contract_id = $_POST['maintance_contract_id']; + $sitename = $_POST['sitename']; + $contractor = $_POST['contractor']; + $contractsnum = $_POST['contractsnum']; + $siteaddress = $_POST['siteaddress']; + $startdate = $_POST['startdate']; + $enddate = $_POST['enddate']; + $contractsigningperiod = $startdate . '_' . $enddate; + $pricereviewer = $_POST['pricereviewer']; + $contracttype = $_POST['contracttype']; + $Maintenanceoperationcategory = $_POST['Maintenanceoperationcategory']; + $contractsigningnature = $_POST['contractsigningnature']; + $contractsignname = $_POST['contractsignname']; + + $servicefee = $_POST['servicefee']; + $managebili = $_POST['managebili']; + + $creater = $_POST['creater']; + $create_at = date('Y/m/d H:i:s'); + $updatee_at = date('Y/m/d H:i:s'); + + $db_query = "insert into maintance_contract_info(maintance_contract_id,sitename,contractor,contractsnum,siteaddress"; + $db_query .= ",contractsigningperiod,pricereviewer,contracttype,Maintenanceoperationcategory,contractsigningnature,contractsignname"; + $db_query .= ",creater,create_at,updatee_at,servicefee,managebili) values ("; + $db_query .= "'$maintance_contract_id', '$sitename', '$contractor', '$contractsnum', '$siteaddress', '$contractsigningperiod',"; + $db_query .= "'$pricereviewer', '$contracttype', '$Maintenanceoperationcategory', '$contractsigningnature','$contractsignname',"; + $db_query .= "'$creater', '$create_at', '$updatee_at','$servicefee','$managebili')"; + + $result = mysqli_query($link, $db_query); + if ($mid = mysqli_insert_id($link)) { + header("Location: pricereview-index.php?account=" . $_POST['account']); + if (mysqli_affected_rows($link) > 0) { + echo ""; + //header("Location: pricereview-index.php"); + } else { + echo ""; + } + } else { + echo ""; + } + + mysqli_close($link); +} ?> \ No newline at end of file diff --git a/wms/T8_APItest.php b/wms/T8_APItest.php index 029c9bd2..e174719a 100644 --- a/wms/T8_APItest.php +++ b/wms/T8_APItest.php @@ -12,42 +12,42 @@ echo "ii"; console.log(validation); // var corsurl = 'http://cors-anywhere.herokuapp.com/'; - var apiurl = 'https:127.0.0.1:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; + var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; headerParam = { CHI_Authorization: `${validation}`, }; var body = [{ "name": "salIncomeApplyMaster", "rows": [{ - "BillNo": "Z001", - "BillDate": 20160811, + "BillNo": "B23100061", + "BillDate": 20231220, "OrgId": "1000", "FOrgId": "1000", - "TypeId": "RR", + "TypeId": "RAS", "BpOrgId": "1000", - "BizPartnerId": "C002", - "CurrId": "RMB", + "BizPartnerId": "B23100061", + "CurrId": "TWD", "CurrOAmount": 1, "CurrLAmount": 1, - "PersonId": "T001", + "PersonId": "M0065", "DtOrgId": "1000", - "DueToId": "C002", - "TaxId": "123", - "CompId": "1000" + "DueToId": "B23100061", + "TaxId": "ST005", + "CompId": "1001" }] }, { "name": "salIncomeApplyDetail", "rows": [{ - "BillNo": "Z001", - "IncomeId": "F203", - "TaxId": "ST003", + "BillNo": "B23100061", + "IncomeId": "A40003", + "TaxId": "ST005", "RowCode": 1, "ItemType": "1", - "SPrice": 50, - "SQuantity": 1, + "SPrice": 10000, + "SQuantity": 2, "FromSourceTag": 0, - "FromBillNo": "123" + "FromBillNo": "" }] } ]; @@ -56,9 +56,9 @@ echo "ii"; type: 'POST', // url: `${corsurl}${apiurl}`, url: `${apiurl}`, - // dataType: 'json', + dataType: 'json', headers: headerParam, - // data: json, + data: json, // dataType: "json", success: function(res) { console.log(res.Status); diff --git a/wms/contract-repair/api/putContractData.php b/wms/contract-repair/api/putContractData.php index cffa48a0..70f080ab 100644 --- a/wms/contract-repair/api/putContractData.php +++ b/wms/contract-repair/api/putContractData.php @@ -6,7 +6,7 @@ ini_set('date.timezone', 'Asia/Taipei'); if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_POST["id"]) && $_POST['id'] != "") { try { $create_date = date('Y-m-d H:i:s'); - $repair_no = !empty($POST['repair_no']) ? $_POST['repair_no'] : null; + $repair_no = !empty($_POST['repair_no']) ? $_POST['repair_no'] : null; $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; $company = !empty($_POST['company']) ? $_POST['company'] : null; $taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; @@ -21,7 +21,7 @@ if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_PO $fail_arr = []; // if (empty($repair_no)) $fail_arr[] = '號為必填'; - if (empty($contractno)) $fail_arr[] = '合約號為必填'; + // if (empty($contractno)) $fail_arr[] = '合約號為必填'; if (empty($company)) $fail_arr[] = '客戶名稱為必填'; if (empty($taxid)) $fail_arr[] = '統一編號為必填'; if (empty($facilityno)) $fail_arr[] = '電梯號為必填'; @@ -35,7 +35,7 @@ if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_PO echo json_encode($fail_arr); exit(); } - // $conn->beginTransaction(); + $conn->beginTransaction(); $sql = "UPDATE contract_r_signed_back SET repaireid = :repaireid,facilityno= :facilityno, invoice=:invoice, taxid=:taxid, address=:address,type=:type,contract_status=:contract_status,update_user=:update_user,update_date=:update_date @@ -56,135 +56,50 @@ if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_PO // echo json_encode($sql); // exit; $stmt->execute(); + t8Insert($_POST); // header("HTTP/1.1 204 NO Content"); - // $conn->commit(); + $conn->commit(); } catch (PDOException $e) { // $conn->rollback(); header("HTTPP/1.1 500 Internal Server Error"); die('Error!:' . $e->getMessage()); } } -// if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST["id"]) && $_POST['id'] != "") { -// try { -// $created_at = date('Y-m-d H:i:s'); -// $created_by = $_POST['user_id']; -// $id = $_POST["id"]; -// $contract_no = !empty($_POST['contractno']) ? $_POST['contractno'] : null; -// $customer = !empty($_POST['customer']) ? $_POST['customer'] : null; -// $manager = !empty($_POST['manager']) ? $_POST['manager'] : null; -// $vat = !empty($_POST['vat']) ? $_POST['vat'] : null; -// $case_name = !empty($_POST['case_name']) ? $_POST['case_name'] : null; -// $linkman = !empty($_POST['linkman']) ? $_POST['linkman'] : null; -// $lm_tel = !empty($_POST['lm_tel']) ? $_POST['lm_tel'] : null; -// $address = !empty($_POST['address']) ? $_POST['address'] : null; -// $salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null; -// $qc = !empty($_POST['qc']) ? $_POST['qc'] : null; -// $deletefiles = !empty($_POST['deletefiles']) ? $_POST['deletefiles'] : null; -// $files_id = !empty($_POST['files_id']) ? $_POST['files_id'] : null; -// $files = !empty($_FILES['files']) ? $_FILES['files'] : null; -// $deletefilesArr = explode(',', $_POST['deletefiles']); -// $fail_arr = []; -// if (empty($contract_no)) $fail_arr[] = '合約號為必填'; -// if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; -// if (empty($manager)) $fail_arr[] = '負責人為必填'; -// if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; -// if (empty($case_name)) $fail_arr[] = '案名為必填'; -// if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; -// if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; -// if (empty($address)) $fail_arr[] = '地址為必填'; -// if (empty($salesman)) $fail_arr[] = '營業員為必填'; -// if (empty($qc)) $fail_arr[] = '請選擇QC或管檢'; -// if (count($fail_arr) > 0) { -// header("HTTP/1.1 422 Unprocessable Entity"); -// echo json_encode($fail_arr); -// exit(); -// } +function t8Insert($data) +{ + require_once('../../contract/connt8.php'); + $create_date = date('Y-m-dH-i-s'); + $repair_no = !empty($data['repair_no']) ? $data['repair_no'] : null; // 報價單號 + $company = !empty($data['company']) ? $data['company'] : null; //立約人 + $repaireid = !empty($data['repaireid']) ? $data['repaireid'] : null; //維保人員 + $facilityno = !empty($data['facilityno']) ? $data['facilityno'] : null; // 電梯編號 + $type = !empty($data['type']) ? $data['type'] : null; //工程進度 + $sign_date = !empty($data['sign_date']) ? $data['sign_date'] : null; //簽訂時間 + $invoice = !empty($data['invoice']) ? $data['invoice'] : null; // 發票抬頭 + $taxid = !empty($data['taxid']) ? $data['taxid'] : null; //統編 + $address = !empty($data['address']) ? $data['address'] : null; //工程地址 + $contract_status = !empty($data['contract_status']) ? $data['contract_status'] : null; + $user_id = !empty($_data['user_id']) ? $data['user_id'] : null; -// $conn->beginTransaction(); + $sign = str_replace("-", '', $sign_date); + $create = str_replace('-', '', $create_date); -// $sql_str = "UPDATE contract_m_signed_back SET contract_no=:contract_no, customer=:customer, manager=:manager, vat=:vat, case_name=:case_name, linkman=:linkman, lm_tel=:lm_tel, address=:address, salesman=:salesman, qc_official_type=:qc WHERE id = :id"; -// $stmt = $conn->prepare($sql_str); -// $stmt->bindParam(':contract_no', $contract_no); -// $stmt->bindParam(':customer', $customer); -// $stmt->bindParam(':manager', $manager); -// $stmt->bindParam(':vat', $vat); -// $stmt->bindParam(':case_name', $case_name); -// $stmt->bindParam(':linkman', $linkman); -// $stmt->bindParam(':lm_tel', $lm_tel); -// $stmt->bindParam(':address', $address); -// $stmt->bindParam(':salesman', $salesman); -// $stmt->bindParam(':qc', $qc); -// $stmt->bindParam(':id', $id); -// $stmt->execute(); -// if (!empty($deletefiles)) { -// $sql_str = "DELETE FROM contract_back_files WHERE id IN ($deletefiles)"; -// $stmt = $conn->prepare($sql_str); -// $stmt->execute(); -// } + $sql = "INSERT INTO comBusinessPartner + (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,BizToDate,TaxNo,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId) + VALUES(:BizPartnerId,:BizPartnerName,1,'TW',99999999,:TaxNo,:ContactAddress,:CreatorId,:CreateTime,'10')"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerId', $repair_no); //報價單編號 + $stmt->bindParam(':BizPartnerName', $company); + $stmt->bindParam(':TaxNo', $taxid); + $stmt->bindParam(':ContactAddress', $address); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $create); + $stmt->execute(); -// if (!empty($files)) { -// $englisharr = range('a', 'z'); -// $files = $_FILES['files']; -// $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 = ''; //負責接收所有檔案檢測後的回傳訊息 -// $datetime = (string)date('YmdHis'); -// $files_id = ($files_id !== null) ? $files_id : 'm' . $datetime; // 新梯=>m + 日期時間 -// foreach ($newfiles as $key => $file) { -// $randNum = rand(1000, 9999); -// $randEnglish = $englisharr[rand(0, 25)]; -// $file_name = 'm' . (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', $created_by); -// $stmt->execute(); -// } else { -// throw new PDOException('檔案上傳失敗:' . $msg); -// } -// $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '
'; -// $src_name = $path . $file['name']; -// if (file_exists($src_name)) { -// //副檔名 -// $extname = pathinfo($src_name, PATHINFO_EXTENSION); -// //主檔名 -// $basename = basename($src_name, '.' . $extname); -// } -// } -// } else { -// $files = null; -// } -// $conn->commit(); -// } catch (PDOException $e) { -// $conn->rollback(); -// header("HTTP/1.1 500 Internal Server Error"); -// die('Error!:' . $e->getMessage()); -// } -// } + + $connT8->commit(); +} diff --git a/wms/contract-repair/js/alpine.js b/wms/contract-repair/js/alpine.js index 8ab51dfd..8877b11b 100644 --- a/wms/contract-repair/js/alpine.js +++ b/wms/contract-repair/js/alpine.js @@ -328,7 +328,7 @@ const contractRepair = () => { nextStepFn() { - if (this.data.contractno == '') return alert('合約號為必填') + if (this.data.repair_no == '') return alert('合約號為必填') this.isLoading = true if (this.step == 1) { this.getContractDate(); @@ -503,7 +503,7 @@ const contractInput = () => { fail_arr: [], nextStepFn() { if (this.step == 1) { - if (this.data.repair_no == '') return alert('請輸入合約號'); + if (this.data.contractno == '') return alert('請輸入合約號'); this.isLoading = true this.getContractDate(); } else if (this.step == 2) { diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 1789bfac..85b38f89 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -374,6 +374,7 @@ function T8insert($data, $facilityno) $endDate = str_replace("-", '', $contract_end_date); if ($contractno == '') { echo 'Error'; + exit; } if (empty($result)) { // 若 客戶資料為空,新增一筆到 comCustomer diff --git a/wms/fun_global.php b/wms/fun_global.php index 7da2f70c..c57b3a3d 100644 --- a/wms/fun_global.php +++ b/wms/fun_global.php @@ -86,7 +86,7 @@ function manage_class($user_id, &$ret = []) function pricereview_class($rate, $user_id, &$ret = [], $special_fee) { global $link; - + $sql = "select manager from account where accountid = '$user_id'"; $res = mysqli_query($link, $sql); while ($row = mysqli_fetch_assoc($res)) { @@ -97,9 +97,9 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee) } else { $ret[2] = "M0024,,<##>M0107,,"; // 業務部專員:M0024許伃廷、M0107許紓晴(第2關有多位審核人) $ret[3] = "M0060,,"; // 業務協理 - if ($rate < 80 || $special_fee > 0){ + if ($rate < 80 || $special_fee > 0) { $ret[4] = "M0006,,"; // 總經理 - } + } } } mysqli_free_result($res); @@ -129,13 +129,14 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag) } } mysqli_free_result($res); - + $ret[2] = 'M0012'; if ($renovate_flag == "REN") { - if ($rate < 80) $ret[3] = "M0008"; // 詹總 - if ($rate < 60) $ret[4] = "M0006"; // 總經理 + // $ret[2] = 'M0012'; + if ($rate < 1000) $ret[3] = "M0008"; // 詹總 + if ($rate < 75) $ret[4] = "M0006"; // 總經理 } else { // 全汰改 - if ($rate < 80) $ret[3] = "M0008"; // 詹總 + if ($rate < 1000) $ret[3] = "M0008"; // 詹總 if ($rate < 75) $ret[4] = "M0006"; // 總經理 } @@ -612,15 +613,14 @@ function collect_month($contractday) $latest_timestamp = $contractday; $latest_date = new DateTime(); $latest_date->setTimestamp($latest_timestamp); - if($latest_timestamp < $today_date->getTimestamp()) { + if ($latest_timestamp < $today_date->getTimestamp()) { $interval = $latest_date->diff($today_date); $interval2 = $latest_date->diff($today_date); $year = $interval2->format('%y'); $month = $interval->format('%m'); $total_month = $year * 12 + $month; return $total_month; - }else{ + } else { return 0; } - } diff --git a/wms/mkt/pricereview-index.php b/wms/mkt/pricereview-index.php index 20ab2b61..662b9a05 100644 --- a/wms/mkt/pricereview-index.php +++ b/wms/mkt/pricereview-index.php @@ -246,6 +246,10 @@ if ($data) : } elseif ($data["status"] == "YS") { ?> 填規調 + + 重填規調 - - + + 待申請 - + - -
+ +
- + diff --git a/wms/mkt/pricereview-record-submit.php b/wms/mkt/pricereview-record-submit.php index 6d8fb233..1772ae02 100644 --- a/wms/mkt/pricereview-record-submit.php +++ b/wms/mkt/pricereview-record-submit.php @@ -1,6 +1,7 @@ $v) { $$k = htmlspecialchars(stripslashes(trim($v))); } @@ -67,9 +68,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $temp_file_name = $_FILES["attatch1"]["tmp_name"]; $file_size = $_FILES["attatch1"]["size"]; $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); - $target_file1 = $target_dir.$vol_no."-price-".$tds.".".$img_file_type; + $target_file1 = $target_dir . $vol_no . "-price-" . $tds . "." . $img_file_type; $upload_ok = 1; - foreach (glob($target_dir.$vol_no."-price-*") as $todelfile) { + foreach (glob($target_dir . $vol_no . "-price-*") as $todelfile) { unlink($todelfile); } $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); @@ -81,9 +82,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $temp_file_name = $_FILES["attatch2"]["tmp_name"]; $file_size = $_FILES["attatch2"]["size"]; $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); - $target_file2 = $target_dir.$vol_no."-appendix-".$tds.".".$img_file_type; + $target_file2 = $target_dir . $vol_no . "-appendix-" . $tds . "." . $img_file_type; $upload_ok = 1; - foreach (glob($target_dir.$vol_no."-appendix-*") as $todelfile) { + foreach (glob($target_dir . $vol_no . "-appendix-*") as $todelfile) { unlink($todelfile); } $upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); @@ -156,7 +157,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { */ $item_no = 1; - for ($i=0; $i", $option_relate_facil_arr[$i]); foreach ($tmp_arr as $val) { - $option_relate_spec .= substr($val, 0, strpos($val, ".")).","; + $option_relate_spec .= substr($val, 0, strpos($val, ".")) . ","; } $option_relate_spec = rtrim($option_relate_spec, ","); /* @@ -226,16 +227,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $mn_memo_arr = explode("@@,", rtrim($mn_memo_all, "@@")); $mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all)); $item_no = 1; - for ($i=0; $i", $mn_relate_facil_arr[$i]); foreach ($tmp_arr as $val) { - $option_relate_spec .= substr($val, 0, strpos($val, ".")).","; + $option_relate_spec .= substr($val, 0, strpos($val, ".")) . ","; } $option_relate_spec = rtrim($option_relate_spec, ","); $db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note, memo) values ("; @@ -253,7 +254,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $except_qty_arr = explode(",", $except_qty_all); $except_price_bp_arr = explode(",", $except_price_bp_all); $item_no = 1; - for ($i=0; $i $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; + $title = "【新梯價審通知】卷號:" . $contractno; $content = "

您有待簽核案件,請至客戶管理 > 價格審查_新梯,點擊「待簽核」進行作業,謝謝!

"; $sendmail->sendx($title, $content, $mail_list); } @@ -324,14 +325,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { mysqli_close($link); if ($affected > 0) { echo ""; } else { echo ""; } } -?> \ No newline at end of file diff --git a/wms/mkt/pricereview_renovate-check.php b/wms/mkt/pricereview_renovate-check.php index 0fde252d..299b3bd9 100644 --- a/wms/mkt/pricereview_renovate-check.php +++ b/wms/mkt/pricereview_renovate-check.php @@ -1,1101 +1,1122 @@ -"; - echo "alert('資料錯誤!!');"; - echo "window.history.go(-1);"; - echo ""; - exit; - } -} - -// 員工編號對應姓名表 -$accountname_arr = accountid2name(); - -// 審核按鈕開關 -$sign_on = 0; - -$data = $item_arr = $option_arr = $mn_arr = $ex_arr = $demolition_arr = $pay_arr = array(); -$checker_1_result = $checker_2_result = $checker_3_result = $checker_4_result = ""; -$db_query = "select * from pricereview_main where id = '$id'"; -/* -if ($res = mysqli_query($link, $db_query)) { - while ($row = mysqli_fetch_row($res)) { - list($id, $version, $company) - } -} -*/ -$res = mysqli_query($link, $db_query); -foreach ($res as $data) { - // 上層主管 - $sql = "select manager from account where accountid = '".$data["person"]."'"; - $res_a = mysqli_query($link, $sql); - $row_a = mysqli_fetch_row($res_a); - $manager = $row_a[0]; - mysqli_free_result($res_a); - // 瀏覽MI權限 - $depart_id = accountidToDepartId($user_id); - if ($depart_id == "320" || $depart_id == "321" || $depart_id == "20" || $user_id == "M0008") $viewmi = 1; - else $viewmi = 0; - - $sql = "select * from pricereview_sign where mid = '$id'"; - $res_s = mysqli_query($link, $sql); - $row_s = mysqli_fetch_assoc($res_s); - mysqli_free_result($res_s); - if (!empty($row_s["sign1"])) list($person1, $status1, $dtte1) = explode(",", $row_s["sign1"]); - else $person1 = $status1 = $dtte1 = ""; - if (!empty($row_s["sign2"])) { - if ($st == 2 && (preg_match("/Y/", $row_s["sign2"]) || preg_match("/N/", $row_s["sign2"]))) { - echo ""; - exit; - } - $sign2_arr = explode("<##>", $row_s["sign2"]); // M0024,,<##>M0175,, - $person2_arr = []; - foreach ($sign2_arr as $v) { - list($person2, $status2, $dtte2) = explode(",", $v); - if (strlen($v) == 7) { // 未審 - $person2_arr[] = $person2; - } else { - unset($person2_arr); - break; - } - } - } else $person2 = $status2 = $dtte2 = ""; - if (!empty($row_s["sign3"])) list($person3, $status3, $dtte3) = explode(",", $row_s["sign3"]); - else $person3 = $status3 = $dtte3 = ""; - if (!empty($row_s["sign4"])) list($person4, $status4, $dtte4) = explode(",", $row_s["sign4"]); - else $person4 = $status4 = $dtte4 = ""; - $sign1_note = (empty($row_s["sign1_note"])) ? "" : $row_s["sign1_note"]; - $sign2_note = (empty($row_s["sign2_note"])) ? "" : $row_s["sign2_note"]; - $sign3_note = (empty($row_s["sign3_note"])) ? "" : $row_s["sign3_note"]; - $sign4_note = (empty($row_s["sign4_note"])) ? "" : $row_s["sign4_note"]; - if ($status1 == "Y") { - $checker_1_result = "同意"; - } elseif ($status1 == "N") { - $checker_1_result = "不同意"; - } - if ($status2 == "Y") { - $checker_2_result = "同意"; - } elseif ($status2 == "N") { - $checker_2_result = "不同意"; - } - if ($status3 == "Y") { - $checker_3_result = "同意"; - } elseif ($status3 == "N") { - $checker_3_result = "不同意"; - } - if ($status4 == "Y") { - $checker_4_result = "同意"; - } elseif ($status4 == "N") { - $checker_4_result = "不同意"; - } - if ($st == 1 && ($person1 == $user_id) && ($status1 == "")) { - $sign_on = 1; - } - if ($st == 2 && ($person2 == $user_id || (isset($person2_arr) && in_array($user_id, $person2_arr))) && ($status2 == "")) { - $sign_on = 1; - } - if ($st == 3 && ($person3 == $user_id) && ($status3 == "")) { - $sign_on = 1; - } - if ($st == 4 && ($person4 == $user_id) && ($status4 == "")) { - $sign_on = 1; - } - // $sign_total=關卡數 - if ($person4 == "") { - if ($person3 == "") { - $sign_total = 1; - } else { - $sign_total = 2; - } - } else { - $sign_total = 3; - } - /* - if (!$data["checker_1"] && !$data["checker_2"] && !$data["checker_3"]) $allow_st = 1; - else if (!$data["checker_2"] && !$data["checker_3"]) $allow_st = 2; - else if (!$data["checker_3"]) $allow_st = 3; - if ($data["checker_1_result"]) { - if ($data["checker_1_result"] == "Y") $checker_1_result = "通過"; - else if ($data["checker_1_result"] == "N") { - $stopchk = 1; - $checker_1_result = "拒絕"; - } - } - if ($data["checker_2_result"]) { - if ($data["checker_2_result"] == "Y") $checker_2_result = "通過"; - else if ($data["checker_2_result"] == "N") { - $stopchk = 1; - $checker_2_result = "拒絕"; - } - } - if ($data["checker_3_result"]) { - if ($data["checker_3_result"] == "Y") $checker_3_result = "通過"; - else if ($data["checker_3_result"] == "N") { - $stopchk = 1; - $checker_3_result = "拒絕"; - } - } - */ - - /* - if ($st != $allow_st) { - mysqli_free_result($res); - mysqli_close($link); - echo ""; - } - */ - $mid = $data["id"]; - $data["qty_total"] = 0; - $db_query = "select * from pricereview_item where mid = '$mid' order by item_group, item_no"; - $res_i = mysqli_query($link, $db_query); - while ($row = mysqli_fetch_assoc($res_i)) { - if ($row['item_group'] == "A") { - $item_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $item_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $item_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $item_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $item_arr[$row['item_no']]['item_price_ct'] = $row['item_price_ct']; - $item_arr[$row['item_no']]['item_price'] = $row['item_price']; - $item_arr[$row['item_no']]['pv_rate'] = $row['pv_rate']; - $item_arr[$row['item_no']]['allocate'] = $row['allocate']; - $item_arr[$row['item_no']]['gross_profit'] = $row['gross_profit']; - $item_arr[$row['item_no']]['gross_profit_rate'] = $row['gross_profit_rate']; - $item_arr[$row['item_no']]['note'] = $row['note']; - $item_arr[$row['item_no']]['mi_fix'] = $row['mi_fix']; - $data["qty_total"] += $row["item_qty"]; - $sql_spec = "select sub_item_id from specsurvey_main where mid = '$mid' and pr_item_id = '".$row['item_no']."' order by sub_item_id"; - $res_spec = mysqli_query($link, $sql_spec); - while ($row_spec = mysqli_fetch_row($res_spec)) { - $item_arr[$row['item_no']]['sub_item_id'][] = $row_spec[0]; - } - mysqli_free_result($res_spec); - } elseif ($row['item_group'] == "B") { - $option_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $option_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $option_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $option_arr[$row['item_no']]['memo'] = $row['memo']; - $option_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; - } elseif ($row['item_group'] == "D") { - $mn_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $mn_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $mn_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $mn_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $mn_arr[$row['item_no']]['note'] = $row['note']; - $mn_arr[$row['item_no']]['memo'] = $row['memo']; - $mn_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; - } elseif ($row['item_group'] == "E") { - $ex_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $ex_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $ex_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $ex_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $ex_arr[$row['item_no']]['note'] = $row['note']; - } elseif ($row['item_group'] == "C") { - $demolition_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $demolition_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $demolition_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $demolition_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $demolition_arr[$row['item_no']]['note'] = $row['note']; - } - } - mysqli_free_result($res_i); - $data["price_total_broken"] = $data["price_total"] - $data["price_lowest"]; - $data["price_broken"] = ($data["qty_total"]) ? round($data["price_total_broken"]/$data["qty_total"], 1) : 0; - - // 付款辦法 - $pay_all_scale = $pay_all_amount = 0; - $sql = "select * from pricereview_pay where mid = '$mid' order by pay_kind"; - $res_p = mysqli_query($link, $sql); - while ($row_p = mysqli_fetch_assoc($res_p)) { - $pay_arr[$row_p["pay_kind"]]["pay_scale"] = $row_p["pay_scale"]; - $pay_arr[$row_p["pay_kind"]]["pay_amount"] = $row_p["pay_amount"]; - $pay_arr[$row_p["pay_kind"]]["pay_period"] = $row_p["pay_period"]; - $pay_arr[$row_p["pay_kind"]]["pay_note"] = $row_p["pay_note"]; - $pay_all_scale += $row_p["pay_scale"]; - $pay_all_amount += $row_p["pay_amount"]; - } - mysqli_free_result($res_p); - ?> - - - - - -
-
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - $val) { - $item_amt_A_all += $val["item_price_bp"]; - if ($viewmi) { - for ($i=0; $i<$val["item_qty"]; $i++) { - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
整機單價業務部作業區
項次規格單價數量複價業務部MI售價利潤利潤率(%)
"> [規調]">">">">">">
"> [規調]">">">
小計
-
- -
- -
- - - - - - - - - - - - - - - - - $val) { - $item_amt_B_all += $val["item_price_bp"]; - ?> - - - - - - - - - - - - - - - -
OPTION加價
項次選配規格單價數量複價備註所屬電梯項次
">">">">
小計
-
- -
- -
- - - - - - - - - - - - - - - - $val) { - $item_amt_E_all += $val["item_price_bp"]; - ?> - - - - - - - - - - - - - - -
除外項目
項次詢價單號名稱單價數量複價
">">">
小計
-
- -
- -
- - - - - - - - - - - - - - - - - - - - $val) { - $item_amt_D_all += $val["item_price_bp"]; - if (!empty($val["note"])) list($mn_seat, $mn_numberofstop, $mn_speed) = explode(",", $val["note"]); - else $mn_seat = $mn_numberofstop = $mn_speed = ""; - ?> - - - - - - - - - - - - - - - - - - - -
保固延長
項次電梯人乘/載重停數速度單價數量(月)複價備註所屬電梯項次
">">">">
小計
-
- -
-
- - - - - - - - - - - - - - - - $val) { - $item_amt_C_all += $val["item_price_bp"]; - if (!empty($val["note"])) $floor = $val["note"]; - else $floor = ""; - ?> - - - - - - - - - - - - - - - -
拆梯價格
項次人乘/載重樓層單價數量複價
- - - - ">">">
小計
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
付款辦法款別比例%金額票期
材料1、訂金 - -
2、二次款 - -
3、貨到工地款 - -
4、其它 - -
安裝5、安裝完畢款 - -
6、驗收款 - -
7、其它 - -
合計
備註
-
- -
-
- - "> -
-
- - "> -
-
- - "> -
-
- - "> -
-
- - " size="46"> -
-
- - "> -
-
- - "> -
-
- - "> -
-
- - "> -
-
- - "> -
-
- - "> -
-
- - "> -
-
-
- "> -
-
-
- "> -
-
-
- - "> -
-
- - "> -
-
- - "> -
-
- - "> -
-
- - - - - - - - - - - -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
審核審核人結果意見時間
區經理
業務承辦人 - -
- prepare($sql_str); - $stmt->bindParam(':name',$accountname_arr[$person3]); - $stmt->execute(); - $user = $stmt->fetch(PDO::FETCH_ASSOC); - echo $user['role']; - }else{ - echo "業務部協理"; - } - - ?> -
總經理
- - - - - - - - - - - - - - -
審核意見批示售價
>
- - - - - - - - - - -
- - - - - - - - - "> - -
-
-"; + echo "alert('資料錯誤!!');"; + echo "window.history.go(-1);"; + echo ""; + exit; + } +} + +// 員工編號對應姓名表 +$accountname_arr = accountid2name(); + +// 審核按鈕開關 +$sign_on = 0; + +$data = $item_arr = $option_arr = $mn_arr = $ex_arr = $demolition_arr = $pay_arr = array(); +$checker_1_result = $checker_2_result = $checker_3_result = $checker_4_result = ""; +$db_query = "select * from pricereview_main where id = '$id'"; +/* +if ($res = mysqli_query($link, $db_query)) { + while ($row = mysqli_fetch_row($res)) { + list($id, $version, $company) + } +} +*/ +$res = mysqli_query($link, $db_query); +foreach ($res as $data) { + // 上層主管 + $sql = "select manager from account where accountid = '" . $data["person"] . "'"; + $res_a = mysqli_query($link, $sql); + $row_a = mysqli_fetch_row($res_a); + $manager = $row_a[0]; + mysqli_free_result($res_a); + // 瀏覽MI權限 + $depart_id = accountidToDepartId($user_id); + if ($depart_id == "320" || $depart_id == "321" || $depart_id == "20" || $user_id == "M0008") $viewmi = 1; + else $viewmi = 0; + + $sql = "select * from pricereview_sign where mid = '$id'"; + $res_s = mysqli_query($link, $sql); + $row_s = mysqli_fetch_assoc($res_s); + mysqli_free_result($res_s); + if (!empty($row_s["sign1"])) list($person1, $status1, $dtte1) = explode(",", $row_s["sign1"]); + else $person1 = $status1 = $dtte1 = ""; + if (!empty($row_s["sign2"])) { + if ($st == 2 && (preg_match("/Y/", $row_s["sign2"]) || preg_match("/N/", $row_s["sign2"]))) { + echo ""; + exit; + } + $sign2_arr = explode("<##>", $row_s["sign2"]); // M0024,,<##>M0175,, + $person2_arr = []; + foreach ($sign2_arr as $v) { + list($person2, $status2, $dtte2) = explode(",", $v); + if (strlen($v) == 7) { // 未審 + $person2_arr[] = $person2; + } else { + unset($person2_arr); + break; + } + } + } else $person2 = $status2 = $dtte2 = ""; + if (!empty($row_s["sign3"])) list($person3, $status3, $dtte3) = explode(",", $row_s["sign3"]); + else $person3 = $status3 = $dtte3 = ""; + if (!empty($row_s["sign4"])) list($person4, $status4, $dtte4) = explode(",", $row_s["sign4"]); + else $person4 = $status4 = $dtte4 = ""; + $sign1_note = (empty($row_s["sign1_note"])) ? "" : $row_s["sign1_note"]; + $sign2_note = (empty($row_s["sign2_note"])) ? "" : $row_s["sign2_note"]; + $sign3_note = (empty($row_s["sign3_note"])) ? "" : $row_s["sign3_note"]; + $sign4_note = (empty($row_s["sign4_note"])) ? "" : $row_s["sign4_note"]; + if ($status1 == "Y") { + $checker_1_result = "同意"; + } elseif ($status1 == "N") { + $checker_1_result = "不同意"; + } + if ($status2 == "Y") { + $checker_2_result = "同意"; + } elseif ($status2 == "N") { + $checker_2_result = "不同意"; + } + if ($status3 == "Y") { + $checker_3_result = "同意"; + } elseif ($status3 == "N") { + $checker_3_result = "不同意"; + } + if ($status4 == "Y") { + $checker_4_result = "同意"; + } elseif ($status4 == "N") { + $checker_4_result = "不同意"; + } + if ($st == 1 && ($person1 == $user_id) && ($status1 == "")) { + $sign_on = 1; + } + if ($st == 2 && ($person2 == $user_id || (isset($person2_arr) && in_array($user_id, $person2_arr))) && ($status2 == "")) { + $sign_on = 1; + } + if ($st == 3 && ($person3 == $user_id) && ($status3 == "")) { + $sign_on = 1; + } + if ($st == 4 && ($person4 == $user_id) && ($status4 == "")) { + $sign_on = 1; + } + // $sign_total=關卡數 + if ($person4 == "") { + if ($person3 == "") { + $sign_total = 1; + } else { + $sign_total = 2; + } + } else { + $sign_total = 3; + } + /* + if (!$data["checker_1"] && !$data["checker_2"] && !$data["checker_3"]) $allow_st = 1; + else if (!$data["checker_2"] && !$data["checker_3"]) $allow_st = 2; + else if (!$data["checker_3"]) $allow_st = 3; + if ($data["checker_1_result"]) { + if ($data["checker_1_result"] == "Y") $checker_1_result = "通過"; + else if ($data["checker_1_result"] == "N") { + $stopchk = 1; + $checker_1_result = "拒絕"; + } + } + if ($data["checker_2_result"]) { + if ($data["checker_2_result"] == "Y") $checker_2_result = "通過"; + else if ($data["checker_2_result"] == "N") { + $stopchk = 1; + $checker_2_result = "拒絕"; + } + } + if ($data["checker_3_result"]) { + if ($data["checker_3_result"] == "Y") $checker_3_result = "通過"; + else if ($data["checker_3_result"] == "N") { + $stopchk = 1; + $checker_3_result = "拒絕"; + } + } + */ + + /* + if ($st != $allow_st) { + mysqli_free_result($res); + mysqli_close($link); + echo ""; + } + */ + $mid = $data["id"]; + $data["qty_total"] = 0; + $db_query = "select * from pricereview_item where mid = '$mid' order by item_group, item_no"; + $res_i = mysqli_query($link, $db_query); + while ($row = mysqli_fetch_assoc($res_i)) { + if ($row['item_group'] == "A") { + $item_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $item_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $item_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $item_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $item_arr[$row['item_no']]['item_price_ct'] = $row['item_price_ct']; + $item_arr[$row['item_no']]['item_price'] = $row['item_price']; + $item_arr[$row['item_no']]['pv_rate'] = $row['pv_rate']; + $item_arr[$row['item_no']]['allocate'] = $row['allocate']; + $item_arr[$row['item_no']]['gross_profit'] = $row['gross_profit']; + $item_arr[$row['item_no']]['gross_profit_rate'] = $row['gross_profit_rate']; + $item_arr[$row['item_no']]['note'] = $row['note']; + $item_arr[$row['item_no']]['mi_fix'] = $row['mi_fix']; + $data["qty_total"] += $row["item_qty"]; + $sql_spec = "select sub_item_id from specsurvey_main where mid = '$mid' and pr_item_id = '" . $row['item_no'] . "' order by sub_item_id"; + $res_spec = mysqli_query($link, $sql_spec); + while ($row_spec = mysqli_fetch_row($res_spec)) { + $item_arr[$row['item_no']]['sub_item_id'][] = $row_spec[0]; + } + mysqli_free_result($res_spec); + } elseif ($row['item_group'] == "B") { + $option_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $option_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $option_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $option_arr[$row['item_no']]['memo'] = $row['memo']; + $option_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; + } elseif ($row['item_group'] == "D") { + $mn_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $mn_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $mn_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $mn_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $mn_arr[$row['item_no']]['note'] = $row['note']; + $mn_arr[$row['item_no']]['memo'] = $row['memo']; + $mn_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; + } elseif ($row['item_group'] == "E") { + $ex_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $ex_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $ex_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $ex_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $ex_arr[$row['item_no']]['note'] = $row['note']; + } elseif ($row['item_group'] == "C") { + $demolition_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $demolition_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $demolition_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $demolition_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $demolition_arr[$row['item_no']]['note'] = $row['note']; + } + } + mysqli_free_result($res_i); + $data["price_total_broken"] = $data["price_total"] - $data["price_lowest"]; + $data["price_broken"] = ($data["qty_total"]) ? round($data["price_total_broken"] / $data["qty_total"], 1) : 0; + + // 付款辦法 + $pay_all_scale = $pay_all_amount = 0; + $sql = "select * from pricereview_pay where mid = '$mid' order by pay_kind"; + $res_p = mysqli_query($link, $sql); + while ($row_p = mysqli_fetch_assoc($res_p)) { + $pay_arr[$row_p["pay_kind"]]["pay_scale"] = $row_p["pay_scale"]; + $pay_arr[$row_p["pay_kind"]]["pay_amount"] = $row_p["pay_amount"]; + $pay_arr[$row_p["pay_kind"]]["pay_period"] = $row_p["pay_period"]; + $pay_arr[$row_p["pay_kind"]]["pay_note"] = $row_p["pay_note"]; + $pay_all_scale += $row_p["pay_scale"]; + $pay_all_amount += $row_p["pay_amount"]; + } + mysqli_free_result($res_p); +?> + + + + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + $val) { + $item_amt_A_all += $val["item_price_bp"]; + if ($viewmi) { + for ($i = 0; $i < $val["item_qty"]; $i++) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
整機單價業務部作業區
項次規格單價數量複價業務部MI售價利潤利潤率(%)
"> [規調]">">">">">">
"> [規調]">">">
小計
+
+ +
+ +
+ + + + + + + + + + + + + + + + + $val) { + $item_amt_B_all += $val["item_price_bp"]; + ?> + + + + + + + + + + + + + + + +
OPTION加價
項次選配規格單價數量複價備註所屬電梯項次
">">">">
小計
+
+ +
+ +
+ + + + + + + + + + + + + + + + $val) { + $item_amt_E_all += $val["item_price_bp"]; + ?> + + + + + + + + + + + + + + +
除外項目
項次詢價單號名稱單價數量複價
">">">
小計
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + $val) { + $item_amt_D_all += $val["item_price_bp"]; + if (!empty($val["note"])) list($mn_seat, $mn_numberofstop, $mn_speed) = explode(",", $val["note"]); + else $mn_seat = $mn_numberofstop = $mn_speed = ""; + ?> + + + + + + + + + + + + + + + + + + + +
保固延長
項次電梯人乘/載重停數速度單價數量(月)複價備註所屬電梯項次
">">">">
小計
+
+ +
+
+ + + + + + + + + + + + + + + + $val) { + $item_amt_C_all += $val["item_price_bp"]; + if (!empty($val["note"])) $floor = $val["note"]; + else $floor = ""; + ?> + + + + + + + + + + + + + + + +
拆梯價格
項次人乘/載重樓層單價數量複價
+ + + + ">">">
小計
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
付款辦法款別比例%金額票期
材料1、訂金 + +
2、二次款 + +
3、貨到工地款 + +
4、其它 + +
安裝5、安裝完畢款 + +
6、驗收款 + +
7、其它 + +
合計
備註
+
+ +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + " size="46"> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+
+ "> +
+
+
+ "> +
+
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
審核審核人結果意見時間
區經理
業務承辦人 + +
+ prepare($sql_str); + $stmt->bindParam(':name', $accountname_arr[$person3]); + $stmt->execute(); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + echo $user['role']; + } else { + echo "業務部協理"; + } + + ?> +
總經理
+ + + + + + + + + + + + + + +
審核意見批示售價
>
+ + + + + + + + + + +
+ + + + + + + + + "> + +
+
+ \ No newline at end of file diff --git a/wms/mkt/pricereview_renovate-create.php b/wms/mkt/pricereview_renovate-create.php index a17d3e41..f03fd7cf 100644 --- a/wms/mkt/pricereview_renovate-create.php +++ b/wms/mkt/pricereview_renovate-create.php @@ -2,6 +2,15 @@ include "../header.php"; $vol_no = $_REQUEST["vol_no"]; // 從有望客戶過來:卷號 +$id = $_GET['id']; + +// $sql = "SELECT * FROM pricereview_main WHERE id = $id"; +// $result1 = mysqli_query($link, $sql); +// if (!empty($result1)) { +// $sql = "UPDATE pricereview_main SET status = 'D' WHERE id = $id"; +// $result = mysqli_query($link, $sql); +// } + // 營業員只建自己客戶的價審單 $sql = "select pre_order_date, case_name from hope_elevator_customer where salesman = '$user_id' and vol_no = '$vol_no'"; @@ -1311,32 +1320,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){ */ ?>
" enctype="multipart/form-data"> - +
@@ -2476,7 +2460,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
- + ">
@@ -2529,7 +2513,8 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
    -
  • 業務員權限>=80%以上;<80-75%呈至業務協理審核;<75%以下呈至總經理審核。< /li> +
  • 營業權限>=85%以上;<85-80%呈至區處長審核;<80%以下呈至總經理審核< /li> +
diff --git a/wms/mkt/pricereview_renovate-edit.php b/wms/mkt/pricereview_renovate-edit.php index 36a3080c..b79985f5 100644 --- a/wms/mkt/pricereview_renovate-edit.php +++ b/wms/mkt/pricereview_renovate-edit.php @@ -1,5 +1,4 @@
- + ">
@@ -2103,9 +2102,8 @@ foreach ($res as $data) {
-
    -
  • 業務員權限>=80%以上;<80-75%呈至業務協理審核;<75%以下呈至總經理審核。< /li> +
  • 營業員權限85%以上;85-80%呈至業務協理審核;80%以下呈至總經理審核。
diff --git a/wms/mkt/pricereview_renovate-index.php b/wms/mkt/pricereview_renovate-index.php index 85cc1247..611c6e70 100644 --- a/wms/mkt/pricereview_renovate-index.php +++ b/wms/mkt/pricereview_renovate-index.php @@ -137,7 +137,7 @@ if ($data) : ?>
- +
@@ -154,7 +154,8 @@ if ($data) : - + + @@ -208,15 +209,30 @@ if ($data) : '; + // print_r($maxContractID); + // echo ''; if ($data["status"] == "Y1") { ?> 修改刪除填規調 + + 重填價審 @@ -271,6 +287,24 @@ if ($data) : //echo $str; ?> +
項次建檔時間 功能 區經理工務副總服務助理服務副總 總經理 狀態 合約書下載 + "; + elseif ($ustatus == "N") $str = ""; + $str .= "
" . $accountname_arr[$uperson] . "
" . $udtte; + } else { + if ($sign_st == 2 && $sign_nt == $user_id && $data["status"] == "YS") { + $str = ""; + $str = "待簽核"; + $str = "" . $str . ""; + } else $str = "--"; + } + echo $str; + ?> +
全汰改 - */ -if ($_SERVER["REQUEST_METHOD"] == "POST") { - //print_r($_REQUEST);exit; - foreach ($_POST as $k => $v) { - $$k = htmlspecialchars(stripslashes(trim($v))); - } - - // 同客戶同電梯不能重覆價審 - /* - $warr = []; - $fp_id_str = ""; - $fp_id_arr = explode(",", $fp_id_all); - foreach ($fp_id_arr as $val) { - if ($val && $val>0) $fp_id_str .= $val.","; - } - $fp_id_str = rtrim($fp_id_str, ","); - $db_query = "select i.item_spec from pricereview_main m, pricereview_item i "; - $db_query .= "where m.id = i.mid and contractno = '$contractno' and fp_id in ($fp_id_str) and last_check_result <> 'N'"; - $res = mysqli_query($link, $db_query); - while ($row = mysqli_fetch_row($res)) { - $warr[] = $row[0]; - } - $warning = implode("、", $warr); - if ($warning) { - echo ""; - } - */ - - $price_total = str_replace(",", "", $price_total); - $price_lowest = str_replace(",", "", $price_lowest); - $pay_amount = str_replace(",", "", $pay_amount); - $pay_all_amount = str_replace(",", "", $pay_all_amount); - $special_fee = str_replace(",", "", $special_fee); - if (empty($deposit_rate)) $deposit_rate = 0; - if (empty($keep_rate)) $keep_rate = 0; - if (empty($warranty_rate)) $warranty_rate = 0; - if (empty($special_fee)) $special_fee = 0; - $status = ($pmstatus == "tosign") ? "YS" : "Y1"; // YS:提交 Y1:保存 - $st_str = ($status == "YS") ? "提交" : "保存"; - $create_at = date("Y-m-d H:i:s"); - $tds = date("Y-m-d"); - - // 客戶資料 - $sql = "select vol_no, salesman, customer, address from hope_elevator_customer where vol_no = '$vol_no'"; - $res = mysqli_query($link, $sql); - $row = mysqli_fetch_row($res); - list($contractno, $person, $company, $address) = $row; - mysqli_free_result($res); - - // 同一卷號只限一筆價審 - $sql = "select count(*) from pricereview_main where contractno = '$contractno' and status in ('Y1', 'YS', 'YY')"; - $res = mysqli_query($link, $sql); - $row = mysqli_fetch_row($res); - if ($row[0] > 0) { - echo ""; - exit; - } - - // 上傳報價單 - $target_dir = "pricereview-uploads/"; - if ($_FILES["attatch1"]["error"] == 0) { - $file_name = $_FILES["attatch1"]["name"]; - $temp_file_name = $_FILES["attatch1"]["tmp_name"]; - $file_size = $_FILES["attatch1"]["size"]; - $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); - $target_file1 = $target_dir.$vol_no."-price-".$tds.".".$img_file_type; - $upload_ok = 1; - foreach (glob($target_dir.$vol_no."-price-*") as $todelfile) { - unlink($todelfile); - } - $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); - } else $target_file1 = ""; - - // 上傳附表一 - if ($_FILES["attatch2"]["error"] == 0) { - $file_name = $_FILES["attatch2"]["name"]; - $temp_file_name = $_FILES["attatch2"]["tmp_name"]; - $file_size = $_FILES["attatch2"]["size"]; - $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); - $target_file2 = $target_dir.$vol_no."-appendix-".$tds.".".$img_file_type; - $upload_ok = 1; - foreach (glob($target_dir.$vol_no."-appendix-*") as $todelfile) { - unlink($todelfile); - } - $upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); - } else $target_file2 = ""; - - if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { - echo ""; - exit; - } - - // 價格審查單-主文 pricereview_main - $db_query = "insert into pricereview_main(contractno, ekind, person, company, case_name, address, price_lowest, "; - $db_query .= "price_total, price_rate, special_fee, predeal_date, facilitok_date, penalty, deposit_rate, keep_rate, "; - $db_query .= "warranty_rate, memo, status, attatch1, attatch2, creater, create_at) values ("; - $db_query .= "'$contractno', '汰改', '$person', '$company', '$case_name', '$address', '$price_lowest', "; - $db_query .= "'$price_total', '$price_rate', '$special_fee', '$predeal_date', '$facilitok_date', '$penalty', '$deposit_rate', '$keep_rate', "; - $db_query .= "'$warranty_rate', '$memo', '$status', '$target_file1', '$target_file2', '$user_id', '$create_at')"; - $result = mysqli_query($link, $db_query); - $affected = mysqli_affected_rows($link); - if ($mid = mysqli_insert_id($link)) { - // 價格審查單-明細項目 pricereview_item:電梯 - $fp_id_arr = explode(",", $fp_id_all); - $fp_kind_arr = explode(",", $fp_kind_all); - $fp_seat_arr = explode(",", $fp_seat_all); - $fp_numberofstop_arr = explode(",", $fp_numberofstop_all); - $fp_speed_arr = explode(",", $fp_speed_all); - $item_weight_arr = explode(",", $item_weight_all); - $item_op_arr = explode(",", $item_op_all); - $item_spec_arr = explode(",", $item_spec_all); - $item_group_arr = explode(",", $item_group_all); - $item_unit_price_arr = explode(",", $item_unit_price_all); - $item_qty_arr = explode(",", $item_qty_all); - $item_qty_ori_arr = explode(",", $item_qty_ori_all); - $item_price_bp_arr = explode(",", $item_price_bp_all); - $item_price_ct_arr = explode(",", rtrim($item_price_ct_all, ",")); - $item_price_arr = explode(",", $item_price_all); - $gross_profit_arr = explode(",", $gross_profit_all); - $item_price_arr = $gross_profit_arr = []; // 先reset, 等審核才產出 - // 非全汰改=REN - $renovate_flag = ""; - if (preg_match("/M1/", $fp_kind_all)) $renovate_flag = "REN"; - - // 如果售價變動或電梯數量異動,售價則平均分攤到每台 - $avg_fg = 0; - foreach ($item_price_bp_arr as $k => $v) { - if ($v && !isset($item_price_ct_arr[$k])) { - $avg_fg = 1; - break; - } - } - foreach ($item_qty_ori_arr as $k => $v) { - if ($v != $item_qty_arr[$k]) { - $avg_fg = 1; - break; - } - } - if ($price_total_ori != $price_total) $avg_fg = 1; - if ($avg_fg) { - $item_price_ct2_arr = []; - $price_total_item = 0; - foreach ($item_qty_arr as $k => $v) { - $price = floor(($price_total/array_sum($item_qty_arr))*$v); - $item_price_ct2_arr[] = $price; - if ($k < count($item_qty_arr)-1) $price_total_item += $price; - } - $item_price_ct2_arr[count($item_qty_arr)-1] = $price_total - $price_total_item; - $item_price_ct_arr = $item_price_ct2_arr; - } - - $item_no = 1; - for ($i=0; $i", $option_relate_facil_arr[$i]); - foreach ($tmp_arr as $val) { - $option_relate_spec .= substr($val, 0, strpos($val, ".")).","; - } - $option_relate_spec = rtrim($option_relate_spec, ","); - $db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo) values ("; - $db_query .= "'$mid', '$op_id_arr[$i]', '$item_no', 'B', '$spec', '$option_relate_spec', '$option_unit_price_arr[$i]', '$option_qty_arr[$i]', '$option_price_bp_arr[$i]', '$option_memo_arr[$i]')"; - $result = mysqli_query($link, $db_query); - $item_no++; - } - - // 價格審查單-明細項目 pricereview_item:拆梯費用 - $db_query = "delete from pricereview_item where mid = '$mid' and item_group = 'C'"; - mysqli_query($link, $db_query); - $dem_id_arr = explode(",", $dem_id_all); - $seat_arr = explode(",", $seat_all); - $floor_arr = explode(",", $floor_all); - $demolition_unit_price_arr = explode(",", $demolition_unit_price_all); - $demolition_qty_arr = explode(",", $demolition_qty_all); - $demolition_price_bp_arr = explode(",", $demolition_price_bp_all); - $item_no = 1; - for ($i=0; $i", $mn_relate_facil_arr[$i]); - foreach ($tmp_arr as $val) { - $option_relate_spec .= substr($val, 0, strpos($val, ".")).","; - } - $option_relate_spec = rtrim($option_relate_spec, ","); - $db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note, memo) values ("; - $db_query .= "'$mid', '$mn_id_arr[$i]', '$item_no', 'D', '$mn_kind_arr[$i]', '$option_relate_spec', '$mn_unit_price_arr[$i]', '$mn_qty_arr[$i]', '$mn_price_bp_arr[$i]', '$note', '$mn_memo_arr[$i]')"; - $result = mysqli_query($link, $db_query); - $item_no++; - } - - // 價審明細:除外費用 - $db_query = "delete from pricereview_item where mid = '$mid' and item_group = 'E'"; - mysqli_query($link, $db_query); - $except_note_arr = explode(",", $except_note_all); - $except_spec_arr = explode(",", $except_spec_all); - $except_unit_price_arr = explode(",", $except_unit_price_all); - $except_qty_arr = explode(",", $except_qty_all); - $except_price_bp_arr = explode(",", $except_price_bp_all); - $item_no = 1; - for ($i=0; $i 上級主管 > 詹總 > 總經理 - if ($status == "YS") { - $manager_arr = pricereview_renovate_class($price_rate, $user_id, $renovate_flag); - if ($manager_arr) { - $sign1 = $sign2 = $sign3 = $sign4 = ""; - foreach ($manager_arr as $k => $v) { - if ($k == 1) $sign1 = $v.",,"; - elseif ($k == 2) $sign2 = $v.",,"; - elseif ($k == 3) $sign3 = $v.",,"; - else $sign4 = $v.",,"; - } - $sql = "insert into pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total) values ('$mid', '$sign1', '$sign2', '$sign3', '$sign4', '".count($manager_arr)."')"; - mysqli_query($link, $sql); - // 寫入待簽表 - if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1); - elseif (strlen($sign2) == 7) $next_signer = str_replace(",", "", $sign2); - do_assign("prm02", $mid, $contractno, $next_signer); - - // 寄信給下位簽核人 - $mail_list = []; - $ret = accountid2email($next_signer); - if (!empty($ret)) { - $mail_list[0] = [$next_signer, $ret[$next_signer]]; - include dirname(__DIR__)."/class/Cmail.php"; - $sendmail = new Cmail; - $title = "【汰改價審通知】卷號:".$contractno; - $content = "

您有待簽核案件,請至客戶管理 > 價格審查_汰改,點擊「待簽核」進行作業,謝謝!

"; - $sendmail->sendx($title, $content, $mail_list); - } - } - } - } - - mysqli_close($link); - if ($affected > 0) { - echo ""; - } else { - echo ""; - } -} -?> \ No newline at end of file +全汰改 + */ +if ($_SERVER["REQUEST_METHOD"] == "POST") { + //print_r($_REQUEST);exit; + foreach ($_POST as $k => $v) { + $$k = htmlspecialchars(stripslashes(trim($v))); + } + + // 同客戶同電梯不能重覆價審 + /* + $warr = []; + $fp_id_str = ""; + $fp_id_arr = explode(",", $fp_id_all); + foreach ($fp_id_arr as $val) { + if ($val && $val>0) $fp_id_str .= $val.","; + } + $fp_id_str = rtrim($fp_id_str, ","); + $db_query = "select i.item_spec from pricereview_main m, pricereview_item i "; + $db_query .= "where m.id = i.mid and contractno = '$contractno' and fp_id in ($fp_id_str) and last_check_result <> 'N'"; + $res = mysqli_query($link, $db_query); + while ($row = mysqli_fetch_row($res)) { + $warr[] = $row[0]; + } + $warning = implode("、", $warr); + if ($warning) { + echo ""; + } + */ + + $price_total = str_replace(",", "", $price_total); + $price_lowest = str_replace(",", "", $price_lowest); + $pay_amount = str_replace(",", "", $pay_amount); + $pay_all_amount = str_replace(",", "", $pay_all_amount); + $special_fee = str_replace(",", "", $special_fee); + if (empty($deposit_rate)) $deposit_rate = 0; + if (empty($keep_rate)) $keep_rate = 0; + if (empty($warranty_rate)) $warranty_rate = 0; + if (empty($special_fee)) $special_fee = 0; + $status = ($pmstatus == "tosign") ? "YS" : "Y1"; // YS:提交 Y1:保存 + $st_str = ($status == "YS") ? "提交" : "保存"; + $create_at = date("Y-m-d H:i:s"); + $tds = date("Y-m-d"); + + // 客戶資料 + $sql = "select vol_no, salesman, customer, address from hope_elevator_customer where vol_no = '$vol_no'"; + $res = mysqli_query($link, $sql); + $row = mysqli_fetch_row($res); + list($contractno, $person, $company, $address) = $row; + mysqli_free_result($res); + + // 同一卷號只限一筆價審 + $sql = "select count(*) from pricereview_main where contractno = '$contractno' and status in ('Y1', 'YS', 'YY')"; + $res = mysqli_query($link, $sql); + $row = mysqli_fetch_row($res); + if ($row[0] > 0) { + echo ""; + exit; + } + + // 上傳報價單 + $target_dir = "pricereview-uploads/"; + if ($_FILES["attatch1"]["error"] == 0) { + $file_name = $_FILES["attatch1"]["name"]; + $temp_file_name = $_FILES["attatch1"]["tmp_name"]; + $file_size = $_FILES["attatch1"]["size"]; + $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); + $target_file1 = $target_dir . $vol_no . "-price-" . $tds . "." . $img_file_type; + $upload_ok = 1; + foreach (glob($target_dir . $vol_no . "-price-*") as $todelfile) { + unlink($todelfile); + } + $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); + } else $target_file1 = ""; + + // 上傳附表一 + if ($_FILES["attatch2"]["error"] == 0) { + $file_name = $_FILES["attatch2"]["name"]; + $temp_file_name = $_FILES["attatch2"]["tmp_name"]; + $file_size = $_FILES["attatch2"]["size"]; + $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); + $target_file2 = $target_dir . $vol_no . "-appendix-" . $tds . "." . $img_file_type; + $upload_ok = 1; + foreach (glob($target_dir . $vol_no . "-appendix-*") as $todelfile) { + unlink($todelfile); + } + $upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); + } else $target_file2 = ""; + + if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { + echo ""; + exit; + } + + // 價格審查單-主文 pricereview_main + $db_query = "insert into pricereview_main(contractno, ekind, person, company, case_name, address, price_lowest, "; + $db_query .= "price_total, price_rate, special_fee, predeal_date, facilitok_date, penalty, deposit_rate, keep_rate, "; + $db_query .= "warranty_rate, memo, status, attatch1, attatch2, creater, create_at) values ("; + $db_query .= "'$contractno', '汰改', '$person', '$company', '$case_name', '$address', '$price_lowest', "; + $db_query .= "'$price_total', '$price_rate', '$special_fee', '$predeal_date', '$facilitok_date', '$penalty', '$deposit_rate', '$keep_rate', "; + $db_query .= "'$warranty_rate', '$memo', '$status', '$target_file1', '$target_file2', '$user_id', '$create_at')"; + $result = mysqli_query($link, $db_query); + $affected = mysqli_affected_rows($link); + if ($mid = mysqli_insert_id($link)) { + // 價格審查單-明細項目 pricereview_item:電梯 + $fp_id_arr = explode(",", $fp_id_all); + $fp_kind_arr = explode(",", $fp_kind_all); + $fp_seat_arr = explode(",", $fp_seat_all); + $fp_numberofstop_arr = explode(",", $fp_numberofstop_all); + $fp_speed_arr = explode(",", $fp_speed_all); + $item_weight_arr = explode(",", $item_weight_all); + $item_op_arr = explode(",", $item_op_all); + $item_spec_arr = explode(",", $item_spec_all); + $item_group_arr = explode(",", $item_group_all); + $item_unit_price_arr = explode(",", $item_unit_price_all); + $item_qty_arr = explode(",", $item_qty_all); + $item_qty_ori_arr = explode(",", $item_qty_ori_all); + $item_price_bp_arr = explode(",", $item_price_bp_all); + $item_price_ct_arr = explode(",", rtrim($item_price_ct_all, ",")); + $item_price_arr = explode(",", $item_price_all); + $gross_profit_arr = explode(",", $gross_profit_all); + $item_price_arr = $gross_profit_arr = []; // 先reset, 等審核才產出 + // 非全汰改=REN + $renovate_flag = ""; + if (preg_match("/M1/", $fp_kind_all)) $renovate_flag = "REN"; + + // 如果售價變動或電梯數量異動,售價則平均分攤到每台 + $avg_fg = 0; + foreach ($item_price_bp_arr as $k => $v) { + if ($v && !isset($item_price_ct_arr[$k])) { + $avg_fg = 1; + break; + } + } + foreach ($item_qty_ori_arr as $k => $v) { + if ($v != $item_qty_arr[$k]) { + $avg_fg = 1; + break; + } + } + if ($price_total_ori != $price_total) $avg_fg = 1; + if ($avg_fg) { + $item_price_ct2_arr = []; + $price_total_item = 0; + foreach ($item_qty_arr as $k => $v) { + $price = floor(($price_total / array_sum($item_qty_arr)) * $v); + $item_price_ct2_arr[] = $price; + if ($k < count($item_qty_arr) - 1) $price_total_item += $price; + } + $item_price_ct2_arr[count($item_qty_arr) - 1] = $price_total - $price_total_item; + $item_price_ct_arr = $item_price_ct2_arr; + } + + $item_no = 1; + for ($i = 0; $i < count($item_spec_arr); $i++) { + $spec = trim($item_spec_arr[$i]); + if (empty($spec)) continue; + if (!$fp_id_arr[$i]) $fp_id_arr[$i] = 0; + $item_unit_price_arr[$i] = str_replace(",", "", $item_unit_price_arr[$i]); + $item_qty_arr[$i] = str_replace(",", "", $item_qty_arr[$i]); + $item_price_bp_arr[$i] = str_replace(",", "", $item_price_bp_arr[$i]); + $item_price_ct_arr[$i] = str_replace(",", "", $item_price_ct_arr[$i]); + //$item_price_arr[$i] = str_replace(",", "", $item_price_arr[$i]); + if (empty($item_price_arr[$i])) $item_price_arr[$i] = 0; + //$gross_profit_arr[$i] = str_replace(",", "", $gross_profit_arr[$i]); + if (empty($gross_profit_arr[$i])) $gross_profit_arr[$i] = 0; + $gross_profit_rate = number_format(($gross_profit_arr[$i] / $item_price_bp_arr[$i]) * 100, 1); + $note = $fp_kind_arr[$i] . "," . $fp_seat_arr[$i] . "," . $fp_numberofstop_arr[$i] . "," . $fp_speed_arr[$i]; + $db_query = "insert into pricereview_item (mid, price_id, item_no, item_spec, item_weight, item_op, item_group, item_unit_price, item_qty, item_price_bp, item_price_ct, item_price, gross_profit, gross_profit_rate, note) values ("; + $db_query .= "'$mid', '$fp_id_arr[$i]', '$item_no', '$item_spec_arr[$i]', '$item_weight_arr[$i]', '$item_op_arr[$i]', 'A', '$item_unit_price_arr[$i]', '$item_qty_arr[$i]', '$item_price_bp_arr[$i]', '$item_price_ct_arr[$i]', '$item_price_arr[$i]', '$gross_profit_arr[$i]', '$gross_profit_rate', '$note')"; + $result = mysqli_query($link, $db_query); + $item_no++; + } + + // 價格審查單-明細項目 pricereview_item:Option加價 + $db_query = "delete from pricereview_item where mid = '$mid' and item_group = 'B'"; + mysqli_query($link, $db_query); + $op_id_arr = explode(",", $op_id_all); + $option_seat_all = str_replace("點選", "", $option_seat_all); + $option_seat_arr = explode(",", str_replace("@@", "", $option_seat_all)); + $option_unit_price_arr = explode(",", $option_unit_price_all); + $option_qty_arr = explode(",", $option_qty_all); + $option_price_bp_arr = explode(",", $option_price_bp_all); + $option_memo_arr = explode("@@,", rtrim($option_memo_all, "@@")); + $option_relate_facil_arr = explode(",", htmlspecialchars_decode($option_relate_facil_all)); + $item_no = 1; + for ($i = 0; $i < count($option_seat_arr); $i++) { + $spec = trim($option_seat_arr[$i]); + if (empty($spec)) continue; + $option_unit_price_arr[$i] = str_replace(",", "", $option_unit_price_arr[$i]); + $option_qty_arr[$i] = str_replace(",", "", $option_qty_arr[$i]); + $option_price_bp_arr[$i] = str_replace(",", "", $option_price_bp_arr[$i]); + $option_relate_spec = ""; + $tmp_arr = explode("
", $option_relate_facil_arr[$i]); + foreach ($tmp_arr as $val) { + $option_relate_spec .= substr($val, 0, strpos($val, ".")) . ","; + } + $option_relate_spec = rtrim($option_relate_spec, ","); + $db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo) values ("; + $db_query .= "'$mid', '$op_id_arr[$i]', '$item_no', 'B', '$spec', '$option_relate_spec', '$option_unit_price_arr[$i]', '$option_qty_arr[$i]', '$option_price_bp_arr[$i]', '$option_memo_arr[$i]')"; + $result = mysqli_query($link, $db_query); + $item_no++; + } + + // 價格審查單-明細項目 pricereview_item:拆梯費用 + $db_query = "delete from pricereview_item where mid = '$mid' and item_group = 'C'"; + mysqli_query($link, $db_query); + $dem_id_arr = explode(",", $dem_id_all); + $seat_arr = explode(",", $seat_all); + $floor_arr = explode(",", $floor_all); + $demolition_unit_price_arr = explode(",", $demolition_unit_price_all); + $demolition_qty_arr = explode(",", $demolition_qty_all); + $demolition_price_bp_arr = explode(",", $demolition_price_bp_all); + $item_no = 1; + for ($i = 0; $i < count($seat_arr); $i++) { + $spec = trim($seat_arr[$i]); + if (!$spec) continue; + $demolition_unit_price_arr[$i] = str_replace(",", "", $demolition_unit_price_arr[$i]); + $demolition_qty_arr[$i] = str_replace(",", "", $demolition_qty_arr[$i]); + $demolition_price_bp_arr[$i] = str_replace(",", "", $demolition_price_bp_arr[$i]); + $db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, item_unit_price, item_qty, item_price_bp, note) values ("; + $db_query .= "'$mid', '$dem_id_arr[$i]', '$item_no', 'C', '$spec', '$demolition_unit_price_arr[$i]', '$demolition_qty_arr[$i]', '$demolition_price_bp_arr[$i]', '$floor_arr[$i]')"; + $result = mysqli_query($link, $db_query); + $item_no++; + } + + // 價審明細:保養費用 + $db_query = "delete from pricereview_item where mid = '$mid' and item_group = 'D'"; + mysqli_query($link, $db_query); + $mn_id_arr = explode(",", $mn_id_all); + $mn_kind_arr = explode(",", $mn_kind_all); + $mn_seat_arr = explode(",", $mn_seat_all); + $mn_numberofstop_arr = explode(",", $mn_numberofstop_all); + $mn_speed_arr = explode(",", $mn_speed_all); + $mn_unit_price_arr = explode(",", $mn_unit_price_all); + $mn_qty_arr = explode(",", $mn_qty_all); + $mn_price_bp_arr = explode(",", $mn_price_bp_all); + $mn_memo_arr = explode("@@,", rtrim($mn_memo_all, "@@")); + $mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all)); + $item_no = 1; + for ($i = 0; $i < count($mn_seat_arr); $i++) { + if (empty($mn_kind_arr[$i])) continue; + $mn_unit_price_arr[$i] = str_replace(",", "", $mn_unit_price_arr[$i]); + $mn_qty_arr[$i] = str_replace(",", "", $mn_qty_arr[$i]); + $mn_price_bp_arr[$i] = str_replace(",", "", $mn_price_bp_arr[$i]); + $note = $mn_seat_arr[$i] . "," . $mn_numberofstop_arr[$i] . "," . $mn_speed_arr[$i]; + $option_relate_spec = ""; + $tmp_arr = explode("
", $mn_relate_facil_arr[$i]); + foreach ($tmp_arr as $val) { + $option_relate_spec .= substr($val, 0, strpos($val, ".")) . ","; + } + $option_relate_spec = rtrim($option_relate_spec, ","); + $db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note, memo) values ("; + $db_query .= "'$mid', '$mn_id_arr[$i]', '$item_no', 'D', '$mn_kind_arr[$i]', '$option_relate_spec', '$mn_unit_price_arr[$i]', '$mn_qty_arr[$i]', '$mn_price_bp_arr[$i]', '$note', '$mn_memo_arr[$i]')"; + $result = mysqli_query($link, $db_query); + $item_no++; + } + + // 價審明細:除外費用 + $db_query = "delete from pricereview_item where mid = '$mid' and item_group = 'E'"; + mysqli_query($link, $db_query); + $except_note_arr = explode(",", $except_note_all); + $except_spec_arr = explode(",", $except_spec_all); + $except_unit_price_arr = explode(",", $except_unit_price_all); + $except_qty_arr = explode(",", $except_qty_all); + $except_price_bp_arr = explode(",", $except_price_bp_all); + $item_no = 1; + for ($i = 0; $i < count($except_spec_arr); $i++) { + $spec = trim($except_spec_arr[$i]); + if (empty($spec)) continue; + $except_unit_price_arr[$i] = str_replace(",", "", $except_unit_price_arr[$i]); + $except_qty_arr[$i] = str_replace(",", "", $except_qty_arr[$i]); + $except_price_bp_arr[$i] = str_replace(",", "", $except_price_bp_arr[$i]); + $db_query = "insert into pricereview_item (mid, item_no, item_group, item_spec, item_unit_price, item_qty, item_price_bp, note) values ("; + $db_query .= "'$mid', '$item_no', 'E', '$spec', '$except_unit_price_arr[$i]', '$except_qty_arr[$i]', '$except_price_bp_arr[$i]', '$except_note_arr[$i]')"; + $result = mysqli_query($link, $db_query); + $item_no++; + } + + // 款別資訊 + $pay_kind_arr = explode(",", $pay_kind_all); + $pay_scale_arr = explode(",", $pay_scale_all); + $pay_amount_arr = explode(",", $pay_amount_all); + $pay_period_arr = explode(",", $pay_period_all); + for ($i = 0; $i < 7; $i++) { + $pay_scale_arr[$i] = (empty($pay_scale_arr[$i])) ? 0 : $pay_scale_arr[$i]; + $pay_amount_arr[$i] = (empty($pay_amount_arr[$i])) ? 0 : $pay_amount_arr[$i]; + $sql = "insert into pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period, pay_note) values "; + $sql .= "('$mid', '$pay_kind_arr[$i]', '$pay_scale_arr[$i]', '$pay_amount_arr[$i]', '$pay_period_arr[$i]', '$pay_note')"; + mysqli_query($link, $sql); + } + + // 價審簽核流程 + // <75%以下呈至總經理審核. ($price_rate) + // 契約員 > 上級主管 > 詹總 > 總經理 + if ($status == "YS") { + $manager_arr = pricereview_renovate_class($price_rate, $user_id, $renovate_flag); + if ($manager_arr) { + $sign1 = $sign2 = $sign3 = $sign4 = ""; + foreach ($manager_arr as $k => $v) { + if ($k == 1) $sign1 = $v . ",,"; + elseif ($k == 2) $sign2 = $v . ",,"; + elseif ($k == 3) $sign3 = $v . ",,"; + else $sign4 = $v . ",,"; + } + $sql = "insert into pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total) values ('$mid', '$sign1', '$sign2', '$sign3', '$sign4', '" . count($manager_arr) . "')"; + mysqli_query($link, $sql); + // 寫入待簽表 + if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1); + elseif (strlen($sign2) == 7) $next_signer = str_replace(",", "", $sign2); + do_assign("prm02", $mid, $contractno, $next_signer); + + // 寄信給下位簽核人 + $mail_list = []; + $ret = accountid2email($next_signer); + if (!empty($ret)) { + $mail_list[0] = [$next_signer, $ret[$next_signer]]; + include dirname(__DIR__) . "/class/Cmail.php"; + $sendmail = new Cmail; + $title = "【汰改價審通知】卷號:" . $contractno; + $content = "

您有待簽核案件,請至客戶管理 > 價格審查_汰改,點擊「待簽核」進行作業,謝謝!

"; + $sendmail->sendx($title, $content, $mail_list); + } + } + } + } + + mysqli_close($link); + if ($affected > 0) { + echo ""; + } else { + echo ""; + } +}