Browse Source

'合約入立(修理)進T8'

main
Cheng 1 year ago
parent
commit
44b04b4fa7
  1. 38
      prv/pricereview-record-submit.php
  2. 36
      wms/T8_APItest.php
  3. 157
      wms/contract-repair/api/putContractData.php
  4. 4
      wms/contract-repair/js/alpine.js
  5. 1
      wms/contract/api/postContractData.php
  6. 16
      wms/fun_global.php
  7. 24
      wms/mkt/pricereview-index.php
  8. 46
      wms/mkt/pricereview-record-submit.php
  9. 1657
      wms/mkt/pricereview_renovate-check.php
  10. 41
      wms/mkt/pricereview_renovate-create.php
  11. 6
      wms/mkt/pricereview_renovate-edit.php
  12. 40
      wms/mkt/pricereview_renovate-index.php
  13. 60
      wms/mkt/pricereview_renovate-record-submit.php

38
prv/pricereview-record-submit.php

@ -1,3 +1,5 @@
<?php <?php
require_once "database.php"; require_once "database.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
@ -6,26 +8,26 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
$maintance_contract_id=$_POST['maintance_contract_id']; $maintance_contract_id = $_POST['maintance_contract_id'];
$sitename=$_POST['sitename']; $sitename = $_POST['sitename'];
$contractor=$_POST['contractor']; $contractor = $_POST['contractor'];
$contractsnum=$_POST['contractsnum']; $contractsnum = $_POST['contractsnum'];
$siteaddress=$_POST['siteaddress']; $siteaddress = $_POST['siteaddress'];
$startdate=$_POST['startdate']; $startdate = $_POST['startdate'];
$enddate=$_POST['enddate']; $enddate = $_POST['enddate'];
$contractsigningperiod=$startdate.'_'.$enddate; $contractsigningperiod = $startdate . '_' . $enddate;
$pricereviewer=$_POST['pricereviewer']; $pricereviewer = $_POST['pricereviewer'];
$contracttype=$_POST['contracttype']; $contracttype = $_POST['contracttype'];
$Maintenanceoperationcategory=$_POST['Maintenanceoperationcategory']; $Maintenanceoperationcategory = $_POST['Maintenanceoperationcategory'];
$contractsigningnature=$_POST['contractsigningnature']; $contractsigningnature = $_POST['contractsigningnature'];
$contractsignname=$_POST['contractsignname']; $contractsignname = $_POST['contractsignname'];
$servicefee=$_POST['servicefee']; $servicefee = $_POST['servicefee'];
$managebili=$_POST['managebili']; $managebili = $_POST['managebili'];
$creater = $_POST['creater']; $creater = $_POST['creater'];
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
$updatee_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 = "insert into maintance_contract_info(maintance_contract_id,sitename,contractor,contractsnum,siteaddress";
$db_query .= ",contractsigningperiod,pricereviewer,contracttype,Maintenanceoperationcategory,contractsigningnature,contractsignname"; $db_query .= ",contractsigningperiod,pricereviewer,contracttype,Maintenanceoperationcategory,contractsigningnature,contractsignname";
@ -36,7 +38,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
if ($mid = mysqli_insert_id($link)) { if ($mid = mysqli_insert_id($link)) {
header("Location: pricereview-index.php?account=".$_POST['account']); header("Location: pricereview-index.php?account=" . $_POST['account']);
if (mysqli_affected_rows($link) > 0) { if (mysqli_affected_rows($link) > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功')"; echo "alert('新增成功')";

36
wms/T8_APItest.php

@ -12,42 +12,42 @@ echo "ii";
console.log(validation); console.log(validation);
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; // 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 = { headerParam = {
CHI_Authorization: `${validation}`, CHI_Authorization: `${validation}`,
}; };
var body = [{ var body = [{
"name": "salIncomeApplyMaster", "name": "salIncomeApplyMaster",
"rows": [{ "rows": [{
"BillNo": "Z001", "BillNo": "B23100061",
"BillDate": 20160811, "BillDate": 20231220,
"OrgId": "1000", "OrgId": "1000",
"FOrgId": "1000", "FOrgId": "1000",
"TypeId": "RR", "TypeId": "RAS",
"BpOrgId": "1000", "BpOrgId": "1000",
"BizPartnerId": "C002", "BizPartnerId": "B23100061",
"CurrId": "RMB", "CurrId": "TWD",
"CurrOAmount": 1, "CurrOAmount": 1,
"CurrLAmount": 1, "CurrLAmount": 1,
"PersonId": "T001", "PersonId": "M0065",
"DtOrgId": "1000", "DtOrgId": "1000",
"DueToId": "C002", "DueToId": "B23100061",
"TaxId": "123", "TaxId": "ST005",
"CompId": "1000" "CompId": "1001"
}] }]
}, },
{ {
"name": "salIncomeApplyDetail", "name": "salIncomeApplyDetail",
"rows": [{ "rows": [{
"BillNo": "Z001", "BillNo": "B23100061",
"IncomeId": "F203", "IncomeId": "A40003",
"TaxId": "ST003", "TaxId": "ST005",
"RowCode": 1, "RowCode": 1,
"ItemType": "1", "ItemType": "1",
"SPrice": 50, "SPrice": 10000,
"SQuantity": 1, "SQuantity": 2,
"FromSourceTag": 0, "FromSourceTag": 0,
"FromBillNo": "123" "FromBillNo": ""
}] }]
} }
]; ];
@ -56,9 +56,9 @@ echo "ii";
type: 'POST', type: 'POST',
// url: `${corsurl}${apiurl}`, // url: `${corsurl}${apiurl}`,
url: `${apiurl}`, url: `${apiurl}`,
// dataType: 'json', dataType: 'json',
headers: headerParam, headers: headerParam,
// data: json, data: json,
// dataType: "json", // dataType: "json",
success: function(res) { success: function(res) {
console.log(res.Status); console.log(res.Status);

157
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'] != "") { if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_POST["id"]) && $_POST['id'] != "") {
try { try {
$create_date = date('Y-m-d H:i:s'); $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; $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
$company = !empty($_POST['company']) ? $_POST['company'] : null; $company = !empty($_POST['company']) ? $_POST['company'] : null;
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; $taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null;
@ -21,7 +21,7 @@ if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_PO
$fail_arr = []; $fail_arr = [];
// if (empty($repair_no)) $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($company)) $fail_arr[] = '客戶名稱為必填';
if (empty($taxid)) $fail_arr[] = '統一編號為必填'; if (empty($taxid)) $fail_arr[] = '統一編號為必填';
if (empty($facilityno)) $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); echo json_encode($fail_arr);
exit(); exit();
} }
// $conn->beginTransaction(); $conn->beginTransaction();
$sql = "UPDATE contract_r_signed_back SET $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 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); // echo json_encode($sql);
// exit; // exit;
$stmt->execute(); $stmt->execute();
t8Insert($_POST);
// header("HTTP/1.1 204 NO Content"); // header("HTTP/1.1 204 NO Content");
// $conn->commit(); $conn->commit();
} catch (PDOException $e) { } catch (PDOException $e) {
// $conn->rollback(); // $conn->rollback();
header("HTTPP/1.1 500 Internal Server Error"); header("HTTPP/1.1 500 Internal Server Error");
die('Error!:' . $e->getMessage()); 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 = []; function t8Insert($data)
// if (empty($contract_no)) $fail_arr[] = '合約號為必填'; {
// if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; require_once('../../contract/connt8.php');
// if (empty($manager)) $fail_arr[] = '負責人為必填'; $create_date = date('Y-m-dH-i-s');
// if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; $repair_no = !empty($data['repair_no']) ? $data['repair_no'] : null; // 報價單號
// if (empty($case_name)) $fail_arr[] = '案名為必填'; $company = !empty($data['company']) ? $data['company'] : null; //立約人
// if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; $repaireid = !empty($data['repaireid']) ? $data['repaireid'] : null; //維保人員
// if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; $facilityno = !empty($data['facilityno']) ? $data['facilityno'] : null; // 電梯編號
// if (empty($address)) $fail_arr[] = '地址為必填'; $type = !empty($data['type']) ? $data['type'] : null; //工程進度
// if (empty($salesman)) $fail_arr[] = '營業員為必填'; $sign_date = !empty($data['sign_date']) ? $data['sign_date'] : null; //簽訂時間
// if (empty($qc)) $fail_arr[] = '請選擇QC或管檢'; $invoice = !empty($data['invoice']) ? $data['invoice'] : null; // 發票抬頭
// if (count($fail_arr) > 0) { $taxid = !empty($data['taxid']) ? $data['taxid'] : null; //統編
// header("HTTP/1.1 422 Unprocessable Entity"); $address = !empty($data['address']) ? $data['address'] : null; //工程地址
// echo json_encode($fail_arr); $contract_status = !empty($data['contract_status']) ? $data['contract_status'] : null;
// exit(); $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"; $sql = "INSERT INTO comBusinessPartner
// $stmt = $conn->prepare($sql_str); (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,BizToDate,TaxNo,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId)
// $stmt->bindParam(':contract_no', $contract_no); VALUES(:BizPartnerId,:BizPartnerName,1,'TW',99999999,:TaxNo,:ContactAddress,:CreatorId,:CreateTime,'10')";
// $stmt->bindParam(':customer', $customer); $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':manager', $manager); $stmt->bindParam(':BizPartnerId', $repair_no); //報價單編號
// $stmt->bindParam(':vat', $vat); $stmt->bindParam(':BizPartnerName', $company);
// $stmt->bindParam(':case_name', $case_name); $stmt->bindParam(':TaxNo', $taxid);
// $stmt->bindParam(':linkman', $linkman); $stmt->bindParam(':ContactAddress', $address);
// $stmt->bindParam(':lm_tel', $lm_tel); $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':address', $address); $stmt->bindParam(':CreateTime', $create);
// $stmt->bindParam(':salesman', $salesman); $stmt->execute();
// $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();
// }
// 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 . '<br/>';
// $src_name = $path . $file['name'];
// if (file_exists($src_name)) {
// //副檔名
// $extname = pathinfo($src_name, PATHINFO_EXTENSION);
// //主檔名
// $basename = basename($src_name, '.' . $extname);
// }
// }
// } else {
// $files = null;
// }
// $conn->commit();
// } catch (PDOException $e) { $connT8->commit();
// $conn->rollback(); }
// header("HTTP/1.1 500 Internal Server Error");
// die('Error!:' . $e->getMessage());
// }
// }

4
wms/contract-repair/js/alpine.js

@ -328,7 +328,7 @@ const contractRepair = () => {
nextStepFn() { nextStepFn() {
if (this.data.contractno == '') return alert('合約號為必填') if (this.data.repair_no == '') return alert('合約號為必填')
this.isLoading = true this.isLoading = true
if (this.step == 1) { if (this.step == 1) {
this.getContractDate(); this.getContractDate();
@ -503,7 +503,7 @@ const contractInput = () => {
fail_arr: [], fail_arr: [],
nextStepFn() { nextStepFn() {
if (this.step == 1) { if (this.step == 1) {
if (this.data.repair_no == '') return alert('請輸入合約號'); if (this.data.contractno == '') return alert('請輸入合約號');
this.isLoading = true this.isLoading = true
this.getContractDate(); this.getContractDate();
} else if (this.step == 2) { } else if (this.step == 2) {

1
wms/contract/api/postContractData.php

@ -374,6 +374,7 @@ function T8insert($data, $facilityno)
$endDate = str_replace("-", '', $contract_end_date); $endDate = str_replace("-", '', $contract_end_date);
if ($contractno == '') { if ($contractno == '') {
echo 'Error'; echo 'Error';
exit;
} }
if (empty($result)) { if (empty($result)) {
// 若 客戶資料為空,新增一筆到 comCustomer // 若 客戶資料為空,新增一筆到 comCustomer

16
wms/fun_global.php

@ -97,7 +97,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee)
} else { } else {
$ret[2] = "M0024,,<##>M0107,,"; // 業務部專員:M0024許伃廷、M0107許紓晴(第2關有多位審核人) $ret[2] = "M0024,,<##>M0107,,"; // 業務部專員:M0024許伃廷、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理 $ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0){ if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理 $ret[4] = "M0006,,"; // 總經理
} }
} }
@ -129,13 +129,14 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
} }
} }
mysqli_free_result($res); mysqli_free_result($res);
$ret[2] = 'M0012';
if ($renovate_flag == "REN") { if ($renovate_flag == "REN") {
if ($rate < 80) $ret[3] = "M0008"; // 詹總 // $ret[2] = 'M0012';
if ($rate < 60) $ret[4] = "M0006"; // 總經理 if ($rate < 1000) $ret[3] = "M0008"; // 詹總
if ($rate < 75) $ret[4] = "M0006"; // 總經理
} else { } else {
// 全汰改 // 全汰改
if ($rate < 80) $ret[3] = "M0008"; // 詹總 if ($rate < 1000) $ret[3] = "M0008"; // 詹總
if ($rate < 75) $ret[4] = "M0006"; // 總經理 if ($rate < 75) $ret[4] = "M0006"; // 總經理
} }
@ -612,15 +613,14 @@ function collect_month($contractday)
$latest_timestamp = $contractday; $latest_timestamp = $contractday;
$latest_date = new DateTime(); $latest_date = new DateTime();
$latest_date->setTimestamp($latest_timestamp); $latest_date->setTimestamp($latest_timestamp);
if($latest_timestamp < $today_date->getTimestamp()) { if ($latest_timestamp < $today_date->getTimestamp()) {
$interval = $latest_date->diff($today_date); $interval = $latest_date->diff($today_date);
$interval2 = $latest_date->diff($today_date); $interval2 = $latest_date->diff($today_date);
$year = $interval2->format('%y'); $year = $interval2->format('%y');
$month = $interval->format('%m'); $month = $interval->format('%m');
$total_month = $year * 12 + $month; $total_month = $year * 12 + $month;
return $total_month; return $total_month;
}else{ } else {
return 0; return 0;
} }
} }

24
wms/mkt/pricereview-index.php

@ -246,6 +246,10 @@ if ($data) :
} elseif ($data["status"] == "YS") { } elseif ($data["status"] == "YS") {
?> ?>
<a href="specsurvey-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey&token=<?= $token; ?>" class="btn btn-danger btn-sm">填規調</a> <a href="specsurvey-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey&token=<?= $token; ?>" class="btn btn-danger btn-sm">填規調</a>
<?php
} elseif ($data['status'] == 'YN') {
?>
<a href="specsurvey-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey&token=<?= $token; ?>" class="btn btn-danger btn-sm">重填規調</a>
<?php <?php
} }
} }
@ -457,19 +461,19 @@ if ($data) :
} }
</style> </style>
<td> <td>
<?php if (($data['status'] == 'YY' && $oneself) || ($data['status'] == 'YY' &&( $user_id == "M0174" || $user_id == 'M0225' || $user_id === "M0107" || $user_id === "M0060"))) : ?> <?php if (($data['status'] == 'YY' && $oneself) || ($data['status'] == 'YY' && ($user_id == "M0174" || $user_id == 'M0225' || $user_id === "M0107" || $user_id === "M0060"))) : ?>
<?php if(($user_id === "M0107" || $user_id === "M0060") && $data['applystatus'] < 3):?> <?php if (($user_id === "M0107" || $user_id === "M0060") && $data['applystatus'] < 3) : ?>
<span style="font-size:13px;font-weight:600">待申請</span> <span style="font-size:13px;font-weight:600">待申請</span>
<?php elseif($data['applystatus'] < 3): ?> <?php elseif ($data['applystatus'] < 3) : ?>
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>"> <a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">
<?php if ($data['applystatus'] < 1) { <?php if ($data['applystatus'] < 1) {
echo "申請"; echo "申請";
} else { } else {
echo "檢視"; echo "檢視";
} ?> } ?>
</a><br> </a><br>
<?php endif; ?> <?php endif; ?>
<?php else: ?> <?php else : ?>
<?php endif; ?> <?php endif; ?>

