|
@ -1,45 +1,46 @@ |
|
|
<?php |
|
|
<?php |
|
|
require_once("../conn.php"); |
|
|
require_once("../conn.php"); |
|
|
include_once("./createFacilityNo.php"); |
|
|
include_once("./getFacilityNo.php"); |
|
|
|
|
|
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{ |
|
|
|
|
|
|
|
|
$contractno = $_POST['contractno'] ?? ''; |
|
|
$contractno = !empty($_POST['contractno'])? $_POST['contractno'] : null; |
|
|
$total_price = $_POST['total_price'] ?? ''; |
|
|
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|
|
$vat = $_POST['vat'] ?? ''; |
|
|
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null; |
|
|
$mtype = $_POST['mtype'] ?? ''; |
|
|
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] :null; |
|
|
$opendoor = $_POST['opendoor'] ?? ''; |
|
|
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor']: null; |
|
|
$phone = $_POST['phone'] ?? ''; |
|
|
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null; |
|
|
$email = $_POST['email'] ?? ''; |
|
|
$email = !empty($_POST['email']) ? $_POST['email'] : null; |
|
|
$mworker = $_POST['mworker'] ?? ''; |
|
|
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null; |
|
|
$mcycle = $_POST['mcycle'] ?? ''; |
|
|
$mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null; |
|
|
$salesman = $_POST['salesman'] ?? ''; |
|
|
$salesman = !empty($_POST['salesman']) ?$_POST['salesman'] : null; |
|
|
$contract_begin_date = $_POST['contract_begin_date'] ?? ''; |
|
|
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null; |
|
|
$contract_end_date = $_POST['contract_end_date'] ?? ''; |
|
|
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null; |
|
|
$address = $_POST['address'] ?? ''; |
|
|
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
|
|
$area = $_POST['area'] ?? ''; |
|
|
$area = !empty($_POST['area']) ? $_POST['area'] : null; |
|
|
$customer = $_POST['customer'] ?? ''; |
|
|
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null; |
|
|
$partyA = $_POST['partyA'] ?? ''; |
|
|
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null; |
|
|
$partyAaddress = $_POST['partyAaddress'] ?? ''; |
|
|
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null; |
|
|
$partyAphone = $_POST['partyAphone'] ?? ''; |
|
|
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null; |
|
|
$partyAemail = $_POST['partyAemail'] ?? ''; |
|
|
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null; |
|
|
$user_id = $_POST['user_id'] ?? ''; |
|
|
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|
|
$user_name = $_POST['user_name'] ?? ''; |
|
|
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null; |
|
|
$spec = $_POST['spec'] ??''; |
|
|
$spec = !empty($_POST['spec']) ? $_POST['spec'] : null; |
|
|
$weight = $_POST['weight'] ??''; |
|
|
$weight = !empty($_POST['weight']) ? $_POST['weight'] : null; |
|
|
$numberofpassenger = $_POST['numberofpassenger'] ??''; |
|
|
$numberofpassenger = !empty($_POST['numberofpassenger']) ? $_POST['numberofpassenger'] : null; |
|
|
$numberofstop = $_POST['numberofstop'] ??''; |
|
|
$numberofstop = !empty($_POST['numberofstop']) ? $_POST['numberofstop'] : null; |
|
|
$numberoffloor = $_POST['numberoffloor'] ??''; |
|
|
$numberoffloor = !empty($_POST['numberoffloor']) ? $_POST['numberoffloor'] : null; |
|
|
$speed = $_POST['speed'] ??''; |
|
|
$speed = !empty($_POST['speed']) ? $_POST['speed'] : null; |
|
|
$takecertificatedate = $_POST['takecertificatedate'] ??''; |
|
|
$takecertificatedate = !empty($_POST['takecertificatedate']) ? $_POST['takecertificatedate'] : null; |
|
|
$maintainance = $_POST['maintainance'] ??''; |
|
|
$maintainance = !empty($_POST['maintainance']) ? $_POST['maintainance'] : null; |
|
|
$licensedate = $_POST['licensedate'] ??''; |
|
|
$licensedate = !empty($_POST['licensedate']) ? $_POST['licensedate'] : null; |
|
|
$latitude = $_POST['latitude'] ??''; |
|
|
$latitude = !empty($_POST['latitude']) ? $_POST['latitude'] : null; |
|
|
$longitude = $_POST['longitude'] ??''; |
|
|
$longitude = !empty($_POST['longitude']) ? $_POST['longitude'] : null; |
|
|
$num = $_POST['num'] ??''; |
|
|
$num = !empty($_POST['num']) ? $_POST['num'] : null; |
|
|
|
|
|
|
|
|
$files = $_FILES['files'] ?? ''; |
|
|
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|
|
|
|
|
|
|
|
//create account table |
|
|
//create account table |
|
|
$accounttype = "A"; |
|
|
$accounttype = "A"; |
|
@ -80,8 +81,6 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") { |
|
|
$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; |
|
|
$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)"; |
|
|
$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); |
|
@ -119,9 +118,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); |
|
|
$define = "B"; |
|
|
$define = "B"; |
|
|
$facilityno = $createFacilityNo->makeTFacilityNo("T", $dailyNecessities[$spec], $num)[0]; |
|
|
|
|
|
echo $facilityno; |
|
|
|
|
|
$customerid = $vat; |
|
|
$customerid = $vat; |
|
|
$opentype = $opendoor; |
|
|
$opentype = $opendoor; |
|
|
$repairtype = "A"; |
|
|
$repairtype = "A"; |
|
@ -129,14 +127,15 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") { |
|
|
$maintainance = "E"; |
|
|
$maintainance = "E"; |
|
|
$repairerid = $mworker; |
|
|
$repairerid = $mworker; |
|
|
$repairername = $worker['name']; |
|
|
$repairername = $worker['name']; |
|
|
$creater = $user_id; |
|
|
|
|
|
$create_at = date("Y-m-d H:i:s"); |
|
|
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) |
|
|
$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)"; |
|
|
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 = $conn -> prepare($sql_str); |
|
|
$stmt -> bindParam(':contractno' ,$contractno); |
|
|
$stmt -> bindParam(':contractno' ,$contractno); |
|
|
$stmt -> bindParam(':define' ,$define); |
|
|
$stmt -> bindParam(':define' ,$define); |
|
|
$stmt -> bindParam(':facilityno' ,$facilityno); |
|
|
$stmt -> bindParam(':facilityno' ,$fno); |
|
|
$stmt -> bindParam(':latitude' ,$latitude); |
|
|
$stmt -> bindParam(':latitude' ,$latitude); |
|
|
$stmt -> bindParam(':longitude' ,$longitude); |
|
|
$stmt -> bindParam(':longitude' ,$longitude); |
|
|
$stmt -> bindParam(':customerid' ,$customerid); |
|
|
$stmt -> bindParam(':customerid' ,$customerid); |
|
@ -159,6 +158,22 @@ if(isset($_POST["contractno"]) && $_POST["contractno"] != "") { |
|
|
$stmt -> bindParam(':licensedate' ,$licensedate); |
|
|
$stmt -> bindParam(':licensedate' ,$licensedate); |
|
|
|
|
|
|
|
|
$result = $stmt -> execute(); |
|
|
$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(':facilityno' ,$facilityno); |
|
|
|
|
|
$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); |
|
|
|
|
|
$result = $stmt -> execute(); |
|
|
|
|
|
|
|
|
header('Content-Type: application/json'); |
|
|
header('Content-Type: application/json'); |
|
|
$jsonData = json_encode($files); |
|
|
$jsonData = json_encode($files); |
|
|