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.
 
 
 
 
 
 

56 lines
1.5 KiB

<?php
/**
* 修理價審結案
* @url /wms/mkt/pricereview_repair_end-api.php
* @method POST
* @return JSON
*
* request
* {
* "pa"
* }
* pa : 價審單序號##總價##議價金額##完工日
* respons json
* {
* "st" : "ok",
* "err" : ""
* }
**/
ob_start();
include "../header.php";
ob_end_clean();
$rarr = array('st' => 'ok', 'err' => '');
try {
if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty");
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
list($id, $total_price, $final_price, $finish_date) = explode("##", $pa);
if (!$id || !$final_price || !$finish_date) throw new \Exception("parameter empty[2]");
$create_at = date("Y-m-d H:i:s");
$final_price = str_replace(",", "", $final_price);
$sql = "update pricereview_repair_main set final_price = '$final_price', finish_date = '$finish_date', pstatus = 'B2', ";
$sql .= "creater = '$user_id', create_at = '$create_at' where id = '$id'";
$res = mysqli_query($link, $sql);
$affected = mysqli_affected_rows($link);
if ($affected > 0) {
$rarr['tp'] = $total_price;
$rarr['fp'] = number_format($final_price);
$rarr['fp'] = number_format($final_price);
$rarr['fd'] = $finish_date;
} else {
$rarr['st'] = 'err';
$rarr['err'] = '無更新';
}
}catch(\Exception $e) {
$rarr['st'] = 'err';
$rarr['err'] = $e->getMessage();
}
echo json_encode($rarr, JSON_UNESCAPED_UNICODE);
exit;
?>