18 changed files with 5789 additions and 5357 deletions
@ -1,110 +1,115 @@ |
|||
<?php |
|||
class IncludeCommon |
|||
{ |
|||
function CheckToken($token) { |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$encryption_code = "MASADA!^***"; |
|||
$time = date("Y-m-d H:i:s"); |
|||
|
|||
if (!isset($token) || empty($token)) { |
|||
$data['code'] = '400'; |
|||
$data['message'] = '非法请求'; |
|||
return $data; |
|||
} |
|||
//对比token |
|||
$explode = explode('.', $token); //以.分割token为数组 |
|||
if (!empty($explode[0]) && !empty($explode[1]) && !empty($explode[2]) && !empty($explode[3]) && !empty($explode[4])) { |
|||
$info = $explode[0] . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; //信息部分 |
|||
$true_signature = hash_hmac('md5', $info, $encryption_code); //正确的签名 |
|||
if ($time > $explode[2]) { |
|||
$data['user_id'] = ''; |
|||
$data['user_name'] = ''; |
|||
$data['code'] = '401'; |
|||
$data['message'] = 'Token已过期,请重新登录'; |
|||
return $data; |
|||
} |
|||
if ($true_signature == $explode[4]) { |
|||
$data['user_id'] = $explode[0]; |
|||
$data['user_name'] = $explode[3]; |
|||
$data['code'] = '200'; |
|||
$data['message'] = 'Token合法'; |
|||
return $data; |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$data['user_name'] = ''; |
|||
$data['code'] = '400'; |
|||
$data['message'] = 'Token不合法'; |
|||
return $data; |
|||
} |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$data['user_name'] = ''; |
|||
$data['code'] = '400'; |
|||
$data['message'] = 'Token不合法'; |
|||
return $data; |
|||
} |
|||
} |
|||
//生成登录记录 |
|||
function save_log_response($source_flag='web', $account, $response_result){ |
|||
# 储存纪录并输出 |
|||
#echo date("Y-m-d"); |
|||
$file_path = "account_log/" . $account . "-" . date("Y-m-d") . ".ini"; |
|||
$data = serialize($response_result). date("H:i:s") . "\n"; |
|||
$fp = fopen($file_path,"a"); # 如果档案不存在择尝试建立再写入 |
|||
fwrite($fp, $data); |
|||
fclose($fp); |
|||
if ($source_flag == "web"){ |
|||
// header("Location: custom-create.php?function_list=" . serialize($response_result) . |
|||
// "&token=" . $response_result["token"]); #请输入使用者名称密码 |
|||
// exit(); |
|||
return true; |
|||
}else{ |
|||
// echo json_encode($response_result, JSON_UNESCAPED_UNICODE); |
|||
return false; |
|||
} |
|||
|
|||
/* |
|||
if ($source_flag == "app"){ |
|||
echo json_encode($response_result, JSON_UNESCAPED_UNICODE); |
|||
}elseif ($source_flag == "web"){ |
|||
header("Location: api-account-reply-functions.php?function_list=" . serialize($response_result) . |
|||
"&token=" . $response_result["token"]); #请输入使用者名称密码 |
|||
exit(); |
|||
} |
|||
*/ |
|||
} |
|||
|
|||
//生成token |
|||
function CreateToken($user_id, $user_name) { |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$start_time = date("Y-m-d H:i:s"); |
|||
$end_time = date('Y-m-d H:i:s',strtotime('+24 hour')); #设定24小时 |
|||
$info = $user_id . '.' . $start_time . '.' . $end_time . '.' . $user_name; //设置token过期时间为一天 |
|||
$encryption_code = "MASADA!^***"; |
|||
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量) |
|||
$signature = hash_hmac('md5', $info, $encryption_code); |
|||
//最后将这两部分拼接起来,得到最终的Token字符串 |
|||
return $token = $info . '.' . $signature; |
|||
} |
|||
//生成菜单 |
|||
|
|||
function menu ($from='tw',$type){ |
|||
$function_type = array( |
|||
"tw" => array( |
|||
# F角色菜单 |
|||
"H" => array( |
|||
"language" => "tw", |
|||
"type" => "manage", |
|||
"list" => array( |
|||
array("name" => "批量导入", "path" => "http://192.168.0.12/wms/excel-upload"), |
|||
), |
|||
"note" => "none", |
|||
"token" => "" |
|||
), |
|||
) |
|||
); |
|||
|
|||
return $function_type[$from][$type]; |
|||
|
|||
} |
|||
} |
|||
<?php |
|||
// phpinfo(); |
|||
// exit; |
|||
class IncludeCommon |
|||
{ |
|||
function CheckToken($token) |
|||
{ |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$encryption_code = "MASADA!^***"; |
|||
$time = date("Y-m-d H:i:s"); |
|||
|
|||
if (!isset($token) || empty($token)) { |
|||
$data['code'] = '400'; |
|||
$data['message'] = '非法請求'; |
|||
return $data; |
|||
} |
|||
//对比token |
|||
$explode = explode('.', $token); //以.分割token为数组 |
|||
if (!empty($explode[0]) && !empty($explode[1]) && !empty($explode[2]) && !empty($explode[3]) && !empty($explode[4])) { |
|||
$info = $explode[0] . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; //信息部分 |
|||
$true_signature = hash_hmac('md5', $info, $encryption_code); //正确的签名 |
|||
if ($time > $explode[2]) { |
|||
$data['user_id'] = ''; |
|||
$data['user_name'] = ''; |
|||
$data['code'] = '401'; |
|||
$data['message'] = 'Token已過期,請重新登入'; |
|||
return $data; |
|||
} |
|||
if ($true_signature == $explode[4]) { |
|||
$data['user_id'] = $explode[0]; |
|||
$data['user_name'] = $explode[3]; |
|||
$data['code'] = '200'; |
|||
$data['message'] = 'Token合法'; |
|||
return $data; |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$data['user_name'] = ''; |
|||
$data['code'] = '400'; |
|||
$data['message'] = 'Token不合法'; |
|||
return $data; |
|||
} |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$data['user_name'] = ''; |
|||
$data['code'] = '400'; |
|||
$data['message'] = 'Token不合法'; |
|||
return $data; |
|||
} |
|||
} |
|||
//生成登录记录 |
|||
function save_log_response($source_flag = 'web', $account, $response_result) |
|||
{ |
|||
# 储存纪录并输出 |
|||
#echo date("Y-m-d"); |
|||
$file_path = "account_log/" . $account . "-" . date("Y-m-d") . ".ini"; |
|||
$data = serialize($response_result) . date("H:i:s") . "\n"; |
|||
$fp = fopen($file_path, "a"); # 如果档案不存在择尝试建立再写入 |
|||
fwrite($fp, $data); |
|||
fclose($fp); |
|||
if ($source_flag == "web") { |
|||
// header("Location: custom-create.php?function_list=" . serialize($response_result) . |
|||
// "&token=" . $response_result["token"]); #请输入使用者名称密码 |
|||
// exit(); |
|||
return true; |
|||
} else { |
|||
// echo json_encode($response_result, JSON_UNESCAPED_UNICODE); |
|||
return false; |
|||
} |
|||
|
|||
/* |
|||
if ($source_flag == "app"){ |
|||
echo json_encode($response_result, JSON_UNESCAPED_UNICODE); |
|||
}elseif ($source_flag == "web"){ |
|||
header("Location: api-account-reply-functions.php?function_list=" . serialize($response_result) . |
|||
"&token=" . $response_result["token"]); #请输入使用者名称密码 |
|||
exit(); |
|||
} |
|||
*/ |
|||
} |
|||
|
|||
//生成token |
|||
function CreateToken($user_id, $user_name) |
|||
{ |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$start_time = date("Y-m-d H:i:s"); |
|||
$end_time = date('Y-m-d H:i:s', strtotime('+24 hour')); #设定24小时 |
|||
$info = $user_id . '.' . $start_time . '.' . $end_time . '.' . $user_name; //设置token过期时间为一天 |
|||
$encryption_code = "MASADA!^***"; |
|||
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量) |
|||
$signature = hash_hmac('md5', $info, $encryption_code); |
|||
//最后将这两部分拼接起来,得到最终的Token字符串 |
|||
return $token = $info . '.' . $signature; |
|||
} |
|||
//生成菜单 |
|||
|
|||
function menu($from = 'tw', $type) |
|||
{ |
|||
$function_type = array( |
|||
"tw" => array( |
|||
# F角色菜单 |
|||
"H" => array( |
|||
"language" => "tw", |
|||
"type" => "manage", |
|||
"list" => array( |
|||
array("name" => "批量导入", "path" => "http://192.168.0.12/wms/excel-upload"), |
|||
), |
|||
"note" => "none", |
|||
"token" => "" |
|||
), |
|||
) |
|||
); |
|||
|
|||
return $function_type[$from][$type]; |
|||
} |
|||
} |
|||
|
@ -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{ |
|||
$id = $_GET['contractid']; |
|||
$user_id = $_GET['user_id']; |
|||
$date = date('Y-m-d H:i:s'); |
|||
$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->execute(); |
|||
header("HTTP/1.1 204 NO Content"); |
|||
}catch(PDOException $e){ |
|||
die("ERROR!!!". $e->getMessage()); |
|||
} |
|||
} |
|||
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()); |
|||
} |
|||
} |
|||
?> |
|||
<?php |
|||
require_once("../conn.php"); |
|||
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'; |
|||
$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->execute(); |
|||
header("HTTP/1.1 204 NO Content"); |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!!" . $e->getMessage()); |
|||
} |
|||
} |
|||
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()); |
|||
} |
|||
} |
|||
|
@ -1,106 +1,122 @@ |
|||
<?php |
|||
require_once('../conn.php'); |
|||
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'b') { |
|||
try { |
|||
$contractno = $_GET['contractno']; |
|||
$sql_str = "SELECT con_maintance_examine_apply.*, con_maintance_examine_clear.* FROM con_maintance_examine_apply |
|||
JOIN con_maintance_examine_clear on con_maintance_examine_apply.apply_key=con_maintance_examine_clear.apply_key |
|||
WHERE con_maintance_examine_apply.vol_no = :vol_no ;"; |
|||
$sql_str = "SELECT * FROM con_maintance_examine_apply WHERE vol_no = :vol_no ORDER BY create_at DESC;"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contractno); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
|
|||
if (empty($contract)) { |
|||
echo false; |
|||
exit; |
|||
} |
|||
$apply_key = $contract['apply_key']; |
|||
$sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key = :apply_key"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':apply_key', $apply_key); |
|||
$stmt->execute(); |
|||
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$count = COUNT($elevators); |
|||
$contract['elevators'] = $elevators; |
|||
$contract['num'] = $count; |
|||
|
|||
$contractResponse = json_encode($contract); |
|||
|
|||
// 設定回應標頭為 JSON |
|||
header('Content-Type: application/json'); |
|||
|
|||
// 將 JSON 回應返回給客戶端 |
|||
echo $contractResponse; |
|||
// echo json_encode($contractResponse); |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'm') { |
|||
try { |
|||
$contractno = $_GET['contractno']; |
|||
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contractno); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$contractResponse = json_encode($contract); |
|||
|
|||
// 設定回應標頭為 JSON |
|||
header('Content-Type: application/json'); |
|||
|
|||
// 將 JSON 回應返回給客戶端 |
|||
echo $contractResponse; |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
} |
|||
////////////////////////////// |
|||
//// 合約簽回(修理) |
|||
//// |
|||
//// 製作人:梓誠 |
|||
/// 時間 : |
|||
////////////////////////////// |
|||
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') { |
|||
try { |
|||
$contractno = $_GET['contractno']; |
|||
$fail_arr = []; |
|||
|
|||
$sql = "SELECT COUNT(*) AS num FROM pricereview_repair_main WHERE contractno = :contractno"; |
|||
$stmt = $conn->prepare($sql); |
|||
|
|||
$stmt->bindParam(":contractno", $contractno); |
|||
$stmt->execute(); |
|||
$result = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$count = $result['num']; |
|||
if ($count > 1) { |
|||
$fail_arr[] = '合約單號重複,請至契約管理(修理)查看。'; |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
// $contractno = $_GET['contractno']; |
|||
$sql = "SELECT a.*,b.name,b.accountid |
|||
FROM pricereview_repair_main AS a |
|||
LEFT JOIN account AS b |
|||
ON a.repairerid = b.accountid |
|||
WHERE a.contractno = :contractno "; |
|||
$stmt = $conn->prepare($sql); |
|||
|
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$contractResponse = json_encode($contract); |
|||
|
|||
// 設定回應標頭為 JSON |
|||
header('Content-Type : appliction/json'); |
|||
|
|||
// 將 JSON 回應給客戶端 |
|||
echo $contractResponse; |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!:" . $e->getMessage()); |
|||
} |
|||
} |
|||
<?php |
|||
require_once('../conn.php'); |
|||
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'b') { |
|||
try { |
|||
$contractno = $_GET['contractno']; |
|||
$sql_str = "SELECT con_maintance_examine_apply.*, con_maintance_examine_clear.* FROM con_maintance_examine_apply |
|||
JOIN con_maintance_examine_clear on con_maintance_examine_apply.apply_key=con_maintance_examine_clear.apply_key |
|||
WHERE con_maintance_examine_apply.vol_no = :vol_no ;"; |
|||
$sql_str = "SELECT * FROM con_maintance_examine_apply WHERE vol_no = :vol_no ORDER BY create_at DESC;"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contractno); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
|
|||
if (empty($contract)) { |
|||
echo false; |
|||
exit; |
|||
} |
|||
$apply_key = $contract['apply_key']; |
|||
$sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key = :apply_key"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':apply_key', $apply_key); |
|||
$stmt->execute(); |
|||
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$count = COUNT($elevators); |
|||
$contract['elevators'] = $elevators; |
|||
$contract['num'] = $count; |
|||
|
|||
$contractResponse = json_encode($contract); |
|||
|
|||
// 設定回應標頭為 JSON |
|||
header('Content-Type: application/json'); |
|||
|
|||
// 將 JSON 回應返回給客戶端 |
|||
echo $contractResponse; |
|||
// echo json_encode($contractResponse); |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'm') { |
|||
try { |
|||
$contractno = $_GET['contractno']; |
|||
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contractno); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$contractResponse = json_encode($contract); |
|||
|
|||
// 設定回應標頭為 JSON |
|||
header('Content-Type: application/json'); |
|||
|
|||
// 將 JSON 回應返回給客戶端 |
|||
echo $contractResponse; |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
} |
|||
////////////////////////////// |
|||
//// 合約簽回(修理) |
|||
//// |
|||
//// 製作人:梓誠 |
|||
/// 時間 : |
|||
////////////////////////////// |
|||
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') { |
|||
try { |
|||
$contractno = $_GET['contractno']; |
|||
$fail_arr = []; |
|||
$d_status = '1'; |
|||
// 判斷單號是否在合約簽核已建立 |
|||
$sql = "SELECT COUNT(*) AS num FROM contract_r_signed_back WHERE contractno = :contractno AND delete_status = :d_status "; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(":contractno", $contractno); |
|||
$stmt->bindParam(":d_status", $d_status); |
|||
$stmt->execute(); |
|||
$result = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$count = $result['num']; |
|||
if ($count >= 1) { |
|||
$fail_arr[] = '合約單號重複,請至契約管理(修理)查看。'; |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
// 判斷單號是否在價格審查中以建立。 |
|||
$sql = "SELECT COUNT(*) AS num FROM pricereview_repair_main WHERE contractno = :contractno"; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(":contractno", $contractno); |
|||
$stmt->execute(); |
|||
$result2 = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$count2 = $result2['num']; |
|||
if ($count2 == 0) { |
|||
$fail_arr[] = '找不到單號,請再確認。'; |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
|
|||
|
|||
// $contractno = $_GET['contractno']; |
|||
$sql = "SELECT a.*,b.name,b.accountid |
|||
FROM pricereview_repair_main AS a |
|||
LEFT JOIN account AS b |
|||
ON a.repairerid = b.accountid |
|||
WHERE a.contractno = :contractno "; |
|||
$stmt = $conn->prepare($sql); |
|||
|
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$contractResponse = json_encode($contract); |
|||
|
|||
// 設定回應標頭為 JSON |
|||
header('Content-Type : appliction/json'); |
|||
|
|||
// 將 JSON 回應給客戶端 |
|||
echo $contractResponse; |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!:" . $e->getMessage()); |
|||
} |
|||
} |
|||
|
@ -1,412 +1,420 @@ |
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./getFacilityNo.php"); |
|||
include_once("./getComboNo.php"); |
|||
include_once("./upload_chk.php"); |
|||
ini_set ( 'date.timezone' , 'Asia/Taipei' ); |
|||
//保養簽回 |
|||
if(isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { |
|||
try{ |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$contractno = !empty($_POST['contractno'])? $_POST['contractno'] : null; |
|||
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|||
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null; |
|||
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] :null; |
|||
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor']: null; |
|||
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null; |
|||
$email = !empty($_POST['email']) ? $_POST['email'] : null; |
|||
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null; |
|||
$mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null; |
|||
$salesman = !empty($_POST['salesman']) ?$_POST['salesman'] : null; |
|||
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null; |
|||
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null; |
|||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
|||
$area = !empty($_POST['area']) ? $_POST['area'] : null; |
|||
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null; |
|||
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null; |
|||
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null; |
|||
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null; |
|||
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null; |
|||
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|||
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null; |
|||
$num = !empty($_POST['num']) ? $_POST['num'] : null; |
|||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|||
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; |
|||
// validate |
|||
$fail_arr = []; |
|||
if($contractno === '') return $fail_arr[] = '合約號為必填'; |
|||
|
|||
if($total_price == '') $fail_arr[] = '合約總價為必填'; |
|||
if($vat == '') $fail_arr[] = '統一編號為必填'; |
|||
if($mtype == '') $fail_arr[] = '維修型態為必填'; |
|||
if($phone == '') $fail_arr[] = '客戶電話為必填'; |
|||
if($email == '') $fail_arr[] = 'Email為必填'; |
|||
if($mworker == '') $fail_arr[] = '保養員為必填'; |
|||
if($mcycle == '') $fail_arr[] = '保養頻率為必填'; |
|||
if($salesman == '') $fail_arr[] = '營業員為必填'; |
|||
if($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填'; |
|||
if($contract_end_date == '') $fail_arr[] = '合約結束時間為必填'; |
|||
if($address == '') $fail_arr[] = '地址為必填'; |
|||
if($area == '') $fail_arr[] = '區域為必填'; |
|||
if($customer == '') $fail_arr[] = '客戶為必填'; |
|||
if($partyA == '') $fail_arr[] = '業務聯繫人為必填'; |
|||
if($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; |
|||
if($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; |
|||
if($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; |
|||
if($num == '') $fail_arr[] = '電梯數量為必填'; |
|||
if(count($fail_arr) > 0) { |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
|
|||
//create account table |
|||
$accounttype = "A"; |
|||
$accountid = $vat; |
|||
$pwd = "123"; |
|||
$name = $partyA; |
|||
$tel = $phone ?? ''; |
|||
$repairerid = $mworker; |
|||
$creater = $user_id; |
|||
$create_at = date('Y-m-d H:i:s'); |
|||
|
|||
$conn->beginTransaction(); |
|||
|
|||
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':accounttype' ,$accounttype); |
|||
$stmt -> bindParam(':accountid' ,$accountid); |
|||
$stmt -> bindParam(':pwd' ,$pwd); |
|||
$stmt -> bindParam(':name' ,$name); |
|||
$stmt -> bindParam(':tel' ,$tel); |
|||
$stmt -> bindParam(':address' ,$address); |
|||
$stmt -> bindParam(':email' ,$email); |
|||
$stmt -> bindParam(':repairerid' ,$repairerid); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$stmt -> execute(); |
|||
|
|||
//create contract table |
|||
|
|||
$contracttype = $mtype; |
|||
$company = $partyA; |
|||
$taxid = $vat; |
|||
$tel = $phone; |
|||
$promiser = $partyA; |
|||
$contractperson = $partyA; |
|||
|
|||
$contractaddress = $address; |
|||
$contracttel = $phone; |
|||
$contractemail = $email; |
|||
$contract_employee = $salesman; |
|||
$start_date = $contract_begin_date; |
|||
$end_date = $contract_end_date; |
|||
|
|||
$sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':contracttype' ,$contracttype); |
|||
$stmt -> bindParam(':contractno' ,$contractno); |
|||
$stmt -> bindParam(':company' ,$company); |
|||
$stmt -> bindParam(':taxid' ,$taxid); |
|||
$stmt -> bindParam(':address' ,$address); |
|||
$stmt -> bindParam(':tel' ,$tel); |
|||
$stmt -> bindParam(':promiser' ,$promiser); |
|||
$stmt -> bindParam(':contractperson' ,$contractperson); |
|||
$stmt -> bindParam(':contractaddress' ,$contractaddress); |
|||
$stmt -> bindParam(':contracttel' ,$contracttel); |
|||
$stmt -> bindParam(':contractemail' ,$contractemail); |
|||
$stmt -> bindParam(':contract_employee' ,$contract_employee); |
|||
$stmt -> bindParam(':start_date' ,$start_date); |
|||
$stmt -> bindParam(':end_date' ,$end_date); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$stmt -> execute(); |
|||
|
|||
//create facility table |
|||
$createFacilityNo = new CreateFacilityNo(); |
|||
$dailyNecessities = [ |
|||
'MAE100'=>'X', |
|||
'MAM200'=>'W', |
|||
'MAH100'=>'H', |
|||
'MAQ100'=>'Z', |
|||
'MAF100'=>'F', |
|||
'MAZ100'=>'B', |
|||
]; |
|||
$facility_arr = []; |
|||
foreach($elevators as $elevator){ |
|||
$facility_arr[] = $dailyNecessities[$elevator['spec']]; |
|||
} |
|||
echo json_encode($facility_arr); |
|||
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); |
|||
echo json_encode($facilityno); |
|||
echo '-------'; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accountid',$mworker); |
|||
$stmt->execute(); |
|||
$worker = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$customerid = $vat; |
|||
$define = "B"; |
|||
$repairtype = $mtype; |
|||
$repairerid = $mworker; |
|||
$repairername = $worker['name']; |
|||
foreach($elevators as $idx=>$elevator){ |
|||
$sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) |
|||
VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':contractno' ,$contractno); |
|||
$stmt -> bindParam(':define' ,$define); |
|||
$stmt -> bindParam(':facilityno' ,$facilityno[$idx]); |
|||
$stmt -> bindParam(':latitude' ,$elevator['latitude']); |
|||
$stmt -> bindParam(':longitude' ,$elevator['longitude']); |
|||
$stmt -> bindParam(':customerid' ,$customerid); |
|||
$stmt -> bindParam(':weight' ,$elevator['weight']); |
|||
$stmt -> bindParam(':numberofpassenger' ,$elevator['persons']); |
|||
$stmt -> bindParam(':numberofstop' ,$elevator['stop']); |
|||
$stmt -> bindParam(':numberoffloor' ,$elevator['floors']); |
|||
$stmt -> bindParam(':opentype' ,$elevator['opendoor']); |
|||
$stmt -> bindParam(':speed' ,$elevator['speed']); |
|||
$stmt -> bindParam(':repairtype' ,$repairtype); |
|||
$stmt -> bindParam(':maintainance' ,$elevator['maintainance']); |
|||
$stmt -> bindParam(':facility_kind' ,$elevator['spec']); |
|||
$stmt -> bindParam(':address' ,$address); |
|||
$stmt -> bindParam(':repairerid' ,$repairerid); |
|||
$stmt -> bindParam(':repairername' ,$repairername); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$stmt -> bindParam(':area' ,$area); |
|||
$stmt -> bindParam(':takecertificatedate' ,$elevator['takecertificatedate']); |
|||
$stmt -> bindParam(':licensedate' ,$elevator['useful_date']); |
|||
$result = $stmt -> execute(); |
|||
} |
|||
|
|||
//create schedule table |
|||
|
|||
$comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); |
|||
$comboArr = json_decode($comboNo->getComboNo(), true); |
|||
foreach($facilityno as $no){ |
|||
foreach($comboArr as $combo){ |
|||
$sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':contractno' ,$contractno); |
|||
$stmt -> bindParam(':facilityno' ,$no); |
|||
$stmt -> bindParam(':combono' ,$combo[0]); |
|||
$stmt -> bindParam(':repairerid' ,$repairerid); |
|||
$stmt -> bindParam(':repairername' ,$repairername); |
|||
$stmt -> bindParam(':duedate' ,$combo[1]); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$result = $stmt -> execute(); |
|||
} |
|||
} |
|||
// create contract_b_signed_back table |
|||
$contract_type = $mtype; |
|||
$company = $customer; |
|||
$customer_no = $vat; |
|||
$salesperson = $salesman; |
|||
$customer_phone = $phone; |
|||
$customer_email = $email; |
|||
$repairman = $mworker; |
|||
$cycle = $mcycle; |
|||
$contact_person = $partyA; |
|||
$contact_address = $partyAaddress; |
|||
$contact_phone = $partyAphone; |
|||
$contract_email = $partyAemail; |
|||
$elevators_number = $num; |
|||
$bonus = 1000; |
|||
$max_bonus = 2000; |
|||
|
|||
if(!empty($files)){ |
|||
$englisharr = range('a', 'z'); |
|||
$file = $_FILES['files']; |
|||
$file_name = $file['name']; |
|||
$file_type = $file['type']; |
|||
$tmp_name = $file['tmp_name']; |
|||
$file_size = $file['size']; |
|||
$error = $file['error']; |
|||
$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 = 'b' . $datetime; // 保養=>b + 日期時間 |
|||
foreach( $newfiles as $key => $file ){ |
|||
$randNum = rand(1000,9999); |
|||
$randEnglish = $englisharr[rand(0,25)]; |
|||
$file_name = 'b' . (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' ,$user_id); |
|||
$stmt ->execute(); |
|||
} |
|||
$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; |
|||
} |
|||
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by) |
|||
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(":contract_no",$contractno); |
|||
$stmt -> bindParam(":contract_type",$contract_type); |
|||
$stmt -> bindParam(":company",$company); |
|||
$stmt -> bindParam(":customer_no",$customer_no); |
|||
$stmt -> bindParam(":salesperson",$salesperson); |
|||
$stmt -> bindParam(":contract_start_date",$contract_begin_date); |
|||
$stmt -> bindParam(":contract_end_date",$contract_end_date); |
|||
$stmt -> bindParam(":total_price",$total_price); |
|||
$stmt -> bindParam(":customer_phone",$customer_phone); |
|||
$stmt -> bindParam(":customer_email",$customer_email); |
|||
$stmt -> bindParam(":repairman",$repairman); |
|||
$stmt -> bindParam(":cycle",$cycle); |
|||
$stmt -> bindParam(":contact_person",$contact_person); |
|||
$stmt -> bindParam(":contact_address",$contact_address); |
|||
$stmt -> bindParam(":contact_phone",$contact_phone); |
|||
$stmt -> bindParam(":contact_email",$contact_email); |
|||
$stmt -> bindParam(":elevators_number",$elevators_number); |
|||
$stmt -> bindParam(":area",$area); |
|||
$stmt -> bindParam(":address",$address); |
|||
$stmt -> bindParam(":files_id",$files_id); |
|||
$stmt -> bindParam(":bonus",$bonus); |
|||
$stmt -> bindParam(":max_bonus",$max_bonus); |
|||
$stmt -> bindParam(":created_at", $created_at); |
|||
$stmt -> bindParam(":created_by",$user_id); |
|||
|
|||
$stmt -> execute(); |
|||
|
|||
header('Content-Type: application/json'); |
|||
// $jsonData = json_encode($files); |
|||
|
|||
$conn->commit(); |
|||
}catch(PDOException $e){ |
|||
$conn->rollback(); |
|||
echo $e->getMessage(); |
|||
die('Error!:'.$e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////// |
|||
//// 合約簽回(修理) |
|||
//// |
|||
//// 製作人:梓誠 |
|||
/// 時間 : |
|||
////////////////////////////// |
|||
if(isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'r'){ |
|||
try{ |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
|||
$company = !empty($_POST['company']) ? $_POST['company'] : null; |
|||
$repairid = !empty($_POST['repairid']) ? $_POST['repairid'] : null; |
|||
$facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null; |
|||
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; |
|||
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null; |
|||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
|||
$repair_no = !empty($_POST['repair_no']) ? $_POST['repair_no'] : null; |
|||
$total_price= !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|||
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|||
$type = !empty($_POST['type']) ? $_POST['type'] : null; |
|||
$sign_date = !empty($_POST['sign_date']) ? $_POST['sign_date']: null; |
|||
|
|||
$fail_arr = []; |
|||
if($contractno === '') return $fail_arr[] = '合約號為必填'; |
|||
if($repair_no === '') return $fail_arr[] = '報價單編號為必填'; |
|||
if($company === '') return $fail_arr[] = '客戶名稱為必填'; |
|||
// if($taxid === '') return $fail_arr[] = '統一編號為必填'; |
|||
if($facilityno === '') return $fail_arr[] = '電梯編號為必填'; |
|||
if($address === '') return $fail_arr[] = '工程地址為必填'; |
|||
if($type === '') return $fail_arr[] = '工程類別為必填'; |
|||
if($invoice === '') return $fail_arr[] = '發票抬頭為必填'; |
|||
if(count($fail_arr)>0){ |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
// exit(); |
|||
//create contrac_r_signed_back table |
|||
$conn -> beginTransaction(); |
|||
$sql = "INSERT INTO contract_r_signed_back( |
|||
repair_no, |
|||
contractno, |
|||
company, |
|||
taxid, |
|||
facilityno, |
|||
address, |
|||
type, |
|||
invoice, |
|||
repaireid, |
|||
total_price, |
|||
sign_date, |
|||
create_userid, |
|||
create_date) VALUES( |
|||
:repair_no, |
|||
:contractno, |
|||
:company, |
|||
:taxid, |
|||
:facilityno, |
|||
:address, |
|||
:type, |
|||
:invoice, |
|||
:repaireid, |
|||
:total_price, |
|||
:sign_date, |
|||
:create_userid, |
|||
:create_date |
|||
)"; |
|||
$stmt = $conn -> prepare($sql); |
|||
$stmt -> bindParam(":repair_no",$repair_no); |
|||
$stmt -> bindParam(":contractno",$contractno); |
|||
$stmt -> bindParam(":company",$company); |
|||
$stmt -> bindParam(":taxid",$taxid); |
|||
$stmt -> bindParam(":facilityno",$facilityno); |
|||
$stmt -> bindParam(":address",$address); |
|||
$stmt -> bindParam(":type", $type); |
|||
$stmt -> bindParam(":invoice", $invoice); |
|||
$stmt -> bindParam(":repaireid",$repaireid); |
|||
$stmt -> bindParam(":total_price",$total_price); |
|||
$stmt -> bindParam(":sign_date",$sign_date); |
|||
$stmt -> bindParam(":create_userid",$user_id); |
|||
$stmt -> bindParam("create_date",$created_at); |
|||
|
|||
$stmt -> execute(); |
|||
header('Content-Type: application/json'); |
|||
// $jsonData = json_encode($files); |
|||
|
|||
$conn -> commit(); |
|||
}catch(PDOException $e){ |
|||
$conn -> rollback(); |
|||
echo $e->getMessage(); |
|||
die('Error!' .$e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./getFacilityNo.php"); |
|||
include_once("./getComboNo.php"); |
|||
include_once("./upload_chk.php"); |
|||
ini_set('date.timezone', 'Asia/Taipei'); |
|||
//保養簽回 |
|||
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { |
|||
try { |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
|||
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|||
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null; |
|||
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null; |
|||
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null; |
|||
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null; |
|||
$email = !empty($_POST['email']) ? $_POST['email'] : null; |
|||
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null; |
|||
$mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null; |
|||
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null; |
|||
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null; |
|||
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null; |
|||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
|||
$area = !empty($_POST['area']) ? $_POST['area'] : null; |
|||
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null; |
|||
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null; |
|||
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null; |
|||
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null; |
|||
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null; |
|||
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|||
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null; |
|||
$num = !empty($_POST['num']) ? $_POST['num'] : null; |
|||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|||
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; |
|||
// validate |
|||
$fail_arr = []; |
|||
if ($contractno === '') return $fail_arr[] = '合約號為必填'; |
|||
|
|||
if ($total_price == '') $fail_arr[] = '合約總價為必填'; |
|||
if ($vat == '') $fail_arr[] = '統一編號為必填'; |
|||
if ($mtype == '') $fail_arr[] = '維修型態為必填'; |
|||
if ($phone == '') $fail_arr[] = '客戶電話為必填'; |
|||
if ($email == '') $fail_arr[] = 'Email為必填'; |
|||
if ($mworker == '') $fail_arr[] = '保養員為必填'; |
|||
if ($mcycle == '') $fail_arr[] = '保養頻率為必填'; |
|||
if ($salesman == '') $fail_arr[] = '營業員為必填'; |
|||
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填'; |
|||
if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填'; |
|||
if ($address == '') $fail_arr[] = '地址為必填'; |
|||
if ($area == '') $fail_arr[] = '區域為必填'; |
|||
if ($customer == '') $fail_arr[] = '客戶為必填'; |
|||
if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; |
|||
if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; |
|||
if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; |
|||
if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; |
|||
if ($num == '') $fail_arr[] = '電梯數量為必填'; |
|||
if (count($fail_arr) > 0) { |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
|
|||
//create account table |
|||
$accounttype = "A"; |
|||
$accountid = $vat; |
|||
$pwd = "123"; |
|||
$name = $partyA; |
|||
$tel = $phone ?? ''; |
|||
$repairerid = $mworker; |
|||
$creater = $user_id; |
|||
$create_at = date('Y-m-d H:i:s'); |
|||
|
|||
$conn->beginTransaction(); |
|||
|
|||
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype', $accounttype); |
|||
$stmt->bindParam(':accountid', $accountid); |
|||
$stmt->bindParam(':pwd', $pwd); |
|||
$stmt->bindParam(':name', $name); |
|||
$stmt->bindParam(':tel', $tel); |
|||
$stmt->bindParam(':address', $address); |
|||
$stmt->bindParam(':email', $email); |
|||
$stmt->bindParam(':repairerid', $repairerid); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$stmt->execute(); |
|||
|
|||
//create contract table |
|||
|
|||
$contracttype = $mtype; |
|||
$company = $partyA; |
|||
$taxid = $vat; |
|||
$tel = $phone; |
|||
$promiser = $partyA; |
|||
$contractperson = $partyA; |
|||
|
|||
$contractaddress = $address; |
|||
$contracttel = $phone; |
|||
$contractemail = $email; |
|||
$contract_employee = $salesman; |
|||
$start_date = $contract_begin_date; |
|||
$end_date = $contract_end_date; |
|||
|
|||
$sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contracttype', $contracttype); |
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->bindParam(':company', $company); |
|||
$stmt->bindParam(':taxid', $taxid); |
|||
$stmt->bindParam(':address', $address); |
|||
$stmt->bindParam(':tel', $tel); |
|||
$stmt->bindParam(':promiser', $promiser); |
|||
$stmt->bindParam(':contractperson', $contractperson); |
|||
$stmt->bindParam(':contractaddress', $contractaddress); |
|||
$stmt->bindParam(':contracttel', $contracttel); |
|||
$stmt->bindParam(':contractemail', $contractemail); |
|||
$stmt->bindParam(':contract_employee', $contract_employee); |
|||
$stmt->bindParam(':start_date', $start_date); |
|||
$stmt->bindParam(':end_date', $end_date); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$stmt->execute(); |
|||
|
|||
//create facility table |
|||
$createFacilityNo = new CreateFacilityNo(); |
|||
$dailyNecessities = [ |
|||
'MAE100' => 'X', |
|||
'MAM200' => 'W', |
|||
'MAH100' => 'H', |
|||
'MAQ100' => 'Z', |
|||
'MAF100' => 'F', |
|||
'MAZ100' => 'B', |
|||
]; |
|||
$facility_arr = []; |
|||
foreach ($elevators as $elevator) { |
|||
$facility_arr[] = $dailyNecessities[$elevator['spec']]; |
|||
} |
|||
echo json_encode($facility_arr); |
|||
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); |
|||
echo json_encode($facilityno); |
|||
echo '-------'; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accountid', $mworker); |
|||
$stmt->execute(); |
|||
$worker = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$customerid = $vat; |
|||
$define = "B"; |
|||
$repairtype = $mtype; |
|||
$repairerid = $mworker; |
|||
$repairername = $worker['name']; |
|||
foreach ($elevators as $idx => $elevator) { |
|||
$sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) |
|||
VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->bindParam(':define', $define); |
|||
$stmt->bindParam(':facilityno', $facilityno[$idx]); |
|||
$stmt->bindParam(':latitude', $elevator['latitude']); |
|||
$stmt->bindParam(':longitude', $elevator['longitude']); |
|||
$stmt->bindParam(':customerid', $customerid); |
|||
$stmt->bindParam(':weight', $elevator['weight']); |
|||
$stmt->bindParam(':numberofpassenger', $elevator['persons']); |
|||
$stmt->bindParam(':numberofstop', $elevator['stop']); |
|||
$stmt->bindParam(':numberoffloor', $elevator['floors']); |
|||
$stmt->bindParam(':opentype', $elevator['opendoor']); |
|||
$stmt->bindParam(':speed', $elevator['speed']); |
|||
$stmt->bindParam(':repairtype', $repairtype); |
|||
$stmt->bindParam(':maintainance', $elevator['maintainance']); |
|||
$stmt->bindParam(':facility_kind', $elevator['spec']); |
|||
$stmt->bindParam(':address', $address); |
|||
$stmt->bindParam(':repairerid', $repairerid); |
|||
$stmt->bindParam(':repairername', $repairername); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$stmt->bindParam(':area', $area); |
|||
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); |
|||
$stmt->bindParam(':licensedate', $elevator['useful_date']); |
|||
$result = $stmt->execute(); |
|||
} |
|||
|
|||
//create schedule table |
|||
|
|||
$comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); |
|||
$comboArr = json_decode($comboNo->getComboNo(), true); |
|||
foreach ($facilityno as $no) { |
|||
foreach ($comboArr as $combo) { |
|||
$sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->bindParam(':facilityno', $no); |
|||
$stmt->bindParam(':combono', $combo[0]); |
|||
$stmt->bindParam(':repairerid', $repairerid); |
|||
$stmt->bindParam(':repairername', $repairername); |
|||
$stmt->bindParam(':duedate', $combo[1]); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$result = $stmt->execute(); |
|||
} |
|||
} |
|||
// create contract_b_signed_back table |
|||
$contract_type = $mtype; |
|||
$company = $customer; |
|||
$customer_no = $vat; |
|||
$salesperson = $salesman; |
|||
$customer_phone = $phone; |
|||
$customer_email = $email; |
|||
$repairman = $mworker; |
|||
$cycle = $mcycle; |
|||
$contact_person = $partyA; |
|||
$contact_address = $partyAaddress; |
|||
$contact_phone = $partyAphone; |
|||
$contract_email = $partyAemail; |
|||
$elevators_number = $num; |
|||
$bonus = 1000; |
|||
$max_bonus = 2000; |
|||
|
|||
if (!empty($files)) { |
|||
$englisharr = range('a', 'z'); |
|||
$file = $_FILES['files']; |
|||
$file_name = $file['name']; |
|||
$file_type = $file['type']; |
|||
$tmp_name = $file['tmp_name']; |
|||
$file_size = $file['size']; |
|||
$error = $file['error']; |
|||
$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 = 'b' . $datetime; // 保養=>b + 日期時間 |
|||
foreach ($newfiles as $key => $file) { |
|||
$randNum = rand(1000, 9999); |
|||
$randEnglish = $englisharr[rand(0, 25)]; |
|||
$file_name = 'b' . (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', $user_id); |
|||
$stmt->execute(); |
|||
} |
|||
$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; |
|||
} |
|||
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by) |
|||
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(":contract_no", $contractno); |
|||
$stmt->bindParam(":contract_type", $contract_type); |
|||
$stmt->bindParam(":company", $company); |
|||
$stmt->bindParam(":customer_no", $customer_no); |
|||
$stmt->bindParam(":salesperson", $salesperson); |
|||
$stmt->bindParam(":contract_start_date", $contract_begin_date); |
|||
$stmt->bindParam(":contract_end_date", $contract_end_date); |
|||
$stmt->bindParam(":total_price", $total_price); |
|||
$stmt->bindParam(":customer_phone", $customer_phone); |
|||
$stmt->bindParam(":customer_email", $customer_email); |
|||
$stmt->bindParam(":repairman", $repairman); |
|||
$stmt->bindParam(":cycle", $cycle); |
|||
$stmt->bindParam(":contact_person", $contact_person); |
|||
$stmt->bindParam(":contact_address", $contact_address); |
|||
$stmt->bindParam(":contact_phone", $contact_phone); |
|||
$stmt->bindParam(":contact_email", $contact_email); |
|||
$stmt->bindParam(":elevators_number", $elevators_number); |
|||
$stmt->bindParam(":area", $area); |
|||
$stmt->bindParam(":address", $address); |
|||
$stmt->bindParam(":files_id", $files_id); |
|||
$stmt->bindParam(":bonus", $bonus); |
|||
$stmt->bindParam(":max_bonus", $max_bonus); |
|||
$stmt->bindParam(":created_at", $created_at); |
|||
$stmt->bindParam(":created_by", $user_id); |
|||
|
|||
$stmt->execute(); |
|||
|
|||
header('Content-Type: application/json'); |
|||
// $jsonData = json_encode($files); |
|||
|
|||
$conn->commit(); |
|||
} catch (PDOException $e) { |
|||
$conn->rollback(); |
|||
echo $e->getMessage(); |
|||
die('Error!:' . $e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////// |
|||
//// 合約簽回(修理) |
|||
//// |
|||
//// 製作人:梓誠 |
|||
/// 時間 : |
|||
////////////////////////////// |
|||
if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'r') { |
|||
try { |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
|||
$company = !empty($_POST['company']) ? $_POST['company'] : null; |
|||
$repairid = !empty($_POST['repairid']) ? $_POST['repairid'] : null; |
|||
$facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null; |
|||
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null; |
|||
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null; |
|||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
|||
$repair_no = !empty($_POST['repair_no']) ? $_POST['repair_no'] : null; |
|||
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|||
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|||
$type = !empty($_POST['type']) ? $_POST['type'] : null; |
|||
$sign_date = !empty($_POST['sign_date']) ? $_POST['sign_date'] : null; |
|||
$contract_status = !empty($_POST['contract_status']) ? $_POST['contract_status'] : null; |
|||
|
|||
$fail_arr = []; |
|||
|
|||
if (empty($contractno)) $fail_arr[] = '合約號為必填'; |
|||
if (empty($repair_no)) $fail_arr[] = '報價單編號為必填'; |
|||
if (empty($company)) $fail_arr[] = '客戶名稱為必填'; |
|||
if (empty($repairid)) $fail_arr[] = '為保人員為必填'; |
|||
// iempty(f($taxid === '') return $fail_arr[] = '統一編號為必填'; |
|||
if (empty($facilityno)) $fail_arr[] = '電梯編號為必填'; |
|||
if (empty($address)) $fail_arr[] = '工程地址為必填'; |
|||
if (empty($type)) $fail_arr[] = '工程類別為必填'; |
|||
if (empty($invoice)) $fail_arr[] = '發票抬頭為必填'; |
|||
if (empty($taxid)) $fail_arr[] = '統一編號為必填'; |
|||
// echo json_encode($fail_arr); |
|||
// exit; |
|||
if (count($fail_arr) > 0) { |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
// exit(); |
|||
//create contrac_r_signed_back table |
|||
$conn->beginTransaction(); |
|||
$sql = "INSERT INTO contract_r_signed_back( |
|||
repair_no, |
|||
contractno, |
|||
company, |
|||
taxid, |
|||
facilityno, |
|||
address, |
|||
type, |
|||
invoice, |
|||
repaireid, |
|||
total_price, |
|||
sign_date, |
|||
contract_status, |
|||
create_user, |
|||
create_date) VALUES( |
|||
:repair_no, |
|||
:contractno, |
|||
:company, |
|||
:taxid, |
|||
:facilityno, |
|||
:address, |
|||
:type, |
|||
:invoice, |
|||
:repaireid, |
|||
:total_price, |
|||
:sign_date, |
|||
:contract_status, |
|||
:create_userid, |
|||
:create_date |
|||
)"; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(":repair_no", $repair_no); |
|||
$stmt->bindParam(":contractno", $contractno); |
|||
$stmt->bindParam(":company", $company); |
|||
$stmt->bindParam(":taxid", $taxid); |
|||
$stmt->bindParam(":facilityno", $facilityno); |
|||
$stmt->bindParam(":address", $address); |
|||
$stmt->bindParam(":type", $type); |
|||
$stmt->bindParam(":invoice", $invoice); |
|||
$stmt->bindParam(":repaireid", $repaireid); |
|||
$stmt->bindParam(":total_price", $total_price); |
|||
$stmt->bindParam(":sign_date", $sign_date); |
|||
$stmt->bindParam(":contract_status", $contract_status); |
|||
$stmt->bindParam(":create_userid", $user_id); |
|||
$stmt->bindParam("create_date", $created_at); |
|||
|
|||
$stmt->execute(); |
|||
header('Content-Type: application/json'); |
|||
// $jsonData = json_encode($files); |
|||
|
|||
$conn->commit(); |
|||
} catch (PDOException $e) { |
|||
$conn->rollback(); |
|||
echo $e->getMessage(); |
|||
die('Error!' . $e->getMessage()); |
|||
} |
|||
} |
|||
|
@ -1,174 +1,190 @@ |
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./upload_chk.php"); |
|||
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{ |
|||
$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; |
|||
$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; |
|||
// $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){ |
|||
header("HTTP/1.1 442 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
$conn -> beginTransaction(); |
|||
|
|||
|
|||
}catch(PDOException $e){ |
|||
$conn->rollback(); |
|||
header("HTTPP/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()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./upload_chk.php"); |
|||
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 { |
|||
$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['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 (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(); |
|||
|
|||
$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()); |
|||
} |
|||
} |
|||
// 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()); |
|||
// } |
|||
// } |
|||
|
@ -1,196 +1,210 @@ |
|||
<?php |
|||
include("../header.php"); |
|||
require_once("./conn.php"); |
|||
$id = $_GET['contractid']; |
|||
$sql_str = "SELECT * FROM contract_r_signed_back WHERE id = :id ORDER BY id DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':id', $id); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
// echo '<pre>'; |
|||
// print_r($contract); |
|||
// echo '</pre>'; |
|||
// $files_id = $contract['files_id']; |
|||
// $sql_str = "SELECT * FROM contract_back_files WHERE files_id = :files_id "; |
|||
// $stmt = $conn->prepare($sql_str); |
|||
// $stmt->bindParam(':files_id', $files_id); |
|||
// $stmt->execute(); |
|||
// $files= $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
// $files = json_encode($files); |
|||
$accounttype = "M"; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(":accounttype", $accounttype); |
|||
$stmt->execute(); |
|||
$persons = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$persons = array_map(function ($person) { |
|||
return [ |
|||
'view' => $person['accountid'] . '-' . $person['name'], |
|||
'value' => $person['accountid'], |
|||
'name' => $person['name'] |
|||
]; |
|||
}, $persons); |
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> |
|||
|
|||
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script> |
|||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css" /> |
|||
<div class="contract-management" x-data='contract_edit'> |
|||
<div class="form" method="post" id="form" enctype="multipart/form-data"> |
|||
<input type="hidden" name='form_name' value="main_form" /> |
|||
<div> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>合約管理(修理)</h3> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
|
|||
<tbody style="font-weight: bolder;margin-bottom: 20px"> |
|||
<tr> |
|||
<td colspan="7" style='vertical-align: middle;border-right:0px;'> |
|||
<h4>檢視合約</h4> |
|||
</td> |
|||
<td class="text-right" style='border-left:0px;'> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">立約人</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" x-model="data.company"> |
|||
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">維保人員</td> |
|||
<td style="vertical-align: middle"> |
|||
<select class="repaireid" id="repaireid" x-model="data.repaireid"> |
|||
<option value="">選擇營業員</option> |
|||
<?php foreach ($persons as $person) : ?> |
|||
<option value="<?php echo $person['value']; ?>"><?php echo $person['view']; ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
<p class="alerttext" x-show="data.repaireid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">電梯編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.facilityno"> |
|||
<p class="alerttext" x-show="data.facilityno==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">報價單編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.repair_no"> |
|||
<p class="alerttext" x-show="data.repair_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">工程類別</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.type"> |
|||
<p class="alerttext" x-show="data.type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">簽訂時間</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="sign_date" x-model="data.sign_date"> |
|||
<p class="alerttext" x-show="data.sign_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">發票抬頭</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.invoice"> |
|||
<p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">統一編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.taxid"> |
|||
<p class="alerttext" x-show="data.taxid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">工程地址</td> |
|||
<td colspan=3> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.address"> |
|||
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<!-- <td style="vertical-align: middle">附件上傳</td> |
|||
<td colspan=3> |
|||
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> |
|||
<p class="alerttext" x-show="data.lm_tel==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> --> |
|||
<td></td> |
|||
<td></td> |
|||
<td></td> |
|||
<td></td> |
|||
</tr> |
|||
<!-- <tr> |
|||
<td style="vertical-align: middle">附件</td> |
|||
<td colspan=7> |
|||
<div class="images"> |
|||
<template x-for="file in data.files" :key="file.id"> |
|||
<div class="image"> |
|||
<a :href="'./images/contracts/' + file.file_name" data-fancybox="gallery" :data-src="'./images/contracts/' + file.file_name" data-caption=""> |
|||
<img :src="'./images/contracts/' + file.file_name" /> |
|||
</a> |
|||
<i class="fas fa-times" @click="deleteFileFn(file.id)"></i> |
|||
</div> |
|||
</template> |
|||
</div> |
|||
|
|||
</td> |
|||
</tr> --> |
|||
|
|||
|
|||
</tbody> |
|||
</table> |
|||
<button @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>更新</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button type="button" class="btn btn-primary btn-lg pull-right savebtn" @click="window.location.href='./contract-repair-management.php?<?php echo $token_link; ?>'">回列表</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<script src="./js/jquery/jquery-3.1.1.min.js"></script> |
|||
<script src="semantic/dist/semantic.min.js"></script> |
|||
<script src="./js/alpine.js"></script> |
|||
<script> |
|||
const user_id = '<?php echo $user_id; ?>'; |
|||
const user_name = '<?php echo $user_name; ?>'; |
|||
const id = <?php echo $contract['id'] ?>; |
|||
const repair_no = '<?php echo $contract['repair_no']; ?>' |
|||
const contractno = '<?php echo $contract['contractno']; ?>' |
|||
const company = '<?php echo $contract['company']; ?>' |
|||
const taxid = '<?php echo $contract['taxid']; ?>' |
|||
const facilityno = '<?php echo $contract['facilityno']; ?>' |
|||
const address = '<?php echo $contract['address']; ?>' |
|||
const type = '<?php echo $contract['type']; ?>' |
|||
const invoice = '<?php echo $contract['invoice']; ?>' |
|||
const repaireid = '<?php echo $contract['repaireid']; ?>' |
|||
const total_price = '<?php echo $contract['total_price']; ?>' |
|||
const sign_date = '<?php echo $contract['sign_date']; ?>' |
|||
// $('#table_index').DataTable( |
|||
// { |
|||
// "order": [ |
|||
// [0, "desc"], |
|||
// ] |
|||
// } |
|||
// ); |
|||
// Fancybox.bind('[data-fancybox="gallery"]', { |
|||
|
|||
// }); |
|||
<?php |
|||
include("../header.php"); |
|||
require_once("./conn.php"); |
|||
$id = $_GET['contractid']; |
|||
$sql_str = "SELECT * FROM contract_r_signed_back WHERE id = :id ORDER BY id DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':id', $id); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
// echo '<pre>'; |
|||
// print_r($contract); |
|||
// echo '</pre>'; |
|||
// $files_id = $contract['files_id']; |
|||
// $sql_str = "SELECT * FROM contract_back_files WHERE files_id = :files_id "; |
|||
// $stmt = $conn->prepare($sql_str); |
|||
// $stmt->bindParam(':files_id', $files_id); |
|||
// $stmt->execute(); |
|||
// $files= $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
// $files = json_encode($files); |
|||
$accounttype = "M"; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(":accounttype", $accounttype); |
|||
$stmt->execute(); |
|||
$persons = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$persons = array_map(function ($person) { |
|||
return [ |
|||
'view' => $person['accountid'] . '-' . $person['name'], |
|||
'value' => $person['accountid'], |
|||
'name' => $person['name'] |
|||
]; |
|||
}, $persons); |
|||
$contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"]; |
|||
|
|||
|
|||
|
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
<!-- <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> --> |
|||
|
|||
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script> |
|||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css" /> |
|||
|
|||
<div class="contract-management" x-data='contract_edit'> |
|||
<div class="form" method="post" id="form" enctype="multipart/form-data"> |
|||
<input type="hidden" name='form_name' value="main_form" /> |
|||
<div> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>合約管理(修理)</h3> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
|
|||
<tbody style="font-weight: bolder;margin-bottom: 20px"> |
|||
<tr> |
|||
<td colspan="7" style='vertical-align: middle;border-right:0px;'> |
|||
<h4>檢視合約</h4> |
|||
</td> |
|||
<td class="text-right" style='border-left:0px;'> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">立約人</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" x-model="data.company"> |
|||
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">維保人員</td> |
|||
<td style="vertical-align: middle"> |
|||
<select class="repaireid" id="repaireid" x-model="data.repaireid"> |
|||
<option value="">選擇營業員</option> |
|||
<?php foreach ($persons as $person) : ?> |
|||
<option value="<?php echo $person['value']; ?>"><?php echo $person['view']; ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
<p class="alerttext" x-show="data.repaireid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">電梯編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.facilityno"> |
|||
<p class="alerttext" x-show="data.facilityno==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">報價單編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.repair_no"> |
|||
<p class="alerttext" x-show="data.repair_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">工程類別</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.type"> |
|||
<p class="alerttext" x-show="data.type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">簽訂時間</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="sign_date" x-model="data.sign_date"> |
|||
<p class="alerttext" x-show="data.sign_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">發票抬頭</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.invoice"> |
|||
<p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">統一編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" x-model="data.taxid"> |
|||
<p class="alerttext" x-show="data.taxid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">工程地址</td> |
|||
<td colspan=3> |
|||
<input class="form-control disabled_select" type="text" x-model="data.address"> |
|||
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<!-- <td style="vertical-align: middle">附件上傳</td> |
|||
<td colspan=3> |
|||
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> |
|||
<p class="alerttext" x-show="data.lm_tel==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> --> |
|||
<td style="vertical-align: middle">工程進度</td> |
|||
<td style="vertical-align: middle"> |
|||
<select class="contract_status" id="contract_status" x-model="data.contract_status"> |
|||
<?php foreach ($contract_stauts as $key => $status) : ?> |
|||
<option value="<?php echo $key + 1; ?>"><?php echo $status; ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
<p class="alerttext" x-show="data.contract_status==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td></td> |
|||
<td></td> |
|||
</tr> |
|||
<!-- <tr> |
|||
<td style="vertical-align: middle">附件</td> |
|||
<td colspan=7> |
|||
<div class="images"> |
|||
<template x-for="file in data.files" :key="file.id"> |
|||
<div class="image"> |
|||
<a :href="'./images/contracts/' + file.file_name" data-fancybox="gallery" :data-src="'./images/contracts/' + file.file_name" data-caption=""> |
|||
<img :src="'./images/contracts/' + file.file_name" /> |
|||
</a> |
|||
<i class="fas fa-times" @click="deleteFileFn(file.id)"></i> |
|||
</div> |
|||
</template> |
|||
</div> |
|||
|
|||
</td> |
|||
</tr> --> |
|||
|
|||
|
|||
</tbody> |
|||
</table> |
|||
<button @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>更新</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button type="button" class="btn btn-primary btn-lg pull-right savebtn" @click="window.location.href='./contract-repair-management.php?<?php echo $token_link; ?>'">回列表</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<script src="./js/jquery/jquery-3.1.1.min.js"></script> |
|||
<script src="semantic/dist/semantic.min.js"></script> |
|||
<script src="./js/alpine.js"></script> |
|||
<script> |
|||
const user_id = '<?php echo $user_id; ?>'; |
|||
const user_name = '<?php echo $user_name; ?>'; |
|||
const id = <?php echo $contract['id'] ?>; |
|||
const repair_no = '<?php echo $contract['repair_no']; ?>'; |
|||
const contractno = '<?php echo $contract['contractno']; ?>'; |
|||
const company = '<?php echo $contract['company']; ?>'; |
|||
const taxid = '<?php echo $contract['taxid']; ?>'; |
|||
const facilityno = '<?php echo $contract['facilityno']; ?>'; |
|||
const address = '<?php echo $contract['address']; ?>'; |
|||
const type = '<?php echo $contract['type']; ?>'; |
|||
const repaireid = '<?php echo $contract['repaireid']; ?>'; |
|||
const total_price = '<?php echo $contract['total_price']; ?>'; |
|||
const sign_date = '<?php echo $contract['sign_date']; ?>'; |
|||
const invoice = '<?php echo $contract['invoice']; ?>' |
|||
const contract_status = '<?php echo $contract['contract_status']; ?>' |
|||
// $('#table_index').DataTable( |
|||
// { |
|||
// "order": [ |
|||
// [0, "desc"], |
|||
// ] |
|||
// } |
|||
// ); |
|||
// Fancybox.bind('[data-fancybox="gallery"]', { |
|||
|
|||
// }); |
|||
</script> |
@ -1,187 +1,173 @@ |
|||
<?php |
|||
include("../header.php"); |
|||
require_once("./conn.php"); |
|||
include_once("./api/getFacilityNo.php"); |
|||
$accounttype = "B"; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype',$accounttype); |
|||
$stmt->execute(); |
|||
$workers = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$accounttype = "M"; |
|||
$sql_str = "SELECT id,accountid, name FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype',$accounttype); |
|||
$stmt->execute(); |
|||
$contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js" ></script> |
|||
|
|||
<div class="contract-input-component" x-data="contractRepair"> |
|||
<div class="form" method="post" id="form" enctype="multipart/form-data" > |
|||
<input type="hidden" name='form_name' value="main_form" /> |
|||
<div> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>合約入力(修理)</h3> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<template x-if="step==1"> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1"> |
|||
<tr> |
|||
<td style="vertical-align: middle">合約號</td> |
|||
<td colspan="5"> |
|||
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="contractno" x-model="data.contractno" > |
|||
|
|||
</td> |
|||
<td colspan="2" style="vertical-align: middle"> |
|||
<label for="customize"> |
|||
<input type="checkbox" x-model="customize" id="customize" />自定義欄位 |
|||
</label> |
|||
</td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</template> |
|||
<template x-if="step==2"> |
|||
<!-- <template x-if="step==1"> --> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==2"> |
|||
<!-- <tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1"> --> |
|||
<tr> |
|||
<td colspan="7" style='vertical-align: middle;border-right:0px;'> |
|||
<h4>業務確認項</h4> |
|||
</td> |
|||
<td class="text-right" style='border-left:0px;'> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">立約人</td> |
|||
<td> |
|||
<input type="text" x-model="data.company"/> |
|||
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">維保人員</td> |
|||
<td> |
|||
<input type="text" x-model="data.repairer" /> |
|||
<p class="alerttext" x-show="data.repairer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">電梯編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="facilityno" x-model="data.facilityno" > |
|||
<p class="alerttext" x-show="data.facilityno==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">工程地址</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="address" x-model="data.address" > |
|||
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">工程類別</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="type" x-model="data.type" > |
|||
<p class="alerttext" x-show="data.type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">簽訂時間</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="date" name="sign_date" x-model="data.sign_date" > |
|||
<p class="alerttext" x-show="data.sign_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">發票抬頭</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="invoice" x-model="data.invoice" > |
|||
<p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">統一編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="taxid" x-model="data.taxid" > |
|||
<p class="alerttext" x-show="data.taxid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
|
|||
|
|||
<!-- <td style="vertical-align: middle">維修型態</td> |
|||
<td style="vertical-align: middle"> |
|||
<select class="ui search dropdown" name="" x-model="data.mtype"> |
|||
<option value="" >選擇維修型態</option> |
|||
<option value="A">定期保養</option> |
|||
</select> |
|||
<p class="alerttext" x-show="data.mtype==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> --> |
|||
|
|||
<!-- <td></td> --> |
|||
<!-- <td></td> --> |
|||
</tr> |
|||
<tr> |
|||
<!-- <td style="vertical-align: middle">維修人員</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="repairer" x-model="data.repairer" > |
|||
<p class="alerttext" x-show="data.repairer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> --> |
|||
<td style="vertical-align: middle">報價單編號</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select" type="text" name="repair_no" x-model="data.repair_no" disabled="disabled"> |
|||
<p class="alerttext" x-show="data.repair_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">附件</td> |
|||
<td colspan="2"> |
|||
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> |
|||
</td> |
|||
<td></td> |
|||
</tr> |
|||
|
|||
|
|||
<tr> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</template> |
|||
</table> |
|||
|
|||
|
|||
<button x-show="step==2" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>存檔</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button x-show="step<=1" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading"> |
|||
<template x-if="!isLoading"> |
|||
<span>下一步</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button x-show="step>1" @click="preStepFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>上一步</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
<script src="./js/jquery/jquery-3.1.1.min.js"></script> |
|||
<script src="semantic/dist/semantic.min.js" ></script> |
|||
<script src="./js/alpine.js"></script> |
|||
<script> |
|||
const user_id = '<?php echo $user_id; ?>' |
|||
const user_name = '<?php echo $user_name; ?>' |
|||
<?php |
|||
include("../header.php"); |
|||
require_once("./conn.php"); |
|||
include_once("./api/getFacilityNo.php"); |
|||
$accounttype = "B"; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype', $accounttype); |
|||
$stmt->execute(); |
|||
$workers = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$accounttype = "M"; |
|||
$sql_str = "SELECT id,accountid, name FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype', $accounttype); |
|||
$stmt->execute(); |
|||
$contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
|
|||
$contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"]; |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
|
|||
<div class="contract-input-component" x-data="contractRepair"> |
|||
<div class="form" method="post" id="form" enctype="multipart/form-data"> |
|||
<input type="hidden" name='form_name' value="main_form" /> |
|||
<div> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>合約入力(修理)</h3> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<template x-if="step==1"> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1"> |
|||
<tr> |
|||
<td style="vertical-align: middle">合約號</td> |
|||
<td colspan="5"> |
|||
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="contractno" x-model="data.contractno"> |
|||
|
|||
</td> |
|||
<td colspan="2" style="vertical-align: middle"> |
|||
<label for="customize"> |
|||
<input type="checkbox" x-model="customize" id="customize" />自定義欄位 |
|||
</label> |
|||
</td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</template> |
|||
<template x-if="step==2"> |
|||
<!-- <template x-if="step==1"> --> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==2"> |
|||
<!-- <tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1"> --> |
|||
<tr> |
|||
<td colspan="7" style='vertical-align: middle;border-right:0px;'> |
|||
<h4>業務確認項</h4> |
|||
</td> |
|||
<td class="text-right" style='border-left:0px;'> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">立約人</td> |
|||
<td> |
|||
<input type="text" x-model="data.company" /> |
|||
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">維保人員</td> |
|||
<td> |
|||
<input type="text" x-model="data.repairer" /> |
|||
<p class="alerttext" x-show="data.repairer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">電梯編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="facilityno" x-model="data.facilityno"> |
|||
<p class="alerttext" x-show="data.facilityno==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">報價單編號</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select" type="text" name="repair_no" x-model="data.repair_no" disabled="disabled"> |
|||
<p class="alerttext" x-show="data.repair_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">工程進度</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="type" x-model="data.type"> |
|||
<p class="alerttext" x-show="data.type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">簽訂時間</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="date" name="sign_date" x-model="data.sign_date"> |
|||
<p class="alerttext" x-show="data.sign_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">發票抬頭</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="invoice" x-model="data.invoice"> |
|||
<p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">統一編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" name="taxid" x-model="data.taxid"> |
|||
<p class="alerttext" x-show="data.taxid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">工程地址</td> |
|||
<td colspan=3> |
|||
<input class="form-control disabled_select" type="text" x-model="data.address"> |
|||
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
<td style="vertical-align: middle">工程確認</td> |
|||
<td style="vertical-align: middle"> |
|||
<select class="contract_status" id="contract_status" x-model="data.contract_status"> |
|||
<?php foreach ($contract_stauts as $key => $status) : ?> |
|||
<option value="<?php echo $key + 1; ?>"><?php echo $status; ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
<!-- <p class="alerttext" x-show="data.contract_status==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> --> |
|||
</td> |
|||
<td></td> |
|||
<td></td> |
|||
</tr> |
|||
|
|||
</tbody> |
|||
</template> |
|||
</table> |
|||
|
|||
|
|||
<button x-show="step==2" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>存檔</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button x-show="step<=1" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading"> |
|||
<template x-if="!isLoading"> |
|||
<span>下一步</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button x-show="step>1" @click="preStepFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>上一步</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
<script src="./js/jquery/jquery-3.1.1.min.js"></script> |
|||
<script src="semantic/dist/semantic.min.js"></script> |
|||
<script src="./js/alpine.js"></script> |
|||
<script> |
|||
const user_id = '<?php echo $user_id; ?>' |
|||
const user_name = '<?php echo $user_name; ?>' |
|||
</script> |
@ -1,119 +1,131 @@ |
|||
<?php |
|||
include("../header.php"); |
|||
require_once("./conn.php"); |
|||
$sql_str = "SELECT * FROM contract_r_signed_back WHERE 1=1 AND delete_status = 1 ORDER BY id DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->execute(); |
|||
$contracts= $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
|
|||
<div class="contract-management" x-data="{ |
|||
deleteFn(id,user){ |
|||
if(confirm('確定要刪除嗎?')){ |
|||
axios.get('./api/deleteNewContractData.php?contracttype=r&contractid='+id+'&user_id='+user).then(res=> { |
|||
console.log(res); |
|||
if(res.status === 204){ |
|||
alert('刪除成功!') |
|||
location.reload(); |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
}"> |
|||
|
|||
<div style="overflow-x:auto;margin-top:12px"> |
|||
<a href="contract-repair-input.php?function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<th>項次</th> |
|||
<th>合約號</th> |
|||
<th>客戶名稱</th> |
|||
<th>統編</th> |
|||
<th>總金額</th> |
|||
<th>建檔者</th> |
|||
<th>建立時間</th> |
|||
<th>操作</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach($contracts as $key => $contract): ?> |
|||
<tr> |
|||
<td><?php echo $contract['id']; ?></td> |
|||
<td><?php echo $contract['contractno'] ?></td> |
|||
<td><?php echo $contract['company'] ?></td> |
|||
<td><?php echo $contract['taxid'] ?></td> |
|||
<td><?php echo $contract['total_price']?></td> |
|||
<td><?php echo $contract['create_userid'] ?></td> |
|||
<td><?php echo $contract['create_date'] ?></td> |
|||
<td style="width:30px"> |
|||
<p> |
|||
<a href="contract-repair-edit.php?&contractid=<?php echo $contract['id']; ?>&function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
<a href="javascript:;" class="btn btn-info btn-sm" style="margin-left:10px;" @click="deleteFn(<?php echo $contract['id']; ?>,'<?php echo $user_id;?>')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
table { |
|||
table-layout:fixed; |
|||
width: 100%; |
|||
} |
|||
|
|||
td { |
|||
word-wrap:break-word; |
|||
} |
|||
|
|||
img { |
|||
width:125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width:125px; |
|||
} |
|||
|
|||
table{ |
|||
width:100%; |
|||
} |
|||
#table_index_filter{ |
|||
float:right; |
|||
} |
|||
#table_index_paginate{ |
|||
float:right; |
|||
} |
|||
label { |
|||
display: inline-flex; |
|||
margin-bottom: .5rem; |
|||
margin-top: .5rem; |
|||
|
|||
} |
|||
|
|||
</style> |
|||
<script src="semantic/dist/semantic.min.js" ></script> |
|||
|
|||
<script> |
|||
$('#table_index').DataTable( |
|||
{ |
|||
"order": [ |
|||
[0, "desc"], |
|||
] |
|||
} |
|||
); |
|||
|
|||
<?php |
|||
include("../header.php"); |
|||
require_once("./conn.php"); |
|||
$sql_str = "SELECT * FROM contract_r_signed_back WHERE 1=1 AND delete_status = 1 ORDER BY id DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->execute(); |
|||
$contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
|
|||
<div class="contract-management" x-data="{ |
|||
deleteFn(id,user){ |
|||
if(confirm('確定要刪除嗎?')){ |
|||
axios.get('./api/deleteNewContractData.php?contracttype=r&contractid='+id+'&user_id='+user).then(res=> { |
|||
console.log(res); |
|||
if(res.status === 204){ |
|||
alert('刪除成功!') |
|||
location.reload(); |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
}"> |
|||
|
|||
<div style="overflow-x:auto;margin-top:12px"> |
|||
<a href="contract-repair-input.php?function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<th>項次</th> |
|||
<th>合約號</th> |
|||
<th>客戶名稱</th> |
|||
<th>統編</th> |
|||
<th>總金額</th> |
|||
<th>工程進度</th> |
|||
<th>建檔者</th> |
|||
<th>建立時間</th> |
|||
<th>操作</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($contracts as $key => $contract) : ?> |
|||
<tr> |
|||
<td><?php echo $contract['id']; ?></td> |
|||
<td><?php echo $contract['contractno'] ?></td> |
|||
<td><?php echo $contract['company'] ?></td> |
|||
<td><?php echo $contract['taxid'] ?></td> |
|||
<td><?php echo $contract['total_price'] ?></td> |
|||
<th><?php if ($contract['contract_status'] == 1) { |
|||
echo '合約簽回'; |
|||
} else if ($contract['contract_status'] == 2) { |
|||
echo '採購'; |
|||
} else if ($contract['contract_status'] == 3) { |
|||
echo '工程發包'; |
|||
} else if ($contract['contract_status'] == 4) { |
|||
echo '工程中'; |
|||
} else if ($contract['contract_status'] == 5) { |
|||
echo '修理完成'; |
|||
} |
|||
?></th> |
|||
<td><?php echo $contract['create_user'] ?></td> |
|||
<td><?php echo $contract['create_date'] ?></td> |
|||
<td style="width:30px"> |
|||
<p> |
|||
<a href="contract-repair-edit.php?&contractid=<?php echo $contract['id']; ?>&function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
<a href="javascript:;" class="btn btn-info btn-sm" style="margin-left:10px;" @click="deleteFn(<?php echo $contract['id']; ?>,'<?php echo $user_id; ?>')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
table { |
|||
table-layout: fixed; |
|||
width: 100%; |
|||
} |
|||
|
|||
td { |
|||
word-wrap: break-word; |
|||
} |
|||
|
|||
img { |
|||
width: 125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width: 125px; |
|||
} |
|||
|
|||
table { |
|||
width: 100%; |
|||
} |
|||
|
|||
#table_index_filter { |
|||
float: right; |
|||
} |
|||
|
|||
#table_index_paginate { |
|||
float: right; |
|||
} |
|||
|
|||
label { |
|||
display: inline-flex; |
|||
margin-bottom: .5rem; |
|||
margin-top: .5rem; |
|||
|
|||
} |
|||
</style> |
|||
<script src="semantic/dist/semantic.min.js"></script> |
|||
|
|||
<script> |
|||
$('#table_index').DataTable({ |
|||
"order": [ |
|||
[0, "desc"], |
|||
] |
|||
}); |
|||
</script> |
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
@ -1,63 +1,63 @@ |
|||
<?php |
|||
/** |
|||
* 客戶資料 |
|||
* @url /pricereview_contractno-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))); |
|||
} |
|||
|
|||
// 基本資料 |
|||
$db_query = "select a.address, a.repairerid, c.contractno, c.company, c.taxid from account a, contract c "; |
|||
$db_query .= "where a.accountid = c.customerid and c.contractno = '$pa'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$rarr["address"] = $row[0]; |
|||
$rarr["repairerid"] = $row[1]; |
|||
$rarr["contractno"] = $row[2]; |
|||
$rarr["company"] = $row[3]; |
|||
$rarr["taxid"] = $row[4]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 電梯編號 |
|||
$db_query = "select facilityno from facility where contractno = '$pa' order by facilityno"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$rarr["faci"][] = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
if (!isset($rarr["contractno"])) { |
|||
$rarr["st"] = "err"; |
|||
$rarr["err"] = "無資料!"; |
|||
} |
|||
}catch(\Exception $e) { |
|||
$rarr["st"] = "err"; |
|||
$rarr["err"] = $e->getMessage(); |
|||
} |
|||
//print_r($rarr);exit; |
|||
echo json_encode($rarr, JSON_UNESCAPED_UNICODE); |
|||
exit; |
|||
?> |
|||
<?php |
|||
|
|||
/** |
|||
* 客戶資料 |
|||
* @url /pricereview_contractno-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))); |
|||
} |
|||
|
|||
// 基本資料 |
|||
$db_query = "select a.address, a.repairerid, c.contractno, c.company, c.taxid from account a, contract c "; |
|||
$db_query .= "where a.accountid = c.customerid and c.contractno = '$pa'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$rarr["address"] = $row[0]; |
|||
$rarr["repairerid"] = $row[1]; |
|||
$rarr["contractno"] = $row[2]; |
|||
$rarr["company"] = $row[3]; |
|||
$rarr["taxid"] = $row[4]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 電梯編號 |
|||
$db_query = "select facilityno from facility where contractno = '$pa' order by facilityno"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$rarr["faci"][] = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
if (!isset($rarr["contractno"])) { |
|||
$rarr["st"] = "err"; |
|||
$rarr["err"] = "無資料!"; |
|||
} |
|||
} catch (\Exception $e) { |
|||
$rarr["st"] = "err"; |
|||
$rarr["err"] = $e->getMessage(); |
|||
} |
|||
//print_r($rarr);exit; |
|||
echo json_encode($rarr, JSON_UNESCAPED_UNICODE); |
|||
exit; |
|||
|
@ -1,271 +1,288 @@ |
|||
<?php |
|||
include "../header.php"; |
|||
require_once '../cont/wf_common.php'; |
|||
$form_key = isset($_GET['form_key']) ? $_GET['form_key'] : ""; |
|||
if ($form_key == "") $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
if (!empty($form_key)) { |
|||
$sql = "select form_id from flow where form_key = '$form_key'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$id = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 目前簽核進度 |
|||
$pstatus = ""; |
|||
$db_query = "select pstatus from pricereview_repair_main where id = '$id'"; |
|||
$res_r = mysqli_query($link ,$db_query); |
|||
if ($row_r = mysqli_fetch_row($res_r)) { |
|||
$pstatus = $row_r[0]; |
|||
} |
|||
mysqli_free_result($res_r); |
|||
if ($pstatus != "A") { |
|||
echo "<script>"; |
|||
echo "alert('請勿重覆簽核!!');"; |
|||
echo "window.close();"; |
|||
echo "</script>"; |
|||
exit; |
|||
} |
|||
} |
|||
|
|||
$assign_status = '<option>請選擇</option><option value="F6">呈核</option><option value="Y1">不同意</option>'; |
|||
|
|||
$data = []; |
|||
$db_query = "select * from pricereview_repair_main where id = '$id'"; |
|||
$data = mysqli_query($link, $db_query); |
|||
|
|||
foreach($data as $data) : |
|||
// 公司站點 |
|||
$sql = "select content from code where field_name = 'masada_addr' and code_name = '".$data["masada_addr"]."'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$data["maddr"] = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 保養人員 |
|||
$repairer_arr = []; |
|||
$sql = "select name from account where accounttype = 'B' and accountid = '".$data["repairerid"]."'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$data["repair"] = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 價審明細 |
|||
$item_arr = []; |
|||
$sql = "select * from pricereview_repair_item where rid = '$id' order by item_no"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$item_arr[$row["item_no"]]["title"] = $row["title"]; |
|||
$item_arr[$row["item_no"]]["item_unit_price"] = $row["item_unit_price"]; |
|||
$item_arr[$row["item_no"]]["item_qty"] = $row["item_qty"]; |
|||
$item_arr[$row["item_no"]]["item_price_bp"] = $row["item_price_bp"]; |
|||
$item_arr[$row["item_no"]]["memo"] = $row["memo"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// get form_key |
|||
$sql = "select max(form_key) from assign where assign_opinion = '".$data["repair_no"]."'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$form_key = $row[0]; |
|||
mysqli_free_result($res); |
|||
?> |
|||
<style> |
|||
.nextline { |
|||
width: 100%; |
|||
height: 0; |
|||
} |
|||
input[type=submit], input[type=button] { |
|||
width: 100%; |
|||
background-color: #1E74FD; |
|||
color: white; |
|||
padding: 14px 20px; |
|||
margin: 8px 0; |
|||
border: none; |
|||
border-radius: 4px; |
|||
cursor: pointer; |
|||
} |
|||
.dollar-right { |
|||
text-align: right; |
|||
} |
|||
.star { |
|||
color: red; |
|||
} |
|||
</style> |
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> |
|||
<script> |
|||
$(function(){ |
|||
$(":input").prop("disabled", true); |
|||
$("#assign_status").prop("disabled", false); |
|||
$("#next_users").prop("disabled", false); |
|||
$("#submit").prop("disabled", false); |
|||
$("#assign_status").change(function(){ |
|||
if ($(this).val() == "F6") $("#next_users").html('<option value="00000">00000</option>'); |
|||
else if ($(this).val() == "Y1") $("#next_users").html('<option value="X">退回</option>'); |
|||
else $("#next_users").html(''); |
|||
}); |
|||
|
|||
$('input[name=submit]').click(function(){ |
|||
$("#id").prop("disabled", false); |
|||
$("#form_key").prop("disabled", false); |
|||
$("#token").prop("disabled", false); |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="pricereview_repair-record-check.php" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="contractno">客戶合約號</label> |
|||
<input type="text" name="contractno" id="contractno" value="<?php echo $data["contractno"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="repair_no">報價單編號</label> |
|||
<input type="text" name="repair_no" id="repair_no" value="<?php echo $data["repair_no"]; ?>"> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="sign_date">簽訂日期</label><br> |
|||
<input type="text" name="sign_date" id="sign_date" value="<?php echo $data["sign_date"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="company">公司地址</label> |
|||
<input type="text" name="masada_addr" id="masada_addr" size="46" value="<?php echo $data["maddr"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="company">客戶名稱</label> |
|||
<input type="text" name="company" id="company" size="30" value="<?php echo $data["company"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="facilityno">電梯編號</label> |
|||
<input type="text" name="facilityno" value="<?php echo $data["facilityno"]; ?>"> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="address">工程地址</label> |
|||
<input type="text" name="address" id="address" size="46" value="<?php echo $data["address"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="taxid">客戶統一編號</label> |
|||
<input type="text" name="taxid" id="taxid" value="<?php echo $data["taxid"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="invoice">客戶發票抬頭</label> |
|||
<input type="text" name="invoice" id="invoice" size="30" value="<?php echo $data["invoice"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="repairerid">申請人</label> |
|||
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data["repair"]; ?>"> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="memo">備註</label><br> |
|||
<textarea name="memo" id="memo" cols="60" rows="4"><?php echo $data["memo"]; ?></textarea> |
|||
</div> |
|||
|
|||
<div class="nextline"></div> |
|||
<br> |
|||
|
|||
<div class="table-responsive"> |
|||
<table id="tb1" class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th>項次</th> |
|||
<th>名稱</th> |
|||
<th>數量</th> |
|||
<th>單價</th> |
|||
<th>合計</th> |
|||
<th>備註</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach ($item_arr as $k => $v) { |
|||
?> |
|||
<tr name="main_templ"> |
|||
<td> |
|||
<input type="text" name="item_no" class="form-control" size="3" value="<?php echo $k; ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_title" class="form-control" size="40" value="<?php echo $v["title"]; ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_qty" class="form-control dollar-right" size="3" value="<?php echo number_format($v["item_qty"]); ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_unit_price" class="form-control dollar-right" size="10" value="<?php echo number_format($v["item_unit_price"]); ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_price_bp" class="form-control dollar-right" size="10" value="<?php echo number_format($v["item_price_bp"]); ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_memo" class="form-control" value="<?php echo $v["memo"]; ?>"> |
|||
</td> |
|||
</tr> |
|||
<?php |
|||
} |
|||
?> |
|||
<tr> |
|||
<td colspan="3"><h5>營業稅</h5></td> |
|||
<td> |
|||
<input type="text" name="sales_tax" class="dollar-right" size="10" value="<?php echo number_format($data["sales_tax"]); ?>"> |
|||
</td> |
|||
<td colspan="2"></td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="3"><h5>總價</h5></td> |
|||
<td> |
|||
<input type="text" name="total_price" class="dollar-right" size="10" value="<?php echo number_format($data["total_price"]); ?>"> |
|||
</td> |
|||
<td colspan="2"></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<div class="nextline"></div> |
|||
<?php |
|||
if (($data["checker"] == $user_id) && ($data["pstatus"] == "A")) { |
|||
?> |
|||
<div class="table-responsive"> |
|||
<table class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="10">簽核操作<span class="star">*</span></th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td><b style='float:right'>簽核狀態</b></td> |
|||
<td> |
|||
<select name="assign_status" id="assign_status" required class="form-control form-control form-control-sm"> |
|||
<?php echo $assign_status; ?> |
|||
</select> |
|||
</td> |
|||
<td><b>下位簽核者</b></td> |
|||
<td> |
|||
<select name="next_users" id="next_users" class="form-control form-control-sm" required></select> |
|||
</td> |
|||
<td> |
|||
<input type="submit" name="submit" id="submit" value="提交"> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<input type="hidden" name="id" id="id" value="<?php echo $id; ?>"> |
|||
<input type="hidden" name="form_key" id="form_key" value="<?php echo $form_key; ?>"> |
|||
<input type="hidden" name="token" id="token" value="<?php echo $token; ?>"> |
|||
<?php |
|||
} |
|||
?> |
|||
</form> |
|||
</div> |
|||
<?php |
|||
endforeach; |
|||
?> |
|||
<?php |
|||
include "../footer.php"; |
|||
<?php |
|||
include "../header.php"; |
|||
require_once '../cont/wf_common.php'; |
|||
$form_key = isset($_GET['form_key']) ? $_GET['form_key'] : ""; |
|||
if ($form_key == "") $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
if (!empty($form_key)) { |
|||
$sql = "SELECT form_id FROM flow where form_key = '$form_key'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$id = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 目前簽核進度 |
|||
$pstatus = ""; |
|||
$db_query = "select pstatus from pricereview_repair_main where id = '$id'"; |
|||
$res_r = mysqli_query($link, $db_query); |
|||
if ($row_r = mysqli_fetch_row($res_r)) { |
|||
$pstatus = $row_r[0]; |
|||
} |
|||
mysqli_free_result($res_r); |
|||
if ($pstatus != "A") { |
|||
echo "<script>"; |
|||
echo "alert('請勿重覆簽核!!');"; |
|||
echo "window.close();"; |
|||
echo "</script>"; |
|||
exit; |
|||
} |
|||
} |
|||
|
|||
$assign_status = '<option>請選擇</option><option value="F6">呈核</option><option value="Y1">不同意</option>'; |
|||
|
|||
$data = []; |
|||
$db_query = "select * from pricereview_repair_main where id = '$id'"; |
|||
$data = mysqli_query($link, $db_query); |
|||
|
|||
foreach ($data as $data) : |
|||
// 公司站點 |
|||
$sql = "select content from code where field_name = 'masada_addr' and code_name = '" . $data["masada_addr"] . "'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$data["maddr"] = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 保養人員 |
|||
$repairer_arr = []; |
|||
$sql = "select name from account where accounttype = 'B' and accountid = '" . $data["repairerid"] . "'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$data["repair"] = $row[0]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 價審明細 |
|||
$item_arr = []; |
|||
$sql = "select * from pricereview_repair_item where rid = '$id' order by item_no"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$item_arr[$row["item_no"]]["title"] = $row["title"]; |
|||
$item_arr[$row["item_no"]]["item_unit_price"] = $row["item_unit_price"]; |
|||
$item_arr[$row["item_no"]]["item_qty"] = $row["item_qty"]; |
|||
$item_arr[$row["item_no"]]["item_price_bp"] = $row["item_price_bp"]; |
|||
$item_arr[$row["item_no"]]["memo"] = $row["memo"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// get form_key |
|||
$sql = "select max(form_key) from assign where assign_opinion = '" . $data["repair_no"] . "'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$form_key = $row[0]; |
|||
mysqli_free_result($res); |
|||
?> |
|||
<style> |
|||
.nextline { |
|||
width: 100%; |
|||
height: 0; |
|||
} |
|||
|
|||
input[type=submit], |
|||
input[type=button] { |
|||
width: 100%; |
|||
background-color: #1E74FD; |
|||
color: white; |
|||
padding: 14px 20px; |
|||
margin: 8px 0; |
|||
border: none; |
|||
border-radius: 4px; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.dollar-right { |
|||
text-align: right; |
|||
} |
|||
|
|||
.star { |
|||
color: red; |
|||
} |
|||
</style> |
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> |
|||
<script> |
|||
$(function() { |
|||
$(":input").prop("disabled", true); |
|||
$("#assign_status").prop("disabled", false); |
|||
$("#next_users").prop("disabled", false); |
|||
$("#submit").prop("disabled", false); |
|||
$("#assign_status").change(function() { |
|||
if ($(this).val() == "F6") $("#next_users").html('<option value="00000">00000</option>'); |
|||
else if ($(this).val() == "Y1") $("#next_users").html('<option value="X">退回</option>'); |
|||
else $("#next_users").html(''); |
|||
}); |
|||
|
|||
$('input[name=submit]').click(function() { |
|||
$("#id").prop("disabled", false); |
|||
$("#form_key").prop("disabled", false); |
|||
$("#token").prop("disabled", false); |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="pricereview_repair-record-check.php" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="contractno">客戶合約號</label> |
|||
<input type="text" name="contractno" id="contractno" value="<?php echo $data["contractno"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="repair_no">報價單編號</label> |
|||
<input type="text" name="repair_no" id="repair_no" value="<?php echo $data["repair_no"]; ?>"> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="sign_date">簽訂日期</label><br> |
|||
<input type="text" name="sign_date" id="sign_date" value="<?php echo $data["sign_date"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="company">公司地址</label> |
|||
<input type="text" name="masada_addr" id="masada_addr" size="46" value="<?php echo $data["maddr"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="company">客戶名稱</label> |
|||
<input type="text" name="company" id="company" size="30" value="<?php echo $data["company"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="facilityno">電梯編號</label> |
|||
<input type="text" name="facilityno" value="<?php echo $data["facilityno"]; ?>"> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="address">工程地址</label> |
|||
<input type="text" name="address" id="address" size="46" value="<?php echo $data["address"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="taxid">客戶統一編號</label> |
|||
<input type="text" name="taxid" id="taxid" value="<?php echo $data["taxid"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="invoice">客戶發票抬頭</label> |
|||
<input type="text" name="invoice" id="invoice" size="30" value="<?php echo $data["invoice"]; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="repairerid">申請人</label> |
|||
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data["repair"]; ?>"> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="memo">備註</label><br> |
|||
<textarea name="memo" id="memo" cols="60" rows="4"><?php echo $data["memo"]; ?></textarea> |
|||
</div> |
|||
|
|||
<div class="nextline"></div> |
|||
<br> |
|||
|
|||
<div class="table-responsive"> |
|||
<table id="tb1" class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th>項次</th> |
|||
<th>名稱</th> |
|||
<th>數量</th> |
|||
<th>單價</th> |
|||
<th>合計</th> |
|||
<th>備註</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach ($item_arr as $k => $v) { |
|||
?> |
|||
<tr name="main_templ"> |
|||
<td> |
|||
<input type="text" name="item_no" class="form-control" size="3" value="<?php echo $k; ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_title" class="form-control" size="40" value="<?php echo $v["title"]; ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_qty" class="form-control dollar-right" size="3" value="<?php echo number_format($v["item_qty"]); ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_unit_price" class="form-control dollar-right" size="10" value="<?php echo number_format($v["item_unit_price"]); ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_price_bp" class="form-control dollar-right" size="10" value="<?php echo number_format($v["item_price_bp"]); ?>"> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="item_memo" class="form-control" value="<?php echo $v["memo"]; ?>"> |
|||
</td> |
|||
</tr> |
|||
<?php |
|||
} |
|||
?> |
|||
<tr> |
|||
<td colspan="3"> |
|||
<h5>服務費</h5> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="service_charge" class="dollar-right" size="10" value="<?php echo number_format($data["service_charge"]); ?>"> |
|||
</td> |
|||
<td colspan="2"></td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="3"> |
|||
<h5>營業稅</h5> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="sales_tax" class="dollar-right" size="10" value="<?php echo number_format($data["sales_tax"]); ?>"> |
|||
</td> |
|||
<td colspan="2"></td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="3"> |
|||
<h5>總價</h5> |
|||
</td> |
|||
<td> |
|||
<input type="text" name="total_price" class="dollar-right" size="10" value="<?php echo number_format($data["total_price"]); ?>"> |
|||
</td> |
|||
<td colspan="2"></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<div class="nextline"></div> |
|||
<?php |
|||
if (($data["checker"] == $user_id) && ($data["pstatus"] == "A")) { |
|||
?> |
|||
<div class="table-responsive"> |
|||
<table class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="10">簽核操作<span class="star">*</span></th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td><b style='float:right'>簽核狀態</b></td> |
|||
<td> |
|||
<select name="assign_status" id="assign_status" required class="form-control form-control form-control-sm"> |
|||
<?php echo $assign_status; ?> |
|||
</select> |
|||
</td> |
|||
<td><b>下位簽核者</b></td> |
|||
<td> |
|||
<select name="next_users" id="next_users" class="form-control form-control-sm" required></select> |
|||
</td> |
|||
<td> |
|||
<input type="submit" name="submit" id="submit" value="提交"> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<input type="hidden" name="id" id="id" value="<?php echo $id; ?>"> |
|||
<input type="hidden" name="form_key" id="form_key" value="<?php echo $form_key; ?>"> |
|||
<input type="hidden" name="token" id="token" value="<?php echo $token; ?>"> |
|||
<?php |
|||
} |
|||
?> |
|||
</form> |
|||
</div> |
|||
<?php |
|||
endforeach; |
|||
?> |
|||
<?php |
|||
include "../footer.php"; |
|||
?> |
File diff suppressed because it is too large
@ -1,78 +1,81 @@ |
|||
<?php |
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
//print_r($_POST);exit; |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
|
|||
$sales_tax = str_replace(",", "", $sales_tax); |
|||
$total_price = str_replace(",", "", $total_price); |
|||
$item_memo_arr = explode("@@,", rtrim($item_memo_all, "@@")); |
|||
$create_at = date("Y-m-d H:i:s"); |
|||
|
|||
// 避免報價單編號重覆 |
|||
$repair_no_a = date("Ymd"); |
|||
$sql = "select max(repair_no) from pricereview_repair_main where SUBSTRING(repair_no, 1, 8) = '$repair_no_a'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
if (empty($row[0])) $serial = "001"; |
|||
else $serial = str_pad(substr($row[0]+1, -3), 3, 0, STR_PAD_LEFT); |
|||
$new_repair_no = $repair_no_a.$serial; |
|||
if ($new_repair_no != $repair_no) $repair_no = $new_repair_no; |
|||
|
|||
// 價審單-主文 pricereview_repair_main |
|||
$db_query = "insert into pricereview_repair_main(repair_no, contractno, masada_addr, company, taxid, invoice, facilityno, "; |
|||
$db_query .= "address, sales_tax, total_price, sign_date, memo, repairerid, pstatus, checker, creater, create_at) values ("; |
|||
$db_query .= "'$repair_no', '$contractno', '$masada_addr', '$company', '$taxid', '$invoice', '$facilityno', "; |
|||
$db_query .= "'$address', $sales_tax, $total_price, '$sign_date', '$memo', '$repairerid', 'A', '$next_users', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
if ($rid = mysqli_insert_id($link)) { |
|||
// 價審單-明細項目 pricereview_repair_item |
|||
$item_title_all = str_replace("點選", "", $item_title_all); |
|||
$item_title_arr = explode(",", $item_title_all); |
|||
$item_qty_arr = explode(",", $item_qty_all); |
|||
$item_unit_price_arr = explode(",", $item_unit_price_all); |
|||
$item_price_bp_arr = explode(",", $item_price_bp_all); |
|||
$item_memo_arr = explode("@@,", rtrim($item_memo_all, "@@")); |
|||
$item_no = 1; |
|||
for ($i=0; $i<count($item_title_arr); $i++) { |
|||
$item_qty_arr[$i] = str_replace(",", "", $item_qty_arr[$i]); |
|||
$item_unit_price_arr[$i] = str_replace(",", "", $item_unit_price_arr[$i]); |
|||
$item_price_bp_arr[$i] = str_replace(",", "", $item_price_bp_arr[$i]); |
|||
$db_query = "insert into pricereview_repair_item (rid, item_no, title, item_unit_price, item_qty, item_price_bp, memo) values ("; |
|||
$db_query .= "'$rid', '$item_no', '$item_title_arr[$i]', '$item_unit_price_arr[$i]', '$item_qty_arr[$i]', '$item_price_bp_arr[$i]', '$item_memo_arr[$i]')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$item_no++; |
|||
} |
|||
|
|||
// 更新待簽表 |
|||
#係統ID |
|||
$system_id = 'prm'; |
|||
#流程ID |
|||
$flow_id = 'prm03'; |
|||
#表單號 $form_id; |
|||
$form_id = $rid; |
|||
$wf = new WorkFlow($system_id, $flow_id, $form_id); |
|||
$wf->initWorkFlow($user_id); |
|||
$form_key = $wf->flowContext->getFormKey(); |
|||
$sql = "insert into assign (form_key, seq, assigner, assign_opinion) values ('$form_key', 1, '$next_users', '$repair_no')"; |
|||
mysqli_query($link, $sql); |
|||
$sql = "update subflow set seq = seq+1, current_assigner = '$next_users', update_date = '$create_at' where form_key = '$form_key'"; |
|||
mysqli_query($link, $sql); |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
echo "alert('提交成功');"; |
|||
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
echo "alert('提交失敗,請重新操作');"; |
|||
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
} |
|||
?> |
|||
<?php |
|||
// echo '<pre>'; |
|||
// print_r($_POST); |
|||
// echo '</pre>'; |
|||
// exit(); |
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
//print_r($_POST);exit; |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
$sales_tax = str_replace(",", "", $sales_tax); |
|||
$service_charge = str_replace(",", "", $service_charge); |
|||
$total_price = str_replace(",", "", $total_price); |
|||
$item_memo_arr = explode("@@,", rtrim($item_memo_all, "@@")); |
|||
$create_at = date("Y-m-d H:i:s"); |
|||
|
|||
// 避免報價單編號重覆 |
|||
$repair_no_a = date("Ymd"); |
|||
$sql = "select max(repair_no) from pricereview_repair_main where SUBSTRING(repair_no, 1, 8) = '$repair_no_a'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
if (empty($row[0])) $serial = "001"; |
|||
else $serial = str_pad(substr($row[0] + 1, -3), 3, 0, STR_PAD_LEFT); |
|||
$new_repair_no = $repair_no_a . $serial; |
|||
if ($new_repair_no != $repair_no) $repair_no = $new_repair_no; |
|||
|
|||
// 價審單-主文 pricereview_repair_main |
|||
$db_query = "INSERT INTO pricereview_repair_main(repair_no, contractno, masada_addr, company, taxid, invoice, facilityno, "; |
|||
$db_query .= "address, sales_tax, service_charge, total_price, sign_date, memo, repairerid, pstatus, checker, creater, create_at) values ("; |
|||
$db_query .= "'$repair_no', '$contractno', '$masada_addr', '$company', '$taxid', '$invoice', '$facilityno', "; |
|||
$db_query .= "'$address', $sales_tax ,$service_charge ,$total_price, '$sign_date', '$memo', '$repairerid', 'A', '$next_users', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
if ($rid = mysqli_insert_id($link)) { |
|||
// 價審單-明細項目 pricereview_repair_item |
|||
$item_title_all = str_replace("點選", "", $item_title_all); |
|||
$item_title_arr = explode(",", $item_title_all); |
|||
$item_qty_arr = explode(",", $item_qty_all); |
|||
$item_unit_price_arr = explode(",", $item_unit_price_all); |
|||
$item_price_bp_arr = explode(",", $item_price_bp_all); |
|||
$item_memo_arr = explode("@@,", rtrim($item_memo_all, "@@")); |
|||
$item_no = 1; |
|||
for ($i = 0; $i < count($item_title_arr); $i++) { |
|||
$item_qty_arr[$i] = str_replace(",", "", $item_qty_arr[$i]); |
|||
$item_unit_price_arr[$i] = str_replace(",", "", $item_unit_price_arr[$i]); |
|||
$item_price_bp_arr[$i] = str_replace(",", "", $item_price_bp_arr[$i]); |
|||
$db_query = "insert into pricereview_repair_item (rid, item_no, title, item_unit_price, item_qty, item_price_bp, memo) values ("; |
|||
$db_query .= "'$rid', '$item_no', '$item_title_arr[$i]', '$item_unit_price_arr[$i]', '$item_qty_arr[$i]', '$item_price_bp_arr[$i]', '$item_memo_arr[$i]')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$item_no++; |
|||
} |
|||
|
|||
// 更新待簽表 |
|||
#係統ID |
|||
$system_id = 'prm'; |
|||
#流程ID |
|||
$flow_id = 'prm03'; |
|||
#表單號 $form_id; |
|||
$form_id = $rid; |
|||
$wf = new WorkFlow($system_id, $flow_id, $form_id); |
|||
$wf->initWorkFlow($user_id); |
|||
$form_key = $wf->flowContext->getFormKey(); |
|||
$sql = "insert into assign (form_key, seq, assigner, assign_opinion) values ('$form_key', 1, '$next_users', '$repair_no')"; |
|||
mysqli_query($link, $sql); |
|||
$sql = "update subflow set seq = seq+1, current_assigner = '$next_users', update_date = '$create_at' where form_key = '$form_key'"; |
|||
mysqli_query($link, $sql); |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
echo "alert('提交成功');"; |
|||
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&" . $token_link . "';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
echo "alert('提交失敗,請重新操作');"; |
|||
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&" . $token_link . "';"; |
|||
echo "</script>"; |
|||
} |
|||
} |
|||
|
@ -1,176 +1,177 @@ |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set("display_errors", "on"); |
|||
/** |
|||
* 显示所有的待签 员工所有待签 |
|||
*/ |
|||
|
|||
|
|||
// 載入db.php來連結資料庫 |
|||
require_once "../database.php"; |
|||
require_once "../header.php"; |
|||
|
|||
|
|||
|
|||
$system_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['system_id'] : @$_POST['system_id']; |
|||
$where_system_id = " and a.system_id like '" . $system_id . "%'"; |
|||
|
|||
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id']; |
|||
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'"; |
|||
|
|||
$sql_get = "select c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner, |
|||
concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name , |
|||
flow_name,c.update_date ,c.create_date,b.path,d.flow_code from system_main a,flow_main b ,subflow |
|||
c,flow d |
|||
where a.system_id=b.system_id |
|||
and b.flow_id=d.flow_id |
|||
and c.current_assigner='$user_id' |
|||
and d.flow_id=b.flow_id |
|||
and c.form_key=d.form_key |
|||
$where_system_id |
|||
$where_flow_id |
|||
"; |
|||
//echo $sql_get; |
|||
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC); |
|||
|
|||
$system_name_opt = array_map(function ($item) { |
|||
return array('system_id' => $item['system_id'], 'system_name' => $item['system_name']); |
|||
}, $res_get); |
|||
$system_name_opt = (array_unique($system_name_opt, SORT_REGULAR)); |
|||
|
|||
|
|||
$flow_name_opt = array_map(function ($item) { |
|||
return array('flow_id' => $item['flow_id'], 'flow_name' => $item['flow_name']); |
|||
}, $res_get); |
|||
$flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR)); |
|||
|
|||
?> |
|||
<style> |
|||
table { |
|||
table-layout: fixed; |
|||
width: 90%; |
|||
} |
|||
|
|||
td { |
|||
word-wrap: break-word; |
|||
} |
|||
|
|||
img { |
|||
width: 125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width: 125px; |
|||
} |
|||
|
|||
.table>tbody>tr>td, |
|||
.table>tbody>tr>th, |
|||
.table>tfoot>tr>td, |
|||
.table>tfoot>tr>th, |
|||
.table>thead>tr>td, |
|||
.table>thead>tr>th { |
|||
vertical-align: middle !important; |
|||
} |
|||
|
|||
#table_index_filter { |
|||
float: right; |
|||
} |
|||
|
|||
#table_index_paginate { |
|||
float: right; |
|||
} |
|||
|
|||
|
|||
table.query-table th { |
|||
text-align: right; |
|||
} |
|||
|
|||
</style> |
|||
<form method='post' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:90%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>待簽查詢</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<th style='width:50px'>系統名稱</th> |
|||
<td colspan='1'> |
|||
<select class='form-control' name='system_id'> |
|||
<?php |
|||
echo " <option class='form-control' value='%' >全部</option>"; |
|||
foreach ($system_name_opt as $opt) { |
|||
echo " <option class='form-control' value=" . $opt['system_id'] . " >" . $opt['system_name'] . "</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</td> |
|||
<th>流程名稱</th> |
|||
<td colspan='1'> <select class='form-control' name='flow_id'> |
|||
<?php |
|||
echo " <option class='form-control' value='%' >全部</option>"; |
|||
foreach ($flow_name_opt as $opt) { |
|||
echo " <option class='form-control' value=" . $opt['flow_id'] . " >" . $opt['flow_name'] . "</option>"; |
|||
} |
|||
?> |
|||
</select> </td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
<tfoot> |
|||
<tr> |
|||
<td colspan="8" style='text-align:center'> |
|||
<button type="submit" style='text-align:center; margin:0 auto;width:50px' class="btn btn-primary">查詢</button> |
|||
</td> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
<div style="overflow-x:auto;width:92%;margin:0 auto"> |
|||
<table id="table_index" style='width:100%;margin:0 auto' class="table table-striped table-bordered display compact"> |
|||
<thead> |
|||
<tr> |
|||
<th>序號</th> |
|||
<th>系統名稱</th> |
|||
<th>流程名稱</th> |
|||
<th>接收日期</th> |
|||
<th>當前簽核者</th> |
|||
<th>狀態</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php |
|||
$rowspan = 1; |
|||
foreach ($res_get as $key => $data) : |
|||
//嘗試將已結案隱藏起來 : 測試使用者體驗 |
|||
if ($data['flow_code'] !== 'Z') { |
|||
?> |
|||
<tr> |
|||
<td><a target="_blank" href="<?= $data['path'] . "?form_key=" . $data['form_key'] . "&token=$token" ?>"><?= $data['form_key']; ?></a></td> |
|||
<td><?php echo $data['system_name']; ?></td> |
|||
<td><?php echo $data['flow_name']; ?></td> |
|||
<td><?php echo $data['update_date']; ?></td> |
|||
<td><?php echo $data['current_assigner_name']; ?></td> |
|||
<td><?php echo $data['flow_code'] == 'Z' ? "結案" : ""; ?></td> |
|||
</tr> |
|||
|
|||
|
|||
<?php |
|||
} |
|||
endforeach; |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</form> |
|||
<?php |
|||
#代錶結束連線 |
|||
mysqli_close($link); |
|||
require_once "../footer.php"; |
|||
|
|||
|
|||
<?php |
|||
// phpinfo(); |
|||
// exit(); |
|||
error_reporting(E_ALL); |
|||
ini_set("display_errors", "on"); |
|||
/** |
|||
* 显示所有的待签 员工所有待签 |
|||
*/ |
|||
|
|||
|
|||
// 載入db.php來連結資料庫 |
|||
require_once "../database.php"; |
|||
require_once "../header.php"; |
|||
|
|||
|
|||
|
|||
$system_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['system_id'] : @$_POST['system_id']; |
|||
$where_system_id = " and a.system_id like '" . $system_id . "%'"; |
|||
|
|||
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id']; |
|||
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'"; |
|||
|
|||
$sql_get = "SELECT c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner, |
|||
concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name , |
|||
flow_name,c.update_date ,c.create_date,b.path,d.flow_code FROM system_main a,flow_main b ,subflow |
|||
c,flow d |
|||
WHERE a.system_id=b.system_id |
|||
AND b.flow_id=d.flow_id |
|||
AND c.current_assigner='$user_id' |
|||
AND d.flow_id=b.flow_id |
|||
AND c.form_key=d.form_key |
|||
$where_system_id |
|||
$where_flow_id |
|||
"; |
|||
echo $sql_get; |
|||
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC); |
|||
|
|||
$system_name_opt = array_map(function ($item) { |
|||
return array('system_id' => $item['system_id'], 'system_name' => $item['system_name']); |
|||
}, $res_get); |
|||
$system_name_opt = (array_unique($system_name_opt, SORT_REGULAR)); |
|||
|
|||
|
|||
$flow_name_opt = array_map(function ($item) { |
|||
return array('flow_id' => $item['flow_id'], 'flow_name' => $item['flow_name']); |
|||
}, $res_get); |
|||
$flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR)); |
|||
|
|||
?> |
|||
<style> |
|||
table { |
|||
table-layout: fixed; |
|||
width: 90%; |
|||
} |
|||
|
|||
td { |
|||
word-wrap: break-word; |
|||
} |
|||
|
|||
img { |
|||
width: 125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width: 125px; |
|||
} |
|||
|
|||
.table>tbody>tr>td, |
|||
.table>tbody>tr>th, |
|||
.table>tfoot>tr>td, |
|||
.table>tfoot>tr>th, |
|||
.table>thead>tr>td, |
|||
.table>thead>tr>th { |
|||
vertical-align: middle !important; |
|||
} |
|||
|
|||
#table_index_filter { |
|||
float: right; |
|||
} |
|||
|
|||
#table_index_paginate { |
|||
float: right; |
|||
} |
|||
|
|||
|
|||
table.query-table th { |
|||
text-align: right; |
|||
} |
|||
</style> |
|||
<form method='post' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:90%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>待簽查詢</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<th style='width:50px'>系統名稱</th> |
|||
<td colspan='1'> |
|||
<select class='form-control' name='system_id'> |
|||
<?php |
|||
echo " <option class='form-control' value='%' >全部</option>"; |
|||
foreach ($system_name_opt as $opt) { |
|||
echo " <option class='form-control' value=" . $opt['system_id'] . " >" . $opt['system_name'] . "</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</td> |
|||
<th>流程名稱</th> |
|||
<td colspan='1'> <select class='form-control' name='flow_id'> |
|||
<?php |
|||
echo " <option class='form-control' value='%' >全部</option>"; |
|||
foreach ($flow_name_opt as $opt) { |
|||
echo " <option class='form-control' value=" . $opt['flow_id'] . " >" . $opt['flow_name'] . "</option>"; |
|||
} |
|||
?> |
|||
</select> </td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
<tfoot> |
|||
<tr> |
|||
<td colspan="8" style='text-align:center'> |
|||
<button type="submit" style='text-align:center; margin:0 auto;width:50px' class="btn btn-primary">查詢</button> |
|||
</td> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
<div style="overflow-x:auto;width:92%;margin:0 auto"> |
|||
<table id="table_index" style='width:100%;margin:0 auto' class="table table-striped table-bordered display compact"> |
|||
<thead> |
|||
<tr> |
|||
<th>序號</th> |
|||
<th>系統名稱</th> |
|||
<th>流程名稱</th> |
|||
<th>接收日期</th> |
|||
<th>當前簽核者</th> |
|||
<th>狀態</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php |
|||
$rowspan = 1; |
|||
foreach ($res_get as $key => $data) : |
|||
//嘗試將已結案隱藏起來 : 測試使用者體驗 |
|||
if ($data['flow_code'] !== 'Z') { |
|||
?> |
|||
<tr> |
|||
<td><a target="_blank" href="<?= $data['path'] . "?form_key=" . $data['form_key'] . "&token=$token" ?>"><?= $data['form_key']; ?></a></td> |
|||
<td><?php echo $data['system_name']; ?></td> |
|||
<td><?php echo $data['flow_name']; ?></td> |
|||
<td><?php echo $data['update_date']; ?></td> |
|||
<td><?php echo $data['current_assigner_name']; ?></td> |
|||
<td><?php echo $data['flow_code'] == 'Z' ? "結案" : ""; ?></td> |
|||
</tr> |
|||
|
|||
|
|||
<?php |
|||
} |
|||
endforeach; |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</form> |
|||
<?php |
|||
#代錶結束連線 |
|||
mysqli_close($link); |
|||
require_once "../footer.php"; |
|||
|
|||
|
|||
?> |
File diff suppressed because it is too large
Loading…
Reference in new issue