You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
2.4 KiB

<?php
require_once("../conn.php");
ini_set ( 'date.timezone' , 'Asia/Taipei' );
if(isset($_POST["contractno"]) && $_POST["contractno"] != "") {
try{
$conn->beginTransaction();
$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'] ?? '';
$customer = $_POST['customer'] ?? '';
$partyA = $_POST['partyA'] ?? '';
$partyAaddress = $_POST['partyAaddress'] ?? '';
$partyAphone = $_POST['partyAphone'] ?? '';
$partyAemail = $_POST['partyAemail'] ?? '';
$user_id = $_POST['user_id'] ?? '';
$files = $_FILES['files'] ?? '';
//create account table
$accounttype = "A";
$accountid = $vat;
$pwd = "123";
$name = $partyA;
$tel = $phone ?? '';
$repairerid = $mworker;
$creater = $user_id;
$create_at = date('Y-m-d H:i:s');
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
$stmt = $conn -> prepare($sql_str);
$stmt -> bindParam(':accounttype' ,$accounttype);
$stmt -> bindParam(':accountid' ,$accountid);
$stmt -> bindParam(':pwd' ,$pwd);
$stmt -> bindParam(':name' ,$name);
$stmt -> bindParam(':tel' ,$tel);
$stmt -> bindParam(':address' ,$address);
$stmt -> bindParam(':email' ,$email);
$stmt -> bindParam(':repairerid' ,$repairerid);
$stmt -> bindParam(':creater' ,$creater);
$stmt -> bindParam(':create_at' ,$create_at);
$stmt -> execute();
header('Content-Type: application/json');
$jsonData = json_encode($files);
echo $jsonData;
$conn->commit();
}catch(PDOException $e){
$conn->rollBack();
die('Error!:'.$e->getMessage());
}
}