46
wms/mkt/pricereview-record-submit.php

@ -1,6 +1,7 @@
<?php <?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
//print_r($_POST);exit; print_r($_POST);
exit;
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
@ -67,9 +68,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; $temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"]; $file_size = $_FILES["attatch1"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $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; $upload_ok = 1;
foreach (glob($target_dir.$vol_no."-price-*") as $todelfile) { foreach (glob($target_dir . $vol_no . "-price-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); $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"]; $temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"]; $file_size = $_FILES["attatch2"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $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; $upload_ok = 1;
foreach (glob($target_dir.$vol_no."-appendix-*") as $todelfile) { foreach (glob($target_dir . $vol_no . "-appendix-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); $upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
@ -156,7 +157,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
*/ */
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($item_spec_arr); $i++) { for ($i = 0; $i < count($item_spec_arr); $i++) {
$spec = trim($item_spec_arr[$i]); $spec = trim($item_spec_arr[$i]);
if (empty($spec)) continue; if (empty($spec)) continue;
if (!$fp_id_arr[$i]) $fp_id_arr[$i] = 0; if (!$fp_id_arr[$i]) $fp_id_arr[$i] = 0;
@ -168,8 +169,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($item_price_arr[$i])) $item_price_arr[$i] = 0; if (empty($item_price_arr[$i])) $item_price_arr[$i] = 0;
//$gross_profit_arr[$i] = str_replace(",", "", $gross_profit_arr[$i]); //$gross_profit_arr[$i] = str_replace(",", "", $gross_profit_arr[$i]);
if (empty($gross_profit_arr[$i])) $gross_profit_arr[$i] = 0; 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); $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]; $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 = "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')"; $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); $result = mysqli_query($link, $db_query);
@ -188,7 +189,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_memo_arr = explode("@@,", rtrim($option_memo_all, "@@")); $option_memo_arr = explode("@@,", rtrim($option_memo_all, "@@"));
$option_relate_facil_arr = explode(",", htmlspecialchars_decode($option_relate_facil_all)); $option_relate_facil_arr = explode(",", htmlspecialchars_decode($option_relate_facil_all));
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($option_seat_arr); $i++) { for ($i = 0; $i < count($option_seat_arr); $i++) {
$spec = trim($option_seat_arr[$i]); $spec = trim($option_seat_arr[$i]);
if (empty($spec)) continue; if (empty($spec)) continue;
$option_unit_price_arr[$i] = str_replace(",", "", $option_unit_price_arr[$i]); $option_unit_price_arr[$i] = str_replace(",", "", $option_unit_price_arr[$i]);
@ -197,7 +198,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_relate_spec = ""; $option_relate_spec = "";
$tmp_arr = explode("<br>", $option_relate_facil_arr[$i]); $tmp_arr = explode("<br>", $option_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) { 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, ","); $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_memo_arr = explode("@@,", rtrim($mn_memo_all, "@@"));
$mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all)); $mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all));
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($mn_seat_arr); $i++) { for ($i = 0; $i < count($mn_seat_arr); $i++) {
if (empty($mn_kind_arr[$i])) continue; if (empty($mn_kind_arr[$i])) continue;
$mn_unit_price_arr[$i] = str_replace(",", "", $mn_unit_price_arr[$i]); $mn_unit_price_arr[$i] = str_replace(",", "", $mn_unit_price_arr[$i]);
$mn_qty_arr[$i] = str_replace(",", "", $mn_qty_arr[$i]); $mn_qty_arr[$i] = str_replace(",", "", $mn_qty_arr[$i]);
$mn_price_bp_arr[$i] = str_replace(",", "", $mn_price_bp_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]; $note = $mn_seat_arr[$i] . "," . $mn_numberofstop_arr[$i] . "," . $mn_speed_arr[$i];
$option_relate_spec = ""; $option_relate_spec = "";
$tmp_arr = explode("<br>", $mn_relate_facil_arr[$i]); $tmp_arr = explode("<br>", $mn_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) { 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, ","); $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 = "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_qty_arr = explode(",", $except_qty_all);
$except_price_bp_arr = explode(",", $except_price_bp_all); $except_price_bp_arr = explode(",", $except_price_bp_all);
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($except_spec_arr); $i++) { for ($i = 0; $i < count($except_spec_arr); $i++) {
$spec = trim($except_spec_arr[$i]); $spec = trim($except_spec_arr[$i]);
if (empty($spec)) continue; if (empty($spec)) continue;
$except_unit_price_arr[$i] = str_replace(",", "", $except_unit_price_arr[$i]); $except_unit_price_arr[$i] = str_replace(",", "", $except_unit_price_arr[$i]);
@ -270,7 +271,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$pay_scale_arr = explode(",", $pay_scale_all); $pay_scale_arr = explode(",", $pay_scale_all);
$pay_amount_arr = explode(",", $pay_amount_all); $pay_amount_arr = explode(",", $pay_amount_all);
$pay_period_arr = explode(",", $pay_period_all); $pay_period_arr = explode(",", $pay_period_all);
for ($i=0; $i<7; $i++) { for ($i = 0; $i < 7; $i++) {
$pay_scale_arr[$i] = (empty($pay_scale_arr[$i])) ? 0 : $pay_scale_arr[$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]; $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 = "insert into pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period, pay_note) values ";
@ -292,7 +293,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
elseif ($k == 3) $sign3 = $v; elseif ($k == 3) $sign3 = $v;
else $sign4 = $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)."')"; $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); mysqli_query($link, $sql);
// 寫入待簽表 // 寫入待簽表
if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1); if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1);
@ -311,9 +312,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($ret as $uid => $uemail) { 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; $sendmail = new Cmail;
$title = "【新梯價審通知】卷號:".$contractno; $title = "【新梯價審通知】卷號:" . $contractno;
$content = "<p>您有待簽核案件,請至<a href=\"http://oa.masada.com.tw\">客戶管理 > 價格審查_新梯</a>,點擊「待簽核」進行作業,謝謝!</p>"; $content = "<p>您有待簽核案件,請至<a href=\"http://oa.masada.com.tw\">客戶管理 > 價格審查_新梯</a>,點擊「待簽核」進行作業,謝謝!</p>";
$sendmail->sendx($title, $content, $mail_list); $sendmail->sendx($title, $content, $mail_list);
} }
@ -324,14 +325,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type = 'text/JavaScript'>"; echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."成功');"; echo "alert('" . $st_str . "成功');";
echo "location.href='pricereview-index.php?function_name=pricereview&".$token_link."';"; echo "location.href='pricereview-index.php?function_name=pricereview&" . $token_link . "';";
echo "</script>"; echo "</script>";
} else { } else {
echo "<script type = 'text/JavaScript'>"; echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."失敗,請重新操作');"; echo "alert('" . $st_str . "失敗,請重新操作');";
echo "location.href='pricereview-index.php?function_name=pricereview&".$token_link."';"; echo "location.href='pricereview-index.php?function_name=pricereview&" . $token_link . "';";
echo "</script>"; echo "</script>";
} }
} }
?>

