10994015 1 year ago
parent
commit
f6b04618b5
  1. 29
      wms/contract/api/getComboNo.php
  2. 0
      wms/contract/api/getFacilityNo.php
  3. 139
      wms/contract/api/postContractData.php
  4. 14
      wms/contract/contract-input.php

29
wms/contract/api/getComboNo.php

@ -0,0 +1,29 @@
<?php
class CreateComboNo{
public $comboarr = [
'week'=>'BW002',
'month'=>'EM002',
'quarter'=>'EQ002',
'half'=>'HY002',
'year'=>'EY002'
];
public $bwarr = [
'week','month','week','month','week','quarter',
'week','month','week','month','week','half',
'week','month','week','month','week','quarter',
'week','month','week','month','week','year'
];
public $emarr = [
'month','month','quarter','month','month','half',
'month','month','quarter','month','month','year'
];
public $combo;
public $startdate;
public $enddate;
public function __construct($combo, $startdate, $enddate){
}
public function getComboNo(){
}
}

0
wms/contract/api/createFacilityNo.php → wms/contract/api/getFacilityNo.php

139
wms/contract/api/postContractData.php

@ -1,45 +1,46 @@
<?php
require_once("../conn.php");
include_once("./createFacilityNo.php");
include_once("./getFacilityNo.php");
include_once("./getComboNo.php");
ini_set ( 'date.timezone' , 'Asia/Taipei' );
if(isset($_POST["contractno"]) && $_POST["contractno"] != "") {
try{
$contractno = $_POST['contractno'] ?? '';
$total_price = $_POST['total_price'] ?? '';
$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'] ??'';
$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 = $_FILES['files'] ?? '';
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
//create account table
$accounttype = "A";
@ -80,8 +81,6 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") {
$contract_employee = $salesman;
$start_date = $contract_begin_date;
$end_date = $contract_end_date;
$creater = $user_id;
$create_at = date('Y-m-d H:i:s');
$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);
@ -118,10 +117,9 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") {
$stmt->bindParam(':accountid',$mworker);
$stmt->execute();
$worker = $stmt->fetch(PDO::FETCH_ASSOC);
$facilityno = $createFacilityNo->makeBFacilityNo("T", $dailyNecessities[$spec], (int)$num);
$define = "B";
$facilityno = $createFacilityNo->makeTFacilityNo("T", $dailyNecessities[$spec], $num)[0];
echo $facilityno;
$customerid = $vat;
$opentype = $opendoor;
$repairtype = "A";
@ -129,35 +127,52 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") {
$maintainance = "E";
$repairerid = $mworker;
$repairername = $worker['name'];
$creater = $user_id;
$create_at = date("Y-m-d H:i:s");
$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)";
foreach($facilityno as $fno){
$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' ,$fno);
$stmt -> bindParam(':latitude' ,$latitude);
$stmt -> bindParam(':longitude' ,$longitude);
$stmt -> bindParam(':customerid' ,$customerid);
$stmt -> bindParam(':weight' ,$weight);
$stmt -> bindParam(':numberofpassenger' ,$numberofpassenger);
$stmt -> bindParam(':numberofstop' ,$numberofstop);
$stmt -> bindParam(':numberoffloor' ,$numberoffloor);
$stmt -> bindParam(':opentype' ,$opentype);
$stmt -> bindParam(':speed' ,$speed);
$stmt -> bindParam(':repairtype' ,$repairtype);
$stmt -> bindParam(':maintainance' ,$maintainance);
$stmt -> bindParam(':facility_kind' ,$facility_kind);
$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' ,$takecertificatedate);
$stmt -> bindParam(':licensedate' ,$licensedate);
$result = $stmt -> execute();
}
//create schedule table
$comboMo = new CreateComboNo();
$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(':define' ,$define);
$stmt -> bindParam(':facilityno' ,$facilityno);
$stmt -> bindParam(':latitude' ,$latitude);
$stmt -> bindParam(':longitude' ,$longitude);
$stmt -> bindParam(':customerid' ,$customerid);
$stmt -> bindParam(':weight' ,$weight);
$stmt -> bindParam(':numberofpassenger' ,$numberofpassenger);
$stmt -> bindParam(':numberofstop' ,$numberofstop);
$stmt -> bindParam(':numberoffloor' ,$numberoffloor);
$stmt -> bindParam(':opentype' ,$opentype);
$stmt -> bindParam(':speed' ,$speed);
$stmt -> bindParam(':repairtype' ,$repairtype);
$stmt -> bindParam(':maintainance' ,$maintainance);
$stmt -> bindParam(':facility_kind' ,$facility_kind);
$stmt -> bindParam(':address' ,$address);
$stmt -> bindParam(':combono' ,$combono);
$stmt -> bindParam(':repairerid' ,$repairerid);
$stmt -> bindParam(':repairername' ,$repairername);
$stmt -> bindParam(':duedate' ,$duedate);
$stmt -> bindParam(':creater' ,$creater);
$stmt -> bindParam(':create_at' ,$create_at);
$stmt -> bindParam(':area' ,$area);
$stmt -> bindParam(':takecertificatedate' ,$takecertificatedate);
$stmt -> bindParam(':licensedate' ,$licensedate);
$result = $stmt -> execute();
header('Content-Type: application/json');

14
wms/contract/contract-input.php

@ -1,6 +1,7 @@
<?php
include("../header.php");
require_once("./conn.php");
include_once("./api/createFacilityNo.php");
$accounttype = "B";
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype";
$stmt = $conn->prepare($sql_str);
@ -13,6 +14,10 @@ $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype',$accounttype);
$stmt->execute();
$contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
$createFacilityNo = new CreateFacilityNo();
$facilityno = $createFacilityNo->makeTFacilityNo("T", 'X', 5);
print_r($facilityno);
?>
<link rel="stylesheet" href="./styles/style.css">
<link rel="stylesheet" href="semantic/dist/semantic.min.css">
@ -30,7 +35,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
},
cities:[],
data:{
contractno:'',
contractno:'Q23080026',
total_price:'', //合約總價
vat:'', //統一編號
mtype:'A', //維修型態
@ -61,6 +66,8 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
takecertificatedate:'', //交車日、竣檢日
licensedate:'', //許可證有效日期
num:'', //電梯數量
latitude:'', //緯度
longitude:'', //經度
},
customize:false,
step:1,
@ -198,6 +205,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
form.append('longitude', this.data.longitude);
form.append('user_id', '<?php echo $user_id; ?>');
form.append('user_name', '<?php echo $user_name; ?>');
form.append('num', this.data.num);
// 如果有附件檔案,可以逐一加入
for (var i = 0; i < this.data.files.length; i++) {
@ -336,8 +344,8 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mcycle">
<option value="">選擇保養頻率</option>
<option value="A">雙週保</option>
<option value="B">月保</option>
<option value="bw">雙週保</option>
<option value="em">月保</option>
</select>
</td>
</tr>

Loading…
Cancel
Save