Browse Source

合約入T8(完成)

main
Cheng 1 year ago
parent
commit
69cbb7ecaa
  1. BIN
      wms/assemble_warehouse.xlsx
  2. 25
      wms/contract/api/T8salIncomeApply.php
  3. 912
      wms/contract/api/postContractData.php
  4. 173
      wms/contract/api/test.json
  5. 133
      wms/contract/api/testT8API.php
  6. 1
      wms/frame/api_getdata.php
  7. 235
      wms/frame/pending.php
  8. 4
      wms/fun_global.php
  9. 18
      wms/header.php
  10. 3
      wms/mkt/pricereview-check.php
  11. 10
      wms/mkt/pricereview-index.php
  12. 117
      wms/mkt/pricereview_mi-api.php
  13. 17
      wms/sign/list.php

BIN
wms/assemble_warehouse.xlsx

Binary file not shown.

25
wms/contract/api/T8salIncomeApply.php

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

912
wms/contract/api/postContractData.php

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

173
wms/contract/api/test.json

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

133
wms/contract/api/testT8API.php

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

1
wms/frame/api_getdata.php

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

235
wms/frame/pending.php

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

4
wms/fun_global.php

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

18
wms/header.php

@ -33,15 +33,15 @@ if (isset($_REQUEST["function_name"])) {
/** /**
* 連線T8 MSSQL * 連線T8 MSSQL
*/ */
try { // try {
$conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "M0225", "IFFBU1E="); // $conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "M0225", "IFFBU1E=");
if ($conn) { // if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} // }
} catch (PDOException $e) { // } catch (PDOException $e) {
//echo "fail"; // //echo "fail";
//echo $e->getMessage(); // //echo $e->getMessage();
} // }

3
wms/mkt/pricereview-check.php

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

10
wms/mkt/pricereview-index.php

@ -5,7 +5,7 @@ include "../header.php";
$accountname_arr = accountid2name(); $accountname_arr = accountid2name();
$status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"]; $status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"];
$pricereviewID = $_GET['id'];
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // 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"; if (empty($sql_cmd)) $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
else $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on contract_new_apply.mid = pricereview_main.id $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id"; else $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on contract_new_apply.mid = pricereview_main.id $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
if (!empty($_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); $data = mysqli_query($link, $sql);
$para = "function_name=pricereview&" . $token_link; $para = "function_name=pricereview&" . $token_link;
@ -162,6 +169,7 @@ if ($data) :
<tbody> <tbody>
<?php <?php
foreach ($data as $data) : foreach ($data as $data) :
$sign1 = $sign2 = $sign3 = $sign4 = ""; $sign1 = $sign2 = $sign3 = $sign4 = "";
$oneself = ($data["creater"] == $user_id) ? 1 : 0; // 是否為營業員本人 $oneself = ($data["creater"] == $user_id) ? 1 : 0; // 是否為營業員本人
// 簽核狀況 // 簽核狀況

117
wms/mkt/pricereview_mi-api.php

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

17
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']; $flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id'];
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'"; $where_flow_id = " and b.flow_id like '" . $flow_id . "%'";
$sql_get = "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 , 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 flow_name,c.update_date ,c.create_date,b.path,d.flow_code FROM system_main a,flow_main b ,subflow
c,flow d 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_system_id
$where_flow_id $where_flow_id
"; ";
// echo '<pre>';
// print_r($sql_get);
// echo '</pre>';
$result = mysqli_query($link, $sql_get); $result = mysqli_query($link, $sql_get);
if ($result == false) { if ($result == false) {
@ -153,6 +156,16 @@ $flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR));
<tbody> <tbody>
<?php <?php
foreach ($res_get as $key => $data) {
if ($data['flow_code'] !== 'Z') {
$test = $data['form_id'];
$id[] = $test;
}
}
$inClause = implode(',', $id);
echo '<pre>';
print_r($inClause);
echo '</pre>';
$rowspan = 1; $rowspan = 1;
$path = "localhost:3000/wms/sign/list.php"; $path = "localhost:3000/wms/sign/list.php";
foreach ($res_get as $key => $data) : 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') { if ($data['flow_code'] !== 'Z') {
?> ?>
<tr> <tr>
<td><a target="_blank" href="<?= $path . "?form_key=" . $data['form_key'] . "&token=$token" ?>"><?= $data['form_key']; ?></a></td> <td><a target="_blank" href="<?= "../mkt/pricereview-index.php?id=" . $inClause . "&token=$token" ?>"><?= $data['form_key']; ?></a></td>
<td><?php echo $data['system_name']; ?></td> <td><?php echo $data['system_name']; ?></td>
<td><?php echo $data['flow_name']; ?></td> <td><?php echo $data['flow_name']; ?></td>
<td><?php echo $data['update_date']; ?></td> <td><?php echo $data['update_date']; ?></td>

Loading…
Cancel
Save