1657
wms/mkt/pricereview_renovate-check.php

File diff suppressed because it is too large

41
wms/mkt/pricereview_renovate-create.php

@ -2,6 +2,15 @@
include "../header.php"; include "../header.php";
$vol_no = $_REQUEST["vol_no"]; // 從有望客戶過來:卷號 $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'"; $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"){
*/ */
?> ?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
<!--
<div>
<label for="contractno">卷號</label>
<input type="text" name="contractno" id="contractno" maxlength="7" required>
</div>
<div>
<label for="person">營業員</label>
<input type="text" name="person" id="person">
</div>
<div>
<label for="company">客戶名稱</label>
<input type="text" name="company" id="company" required>
</div>
<div>
<label for="case_name">案件名稱</label>
<input type="text" name="case_name" id="case_name" required>
</div>
<div>
<label for="address">工地地址</label>
<input type="text" name="address" id="address" required>
</div>
<div>
<label for="compete">競爭對手</label>
<input type="text" name="compete" id="compete">
</div>
-->
<div class="table-responsive"> <div class="table-responsive">
<table id="tb1" class="table table-bordered"> <table id="tb1" class="table table-bordered">
<thead> <thead>
@ -2476,7 +2460,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<input type="text" name="qty_total" id="qty_total" value="<?php echo $qty_total; ?>" readonly> <input type="text" name="qty_total" id="qty_total" value="<?php echo $qty_total; ?>" readonly>
</div> </div>
<div> <div>
<label for="special_fee">特殊費用</label> <label for="special_fee">服務費</label>
<input type="text" name="special_fee" id="special_fee" value="<?php if (isset($last_pr_arr["special_fee"])) echo number_format($last_pr_arr["special_fee"]); ?>"> <input type="text" name="special_fee" id="special_fee" value="<?php if (isset($last_pr_arr["special_fee"])) echo number_format($last_pr_arr["special_fee"]); ?>">
</div> </div>
<div> <div>
@ -2529,7 +2513,8 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
</div> </div>
<ul> <ul>
<li>業務員權限>=80%以上;<80-75%呈至業務協理審核<75%以下呈至總經理審核< /li> <li>營業權限>=85%以上;<85-80%呈至區處長審核<80%以下呈至總經理審核< /li>
</ul> </ul>
<div class="nextline"></div> <div class="nextline"></div>
<label for="attatch1">報價單</label> <label for="attatch1">報價單</label>

