18 changed files with 5789 additions and 5357 deletions
@ -1,35 +1,34 @@ |
|||||
<?php |
<?php |
||||
require_once("../conn.php"); |
require_once("../conn.php"); |
||||
ini_set ( 'date.timezone' , 'Asia/Taipei' ); |
ini_set('date.timezone', 'Asia/Taipei'); |
||||
if(isset($_GET['contractid']) && $_GET['contractid']!="" && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r'){ |
if (isset($_GET['contractid']) && $_GET['contractid'] != "" && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') { |
||||
try{ |
try { |
||||
$id = $_GET['contractid']; |
$id = $_GET['contractid']; |
||||
$user_id = $_GET['user_id']; |
$user_id = $_GET['user_id']; |
||||
$date = date('Y-m-d H:i:s'); |
$date = date('Y-m-d H:i:s'); |
||||
$del = 2; |
$del = '2'; |
||||
$sql = "UPDATE contract_r_signed_back SET delete_status = :del,delete_userid= :user_id, delete_date = :date WHERE id = :id"; |
$sql = "UPDATE contract_r_signed_back SET delete_status = :del,delete_userid= :user_id, delete_date = :date WHERE id = :id"; |
||||
|
|
||||
$stmt = $conn->prepare($sql); |
$stmt = $conn->prepare($sql); |
||||
$stmt->bindParam(":id",$id); |
$stmt->bindParam(":id", $id); |
||||
$stmt->bindParam(":del",$del); |
$stmt->bindParam(":del", $del); |
||||
$stmt->bindParam(":user_id",$user_id); |
$stmt->bindParam(":user_id", $user_id); |
||||
$stmt->bindParam(":date",$date); |
$stmt->bindParam(":date", $date); |
||||
$stmt->execute(); |
$stmt->execute(); |
||||
header("HTTP/1.1 204 NO Content"); |
header("HTTP/1.1 204 NO Content"); |
||||
}catch(PDOException $e){ |
} catch (PDOException $e) { |
||||
die("ERROR!!!". $e->getMessage()); |
die("ERROR!!!" . $e->getMessage()); |
||||
} |
} |
||||
} |
} |
||||
if(isset($_GET['contractid']) && $_GET['contractid']!=""){ |
if (isset($_GET['contractid']) && $_GET['contractid'] != "") { |
||||
try{ |
try { |
||||
$id = $_GET["contractid"]; |
$id = $_GET["contractid"]; |
||||
$sql_str = "DELETE FROM contract_m_signed_back WHERE id = :contractid"; |
$sql_str = "DELETE FROM contract_m_signed_back WHERE id = :contractid"; |
||||
$stmt = $conn->prepare($sql_str); |
$stmt = $conn->prepare($sql_str); |
||||
$stmt->bindParam(":contractid", $id); |
$stmt->bindParam(":contractid", $id); |
||||
$stmt->execute(); |
$stmt->execute(); |
||||
header("HTTP/1.1 204 No Content"); |
header("HTTP/1.1 204 No Content"); |
||||
}catch(PDOException $e){ |
} catch (PDOException $e) { |
||||
die("ERROR!!!: ". $e->getMessage()); |
die("ERROR!!!: " . $e->getMessage()); |
||||
} |
} |
||||
} |
} |
||||
?> |
|
@ -1,174 +1,190 @@ |
|||||
<?php |
<?php |
||||
require_once("../conn.php"); |
require_once("../conn.php"); |
||||
include_once("./upload_chk.php"); |
include_once("./upload_chk.php"); |
||||
ini_set ( 'date.timezone' , 'Asia/Taipei' ); |
ini_set('date.timezone', 'Asia/Taipei'); |
||||
// echo json_encode(explode(',', $_POST['deletefiles'])); |
// echo json_encode(explode(',', $_POST['deletefiles'])); |
||||
if(isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_POST["id"]) && $_POST['id']!=""){ |
if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_POST["id"]) && $_POST['id'] != "") { |
||||
try{ |
try { |
||||
$create_date = date('Y-m-d H:i:s'); |
$create_date = date('Y-m-d H:i:s'); |
||||
$repair_no = !empty($POST['repair_no']) ? $_POST['repair_no'] : null; |
$repair_no = !empty($POST['repair_no']) ? $_POST['repair_no'] : null; |
||||
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
||||
$company = !empty($_POST['company']) ? $_POST['conpany'] : null; |
$company = !empty($_POST['company']) ? $_POST['company'] : null; |
||||
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; |
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; |
||||
$facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null; |
$facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null; |
||||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
||||
$type = !empty($_POST['type']) ? $_POST['type'] : null; |
$type = !empty($_POST['type']) ? $_POST['type'] : null; |
||||
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null; |
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null; |
||||
$repaireid = !empty($_POST['repaireid']) ? $_POST['repaireid'] : null; |
$repaireid = !empty($_POST['repaireid']) ? $_POST['repaireid'] : null; |
||||
|
$contract_status = !empty($_POST['contract_status']) ? $_POST['contract_status'] : null; |
||||
// $total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
// $total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
||||
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
||||
|
|
||||
$fail_arr = []; |
$fail_arr = []; |
||||
if(empty($repair_no)) $fail_arr[] = '號為必填'; |
// if (empty($repair_no)) $fail_arr[] = '號為必填'; |
||||
if(empty($contractno)) $fail_arr[] = '合約號為必填'; |
if (empty($contractno)) $fail_arr[] = '合約號為必填'; |
||||
if(empty($company)) $fail_arr[] = '客戶名稱為必填'; |
if (empty($company)) $fail_arr[] = '客戶名稱為必填'; |
||||
if(empty($taxid)) $fail_arr[] = '統一編號為必填'; |
if (empty($taxid)) $fail_arr[] = '統一編號為必填'; |
||||
if(empty($facilityno)) $fail_arr[] = '電梯號為必填'; |
if (empty($facilityno)) $fail_arr[] = '電梯號為必填'; |
||||
if(empty($address)) $fail_arr[] = '工程地址為必填'; |
if (empty($address)) $fail_arr[] = '工程地址為必填'; |
||||
if(empty($type)) $fail_arr[] = '工程類行為必填'; |
if (empty($type)) $fail_arr[] = '工程類行為必填'; |
||||
if(empty($invoice)) $fail_arr[] = '發票抬頭為必填'; |
if (empty($invoice)) $fail_arr[] = '發票抬頭為必填'; |
||||
if(empty($repaireid)) $fail_arr[] = '維修人員為必填'; |
if (empty($repaireid)) $fail_arr[] = '維修人員為必填'; |
||||
if(count($fail_arr) > 0){ |
if (empty($contract_status)) $fail_arr[] = '工程類別為必填'; |
||||
|
if (count($fail_arr) > 0) { |
||||
header("HTTP/1.1 442 Unprocessable Entity"); |
header("HTTP/1.1 442 Unprocessable Entity"); |
||||
echo json_encode($fail_arr); |
echo json_encode($fail_arr); |
||||
exit(); |
exit(); |
||||
} |
} |
||||
$conn -> beginTransaction(); |
// $conn->beginTransaction(); |
||||
|
|
||||
|
$sql = "UPDATE contract_r_signed_back SET |
||||
}catch(PDOException $e){ |
repaireid = :repaireid,facilityno= :facilityno, invoice=:invoice, taxid=:taxid, address=:address,type=:type,contract_status=:contract_status,update_user=:update_user,update_date=:update_date |
||||
$conn->rollback(); |
WHERE id = :id"; |
||||
|
|
||||
|
$stmt = $conn->prepare($sql); |
||||
|
$stmt->bindParam(':repaireid', $repaireid); |
||||
|
$stmt->bindParam(':facilityno', $facilityno); |
||||
|
$stmt->bindParam(':invoice', $invoice); |
||||
|
$stmt->bindParam(':taxid', $taxid); |
||||
|
$stmt->bindParam(':address', $address); |
||||
|
$stmt->bindParam(':type', $type); |
||||
|
$stmt->bindParam(':contract_status', $contract_status); |
||||
|
$stmt->bindParam(':update_user', $user_id); |
||||
|
$stmt->bindParam(':update_date', $create_date); |
||||
|
|
||||
|
$stmt->bindParam(':id', $_POST['id']); |
||||
|
// echo json_encode($sql); |
||||
|
// exit; |
||||
|
$stmt->execute(); |
||||
|
// header("HTTP/1.1 204 NO Content"); |
||||
|
|
||||
|
// $conn->commit(); |
||||
|
} catch (PDOException $e) { |
||||
|
// $conn->rollback(); |
||||
header("HTTPP/1.1 500 Internal Server Error"); |
header("HTTPP/1.1 500 Internal Server Error"); |
||||
die('Error!:' .$e->getMessage()); |
die('Error!:' . $e->getMessage()); |
||||
} |
} |
||||
} |
} |
||||
if(isset($_POST['contractno']) && $_POST['contractno']!="" && isset($_POST["id"]) && $_POST['id']!=""){ |
// if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST["id"]) && $_POST['id'] != "") { |
||||
try{ |
// try { |
||||
$created_at = date('Y-m-d H:i:s'); |
// $created_at = date('Y-m-d H:i:s'); |
||||
$created_by = $_POST['user_id']; |
// $created_by = $_POST['user_id']; |
||||
$id = $_POST["id"]; |
// $id = $_POST["id"]; |
||||
$contract_no = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
// $contract_no = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
||||
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null; |
// $customer = !empty($_POST['customer']) ? $_POST['customer'] : null; |
||||
$manager = !empty($_POST['manager']) ? $_POST['manager'] : null; |
// $manager = !empty($_POST['manager']) ? $_POST['manager'] : null; |
||||
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null; |
// $vat = !empty($_POST['vat']) ? $_POST['vat'] : null; |
||||
$case_name = !empty($_POST['case_name']) ? $_POST['case_name'] : null; |
// $case_name = !empty($_POST['case_name']) ? $_POST['case_name'] : null; |
||||
$linkman = !empty($_POST['linkman']) ? $_POST['linkman'] : null; |
// $linkman = !empty($_POST['linkman']) ? $_POST['linkman'] : null; |
||||
$lm_tel = !empty($_POST['lm_tel']) ? $_POST['lm_tel'] : null; |
// $lm_tel = !empty($_POST['lm_tel']) ? $_POST['lm_tel'] : null; |
||||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
// $address = !empty($_POST['address']) ? $_POST['address'] : null; |
||||
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null; |
// $salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null; |
||||
$qc = !empty($_POST['qc']) ? $_POST['qc'] : null; |
// $qc = !empty($_POST['qc']) ? $_POST['qc'] : null; |
||||
$deletefiles = !empty($_POST['deletefiles']) ? $_POST['deletefiles'] : null; |
// $deletefiles = !empty($_POST['deletefiles']) ? $_POST['deletefiles'] : null; |
||||
$files_id = !empty($_POST['files_id']) ? $_POST['files_id'] : null; |
// $files_id = !empty($_POST['files_id']) ? $_POST['files_id'] : null; |
||||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
// $files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
||||
|
|
||||
$deletefilesArr = explode(',', $_POST['deletefiles']); |
// $deletefilesArr = explode(',', $_POST['deletefiles']); |
||||
|
|
||||
$fail_arr = []; |
// $fail_arr = []; |
||||
if(empty($contract_no)) $fail_arr[] = '合約號為必填'; |
// if (empty($contract_no)) $fail_arr[] = '合約號為必填'; |
||||
if(empty($customer)) $fail_arr[] = '客戶名稱為必填'; |
// if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; |
||||
if(empty($manager)) $fail_arr[] = '負責人為必填'; |
// if (empty($manager)) $fail_arr[] = '負責人為必填'; |
||||
if(empty($vat)) $fail_arr[] = '統編/身分證為必填'; |
// if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; |
||||
if(empty($case_name)) $fail_arr[] = '案名為必填'; |
// if (empty($case_name)) $fail_arr[] = '案名為必填'; |
||||
if(empty($linkman)) $fail_arr[] = '聯絡人為必填'; |
// if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; |
||||
if(empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; |
// if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; |
||||
if(empty($address)) $fail_arr[] = '地址為必填'; |
// if (empty($address)) $fail_arr[] = '地址為必填'; |
||||
if(empty($salesman)) $fail_arr[] = '營業員為必填'; |
// if (empty($salesman)) $fail_arr[] = '營業員為必填'; |
||||
if(empty($qc)) $fail_arr[] = '請選擇QC或管檢'; |
// if (empty($qc)) $fail_arr[] = '請選擇QC或管檢'; |
||||
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(); |
||||
} |
// } |
||||
|
|
||||
$conn->beginTransaction(); |
// $conn->beginTransaction(); |
||||
|
|
||||
$sql_str = "UPDATE contract_m_signed_back SET contract_no=:contract_no, customer=:customer, manager=:manager, vat=:vat, case_name=:case_name, linkman=:linkman, lm_tel=:lm_tel, address=:address, salesman=:salesman, qc_official_type=:qc WHERE id = :id"; |
// $sql_str = "UPDATE contract_m_signed_back SET contract_no=:contract_no, customer=:customer, manager=:manager, vat=:vat, case_name=:case_name, linkman=:linkman, lm_tel=:lm_tel, address=:address, salesman=:salesman, qc_official_type=:qc WHERE id = :id"; |
||||
$stmt = $conn -> prepare($sql_str); |
// $stmt = $conn->prepare($sql_str); |
||||
$stmt -> bindParam(':contract_no' ,$contract_no); |
// $stmt->bindParam(':contract_no', $contract_no); |
||||
$stmt -> bindParam(':customer' ,$customer); |
// $stmt->bindParam(':customer', $customer); |
||||
$stmt -> bindParam(':manager' ,$manager); |
// $stmt->bindParam(':manager', $manager); |
||||
$stmt -> bindParam(':vat' ,$vat); |
// $stmt->bindParam(':vat', $vat); |
||||
$stmt -> bindParam(':case_name' ,$case_name); |
// $stmt->bindParam(':case_name', $case_name); |
||||
$stmt -> bindParam(':linkman' ,$linkman); |
// $stmt->bindParam(':linkman', $linkman); |
||||
$stmt -> bindParam(':lm_tel' ,$lm_tel); |
// $stmt->bindParam(':lm_tel', $lm_tel); |
||||
$stmt -> bindParam(':address' ,$address); |
// $stmt->bindParam(':address', $address); |
||||
$stmt -> bindParam(':salesman' ,$salesman); |
// $stmt->bindParam(':salesman', $salesman); |
||||
$stmt -> bindParam(':qc' ,$qc); |
// $stmt->bindParam(':qc', $qc); |
||||
$stmt -> bindParam(':id' ,$id); |
// $stmt->bindParam(':id', $id); |
||||
$stmt -> execute(); |
// $stmt->execute(); |
||||
if(!empty($deletefiles)){ |
// if (!empty($deletefiles)) { |
||||
$sql_str = "DELETE FROM contract_back_files WHERE id IN ($deletefiles)"; |
// $sql_str = "DELETE FROM contract_back_files WHERE id IN ($deletefiles)"; |
||||
$stmt = $conn -> prepare($sql_str); |
// $stmt = $conn->prepare($sql_str); |
||||
$stmt -> execute(); |
// $stmt->execute(); |
||||
} |
// } |
||||
|
|
||||
if(!empty($files)){ |
// if (!empty($files)) { |
||||
$englisharr = range('a', 'z'); |
// $englisharr = range('a', 'z'); |
||||
$files = $_FILES['files']; |
// $files = $_FILES['files']; |
||||
$newfiles = []; |
// $newfiles = []; |
||||
foreach( $files as $file ){ |
// foreach ($files as $file) { |
||||
$i = 0; //新陣列的索引編號 |
// $i = 0; //新陣列的索引編號 |
||||
foreach( $file as $key => $val ){ |
// foreach ($file as $key => $val) { |
||||
$newfiles[$i]['name'] = $files['name'][$key]; |
// $newfiles[$i]['name'] = $files['name'][$key]; |
||||
$newfiles[$i]['type'] = $files['type'][$key]; |
// $newfiles[$i]['type'] = $files['type'][$key]; |
||||
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; |
// $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; |
||||
$newfiles[$i]['error'] = $files['error'][$key]; |
// $newfiles[$i]['error'] = $files['error'][$key]; |
||||
$newfiles[$i]['size'] = $files['size'][$key]; |
// $newfiles[$i]['size'] = $files['size'][$key]; |
||||
$i++; |
// $i++; |
||||
} //foreach 第2層 end |
// } //foreach 第2層 end |
||||
} |
// } |
||||
$max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M) |
// $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) |
||||
$allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型 |
// $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 |
||||
$path = '../images/contracts/'; |
// $path = '../images/contracts/'; |
||||
if (!file_exists($path)) { mkdir($path); } |
// if (!file_exists($path)) { |
||||
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 |
// mkdir($path); |
||||
$datetime = (string)date('YmdHis'); |
// } |
||||
$files_id = ($files_id !== null ) ? $files_id : 'm' . $datetime; // 新梯=>m + 日期時間 |
// $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 |
||||
foreach( $newfiles as $key => $file ){ |
// $datetime = (string)date('YmdHis'); |
||||
$randNum = rand(1000,9999); |
// $files_id = ($files_id !== null) ? $files_id : 'm' . $datetime; // 新梯=>m + 日期時間 |
||||
$randEnglish = $englisharr[rand(0,25)]; |
// foreach ($newfiles as $key => $file) { |
||||
$file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name']; |
// $randNum = rand(1000, 9999); |
||||
$msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name ); |
// $randEnglish = $englisharr[rand(0, 25)]; |
||||
if($msg==1){ |
// $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; |
||||
$msg = '檔案傳送成功!'; |
// $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); |
||||
$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)"; |
// if ($msg == 1) { |
||||
$stmt = $conn -> prepare($sql_str); |
// $msg = '檔案傳送成功!'; |
||||
$stmt -> bindParam(':files_id' ,$files_id); |
// $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 -> bindParam(':file_name' ,$file_name); |
// $stmt = $conn->prepare($sql_str); |
||||
$stmt -> bindParam(':file_mime' ,$file['type']); |
// $stmt->bindParam(':files_id', $files_id); |
||||
$stmt -> bindParam(':file_size' ,$file['size']); |
// $stmt->bindParam(':file_name', $file_name); |
||||
$stmt -> bindParam(':created_at' ,$created_at); |
// $stmt->bindParam(':file_mime', $file['type']); |
||||
$stmt -> bindParam(':created_by' ,$created_by); |
// $stmt->bindParam(':file_size', $file['size']); |
||||
$stmt ->execute(); |
// $stmt->bindParam(':created_at', $created_at); |
||||
}else{ |
// $stmt->bindParam(':created_by', $created_by); |
||||
throw new PDOException('檔案上傳失敗:' . $msg); |
// $stmt->execute(); |
||||
} |
// } else { |
||||
$msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '<br/>'; |
// throw new PDOException('檔案上傳失敗:' . $msg); |
||||
$src_name = $path.$file['name']; |
// } |
||||
if( file_exists($src_name) ){ |
// $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>'; |
||||
//副檔名 |
// $src_name = $path . $file['name']; |
||||
$extname = pathinfo($src_name, PATHINFO_EXTENSION); |
// if (file_exists($src_name)) { |
||||
//主檔名 |
// //副檔名 |
||||
$basename = basename($src_name, '.'.$extname); |
// $extname = pathinfo($src_name, PATHINFO_EXTENSION); |
||||
} |
// //主檔名 |
||||
} |
// $basename = basename($src_name, '.' . $extname); |
||||
}else{ |
// } |
||||
$files = null; |
// } |
||||
} |
// } else { |
||||
|
// $files = null; |
||||
$conn->commit(); |
// } |
||||
}catch(PDOException $e) { |
|
||||
$conn->rollback(); |
// $conn->commit(); |
||||
header("HTTP/1.1 500 Internal Server Error"); |
// } catch (PDOException $e) { |
||||
die('Error!:'.$e->getMessage()); |
// $conn->rollback(); |
||||
} |
// header("HTTP/1.1 500 Internal Server Error"); |
||||
|
// die('Error!:' . $e->getMessage()); |
||||
|
// } |
||||
|
// } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Loading…
Reference in new issue