@ -9,7 +9,7 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
exit();
}
//暫存、送審
if (isset($_POST['vol_no']) & & !empty($_POST['vol_no']) & & ($_POST['status'] == 0 || $_POST['status'] == 1)) {
if (isset($_POST['vol_no']) & & !empty($_POST['vol_no']) & & ($_POST['status'] == 0 || $_POST['status'] == 1) & & $_POST['progress'] < = 1 ) {
if ($_POST['regulations'] < 10 ) {
header("HTTP/1.1 500 傳送失敗!!試車時間不得低於10天");
exit;
@ -37,6 +37,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$tradedeadline = $_POST['tradedeadline'];
$secondPayDeadline = $_POST['secondPayDeadline'];
$pays = $_POST['pays'];
$description = $_POST['description'];
$status = $_POST['status']; // 0:暫存 1:送審 2:退回 3:完成
$pays = json_decode($pays, true);
@ -55,7 +56,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$conn->beginTransaction();
try {
if ($isFirst == 1) {
$sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, total_items, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, secondPayDeadline, progress, status, person, personname, submit_date, created_at, created_by) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :total_items, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :secondPayDeadline, :progress, :status, :person, :personname, :submit_date, :created_at, :created_by)";
$sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, total_items, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, secondPayDeadline, progress, status, person, personname, submit_date, created_at, created_by, description ) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :total_items, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :secondPayDeadline, :progress, :status, :person, :personname, :submit_date, :created_at, :created_by, :description )";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':contractno', $vol_no);
@ -85,6 +86,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt->bindParam(':submit_date', $submit_date);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $created_by);
$stmt->bindParam(':description', $description);
$stmt->execute();
$contract_apply_id = $conn->lastInsertId();
foreach ($pays as $idx => $pay) {
@ -160,7 +162,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
header("HTTP/1.1 201 success!");
$conn->commit();
} else {
$sql_str = "UPDATE contract_new_apply SET status = :status, apply_date=:apply_date, apply_type=:apply_type, case_name=:case_name, customer=:customer, manager=:manager, vat=:vat, total_price=:total_price, total_items=:total_items, buy_fee=:buy_fee, install_fee=:install_fee, contact_address=:contact_address, trade_address=:trade_address, workdeadline_a=:workdeadline_a, workdeadline_b=:workdeadline_b, test_time=:test_time, freedeadline=:freedeadline, trade_address=:trade_address, trade_address=:trade_address, tradedeadline=:tradedeadline, secondPayDeadline=:secondPayDeadline, progress=:progress, person=:person, personname=:personname, submit_date=:submit_date, updated_at=:updated_at, updated_by=:updated_by WHERE mid = :mid";
$sql_str = "UPDATE contract_new_apply SET status = :status, apply_date=:apply_date, apply_type=:apply_type, case_name=:case_name, customer=:customer, manager=:manager, vat=:vat, total_price=:total_price, total_items=:total_items, buy_fee=:buy_fee, install_fee=:install_fee, contact_address=:contact_address, trade_address=:trade_address, workdeadline_a=:workdeadline_a, workdeadline_b=:workdeadline_b, test_time=:test_time, freedeadline=:freedeadline, trade_address=:trade_address, trade_address=:trade_address, tradedeadline=:tradedeadline, secondPayDeadline=:secondPayDeadline, progress=:progress, person=:person, personname=:personname, submit_date=:submit_date, updated_at=:updated_at, updated_by=:updated_by, description=:description WHERE mid = :mid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':status', $status);
@ -188,6 +190,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt->bindParam(':submit_date', $submit_date);
$stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':updated_by', $updated_by);
$stmt->bindParam(':description', $description);
$stmt->execute();
foreach ($pays as $idx => $pay) {
@ -205,7 +208,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt->execute();
}
$deleted_at = date("Y-m-d H:i:s");
$removefiles = json_decode($_POST['removefiles'], true);
$removefiles = isset($_POST['removefiles']) ? json_decode($_POST['removefiles'], true) : [] ;
print_r($removefiles);
if(count($removefiles) > 0){
foreach($removefiles as $file){
@ -216,10 +219,6 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt ->execute();
}
}
header("HTTP/1.1 201 success!");
$conn->commit();
}
@ -230,6 +229,35 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
die('Error!:' . $e->getMessage());
}
}
//業務部承辦人同意
if (isset($_POST['vol_no']) & & !empty($_POST['vol_no']) & & ($_POST['status'] == 1) & & $_POST['progress'] == 2) {
$status = $_POST['status'];
$vol_no = $_POST['vol_no'];
$contract_new_apply_id = $_POST['contract_new_apply_id'];
$progress = $_POST['progress'];
$review_comment = $_POST['review_comment'];
$user_id = $_POST['review_person_id'];
$review_date = date('Y-m-d H:i:s');
$conn->beginTransaction();
try {
$sql_str = "UPDATE contract_new_apply SET status = :status, progress = :progress, review_comment=:review_comment, review_person_id=:review_person_id, review_date=:review_date WHERE id = :contract_new_apply_id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':progress', $progress);
$stmt->bindParam(':contract_new_apply_id', $contract_new_apply_id);
$stmt->bindParam(':review_comment', $review_comment);
$stmt->bindParam(':review_person_id', $user_id);
$stmt->bindParam(':review_date', $review_date);
$stmt->execute();
header("HTTP/1.1 200 success!");
$conn->commit();
} catch (PDOException $e) {
$conn->rollback();
header("HTTP/1.1 500 failed!");
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
}
//結案同意
if (isset($_POST['vol_no']) & & !empty($_POST['vol_no']) & & ($_POST['status'] == 3)) {
$status = $_POST['status'];
@ -241,7 +269,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$review_date = date('Y-m-d H:i:s');
$conn->beginTransaction();
try {
$sql_str = "UPDATE contract_new_apply SET status = :status, progress = :progress, review_comment=:review_comment, review_person_id=:review_person_id, review_date=:review_date WHERE id = :contract_new_apply_id";
$sql_str = "UPDATE contract_new_apply SET status = :status, progress = :progress, review_final_ comment=:review_comment, review_final_ person_id=:review_person_id, review_final _date=:review_date WHERE id = :contract_new_apply_id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':progress', $progress);