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.
 
 
 
 
 
 

92 lines
3.4 KiB

<?php
require_once "database.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$input = &$_POST;
if ($input["progress"] == "9") {
$data = array_reduce(array(
"reviewresult", "responsiblesupplier", "closer" , "ngfeedback_type"
), function ($acc, $key) use ($input) {
switch ($key) {
default:
$acc[$key] = htmlspecialchars(stripslashes(trim($input[$key]))) ?: null;
}
return $acc;
}, array("close_at" => date("Y-m-d H:i:s")));
$db_query = sprintf("UPDATE ngfeedback SET %s WHERE id = ?",
implode(",", array_map(
function ($_k) {
return sprintf("%s = ?", $_k);
}, array_keys($data)
)
));
$stmt = $link->prepare($db_query);
// 此處僅有字串格式
$stmt->bind_param(implode("", array_fill(0, count($data) + 1, "s")), ...array_values(array_merge($data, array("id" => $_POST["no"]))));
$stmt->execute();
if (mysqli_affected_rows($link) > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('更新成功');";
echo "window.location.href='/wms/ngfeedback-index.php?function_name=ngfeedback&token=".$_POST["token"]."';";
echo "</script>";
//header("Location: pricereview-index.php");
} else {
echo "<script type ='text/JavaScript'>";
echo "alert('更新失敗,請重新操作[I]')";
echo "</script>";
}
} else {
$data = array_reduce(array(
"responsibledepartment", "investigationreason", "countermeasure", "verify"
), function ($acc, $key) use ($input) {
switch ($key) {
default:
$acc[$key] = htmlspecialchars(stripslashes(trim($input[$key]))) ?: null;
}
return $acc;
}, array("progress" => "1", "update_at" => date("Y-m-d H:i:s")));
if ($data["responsibledepartment"]) {
$db_query = "SELECT accountid FROM account WHERE department_id = ? ORDER BY role_id ASC, create_at DESC LIMIT 0 , 1";
$stmt = $link->prepare($db_query);
// 此處僅有字串格式
$stmt->bind_param("s", $data["responsibledepartment"]);
$stmt->execute();
$result = $stmt->get_result();
$uarr = mysqli_fetch_assoc($result);
$data["responsibledepartmentleader"] = isset($uarr["accountid"]) ? $uarr["accountid"] : null;
// 責任單位回覆人預設主管
$data["responder"] = isset($uarr["accountid"]) ? $uarr["accountid"] : null;
}
if ($data["responsibledepartmentleader"]) {
$db_query = sprintf("UPDATE ngfeedback SET %s WHERE id = ?",
implode(",", array_map(
function ($_k) {
return sprintf("%s = ?", $_k);
}, array_keys($data)
)
));
$stmt = $link->prepare($db_query);
// 此處僅有字串格式
$stmt->bind_param(implode("", array_fill(0, count($data) + 1, "s")), ...array_values(array_merge($data, array("id" => $_POST["no"]))));
$stmt->execute();
if (mysqli_affected_rows($link) > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('更新成功');";
echo "window.location.href='/wms/ngfeedback-index.php?function_name=ngfeedback&token=".$_POST["token"]."';";
echo "</script>";
//header("Location: pricereview-index.php");
} else {
echo "<script type ='text/JavaScript'>";
echo "alert('更新失敗,請重新操作[I]')";
echo "</script>";
}
} else {
echo "<script type ='text/JavaScript'>";
echo "alert('更新失敗,請重新操作[L]')";
echo "</script>";
}
}
}
?>