6
wms/mkt/pricereview_renovate-edit.php

@ -1,5 +1,4 @@
<?php <?php
phpinfo();
include "../header.php"; include "../header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
@ -2054,7 +2053,7 @@ foreach ($res as $data) {
<input type="text" name="qty_total" id="qty_total" readonly> <input type="text" name="qty_total" id="qty_total" readonly>
</div> </div>
<div> <div>
<label for="special_fee">特殊費用</label> <label for="special_fee">服務費</label>
<input type="text" name="special_fee" id="special_fee" value="<?php echo number_format($data["special_fee"]); ?>"> <input type="text" name="special_fee" id="special_fee" value="<?php echo number_format($data["special_fee"]); ?>">
</div> </div>
<div> <div>
@ -2103,9 +2102,8 @@ foreach ($res as $data) {
</tbody> </tbody>
</table> </table>
</div> </div>
<ul> <ul>
<li>業務員權限>=80%以上;<80-75%呈至業務協理審核<75%以下呈至總經理審核< /li> <li>營業員權限85%以上;85-80%呈至業務協理審核;80%以下呈至總經理審核。</li>
</ul> </ul>
<div class="nextline"></div> <div class="nextline"></div>
<label for="attatch1">報價單</label> <label for="attatch1">報價單</label>

40
wms/mkt/pricereview_renovate-index.php

@ -137,7 +137,7 @@ if ($data) :
?> ?>
<link rel="stylesheet" href="common.css"> <link rel="stylesheet" href="common.css">
<div style="overflow-x:auto; white-space:nowrap;"> <div style="overflow-x:auto; white-space:nowrap;">
<table id="table_index2" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <tr>
<th>項次</th> <th>項次</th>
@ -154,7 +154,8 @@ if ($data) :
<th>建檔時間</th> <th>建檔時間</th>
<th>功能</th> <th>功能</th>
<th>區經理</th> <th>區經理</th>
<th>工務副總</th> <th>服務助理</th>
<th>服務副總</th>
<th>總經理</th> <th>總經理</th>
<th>狀態</th> <th>狀態</th>
<th>合約書下載</th> <th>合約書下載</th>
@ -208,15 +209,30 @@ if ($data) :
<?php <?php
//if ($oneself && !($data["status"] == "YY" || $data["status"] == "YN")) { // 自己可以進行規調 //if ($oneself && !($data["status"] == "YY" || $data["status"] == "YN")) { // 自己可以進行規調
if ($oneself) { if ($oneself) {
// 重填價審只能有最新一筆,填規調只有最新一筆可以填。
$contractno = $data['contractno'];
$sql = "SELECT MAX(id),COUNT(*) FROM pricereview_main WHERE contractno = '$contractno' ORDER BY id DESC";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_row($result);
$maxContractID = $row[0];
$countContract = $row[1];
// echo '<pre>';
// print_r($maxContractID);
// echo '</pre>';
if ($data["status"] == "Y1") { if ($data["status"] == "Y1") {
?> ?>
<a href="pricereview_renovate-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a> <a href="pricereview_renovate-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a>
<a href="pricereview_renovate-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a> <a href="pricereview_renovate-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a>
<?php <?php
} elseif ($data["status"] == "YS") { } elseif ($data["status"] == "YS" && $countContract == 0) {
?> ?>
<a href="specsurvey_renovate-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">填規調</a> <a href="specsurvey_renovate-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">填規調</a>
<?php
} elseif ($data['status'] == "YN" && $data['id'] == $maxContractID) {
?>
<a href="pricereview_renovate-create.php?vol_no=<?= $data['contractno']; ?>&id=<?= $data['id'] ?>&function_name=pricereview_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">重填價審</a>
<?php <?php
} }
} }
?> ?>
@ -271,6 +287,24 @@ if ($data) :
//echo $str; //echo $str;
?> ?>
</td> </td>
<td>
<?php
$str = $uperson = $ustatus = $udtte = "";
if (!empty($sign2)) list($uperson, $ustatus, $udtte) = explode(",", $sign2);
if ($ustatus) {
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>";
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>";
$str .= "<br>" . $accountname_arr[$uperson] . "<br>" . $udtte;
} else {
if ($sign_st == 2 && $sign_nt == $user_id && $data["status"] == "YS") {
$str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "待簽核";
$str = "<a href=\"pricereview_renovate-check.php?st=2&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>";
} else $str = "--";
}
echo $str;
?>
</td>
<td> <td>
<?php <?php
$str = $uperson = $ustatus = $udtte = ""; $str = $uperson = $ustatus = $udtte = "";

60
wms/mkt/pricereview_renovate-record-submit.php

@ -1,4 +1,5 @@
<?php <?php
/** /**
* 沒有選擇M1/M4的-->全汰改 * 沒有選擇M1/M4的-->全汰改
*/ */
@ -70,9 +71,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; $temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"]; $file_size = $_FILES["attatch1"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $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; $upload_ok = 1;
foreach (glob($target_dir.$vol_no."-price-*") as $todelfile) { foreach (glob($target_dir . $vol_no . "-price-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
@ -84,9 +85,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch2"]["tmp_name"]; $temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"]; $file_size = $_FILES["attatch2"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $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; $upload_ok = 1;
foreach (glob($target_dir.$vol_no."-appendix-*") as $todelfile) { foreach (glob($target_dir . $vol_no . "-appendix-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); $upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
@ -151,16 +152,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$item_price_ct2_arr = []; $item_price_ct2_arr = [];
$price_total_item = 0; $price_total_item = 0;
foreach ($item_qty_arr as $k => $v) { foreach ($item_qty_arr as $k => $v) {
$price = floor(($price_total/array_sum($item_qty_arr))*$v); $price = floor(($price_total / array_sum($item_qty_arr)) * $v);
$item_price_ct2_arr[] = $price; $item_price_ct2_arr[] = $price;
if ($k < count($item_qty_arr)-1) $price_total_item += $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_ct2_arr[count($item_qty_arr) - 1] = $price_total - $price_total_item;
$item_price_ct_arr = $item_price_ct2_arr; $item_price_ct_arr = $item_price_ct2_arr;
} }
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($item_spec_arr); $i++) { for ($i = 0; $i < count($item_spec_arr); $i++) {
$spec = trim($item_spec_arr[$i]); $spec = trim($item_spec_arr[$i]);
if (empty($spec)) continue; if (empty($spec)) continue;
if (!$fp_id_arr[$i]) $fp_id_arr[$i] = 0; if (!$fp_id_arr[$i]) $fp_id_arr[$i] = 0;
@ -172,8 +173,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($item_price_arr[$i])) $item_price_arr[$i] = 0; if (empty($item_price_arr[$i])) $item_price_arr[$i] = 0;
//$gross_profit_arr[$i] = str_replace(",", "", $gross_profit_arr[$i]); //$gross_profit_arr[$i] = str_replace(",", "", $gross_profit_arr[$i]);
if (empty($gross_profit_arr[$i])) $gross_profit_arr[$i] = 0; 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); $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]; $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 = "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')"; $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); $result = mysqli_query($link, $db_query);
@ -192,7 +193,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_memo_arr = explode("@@,", rtrim($option_memo_all, "@@")); $option_memo_arr = explode("@@,", rtrim($option_memo_all, "@@"));
$option_relate_facil_arr = explode(",", htmlspecialchars_decode($option_relate_facil_all)); $option_relate_facil_arr = explode(",", htmlspecialchars_decode($option_relate_facil_all));
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($option_seat_arr); $i++) { for ($i = 0; $i < count($option_seat_arr); $i++) {
$spec = trim($option_seat_arr[$i]); $spec = trim($option_seat_arr[$i]);
if (empty($spec)) continue; if (empty($spec)) continue;
$option_unit_price_arr[$i] = str_replace(",", "", $option_unit_price_arr[$i]); $option_unit_price_arr[$i] = str_replace(",", "", $option_unit_price_arr[$i]);
@ -201,7 +202,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_relate_spec = ""; $option_relate_spec = "";
$tmp_arr = explode("<br>", $option_relate_facil_arr[$i]); $tmp_arr = explode("<br>", $option_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) { 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, ","); $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 = "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 (";
@ -220,7 +221,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$demolition_qty_arr = explode(",", $demolition_qty_all); $demolition_qty_arr = explode(",", $demolition_qty_all);
$demolition_price_bp_arr = explode(",", $demolition_price_bp_all); $demolition_price_bp_arr = explode(",", $demolition_price_bp_all);
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($seat_arr); $i++) { for ($i = 0; $i < count($seat_arr); $i++) {
$spec = trim($seat_arr[$i]); $spec = trim($seat_arr[$i]);
if (!$spec) continue; if (!$spec) continue;
$demolition_unit_price_arr[$i] = str_replace(",", "", $demolition_unit_price_arr[$i]); $demolition_unit_price_arr[$i] = str_replace(",", "", $demolition_unit_price_arr[$i]);
@ -246,16 +247,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$mn_memo_arr = explode("@@,", rtrim($mn_memo_all, "@@")); $mn_memo_arr = explode("@@,", rtrim($mn_memo_all, "@@"));
$mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all)); $mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all));
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($mn_seat_arr); $i++) { for ($i = 0; $i < count($mn_seat_arr); $i++) {
if (empty($mn_kind_arr[$i])) continue; if (empty($mn_kind_arr[$i])) continue;
$mn_unit_price_arr[$i] = str_replace(",", "", $mn_unit_price_arr[$i]); $mn_unit_price_arr[$i] = str_replace(",", "", $mn_unit_price_arr[$i]);
$mn_qty_arr[$i] = str_replace(",", "", $mn_qty_arr[$i]); $mn_qty_arr[$i] = str_replace(",", "", $mn_qty_arr[$i]);
$mn_price_bp_arr[$i] = str_replace(",", "", $mn_price_bp_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]; $note = $mn_seat_arr[$i] . "," . $mn_numberofstop_arr[$i] . "," . $mn_speed_arr[$i];
$option_relate_spec = ""; $option_relate_spec = "";
$tmp_arr = explode("<br>", $mn_relate_facil_arr[$i]); $tmp_arr = explode("<br>", $mn_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) { 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, ","); $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 = "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 (";
@ -273,7 +274,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$except_qty_arr = explode(",", $except_qty_all); $except_qty_arr = explode(",", $except_qty_all);
$except_price_bp_arr = explode(",", $except_price_bp_all); $except_price_bp_arr = explode(",", $except_price_bp_all);
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($except_spec_arr); $i++) { for ($i = 0; $i < count($except_spec_arr); $i++) {
$spec = trim($except_spec_arr[$i]); $spec = trim($except_spec_arr[$i]);
if (empty($spec)) continue; if (empty($spec)) continue;
$except_unit_price_arr[$i] = str_replace(",", "", $except_unit_price_arr[$i]); $except_unit_price_arr[$i] = str_replace(",", "", $except_unit_price_arr[$i]);
@ -290,7 +291,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$pay_scale_arr = explode(",", $pay_scale_all); $pay_scale_arr = explode(",", $pay_scale_all);
$pay_amount_arr = explode(",", $pay_amount_all); $pay_amount_arr = explode(",", $pay_amount_all);
$pay_period_arr = explode(",", $pay_period_all); $pay_period_arr = explode(",", $pay_period_all);
for ($i=0; $i<7; $i++) { for ($i = 0; $i < 7; $i++) {
$pay_scale_arr[$i] = (empty($pay_scale_arr[$i])) ? 0 : $pay_scale_arr[$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]; $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 = "insert into pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period, pay_note) values ";
@ -306,12 +307,12 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($manager_arr) { if ($manager_arr) {
$sign1 = $sign2 = $sign3 = $sign4 = ""; $sign1 = $sign2 = $sign3 = $sign4 = "";
foreach ($manager_arr as $k => $v) { foreach ($manager_arr as $k => $v) {
if ($k == 1) $sign1 = $v.",,"; if ($k == 1) $sign1 = $v . ",,";
elseif ($k == 2) $sign2 = $v.",,"; elseif ($k == 2) $sign2 = $v . ",,";
elseif ($k == 3) $sign3 = $v.",,"; elseif ($k == 3) $sign3 = $v . ",,";
else $sign4 = $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)."')"; $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); mysqli_query($link, $sql);
// 寫入待簽表 // 寫入待簽表
if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1); if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1);
@ -323,9 +324,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$ret = accountid2email($next_signer); $ret = accountid2email($next_signer);
if (!empty($ret)) { if (!empty($ret)) {
$mail_list[0] = [$next_signer, $ret[$next_signer]]; $mail_list[0] = [$next_signer, $ret[$next_signer]];
include dirname(__DIR__)."/class/Cmail.php"; include dirname(__DIR__) . "/class/Cmail.php";
$sendmail = new Cmail; $sendmail = new Cmail;
$title = "【汰改價審通知】卷號:".$contractno; $title = "【汰改價審通知】卷號:" . $contractno;
$content = "<p>您有待簽核案件,請至<a href=\"http://oa.masada.com.tw\">客戶管理 > 價格審查_汰改</a>,點擊「待簽核」進行作業,謝謝!</p>"; $content = "<p>您有待簽核案件,請至<a href=\"http://oa.masada.com.tw\">客戶管理 > 價格審查_汰改</a>,點擊「待簽核」進行作業,謝謝!</p>";
$sendmail->sendx($title, $content, $mail_list); $sendmail->sendx($title, $content, $mail_list);
} }
@ -336,14 +337,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type = 'text/JavaScript'>"; echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."成功');"; echo "alert('" . $st_str . "成功');";
echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&".$token_link."';"; echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&" . $token_link . "';";
echo "</script>"; echo "</script>";
} else { } else {
echo "<script type = 'text/JavaScript'>"; echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."失敗,請重新操作');"; echo "alert('" . $st_str . "失敗,請重新操作');";
echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&".$token_link."';"; echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&" . $token_link . "';";
echo "</script>"; echo "</script>";
} }
} }
?>
Loading…
Cancel
Save