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