diff --git a/wms/assemble_warehouse.xlsx b/wms/assemble_warehouse.xlsx
index 0302398d..7b6b9f71 100644
Binary files a/wms/assemble_warehouse.xlsx and b/wms/assemble_warehouse.xlsx differ
diff --git a/wms/contract/api/T8salIncomeApply.php b/wms/contract/api/T8salIncomeApply.php
index 2403d1a7..b0f4e018 100644
--- a/wms/contract/api/T8salIncomeApply.php
+++ b/wms/contract/api/T8salIncomeApply.php
@@ -3,9 +3,9 @@ require_once("../../T8_Authorization_from_bpm.php");
function T8API($data)
{
- echo '
';
- print_r(json_encode($data));
- echo '
';
+ // echo '';
+ // print_r(json_encode($data));
+ // echo '
';
$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
$validation = get_Auth();
@@ -16,19 +16,24 @@ function T8API($data)
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+ curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
- // $validation = $result['Data']['CHI_Authorization'];
- echo '';
- print_r($result);
- echo '
';
- return $result;
+ // 若 API 傳入失敗。
+ if ($result['Status'] == 'Erroe') {
+ echo 'API傳入失敗,' . $result['ErrorMsg'];
+ return $result;
+ } else {
+ // echo '';
+ // print_r($result);
+ // echo '
';
+ return $result;
+ }
}
curl_close($ch);
diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php
index 45c58743..3b00d2a9 100644
--- a/wms/contract/api/postContractData.php
+++ b/wms/contract/api/postContractData.php
@@ -8,343 +8,345 @@ include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei');
//保養簽回
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') {
- // try {
- $created_at = date('Y-m-d H:i:s');
- $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
- $total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null;
- $vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
- $mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null;
- $opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null;
- $phone = !empty($_POST['phone']) ? $_POST['phone'] : null;
- $email = !empty($_POST['email']) ? $_POST['email'] : null;
- $mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null;
- $mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null;
- $salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
- $contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null;
- $contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null;
- $address = !empty($_POST['address']) ? $_POST['address'] : null;
- $area = !empty($_POST['area']) ? $_POST['area'] : null;
- $customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
- $partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null;
- $partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null;
- $partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null;
- $partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null;
- $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
- $user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null;
- $num = !empty($_POST['num']) ? $_POST['num'] : null;
- $files = !empty($_FILES['files']) ? $_FILES['files'] : null;
- $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
- $payType = !empty($_POST['payType']) ? $_POST['payType'] : null;
- // validate
- $fail_arr = [];
- if ($contractno === '') return $fail_arr[] = '合約號為必填';
-
- if ($total_price == '') $fail_arr[] = '合約總價為必填';
- if ($vat == '') $fail_arr[] = '統一編號為必填';
- if ($mtype == '') $fail_arr[] = '維修型態為必填';
- if ($phone == '') $fail_arr[] = '客戶電話為必填';
- if ($email == '') $fail_arr[] = 'Email為必填';
- if ($mworker == '') $fail_arr[] = '保養員為必填';
- if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
- if ($salesman == '') $fail_arr[] = '營業員為必填';
- if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填';
- if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填';
- if ($address == '') $fail_arr[] = '地址為必填';
- if ($area == '') $fail_arr[] = '區域為必填';
- if ($customer == '') $fail_arr[] = '客戶為必填';
- if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
- if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
- if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
- if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
- if ($num == '') $fail_arr[] = '電梯數量為必填';
- if ($payType == '') $fail_arr[] = '付款方式為必填';
- if (count($fail_arr) > 0) {
- header("HTTP/1.1 422 Unprocessable Entity");
- echo json_encode($fail_arr);
- exit();
- }
+ try {
+ $created_at = date('Y-m-d H:i:s');
+ $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
+ $total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null;
+ $vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
+ $mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null;
+ $opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null;
+ $phone = !empty($_POST['phone']) ? $_POST['phone'] : null;
+ $email = !empty($_POST['email']) ? $_POST['email'] : null;
+ $mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null;
+ $mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null;
+ $salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
+ $contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null;
+ $contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null;
+ $address = !empty($_POST['address']) ? $_POST['address'] : null;
+ $area = !empty($_POST['area']) ? $_POST['area'] : null;
+ $customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
+ $partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null;
+ $partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null;
+ $partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null;
+ $partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null;
+ $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
+ $user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null;
+ $num = !empty($_POST['num']) ? $_POST['num'] : null;
+ $files = !empty($_FILES['files']) ? $_FILES['files'] : null;
+ $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
+ $payType = !empty($_POST['payType']) ? $_POST['payType'] : null;
+ // validate
+ $fail_arr = [];
+ if ($contractno === '') return $fail_arr[] = '合約號為必填';
+
+ if ($total_price == '') $fail_arr[] = '合約總價為必填';
+ if ($vat == '') $fail_arr[] = '統一編號為必填';
+ if ($mtype == '') $fail_arr[] = '維修型態為必填';
+ if ($phone == '') $fail_arr[] = '客戶電話為必填';
+ if ($email == '') $fail_arr[] = 'Email為必填';
+ if ($mworker == '') $fail_arr[] = '保養員為必填';
+ if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
+ if ($salesman == '') $fail_arr[] = '營業員為必填';
+ if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填';
+ if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填';
+ if ($address == '') $fail_arr[] = '地址為必填';
+ if ($area == '') $fail_arr[] = '區域為必填';
+ if ($customer == '') $fail_arr[] = '客戶為必填';
+ if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
+ if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
+ if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
+ if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
+ if ($num == '') $fail_arr[] = '電梯數量為必填';
+ if ($payType == '') $fail_arr[] = '付款方式為必填';
+ if (count($fail_arr) > 0) {
+ header("HTTP/1.1 422 Unprocessable Entity");
+ echo json_encode($fail_arr);
+ exit();
+ }
- //create account table
- $accounttype = "A";
- $accountid = $vat;
- $pwd = "123";
- $name = $partyA;
- $tel = $phone ?? '';
- $repairerid = $mworker;
- $creater = $user_id;
- $create_at = date('Y-m-d H:i:s');
-
- // $conn->beginTransaction();
-
- // $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
- // $stmt = $conn->prepare($sql_str);
- // $stmt->bindParam(':accounttype', $accounttype);
- // $stmt->bindParam(':accountid', $accountid);
- // $stmt->bindParam(':pwd', $pwd);
- // $stmt->bindParam(':name', $name);
- // $stmt->bindParam(':tel', $tel);
- // $stmt->bindParam(':address', $address);
- // $stmt->bindParam(':email', $email);
- // $stmt->bindParam(':repairerid', $repairerid);
- // $stmt->bindParam(':creater', $creater);
- // $stmt->bindParam(':create_at', $create_at);
- // $stmt->execute();
-
- //create contract table
-
- $contracttype = $mtype;
- $company = $partyA;
- $taxid = $vat;
- $tel = $phone;
- $promiser = $partyA;
- $contractperson = $partyA;
-
- $contractaddress = $address;
- $contracttel = $phone;
- $contractemail = $email;
- $contract_employee = $salesman;
- $start_date = $contract_begin_date;
- $end_date = $contract_end_date;
-
- // $sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)";
- // $stmt = $conn->prepare($sql_str);
- // $stmt->bindParam(':contracttype', $contracttype);
- // $stmt->bindParam(':contractno', $contractno);
- // $stmt->bindParam(':company', $company);
- // $stmt->bindParam(':taxid', $taxid);
- // $stmt->bindParam(':address', $address);
- // $stmt->bindParam(':tel', $tel);
- // $stmt->bindParam(':promiser', $promiser);
- // $stmt->bindParam(':contractperson', $contractperson);
- // $stmt->bindParam(':contractaddress', $contractaddress);
- // $stmt->bindParam(':contracttel', $contracttel);
- // $stmt->bindParam(':contractemail', $contractemail);
- // $stmt->bindParam(':contract_employee', $contract_employee);
- // $stmt->bindParam(':start_date', $start_date);
- // $stmt->bindParam(':end_date', $end_date);
- // $stmt->bindParam(':creater', $creater);
- // $stmt->bindParam(':create_at', $create_at);
- // $stmt->execute();
-
- //create facility table
- $createFacilityNo = new CreateFacilityNo();
- $dailyNecessities = [
- 'MAE100' => 'X',
- 'MAM200' => 'W',
- 'MAH100' => 'H',
- 'MAQ100' => 'Z',
- 'MAF100' => 'F',
- 'MAZ100' => 'B',
- ];
- $facility_arr = [];
- foreach ($elevators as $elevator) {
- $facility_arr[] = $dailyNecessities[$elevator['spec']];
- }
- echo json_encode($facility_arr);
- // 電梯做番號
- $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
- // if ($user_id == 'M0225') {
- // echo '';
- // print_r($facilityno);
- // echo '
';
- // exit();
- // }
- echo json_encode($facilityno);
- echo '-------';
- $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
- $stmt = $conn->prepare($sql_str);
- $stmt->bindParam(':accountid', $mworker);
- $stmt->execute();
- $worker = $stmt->fetch(PDO::FETCH_ASSOC);
- $customerid = $vat;
- $define = "B";
- $repairtype = $mtype;
- $repairerid = $mworker;
- $repairername = $worker['name'];
- // foreach ($elevators as $idx => $elevator) {
- // $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate)
- // VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)";
- // $stmt = $conn->prepare($sql_str);
- // $stmt->bindParam(':contractno', $contractno);
- // $stmt->bindParam(':define', $define);
- // $stmt->bindParam(':facilityno', $facilityno[$idx]);
- // $stmt->bindParam(':latitude', $elevator['latitude']);
- // $stmt->bindParam(':longitude', $elevator['longitude']);
- // $stmt->bindParam(':customerid', $customerid);
- // $stmt->bindParam(':weight', $elevator['weight']);
- // $stmt->bindParam(':numberofpassenger', $elevator['persons']);
- // $stmt->bindParam(':numberofstop', $elevator['stop']);
- // $stmt->bindParam(':numberoffloor', $elevator['floors']);
- // $stmt->bindParam(':opentype', $elevator['opendoor']);
- // $stmt->bindParam(':speed', $elevator['speed']);
- // $stmt->bindParam(':repairtype', $repairtype);
- // $stmt->bindParam(':maintainance', $elevator['maintainance']);
- // $stmt->bindParam(':facility_kind', $elevator['spec']);
- // $stmt->bindParam(':address', $address);
- // $stmt->bindParam(':repairerid', $repairerid);
- // $stmt->bindParam(':repairername', $repairername);
- // $stmt->bindParam(':creater', $creater);
- // $stmt->bindParam(':create_at', $create_at);
- // $stmt->bindParam(':area', $area);
- // $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
- // $stmt->bindParam(':licensedate', $elevator['useful_date']);
- // $result = $stmt->execute();
- // }
-
- //create schedule table
-
- $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
- $comboArr = json_decode($comboNo->getComboNo(), true);
- // foreach ($facilityno as $no) {
- // foreach ($comboArr as $combo) {
- // $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
- // $stmt = $conn->prepare($sql_str);
- // $stmt->bindParam(':contractno', $contractno);
- // $stmt->bindParam(':facilityno', $no);
- // $stmt->bindParam(':combono', $combo[0]);
- // $stmt->bindParam(':repairerid', $repairerid);
- // $stmt->bindParam(':repairername', $repairername);
- // $stmt->bindParam(':duedate', $combo[1]);
- // $stmt->bindParam(':creater', $creater);
- // $stmt->bindParam(':create_at', $create_at);
- // $result = $stmt->execute();
- // }
- // }
- // create contract_b_signed_back table
- $contract_type = $mtype;
- $company = $customer;
- $customer_no = $vat;
- $salesperson = $salesman;
- $customer_phone = $phone;
- $customer_email = $email;
- $repairman = $mworker;
- $cycle = $mcycle;
- $contact_person = $partyA;
- $contact_address = $partyAaddress;
- $contact_phone = $partyAphone;
- $contract_email = $partyAemail;
- $elevators_number = $num;
- $bonus = 1000;
- $max_bonus = 2000;
-
- if (!empty($files)) {
- $englisharr = range('a', 'z');
- $file = $_FILES['files'];
- $file_name = $file['name'];
- $file_type = $file['type'];
- $tmp_name = $file['tmp_name'];
- $file_size = $file['size'];
- $error = $file['error'];
- $newfiles = [];
- foreach ($files as $file) {
- $i = 0; //新陣列的索引編號
- foreach ($file as $key => $val) {
- $newfiles[$i]['name'] = $files['name'][$key];
- $newfiles[$i]['type'] = $files['type'][$key];
- $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
- $newfiles[$i]['error'] = $files['error'][$key];
- $newfiles[$i]['size'] = $files['size'][$key];
- $i++;
- } //foreach 第2層 end
+ //create account table
+ $accounttype = "A";
+ $accountid = $vat;
+ $pwd = "123";
+ $name = $partyA;
+ $tel = $phone ?? '';
+ $repairerid = $mworker;
+ $creater = $user_id;
+ $create_at = date('Y-m-d H:i:s');
+
+ $conn->beginTransaction();
+
+ $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
+ $stmt = $conn->prepare($sql_str);
+ $stmt->bindParam(':accounttype', $accounttype);
+ $stmt->bindParam(':accountid', $accountid);
+ $stmt->bindParam(':pwd', $pwd);
+ $stmt->bindParam(':name', $name);
+ $stmt->bindParam(':tel', $tel);
+ $stmt->bindParam(':address', $address);
+ $stmt->bindParam(':email', $email);
+ $stmt->bindParam(':repairerid', $repairerid);
+ $stmt->bindParam(':creater', $creater);
+ $stmt->bindParam(':create_at', $create_at);
+ $stmt->execute();
+
+ //create contract table
+
+ $contracttype = $mtype;
+ $company = $partyA;
+ $taxid = $vat;
+ $tel = $phone;
+ $promiser = $partyA;
+ $contractperson = $partyA;
+
+ $contractaddress = $address;
+ $contracttel = $phone;
+ $contractemail = $email;
+ $contract_employee = $salesman;
+ $start_date = $contract_begin_date;
+ $end_date = $contract_end_date;
+
+ $sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)";
+ $stmt = $conn->prepare($sql_str);
+ $stmt->bindParam(':contracttype', $contracttype);
+ $stmt->bindParam(':contractno', $contractno);
+ $stmt->bindParam(':company', $company);
+ $stmt->bindParam(':taxid', $taxid);
+ $stmt->bindParam(':address', $address);
+ $stmt->bindParam(':tel', $tel);
+ $stmt->bindParam(':promiser', $promiser);
+ $stmt->bindParam(':contractperson', $contractperson);
+ $stmt->bindParam(':contractaddress', $contractaddress);
+ $stmt->bindParam(':contracttel', $contracttel);
+ $stmt->bindParam(':contractemail', $contractemail);
+ $stmt->bindParam(':contract_employee', $contract_employee);
+ $stmt->bindParam(':start_date', $start_date);
+ $stmt->bindParam(':end_date', $end_date);
+ $stmt->bindParam(':creater', $creater);
+ $stmt->bindParam(':create_at', $create_at);
+ $stmt->execute();
+
+ //create facility table
+ $createFacilityNo = new CreateFacilityNo();
+ $dailyNecessities = [
+ 'MAE100' => 'X',
+ 'MAM200' => 'W',
+ 'MAH100' => 'H',
+ 'MAQ100' => 'Z',
+ 'MAF100' => 'F',
+ 'MAZ100' => 'B',
+ ];
+ $facility_arr = [];
+ foreach ($elevators as $elevator) {
+ $facility_arr[] = $dailyNecessities[$elevator['spec']];
}
- $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
- $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型
- $path = '../images/contracts/';
- if (!file_exists($path)) {
- mkdir($path);
+ echo json_encode($facility_arr);
+ // 電梯做番號
+ $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
+ // if ($user_id == 'M0225') {
+ // echo '';
+ // print_r($facilityno);
+ // echo '
';
+ // exit();
+ // }
+ echo json_encode($facilityno);
+ echo '-------';
+ $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
+ $stmt = $conn->prepare($sql_str);
+ $stmt->bindParam(':accountid', $mworker);
+ $stmt->execute();
+ $worker = $stmt->fetch(PDO::FETCH_ASSOC);
+ $customerid = $vat;
+ $define = "B";
+ $repairtype = $mtype;
+ $repairerid = $mworker;
+ $repairername = $worker['name'];
+ foreach ($elevators as $idx => $elevator) {
+ $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate)
+ VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)";
+ $stmt = $conn->prepare($sql_str);
+ $stmt->bindParam(':contractno', $contractno);
+ $stmt->bindParam(':define', $define);
+ $stmt->bindParam(':facilityno', $facilityno[$idx]);
+ $stmt->bindParam(':latitude', $elevator['latitude']);
+ $stmt->bindParam(':longitude', $elevator['longitude']);
+ $stmt->bindParam(':customerid', $customerid);
+ $stmt->bindParam(':weight', $elevator['weight']);
+ $stmt->bindParam(':numberofpassenger', $elevator['persons']);
+ $stmt->bindParam(':numberofstop', $elevator['stop']);
+ $stmt->bindParam(':numberoffloor', $elevator['floors']);
+ $stmt->bindParam(':opentype', $elevator['opendoor']);
+ $stmt->bindParam(':speed', $elevator['speed']);
+ $stmt->bindParam(':repairtype', $repairtype);
+ $stmt->bindParam(':maintainance', $elevator['maintainance']);
+ $stmt->bindParam(':facility_kind', $elevator['spec']);
+ $stmt->bindParam(':address', $address);
+ $stmt->bindParam(':repairerid', $repairerid);
+ $stmt->bindParam(':repairername', $repairername);
+ $stmt->bindParam(':creater', $creater);
+ $stmt->bindParam(':create_at', $create_at);
+ $stmt->bindParam(':area', $area);
+ $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
+ $stmt->bindParam(':licensedate', $elevator['useful_date']);
+ $result = $stmt->execute();
}
- $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
- $datetime = (string)date('YmdHis');
- $files_id = 'b' . $datetime; // 保養=>b + 日期時間
- foreach ($newfiles as $key => $file) {
- $randNum = rand(1000, 9999);
- $randEnglish = $englisharr[rand(0, 25)];
- $file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name'];
- $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name);
- if ($msg == 1) {
- $msg = '檔案傳送成功!';
- $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
+
+ //create schedule table
+
+ $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
+ $comboArr = json_decode($comboNo->getComboNo(), true);
+ foreach ($facilityno as $no) {
+ foreach ($comboArr as $combo) {
+ $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
$stmt = $conn->prepare($sql_str);
- $stmt->bindParam(':files_id', $files_id);
- $stmt->bindParam(':file_name', $file_name);
- $stmt->bindParam(':file_mime', $file['type']);
- $stmt->bindParam(':file_size', $file['size']);
- $stmt->bindParam(':created_at', $created_at);
- $stmt->bindParam(':created_by', $user_id);
- $stmt->execute();
+ $stmt->bindParam(':contractno', $contractno);
+ $stmt->bindParam(':facilityno', $no);
+ $stmt->bindParam(':combono', $combo[0]);
+ $stmt->bindParam(':repairerid', $repairerid);
+ $stmt->bindParam(':repairername', $repairername);
+ $stmt->bindParam(':duedate', $combo[1]);
+ $stmt->bindParam(':creater', $creater);
+ $stmt->bindParam(':create_at', $create_at);
+ $result = $stmt->execute();
+ }
+ }
+ // create contract_b_signed_back table
+ $contract_type = $mtype;
+ $company = $customer;
+ $customer_no = $vat;
+ $salesperson = $salesman;
+ $customer_phone = $phone;
+ $customer_email = $email;
+ $repairman = $mworker;
+ $cycle = $mcycle;
+ $contact_person = $partyA;
+ $contact_address = $partyAaddress;
+ $contact_phone = $partyAphone;
+ $contract_email = $partyAemail;
+ $elevators_number = $num;
+ $bonus = 1000;
+ $max_bonus = 2000;
+
+ if (!empty($files)) {
+ $englisharr = range('a', 'z');
+ $file = $_FILES['files'];
+ $file_name = $file['name'];
+ $file_type = $file['type'];
+ $tmp_name = $file['tmp_name'];
+ $file_size = $file['size'];
+ $error = $file['error'];
+ $newfiles = [];
+ foreach ($files as $file) {
+ $i = 0; //新陣列的索引編號
+ foreach ($file as $key => $val) {
+ $newfiles[$i]['name'] = $files['name'][$key];
+ $newfiles[$i]['type'] = $files['type'][$key];
+ $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
+ $newfiles[$i]['error'] = $files['error'][$key];
+ $newfiles[$i]['size'] = $files['size'][$key];
+ $i++;
+ } //foreach 第2層 end
+ }
+ $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
+ $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型
+ $path = '../images/contracts/';
+ if (!file_exists($path)) {
+ mkdir($path);
}
- $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);
+ $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
+ $datetime = (string)date('YmdHis');
+ $files_id = 'b' . $datetime; // 保養=>b + 日期時間
+ foreach ($newfiles as $key => $file) {
+ $randNum = rand(1000, 9999);
+ $randEnglish = $englisharr[rand(0, 25)];
+ $file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name'];
+ $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name);
+ if ($msg == 1) {
+ $msg = '檔案傳送成功!';
+ $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
+ $stmt = $conn->prepare($sql_str);
+ $stmt->bindParam(':files_id', $files_id);
+ $stmt->bindParam(':file_name', $file_name);
+ $stmt->bindParam(':file_mime', $file['type']);
+ $stmt->bindParam(':file_size', $file['size']);
+ $stmt->bindParam(':created_at', $created_at);
+ $stmt->bindParam(':created_by', $user_id);
+ $stmt->execute();
+ }
+ $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '
';
+ $src_name = $path . $file['name'];
+ if (file_exists($src_name)) {
+ //副檔名
+ $extname = pathinfo($src_name, PATHINFO_EXTENSION);
+ //主檔名
+ $basename = basename($src_name, '.' . $extname);
+ }
}
+ } else {
+ $files = null;
}
- } else {
- $files = null;
- }
- $sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
+ $sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :payType ,:customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)";
- $stmt = $conn->prepare($sql_str);
- $stmt->bindParam(":contract_no", $contractno);
- $stmt->bindParam(":contract_type", $contract_type);
- $stmt->bindParam(":company", $company);
- $stmt->bindParam(":customer_no", $customer_no);
- $stmt->bindParam(":salesperson", $salesperson);
- $stmt->bindParam(":contract_start_date", $contract_begin_date);
- $stmt->bindParam(":contract_end_date", $contract_end_date);
- $stmt->bindParam(":total_price", $total_price);
- $stmt->bindParam(":customer_phone", $customer_phone);
- $stmt->bindParam(":customer_email", $customer_email);
- $stmt->bindParam(":repairman", $repairman);
- $stmt->bindParam(":cycle", $cycle);
- $stmt->bindParam(":contact_person", $contact_person);
- $stmt->bindParam(":contact_address", $contact_address);
- $stmt->bindParam(":contact_phone", $contact_phone);
- $stmt->bindParam(":contact_email", $contact_email);
- $stmt->bindParam(":elevators_number", $elevators_number);
- $stmt->bindParam(":area", $area);
- $stmt->bindParam(":address", $address);
- $stmt->bindParam(":files_id", $files_id);
- $stmt->bindParam(":bonus", $bonus);
- $stmt->bindParam(":max_bonus", $max_bonus);
- $stmt->bindParam(":created_at", $created_at);
- $stmt->bindParam(":created_by", $user_id);
- $stmt->bindParam(':payType', $payType);
+ $stmt = $conn->prepare($sql_str);
+ $stmt->bindParam(":contract_no", $contractno);
+ $stmt->bindParam(":contract_type", $contract_type);
+ $stmt->bindParam(":company", $company);
+ $stmt->bindParam(":customer_no", $customer_no);
+ $stmt->bindParam(":salesperson", $salesperson);
+ $stmt->bindParam(":contract_start_date", $contract_begin_date);
+ $stmt->bindParam(":contract_end_date", $contract_end_date);
+ $stmt->bindParam(":total_price", $total_price);
+ $stmt->bindParam(":customer_phone", $customer_phone);
+ $stmt->bindParam(":customer_email", $customer_email);
+ $stmt->bindParam(":repairman", $repairman);
+ $stmt->bindParam(":cycle", $cycle);
+ $stmt->bindParam(":contact_person", $contact_person);
+ $stmt->bindParam(":contact_address", $contact_address);
+ $stmt->bindParam(":contact_phone", $contact_phone);
+ $stmt->bindParam(":contact_email", $contact_email);
+ $stmt->bindParam(":elevators_number", $elevators_number);
+ $stmt->bindParam(":area", $area);
+ $stmt->bindParam(":address", $address);
+ $stmt->bindParam(":files_id", $files_id);
+ $stmt->bindParam(":bonus", $bonus);
+ $stmt->bindParam(":max_bonus", $max_bonus);
+ $stmt->bindParam(":created_at", $created_at);
+ $stmt->bindParam(":created_by", $user_id);
+ $stmt->bindParam(':payType', $payType);
+
+ $stmt->execute();
+
+ // $date = date('Y-m-sH-s-i');
+ // $createTime = str_replace("-", '', $date);
+ // $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
+ // $stmt = $connT8->prepare($sql);
+ // $stmt->bindParam(':BizPartnerId', $contractno);
+ // $stmt->bindParam(':PersonId', $salesman);
+ // $stmt->bindParam(':CreatorId', $user_id);
+ // $stmt->bindParam(':InvoiceAddress', $address);
+ // $stmt->bindParam(':CreateTime', $createTime);
- $stmt->execute();
+ // $stmt->execute();
+ T8insert($_POST, $facilityno);
- // $date = date('Y-m-sH-s-i');
- // $createTime = str_replace("-", '', $date);
- // $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':BizPartnerId', $contractno);
- // $stmt->bindParam(':PersonId', $salesman);
- // $stmt->bindParam(':CreatorId', $user_id);
- // $stmt->bindParam(':InvoiceAddress', $address);
- // $stmt->bindParam(':CreateTime', $createTime);
-
- // $stmt->execute();
- T8insert($_POST, $facilityno);
-
- // header('Content-Type: application/json');
- // $jsonData = json_encode($files);
-
- // $conn->commit();
- // } catch (PDOException $e) {
- // $conn->rollback();
- // http_response_code(404);
- // echo $e->getMessage();
- // die('Error!:' . $e->getMessage());
- // }
+ header('Content-Type: application/json');
+ $jsonData = json_encode($files);
+
+ $conn->commit();
+ } catch (PDOException $e) {
+ $conn->rollback();
+ http_response_code(404);
+ echo $e->getMessage();
+ die('Error!:' . $e->getMessage());
+ }
};
function T8insert($data, $facilityno)
{
require_once("../connt8.php");
+ // 引入 T8 API 連線
require_once("./T8salIncomeApply.php");
+
$contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號
$address = !empty($data['address']) ? $data['address'] : null; // 客戶地址
$customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱
@@ -372,7 +374,7 @@ function T8insert($data, $facilityno)
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$date = date('Y-m-sH-s-i');
- $date_1 = date('Y-m-sH-s');
+ $date_1 = date('Y-m-s');
$createTime = str_replace("-", '', $date);
$insertTime = str_replace('-', '', $date_1);
$beginDate = str_replace("-", '', $contract_begin_date);
@@ -381,78 +383,78 @@ function T8insert($data, $facilityno)
echo 'Error';
exit;
}
- // if (empty($result)) {
- // // 若 客戶資料為空,新增一筆到 comCustomer
- // // 新增客戶資料
- // $sql = "INSERT INTO comBusinessPartner
- // (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId)
- // VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':BizPartnerId', $contractno);
- // $stmt->bindParam(':BizPartnerName', $partyA);
- // $stmt->bindParam(':WorkTelNo', $phone);
- // $stmt->bindParam(':TaxNo', $vat);
- // $stmt->bindParam(':EnterpriseName', $customer); //企業名稱
- // $stmt->bindParam(':ContactAddress', $partyAaddress);
- // $stmt->bindParam(':EMail', $email);
- // $stmt->bindParam(':CreatorId', $user_id);
- // $stmt->bindParam(':CreateTime', $createTime);
-
- // $stmt->execute();
-
- // $sql = "INSERT INTO comCustomer
- // (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)
- // VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
- // $stmt = $connT8->prepare($sql);
-
- // $stmt->bindParam(':BizPartnerId', $contractno);
- // $stmt->bindParam(':PersonId', $salesman);
- // $stmt->bindParam(':CreatorId', $user_id);
- // $stmt->bindParam(':InvoiceAddress', $address);
- // $stmt->bindParam(':CreateTime', $createTime);
-
- // $stmt->execute();
- // } else {
- // // // 若客戶資料不為空,更新該客戶資訊。
- // $sql = "UPDATE comCustomer SET
- // PersonId=:PersonId,
- // InvoiceAddress=:InvoiceAddress,
- // LastOperatorId=:LastOperatorId,
- // LastOperateTime=:LastOperateTime
- // WHERE BizPartnerId=:BizPartnerId
- // ";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':PersonId', $salesman);
- // $stmt->bindParam(':InvoiceAddress', $address);
- // $stmt->bindParam(':LastOperatorId', $user_id);
- // $stmt->bindParam(':LastOperateTime', $createTime);
- // $stmt->bindParam(':BizPartnerId', $contractno);
- // $stmt->execute();
-
-
- // $sql = "UPDATE comBusinessPartner SET
- // BizPartnerName=:BizPartnerName,
- // WorkTelNo=:WorkTelNo,
- // TaxNo=:TaxNo,
- // EnterpriseName=:EnterpriseName,
- // ContactAddress=:ContactAddress,
- // EMail=:EMail,
- // LastOperatorId=:LastOperatorId,
- // LastOperateTime=:LastOperateTime
- // WHERE BizPartnerId = :BizPartnerId
- // ";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':BizPartnerName', $partyA);
- // $stmt->bindParam(':WorkTelNo', $phone);
- // $stmt->bindParam(':TaxNo', $vat);
- // $stmt->bindParam(':EnterpriseName', $customer);
- // $stmt->bindParam(':ContactAddress', $partyAaddress);
- // $stmt->bindParam(':EMail', $email);
- // $stmt->bindParam(':LastOperatorId', $user_id);
- // $stmt->bindParam(':LastOperateTime', $createTime);
- // $stmt->bindParam(':BizPartnerId', $contractno);
- // $stmt->execute();
- // }
+ if (empty($result)) {
+ // 若 客戶資料為空,新增一筆到 comCustomer
+ // 新增客戶資料
+ $sql = "INSERT INTO comBusinessPartner
+ (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId)
+ VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':BizPartnerId', $contractno);
+ $stmt->bindParam(':BizPartnerName', $partyA);
+ $stmt->bindParam(':WorkTelNo', $phone);
+ $stmt->bindParam(':TaxNo', $vat);
+ $stmt->bindParam(':EnterpriseName', $customer); //企業名稱
+ $stmt->bindParam(':ContactAddress', $partyAaddress);
+ $stmt->bindParam(':EMail', $email);
+ $stmt->bindParam(':CreatorId', $user_id);
+ $stmt->bindParam(':CreateTime', $createTime);
+
+ $stmt->execute();
+
+ $sql = "INSERT INTO comCustomer
+ (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)
+ VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
+ $stmt = $connT8->prepare($sql);
+
+ $stmt->bindParam(':BizPartnerId', $contractno);
+ $stmt->bindParam(':PersonId', $salesman);
+ $stmt->bindParam(':CreatorId', $user_id);
+ $stmt->bindParam(':InvoiceAddress', $address);
+ $stmt->bindParam(':CreateTime', $createTime);
+
+ $stmt->execute();
+ } else {
+ // // 若客戶資料不為空,更新該客戶資訊。
+ $sql = "UPDATE comCustomer SET
+ PersonId=:PersonId,
+ InvoiceAddress=:InvoiceAddress,
+ LastOperatorId=:LastOperatorId,
+ LastOperateTime=:LastOperateTime
+ WHERE BizPartnerId=:BizPartnerId
+ ";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':PersonId', $salesman);
+ $stmt->bindParam(':InvoiceAddress', $address);
+ $stmt->bindParam(':LastOperatorId', $user_id);
+ $stmt->bindParam(':LastOperateTime', $createTime);
+ $stmt->bindParam(':BizPartnerId', $contractno);
+ $stmt->execute();
+
+
+ $sql = "UPDATE comBusinessPartner SET
+ BizPartnerName=:BizPartnerName,
+ WorkTelNo=:WorkTelNo,
+ TaxNo=:TaxNo,
+ EnterpriseName=:EnterpriseName,
+ ContactAddress=:ContactAddress,
+ EMail=:EMail,
+ LastOperatorId=:LastOperatorId,
+ LastOperateTime=:LastOperateTime
+ WHERE BizPartnerId = :BizPartnerId
+ ";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':BizPartnerName', $partyA);
+ $stmt->bindParam(':WorkTelNo', $phone);
+ $stmt->bindParam(':TaxNo', $vat);
+ $stmt->bindParam(':EnterpriseName', $customer);
+ $stmt->bindParam(':ContactAddress', $partyAaddress);
+ $stmt->bindParam(':EMail', $email);
+ $stmt->bindParam(':LastOperatorId', $user_id);
+ $stmt->bindParam(':LastOperateTime', $createTime);
+ $stmt->bindParam(':BizPartnerId', $contractno);
+ $stmt->execute();
+ }
// echo '';
// print_r($elevators['maintainance']);
// echo '
';
@@ -466,22 +468,25 @@ function T8insert($data, $facilityno)
$type = 'C5';
}
}
- // echo '';
- // print_r($type);
- // echo '
';
-
- // //新增於 comProject。合約 table
- // $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed)
- // VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,:ValidityToDate,:CreateTime,:CreatorId,1)";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':ProjectId', $contractno);
- // $stmt->bindParam(':ProjectName', $customer);
- // $stmt->bindParam(':TypeId', $type);
- // $stmt->bindParam(':ValidityFromDate', $beginDate);
- // $stmt->bindParam(':ValidityToDate', $endDate);
- // $stmt->bindParam(':CreateTime', $createTime);
- // $stmt->bindParam(':CreatorId', $user_id);
- // $stmt->execute();
+ $sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':ProjectId', $contractno);
+ $stmt->execute();
+ $resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ if (empty($resultProject)) {
+ //新增於 comProject。合約 table
+ $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed)
+ VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,:ValidityToDate,:CreateTime,:CreatorId,1)";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':ProjectId', $contractno);
+ $stmt->bindParam(':ProjectName', $customer);
+ $stmt->bindParam(':TypeId', $type);
+ $stmt->bindParam(':ValidityFromDate', $beginDate);
+ $stmt->bindParam(':ValidityToDate', $endDate);
+ $stmt->bindParam(':CreateTime', $createTime);
+ $stmt->bindParam(':CreatorId', $user_id);
+ $stmt->execute();
+ }
// // 新增電梯數
foreach ($elevators as $index => $elevator) {
@@ -489,35 +494,35 @@ function T8insert($data, $facilityno)
// print_r($elevator);
// echo '';
- // $sql = "INSERT INTO comMaterial
- // (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime)
- // VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':MaterialId', $facilityno[$index]);
- // $stmt->bindParam(':CreatorId', $user_id);
- // $stmt->bindParam(':CreateTime', $createTime);
- // $stmt->execute();
-
- // $sql = "INSERT INTO comMaterialGroup
- // (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime)
- // VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':MaterialId', $facilityno[$index]);
- // $stmt->bindParam(':MaterialName', $customer);
- // $stmt->bindParam(':CreatorId', $user_id);
- // $stmt->bindParam(':CreateTime', $createTime);
- // $stmt->execute();
-
- // $sql = "INSERT INTO comMaterialPurchases
- // (Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
- // VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)";
- // $stmt = $connT8->prepare($sql);
- // $stmt->bindParam(':MaterialId', $facilityno[$index]);
- // $stmt->bindParam(':CreatorId', $user_id);
- // $stmt->bindParam(':CreateTime', $createTime);
- // $stmt->execute();
-
- // $arr = [];
+ $sql = "INSERT INTO comMaterial
+ (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime)
+ VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':MaterialId', $facilityno[$index]);
+ $stmt->bindParam(':CreatorId', $user_id);
+ $stmt->bindParam(':CreateTime', $createTime);
+ $stmt->execute();
+
+ $sql = "INSERT INTO comMaterialGroup
+ (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime)
+ VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':MaterialId', $facilityno[$index]);
+ $stmt->bindParam(':MaterialName', $customer);
+ $stmt->bindParam(':CreatorId', $user_id);
+ $stmt->bindParam(':CreateTime', $createTime);
+ $stmt->execute();
+
+ $sql = "INSERT INTO comMaterialPurchases
+ (Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
+ VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)";
+ $stmt = $connT8->prepare($sql);
+ $stmt->bindParam(':MaterialId', $facilityno[$index]);
+ $stmt->bindParam(':CreatorId', $user_id);
+ $stmt->bindParam(':CreateTime', $createTime);
+ $stmt->execute();
+
+ // 分期代碼計算
$IncomeId = [
'A40006' => 1,
'A40007' => 4,
@@ -525,28 +530,35 @@ function T8insert($data, $facilityno)
'A40004' => 6,
'A40005' => 2
];
- $SQuantity = $elevator['maintain_months'] / $IncomeId[$payType]; //分幾期 => 總共保養月 / 分期月
+ //分幾期 => 總共保養月 / 分期月
+ $SQuantity = $elevator['maintain_months'] / $IncomeId[$payType];
+
+ // 依每台電梯去加入各個的付款項
for ($i = 1; $i <= $IncomeId[$payType]; $i++) {
$rows_data = [
- "BillNo" => " $contractno ",
- "IncomeId" => " $payType ",
+ "BillNo" => "$contractno",
+ "IncomeId" => "$payType",
"TaxId" => "ST005",
"RowCode" => $i,
"RowNo" => $i,
"ItemType" => 1,
"SPrice" => $elevator['sold_price'],
"SQuantity" => $SQuantity,
- "ProjectId" => " $contractno ",
+ "ProjectId" => "$contractno",
"FromSourceTag" => 0,
- "CU_MaterialId" => " $facilityno[$index] "
+ "CU_MaterialId" => "$facilityno[$index]"
];
$salIncomeApplyDetail_rows[] = $rows_data;
}
}
+ $connT8->commit();
+
+
+ // $insertime = settype($insertTime, 'integer');
$salIncomeApplyMaster_rows = [
"BillNo" => "$contractno",
- "BillDate" => $date_1,
+ "BillDate" => $insertTime,
"OrgId" => "1000",
"FOrgId" => "1000",
"TypeId" => "RAS",
@@ -574,7 +586,11 @@ function T8insert($data, $facilityno)
];
$API_body[] = $salIncomeApplyMaster;
$API_body[] = $salIncomeApplyDetail;
- T8API($API_body);
- // json_encode($API_body);
- // $connT8->commit();
+ // 呼叫 API
+ $result = T8API($API_body);
+
+ if ($result['Status'] == 'Error') {
+ http_response_code(404);
+ die('Error!:' . $result['ErrorMsg']);
+ }
}
diff --git a/wms/contract/api/test.json b/wms/contract/api/test.json
index 83da16d0..04729705 100644
--- a/wms/contract/api/test.json
+++ b/wms/contract/api/test.json
@@ -4,7 +4,7 @@
"rows": [
{
"BillNo": "B23100060",
- "BillDate": "2024-01-5215-52",
+ "BillDate": "20240122",
"OrgId": "1000",
"FOrgId": "1000",
"TypeId": "RAS",
@@ -26,89 +26,160 @@
"name": "salIncomeApplyDetail",
"rows": [
{
- "BillNo": " B23100060 ",
- "IncomeId": " A40007 ",
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 1,
"RowNo": 1,
"ItemType": 1,
"SPrice": 1250,
- "SQuantity": 3,
- "ProjectId": " B23100060 ",
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
"FromSourceTag": 0,
- "CU_MaterialId": " 4TZ53201 "
+ "CU_MaterialId": "4TH53801"
},
{
- "BillNo": " B23100060 ",
- "IncomeId": " A40007 ",
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 2,
"RowNo": 2,
"ItemType": 1,
"SPrice": 1250,
- "SQuantity": 3,
- "ProjectId": " B23100060 ",
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
"FromSourceTag": 0,
- "CU_MaterialId": " 4TZ53201 "
+ "CU_MaterialId": "4TH53801"
},
{
- "BillNo": " B23100060 ",
- "IncomeId": " A40007 ",
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 3,
"RowNo": 3,
"ItemType": 1,
"SPrice": 1250,
- "SQuantity": 3,
- "ProjectId": " B23100060 ",
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
"FromSourceTag": 0,
- "CU_MaterialId": " 4TZ53201 "
+ "CU_MaterialId": "4TH53801"
},
{
- "BillNo": " B23100060 ",
- "IncomeId": " A40007 ",
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
"TaxId": "ST005",
"RowCode": 4,
"RowNo": 4,
"ItemType": 1,
"SPrice": 1250,
- "SQuantity": 3,
- "ProjectId": " B23100060 ",
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
"FromSourceTag": 0,
- "CU_MaterialId": " 4TZ53201 "
- }
- ]
- }
-]
-
-
-[
- {
- "name": "OtherStockOutMtable",
- "rows": [
+ "CU_MaterialId": "4TH53801"
+ },
{
- "BillNo": "Z001",
- "BillDate": 20210427,
- "OrgId": "1000",
- "FOrgId": "1000",
- "TypeId": "OD",
- "BizPartnerId": "Z001",
- "PersonId": "Z001",
- "DeptId": "T001",
- "CompId": "1000"
- }
- ]
- },
- {
- "name": "OtherStockOutDetail",
- "rows": [
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 5,
+ "RowNo": 5,
+ "ItemType": 1,
+ "SPrice": 1250,
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
+ },
{
- "BillNo": "Z001",
- "RowCode": 1,
- "MaterialId": "Z001",
- "SupplyOrgId": "1000",
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 6,
+ "RowNo": 6,
+ "ItemType": 1,
+ "SPrice": 1250,
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
+ },
+ {
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 7,
+ "RowNo": 7,
+ "ItemType": 1,
+ "SPrice": 1250,
"SQuantity": 1,
- "WarehouseId": "10"
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
+ },
+ {
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 8,
+ "RowNo": 8,
+ "ItemType": 1,
+ "SPrice": 1250,
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
+ },
+ {
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 9,
+ "RowNo": 9,
+ "ItemType": 1,
+ "SPrice": 1250,
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
+ },
+ {
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 10,
+ "RowNo": 10,
+ "ItemType": 1,
+ "SPrice": 1250,
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
+ },
+ {
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 11,
+ "RowNo": 11,
+ "ItemType": 1,
+ "SPrice": 1250,
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
+ },
+ {
+ "BillNo": "B23100060",
+ "IncomeId": "A40003",
+ "TaxId": "ST005",
+ "RowCode": 12,
+ "RowNo": 12,
+ "ItemType": 1,
+ "SPrice": 1250,
+ "SQuantity": 1,
+ "ProjectId": "B23100060",
+ "FromSourceTag": 0,
+ "CU_MaterialId": "4TH53801"
}
]
}
diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php
index dab6cd29..39354c9b 100644
--- a/wms/contract/api/testT8API.php
+++ b/wms/contract/api/testT8API.php
@@ -1,61 +1,86 @@
"OtherStockOutMtable",
- "rows" => [
- [
- "BillNo" => "00850110", // 單據編號 varchar(20)
- "BillDate" => 20210427, // 單據日期 int
- "OrgId" => "1000", //組織 varchar(20)
- "FOrgId" => "1000", //核算組織 varchar(20)
- "TypeId" => "OS", //單據類型 varchar(10)
- "BizPartnerId" => "", //往來對象(供應商) 可為空
- "PersonId" => "C0003", // 經辦人員 varchar(20)
- "DeptId" => "250", // 經辦部門 varchar(20)
- "CompId" => "1001" // 公司 varchar(20)
- ]
- ]
- ], [
- "name" => "OtherStockOutDetail",
- "rows" => [
- [
- "BillNo" => "00850110", //單據編號 varchar(20)
- "RowCode" => 1, // 序號 int(10)
- "MaterialId" => "MX00021003", // 產品代碼 -> 產品集成 varchar(40)
- "SupplyOrgId" => "1000", // 供貨組織代碼 varchar(20)
- "SQuantity" => 1, // 交易數量 numeric(19)
- "WarehouseId" => "100" // 倉庫代碼 varchar(20)
- ]
- ]
- ]
-];
+require_once('../connt8.php');
+$sql = "SELECT * FROM salIncomeApplyMaster WHERE BillNo = '3TX10701' ";
+$stmt = $connT8->prepare($sql);
+$stmt->execute();
+$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
+echo '';
+print_r($result);
+echo '
';
+// $date = date("Y-m-d");
+// $date1 = str_replace('-', '', $date);
+
+// $arr = [
+// "date" => $date1
+// ];
+
+// echo '';
+// print_r($arr);
+// echo '
';
+// $validation = get_Auth();
+// $data = [
+// [
+// "name" => "OtherStockOutMtable",
+// "rows" => [
+// [
+// "BillNo" => "00850110", // 單據編號 varchar(20)
+// "BillDate" => 20210427, // 單據日期 int
+// "OrgId" => "1000", //組織 varchar(20)
+// "FOrgId" => "1000", //核算組織 varchar(20)
+// "TypeId" => "OS", //單據類型 varchar(10)
+// "BizPartnerId" => "", //往來對象(供應商) 可為空
+// "PersonId" => "C0003", // 經辦人員 varchar(20)
+// "DeptId" => "250", // 經辦部門 varchar(20)
+// "CompId" => "1001" // 公司 varchar(20)
+// ]
+// ]
+// ], [
+// "name" => "OtherStockOutDetail",
+// "rows" => [
+// [
+// "BillNo" => "00850110", //單據編號 varchar(20)
+// "RowCode" => 1, // 序號 int(10)
+// "MaterialId" => "MX00021003", // 產品代碼 -> 產品集成 varchar(40)
+// "SupplyOrgId" => "1000", // 供貨組織代碼 varchar(20)
+// "SQuantity" => 1, // 交易數量 numeric(19)
+// "WarehouseId" => "100" // 倉庫代碼 varchar(20)
+// ]
+// ]
+// ]
+// ];
// $data = file_get_contents('test.json');
// echo '';
// print_r($data);
// echo '
';
-$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKOTHERSTOCKOUT/PostERPData';
-$header = [
- "CHI_Authorization :" . $validation
-];
-$ch = curl_init();
-curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
-curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
-curl_setopt($ch, CURLOPT_POST, 1);
-curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
-curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
-$response = curl_exec($ch);
-if ($response === false) {
- echo 'Curl error: ' . curl_error($ch);
-} else {
- $result = json_decode($response, true);
- // $validation = $result['Data']['CHI_Authorization'];
- echo '';
- print_r($result);
- echo '
';
- return $result;
-}
+// $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKOTHERSTOCKOUT/PostERPData';
+// $header = [
+// "CHI_Authorization :" . $validation
+// ];
+// $ch = curl_init();
+// curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
+// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+// curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+// curl_setopt($ch, CURLOPT_POST, 1);
+// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
+
+// $response = curl_exec($ch);
+// if ($response === false) {
+// echo 'Curl error: ' . curl_error($ch);
+// } else {
+// $result = json_decode($response, true);
+// if ($result['Status'] == 'Error') {
+// echo '';
+// print_r($result);
+// echo '
';
+// echo 'API 傳入錯誤,' . $result['ErrorMsg'];
+// } else {
+// echo '';
+// print_r($result['Status']);
+// echo '
';
+// return $result;
+// }
+// }
-curl_close($ch);
+// curl_close($ch);
diff --git a/wms/frame/api_getdata.php b/wms/frame/api_getdata.php
index 3c0c1af6..802d080b 100644
--- a/wms/frame/api_getdata.php
+++ b/wms/frame/api_getdata.php
@@ -161,6 +161,7 @@ function get_pending($token)
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
+ // print_r($row);
$data[$i]["sid"] = $row[0];
$data[$i]["sname"] = $row[1];
$data[$i]["fid"] = $row[2];
diff --git a/wms/frame/pending.php b/wms/frame/pending.php
index 89a929a4..9ddc2dbf 100644
--- a/wms/frame/pending.php
+++ b/wms/frame/pending.php
@@ -1,109 +1,128 @@
-
-
-
-
-
-
-待我簽核
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ 待我簽核
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wms/fun_global.php b/wms/fun_global.php
index f06b1d44..2b9ee697 100644
--- a/wms/fun_global.php
+++ b/wms/fun_global.php
@@ -108,11 +108,11 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee)
$ret[4] = "M0006,,"; // 總經理
}
}
+
+ return $ret;
}
}
mysqli_free_result($res);
-
- return $ret;
}
/**
* 汰改(契約)價審簽核順位
diff --git a/wms/header.php b/wms/header.php
index 83c6bfa3..18d0f8c8 100644
--- a/wms/header.php
+++ b/wms/header.php
@@ -33,15 +33,15 @@ if (isset($_REQUEST["function_name"])) {
/**
* 連線T8 MSSQL
*/
-try {
- $conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "M0225", "IFFBU1E=");
- if ($conn) {
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
-} catch (PDOException $e) {
- //echo "fail";
- //echo $e->getMessage();
-}
+// try {
+// $conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "M0225", "IFFBU1E=");
+// if ($conn) {
+// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+// }
+// } catch (PDOException $e) {
+// //echo "fail";
+// //echo $e->getMessage();
+// }
diff --git a/wms/mkt/pricereview-check.php b/wms/mkt/pricereview-check.php
index da0b84d8..45080ac3 100644
--- a/wms/mkt/pricereview-check.php
+++ b/wms/mkt/pricereview-check.php
@@ -58,7 +58,7 @@ foreach ($res as $data) {
mysqli_free_result($res_a);
// 瀏覽MI權限
$depart_id = accountidToDepartId($user_id);
- if ($depart_id == "320" || $depart_id == "321" || $depart_id == "20") $viewmi = 1;
+ if ($depart_id == "320" || $depart_id == "321" || $depart_id == "20" || $user_id == 'TEST04') $viewmi = 1;
else $viewmi = 0;
$sql = "select * from pricereview_sign where mid = '$id'";
@@ -258,6 +258,7 @@ foreach ($res as $data) {
function getMI(id) {
var formdata = new FormData();
formdata.append('pa', id);
+ // formdata.append('user_id', = $user_id ?>);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
diff --git a/wms/mkt/pricereview-index.php b/wms/mkt/pricereview-index.php
index f3d93000..b827938c 100644
--- a/wms/mkt/pricereview-index.php
+++ b/wms/mkt/pricereview-index.php
@@ -5,7 +5,7 @@ include "../header.php";
$accountname_arr = accountid2name();
$status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"];
-
+$pricereviewID = $_GET['id'];
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
@@ -23,6 +23,13 @@ if ($user_id == "M0060") {
if (empty($sql_cmd)) $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
else $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on contract_new_apply.mid = pricereview_main.id $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
+if (!empty($_GET)) {
+ $sql = "SELECT pricereview_main.*, flow.*,contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main
+ left join contract_new_apply on contract_new_apply.mid = pricereview_main.id
+ LEFT JOIN flow ON pricereview_main.id = flow.flow_id
+ $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.id IN ($pricereviewID) and flow.flow_code = 'A' and flow.system_id = 'prm' AND pricereview_main.ekind = '新梯' order by pricereview_main.id";
+ echo $sql;
+}
$data = mysqli_query($link, $sql);
$para = "function_name=pricereview&" . $token_link;
@@ -162,6 +169,7 @@ if ($data) :
'ok', 'err' => '');
try {
- if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty");
+ if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty");
+ $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id'];
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
@@ -33,17 +35,19 @@ try {
if (strpos($pa, ",")) list($id, $opt) = explode(",", $pa);
else $id = $pa;
- $person2weight_arr = [ "6" => "450",
- "8" => "550",
- "9" => "600",
- "10" => "700",
- "11" => "750",
- "12" => "800",
- "13" => "900",
- "15" => "1000",
- "17" => "1150",
- "20" => "1350",
- "24" => "1600"];
+ $person2weight_arr = [
+ "6" => "450",
+ "8" => "550",
+ "9" => "600",
+ "10" => "700",
+ "11" => "750",
+ "12" => "800",
+ "13" => "900",
+ "15" => "1000",
+ "17" => "1150",
+ "20" => "1350",
+ "24" => "1600"
+ ];
$elev_arr = $elev_opt_arr = $pv_arr = $opt_elev_arr = $mi_arr = [];
$i = $weight = $elev_qty_all = 0;
@@ -84,7 +88,7 @@ try {
$special_fee = $row[0];
mysqli_free_result($res);
$specarr[0] = "服務費";
- $specarr[1] = round($special_fee/$elev_qty_all, 0);
+ $specarr[1] = round($special_fee / $elev_qty_all, 0);
// 電梯所屬OPTION
$opt_sel_id_arr = [];
@@ -102,7 +106,7 @@ try {
$opt_sel_id_arr[] = $row[0];
}
}
-
+
/*
$pv_arr["price_id"] = $row[1];
$pv_arr["item_spec"] = $row[2];
@@ -114,7 +118,6 @@ try {
$elev_opt_arr[$v][] = $pv_arr;
}
*/
-
}
mysqli_free_result($res);
$opt_nosel_id_arr = array_diff(array_keys($opt_elev_arr), $opt_sel_id_arr);
@@ -143,7 +146,7 @@ try {
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$exarr[$j][0] = $row[1];
- $exarr[$j][1] = round($row[2]/$elev_qty_all, 0);
+ $exarr[$j][1] = round($row[2] / $elev_qty_all, 0);
$ex_fee += $exarr[$j][1];
$j++;
}
@@ -155,57 +158,57 @@ try {
$sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'";
$res_i = mysqli_query($link, $sql3);
while ($row_i = mysqli_fetch_assoc($res_i)) {
- $sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '".$row_i["item_spec"]."' ";
+ $sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '" . $row_i["item_spec"] . "' ";
$sql4 .= "and version_date = '2023-09-04'";
$sql4 .= "and ($row_i[note] between min_floors and max_floors) ";
$res_d = mysqli_query($link, $sql4);
if ($row_d = mysqli_fetch_assoc($res_d)) {
- $dismantle_amt += ($row_d["price"] + $row_d["price_plus"]*($row_i["note"] - $row_d["min_floors"]))*$row_i["item_qty"];
- $polishing_amt += 3000*$row_i["note"];
+ $dismantle_amt += ($row_d["price"] + $row_d["price_plus"] * ($row_i["note"] - $row_d["min_floors"])) * $row_i["item_qty"];
+ $polishing_amt += 3000 * $row_i["note"];
}
mysqli_free_result($res_d);
}
mysqli_free_result($res_i);
}
- $dismantle_fee = round($dismantle_amt/$elev_qty_all, 0);
- $polishing_fee = round($polishing_amt/$elev_qty_all, 0);
+ $dismantle_fee = round($dismantle_amt / $elev_qty_all, 0);
+ $polishing_fee = round($polishing_amt / $elev_qty_all, 0);
//print_r($elev_arr);
//print_r($opt_elev_arr);
//print_r($opt_nosel_id_arr);
//print_r($mn_elev_arr);
//print_r($ex_arr);exit;
-
+
foreach ($elev_arr as $item_no => $v) {
// 電梯MI
$sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r ";
- $sql2 .= "where o.quotation_no = r.quotation_no and o.elevator_type = '".$v['etype']."' ";
+ $sql2 .= "where o.quotation_no = r.quotation_no and o.elevator_type = '" . $v['etype'] . "' ";
$sql2 .= "and ($v[item_weight] between o.min_weight and o.max_weight) ";
$sql2 .= "and ($v[floors] between o.min_floors and o.max_floors) ";
$sql2 .= "and ($v[speed] between o.min_speed and o.max_speed) ";
if ($v["etype"] == "MAQ100" || $v["etype"] == "MAP100") {
- $sql2 .= "and (o.model_no = '".$v["persons"]."') ";
+ $sql2 .= "and (o.model_no = '" . $v["persons"] . "') ";
}
$res_e = mysqli_query($link, $sql2);
if ($row_e = mysqli_fetch_assoc($res_e)) {
// 加價:先不納入
$row_e["option_price"] = 0;
// 基准采购成本+±1停材料费+设计费+出口费用
- $part1 = $row_e["purchase_cost"]+($v["floors"]-$row_e["base_floor"])*$row_e["material_plus"]+$row_e["design"]*$row_e["design_hour"]+$row_e["export_fee"];
+ $part1 = $row_e["purchase_cost"] + ($v["floors"] - $row_e["base_floor"]) * $row_e["material_plus"] + $row_e["design"] * $row_e["design_hour"] + $row_e["export_fee"];
// 利潤
- $profit = round($part1*$row_e["profit"]+$row_e["equip_profit"], 0);
+ $profit = round($part1 * $row_e["profit"] + $row_e["equip_profit"], 0);
// 設備
- $equipment_ntd = round(($part1+$profit)*$row_e["equipment"], 0);
+ $equipment_ntd = round(($part1 + $profit) * $row_e["equipment"], 0);
// 報關+運輸
- $customs = round($equipment_ntd*$row_e["shipping"], 0)+$row_e["customs_shipping"];
+ $customs = round($equipment_ntd * $row_e["shipping"], 0) + $row_e["customs_shipping"];
// 安裝基價
- $install_base = $row_e["install_price"]+$row_e["trial_price"]+$row_e["install_coef"]*$row_e["install_plus"]+$row_e["trial_coef"]*$row_e["trial_plus"];
+ $install_base = $row_e["install_price"] + $row_e["trial_price"] + $row_e["install_coef"] * $row_e["install_plus"] + $row_e["trial_coef"] * $row_e["trial_plus"];
// 安裝成本
- $install_price = round($install_base+($row_e["install_plus"]+$row_e["trial_plus"])*($v["floors"]-$row_e["base_floor"]), 0);
+ $install_price = round($install_base + ($row_e["install_plus"] + $row_e["trial_plus"]) * ($v["floors"] - $row_e["base_floor"]), 0);
// 起吊+木箱+耗材
- $woods = $row_e["crane"]+$row_e["wooden_box"]+$row_e["consume"]+$row_e["consumables"];
+ $woods = $row_e["crane"] + $row_e["wooden_box"] + $row_e["consume"] + $row_e["consumables"];
// MI
- $mi = $equipment_ntd+$customs+$row_e["unloading"]+$row_e["transport_site"]+$install_price+$row_e["free1y"]+$woods+$row_e["option_price"];
+ $mi = $equipment_ntd + $customs + $row_e["unloading"] + $row_e["transport_site"] + $install_price + $row_e["free1y"] + $woods + $row_e["option_price"];
/*
$install_price = $row_e["install_price"] + $row_e["install_plus"]*($floors - $row_e["min_floors"]); // 安裝
@@ -261,25 +264,26 @@ try {
$sql4 = "select o.base_floor, o.base_floor_plus, o.price, r.equipment, p.price 'OP' ";
$sql4 .= "from option_mi o, elevator_quotation_rule r, option_price p ";
$sql4 .= "where o.quotation_no = r.quotation_no and o.option_price_id = p.id ";
- $sql4 .= "and o.option_price_id = ".$opt_elev_arr[$val]["price_id"]." ";
- $sql4 .= "and ($v[item_weight] between o.min_weight and o.max_weight) and o.open_kind = '".$v["item_op"]."'";
+ $sql4 .= "and o.option_price_id = " . $opt_elev_arr[$val]["price_id"] . " ";
+ $sql4 .= "and ($v[item_weight] between o.min_weight and o.max_weight) and o.open_kind = '" . $v["item_op"] . "'";
+
$res_om = mysqli_query($link, $sql4);
if ($row_om = mysqli_fetch_assoc($res_om)) {
$row_om['price'] = (int)ceil($row_om['price']);
- $plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"])*$row_om["base_floor_plus"] : 0;
+ $plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"]) * $row_om["base_floor_plus"] : 0;
// 特例
if ($opt_elev_arr[$val]["price_id"] == "256" && ($v["floors"] < $row_om["base_floor"])) $row_om["price"] = 9815;
if ($opt_elev_arr[$val]["price_id"] == "266" && $v["floors"] >= 20) $plus += 44.8; // 15层,14.6元/层(19层内,跳20层再追加44.8元)
- if ($row_om["price"] == 0) $row_om["price"] = $row_om["OP"]*0.6; // 實體且沒成本的:抓牌價6成
+ if ($row_om["price"] == 0) $row_om["price"] = $row_om["OP"] * 0.6; // 實體且沒成本的:抓牌價6成
// 含此option的電梯總台數
$myelev_qty = 0;
foreach ($opt_elev_arr[$val]["elev_no"] as $pval) {
$myelev_qty += $elev_arr[$pval]["item_qty"];
}
// 分配:OPTION數量除以電梯總台數
- $option_amt = round(0+($row_om["price"]+$plus)*($opt_elev_arr[$val]["item_qty"]/$myelev_qty)*$row_om["equipment"], 0);
+ $option_amt = round(0 + ($row_om["price"] + $plus) * ($opt_elev_arr[$val]["item_qty"] / $myelev_qty) * $row_om["equipment"], 0);
$option_fee += $option_amt; // option總金額
-
+
$oparr[$j][1] = $option_amt;
} else {
$oparr[$j][1] = 0;
@@ -301,8 +305,8 @@ try {
$myelev_qty += $elev_arr[$pval]["item_qty"];
}
// 分配:延保總價除以電梯總台數
- $mn_amt += round(0+($mn_elev_arr[$val]["item_price_bp"]/$myelev_qty), 0);
- $mnarr[$j][0] = $mn_elev_arr[$val]["item_spec"]."保養費";
+ $mn_amt += round(0 + ($mn_elev_arr[$val]["item_price_bp"] / $myelev_qty), 0);
+ $mnarr[$j][0] = $mn_elev_arr[$val]["item_spec"] . "保養費";
$mnarr[$j][1] = $mn_amt;
$mn_fee += $mn_amt;
$j++;
@@ -338,7 +342,7 @@ try {
*/
// 拆台數
- for ($n = 0; $n<$v["item_qty"]; $n++) {
+ for ($n = 0; $n < $v["item_qty"]; $n++) {
$mi_arr[$i][0] = $mi + $dismantle_fee + $polishing_fee + $option_fee + $ex_fee + $mn_fee;
/*
$mi_arr[$i][1] = $row_e["purchase_cost"];
@@ -348,23 +352,23 @@ try {
$mi_arr[$i][5] = $profit_amt;
$mi_arr[$i][6] = $quotation;
*/
- $mi_arr[$i][1] = 0+$equipment_ntd;
- $mi_arr[$i][2] = 0+$customs;
- $mi_arr[$i][3] = 0+$row_e["unloading"];
- $mi_arr[$i][4] = 0+$row_e["transport_site"];
- $mi_arr[$i][5] = 0+$install_price;
- $mi_arr[$i][6] = 0+$row_e["free1y"];
- $mi_arr[$i][7] = 0+$woods;
+ $mi_arr[$i][1] = 0 + $equipment_ntd;
+ $mi_arr[$i][2] = 0 + $customs;
+ $mi_arr[$i][3] = 0 + $row_e["unloading"];
+ $mi_arr[$i][4] = 0 + $row_e["transport_site"];
+ $mi_arr[$i][5] = 0 + $install_price;
+ $mi_arr[$i][6] = 0 + $row_e["free1y"];
+ $mi_arr[$i][7] = 0 + $woods;
$mi_arr[$i][8] = $row_e["equipment"];
- $mi_arr[$i][9] = 0+$row_e["option_price"];
- $mi_arr[$i][10] = 0+$dismantle_fee;
- $mi_arr[$i][11] = 0+$polishing_fee;
- $mi_arr[$i][12] = $mi_arr[$i][1]+$mi_arr[$i][2]+$mi_arr[$i][3]+$mi_arr[$i][4]+$mi_arr[$i][5]+$mi_arr[$i][6]+$mi_arr[$i][7]+$mi_arr[$i][9]+$mi_arr[$i][10]+$mi_arr[$i][11];
- $mi_arr[$i][13] = $option_fee+$ex_fee+$mn_fee+$special_fee;
+ $mi_arr[$i][9] = 0 + $row_e["option_price"];
+ $mi_arr[$i][10] = 0 + $dismantle_fee;
+ $mi_arr[$i][11] = 0 + $polishing_fee;
+ $mi_arr[$i][12] = $mi_arr[$i][1] + $mi_arr[$i][2] + $mi_arr[$i][3] + $mi_arr[$i][4] + $mi_arr[$i][5] + $mi_arr[$i][6] + $mi_arr[$i][7] + $mi_arr[$i][9] + $mi_arr[$i][10] + $mi_arr[$i][11];
+ $mi_arr[$i][13] = $option_fee + $ex_fee + $mn_fee + $special_fee;
$mi_arr[$i][14] = $oparr;
- $mi_arr[$i][15] = 0+$ex_fee;
+ $mi_arr[$i][15] = 0 + $ex_fee;
$mi_arr[$i][16] = $exarr;
- $mi_arr[$i][17] = 0+$mn_fee;
+ $mi_arr[$i][17] = 0 + $mn_fee;
$mi_arr[$i][18] = $mnarr;
$mi_arr[$i][19] = $specarr;
$i++;
@@ -374,11 +378,10 @@ try {
}
$rarr["content"] = $mi_arr;
-}catch(\Exception $e) {
+} catch (\Exception $e) {
$rarr['st'] = 'err';
$rarr['err'] = $e->getMessage();
}
echo json_encode($rarr, JSON_UNESCAPED_UNICODE);
exit;
-?>
\ No newline at end of file
diff --git a/wms/sign/list.php b/wms/sign/list.php
index 73cd0644..126a4627 100644
--- a/wms/sign/list.php
+++ b/wms/sign/list.php
@@ -20,7 +20,7 @@ $where_system_id = " and a.system_id like '" . $system_id . "%'";
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id'];
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'";
-$sql_get = "SELECT c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner,
+$sql_get = "SELECT d.form_id,c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner,
concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name ,
flow_name,c.update_date ,c.create_date,b.path,d.flow_code FROM system_main a,flow_main b ,subflow
c,flow d
@@ -32,6 +32,9 @@ $sql_get = "SELECT c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_a
$where_system_id
$where_flow_id
";
+// echo '';
+// print_r($sql_get);
+// echo '
';
$result = mysqli_query($link, $sql_get);
if ($result == false) {
@@ -153,6 +156,16 @@ $flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR));
$data) {
+ if ($data['flow_code'] !== 'Z') {
+ $test = $data['form_id'];
+ $id[] = $test;
+ }
+ }
+ $inClause = implode(',', $id);
+ echo '';
+ print_r($inClause);
+ echo '
';
$rowspan = 1;
$path = "localhost:3000/wms/sign/list.php";
foreach ($res_get as $key => $data) :
@@ -160,7 +173,7 @@ $flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR));
if ($data['flow_code'] !== 'Z') {
?>
- ">= $data['form_key']; ?> |
+ ">= $data['form_key']; ?> |
|
|
|