Browse Source

合約入力 修改1109

gary
10994015 1 year ago
parent
commit
4ca030cdc4
  1. 109
      wms/contract/api/postContractData.php

109
wms/contract/api/postContractData.php

@ -5,81 +5,42 @@ include_once("./getComboNo.php");
ini_set ( 'date.timezone' , 'Asia/Taipei' ); ini_set ( 'date.timezone' , 'Asia/Taipei' );
if(isset($_POST["contractno"]) && $_POST["contractno"] != "") { if(isset($_POST["contractno"]) && $_POST["contractno"] != "") {
try{ 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;
$spec = !empty($_POST['spec']) ? $_POST['spec'] : null;
$weight = !empty($_POST['weight']) ? $_POST['weight'] : null;
$numberofpassenger = !empty($_POST['numberofpassenger']) ? $_POST['numberofpassenger'] : null;
$numberofstop = !empty($_POST['numberofstop']) ? $_POST['numberofstop'] : null;
$numberoffloor = !empty($_POST['numberoffloor']) ? $_POST['numberoffloor'] : null;
$speed = !empty($_POST['speed']) ? $_POST['speed'] : null;
$takecertificatedate = !empty($_POST['takecertificatedate']) ? $_POST['takecertificatedate'] : null;
$maintainance = !empty($_POST['maintainance']) ? $_POST['maintainance'] : null;
$licensedate = !empty($_POST['licensedate']) ? $_POST['licensedate'] : null;
$latitude = !empty($_POST['latitude']) ? $_POST['latitude'] : null;
$longitude = !empty($_POST['longitude']) ? $_POST['longitude'] : null;
$num = !empty($_POST['num']) ? $_POST['num'] : null;
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
// validate $contractno = $_POST['contractno'] ?? '';
$fail_arr = []; $total_price = $_POST['total_price'] ?? '';
if($contractno === '') return $fail_arr[] = '合約號為必填'; $vat = $_POST['vat'] ?? '';
$mtype = $_POST['mtype'] ?? '';
$opendoor = $_POST['opendoor'] ?? '';
$phone = $_POST['phone'] ?? '';
$email = $_POST['email'] ?? '';
$mworker = $_POST['mworker'] ?? '';
$mcycle = $_POST['mcycle'] ?? '';
$salesman = $_POST['salesman'] ?? '';
$contract_begin_date = $_POST['contract_begin_date'] ?? '';
$contract_end_date = $_POST['contract_end_date'] ?? '';
$address = $_POST['address'] ?? '';
$area = $_POST['area'] ?? '';
$customer = $_POST['customer'] ?? '';
$partyA = $_POST['partyA'] ?? '';
$partyAaddress = $_POST['partyAaddress'] ?? '';
$partyAphone = $_POST['partyAphone'] ?? '';
$partyAemail = $_POST['partyAemail'] ?? '';
$user_id = $_POST['user_id'] ?? '';
$user_name = $_POST['user_name'] ?? '';
$spec = $_POST['spec'] ??'';
$weight = $_POST['weight'] ??'';
$numberofpassenger = $_POST['numberofpassenger'] ??'';
$numberofstop = $_POST['numberofstop'] ??'';
$numberoffloor = $_POST['numberoffloor'] ??'';
$speed = $_POST['speed'] ??'';
$takecertificatedate = $_POST['takecertificatedate'] ??'';
$maintainance = $_POST['maintainance'] ??'';
$licensedate = $_POST['licensedate'] ??'';
$latitude = $_POST['latitude'] ??'';
$longitude = $_POST['longitude'] ??'';
$num = $_POST['num'] ??'';
if($total_price == '') $fail_arr[] = '合約總價為必填'; $files = $_FILES['files'] ?? '';
if($vat == '') $fail_arr[] = '統一編號為必填';
if($mtype == '') $fail_arr[] = '維修型態為必填';
if($opendoor == '') $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($spec == '') $fail_arr[] = '規格為必填';
if($weight == '') $fail_arr[] = '重量為必填';
if($numberofpassenger == '') $fail_arr[] = '乘客人數為必填';
if($numberofstop == '') $fail_arr[] = '停留站數為必填';
if($numberoffloor == '') $fail_arr[] = '停留樓層為必填';
if($speed == '') $fail_arr[] = '速度為必填';
if($takecertificatedate == '') $fail_arr[] = '取標日期為必填';
if($maintainance == '') $fail_arr[] = '保養為必填';
if($licensedate == '') $fail_arr[] = '營業員為必填';
if($latitude == '') $fail_arr[] = '緯度為必填';
if($longitude == '') $fail_arr[] = '經度為必填';
if($num == '') $fail_arr[] = '數量為必填';
if(count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
//create account table //create account table
$accounttype = "A"; $accounttype = "A";
@ -159,6 +120,8 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") {
$stmt->execute(); $stmt->execute();
$worker = $stmt->fetch(PDO::FETCH_ASSOC); $worker = $stmt->fetch(PDO::FETCH_ASSOC);
$facilityno = $createFacilityNo->makeBFacilityNo("T", $dailyNecessities[$spec], (int)$num);
$facilityno = $createFacilityNo->makeBFacilityNo("T", $dailyNecessities[$spec], (int)$num); $facilityno = $createFacilityNo->makeBFacilityNo("T", $dailyNecessities[$spec], (int)$num);
$define = "B"; $define = "B";
$customerid = $vat; $customerid = $vat;

Loading…
Cancel
Save