Browse Source
# Conflicts: # wms/estimated_shipping_date_report.php # wms/wipwhole-change-contractdate-submit.php # wms/wipwhole-index-function.php # wms/wipwhole-rec-invoice.php # wms/wipwhole-renovate-rec-invoice-edit-submit.php # wms/wipwhole-renovate-rec-invoice-edit.php # wms/wipwhole-renovate-rec-invoice.php # wms/wipwholeinstall-index-function.php # wms/wipwholeinstall-renovate-index-function.phpgary
1792 changed files with 514130 additions and 50164 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,140 +1,143 @@ |
|||
<?php |
|||
include "header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
require_once "database.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql = "select * from contractapply_main order by id"; |
|||
$data = mysqli_query($link,$sql); |
|||
$apply_type_arr = ["A" => "制式新合約", "B" => "非制式新合約"]; |
|||
$status_arr = ["I" => "申請中", "P" => "在途中", "Y" => "已完成", "X" => "作廢"]; |
|||
?> |
|||
<p> |
|||
<a href="contractapply-create.php" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
if($data): |
|||
?> |
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>合約狀態時間</th> |
|||
<th>案件名稱</th> |
|||
<th>含稅貨款</th> |
|||
<th>含稅按裝款</th> |
|||
<th>含稅給約總價</th> |
|||
<th>二次款</th> |
|||
<!--<th>交貨期限</th> |
|||
<th>完工期限</th>--> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach($data as $data) : |
|||
switch ($data["status"]) { |
|||
case "I": |
|||
$status_dt = $data["status_1_dt"]; |
|||
break; |
|||
case "P": |
|||
$status_dt = $data["status_2_dt"]; |
|||
break; |
|||
case "Y": |
|||
$status_dt = $data["status_3_dt"]; |
|||
break; |
|||
case "X": |
|||
$status_dt = $data["status_4_dt"]; |
|||
break; |
|||
} |
|||
?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['apply_no1'].$data['apply_no2']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['person']; ?></td> |
|||
<td><?php echo $data['apply_number']; ?></td> |
|||
<td><?php echo $data['apply_date']; ?></td> |
|||
<td><?php echo $data['promiser']; ?></td> |
|||
<td><?php echo $apply_type_arr[$data['apply_type']]; ?></td> |
|||
<td> |
|||
<?php echo $status_arr[$data['status']]; ?> |
|||
<p> |
|||
<a href="contractapply-edit.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td><?php echo $status_dt; ?></td> |
|||
<td><?php echo $data['case_name']; ?></td> |
|||
<td><?php echo number_format($data['pay']); ?></td> |
|||
<td><?php echo number_format($data['pay_install']); ?></td> |
|||
<td><?php echo number_format($data['pay_total']); ?></td> |
|||
<td><?php echo $data['pay_second']; ?>天</td> |
|||
<!--<td><?php echo $data['delivery_date']; ?></td>
|
|||
<td><?php echo $data['completion_date']; ?></td>--> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_dt']; ?></td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<?php |
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
<?php |
|||
include "header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
require_once "database.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql = "select * from contractapply_main order by id"; |
|||
$data = mysqli_query($link, $sql); |
|||
$apply_type_arr = ["A" => "制式新合約", "B" => "非制式新合約"]; |
|||
$status_arr = ["I" => "申請中", "P" => "在途中", "Y" => "已完成", "X" => "作廢"]; |
|||
?> |
|||
<p> |
|||
<a href="contractapply-create.php" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
if ($data) : |
|||
?> |
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>合約狀態時間</th> |
|||
<th>案件名稱</th> |
|||
<th>含稅貨款</th> |
|||
<th>含稅按裝款</th> |
|||
<th>含稅給約總價</th> |
|||
<th>二次款</th> |
|||
<!--<th>交貨期限</th> |
|||
<th>完工期限</th>--> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $data) : |
|||
switch ($data["status"]) { |
|||
case "I": |
|||
$status_dt = $data["status_1_dt"]; |
|||
break; |
|||
case "P": |
|||
$status_dt = $data["status_2_dt"]; |
|||
break; |
|||
case "Y": |
|||
$status_dt = $data["status_3_dt"]; |
|||
break; |
|||
case "X": |
|||
$status_dt = $data["status_4_dt"]; |
|||
break; |
|||
} |
|||
?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['apply_no1'] . $data['apply_no2']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['person']; ?></td> |
|||
<td><?php echo $data['apply_number']; ?></td> |
|||
<td><?php echo $data['apply_date']; ?></td> |
|||
<td><?php echo $data['promiser']; ?></td> |
|||
<td><?php echo $apply_type_arr[$data['apply_type']]; ?></td> |
|||
<td> |
|||
<?php echo $status_arr[$data['status']]; ?> |
|||
<p> |
|||
<a href="contractapply-edit.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td><?php echo $status_dt; ?></td> |
|||
<td><?php echo $data['case_name']; ?></td> |
|||
<td><?php echo number_format($data['pay']); ?></td> |
|||
<td><?php echo number_format($data['pay_install']); ?></td> |
|||
<td><?php echo number_format($data['pay_total']); ?></td> |
|||
<td><?php echo $data['pay_second']; ?>天</td> |
|||
<!--<td><?php echo $data['delivery_date']; ?></td>
|
|||
<td><?php echo $data['completion_date']; ?></td>--> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_dt']; ?></td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<?php |
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
?> |
@ -0,0 +1,3 @@ |
|||
Array |
|||
Array |
|||
Array |
@ -1,212 +1,212 @@ |
|||
<?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[3]) { |
|||
$data['user_id'] = ''; |
|||
$data['code'] = '401'; |
|||
$data['message'] = 'Token已过期,请重新登录'; |
|||
return $data; |
|||
} |
|||
if (($true_signature == $explode[4])) { |
|||
$data['user_id'] = $explode[0]; |
|||
$data['code'] = '200'; |
|||
$data['message'] = 'Token合法'; |
|||
return $data; |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$data['code'] = '400'; |
|||
$data['message'] = 'Token不合法'; |
|||
return $data; |
|||
} |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$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 . '.' . base64_encode(urlencode($user_name)) . '.' . $start_time . '.' . $end_time; //设置token过期时间为一天 |
|||
$encryption_code = "MASADA!^***"; |
|||
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量) |
|||
$signature = hash_hmac('md5', $info, $encryption_code); |
|||
//最后将这两部分拼接起来,得到最终的Token字符串 |
|||
return $token = $info . '.' . $signature; |
|||
} |
|||
//生成菜单 |
|||
|
|||
/** |
|||
* 將模擬帳號寫入token |
|||
*/ |
|||
function FakeToken($fake_user_id, $token) { |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$encryption_code = "MASADA!^***"; |
|||
$time = date("Y-m-d H:i:s"); |
|||
$explode = explode('.', $token); |
|||
$info = $fake_user_id . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; // 欲模擬帳號.本人帳號.有效開始時間.失效時間 |
|||
$signature = hash_hmac('md5', $info, $encryption_code); |
|||
return $token = $info . '.' . $signature; |
|||
} |
|||
|
|||
function menu ($from='tw',$type){ |
|||
$function_type = array( |
|||
"tw" => array( |
|||
# F角色菜单 |
|||
"F" => 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]; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 依帳號類別檢視功能目錄 |
|||
*/ |
|||
function menu_v2($atype="") { |
|||
global $link; |
|||
|
|||
if (!$atype) return; |
|||
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu where accounttype = '$atype' and status = 'Y' order by main_menu_seq, sub_menu_seq"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$arr[$row["main_menu"]][$row["sub_menu"]][$row["sub_menu_eng"]] = $row["mlink"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
$str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
return $str; |
|||
} |
|||
|
|||
/** |
|||
* 依帳號檢視功能目錄 |
|||
* 管理者可看到全部選單 |
|||
* 其餘人員依account_auth決定可檢視的選單 |
|||
*/ |
|||
function menu_v3($aid="", $accounttype) { |
|||
global $link; |
|||
|
|||
if (!$aid) return; |
|||
$str = ""; |
|||
$arr = $menu_arr = []; |
|||
|
|||
$sql_cmd = ($accounttype == "E") ? "" : "where status = 'Y'"; |
|||
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu $sql_cmd order by main_menu_seq, sub_menu_seq"; |
|||
|
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$menu_arr[$row["mlink"]]["main_menu"] = $row["main_menu"]; |
|||
$menu_arr[$row["mlink"]]["sub_menu"] = $row["sub_menu"]; |
|||
$menu_arr[$row["mlink"]]["sub_menu_eng"] = $row["sub_menu_eng"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$sql = "select permission from account_auth where accountid = '$aid'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$permission = empty($row)? json_encode([]): $row[0]; // $permission = $row[0]; //P0044 修改于2023/6/13 16:30 |
|||
|
|||
$permission_arr = json_decode($permission, true); |
|||
foreach ($menu_arr as $key => $val) { |
|||
if (($accounttype == "E") || !empty($permission_arr[$key])) { |
|||
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key; |
|||
} |
|||
} |
|||
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
/* |
|||
if ($permission_arr) { |
|||
foreach ($menu_arr as $key => $val) { |
|||
if ($permission_arr[$key]) { |
|||
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key; |
|||
} |
|||
} |
|||
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
} |
|||
*/ |
|||
mysqli_free_result($res); |
|||
|
|||
return $str; |
|||
/* |
|||
$str = ""; |
|||
$sql = "select a.id, a.accountid, m.auth_content from account a, menu_auth m where a.accountid = '$aid' and a.accountid = m.accountid and m.status = 'Y'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
list($id, $accountid, $auth_content) = $row; |
|||
$auth_arr = json_decode($auth_content, true); |
|||
$menuid_arr = array_keys($auth_arr); |
|||
if ($menuid_arr) { |
|||
$arr = []; |
|||
$menuid_str = implode(",", $menuid_arr); |
|||
$sql2 = "select id, main_menu, sub_menu, sub_menu_eng, link from menu_tree where id in ($menuid_str) and status = 'Y' order by main_menu_seq, sub_menu_seq"; |
|||
$res2 = mysqli_query($link, $sql2); |
|||
while ($row2 = mysqli_fetch_assoc($res2)) { |
|||
$arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = $row2["link"]; // R+W |
|||
if ($auth_arr[$row2["id"]] == "N") $arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = "";//"/wms/forbidden.php"; // R |
|||
} |
|||
mysqli_free_result($res2); |
|||
$str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
} |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
return $str; |
|||
*/ |
|||
} |
|||
<?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[3]) { |
|||
$data['user_id'] = ''; |
|||
$data['code'] = '401'; |
|||
$data['message'] = 'Token已过期,请重新登录'; |
|||
return $data; |
|||
} |
|||
if (($true_signature == $explode[4])) { |
|||
$data['user_id'] = $explode[0]; |
|||
$data['code'] = '200'; |
|||
$data['message'] = 'Token合法'; |
|||
return $data; |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$data['code'] = '400'; |
|||
$data['message'] = 'Token不合法'; |
|||
return $data; |
|||
} |
|||
} else { |
|||
$data['user_id'] = ''; |
|||
$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 . '.' . base64_encode(urlencode($user_name)) . '.' . $start_time . '.' . $end_time; //设置token过期时间为一天 |
|||
$encryption_code = "MASADA!^***"; |
|||
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量) |
|||
$signature = hash_hmac('md5', $info, $encryption_code); |
|||
//最后将这两部分拼接起来,得到最终的Token字符串 |
|||
return $token = $info . '.' . $signature; |
|||
} |
|||
//生成菜单 |
|||
|
|||
/** |
|||
* 將模擬帳號寫入token |
|||
*/ |
|||
function FakeToken($fake_user_id, $token) { |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$encryption_code = "MASADA!^***"; |
|||
$time = date("Y-m-d H:i:s"); |
|||
$explode = explode('.', $token); |
|||
$info = $fake_user_id . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; // 欲模擬帳號.本人帳號.有效開始時間.失效時間 |
|||
$signature = hash_hmac('md5', $info, $encryption_code); |
|||
return $token = $info . '.' . $signature; |
|||
} |
|||
|
|||
function menu ($from='tw',$type){ |
|||
$function_type = array( |
|||
"tw" => array( |
|||
# F角色菜单 |
|||
"F" => 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]; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 依帳號類別檢視功能目錄 |
|||
*/ |
|||
function menu_v2($atype="") { |
|||
global $link; |
|||
|
|||
if (!$atype) return; |
|||
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu where accounttype = '$atype' and status = 'Y' order by main_menu_seq, sub_menu_seq"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$arr[$row["main_menu"]][$row["sub_menu"]][$row["sub_menu_eng"]] = $row["mlink"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
$str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
return $str; |
|||
} |
|||
|
|||
/** |
|||
* 依帳號檢視功能目錄 |
|||
* 管理者可看到全部選單 |
|||
* 其餘人員依account_auth決定可檢視的選單 |
|||
*/ |
|||
function menu_v3($aid="", $accounttype) { |
|||
global $link; |
|||
|
|||
if (!$aid) return; |
|||
$str = ""; |
|||
$arr = $menu_arr = []; |
|||
|
|||
$sql_cmd = ($accounttype == "E") ? "" : "where status = 'Y'"; |
|||
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu $sql_cmd order by main_menu_seq, sub_menu_seq"; |
|||
|
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$menu_arr[$row["mlink"]]["main_menu"] = $row["main_menu"]; |
|||
$menu_arr[$row["mlink"]]["sub_menu"] = $row["sub_menu"]; |
|||
$menu_arr[$row["mlink"]]["sub_menu_eng"] = $row["sub_menu_eng"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$sql = "select permission from account_auth where accountid = '$aid'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$permission = empty($row)? json_encode([]): $row[0]; // $permission = $row[0]; //P0044 修改于2023/6/13 16:30 |
|||
|
|||
$permission_arr = json_decode($permission, true); |
|||
foreach ($menu_arr as $key => $val) { |
|||
if (($accounttype == "E") || !empty($permission_arr[$key])) { |
|||
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key; |
|||
} |
|||
} |
|||
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
/* |
|||
if ($permission_arr) { |
|||
foreach ($menu_arr as $key => $val) { |
|||
if ($permission_arr[$key]) { |
|||
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key; |
|||
} |
|||
} |
|||
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
} |
|||
*/ |
|||
mysqli_free_result($res); |
|||
|
|||
return $str; |
|||
/* |
|||
$str = ""; |
|||
$sql = "select a.id, a.accountid, m.auth_content from account a, menu_auth m where a.accountid = '$aid' and a.accountid = m.accountid and m.status = 'Y'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
list($id, $accountid, $auth_content) = $row; |
|||
$auth_arr = json_decode($auth_content, true); |
|||
$menuid_arr = array_keys($auth_arr); |
|||
if ($menuid_arr) { |
|||
$arr = []; |
|||
$menuid_str = implode(",", $menuid_arr); |
|||
$sql2 = "select id, main_menu, sub_menu, sub_menu_eng, link from menu_tree where id in ($menuid_str) and status = 'Y' order by main_menu_seq, sub_menu_seq"; |
|||
$res2 = mysqli_query($link, $sql2); |
|||
while ($row2 = mysqli_fetch_assoc($res2)) { |
|||
$arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = $row2["link"]; // R+W |
|||
if ($auth_arr[$row2["id"]] == "N") $arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = "";//"/wms/forbidden.php"; // R |
|||
} |
|||
mysqli_free_result($res2); |
|||
$str = json_encode($arr, JSON_UNESCAPED_UNICODE); |
|||
} |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
return $str; |
|||
*/ |
|||
} |
|||
} |
@ -1,91 +1,91 @@ |
|||
<?php |
|||
include "T8_Authorization.php"; |
|||
echo "ii"; |
|||
?> |
|||
<script> |
|||
get_Auth(); |
|||
window.addEventListener('message', function(event) { |
|||
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { |
|||
// if (event.origin === "https://masada.com.tw" && (typeof event.data === "string")) { |
|||
var validation = event.data; |
|||
console.log("event"); |
|||
console.log(validation); |
|||
|
|||
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; |
|||
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALDISPATCHLIST/GetERPData?pkValue=SS20230825001'; |
|||
headerParam = { |
|||
CHI_Authorization: `${validation}`, |
|||
}; |
|||
var body = [{ |
|||
"name": "MasterTable", |
|||
"rows": [{ |
|||
"BillNo": "Z001", |
|||
"BillDate": 20230930, |
|||
"OrgId": "1000", |
|||
"TypeId": "OPV", |
|||
"BizPartnerId": "03051501", |
|||
"CurrId": "RMB", |
|||
"CurrLAmount":5, |
|||
"TaxId": "ST005", |
|||
"PersonId": "M0012", |
|||
"DeptId": "220", |
|||
"CompId": "1001", |
|||
"CreditAgeDate": 20230930, |
|||
"RecBizPartnerId": "03051501", |
|||
|
|||
}] |
|||
}, |
|||
{ |
|||
"name": "DetailTable", |
|||
"rows": [{ |
|||
"BillNo": "Z001", |
|||
"RowCode": 1, |
|||
"RowNo": 1, |
|||
"ItemType": 0, |
|||
"MaterialId": "MX00000001", |
|||
"UnitId": "PCS", |
|||
"MaterialSpec": "", |
|||
"SQuantity": 10, |
|||
"SPrice": 141.18, |
|||
"OAmount": 1344.57, |
|||
"OTax": 67.23, |
|||
"OAmountWithTax": 1411.8, |
|||
"TaxId": "ST005" |
|||
}, |
|||
{ |
|||
"BillNo": "Z001", |
|||
"RowCode": 2, |
|||
"RowNo": 2, |
|||
"ItemType": 0, |
|||
"MaterialId": "MX00000001", |
|||
"UnitId": "PCS", |
|||
"MaterialSpec": "", |
|||
"SQuantity": 15, |
|||
"SPrice": 141.18, |
|||
"OAmount": 2016.86, |
|||
"OTax": 100.84, |
|||
"OAmountWithTax": 2117.7, |
|||
"TaxId": "ST005" |
|||
} |
|||
] |
|||
} |
|||
]; |
|||
var json = JSON.stringify(body); |
|||
obj = { |
|||
type: 'GET', |
|||
// url: `${corsurl}${apiurl}`, |
|||
url: `${apiurl}`, |
|||
// dataType: 'json', |
|||
headers: headerParam, |
|||
// data: json, |
|||
// dataType: "json", |
|||
success: function(res) { |
|||
console.log(res.Status); |
|||
console.log(res.ErrorMsg); |
|||
console.log(res.Data); |
|||
} |
|||
}; |
|||
jQuery.ajax(obj); |
|||
} |
|||
}) |
|||
<?php |
|||
include "T8_Authorization.php"; |
|||
echo "ii"; |
|||
?> |
|||
<script> |
|||
get_Auth(); |
|||
window.addEventListener('message', function(event) { |
|||
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { |
|||
// if (event.origin === "https://masada.com.tw" && (typeof event.data === "string")) { |
|||
var validation = event.data; |
|||
console.log("event"); |
|||
console.log(validation); |
|||
|
|||
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; |
|||
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALDISPATCHLIST/GetERPData?pkValue=SS20230825001'; |
|||
headerParam = { |
|||
CHI_Authorization: `${validation}`, |
|||
}; |
|||
var body = [{ |
|||
"name": "MasterTable", |
|||
"rows": [{ |
|||
"BillNo": "Z001", |
|||
"BillDate": 20230930, |
|||
"OrgId": "1000", |
|||
"TypeId": "OPV", |
|||
"BizPartnerId": "03051501", |
|||
"CurrId": "RMB", |
|||
"CurrLAmount":5, |
|||
"TaxId": "ST005", |
|||
"PersonId": "M0012", |
|||
"DeptId": "220", |
|||
"CompId": "1001", |
|||
"CreditAgeDate": 20230930, |
|||
"RecBizPartnerId": "03051501", |
|||
|
|||
}] |
|||
}, |
|||
{ |
|||
"name": "DetailTable", |
|||
"rows": [{ |
|||
"BillNo": "Z001", |
|||
"RowCode": 1, |
|||
"RowNo": 1, |
|||
"ItemType": 0, |
|||
"MaterialId": "MX00000001", |
|||
"UnitId": "PCS", |
|||
"MaterialSpec": "", |
|||
"SQuantity": 10, |
|||
"SPrice": 141.18, |
|||
"OAmount": 1344.57, |
|||
"OTax": 67.23, |
|||
"OAmountWithTax": 1411.8, |
|||
"TaxId": "ST005" |
|||
}, |
|||
{ |
|||
"BillNo": "Z001", |
|||
"RowCode": 2, |
|||
"RowNo": 2, |
|||
"ItemType": 0, |
|||
"MaterialId": "MX00000001", |
|||
"UnitId": "PCS", |
|||
"MaterialSpec": "", |
|||
"SQuantity": 15, |
|||
"SPrice": 141.18, |
|||
"OAmount": 2016.86, |
|||
"OTax": 100.84, |
|||
"OAmountWithTax": 2117.7, |
|||
"TaxId": "ST005" |
|||
} |
|||
] |
|||
} |
|||
]; |
|||
var json = JSON.stringify(body); |
|||
obj = { |
|||
type: 'GET', |
|||
// url: `${corsurl}${apiurl}`, |
|||
url: `${apiurl}`, |
|||
// dataType: 'json', |
|||
headers: headerParam, |
|||
// data: json, |
|||
// dataType: "json", |
|||
success: function(res) { |
|||
console.log(res.Status); |
|||
console.log(res.ErrorMsg); |
|||
console.log(res.Data); |
|||
} |
|||
}; |
|||
jQuery.ajax(obj); |
|||
} |
|||
}) |
|||
</script> |
@ -1,37 +1,37 @@ |
|||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> |
|||
<?php |
|||
$now = gmdate("YmdHis"); |
|||
$data = 'M0000.' . $now; |
|||
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); |
|||
|
|||
?> |
|||
|
|||
<script> |
|||
function get_Auth() { |
|||
var api_key = 'B2D6395D2883E26C'; |
|||
var validation = ""; |
|||
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; |
|||
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; |
|||
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth' |
|||
headerParam = { |
|||
UserId: 'M0000', |
|||
Pwd: 'M012290493119', |
|||
TimestampUTC: <?= $now ?>, |
|||
Sign: '<?= $sign ?>' |
|||
}; |
|||
obj = { |
|||
type: 'get', |
|||
// url: `${corsurl}${apiurl}`, |
|||
url: `${apiurl}`, |
|||
dataType: 'json', |
|||
headers: headerParam, |
|||
success: function(res) { |
|||
validation = res.Data['CHI_Authorization']; |
|||
console.log("validation:",validation); |
|||
window.parent.postMessage(validation,'http://localhost:3000'); |
|||
// window.parent.postMessage(validation,'https://masada.com.tw'); |
|||
} |
|||
}; |
|||
jQuery.ajax(obj); |
|||
} |
|||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> |
|||
<?php |
|||
$now = gmdate("YmdHis"); |
|||
$data = 'M0000.' . $now; |
|||
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); |
|||
|
|||
?> |
|||
|
|||
<script> |
|||
function get_Auth() { |
|||
var api_key = 'B2D6395D2883E26C'; |
|||
var validation = ""; |
|||
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; |
|||
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; |
|||
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth' |
|||
headerParam = { |
|||
UserId: 'M0000', |
|||
Pwd: 'M012290493119', |
|||
TimestampUTC: <?= $now ?>, |
|||
Sign: '<?= $sign ?>' |
|||
}; |
|||
obj = { |
|||
type: 'get', |
|||
// url: `${corsurl}${apiurl}`, |
|||
url: `${apiurl}`, |
|||
dataType: 'json', |
|||
headers: headerParam, |
|||
success: function(res) { |
|||
validation = res.Data['CHI_Authorization']; |
|||
console.log("validation:",validation); |
|||
window.parent.postMessage(validation,'http://localhost:3000'); |
|||
// window.parent.postMessage(validation,'https://masada.com.tw'); |
|||
} |
|||
}; |
|||
jQuery.ajax(obj); |
|||
} |
|||
</script> |
@ -1,71 +1,71 @@ |
|||
<?php |
|||
//外購組裝單 (組裝申請單) |
|||
include "T8_Authorization.php"; |
|||
?> |
|||
<script> |
|||
get_Auth(); |
|||
window.addEventListener('message', function(event) { |
|||
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { |
|||
var validation = event.data; |
|||
console.log(validation); |
|||
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData'; |
|||
headerParam = { |
|||
CHI_Authorization: `${validation}`, |
|||
}; |
|||
var body = [{ |
|||
"name":"stkAssyMast", |
|||
"rows":[ |
|||
{ |
|||
"BillNo":"TEST02", |
|||
"OrgId":"1000", |
|||
"TypeId":"CA", |
|||
"MaterialId":"3MH00302", |
|||
"PersonId":"M0122", |
|||
"CompId":"1001", |
|||
"DeptId":"220", |
|||
"SQuantity":1, |
|||
"SUnitId":"SET", |
|||
"CurrentState":2, |
|||
"CreatorId":"M0122" |
|||
} |
|||
] |
|||
},{ |
|||
"name":"stkAssySubMatInfo", |
|||
"rows":[ |
|||
{ |
|||
"BillNo":"TEST02", |
|||
"MaterialId":"3MH00302P", |
|||
"ComponentBaseQty":1, |
|||
"UnitQty":1, |
|||
"SUnitId":"SET", |
|||
"MarkerNo":"3MH00302", |
|||
"CU_MaterialId":"3MH00302" |
|||
},{ |
|||
"BillNo":"TEST02", |
|||
"MaterialId":"MX00000001", |
|||
"ComponentBaseQty":1, |
|||
"UnitQty":3, |
|||
"SUnitId":"PCS", |
|||
"MarkerNo":"3MH00302", |
|||
"CU_MaterialId":"3MH00302" |
|||
} |
|||
] |
|||
}]; |
|||
var json = JSON.stringify(body); |
|||
obj = { |
|||
type:'POST', |
|||
url:`${apiurl}`, |
|||
headers:headerParam, |
|||
data: json, |
|||
dataType:"json", |
|||
success: function(res){ |
|||
console.log(res.Status); |
|||
console.log(res.ErrorMsg); |
|||
console.log(res.Data); |
|||
} |
|||
}; |
|||
jQuery.ajax(obj); |
|||
|
|||
} |
|||
}) |
|||
<?php |
|||
//外購組裝單 (組裝申請單) |
|||
include "T8_Authorization.php"; |
|||
?> |
|||
<script> |
|||
get_Auth(); |
|||
window.addEventListener('message', function(event) { |
|||
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { |
|||
var validation = event.data; |
|||
console.log(validation); |
|||
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData'; |
|||
headerParam = { |
|||
CHI_Authorization: `${validation}`, |
|||
}; |
|||
var body = [{ |
|||
"name":"stkAssyMast", |
|||
"rows":[ |
|||
{ |
|||
"BillNo":"TEST02", |
|||
"OrgId":"1000", |
|||
"TypeId":"CA", |
|||
"MaterialId":"3MH00302", |
|||
"PersonId":"M0122", |
|||
"CompId":"1001", |
|||
"DeptId":"220", |
|||
"SQuantity":1, |
|||
"SUnitId":"SET", |
|||
"CurrentState":2, |
|||
"CreatorId":"M0122" |
|||
} |
|||
] |
|||
},{ |
|||
"name":"stkAssySubMatInfo", |
|||
"rows":[ |
|||
{ |
|||
"BillNo":"TEST02", |
|||
"MaterialId":"3MH00302P", |
|||
"ComponentBaseQty":1, |
|||
"UnitQty":1, |
|||
"SUnitId":"SET", |
|||
"MarkerNo":"3MH00302", |
|||
"CU_MaterialId":"3MH00302" |
|||
},{ |
|||
"BillNo":"TEST02", |
|||
"MaterialId":"MX00000001", |
|||
"ComponentBaseQty":1, |
|||
"UnitQty":3, |
|||
"SUnitId":"PCS", |
|||
"MarkerNo":"3MH00302", |
|||
"CU_MaterialId":"3MH00302" |
|||
} |
|||
] |
|||
}]; |
|||
var json = JSON.stringify(body); |
|||
obj = { |
|||
type:'POST', |
|||
url:`${apiurl}`, |
|||
headers:headerParam, |
|||
data: json, |
|||
dataType:"json", |
|||
success: function(res){ |
|||
console.log(res.Status); |
|||
console.log(res.ErrorMsg); |
|||
console.log(res.Data); |
|||
} |
|||
}; |
|||
jQuery.ajax(obj); |
|||
|
|||
} |
|||
}) |
|||
</script> |
@ -1,23 +1,23 @@ |
|||
<?php |
|||
include "./header.php"; |
|||
//假設供應商代碼為P |
|||
$BizPartnerId = "P"; |
|||
$sql_purBillOrder = " |
|||
SELECT * FROM purBillOrderMaster WHERE BizPartnerId = '$BizPartnerId' AND CurrentState = 2"; |
|||
$purMaster = $conn->query($sql_purBillOrder); |
|||
//每筆採購單資料 |
|||
foreach($purMaster as $master){ |
|||
//print_r($master); |
|||
$BillNo = $master['BillNo']; |
|||
|
|||
//每筆採購單明細資料 |
|||
$sql_purDetail = " |
|||
SELECT * FROM purBillOrderDetail WHERE BillNo = '$BillNo'"; |
|||
$purDetail = $conn->query($sql_purDetail); |
|||
foreach($purDetail as $detail){ |
|||
print_r($detail); |
|||
} |
|||
echo "<br>----------------------<br>"; |
|||
|
|||
} |
|||
|
|||
<?php |
|||
include "./header.php"; |
|||
//假設供應商代碼為P |
|||
$BizPartnerId = "P"; |
|||
$sql_purBillOrder = " |
|||
SELECT * FROM purBillOrderMaster WHERE BizPartnerId = '$BizPartnerId' AND CurrentState = 2"; |
|||
$purMaster = $conn->query($sql_purBillOrder); |
|||
//每筆採購單資料 |
|||
foreach($purMaster as $master){ |
|||
//print_r($master); |
|||
$BillNo = $master['BillNo']; |
|||
|
|||
//每筆採購單明細資料 |
|||
$sql_purDetail = " |
|||
SELECT * FROM purBillOrderDetail WHERE BillNo = '$BillNo'"; |
|||
$purDetail = $conn->query($sql_purDetail); |
|||
foreach($purDetail as $detail){ |
|||
print_r($detail); |
|||
} |
|||
echo "<br>----------------------<br>"; |
|||
|
|||
} |
|||
|
|||
|
@ -1,45 +1,45 @@ |
|||
<?php |
|||
include "./header.php"; |
|||
date_default_timezone_set('Asia/Taipei'); |
|||
|
|||
//表頭 |
|||
$BillNo ="TEST01"; |
|||
$BillDate = 20231204; |
|||
$PersonId = "M0122"; |
|||
$DeptId = "220"; |
|||
// $ProjectId = "3MH00545"; |
|||
$CreateTime = Date("YmdHis"); |
|||
$CurrentState = 2; |
|||
|
|||
//表身 |
|||
$ItemType = 0; |
|||
$MaterialId = "MX00011078"; |
|||
$SUnitId = "PCS"; |
|||
$DemandSQty = 5; //核准數量 |
|||
$RequestSQty = 5; //請購數量 |
|||
$RequireDate=20231205; |
|||
$CurrId="TWD"; |
|||
$UnTransQty = 5; //未轉採購基本數量 |
|||
$TransQty = 0; //已轉採購基本數量 |
|||
$SupplyQty = 5; //供給數量 |
|||
$ProjectId="3MH00545"; //合約號 |
|||
$SupplyId= "P"; //供應商 |
|||
$UnTransOtherSQty = 5; |
|||
$AllowTransOtherSQty = 5; |
|||
$CU_MaterialId="3MH00352"; //作番號 、預留標示號 |
|||
|
|||
$sql = "INSERT INTO purRequestOrder(BillNo, BillDate, PersonId, DeptId, CreateTime, CurrentState, |
|||
TypeId, DemandOrgId, FOrgId,CreatorId, CompId) VALUES ('$BillNo',$BillDate,'$PersonId','$DeptId',$CreateTime,$CurrentState, |
|||
'PR','1000','1000','$user_id','1001')"; |
|||
|
|||
$sql_sub = "INSERT INTO purApplyOrderDetail(BillNo,RowCode, RowNo, ItemType, MaterialId, SUnitId, |
|||
DemandSQty, DemandQty, RequestSQty,RequestQty, RequireDate, IsPriceWithTax, CurrId, |
|||
PurOrgId, BpOrgId, SupplyId, UnTransQty, TransQty, SupplyQty, ProjectId, PlanRangeId, |
|||
UnTransOtherSQty, AllowTransOtherSQty,P_A_DemandOrgId, PurCompId, CU_MaterialId, MarkerNo |
|||
) VALUES ('$BillNo',1,1,$ItemType,'$MaterialId','$SUnitId', |
|||
$DemandSQty, $DemandSQty, $RequestSQty, $RequestSQty, $RequireDate, 1, '$CurrId', |
|||
'1000', '1000', '$SupplyId', $UnTransQty, $TransQty, $SupplyQty, '$ProjectId', '1000', |
|||
$UnTransOtherSQty, $AllowTransOtherSQty,'1000','1001','$CU_MaterialId','$CU_MaterialId')"; |
|||
|
|||
$conn ->query($sql); |
|||
<?php |
|||
include "./header.php"; |
|||
date_default_timezone_set('Asia/Taipei'); |
|||
|
|||
//表頭 |
|||
$BillNo ="TEST01"; |
|||
$BillDate = 20231204; |
|||
$PersonId = "M0122"; |
|||
$DeptId = "220"; |
|||
// $ProjectId = "3MH00545"; |
|||
$CreateTime = Date("YmdHis"); |
|||
$CurrentState = 2; |
|||
|
|||
//表身 |
|||
$ItemType = 0; |
|||
$MaterialId = "MX00011078"; |
|||
$SUnitId = "PCS"; |
|||
$DemandSQty = 5; //核准數量 |
|||
$RequestSQty = 5; //請購數量 |
|||
$RequireDate=20231205; |
|||
$CurrId="TWD"; |
|||
$UnTransQty = 5; //未轉採購基本數量 |
|||
$TransQty = 0; //已轉採購基本數量 |
|||
$SupplyQty = 5; //供給數量 |
|||
$ProjectId="3MH00545"; //合約號 |
|||
$SupplyId= "P"; //供應商 |
|||
$UnTransOtherSQty = 5; |
|||
$AllowTransOtherSQty = 5; |
|||
$CU_MaterialId="3MH00352"; //作番號 、預留標示號 |
|||
|
|||
$sql = "INSERT INTO purRequestOrder(BillNo, BillDate, PersonId, DeptId, CreateTime, CurrentState, |
|||
TypeId, DemandOrgId, FOrgId,CreatorId, CompId) VALUES ('$BillNo',$BillDate,'$PersonId','$DeptId',$CreateTime,$CurrentState, |
|||
'PR','1000','1000','$user_id','1001')"; |
|||
|
|||
$sql_sub = "INSERT INTO purApplyOrderDetail(BillNo,RowCode, RowNo, ItemType, MaterialId, SUnitId, |
|||
DemandSQty, DemandQty, RequestSQty,RequestQty, RequireDate, IsPriceWithTax, CurrId, |
|||
PurOrgId, BpOrgId, SupplyId, UnTransQty, TransQty, SupplyQty, ProjectId, PlanRangeId, |
|||
UnTransOtherSQty, AllowTransOtherSQty,P_A_DemandOrgId, PurCompId, CU_MaterialId, MarkerNo |
|||
) VALUES ('$BillNo',1,1,$ItemType,'$MaterialId','$SUnitId', |
|||
$DemandSQty, $DemandSQty, $RequestSQty, $RequestSQty, $RequireDate, 1, '$CurrId', |
|||
'1000', '1000', '$SupplyId', $UnTransQty, $TransQty, $SupplyQty, '$ProjectId', '1000', |
|||
$UnTransOtherSQty, $AllowTransOtherSQty,'1000','1001','$CU_MaterialId','$CU_MaterialId')"; |
|||
|
|||
$conn ->query($sql); |
|||
$conn ->query($sql_sub); |
@ -1,180 +1,180 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 部門職別 |
|||
$db_query = "select department_id, name, role_id, role from department order by department_id"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$depart_arr[$row["department_id"]] = $row["name"]; |
|||
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
?> |
|||
<script> |
|||
$(function(){ |
|||
var jroleStr = '<?php echo json_encode($role_arr); ?>'; |
|||
var jroleArr = JSON.parse(jroleStr); |
|||
var optStr = ""; |
|||
$("select[name=department_id]").change(function(){ |
|||
if ($(this).val() != "") { |
|||
optStr = ""; |
|||
for (var i in jroleArr[$(this).val()]) { |
|||
if ('undefined' !== jroleArr[$(this).val()][i]) { |
|||
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; |
|||
} |
|||
} |
|||
$("select[name=role_id]").html(optStr); |
|||
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); |
|||
}) |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "account-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> |
|||
|
|||
|
|||
<div> |
|||
<label for="accounttype">帳號類別(必選)</label> |
|||
<select name="accounttype" id="accounttype" required> |
|||
<option selected="selected" disabled="disabled" style="display: none" value=""></option> |
|||
<option value="A">客戶(A)</option> |
|||
<option value="B">保養人員(B)</option> |
|||
<!-- |
|||
<option value="C">檢查人員</option> |
|||
<option value="D">契約人員</option> |
|||
--> |
|||
<option value="E">管理人員(E)</option> |
|||
<option value="M">永佳捷員工(M)</option> |
|||
<option value="X">未分類(X)</option> |
|||
</select> |
|||
<!-- <input type="text" name="accounttype" id="accounttype" placeholder="帳號類別..." required> --> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="accountid">請輸入員工、個人客戶ID或公司客戶統編(必填)</label> |
|||
<input type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編...(必填)" maxlength="10" required> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="pwd">密碼(必填)</label> |
|||
<input type="text" name="pwd" id="pwd" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="name">姓名(必填)</label> |
|||
<input type="text" name="name" id="name" required> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" maxlength="16"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="email">電子郵箱</label> |
|||
<input type="text" name="email" id="email"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="lineid">Line ID</label> |
|||
<input type="text" name="lineid" id="lineid"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="wechatid">微信ID</label> |
|||
<input type="text" name="wechatid" id="wechatid"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label> |
|||
<input type="text" name="phone_call_help" id="phone_call_help" maxlength="16"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="chat_for_help">線上文字客服</label> |
|||
<input type="text" name="chat_for_help" id="chat_for_help"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="remote_help">遠端視頻帳號</label> |
|||
<input type="text" name="remote_help" id="remote_help"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="repairerid">服務與支持人員工號(客戶必填)</label> |
|||
<input type="text" name="repairerid" id="repairerid" maxlength="10"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="manager">直屬主管工號(員工必填)</label> |
|||
<input type="text" name="manager" id="manager" maxlength="10"> |
|||
|
|||
</div> |
|||
<div> |
|||
<label for="department_id">部門(員工必填)</label> |
|||
<select name="department_id"> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($depart_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="role_id">職別(員工必填)</label> |
|||
<select name="role_id"> |
|||
<option value="">請選擇</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
<?php if ($user_auth&2) { ?> |
|||
<div> |
|||
<button type="submit" name="submit">確定</button> |
|||
</div> |
|||
<?php } ?> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php include "footer.php"; ?> |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 部門職別 |
|||
$db_query = "select department_id, name, role_id, role from department order by department_id"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$depart_arr[$row["department_id"]] = $row["name"]; |
|||
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
?> |
|||
<script> |
|||
$(function(){ |
|||
var jroleStr = '<?php echo json_encode($role_arr); ?>'; |
|||
var jroleArr = JSON.parse(jroleStr); |
|||
var optStr = ""; |
|||
$("select[name=department_id]").change(function(){ |
|||
if ($(this).val() != "") { |
|||
optStr = ""; |
|||
for (var i in jroleArr[$(this).val()]) { |
|||
if ('undefined' !== jroleArr[$(this).val()][i]) { |
|||
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; |
|||
} |
|||
} |
|||
$("select[name=role_id]").html(optStr); |
|||
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); |
|||
}) |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "account-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> |
|||
|
|||
|
|||
<div> |
|||
<label for="accounttype">帳號類別(必選)</label> |
|||
<select name="accounttype" id="accounttype" required> |
|||
<option selected="selected" disabled="disabled" style="display: none" value=""></option> |
|||
<option value="A">客戶(A)</option> |
|||
<option value="B">保養人員(B)</option> |
|||
<!-- |
|||
<option value="C">檢查人員</option> |
|||
<option value="D">契約人員</option> |
|||
--> |
|||
<option value="E">管理人員(E)</option> |
|||
<option value="M">永佳捷員工(M)</option> |
|||
<option value="X">未分類(X)</option> |
|||
</select> |
|||
<!-- <input type="text" name="accounttype" id="accounttype" placeholder="帳號類別..." required> --> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="accountid">請輸入員工、個人客戶ID或公司客戶統編(必填)</label> |
|||
<input type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編...(必填)" maxlength="10" required> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="pwd">密碼(必填)</label> |
|||
<input type="text" name="pwd" id="pwd" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="name">姓名(必填)</label> |
|||
<input type="text" name="name" id="name" required> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" maxlength="16"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="email">電子郵箱</label> |
|||
<input type="text" name="email" id="email"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="lineid">Line ID</label> |
|||
<input type="text" name="lineid" id="lineid"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="wechatid">微信ID</label> |
|||
<input type="text" name="wechatid" id="wechatid"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label> |
|||
<input type="text" name="phone_call_help" id="phone_call_help" maxlength="16"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="chat_for_help">線上文字客服</label> |
|||
<input type="text" name="chat_for_help" id="chat_for_help"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="remote_help">遠端視頻帳號</label> |
|||
<input type="text" name="remote_help" id="remote_help"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="repairerid">服務與支持人員工號(客戶必填)</label> |
|||
<input type="text" name="repairerid" id="repairerid" maxlength="10"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="manager">直屬主管工號(員工必填)</label> |
|||
<input type="text" name="manager" id="manager" maxlength="10"> |
|||
|
|||
</div> |
|||
<div> |
|||
<label for="department_id">部門(員工必填)</label> |
|||
<select name="department_id"> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($depart_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="role_id">職別(員工必填)</label> |
|||
<select name="role_id"> |
|||
<option value="">請選擇</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
<?php if ($user_auth&2) { ?> |
|||
<div> |
|||
<button type="submit" name="submit">確定</button> |
|||
</div> |
|||
<?php } ?> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php include "footer.php"; ?> |
|||
|
@ -1,19 +1,19 @@ |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$sql = "select accountid from account where id = '$id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_assoc($res)) { |
|||
$db_query = "delete from account where id = '$id'"; |
|||
mysqli_query($link, $db_query); |
|||
|
|||
$db_query = "delete from account_auth where accountid = '".$row["accountid"]."'"; |
|||
mysqli_query($link, $db_query); |
|||
} |
|||
mysqli_free_result($res); |
|||
header("Refresh:0; url=account-index.php?function_name=account&".$token_link); |
|||
ob_end_flush(); |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$sql = "select accountid from account where id = '$id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_assoc($res)) { |
|||
$db_query = "delete from account where id = '$id'"; |
|||
mysqli_query($link, $db_query); |
|||
|
|||
$db_query = "delete from account_auth where accountid = '".$row["accountid"]."'"; |
|||
mysqli_query($link, $db_query); |
|||
} |
|||
mysqli_free_result($res); |
|||
header("Refresh:0; url=account-index.php?function_name=account&".$token_link); |
|||
ob_end_flush(); |
|||
?> |
@ -1,173 +1,173 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
// 部門職別 |
|||
$db_query = "select department_id, name, role_id, role from department order by department_id"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$depart_arr[$row["department_id"]] = $row["name"]; |
|||
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM account WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
/* |
|||
include "inc/record_update.php"; |
|||
|
|||
try { |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM expert WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
}catch (Exception $e) { |
|||
echo 'Caught exception: ', $e->getMessage(), "\n"; |
|||
} |
|||
*/ |
|||
foreach($data as $data) : |
|||
?> |
|||
<script> |
|||
$(function(){ |
|||
var jroleStr = '<?php echo json_encode($role_arr); ?>'; |
|||
var jroleArr = JSON.parse(jroleStr); |
|||
var optStr = ""; |
|||
$("select[name=department_id]").change(function(){ |
|||
if ($(this).val() != "") { |
|||
optStr = ""; |
|||
for (var i in jroleArr[$(this).val()]) { |
|||
if ('undefined' !== jroleArr[$(this).val()][i]) { |
|||
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; |
|||
} |
|||
} |
|||
$("select[name=role_id]").html(optStr); |
|||
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); |
|||
}) |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="account-record-update.php"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="accounttype">帳號類別</label> |
|||
<input type="text" name="accounttype" id="accounttype" value="<?php echo $data['accounttype']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="accountid">帳號</label> |
|||
<input type="text" name="accountid" id="accountid" value="<?php echo $data['accountid']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="pwd">密碼(必填)</label> |
|||
<input type="text" name="pwd" id="pwd" value="<?php echo $data['pwd']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="name">姓名(必填)</label> |
|||
<input type="text" name="name" id="name" value="<?php echo $data['name']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="email">電子郵箱</label> |
|||
<input type="text" name="email" id="email" value="<?php echo $data['email']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="lineid">Line ID</label> |
|||
<input type="text" name="lineid" id="lineid" value="<?php echo $data['lineid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="wechatid">微信ID</label> |
|||
<input type="text" name="wechatid" id="wechatid" value="<?php echo $data['wechatid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label> |
|||
<input type="text" name="phone_call_help" id="phone_call_help" value="<?php echo $data['phone_call_help']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="chat_for_help">線上文字客服</label> |
|||
<input type="text" name="chat_for_help" id="chat_for_help" value="<?php echo $data['chat_for_help']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="remote_help">遠端視頻帳號</label> |
|||
<input type="text" name="remote_help" id="remote_help" value="<?php echo $data['remote_help']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="repairerid">服務與支持人員工號(客戶必填)</label> |
|||
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="manager">直屬主管工號(員工必填)</label> |
|||
<input type="text" name="manager" id="manager" value="<?php echo $data['manager']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="department_id">部門(員工必填)</label> |
|||
<select name="department_id"> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($depart_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["department_id"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="role_id">職別(員工必填)</label> |
|||
<select name="role_id"> |
|||
<?php |
|||
foreach ($role_arr[$data["department_id"]] as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["role_id"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
|
|||
|
|||
<div> |
|||
<button type="submit" name="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
// 部門職別 |
|||
$db_query = "select department_id, name, role_id, role from department order by department_id"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$depart_arr[$row["department_id"]] = $row["name"]; |
|||
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM account WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
/* |
|||
include "inc/record_update.php"; |
|||
|
|||
try { |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM expert WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
}catch (Exception $e) { |
|||
echo 'Caught exception: ', $e->getMessage(), "\n"; |
|||
} |
|||
*/ |
|||
foreach($data as $data) : |
|||
?> |
|||
<script> |
|||
$(function(){ |
|||
var jroleStr = '<?php echo json_encode($role_arr); ?>'; |
|||
var jroleArr = JSON.parse(jroleStr); |
|||
var optStr = ""; |
|||
$("select[name=department_id]").change(function(){ |
|||
if ($(this).val() != "") { |
|||
optStr = ""; |
|||
for (var i in jroleArr[$(this).val()]) { |
|||
if ('undefined' !== jroleArr[$(this).val()][i]) { |
|||
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; |
|||
} |
|||
} |
|||
$("select[name=role_id]").html(optStr); |
|||
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); |
|||
}) |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="account-record-update.php"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="accounttype">帳號類別</label> |
|||
<input type="text" name="accounttype" id="accounttype" value="<?php echo $data['accounttype']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="accountid">帳號</label> |
|||
<input type="text" name="accountid" id="accountid" value="<?php echo $data['accountid']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="pwd">密碼(必填)</label> |
|||
<input type="text" name="pwd" id="pwd" value="<?php echo $data['pwd']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="name">姓名(必填)</label> |
|||
<input type="text" name="name" id="name" value="<?php echo $data['name']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="email">電子郵箱</label> |
|||
<input type="text" name="email" id="email" value="<?php echo $data['email']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="lineid">Line ID</label> |
|||
<input type="text" name="lineid" id="lineid" value="<?php echo $data['lineid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="wechatid">微信ID</label> |
|||
<input type="text" name="wechatid" id="wechatid" value="<?php echo $data['wechatid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label> |
|||
<input type="text" name="phone_call_help" id="phone_call_help" value="<?php echo $data['phone_call_help']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="chat_for_help">線上文字客服</label> |
|||
<input type="text" name="chat_for_help" id="chat_for_help" value="<?php echo $data['chat_for_help']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="remote_help">遠端視頻帳號</label> |
|||
<input type="text" name="remote_help" id="remote_help" value="<?php echo $data['remote_help']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="repairerid">服務與支持人員工號(客戶必填)</label> |
|||
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="manager">直屬主管工號(員工必填)</label> |
|||
<input type="text" name="manager" id="manager" value="<?php echo $data['manager']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="department_id">部門(員工必填)</label> |
|||
<select name="department_id"> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($depart_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["department_id"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="role_id">職別(員工必填)</label> |
|||
<select name="role_id"> |
|||
<?php |
|||
foreach ($role_arr[$data["department_id"]] as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["role_id"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
|
|||
|
|||
<div> |
|||
<button type="submit" name="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
|
@ -1,85 +1,85 @@ |
|||
<?php |
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
include "database.php"; |
|||
include 'class/Cmail.php'; |
|||
|
|||
header('Content-Type: application/json'); |
|||
$method = $_POST['method']; |
|||
$id = empty($_POST['id']) ? '' : $_POST['id']; |
|||
$sql = " |
|||
SELECT * FROM account WHERE id = '$id' |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_assoc($result); |
|||
|
|||
$cmail = new Cmail(); |
|||
$subject = "永佳捷新人文件"; |
|||
$em_body = ""; |
|||
$file_name = str_replace('/', '\\', __DIR__ . "/public/file/永佳捷雲端空間使用設定方式.pdf"); |
|||
$file[0] = [$file_name, "永佳捷雲端空間使用設定方式.pdf"]; |
|||
$sendlist[0] = [$data['name'], $data['email']]; |
|||
|
|||
// 保養人員 |
|||
if (in_array($data['accounttype'], ['B'])) { |
|||
$em_body = " |
|||
您好,我是桃園資訊處的子苹, |
|||
以下是給新報到同仁的基本資訊,您再參考: |
|||
|
|||
員編:" . $data['accountid'] . " |
|||
公司手機門號:請和資訊人員聯絡 |
|||
你的email:" . $data['email'] . " |
|||
web收信:http://webmail.masada.com.tw:8081 |
|||
帳號:" . explode('@', $data['email'])[0] . " |
|||
密碼:" . $data['accountid'] . " |
|||
登入後密碼可再自行更改 |
|||
除了這個web方式收信,你也可以點擊手機裡的gmail收發信 |
|||
|
|||
桌面有安裝「維保APP系統」 |
|||
登入帳號 " . $data['accountid'] . " |
|||
密碼 " . explode('@', $data['email'])[0] . " |
|||
GPS定位APP的登入帳密跟上面的一樣 |
|||
|
|||
http://oa.masada.com.tw |
|||
這是公司內部系統 |
|||
登入帳號:" . $data['accountid'] . " |
|||
登入密碼:" . explode('@', $data['email'])[0] . " |
|||
|
|||
https://cloud.masada.com.tw:1846/ |
|||
這是公司雲端系統 |
|||
預設帳密在信箱 請記得去更改密碼 |
|||
|
|||
以上,有問題請隨時與資訊聯繫,謝謝! |
|||
"; |
|||
} |
|||
// 員工 |
|||
if (in_array($data['accounttype'], ['M', 'E'])) { |
|||
$em_body = " |
|||
您好, |
|||
以下是給新報到同仁的基本資訊,您再參考: |
|||
|
|||
員編:" . $data['accountid'] . " |
|||
你的email:" . $data['email'] . " |
|||
web收信:http://webmail.masada.com.tw:8081 |
|||
帳號:" . explode('@', $data['email'])[0] . " |
|||
密碼:" . $data['accountid'] . " |
|||
登入後密碼可再自行更改 |
|||
除了這個web方式收信,你也可以用電腦裡的outlook收發信 |
|||
|
|||
http://oa.masada.com.tw |
|||
這是公司內部系統 |
|||
登入帳號:" . $data['accountid'] . " |
|||
登入密碼:" . explode('@', $data['email'])[0] . " |
|||
|
|||
https://cloud.masada.com.tw:1846/ |
|||
這是公司雲端系統 |
|||
預設帳密在信箱 請記得去更改密碼 |
|||
|
|||
|
|||
以上,有問題請隨時與資訊聯繫,謝謝! |
|||
|
|||
"; |
|||
} |
|||
|
|||
$cmail->sendx($subject, $em_body, $sendlist, "永佳捷科技", "", $file); |
|||
echo json_encode([1, "信件發送成功"]); |
|||
} |
|||
<?php |
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
include "database.php"; |
|||
include 'class/Cmail.php'; |
|||
|
|||
header('Content-Type: application/json'); |
|||
$method = $_POST['method']; |
|||
$id = empty($_POST['id']) ? '' : $_POST['id']; |
|||
$sql = " |
|||
SELECT * FROM account WHERE id = '$id' |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_assoc($result); |
|||
|
|||
$cmail = new Cmail(); |
|||
$subject = "永佳捷新人文件"; |
|||
$em_body = ""; |
|||
$file_name = str_replace('/', '\\', __DIR__ . "/public/file/永佳捷雲端空間使用設定方式.pdf"); |
|||
$file[0] = [$file_name, "永佳捷雲端空間使用設定方式.pdf"]; |
|||
$sendlist[0] = [$data['name'], $data['email']]; |
|||
|
|||
// 保養人員 |
|||
if (in_array($data['accounttype'], ['B'])) { |
|||
$em_body = " |
|||
您好,我是桃園資訊處的子苹, |
|||
以下是給新報到同仁的基本資訊,您再參考: |
|||
|
|||
員編:" . $data['accountid'] . " |
|||
公司手機門號:請和資訊人員聯絡 |
|||
你的email:" . $data['email'] . " |
|||
web收信:http://webmail.masada.com.tw:8081 |
|||
帳號:" . explode('@', $data['email'])[0] . " |
|||
密碼:" . $data['accountid'] . " |
|||
登入後密碼可再自行更改 |
|||
除了這個web方式收信,你也可以點擊手機裡的gmail收發信 |
|||
|
|||
桌面有安裝「維保APP系統」 |
|||
登入帳號 " . $data['accountid'] . " |
|||
密碼 " . explode('@', $data['email'])[0] . " |
|||
GPS定位APP的登入帳密跟上面的一樣 |
|||
|
|||
http://oa.masada.com.tw |
|||
這是公司內部系統 |
|||
登入帳號:" . $data['accountid'] . " |
|||
登入密碼:" . explode('@', $data['email'])[0] . " |
|||
|
|||
https://cloud.masada.com.tw:1846/ |
|||
這是公司雲端系統 |
|||
預設帳密在信箱 請記得去更改密碼 |
|||
|
|||
以上,有問題請隨時與資訊聯繫,謝謝! |
|||
"; |
|||
} |
|||
// 員工 |
|||
if (in_array($data['accounttype'], ['M', 'E'])) { |
|||
$em_body = " |
|||
您好, |
|||
以下是給新報到同仁的基本資訊,您再參考: |
|||
|
|||
員編:" . $data['accountid'] . " |
|||
你的email:" . $data['email'] . " |
|||
web收信:http://webmail.masada.com.tw:8081 |
|||
帳號:" . explode('@', $data['email'])[0] . " |
|||
密碼:" . $data['accountid'] . " |
|||
登入後密碼可再自行更改 |
|||
除了這個web方式收信,你也可以用電腦裡的outlook收發信 |
|||
|
|||
http://oa.masada.com.tw |
|||
這是公司內部系統 |
|||
登入帳號:" . $data['accountid'] . " |
|||
登入密碼:" . explode('@', $data['email'])[0] . " |
|||
|
|||
https://cloud.masada.com.tw:1846/ |
|||
這是公司雲端系統 |
|||
預設帳密在信箱 請記得去更改密碼 |
|||
|
|||
|
|||
以上,有問題請隨時與資訊聯繫,謝謝! |
|||
|
|||
"; |
|||
} |
|||
|
|||
$cmail->sendx($subject, $em_body, $sendlist, "永佳捷科技", "", $file); |
|||
echo json_encode([1, "信件發送成功"]); |
|||
} |
|||
|
@ -1,198 +1,198 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$accounttype_arr = ["A" => "客戶", "B" => "保養人員", "C" => "檢查人員", "D" => "契約人員", "M" => "員工", "E" => "管理員(IT)", "X" => "未分類"]; #A=客戶 B=保養人員 C=檢查人員 D=契約人員 E=管理人員 M=永佳捷員工 X=未分類 |
|||
|
|||
// 工務總處、王凱欣可瀏覽全部資料 |
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = ""; |
|||
$sql = "SELECT * FROM account $sql_cmd ORDER BY id"; |
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link, $sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<p> |
|||
<a href="account-create.php?function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
<?php |
|||
} |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:account-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<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>Line ID</th> |
|||
<th>微信id</th> |
|||
<th>遠端協助</th> |
|||
<th>維修ID</th> |
|||
<th>直屬主管</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<th>修改</th> |
|||
<th>新人資料</th> |
|||
<!--<th>刪除</th>--> |
|||
<?php } ?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php foreach ($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td data-toggle="tooltip" data-placement="right" title=" |
|||
<?php |
|||
if (isset($accounttype_arr[$data['accounttype']])) { |
|||
echo $accounttype_arr[$data['accounttype']]; |
|||
} else { |
|||
echo $data['accounttype']; |
|||
} |
|||
?> |
|||
"> |
|||
<?php |
|||
if (isset($accounttype_arr[$data['accounttype']])) { |
|||
echo $accounttype_arr[$data['accounttype']]; |
|||
} else { |
|||
echo $data['accounttype']; |
|||
} |
|||
?></td> |
|||
<td><?php echo $data['accountid']; ?></td> |
|||
<!--<td><?php echo $data['pwd']; ?></td>--> |
|||
<td><?php echo $data['name']; ?></td> |
|||
<td><?php echo $data['tel']; ?></td> |
|||
<td><?php echo $data['address']; ?></td> |
|||
<td><?php echo $data['email']; ?></td> |
|||
<td><?php echo $data['lineid']; ?></td> |
|||
<td><?php echo $data['wechatid']; ?></td> |
|||
<td><a href="<?php echo $data['remote_help']; ?>">連結<a /></td> |
|||
<td><?php echo $data['repairerid']; ?></td> |
|||
<td><?php echo $data['manager']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<td> |
|||
<p> |
|||
<a href="account-edit.php?id=<?php echo $data['id']; ?>&function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<!--<td> |
|||
<p> |
|||
<a href="account-delete.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td>--> |
|||
<?php } ?> |
|||
<td> |
|||
<button type="button" class="btn" onclick="sendJuniorStaffDoc(<?php echo $data['id']; ?>)">寄送</button> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<script> |
|||
function sendJuniorStaffDoc(id) { |
|||
$.ajax({ |
|||
url: window.location.origin + '/wms/account-index-submit.php', |
|||
type: 'POST', |
|||
data: { |
|||
'method': 'sendJuniorStaffDoc', |
|||
'id': id |
|||
}, |
|||
dataType: 'json', |
|||
success: function(response) { |
|||
alert("寄送成功!"); |
|||
}, |
|||
error: function(xhr, status, error) { |
|||
alert("寄送失敗!"); |
|||
} |
|||
}); |
|||
|
|||
} |
|||
</script> |
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
|
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$accounttype_arr = ["A" => "客戶", "B" => "保養人員", "C" => "檢查人員", "D" => "契約人員", "M" => "員工", "E" => "管理員(IT)", "X" => "未分類"]; #A=客戶 B=保養人員 C=檢查人員 D=契約人員 E=管理人員 M=永佳捷員工 X=未分類 |
|||
|
|||
// 工務總處、王凱欣可瀏覽全部資料 |
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = ""; |
|||
$sql = "SELECT * FROM account $sql_cmd ORDER BY id"; |
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link, $sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<p> |
|||
<a href="account-create.php?function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
<?php |
|||
} |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:account-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<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>Line ID</th> |
|||
<th>微信id</th> |
|||
<th>遠端協助</th> |
|||
<th>維修ID</th> |
|||
<th>直屬主管</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<th>修改</th> |
|||
<th>新人資料</th> |
|||
<!--<th>刪除</th>--> |
|||
<?php } ?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php foreach ($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td data-toggle="tooltip" data-placement="right" title=" |
|||
<?php |
|||
if (isset($accounttype_arr[$data['accounttype']])) { |
|||
echo $accounttype_arr[$data['accounttype']]; |
|||
} else { |
|||
echo $data['accounttype']; |
|||
} |
|||
?> |
|||
"> |
|||
<?php |
|||
if (isset($accounttype_arr[$data['accounttype']])) { |
|||
echo $accounttype_arr[$data['accounttype']]; |
|||
} else { |
|||
echo $data['accounttype']; |
|||
} |
|||
?></td> |
|||
<td><?php echo $data['accountid']; ?></td> |
|||
<!--<td><?php echo $data['pwd']; ?></td>--> |
|||
<td><?php echo $data['name']; ?></td> |
|||
<td><?php echo $data['tel']; ?></td> |
|||
<td><?php echo $data['address']; ?></td> |
|||
<td><?php echo $data['email']; ?></td> |
|||
<td><?php echo $data['lineid']; ?></td> |
|||
<td><?php echo $data['wechatid']; ?></td> |
|||
<td><a href="<?php echo $data['remote_help']; ?>">連結<a /></td> |
|||
<td><?php echo $data['repairerid']; ?></td> |
|||
<td><?php echo $data['manager']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<td> |
|||
<p> |
|||
<a href="account-edit.php?id=<?php echo $data['id']; ?>&function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<!--<td> |
|||
<p> |
|||
<a href="account-delete.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td>--> |
|||
<?php } ?> |
|||
<td> |
|||
<button type="button" class="btn" onclick="sendJuniorStaffDoc(<?php echo $data['id']; ?>)">寄送</button> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<script> |
|||
function sendJuniorStaffDoc(id) { |
|||
$.ajax({ |
|||
url: window.location.origin + '/wms/account-index-submit.php', |
|||
type: 'POST', |
|||
data: { |
|||
'method': 'sendJuniorStaffDoc', |
|||
'id': id |
|||
}, |
|||
dataType: 'json', |
|||
success: function(response) { |
|||
alert("寄送成功!"); |
|||
}, |
|||
error: function(xhr, status, error) { |
|||
alert("寄送失敗!"); |
|||
} |
|||
}); |
|||
|
|||
} |
|||
</script> |
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
@ -1,245 +1,201 @@ |
|||
<?php |
|||
include "./header.php"; |
|||
$Bill = $_POST['Bill']; |
|||
$Bill = json_decode($Bill, true); |
|||
|
|||
$data = json_encode($Bill); |
|||
?> |
|||
<style> |
|||
th { |
|||
text-align: center; |
|||
} |
|||
|
|||
td { |
|||
text-align: right; |
|||
} |
|||
</style> |
|||
<div style="width: 90%;"> |
|||
|
|||
<div style="padding-left: 2rem; padding-bottom: 1rem;"> |
|||
<a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg"> |
|||
<span class="glyphicon glyphicon-home"></span> |
|||
</a> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="container"> |
|||
<div class="text-center" style="margin-bottom: 20px;"> |
|||
<h3><strong><?= $Bill[5] ?></strong></h3> |
|||
</div> |
|||
<form class="form-horizontal"> |
|||
<div class="form-group"> |
|||
<div class="col-md-3"> |
|||
<label for="BillNo">合約號</label> |
|||
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[10] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="DeptId">部門</label> |
|||
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="Manager">經理</label> |
|||
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="PersonName">營業員</label> |
|||
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[4] ?>" disabled> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="form-group"> |
|||
<div class="col-md-3"> |
|||
<label for="EnterpriseName">抬頭</label> |
|||
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[6] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="TaxNo">統一編號</label> |
|||
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[7] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-6"> |
|||
<label for="ContactAddress">聯絡地址</label> |
|||
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[8] ?>" disabled> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="detail">狀態</label> |
|||
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill['facilities']) ?></textarea> |
|||
</div> |
|||
</form> |
|||
<div style="width: auto; margin-top: 30px;"> |
|||
<table 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> |
|||
<tr> |
|||
<td>合約金額</td> |
|||
<td><?= number_format(round($Bill['sign'][1])) ?></td> |
|||
<td><?= number_format(round($Bill['second'][1])) ?></td> |
|||
<td><?= number_format(round($Bill['arrive'][1])) ?></td> |
|||
<td><?= number_format(round($Bill['install'][1])) ?></td> |
|||
<td><?= number_format(round($Bill['tryrun'][1])) ?></td> |
|||
<td><?= number_format(round($Bill['check'][1])) ?></td> |
|||
<td><?= number_format(round($Bill['delivery'][1])) ?></td> |
|||
<td><?= number_format(round($Bill['final'][1])) ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>目前應收</td> |
|||
<td><?= number_format(round($Bill['sign'][3])) ?></td> |
|||
<td><?= number_format(round($Bill['second'][3])) ?></td> |
|||
<td><?= number_format(round($Bill['arrive'][3])) ?></td> |
|||
<td><?= number_format(round($Bill['install'][3])) ?></td> |
|||
<td><?= number_format(round($Bill['tryrun'][3])) ?></td> |
|||
<td><?= number_format(round($Bill['check'][3])) ?></td> |
|||
<td><?= number_format(round($Bill['delivery'][3])) ?></td> |
|||
<td><?= number_format(round($Bill['final'][3])) ?></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
<div style="width: auto; margin-top: 30px;"> |
|||
<table class="table table-striped table-bordered" style="width:100%;"> |
|||
<thead> |
|||
<tr> |
|||
<th>目前應收</th> |
|||
<th>已開發票金額</th> |
|||
<th>未開發票金額</th> |
|||
<th>已收金額</th> |
|||
<th>未收金額</th> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td><?= number_format(round($Bill['receivable_budget'])) ?></td> |
|||
<td><?= number_format(round($Bill['invoice_budget'])) ?></td> |
|||
<td><?= number_format(round($Bill['receivable_budget'] - $Bill['invoice_budget'])) ?></td> |
|||
<td><?= number_format(round($Bill['received_budget'])) ?></td> |
|||
<td><?= number_format(round($Bill['invoice_budget'] - $Bill['received_budget'])) ?></td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
|
|||
</div> |
|||
</div> |
|||
<?php |
|||
include "./footer.php"; |
|||
|
|||
?> |
|||
<?php |
|||
if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) { |
|||
?> |
|||
<!-- <button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;"> |
|||
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button> --> |
|||
<?php |
|||
} |
|||
?> |
|||
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;"> |
|||
<table 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 if ($Bill['invoice'] != Null) { |
|||
foreach ($Bill['invoice'] as $key => $invoice) { ?> |
|||
<tr> |
|||
<td><?= $key ?></td> |
|||
<td><?= $invoice[0] ?></td> |
|||
|
|||
<td><?php switch ($invoice[2]) { |
|||
case 0: |
|||
echo "藍字"; |
|||
break; |
|||
case 1: |
|||
echo "紅字"; |
|||
break; |
|||
case 2: |
|||
echo "作廢"; |
|||
break; |
|||
} ?></td> |
|||
<td><?= isset($invoice[1])? number_format($invoice[1]):0 ?></td> |
|||
<td><?= isset($invoice[3])? $invoice[3]:' ' ?></td> |
|||
<td><?= isset($invoice[4])? number_format($invoice[4]):0 ?></td> |
|||
<td><?= isset($invoice[5])? number_format($invoice[5]):0 ?></td> |
|||
<!-- <td><?= $received['remark'] ?></td>
|
|||
<td style="text-align: center;"> |
|||
<?php |
|||
switch ($received['status']) { |
|||
case 0: |
|||
echo "<span style='color:blue;'>進行中</span>"; |
|||
break; |
|||
case 1: |
|||
echo "<span style='color:brown;'>催收</span>"; |
|||
break; |
|||
case 2: |
|||
echo "<span style='color:red;'>法務件 (發函)</span>"; |
|||
break; |
|||
case 3: |
|||
echo "<span style='color:red;'>法務件 (訴訟)</span>"; |
|||
break; |
|||
case 4: |
|||
echo "折讓"; |
|||
break; |
|||
case 5: |
|||
echo "壞帳"; |
|||
break; |
|||
case 99: |
|||
echo "完成"; |
|||
break; |
|||
} |
|||
?></td> --> |
|||
|
|||
|
|||
</tr> |
|||
<?php } |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<script> |
|||
function create(type, pay_id) { |
|||
var BillData = <?= $data ?>; |
|||
var form = document.createElement("form"); |
|||
form.method = 'POST'; |
|||
if (type === 'create') { |
|||
form.action = "account-receivable-received-create.php?<?= $token_link ?>"; |
|||
} else { |
|||
form.action = "account-receivable-received-edit.php?pay_id=" + pay_id + "&<?= $token_link ?>"; |
|||
} |
|||
|
|||
var input = document.createElement("input"); |
|||
input.type = "hidden"; |
|||
input.name = "Bill"; |
|||
input.value = JSON.stringify(BillData); |
|||
form.appendChild(input); |
|||
document.body.appendChild(form); |
|||
form.submit(); |
|||
} |
|||
<?php |
|||
include "./header.php"; |
|||
$BillNo = $_GET['BillNo']; |
|||
echo $BillNo; |
|||
//企業名稱 統一編號 聯絡地址 |
|||
// $Bill = $_POST['Bill']; |
|||
// $Bill = json_decode($Bill, true); |
|||
// $sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC"; |
|||
// $pay_received = mysqli_query($link, $sql_received); |
|||
// $had_received = 0; |
|||
// if (mysqli_num_rows($pay_received) == 0) { |
|||
// foreach ($pay_received as $received) { |
|||
// $had_received += $received['received_amount']; |
|||
// } |
|||
// } |
|||
// $unreceived = $Bill[12] - $had_received; |
|||
// $data = json_encode($Bill); |
|||
?> |
|||
<style> |
|||
th { |
|||
text-align: center; |
|||
} |
|||
|
|||
td { |
|||
text-align: right; |
|||
} |
|||
</style> |
|||
<div style="width: 90%;"> |
|||
|
|||
<div style="padding-left: 2rem; padding-bottom: 1rem;"> |
|||
<a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg"> |
|||
<span class="glyphicon glyphicon-home"></span> |
|||
</a> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="container"> |
|||
<div class="text-center" style="margin-bottom: 20px;"> |
|||
<h3><strong><?= $Bill[4] ?></strong></h3> |
|||
</div> |
|||
<form class="form-horizontal"> |
|||
<div class="form-group"> |
|||
<div class="col-md-3"> |
|||
<label for="BillNo">合約號</label> |
|||
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[0] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="DeptId">部門</label> |
|||
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="Manager">經理</label> |
|||
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="PersonName">營業員</label> |
|||
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[3] ?>" disabled> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="form-group"> |
|||
<div class="col-md-3"> |
|||
<label for="EnterpriseName">抬頭</label> |
|||
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[14] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="TaxNo">統一編號</label> |
|||
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-6"> |
|||
<label for="ContactAddress">聯絡地址</label> |
|||
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[16] ?>" disabled> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="detail">狀態</label> |
|||
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill[13]) ?></textarea> |
|||
</div> |
|||
</form> |
|||
<div style="width: auto; margin-top: 30px;"> |
|||
<table class="table table-striped table-bordered" style="width:100%;"> |
|||
<thead> |
|||
<tr> |
|||
<th>目前應收</th> |
|||
<th>已開發票金額</th> |
|||
<th>未開發票金額</th> |
|||
<th>已收金額</th> |
|||
<th>未收金額</th> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td><?= number_format(round($Bill[12])) ?></td> |
|||
<td><?= number_format(round($Bill[19])) ?></td> |
|||
<td><?= number_format(round($Bill[21])) ?></td> |
|||
<td><?= number_format(round($Bill[20])) ?></td> |
|||
<td><?= number_format(round($Bill[22])) ?></td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<div style="width: auto; margin-top: 30px;"> |
|||
<table 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> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td><?= number_format(round($Bill[5])) ?></td> |
|||
<td><?= number_format(round($Bill[6])) ?></td> |
|||
<td><?= number_format(round($Bill[7])) ?></td> |
|||
<td><?= number_format(round($Bill[8])) ?></td> |
|||
<td><?= number_format(round($Bill[9])) ?></td> |
|||
<td><?= number_format(round($Bill[10])) ?></td> |
|||
<td><?= number_format(round($Bill[11])) ?></td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
<?php |
|||
include "./footer.php"; |
|||
|
|||
?> |
|||
<?php |
|||
if ($user_id == "M0122") { |
|||
?> |
|||
<button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;"> |
|||
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button> |
|||
<?php |
|||
} |
|||
?> |
|||
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;"> |
|||
<table class="table table-striped table-bordered" style="width:100%;"> |
|||
<thead> |
|||
<tr> |
|||
<th>發票日期</th> |
|||
<th>發票金額</th> |
|||
<th>收款日期</th> |
|||
<th>收款金額</th> |
|||
<th>說明</th> |
|||
<th style="width: 10%;">功能</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php if ($pay_received) { |
|||
foreach ($pay_received as $received) { ?> |
|||
<tr> |
|||
<td><?= $received['invoice_date'] ?></td> |
|||
<td><?= number_format($received['invoice_amount']) ?></td> |
|||
<td><?= $received['received_date'] ?></td> |
|||
<td><?= number_format($received['received_amount']) ?></td> |
|||
<td><?= $received['remark'] ?></td> |
|||
<td><?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?> |
|||
<button type="button" onclick="create('edit',<?= $received['pay_id'] ?>)" class="btn btn-warning btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;"> |
|||
<span class="glyphicon glyphicon-pencil"></span></button> |
|||
<a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm"> |
|||
<span class=" glyphicon glyphicon-trash"></span> |
|||
</a> |
|||
<?php } ?> |
|||
</td> |
|||
</tr> |
|||
<?php } |
|||
} ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<script> |
|||
function create(type, pay_id) { |
|||
var BillData = <?= $data ?>; |
|||
var form = document.createElement("form"); |
|||
form.method = 'POST'; |
|||
if (type === 'create') { |
|||
form.action = "account-receivable-received-create.php?<?= $token_link ?>"; |
|||
} else { |
|||
form.action = "account-receivable-received-edit.php?pay_id=" + pay_id + "&<?= $token_link ?>"; |
|||
} |
|||
|
|||
var input = document.createElement("input"); |
|||
input.type = "hidden"; |
|||
input.name = "Bill"; |
|||
input.value = JSON.stringify(BillData); |
|||
form.appendChild(input); |
|||
document.body.appendChild(form); |
|||
form.submit(); |
|||
} |
|||
</script> |
@ -1,39 +1,245 @@ |
|||
<?php |
|||
include "header.php"; |
|||
// 合約收款款別名稱 |
|||
$arrayData = []; |
|||
echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>"; |
|||
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName |
|||
FROM salOrderStagePay AS a |
|||
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo |
|||
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId |
|||
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4)"; |
|||
|
|||
$contract = $conn->query($sql_contract); |
|||
foreach ($contract as $cont) { |
|||
if ($cont['BillNo'] == 'SO20230801002') { |
|||
$BillNo = 'M231067'; |
|||
}else{ |
|||
$BillNo = $cont['BillNo']; |
|||
}; |
|||
$PayStage = $cont['PayStage']; |
|||
$PayAmount = $cont['PlanPayAmt']; |
|||
$partnerName = $cont['BizPartnerName']; |
|||
if(isset($arrayData[$BillNo])){ |
|||
array_push($arrayData[$BillNo], $PayStage); |
|||
array_push($arrayData[$BillNo], $PayAmount); |
|||
|
|||
}else{ |
|||
$arrayData[$BillNo][0] = $BillNo; |
|||
$arrayData[$BillNo][1] = $partnerName; |
|||
array_push($arrayData[$BillNo], $PayStage); |
|||
array_push($arrayData[$BillNo], $PayAmount); |
|||
|
|||
} |
|||
}; |
|||
foreach($arrayData as $data){ |
|||
foreach($data as $value){ |
|||
echo $value.";"; |
|||
} |
|||
echo "</br>"; |
|||
} |
|||
<?php |
|||
include "header.php"; |
|||
$BillNo = $_GET['BillNo']; |
|||
if ($cont['BillNo'] == 'M231067') { |
|||
$BillNo = 'SO20230801002'; |
|||
} |
|||
|
|||
// 合約收款款別名稱 |
|||
$arrayData = []; |
|||
// echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>"; |
|||
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName |
|||
FROM salOrderStagePay AS a |
|||
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo |
|||
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId |
|||
WHERE s.BillNo = '$BillNo'"; |
|||
|
|||
// T8發票 |
|||
//M220478 |
|||
$sql_invoice = "SELECT DISTINCT |
|||
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, |
|||
b.ProjectId |
|||
FROM arSellInvoice as a |
|||
LEFT JOIN arSellInvoiceMaterial as b |
|||
ON a.BillNo=b.BillNo |
|||
WHERE b.ProjectId='$BillNo'"; |
|||
|
|||
$contract = $conn->query($sql_contract); |
|||
$invoices = $conn->query($sql_invoice); |
|||
|
|||
// foreach($contract as $con){ |
|||
// print_r($con); |
|||
// echo "<br>"; |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// foreach ($contract as $cont) { |
|||
// if ($cont['BillNo'] == 'SO20230801002') { |
|||
// $BillNo = 'M231067'; |
|||
// }else{ |
|||
// $BillNo = $cont['BillNo']; |
|||
// }; |
|||
// $PayStage = $cont['PayStage']; |
|||
// $PayAmount = $cont['PlanPayAmt']; |
|||
// $partnerName = $cont['BizPartnerName']; |
|||
// if(isset($arrayData[$BillNo])){ |
|||
// array_push($arrayData[$BillNo], $PayStage); |
|||
// array_push($arrayData[$BillNo], $PayAmount); |
|||
|
|||
// }else{ |
|||
// $arrayData[$BillNo][0] = $BillNo; |
|||
// $arrayData[$BillNo][1] = $partnerName; |
|||
// array_push($arrayData[$BillNo], $PayStage); |
|||
// array_push($arrayData[$BillNo], $PayAmount); |
|||
|
|||
// } |
|||
// }; |
|||
// foreach($arrayData as $data){ |
|||
// foreach($data as $value){ |
|||
// echo $value.";"; |
|||
// } |
|||
// echo "</br>"; |
|||
// } |
|||
|
|||
|
|||
|
|||
?> |
|||
<style> |
|||
th { |
|||
text-align: center; |
|||
} |
|||
|
|||
td { |
|||
text-align: right; |
|||
} |
|||
</style> |
|||
<div class="container"> |
|||
<div class="text-center" style="margin-bottom: 20px;"> |
|||
<h3><strong><?= $Bill[4] ?></strong></h3> |
|||
</div> |
|||
<form class="form-horizontal"> |
|||
<div class="form-group"> |
|||
<div class="col-md-3"> |
|||
<label for="BillNo">合約號</label> |
|||
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[0] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="DeptId">部門</label> |
|||
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="Manager">經理</label> |
|||
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="PersonName">營業員</label> |
|||
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[3] ?>" disabled> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="form-group"> |
|||
<div class="col-md-3"> |
|||
<label for="EnterpriseName">抬頭</label> |
|||
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[14] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-3"> |
|||
<label for="TaxNo">統一編號</label> |
|||
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" disabled> |
|||
</div> |
|||
<div class="col-md-6"> |
|||
<label for="ContactAddress">聯絡地址</label> |
|||
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[16] ?>" disabled> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="detail">狀態</label> |
|||
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill[13]) ?></textarea> |
|||
</div> |
|||
</form> |
|||
<div style="width: auto; margin-top: 30px;"> |
|||
<table class="table table-striped table-bordered" style="width:100%;"> |
|||
<thead> |
|||
<tr> |
|||
<th>目前應收</th> |
|||
<th>已開發票金額</th> |
|||
<th>未開發票金額</th> |
|||
<th>已收金額</th> |
|||
<th>未收金額</th> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td><?= number_format(round($Bill[12])) ?></td> |
|||
<td><?= number_format(round($Bill[19])) ?></td> |
|||
<td><?= number_format(round($Bill[21])) ?></td> |
|||
<td><?= number_format(round($Bill[20])) ?></td> |
|||
<td><?= number_format(round($Bill[22])) ?></td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<div style="width: auto; margin-top: 30px;"> |
|||
<table 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> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td><?= number_format(round($Bill[5])) ?></td> |
|||
<td><?= number_format(round($Bill[6])) ?></td> |
|||
<td><?= number_format(round($Bill[7])) ?></td> |
|||
<td><?= number_format(round($Bill[8])) ?></td> |
|||
<td><?= number_format(round($Bill[9])) ?></td> |
|||
<td><?= number_format(round($Bill[10])) ?></td> |
|||
<td><?= number_format(round($Bill[11])) ?></td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
<?php |
|||
include "./footer.php"; |
|||
|
|||
?> |
|||
<?php |
|||
if ($user_id == "M0122") { |
|||
?> |
|||
<button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;"> |
|||
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button> |
|||
<?php |
|||
} |
|||
?> |
|||
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;"> |
|||
<table class="table table-striped table-bordered" style="width:100%;"> |
|||
<thead> |
|||
<tr> |
|||
<th>發票號碼</th> |
|||
<th>發票日期</th> |
|||
<th>發票金額</th> |
|||
<th>收款日期</th> |
|||
<th>收款金額</th> |
|||
<th>說明</th> |
|||
<th style="width: 10%;">功能</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php if (!empty($invoices)) { |
|||
foreach ($invoices as $invoice) { ?> |
|||
<tr> |
|||
<td><?= $invoice['InvoiceNo'] ?></td> |
|||
<td><?= date('Y-m-d', strtotime(strval($invoice['InvoiceTime']))) ?></td> |
|||
<td><?= number_format($invoice['OAmountWithTax']) ?></td> |
|||
|
|||
<td><?= number_format($received['received_amount']) ?></td> |
|||
<td><?= $received['remark'] ?></td> |
|||
<td><?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?> |
|||
<button type="button" onclick="create('edit',<?= $received['pay_id'] ?>)" class="btn btn-warning btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;"> |
|||
<span class="glyphicon glyphicon-pencil"></span></button> |
|||
<a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm"> |
|||
<span class=" glyphicon glyphicon-trash"></span> |
|||
</a> |
|||
<?php } ?> |
|||
</td> |
|||
</tr> |
|||
<?php } |
|||
} ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<script> |
|||
function create(type, pay_id) { |
|||
var BillData = <?= $data ?>; |
|||
var form = document.createElement("form"); |
|||
form.method = 'POST'; |
|||
if (type === 'create') { |
|||
form.action = "account-receivable-received-create.php?<?= $token_link ?>"; |
|||
} else { |
|||
form.action = "account-receivable-received-edit.php?pay_id=" + pay_id + "&<?= $token_link ?>"; |
|||
} |
|||
|
|||
var input = document.createElement("input"); |
|||
input.type = "hidden"; |
|||
input.name = "Bill"; |
|||
input.value = JSON.stringify(BillData); |
|||
form.appendChild(input); |
|||
document.body.appendChild(form); |
|||
form.submit(); |
|||
} |
|||
</script> |
@ -0,0 +1,855 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$follower = find_follow($user_id); |
|||
$arrayData = []; |
|||
$receivable_array = []; |
|||
// T8發票 (有專案的發票) |
|||
$sql_invoice = "SELECT DISTINCT |
|||
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState, |
|||
b.ProjectId |
|||
FROM arSellInvoice as a |
|||
LEFT JOIN arSellInvoiceMaterial as b |
|||
ON a.BillNo=b.BillNo |
|||
WHERE DATALENGTH(b.ProjectId)>0"; |
|||
|
|||
// T8核銷 |
|||
$sql_received = "SELECT |
|||
a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount, |
|||
b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee, |
|||
c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate |
|||
FROM arWriteOffBill AS a |
|||
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo |
|||
LEFT JOIN |
|||
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail |
|||
LEFT JOIN |
|||
(SELECT |
|||
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo |
|||
FROM arCheckBill |
|||
LEFT JOIN arCheckBillInvInfo |
|||
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 |
|||
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c |
|||
ON a.BillNo=c.BillNo |
|||
WHERE DATALENGTH(c.OrderBillNo) >0"; |
|||
|
|||
//T8 銷售訂單 階段收款計畫 |
|||
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId, |
|||
c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a |
|||
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo |
|||
LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId |
|||
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) "; |
|||
|
|||
// 期初收款資訊 |
|||
$sql_opening = " |
|||
SELECT * FROM account_received "; |
|||
|
|||
// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的 |
|||
if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) { |
|||
$sql_contract .= "AND (s.PersonId = '$user_id'"; |
|||
$sql_received .= " AND (PersonId = '$user_id'"; |
|||
$sql_opening .= " OR person_id = '$user_id'"; |
|||
if (count($follower) > 0) { |
|||
$column_str = "('$user_id'" . ",'"; |
|||
$column_str .= implode("','", $follower); |
|||
$column_str .= "')"; |
|||
$sql_contract .= " OR s.PersonId IN $column_str)"; |
|||
$sql_received .= " OR PersonId IN $column_str)"; |
|||
$sql_opening .= " OR person_id IN $column_str)"; |
|||
} else { |
|||
$sql_contract .= ")"; |
|||
$sql_received .= ")"; |
|||
$sql_opening .= ")"; |
|||
}; |
|||
} |
|||
|
|||
$contract = $conn->query($sql_contract); |
|||
$received_array = $conn->query($sql_received); |
|||
$opening_data = mysqli_query($link, $sql_opening); |
|||
$invoice_data = $conn->query($sql_invoice); |
|||
|
|||
|
|||
// 合約收款階段內容分類 |
|||
$sign60 = array('簽訂後60天', '簽約60日', '簽約後60天', '簽訂後60日內', '訂金支付後60天'); |
|||
$sign90 = array('簽約後90天', '簽約後90日', '簽訂後90天'); |
|||
$sign120 = array('簽約後120天', '簽約後120日', '簽訂後120天'); |
|||
|
|||
// 將T8合約收款階段資料依據款別分類放進arraData裡 |
|||
foreach ($contract as $cont) { |
|||
if ($cont['BillNo'] == 'SO20230801001') { |
|||
$BillNo = 'M230947'; |
|||
} elseif ($cont['BillNo'] == 'SO20230801002') { |
|||
$BillNo = 'M231067'; |
|||
} else { |
|||
$BillNo = $cont['BillNo']; |
|||
}; |
|||
$PayStage = $cont['PayStage']; |
|||
$PlanPayDate = $cont['PlanPayDate']; |
|||
$PayAmount = $cont['PlanPayAmt']; |
|||
$partnerName = $cont['BizPartnerName']; |
|||
$EnterpriseName = $cont['EnterpriseName']; |
|||
$TaxNo = $cont['TaxNo']; |
|||
$ContactAddress = $cont['ContactAddress']; |
|||
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期 |
|||
//['tryrun'] 0 試車款名 1試車金額 2 試車收款日期 ['check'] 0 官檢款名 1 官檢金額 2 官檢收款日期 ['delivery'] 0 交車款名 1 交車金額 2 交車收款日期 ['final'] 0 尾款名 1 尾款金額 2 尾款收款日期 |
|||
if (!(isset($arrayData[$BillNo]))) { |
|||
// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址 |
|||
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0]; |
|||
$arrayData[$BillNo][5] = $partnerName; |
|||
$arrayData[$BillNo][6] = $EnterpriseName; |
|||
$arrayData[$BillNo][7] = $TaxNo; |
|||
$arrayData[$BillNo][8] = $ContactAddress; |
|||
$arrayData[$BillNo]['total_budget'] = 0; |
|||
$arrayData[$BillNo]['invoice'] = array(); |
|||
$arrayData[$BillNo]['received_budget'] = 0; |
|||
$arrayData[$BillNo]['invoice_budget'] = 0; |
|||
$arrayData[$BillNo]['sign'][1] = $arrayData[$BillNo]['second'][1] = $arrayData[$BillNo]['arrive'][1] = $arrayData[$BillNo]['install'][1] = $arrayData[$BillNo]['tryrun'][1] = $arrayData[$BillNo]['check'][1] = $arrayData[$BillNo]['delivery'][1] = $arrayData[$BillNo]['final'][1] = 0; |
|||
$arrayData[$BillNo]['sign']['min'] = $arrayData[$BillNo]['second']['min'] = $arrayData[$BillNo]['arrive']['min'] = $arrayData[$BillNo]['install']['min'] = $arrayData[$BillNo]['tryrun']['min'] = $arrayData[$BillNo]['check']['min'] = $arrayData[$BillNo]['delivery']['min'] = $arrayData[$BillNo]['final']['min'] = array(); |
|||
$arrayData[$BillNo]['sign']['max'] = $arrayData[$BillNo]['second']['max'] = $arrayData[$BillNo]['arrive']['max'] = $arrayData[$BillNo]['install']['max'] = $arrayData[$BillNo]['tryrun']['max'] = $arrayData[$BillNo]['check']['max'] = $arrayData[$BillNo]['delivery']['max'] = $arrayData[$BillNo]['final']['max'] = array(); |
|||
$arrayData[$BillNo]['facilities'] = ""; |
|||
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['receivable_budget'] = 0; |
|||
} |
|||
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60') || stristr($PayStage, '寶佳出貨後10天')) { |
|||
$arrayData[$BillNo]['second'][0] = $PayStage; |
|||
$arrayData[$BillNo]['second'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['second'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
if (isset($arrayData[$BillNo]['sign'][2]) && !is_null($arrayData[$BillNo]['sign'][2])) { |
|||
$signtime = strtotime(strval($arrayData[$BillNo]['sign'][2])); |
|||
if (in_array($PayStage, $sign60)) { |
|||
$secondtime = $signtime + (60 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$BillNo]['second'][2] = strval($secondtime); |
|||
} elseif (in_array($PayStage, $sign90)) { |
|||
$secondtime = $signtime + (90 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$BillNo]['second'][2] = strval($secondtime); |
|||
} elseif (in_array($PayStage, $sign120)) { |
|||
$secondtime = $signtime + (120 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$BillNo]['second'][2] = strval($secondtime); |
|||
} elseif (stristr($PayStage, '簽訂後30天')) { |
|||
$secondtime = $signtime + (30 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$BillNo]['second'][2] = strval($secondtime); |
|||
} |
|||
} |
|||
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工') || stristr($PayStage, '寶佳出貨前30天')) { |
|||
$arrayData[$BillNo]['sign'][0] = $PayStage; |
|||
$arrayData[$BillNo]['sign'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['sign'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
$arrayData[$BillNo]['receivable_budget'] += $PayAmount; |
|||
if (isset($PlanPayDate) && !empty($PlanPayDate)) { |
|||
array_push($arrayData[$BillNo]['sign']['min'], strval($PlanPayDate)); |
|||
array_push($arrayData[$BillNo]['sign']['max'], strtotime(strval($PlanPayDate))); |
|||
} |
|||
} elseif (stristr($PayStage, '試車')) { |
|||
$arrayData[$BillNo]['tryrun'][0] = $PayStage; |
|||
$arrayData[$BillNo]['tryrun'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['tryrun'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
} elseif (stristr($PayStage, '安裝') || stristr($PayStage, '貨抵工地且完工')) { |
|||
$arrayData[$BillNo]['install'][0] = $PayStage; |
|||
$arrayData[$BillNo]['install'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['install'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
} elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) { |
|||
$arrayData[$BillNo]['arrive'][0] = $PayStage; |
|||
$arrayData[$BillNo]['arrive'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['arrive'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
} elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) { |
|||
$arrayData[$BillNo]['delivery'][0] = $PayStage; |
|||
$arrayData[$BillNo]['delivery'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['delivery'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
} elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) { |
|||
$arrayData[$BillNo]['check'][0] = $PayStage; |
|||
$arrayData[$BillNo]['check'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['check'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
} elseif (stristr($PayStage, '驗收完成')) { |
|||
$arrayData[$BillNo]['final'][0] = $PayStage; |
|||
$arrayData[$BillNo]['final'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['final'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
} else { |
|||
$arrayData[$BillNo]['other'][1] = $PayAmount; |
|||
$arrayData[$BillNo]['other'][2] = $PlanPayDate; |
|||
$arrayData[$BillNo]['total_budget'] += $PayAmount; |
|||
} |
|||
} |
|||
//取作番大日程作番與時程 |
|||
// real_contract_arrival_date 預計出貨日 |
|||
// real_arrival_date 實際出貨日 |
|||
$sql = "SELECT |
|||
tmp2.*, |
|||
d.name AS depart_name |
|||
FROM( |
|||
SELECT |
|||
a.manager, |
|||
a2.name as manager_name, |
|||
a.name, |
|||
a.department_id, |
|||
w.salesid, |
|||
w.contractno, |
|||
w.facilityno, |
|||
w.estimated_shipping_date, |
|||
w.real_contract_arrival_date, |
|||
w.actual_tofactory_date, |
|||
w.real_contract_arrival_date, |
|||
w.real_arrival_date, |
|||
w.install_end_date, |
|||
w.tryrun_end_date, |
|||
w.official_check_date, |
|||
w.delivery_date |
|||
from wipwholestatus AS w |
|||
left join account AS a |
|||
ON w.salesid = a.accountid |
|||
left join account AS a2 |
|||
ON a2.accountid = a.manager |
|||
where w.status = '1' AND w.contract_type='A' |
|||
)AS tmp2 |
|||
left join ( |
|||
SELECT DISTINCT |
|||
department_id, |
|||
name |
|||
FROM department |
|||
|
|||
) AS d |
|||
ON d.department_id = tmp2.department_id ORDER BY contractno"; |
|||
$wipwhole_array = mysqli_query($link, $sql); |
|||
foreach ($wipwhole_array as $wip) { |
|||
if (isset($arrayData[$wip['contractno']])) { |
|||
// 整理合約資料 |
|||
$arrayData[$wip['contractno']][0] = $wip['department_id'];; |
|||
$arrayData[$wip['contractno']][1] = $wip['depart_name']; |
|||
$arrayData[$wip['contractno']][2] = $wip['manager_name']; |
|||
$arrayData[$wip['contractno']][3] = $wip['salesid']; |
|||
$arrayData[$wip['contractno']][4] = $wip['name']; |
|||
$arrayData[$wip['contractno']][10] = $wip['contractno']; |
|||
// [合約號][作番號]['no'] |
|||
$arrayData[$wip['contractno']][$wip['facilityno']]['no'] = $wip['facilityno']; |
|||
|
|||
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期] |
|||
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期] |
|||
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期] |
|||
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); |
|||
foreach ($contractstage as $i) { |
|||
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['date'] = ""; |
|||
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['budget'] = 0; |
|||
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['date'] = ""; |
|||
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['budget'] = 0; |
|||
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['date'] = (isset($arrayData[$wip['contractno']][$i][2])) ? $arrayData[$wip['contractno']][$i][2] : ""; |
|||
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['con']['budget'] = 0; |
|||
} |
|||
// 補上寶佳 (出貨前) 收款時間 |
|||
|
|||
if (isset($arrayData[$wip['contractno']]['sign'][0]) && $arrayData[$wip['contractno']]['sign'][0] == '寶佳出貨前30天') { |
|||
if ($wip['real_arrival_date'] != NULL) { |
|||
$estimate_delivery_time = strtotime($wip['real_arrival_date']); |
|||
$signtime = $estimate_delivery_time - (30 * 86400); |
|||
$signtime = date('Ymd', $signtime); |
|||
$arrayData[$wip['contractno']]['sign'][2] = strval($signtime); |
|||
array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime))); |
|||
array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime))); |
|||
} elseif ($wip['real_contract_arrival_date'] != NULL) { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$signtime = $estimate_delivery_time - (30 * 86400); |
|||
$signtime = date('Ymd', $signtime); |
|||
$arrayData[$wip['contractno']]['sign'][2] = strval($signtime); |
|||
array_push($arrayData[$wip['contractno']]['sign']['max'], strtotime(strval($signtime))); |
|||
array_push($arrayData[$wip['contractno']]['sign']['min'], strtotime(strval($signtime))); |
|||
} |
|||
} |
|||
|
|||
// 補上二次款 (出貨前) 收款時間,條件不是"出貨前"就pass |
|||
if (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前30天')) { |
|||
if (empty($wip['real_contract_arrival_date'])) { |
|||
} else { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$secondtime = $estimate_delivery_time - (30 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime))); |
|||
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); |
|||
} |
|||
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前90天')) { |
|||
if (empty($wip['real_contract_arrival_date'])) { |
|||
} else { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$secondtime = $estimate_delivery_time - (90 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime))); |
|||
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); |
|||
} |
|||
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && $arrayData[$wip['contractno']]['second'][0] == '寶佳出貨後10天') { |
|||
|
|||
if ($wip['real_arrival_date'] != NULL) { |
|||
$estimate_delivery_time = strtotime($wip['real_arrival_date']); |
|||
$secondtime = $estimate_delivery_time + (10 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime))); |
|||
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); |
|||
} else { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$secondtime = $estimate_delivery_time + (10 * 86400); |
|||
$secondtime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime($secondtime)); |
|||
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime))); |
|||
} |
|||
} |
|||
//根據作番狀態填入facilities,計算各階段數量、一個合約有幾個作番,增加作番資料 |
|||
// real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地 |
|||
// real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地 |
|||
if ($wip['delivery_date'] != NULL) { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
$arrayData[$wip['contractno']]['delivery_num'] += 1; |
|||
$arrayData[$wip['contractno']]['check_num'] += 1; |
|||
$arrayData[$wip['contractno']]['tryrun_num'] += 1; |
|||
$arrayData[$wip['contractno']]['install_num'] += 1; |
|||
$arrayData[$wip['contractno']]['arrive_num'] += 1; |
|||
$arrayData[$wip['contractno']]['second_num'] += 1; |
|||
|
|||
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") { |
|||
$estimate_delivery_time = strtotime($wip['delivery_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['delivery'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']); |
|||
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($wip['delivery_date']))); |
|||
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($wip['delivery_date']))); |
|||
} |
|||
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) { |
|||
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date']))); |
|||
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date']))); |
|||
} |
|||
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { |
|||
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") { |
|||
$estimate_delivery_time = strtotime($wip['tryrun_end_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date']))); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date']))); |
|||
} |
|||
} |
|||
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { |
|||
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date']))); |
|||
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date']))); |
|||
} |
|||
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); |
|||
} |
|||
} else { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
} |
|||
} |
|||
} elseif ($wip['official_check_date'] != NULL) { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
$arrayData[$wip['contractno']]['check_num'] += 1; |
|||
$arrayData[$wip['contractno']]['tryrun_num'] += 1; |
|||
$arrayData[$wip['contractno']]['install_num'] += 1; |
|||
$arrayData[$wip['contractno']]['arrive_num'] += 1; |
|||
$arrayData[$wip['contractno']]['second_num'] += 1; |
|||
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) { |
|||
array_push($arrayData[$wip['contractno']]['check']['min'], strval($wip['official_check_date'])); |
|||
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date']))); |
|||
} |
|||
|
|||
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { |
|||
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") { |
|||
$estimate_delivery_time = strtotime($wip['tryrun_end_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date']))); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date']))); |
|||
} |
|||
} |
|||
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { |
|||
array_push($arrayData[$wip['contractno']]['install']['min'], strval($wip['install_end_date'])); |
|||
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date']))); |
|||
} |
|||
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); |
|||
} |
|||
} else { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
} |
|||
} |
|||
} elseif ($wip['tryrun_end_date'] != NULL) { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
$arrayData[$wip['contractno']]['tryrun_num'] += 1; |
|||
$arrayData[$wip['contractno']]['install_num'] += 1; |
|||
$arrayData[$wip['contractno']]['arrive_num'] += 1; |
|||
$arrayData[$wip['contractno']]['second_num'] += 1; |
|||
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strval($wip['tryrun_end_date'])); |
|||
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date']))); |
|||
} |
|||
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { |
|||
array_push($arrayData[$wip['contractno']]['install']['min'], strval($wip['install_end_date'])); |
|||
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date']))); |
|||
} |
|||
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); |
|||
} |
|||
} else { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
} |
|||
} |
|||
} elseif ($wip['install_end_date'] != NULL) { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
$arrayData[$wip['contractno']]['install_num'] += 1; |
|||
$arrayData[$wip['contractno']]['arrive_num'] += 1; |
|||
$arrayData[$wip['contractno']]['second_num'] += 1; |
|||
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { |
|||
array_push($arrayData[$wip['contractno']]['install']['min'], strval($wip['install_end_date'])); |
|||
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strtotime(strval($wip['install_end_date'])))); |
|||
} |
|||
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); |
|||
} |
|||
} else { |
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date']))); |
|||
} |
|||
} |
|||
} elseif ($wip['real_arrival_date'] != NULL) { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
$arrayData[$wip['contractno']]['arrive_num'] += 1; |
|||
$arrayData[$wip['contractno']]['second_num'] += 1; |
|||
|
|||
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { |
|||
$estimate_delivery_time = strtotime($wip['real_arrival_date']); |
|||
$arrivetime = $estimate_delivery_time + (90 * 86400); |
|||
$arrivetime = date('Ymd', $secondtime); |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); |
|||
} else { |
|||
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date']))); |
|||
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); |
|||
} |
|||
} elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) { |
|||
|
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
$arrayData[$wip['contractno']]['second_num'] += 1; |
|||
} else { |
|||
if ($wip['real_contract_arrival_date'] != NULL) { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
} elseif ($wip['estimated_shipping_date'] != NULL) { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
} else { |
|||
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>"; |
|||
$arrayData[$wip['contractno']]['total_facility_num'] += 1; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 計算每個合約的應收款、作番總數 |
|||
foreach ($arrayData as &$value) { |
|||
if ($value['total_facility_num'] > 0) { |
|||
$value['receivable_budget'] += ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) + |
|||
($value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num'])) + ($value['install'][1] * ($value['install_num'] / $value['total_facility_num'])) + |
|||
($value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num'])) + ($value['check'][1] * ($value['check_num'] / $value['total_facility_num'])) + |
|||
(($value['delivery'][1] + $value['final'][1]) * ($value['delivery_num'] / $value['total_facility_num'])); |
|||
$value['sign'][3] = $value['sign'][1]; |
|||
$value['second'][3] = $value['second'][1] * ($value['second_num'] / $value['total_facility_num']); |
|||
$value['arrive'][3] = $value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num']); |
|||
$value['install'][3] = $value['install'][1] * ($value['install_num'] / $value['total_facility_num']); |
|||
$value['tryrun'][3] = $value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num']); |
|||
$value['check'][3] = $value['check'][1] * ($value['check_num'] / $value['total_facility_num']); |
|||
$value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']); |
|||
$value['final'][3] = $value['final'][1] * ($value['delivery_num'] / $value['total_facility_num']); |
|||
} |
|||
$stagearray = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); |
|||
|
|||
$today = date('Ym01', strtotime('-1 month', strtotime(date('Ym01')))); |
|||
// $today = strtotime($today,); |
|||
// echo "today: " . $today . "<br>"; |
|||
// exit(); |
|||
// foreach ($stagearray as $stage) { |
|||
// // 計算月份差距 |
|||
// if (empty($value[$stage]['min'])==0) { |
|||
// print_r($value[$stage]['min']); |
|||
// echo "<br>"; |
|||
// // $maxtime = array_map('strtotime', $value[$stage]['min']); |
|||
// $earliestDate = min($value[$stage]['min']); |
|||
// $earliestMonth = date('Ym01', $earliestDate); |
|||
// echo "earliestDate: " . $earliestDate . "<br>"; |
|||
// // $earliestMonth = date('n', strtotime($earliestDate)); |
|||
// // 計算月份差距 |
|||
// $maxDifference = $today -$earliestMonth; |
|||
// echo "difference = ".$maxDifference."<br>"; |
|||
// $value[$stage]['max'] = $maxDifference; |
|||
// } else { |
|||
// $value[$stage]['max'] = 0; |
|||
// } |
|||
// echo $value[$stage]['max']; |
|||
// echo "<br>--------------------<br>"; |
|||
// exit(); |
|||
|
|||
// if(!empty($value[$stage]['max']) && $value[$stage]['max'] !==10 && $value[$stage]['max'] !==1){ |
|||
// echo "max: " . $value[$stage]['max'] . "<br>"; |
|||
// if (!empty($value[$stage]['max'])) { |
|||
// $mintime = array_map('strtotime', $value[$stage]['max']); |
|||
// $latestDate = max($mintime); |
|||
// $latestMonth = date('n', strtotime($latestDate)); |
|||
// $minDifference = abs($latestMonth - $today); |
|||
// $value[$stage]['min'] = $minDifference; |
|||
// } else { |
|||
// $value[$stage]['min'] = 0; |
|||
// } |
|||
// }else{ |
|||
// $value[$stage]['min'] = 0; |
|||
// } |
|||
|
|||
// } |
|||
} |
|||
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期] |
|||
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期] |
|||
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期] |
|||
foreach ($wipwhole_array as $wip) { |
|||
if (isset($arrayData[$wip['contractno']]) && isset($arrayData[$wip['contractno']][$wip['facilityno']]) && !empty($arrayData[$wip['contractno']]['total_facility_num'])) { |
|||
$stagearray = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); |
|||
foreach ($stagearray as $stage) { |
|||
$arrayData[$wip['contractno']][$wip['facilityno']][$stage]['con'] = $arrayData[$wip['contractno']][$stage][1] / $arrayData[$wip['contractno']]['total_facility_num']; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號] |
|||
foreach ($invoice_data as $invoice) { |
|||
if (isset($arrayData[$invoice['ProjectId']])) { |
|||
$arrayData[$invoice['ProjectId']]['invoice_budget'] += intval($invoice['OAmountWithTax']); |
|||
$arrayData[$invoice['ProjectId']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']]; |
|||
} |
|||
} |
|||
|
|||
// 把核銷單的內容補到發票資料中 |
|||
foreach ($received_array as $received) { |
|||
if ($received['OrderBillNo'] == 'SO20230801001') { |
|||
$BillNo = 'M230947'; |
|||
} elseif ($received['OrderBillNo'] == 'SO20230801002') { |
|||
$BillNo = 'M231067'; |
|||
} else { |
|||
$BillNo = $received['OrderBillNo']; |
|||
}; |
|||
if (isset($arrayData[$BillNo])) { |
|||
if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) { |
|||
$arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount']; |
|||
array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']); |
|||
} |
|||
} |
|||
} |
|||
foreach ($arrayData as $key => $value) { |
|||
print_r($value); |
|||
echo "<br>"; |
|||
} |
|||
|
|||
$data = json_encode($arrayData); |
|||
|
|||
?> |
|||
<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> |
|||
<button type="button" onclick="downloadData()" class="btn btn-warning btn-lg pull-right"><span class="glyphicon glyphicon-download-alt"></span></button> |
|||
<div style="width:98%;margin:1% ;overflow-x: auto;"> |
|||
<table id="table_index" class="table table-striped table-bordered" style="width:100%;"> |
|||
<thead> |
|||
<tr> |
|||
<th style="width: 120px;">合約號</th> |
|||
<th style="width: 120px;">部門</th> |
|||
<th style="width: 120px;">經理</th> |
|||
<th style="width: 120px;">營業員</th> |
|||
<th style="width: 180px;">客戶名稱</th> |
|||
<th style="width: 150px;">簽約款</th> |
|||
<th style="width: 150px;">應收簽約金額</th> |
|||
<th style="width: 150px;">簽約最大催收次數</th> |
|||
<th style="width: 150px;">簽約最小催收次數</th> |
|||
<th style="width: 150px;">二次款</th> |
|||
<th style="width: 150px;">應收二次金額</th> |
|||
<th style="width: 150px;">二次最大催收次數</th> |
|||
<th style="width: 150px;">二次最小催收次數</th> |
|||
<th style="width: 150px;">貨抵工地款</th> |
|||
<th style="width: 150px;">應收貨抵工地金額</th> |
|||
<th style="width: 150px;">貨抵工地最大催收次數</th> |
|||
<th style="width: 150px;">貨抵工地最小催收次數</th> |
|||
<th style="width: 150px;">安裝款</th> |
|||
<th style="width: 150px;">應收安裝金額</th> |
|||
<th style="width: 150px;">安裝最大催收次數</th> |
|||
<th style="width: 150px;">安裝最小催收次數</th> |
|||
<th style="width: 150px;">試車款</th> |
|||
<th style="width: 150px;">應收試車金額</th> |
|||
<th style="width: 150px;">試車最大催收次數</th> |
|||
<th style="width: 150px;">試車最小催收次數</th> |
|||
<th style="width: 150px;">官檢款</th> |
|||
<th style="width: 150px;">應收官檢金額</th> |
|||
<th style="width: 150px;">官檢最大催收次數</th> |
|||
<th style="width: 150px;">官檢最小催收次數</th> |
|||
<th style="width: 150px;">移交款</th> |
|||
<th style="width: 150px;">應收移交金額</th> |
|||
<th style="width: 150px;">移交最大催收次數</th> |
|||
<th style="width: 150px;">移交最小催收次數</th> |
|||
<th style="width: 150px;">尾款</th> |
|||
<th style="width: 150px;">應收尾款金額</th> |
|||
<th style="width: 150px;">尾款最大催收次數</th> |
|||
<th style="width: 150px;">尾款最小催收次數</th> |
|||
<th style="width: 150px;">合約總金額</th> |
|||
<th style="width: 150px;" style="width: 120px;">目前應收</th> |
|||
<th style="width: 150px;" style="width: 120px;">已開發票金額</th> |
|||
<th style="width: 150px;">已收金額</th> |
|||
<!-- <th>作番狀態</th> --> |
|||
<!-- <th style="width: 100px;">收款狀態</th> --> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach ($arrayData as $key => $value) { |
|||
?> |
|||
<tr> |
|||
<th><?= $key ?></th> |
|||
<td><?= $value[1] ?></td> |
|||
<td><?= $value[2] ?></td> |
|||
<td><?= $value[4] ?></td> |
|||
<td><?= $value[5] ?></td> |
|||
<td><?= number_format(round($value['sign'][1])) ?></td> |
|||
<td style="text-align: end;"><?= isset($value['sign'][3]) ? number_format(round($value['sign'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['sign']['min']) ? $value['sign']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['sign']['max']) ? $value['sign']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['second'][1]) ? number_format(round($value['second'][1])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['second'][3]) ? number_format(round($value['second'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['second']['min']) ? $value['second']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['second']['max']) ? $value['second']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['arrive'][1]) ? number_format(round($value['arrive'][1])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['arrive'][3]) ? number_format(round($value['arrive'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['arrive']['min']) ? $value['arrive']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['arrive']['max']) ? $value['arrive']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['install'][1]) ? number_format(round($value['install'][1])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['install'][3]) ? number_format(round($value['install'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['install']['min']) ? $value['install']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['install']['max']) ? $value['install']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['tryrun'][1]) ? number_format(round($value['tryrun'][1])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['tryrun'][3]) ? number_format(round($value['tryrun'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['tryrun']['min']) ? $value['tryrun']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['tryrun']['max']) ? $value['tryrun']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['check'][1]) ? number_format(round($value['check'][1])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['check'][3]) ? number_format(round($value['check'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['check']['min']) ? $value['check']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['check']['max']) ? $value['check']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['delivery'][1]) ? number_format(round($value['delivery'][1])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['delivery'][3]) ? number_format(round($value['delivery'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['delivery']['min']) ? $value['delivery']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['delivery']['max']) ? $value['delivery']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['final'][1]) ? number_format(round($value['final'][1])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['final'][3]) ? number_format(round($value['final'][3])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['final']['min']) ? $value['final']['min'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['final']['max']) ? $value['final']['max'] : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['total_budget']) ? number_format(round($value['total_budget'])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['receivable_budget']) ? number_format(round($value['receivable_budget'])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['invoice_budget']) ? number_format(round($value['invoice_budget'])) : '--' ?></td> |
|||
<td style="text-align: end;"><?= isset($value['received_budget']) ? number_format(round($value['received_budget'])) : '--' ?></td> |
|||
<!-- <td style="text-align: start;"><?= $value['facilities'] ?></td>
|
|||
<td><button type="button" onclick="sendData('<?= $key ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button> |
|||
</td> --> |
|||
</tr> |
|||
<?php |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<script> |
|||
function test() { |
|||
var BillData = <?= $data ?>; |
|||
var form = document.createElement("form"); |
|||
form.method = 'POST'; |
|||
form.action = "account-receivable-excel.php?<?= $token_link ?>"; |
|||
var input = document.createElement("input"); |
|||
input.type = "hidden"; |
|||
input.name = "Bill"; |
|||
input.value = JSON.stringify(BillData); |
|||
form.appendChild(input); |
|||
document.body.appendChild(form); |
|||
form.submit(); |
|||
|
|||
} |
|||
|
|||
function downloadData() { |
|||
var xhr = new XMLHttpRequest(); |
|||
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $token_link ?>"; |
|||
xhr.open('POST', url, true); |
|||
xhr.setRequestHeader('Content-Type', 'application/json'); |
|||
xhr.onreadystatechange = function() { |
|||
if (xhr.readyState === 4 && xhr.status === 200) { |
|||
var file_path = xhr.responseText; |
|||
var link = document.createElement('a'); |
|||
var name = "應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|||
link.setAttribute('href', window.location.origin + "/wms/account-receivable.xlsx"); |
|||
link.setAttribute('download', name); |
|||
link.style.display = 'none'; |
|||
document.body.appendChild(link); |
|||
link.click(); |
|||
document.body.removeChild(link); |
|||
} |
|||
} |
|||
xhr.send(JSON.stringify({ |
|||
Bill: <?= $data ?> |
|||
})); |
|||
} |
|||
|
|||
function sendData(BillNo) { |
|||
var BillData = <?= $data ?>; |
|||
var Bill = BillData[BillNo]; |
|||
var form = document.createElement("form"); |
|||
form.method = 'POST'; |
|||
form.action = "account-receivable-check.php?<?= $token_link ?>"; |
|||
var input = document.createElement("input"); |
|||
input.type = "hidden"; |
|||
input.name = "Bill"; |
|||
input.value = JSON.stringify(Bill); |
|||
form.appendChild(input); |
|||
document.body.appendChild(form); |
|||
form.submit(); |
|||
} |
|||
</script> |
@ -1,3 +1,32 @@ |
|||
<?php |
|||
$test = [8,9,3,4]; |
|||
echo min($test); |
|||
// $today = date('Ym01', strtotime('-1 month',strtotime(date('Ym01')))); |
|||
// $yesterday = date("Ym01", strtotime('-1 month',strtotime(date('2023-11-17')))); |
|||
// echo "today: " . $today . "<br>"; |
|||
// echo "yesterday: " . $yesterday . "<br>"; |
|||
// echo $today-$yesterday; |
|||
// echo "<br>"; |
|||
// $test = date('Ymd', $today-$yesterday); |
|||
// echo $test; |
|||
|
|||
include './header.php'; |
|||
$sql = "SELECT |
|||
salOrderStagePay.BillNo, |
|||
salOrderStagePay.PayStage |
|||
FROM salOrderStagePay |
|||
LEFT JOIN salSalesOrder |
|||
ON salSalesOrder.BillNo = salOrderStagePay.BillNo WHERE salSalesOrder.ModeId = 'M' AND (salSalesOrder.CurrentState=2 OR salSalesOrder.CurrentState=4) "; |
|||
$query = $conn->query($sql); |
|||
$contracts = array(); |
|||
foreach ($query as $row) { |
|||
if (!array_key_exists($row['BillNo'], $contracts)) { |
|||
$contracts[$row['BillNo']] = [$row['BillNo'], $row['PayStage']]; |
|||
}else{ |
|||
array_push($contracts[$row['BillNo']], $row['PayStage']); |
|||
} |
|||
} |
|||
foreach($contracts as $contract){ |
|||
foreach($contract as $con){ |
|||
echo $con.";"; |
|||
} |
|||
echo "<br>"; |
|||
} |
|||
|
Binary file not shown.
Binary file not shown.
@ -1,75 +1,75 @@ |
|||
<?php |
|||
$id= ""; |
|||
$accounttype= ""; |
|||
$accountid= ""; |
|||
$pwd= ""; |
|||
$name= ""; |
|||
$tel= ""; |
|||
$address= ""; |
|||
$email= ""; |
|||
$lineid= ""; |
|||
$wechatid= ""; |
|||
$phone_call_help= ""; |
|||
$chat_for_help= ""; |
|||
$remote_help= ""; |
|||
$repairerid= ""; |
|||
$manager= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
|
|||
|
|||
$id_error = ""; |
|||
$accounttype_error= ""; |
|||
$accountid_error= ""; |
|||
$pwd_error= ""; |
|||
$name_error= ""; |
|||
$tel_error= ""; |
|||
$address_error= ""; |
|||
$email_error= ""; |
|||
$lineid_error= ""; |
|||
$wechatid_error= ""; |
|||
$phone_call_help_error= ""; |
|||
$chat_for_help_error= ""; |
|||
$remote_help_error= ""; |
|||
$repairerid_error= ""; |
|||
$manager_error= ""; |
|||
$creater_error= ""; |
|||
$create_at_error= ""; |
|||
|
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
include "account-user-input.php"; |
|||
|
|||
$db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, department_id, role_id, creater, create_at) VALUES "; |
|||
$db_query .= "('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$department_id', '$role_id', '$creater', '$create_at')"; |
|||
$result = mysqli_query($link,$db_query); |
|||
|
|||
// 新增權限 |
|||
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) { |
|||
$db_query = "insert into account_auth (accountid, permission) "; |
|||
$db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
} |
|||
|
|||
// mysqli_insert_id可以抓到第一筆的id |
|||
//$new_id= mysqli_insert_id ($link); |
|||
#echo "新增後的id為 {$id} "; |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
// 如果有一筆以上代表有更新 |
|||
echo "<script>"; |
|||
echo "alert('新增成功');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
<?php |
|||
$id= ""; |
|||
$accounttype= ""; |
|||
$accountid= ""; |
|||
$pwd= ""; |
|||
$name= ""; |
|||
$tel= ""; |
|||
$address= ""; |
|||
$email= ""; |
|||
$lineid= ""; |
|||
$wechatid= ""; |
|||
$phone_call_help= ""; |
|||
$chat_for_help= ""; |
|||
$remote_help= ""; |
|||
$repairerid= ""; |
|||
$manager= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
|
|||
|
|||
$id_error = ""; |
|||
$accounttype_error= ""; |
|||
$accountid_error= ""; |
|||
$pwd_error= ""; |
|||
$name_error= ""; |
|||
$tel_error= ""; |
|||
$address_error= ""; |
|||
$email_error= ""; |
|||
$lineid_error= ""; |
|||
$wechatid_error= ""; |
|||
$phone_call_help_error= ""; |
|||
$chat_for_help_error= ""; |
|||
$remote_help_error= ""; |
|||
$repairerid_error= ""; |
|||
$manager_error= ""; |
|||
$creater_error= ""; |
|||
$create_at_error= ""; |
|||
|
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
include "account-user-input.php"; |
|||
|
|||
$db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, department_id, role_id, creater, create_at) VALUES "; |
|||
$db_query .= "('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$department_id', '$role_id', '$creater', '$create_at')"; |
|||
$result = mysqli_query($link,$db_query); |
|||
|
|||
// 新增權限 |
|||
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) { |
|||
$db_query = "insert into account_auth (accountid, permission) "; |
|||
$db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
} |
|||
|
|||
// mysqli_insert_id可以抓到第一筆的id |
|||
//$new_id= mysqli_insert_id ($link); |
|||
#echo "新增後的id為 {$id} "; |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
// 如果有一筆以上代表有更新 |
|||
echo "<script>"; |
|||
echo "alert('新增成功');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
@ -1,66 +1,66 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
$id = $_POST['id']; |
|||
$accounttype = user_input($_POST["accounttype"]); |
|||
$accountid = user_input($_POST["accountid"]); |
|||
$pwd = user_input($_POST["pwd"]); |
|||
$name = user_input($_POST["name"]); |
|||
$tel = user_input($_POST["tel"]); |
|||
$address = user_input($_POST["address"]); |
|||
$email = user_input($_POST["email"]); |
|||
$lineid = user_input($_POST["lineid"]); |
|||
$wechatid = user_input($_POST["wechatid"]); |
|||
$phone_call_help = user_input($_POST["phone_call_help"]); |
|||
$chat_for_help = user_input($_POST["chat_for_help"]); |
|||
$remote_help = user_input($_POST["remote_help"]); |
|||
$repairerid = user_input($_POST["repairerid"]); |
|||
$manager = user_input($_POST["manager"]); |
|||
$department_id = user_input($_POST["department_id"]); |
|||
$role_id = user_input($_POST["role_id"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
|
|||
|
|||
$db_query = "UPDATE account set pwd = '$pwd', name = '$name', tel = '$tel', address = '$address', "; |
|||
$db_query .= "email = '$email', lineid = '$lineid', wechatid = '$wechatid', phone_call_help = '$phone_call_help', chat_for_help = '$chat_for_help', "; |
|||
$db_query .= "remote_help = '$remote_help', repairerid = '$repairerid', manager = '$manager', "; |
|||
$db_query .= "department_id = '$department_id', role_id = '$role_id', create_at = '$create_at' WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
|
|||
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) { |
|||
$sql = "select permission from department where department_id = '$department_id' and role_id = '$role_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$db_query = "update account_auth set permission = '$row[0]' where accountid = '$accountid'"; |
|||
mysqli_query($link, $db_query); |
|||
} |
|||
mysqli_free_result($res); |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
$id = $_POST['id']; |
|||
$accounttype = user_input($_POST["accounttype"]); |
|||
$accountid = user_input($_POST["accountid"]); |
|||
$pwd = user_input($_POST["pwd"]); |
|||
$name = user_input($_POST["name"]); |
|||
$tel = user_input($_POST["tel"]); |
|||
$address = user_input($_POST["address"]); |
|||
$email = user_input($_POST["email"]); |
|||
$lineid = user_input($_POST["lineid"]); |
|||
$wechatid = user_input($_POST["wechatid"]); |
|||
$phone_call_help = user_input($_POST["phone_call_help"]); |
|||
$chat_for_help = user_input($_POST["chat_for_help"]); |
|||
$remote_help = user_input($_POST["remote_help"]); |
|||
$repairerid = user_input($_POST["repairerid"]); |
|||
$manager = user_input($_POST["manager"]); |
|||
$department_id = user_input($_POST["department_id"]); |
|||
$role_id = user_input($_POST["role_id"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
|
|||
|
|||
$db_query = "UPDATE account set pwd = '$pwd', name = '$name', tel = '$tel', address = '$address', "; |
|||
$db_query .= "email = '$email', lineid = '$lineid', wechatid = '$wechatid', phone_call_help = '$phone_call_help', chat_for_help = '$chat_for_help', "; |
|||
$db_query .= "remote_help = '$remote_help', repairerid = '$repairerid', manager = '$manager', "; |
|||
$db_query .= "department_id = '$department_id', role_id = '$role_id', create_at = '$create_at' WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
|
|||
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) { |
|||
$sql = "select permission from department where department_id = '$department_id' and role_id = '$role_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
$db_query = "update account_auth set permission = '$row[0]' where accountid = '$accountid'"; |
|||
mysqli_query($link, $db_query); |
|||
} |
|||
mysqli_free_result($res); |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
@ -1,65 +1,65 @@ |
|||
<?php |
|||
|
|||
//Function to filter the form input |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
|
|||
$accounttype = user_input($_POST["accounttype"]); |
|||
$accountid = user_input($_POST["accountid"]); |
|||
#$accountid = $accounttype . $accountid; |
|||
$pwd = user_input($_POST["pwd"]); |
|||
$name = user_input($_POST["name"]); |
|||
$tel = user_input($_POST["tel"]); |
|||
$address = user_input($_POST["address"]); |
|||
$email = user_input($_POST["email"]); |
|||
$lineid = user_input($_POST["lineid"]); |
|||
$wechatid = user_input($_POST["wechatid"]); |
|||
$phone_call_help = user_input($_POST["phone_call_help"]); |
|||
$chat_for_help = user_input($_POST["chat_for_help"]); |
|||
$remote_help = user_input($_POST["remote_help"]); |
|||
$repairerid = user_input($_POST["repairerid"]); |
|||
$manager = user_input($_POST["manager"]); |
|||
$department_id = user_input($_POST["department_id"]); |
|||
$role_id = user_input($_POST["role_id"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
|
|||
|
|||
|
|||
/* |
|||
|
|||
if(empty($_POST["name"])) { |
|||
$name_error = "Name is required"; |
|||
} else { |
|||
$name = user_input($_POST["name"]); |
|||
|
|||
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { |
|||
$name_error = "Only letter and white space are allowed"; |
|||
} |
|||
} |
|||
|
|||
|
|||
/* |
|||
if(empty($_POST["website"])) { |
|||
$website_error = "Website address is required"; |
|||
} else { |
|||
$website = user_input($_POST["website"]); |
|||
|
|||
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { |
|||
$website_error = "Invalid website URL"; |
|||
} |
|||
} |
|||
|
|||
if(empty($_POST["comment"])) { |
|||
$comment = ""; |
|||
} else { |
|||
$comment = user_input($_POST["comment"]); |
|||
} |
|||
*/ |
|||
?> |
|||
<?php |
|||
|
|||
//Function to filter the form input |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
|
|||
$accounttype = user_input($_POST["accounttype"]); |
|||
$accountid = user_input($_POST["accountid"]); |
|||
#$accountid = $accounttype . $accountid; |
|||
$pwd = user_input($_POST["pwd"]); |
|||
$name = user_input($_POST["name"]); |
|||
$tel = user_input($_POST["tel"]); |
|||
$address = user_input($_POST["address"]); |
|||
$email = user_input($_POST["email"]); |
|||
$lineid = user_input($_POST["lineid"]); |
|||
$wechatid = user_input($_POST["wechatid"]); |
|||
$phone_call_help = user_input($_POST["phone_call_help"]); |
|||
$chat_for_help = user_input($_POST["chat_for_help"]); |
|||
$remote_help = user_input($_POST["remote_help"]); |
|||
$repairerid = user_input($_POST["repairerid"]); |
|||
$manager = user_input($_POST["manager"]); |
|||
$department_id = user_input($_POST["department_id"]); |
|||
$role_id = user_input($_POST["role_id"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
|
|||
|
|||
|
|||
/* |
|||
|
|||
if(empty($_POST["name"])) { |
|||
$name_error = "Name is required"; |
|||
} else { |
|||
$name = user_input($_POST["name"]); |
|||
|
|||
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { |
|||
$name_error = "Only letter and white space are allowed"; |
|||
} |
|||
} |
|||
|
|||
|
|||
/* |
|||
if(empty($_POST["website"])) { |
|||
$website_error = "Website address is required"; |
|||
} else { |
|||
$website = user_input($_POST["website"]); |
|||
|
|||
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { |
|||
$website_error = "Invalid website URL"; |
|||
} |
|||
} |
|||
|
|||
if(empty($_POST["comment"])) { |
|||
$comment = ""; |
|||
} else { |
|||
$comment = user_input($_POST["comment"]); |
|||
} |
|||
*/ |
|||
?> |
|||
|
@ -1,177 +1,177 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 部門職別 |
|||
$db_query = "select department_id, name, role_id, role from department order by department_id"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$depart_arr[$row["department_id"]] = $row["name"]; |
|||
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 選單結構 |
|||
$data = array(); |
|||
$db_query = "select * from menu order by main_menu_seq, sub_menu_seq"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$data[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"]; |
|||
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"]; |
|||
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"]; |
|||
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
//print_r($data);exit; |
|||
?> |
|||
<style> |
|||
table { |
|||
margin-top:10px; |
|||
} |
|||
.table-off, .table-off > td, .table-off > th { |
|||
background-color: #d6d8db; |
|||
} |
|||
.label-checkbox { cursor: pointer; } |
|||
</style> |
|||
<script> |
|||
$(function () { |
|||
var jroleStr = '<?php echo json_encode($role_arr); ?>'; |
|||
var jroleArr = JSON.parse(jroleStr); |
|||
var optStr = ""; |
|||
$("select[name=department_id]").change(function(){ |
|||
if ($(this).val() != "") { |
|||
optStr = ""; |
|||
for (var i in jroleArr[$(this).val()]) { |
|||
if ('undefined' !== jroleArr[$(this).val()][i]) { |
|||
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; |
|||
} |
|||
} |
|||
$("select[name=role_id]").html(optStr); |
|||
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); |
|||
}) |
|||
|
|||
$('#submit').click(function(){ |
|||
var optRStr = ""; |
|||
var optRArr = []; |
|||
$("input[name=opt_r]").each(function(){ |
|||
optRStr = ""; |
|||
optRStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optRStr += ";"+$(this).val(); |
|||
else optRStr += ";X"; |
|||
optRArr.push(optRStr); |
|||
}) |
|||
$('#opt_r_all').val(optRArr); |
|||
var optWStr = ""; |
|||
var optWArr = []; |
|||
$("input[name=opt_w]").each(function(){ |
|||
optWStr = ""; |
|||
optWStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optWStr += ";"+$(this).val(); |
|||
else optWStr += ";X"; |
|||
optWArr.push(optWStr); |
|||
}) |
|||
$('#opt_w_all').val(optWArr); |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "account_auth-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> |
|||
<div> |
|||
<label for="department_id">部門</label> |
|||
<select name="department_id" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($depart_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="role_id">職別</label> |
|||
<select name="role_id" required> |
|||
<?php |
|||
foreach ($role_arr[$data2["department_id"]] as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
|
|||
<table class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th scope="col">主功能名稱</th> |
|||
<th scope="col">子功能名稱</th> |
|||
<th scope="col">控管</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach($data as $key => $val) { |
|||
foreach($val as $k2 => $v2) { |
|||
if ($k2 == "main_menu") continue; |
|||
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : ''; |
|||
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"'; |
|||
?> |
|||
<tr<?php echo $sta_str; ?>> |
|||
<?php echo $td_str; ?> |
|||
<td><?php echo $v2["sub_menu"]; ?></td> |
|||
<td> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_r" value="R" data-auth="<?php echo $key.";".$k2; ?>"> |
|||
可讀</label> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_w" value="W" data-auth="<?php echo $key.";".$k2; ?>"> |
|||
可寫</label> |
|||
</td> |
|||
</tr> |
|||
|
|||
<?php |
|||
} |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" id="submit" name="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="opt_r_all" id="opt_r_all"> |
|||
<input type="hidden" name="opt_w_all" id="opt_w_all"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
include "footer.php"; |
|||
?> |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 部門職別 |
|||
$db_query = "select department_id, name, role_id, role from department order by department_id"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$depart_arr[$row["department_id"]] = $row["name"]; |
|||
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// 選單結構 |
|||
$data = array(); |
|||
$db_query = "select * from menu order by main_menu_seq, sub_menu_seq"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$data[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"]; |
|||
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"]; |
|||
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"]; |
|||
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
//print_r($data);exit; |
|||
?> |
|||
<style> |
|||
table { |
|||
margin-top:10px; |
|||
} |
|||
.table-off, .table-off > td, .table-off > th { |
|||
background-color: #d6d8db; |
|||
} |
|||
.label-checkbox { cursor: pointer; } |
|||
</style> |
|||
<script> |
|||
$(function () { |
|||
var jroleStr = '<?php echo json_encode($role_arr); ?>'; |
|||
var jroleArr = JSON.parse(jroleStr); |
|||
var optStr = ""; |
|||
$("select[name=department_id]").change(function(){ |
|||
if ($(this).val() != "") { |
|||
optStr = ""; |
|||
for (var i in jroleArr[$(this).val()]) { |
|||
if ('undefined' !== jroleArr[$(this).val()][i]) { |
|||
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; |
|||
} |
|||
} |
|||
$("select[name=role_id]").html(optStr); |
|||
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); |
|||
}) |
|||
|
|||
$('#submit').click(function(){ |
|||
var optRStr = ""; |
|||
var optRArr = []; |
|||
$("input[name=opt_r]").each(function(){ |
|||
optRStr = ""; |
|||
optRStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optRStr += ";"+$(this).val(); |
|||
else optRStr += ";X"; |
|||
optRArr.push(optRStr); |
|||
}) |
|||
$('#opt_r_all').val(optRArr); |
|||
var optWStr = ""; |
|||
var optWArr = []; |
|||
$("input[name=opt_w]").each(function(){ |
|||
optWStr = ""; |
|||
optWStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optWStr += ";"+$(this).val(); |
|||
else optWStr += ";X"; |
|||
optWArr.push(optWStr); |
|||
}) |
|||
$('#opt_w_all').val(optWArr); |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "account_auth-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> |
|||
<div> |
|||
<label for="department_id">部門</label> |
|||
<select name="department_id" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($depart_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="role_id">職別</label> |
|||
<select name="role_id" required> |
|||
<?php |
|||
foreach ($role_arr[$data2["department_id"]] as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
|
|||
<table class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th scope="col">主功能名稱</th> |
|||
<th scope="col">子功能名稱</th> |
|||
<th scope="col">控管</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach($data as $key => $val) { |
|||
foreach($val as $k2 => $v2) { |
|||
if ($k2 == "main_menu") continue; |
|||
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : ''; |
|||
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"'; |
|||
?> |
|||
<tr<?php echo $sta_str; ?>> |
|||
<?php echo $td_str; ?> |
|||
<td><?php echo $v2["sub_menu"]; ?></td> |
|||
<td> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_r" value="R" data-auth="<?php echo $key.";".$k2; ?>"> |
|||
可讀</label> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_w" value="W" data-auth="<?php echo $key.";".$k2; ?>"> |
|||
可寫</label> |
|||
</td> |
|||
</tr> |
|||
|
|||
<?php |
|||
} |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" id="submit" name="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="opt_r_all" id="opt_r_all"> |
|||
<input type="hidden" name="opt_w_all" id="opt_w_all"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
include "footer.php"; |
|||
?> |
|||
|
@ -1,182 +1,182 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
// 選單結構 |
|||
$menu = array(); |
|||
$db_query = "select * from menu where status = 'Y' order by main_menu_seq, sub_menu_seq"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$menu[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["mlink"] = $row["mlink"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["id"] = $row["id"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$data = array(); |
|||
// sql语法存在变数中 |
|||
$db_query = "select * from department where id = '$id'"; |
|||
// 用mysqli_query方法执行(sql语法)将结果存在变数中 |
|||
$data = mysqli_query($link,$db_query); |
|||
foreach($data as $data) : |
|||
$permission_arr = json_decode(urldecode($data["permission"]), true); |
|||
|
|||
$person = ""; |
|||
$sql = "select accountid, name from account where department_id = '".$data["department_id"]."' and role_id = '".$data["role_id"]."' and accounttype <> 'X'"; |
|||
$result = mysqli_query($link, $sql); |
|||
while ($row_a = mysqli_fetch_row($result)) { |
|||
$person .= $row_a[1]."(".$row_a[0].")、"; |
|||
} |
|||
mysqli_free_result($result); |
|||
?> |
|||
<style> |
|||
table { |
|||
margin-top:10px; |
|||
} |
|||
.table-off, .table-off > td, .table-off > th { |
|||
background-color: #d6d8db; |
|||
} |
|||
.label-checkbox { |
|||
cursor: pointer; |
|||
} |
|||
|
|||
body > div > form > table > thead > tr > th:nth-child(3) > label > span { |
|||
font-size:14px; |
|||
} |
|||
.nextline { |
|||
width: 100%; |
|||
height: 0; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function () { |
|||
$("input[name=rall]").click(function(){ |
|||
$("input[name=opt_r]").not(this).prop('checked', this.checked); |
|||
}); |
|||
$("input[name=wall]").click(function(){ |
|||
$("input[name=opt_w]").not(this).prop('checked', this.checked); |
|||
}); |
|||
|
|||
$('#update').click(function(){ |
|||
var optRStr = ""; |
|||
var optRArr = []; |
|||
$("input[name=opt_r]").each(function(){ |
|||
optRStr = ""; |
|||
optRStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optRStr += ";"+$(this).val(); |
|||
else optRStr += ";0"; |
|||
optRArr.push(optRStr); |
|||
}) |
|||
$('#opt_r_all').val(optRArr); |
|||
var optWStr = ""; |
|||
var optWArr = []; |
|||
$("input[name=opt_w]").each(function(){ |
|||
optWStr = ""; |
|||
optWStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optWStr += ";"+$(this).val(); |
|||
else optWStr += ";0"; |
|||
optWArr.push(optWStr); |
|||
}) |
|||
$('#opt_w_all').val(optWArr); |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="account_auth-record-update.php"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="department_name">部門</label> |
|||
<input type="text" name="department_name" id="department_name" value="<?php echo $data['name']; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="role_name">職別</label> |
|||
<input type="text" name="role_name" id="role_name" value="<?php echo $data['role']; ?>" readonly> |
|||
</div> |
|||
|
|||
<table class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th scope="col">主功能名稱</th> |
|||
<th scope="col">子功能名稱</th> |
|||
<th scope="col"> |
|||
<label class="label-checkbox"><input type="checkbox" name="rall"> |
|||
全選</label> |
|||
</th> |
|||
<th scope="col"> |
|||
<label class="label-checkbox"><input type="checkbox" name="wall"> |
|||
全選</label> |
|||
</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach($menu as $key => $val) { |
|||
foreach($val as $k2 => $v2) { |
|||
if ($k2 == "main_menu") continue; |
|||
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : ''; |
|||
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"'; |
|||
$chk_r = $chk_w = ""; |
|||
if (!empty($permission_arr[$v2["mlink"]])) { |
|||
if ($permission_arr[$v2["mlink"]]&1) $chk_r = " checked"; |
|||
if ($permission_arr[$v2["mlink"]]&2) $chk_w = " checked"; |
|||
} |
|||
?> |
|||
<tr<?php echo $sta_str; ?>> |
|||
<?php echo $td_str; ?> |
|||
<td> |
|||
<?php echo $v2["sub_menu"]; ?> |
|||
</td> |
|||
<td> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_r" value="1" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_r; ?>> |
|||
可讀</label> |
|||
</td> |
|||
<td> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_w" value="2" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_w; ?>> |
|||
可寫</label> |
|||
</td> |
|||
</tr> |
|||
|
|||
<?php |
|||
} |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
|
|||
<div> |
|||
<label>所屬人員</label> |
|||
<textarea name="person-info" rows="6" cols="70" class="form-control" readonly><?php echo rtrim($person, "、"); ?></textarea> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update" id="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="opt_r_all" id="opt_r_all"> |
|||
<input type="hidden" name="opt_w_all" id="opt_w_all"> |
|||
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data["department_id"]; ?>"> |
|||
<input type="hidden" name="role_id" id="role_id" value="<?php echo $data["role_id"]; ?>"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
|
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
// 選單結構 |
|||
$menu = array(); |
|||
$db_query = "select * from menu where status = 'Y' order by main_menu_seq, sub_menu_seq"; |
|||
$res = mysqli_query($link, $db_query); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$menu[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["mlink"] = $row["mlink"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"]; |
|||
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["id"] = $row["id"]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$data = array(); |
|||
// sql语法存在变数中 |
|||
$db_query = "select * from department where id = '$id'"; |
|||
// 用mysqli_query方法执行(sql语法)将结果存在变数中 |
|||
$data = mysqli_query($link,$db_query); |
|||
foreach($data as $data) : |
|||
$permission_arr = json_decode(urldecode($data["permission"]), true); |
|||
|
|||
$person = ""; |
|||
$sql = "select accountid, name from account where department_id = '".$data["department_id"]."' and role_id = '".$data["role_id"]."' and accounttype <> 'X'"; |
|||
$result = mysqli_query($link, $sql); |
|||
while ($row_a = mysqli_fetch_row($result)) { |
|||
$person .= $row_a[1]."(".$row_a[0].")、"; |
|||
} |
|||
mysqli_free_result($result); |
|||
?> |
|||
<style> |
|||
table { |
|||
margin-top:10px; |
|||
} |
|||
.table-off, .table-off > td, .table-off > th { |
|||
background-color: #d6d8db; |
|||
} |
|||
.label-checkbox { |
|||
cursor: pointer; |
|||
} |
|||
|
|||
body > div > form > table > thead > tr > th:nth-child(3) > label > span { |
|||
font-size:14px; |
|||
} |
|||
.nextline { |
|||
width: 100%; |
|||
height: 0; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function () { |
|||
$("input[name=rall]").click(function(){ |
|||
$("input[name=opt_r]").not(this).prop('checked', this.checked); |
|||
}); |
|||
$("input[name=wall]").click(function(){ |
|||
$("input[name=opt_w]").not(this).prop('checked', this.checked); |
|||
}); |
|||
|
|||
$('#update').click(function(){ |
|||
var optRStr = ""; |
|||
var optRArr = []; |
|||
$("input[name=opt_r]").each(function(){ |
|||
optRStr = ""; |
|||
optRStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optRStr += ";"+$(this).val(); |
|||
else optRStr += ";0"; |
|||
optRArr.push(optRStr); |
|||
}) |
|||
$('#opt_r_all').val(optRArr); |
|||
var optWStr = ""; |
|||
var optWArr = []; |
|||
$("input[name=opt_w]").each(function(){ |
|||
optWStr = ""; |
|||
optWStr += $(this).attr('data-auth'); |
|||
if ($(this).prop('checked')) optWStr += ";"+$(this).val(); |
|||
else optWStr += ";0"; |
|||
optWArr.push(optWStr); |
|||
}) |
|||
$('#opt_w_all').val(optWArr); |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="account_auth-record-update.php"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="department_name">部門</label> |
|||
<input type="text" name="department_name" id="department_name" value="<?php echo $data['name']; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="role_name">職別</label> |
|||
<input type="text" name="role_name" id="role_name" value="<?php echo $data['role']; ?>" readonly> |
|||
</div> |
|||
|
|||
<table class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th scope="col">主功能名稱</th> |
|||
<th scope="col">子功能名稱</th> |
|||
<th scope="col"> |
|||
<label class="label-checkbox"><input type="checkbox" name="rall"> |
|||
全選</label> |
|||
</th> |
|||
<th scope="col"> |
|||
<label class="label-checkbox"><input type="checkbox" name="wall"> |
|||
全選</label> |
|||
</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach($menu as $key => $val) { |
|||
foreach($val as $k2 => $v2) { |
|||
if ($k2 == "main_menu") continue; |
|||
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : ''; |
|||
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"'; |
|||
$chk_r = $chk_w = ""; |
|||
if (!empty($permission_arr[$v2["mlink"]])) { |
|||
if ($permission_arr[$v2["mlink"]]&1) $chk_r = " checked"; |
|||
if ($permission_arr[$v2["mlink"]]&2) $chk_w = " checked"; |
|||
} |
|||
?> |
|||
<tr<?php echo $sta_str; ?>> |
|||
<?php echo $td_str; ?> |
|||
<td> |
|||
<?php echo $v2["sub_menu"]; ?> |
|||
</td> |
|||
<td> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_r" value="1" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_r; ?>> |
|||
可讀</label> |
|||
</td> |
|||
<td> |
|||
<label class="label-checkbox"> |
|||
<input type="checkbox" name="opt_w" value="2" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_w; ?>> |
|||
可寫</label> |
|||
</td> |
|||
</tr> |
|||
|
|||
<?php |
|||
} |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
|
|||
<div> |
|||
<label>所屬人員</label> |
|||
<textarea name="person-info" rows="6" cols="70" class="form-control" readonly><?php echo rtrim($person, "、"); ?></textarea> |
|||
</div> |
|||
<div class="nextline"></div> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update" id="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="opt_r_all" id="opt_r_all"> |
|||
<input type="hidden" name="opt_w_all" id="opt_w_all"> |
|||
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data["department_id"]; ?>"> |
|||
<input type="hidden" name="role_id" id="role_id" value="<?php echo $data["role_id"]; ?>"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
|
|||
|
@ -1,105 +1,105 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql = "select * from department order by department_id, role_id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<!-- |
|||
<p> |
|||
<a href="account_auth-create.php?function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
--> |
|||
<?php |
|||
if($data): |
|||
?> |
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['department_id']; ?></td> |
|||
<td><?php echo $data['name']; ?></td> |
|||
<td><?php echo $data['role_id']; ?></td> |
|||
<td><?php echo $data['role']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<p> |
|||
<a href="account_auth-edit.php?id=<?php echo $data['id']; ?>&function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
include "footer.php"; |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql = "select * from department order by department_id, role_id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<!-- |
|||
<p> |
|||
<a href="account_auth-create.php?function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
--> |
|||
<?php |
|||
if($data): |
|||
?> |
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['department_id']; ?></td> |
|||
<td><?php echo $data['name']; ?></td> |
|||
<td><?php echo $data['role_id']; ?></td> |
|||
<td><?php echo $data['role']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<p> |
|||
<a href="account_auth-edit.php?id=<?php echo $data['id']; ?>&function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
include "footer.php"; |
|||
?> |
@ -1,65 +1,65 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
//print_r($_POST);exit; |
|||
|
|||
// 選單各功能的權限 |
|||
$prog_arr = []; |
|||
$opt_r_arr = explode(",", $opt_r_all); |
|||
$opt_w_arr = explode(",", $opt_w_all); |
|||
foreach ($opt_r_arr as $key => $val) { |
|||
list($menu_id, $auth_r) = explode(";", $val); |
|||
list($menu_id, $auth_w) = explode(";", $opt_w_arr[$key]); |
|||
|
|||
// 找出相關程式 |
|||
$sql = "select link_content from menu where id = '$menu_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_assoc($res)) { |
|||
if ($row["link_content"]) { |
|||
$tmp_arr = explode("\r\n", $row["link_content"]); |
|||
foreach ($tmp_arr as $v) { |
|||
$prog_arr[$v] = $auth_r|$auth_w; |
|||
} |
|||
} |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
if (($key%10)==0) usleep(200000); |
|||
} |
|||
|
|||
// 開始更新權限 |
|||
$permission = json_encode($prog_arr, JSON_UNESCAPED_SLASHES); |
|||
$sql = "update department set permission = '$permission', create_at = '$create_at' where id = '$id'"; |
|||
mysqli_query($link, $sql); |
|||
$affected = mysqli_affected_rows($link); |
|||
|
|||
// 更新user權限 |
|||
$sql = "select accountid from account where department_id = '$department_id' and role_id = '$role_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$db_query = "insert into account_auth (accountid, permission) values ('$row[0]', '$permission') "; |
|||
$db_query .= "ON DUPLICATE KEY UPDATE accountid = '$row[0]', permission = '$permission'"; |
|||
$res_u = mysqli_query($link, $db_query); |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
//print_r($_POST);exit; |
|||
|
|||
// 選單各功能的權限 |
|||
$prog_arr = []; |
|||
$opt_r_arr = explode(",", $opt_r_all); |
|||
$opt_w_arr = explode(",", $opt_w_all); |
|||
foreach ($opt_r_arr as $key => $val) { |
|||
list($menu_id, $auth_r) = explode(";", $val); |
|||
list($menu_id, $auth_w) = explode(";", $opt_w_arr[$key]); |
|||
|
|||
// 找出相關程式 |
|||
$sql = "select link_content from menu where id = '$menu_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
if ($row = mysqli_fetch_assoc($res)) { |
|||
if ($row["link_content"]) { |
|||
$tmp_arr = explode("\r\n", $row["link_content"]); |
|||
foreach ($tmp_arr as $v) { |
|||
$prog_arr[$v] = $auth_r|$auth_w; |
|||
} |
|||
} |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
if (($key%10)==0) usleep(200000); |
|||
} |
|||
|
|||
// 開始更新權限 |
|||
$permission = json_encode($prog_arr, JSON_UNESCAPED_SLASHES); |
|||
$sql = "update department set permission = '$permission', create_at = '$create_at' where id = '$id'"; |
|||
mysqli_query($link, $sql); |
|||
$affected = mysqli_affected_rows($link); |
|||
|
|||
// 更新user權限 |
|||
$sql = "select accountid from account where department_id = '$department_id' and role_id = '$role_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$db_query = "insert into account_auth (accountid, permission) values ('$row[0]', '$permission') "; |
|||
$db_query .= "ON DUPLICATE KEY UPDATE accountid = '$row[0]', permission = '$permission'"; |
|||
$res_u = mysqli_query($link, $db_query); |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 2.6 KiB |
@ -1,313 +1,313 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; |
|||
|
|||
$sql = "select max(bargainno) as maxno from bargain"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$bargainno = $row[0] ? $row[0]+1 : date("Ym")."001"; |
|||
|
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
list($department_id) = $row; |
|||
mysqli_free_result($res); |
|||
|
|||
$department_arr = []; |
|||
$sql = "select department_id, name from department"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$department_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
?> |
|||
<style> |
|||
|
|||
</style> |
|||
<script> |
|||
function commafy(num) { |
|||
num = num + ""; |
|||
var re = /(-?\d+)(\d{3})/ |
|||
while (re.test(num)) { |
|||
num = num.replace(re, "$1,$2") |
|||
} |
|||
return num; |
|||
} |
|||
|
|||
$(function(){ |
|||
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$("input[name=quote_amt_be]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$("input[name=quote_amt_ar]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$('#btnadd').click(function(){ |
|||
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end()); |
|||
$('#tb1 tr:last').prev().find('td').first().html($("tr[name='supplier_templ']").length); |
|||
}); |
|||
$('#submit').click(function(){ |
|||
var supIdArr = []; |
|||
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); }) |
|||
$('#sup_id_all').val(supIdArr); |
|||
var supplierArr = []; |
|||
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); }) |
|||
$('#supplier_all').val(supplierArr); |
|||
var quoteAmtBeArr = []; |
|||
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_be_all').val(quoteAmtBeArr); |
|||
var noteBeArr = []; |
|||
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); }) |
|||
$('#note_be_all').val(noteBeArr); |
|||
var quoteAmtArArr = []; |
|||
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_ar_all').val(quoteAmtArArr); |
|||
var noteArArr = []; |
|||
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); }) |
|||
$('#note_ar_all').val(noteArArr); |
|||
//console.log(itemNameArr); |
|||
//return false; |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<?php |
|||
include "bargain-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="bargainno">申請單號</label> |
|||
<input type="text" name="bargainno" id="bargainno" value="<?php echo $bargainno; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="department">作成單位</label> |
|||
<input type="text" name="department" id="department" value="<?php echo $department_arr[$department_id]; ?>" readonly> |
|||
<input type="hidden" name="department_id" id="department_id" value="<?php echo $department_id; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="proposer">作成者</label> |
|||
<input type="text" name="proposer" id="proposer" value="<?php echo $user_name; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="receiver">收文單位</label> |
|||
<select name="receiver" id="receiver" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($department_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="response_dt">回答期限</label><br> |
|||
<input type="date" name="response_dt" id="response_dt" required> |
|||
</div> |
|||
<div> |
|||
<label for="item">項目名稱</label> |
|||
<input type="text" name="item" id="item" size="60" maxlength="50" required> |
|||
</div> |
|||
<div> |
|||
<label for="annual">年度議價件</label> |
|||
<select name="annual" id="annual"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="urgent">緊急件</label> |
|||
<select name="urgent" id="urgent"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="vendor">指定廠商</label> |
|||
<select name="vendor" id="vendor"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="prospecting">現場勘查</label> |
|||
<select name="prospecting" id="prospecting"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="category">類別</label> |
|||
<select name="category" id="category" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="dealer">原廠或原代理商</label> |
|||
<select name="dealer" id="dealer" required> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="reason">理由</label> |
|||
<input type="text" name="reason" id="reason" size="60" maxlength="50"> |
|||
</div> |
|||
<div> |
|||
<label for="brand">品牌</label> |
|||
<input type="text" name="brand" id="brand" maxlength="25"> |
|||
</div> |
|||
<div> |
|||
<label for="model">型號</label> |
|||
<input type="text" name="model" id="model" maxlength="25"> |
|||
</div> |
|||
<div> |
|||
<label for="quantity">預估數量</label> |
|||
<input type="text" name="quantity" id="quantity" required> |
|||
</div> |
|||
<div> |
|||
<label for="brandkeep">備選品牌</label> |
|||
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25"> |
|||
</div> |
|||
<div> |
|||
<label for="lead_time">交期/施工期(天)</label> |
|||
<input type="text" name="lead_time" id="lead_time"> |
|||
</div> |
|||
<div> |
|||
<label for="margin">質保金</label> |
|||
<select name="margin" id="margin"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="margin_day">質保期限(天)</label> |
|||
<input type="text" name="margin_day" id="margin_day" required> |
|||
</div> |
|||
<div> |
|||
<label for="acceptance">驗收標準</label> |
|||
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50"> |
|||
</div> |
|||
<div> |
|||
<label for="purchase_history">歷史購買記錄</label> |
|||
<select name="purchase_history" id="purchase_history"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="attatch1">附件1</label> |
|||
<div> |
|||
<input type="file" name="attatch1" id="attatch1"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="attatch2">附件2</label> |
|||
<div> |
|||
<input type="file" name="attatch2" id="attatch2"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="item_description">項目描述</label> |
|||
<input type="text" name="item_description" id="item_description" size="80" maxlength="120"> |
|||
</div> |
|||
<div> |
|||
<label for="repairno">設備維修單號</label> |
|||
<input type="text" name="repairno" id="repairno" maxlength="20"> |
|||
</div> |
|||
<div> |
|||
<label for="category_repair">類別</label> |
|||
<select name="category_repair" id="category_repair" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="content">內容</label><br> |
|||
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"></textarea> |
|||
</div> |
|||
<div> |
|||
<label for="quotation">採購報價單</label> |
|||
<input type="text" name="quotation" id="quotation" readonly> |
|||
</div> |
|||
|
|||
<div class="table-responsive" style="width:100%;margin-top:10px;"> |
|||
<table id="tb1" class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="8"><h4>附件上傳及信息維護</h4></th> |
|||
</tr> |
|||
<tr> |
|||
<th rowspan="2" nowrap>序號</th> |
|||
<th colspan="4">作成單位提供◎維護信息</th> |
|||
<th colspan="3">配合單位提供◎維護信息</th> |
|||
</tr> |
|||
<tr> |
|||
<th nowrap>供應商名稱</th> |
|||
<th nowrap>供應商報價單上傳</th> |
|||
<th nowrap>報價</th> |
|||
<th nowrap>備註</th> |
|||
<th nowrap>議價後報價單上傳</th> |
|||
<th nowrap>議價後報價</th> |
|||
<th nowrap>備註</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr name="supplier_templ"> |
|||
<td>1</td> |
|||
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_be[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_ar[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td> |
|||
</tr> |
|||
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="submit" id="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="sup_id_all" id="sup_id_all"> |
|||
<input type="hidden" name="supplier_all" id="supplier_all"> |
|||
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all"> |
|||
<input type="hidden" name="note_be_all" id="note_be_all"> |
|||
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all"> |
|||
<input type="hidden" name="note_ar_all" id="note_ar_all"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; |
|||
|
|||
$sql = "select max(bargainno) as maxno from bargain"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$bargainno = $row[0] ? $row[0]+1 : date("Ym")."001"; |
|||
|
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
list($department_id) = $row; |
|||
mysqli_free_result($res); |
|||
|
|||
$department_arr = []; |
|||
$sql = "select department_id, name from department"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$department_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
?> |
|||
<style> |
|||
|
|||
</style> |
|||
<script> |
|||
function commafy(num) { |
|||
num = num + ""; |
|||
var re = /(-?\d+)(\d{3})/ |
|||
while (re.test(num)) { |
|||
num = num.replace(re, "$1,$2") |
|||
} |
|||
return num; |
|||
} |
|||
|
|||
$(function(){ |
|||
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$("input[name=quote_amt_be]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$("input[name=quote_amt_ar]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$('#btnadd').click(function(){ |
|||
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end()); |
|||
$('#tb1 tr:last').prev().find('td').first().html($("tr[name='supplier_templ']").length); |
|||
}); |
|||
$('#submit').click(function(){ |
|||
var supIdArr = []; |
|||
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); }) |
|||
$('#sup_id_all').val(supIdArr); |
|||
var supplierArr = []; |
|||
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); }) |
|||
$('#supplier_all').val(supplierArr); |
|||
var quoteAmtBeArr = []; |
|||
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_be_all').val(quoteAmtBeArr); |
|||
var noteBeArr = []; |
|||
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); }) |
|||
$('#note_be_all').val(noteBeArr); |
|||
var quoteAmtArArr = []; |
|||
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_ar_all').val(quoteAmtArArr); |
|||
var noteArArr = []; |
|||
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); }) |
|||
$('#note_ar_all').val(noteArArr); |
|||
//console.log(itemNameArr); |
|||
//return false; |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<?php |
|||
include "bargain-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="bargainno">申請單號</label> |
|||
<input type="text" name="bargainno" id="bargainno" value="<?php echo $bargainno; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="department">作成單位</label> |
|||
<input type="text" name="department" id="department" value="<?php echo $department_arr[$department_id]; ?>" readonly> |
|||
<input type="hidden" name="department_id" id="department_id" value="<?php echo $department_id; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="proposer">作成者</label> |
|||
<input type="text" name="proposer" id="proposer" value="<?php echo $user_name; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="receiver">收文單位</label> |
|||
<select name="receiver" id="receiver" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($department_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="response_dt">回答期限</label><br> |
|||
<input type="date" name="response_dt" id="response_dt" required> |
|||
</div> |
|||
<div> |
|||
<label for="item">項目名稱</label> |
|||
<input type="text" name="item" id="item" size="60" maxlength="50" required> |
|||
</div> |
|||
<div> |
|||
<label for="annual">年度議價件</label> |
|||
<select name="annual" id="annual"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="urgent">緊急件</label> |
|||
<select name="urgent" id="urgent"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="vendor">指定廠商</label> |
|||
<select name="vendor" id="vendor"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="prospecting">現場勘查</label> |
|||
<select name="prospecting" id="prospecting"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="category">類別</label> |
|||
<select name="category" id="category" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="dealer">原廠或原代理商</label> |
|||
<select name="dealer" id="dealer" required> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="reason">理由</label> |
|||
<input type="text" name="reason" id="reason" size="60" maxlength="50"> |
|||
</div> |
|||
<div> |
|||
<label for="brand">品牌</label> |
|||
<input type="text" name="brand" id="brand" maxlength="25"> |
|||
</div> |
|||
<div> |
|||
<label for="model">型號</label> |
|||
<input type="text" name="model" id="model" maxlength="25"> |
|||
</div> |
|||
<div> |
|||
<label for="quantity">預估數量</label> |
|||
<input type="text" name="quantity" id="quantity" required> |
|||
</div> |
|||
<div> |
|||
<label for="brandkeep">備選品牌</label> |
|||
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25"> |
|||
</div> |
|||
<div> |
|||
<label for="lead_time">交期/施工期(天)</label> |
|||
<input type="text" name="lead_time" id="lead_time"> |
|||
</div> |
|||
<div> |
|||
<label for="margin">質保金</label> |
|||
<select name="margin" id="margin"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="margin_day">質保期限(天)</label> |
|||
<input type="text" name="margin_day" id="margin_day" required> |
|||
</div> |
|||
<div> |
|||
<label for="acceptance">驗收標準</label> |
|||
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50"> |
|||
</div> |
|||
<div> |
|||
<label for="purchase_history">歷史購買記錄</label> |
|||
<select name="purchase_history" id="purchase_history"> |
|||
<option value="Y">是</option> |
|||
<option value="N">否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="attatch1">附件1</label> |
|||
<div> |
|||
<input type="file" name="attatch1" id="attatch1"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="attatch2">附件2</label> |
|||
<div> |
|||
<input type="file" name="attatch2" id="attatch2"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="item_description">項目描述</label> |
|||
<input type="text" name="item_description" id="item_description" size="80" maxlength="120"> |
|||
</div> |
|||
<div> |
|||
<label for="repairno">設備維修單號</label> |
|||
<input type="text" name="repairno" id="repairno" maxlength="20"> |
|||
</div> |
|||
<div> |
|||
<label for="category_repair">類別</label> |
|||
<select name="category_repair" id="category_repair" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="content">內容</label><br> |
|||
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"></textarea> |
|||
</div> |
|||
<div> |
|||
<label for="quotation">採購報價單</label> |
|||
<input type="text" name="quotation" id="quotation" readonly> |
|||
</div> |
|||
|
|||
<div class="table-responsive" style="width:100%;margin-top:10px;"> |
|||
<table id="tb1" class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="8"><h4>附件上傳及信息維護</h4></th> |
|||
</tr> |
|||
<tr> |
|||
<th rowspan="2" nowrap>序號</th> |
|||
<th colspan="4">作成單位提供◎維護信息</th> |
|||
<th colspan="3">配合單位提供◎維護信息</th> |
|||
</tr> |
|||
<tr> |
|||
<th nowrap>供應商名稱</th> |
|||
<th nowrap>供應商報價單上傳</th> |
|||
<th nowrap>報價</th> |
|||
<th nowrap>備註</th> |
|||
<th nowrap>議價後報價單上傳</th> |
|||
<th nowrap>議價後報價</th> |
|||
<th nowrap>備註</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr name="supplier_templ"> |
|||
<td>1</td> |
|||
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_be[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_ar[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td> |
|||
</tr> |
|||
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="submit" id="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="sup_id_all" id="sup_id_all"> |
|||
<input type="hidden" name="supplier_all" id="supplier_all"> |
|||
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all"> |
|||
<input type="hidden" name="note_be_all" id="note_be_all"> |
|||
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all"> |
|||
<input type="hidden" name="note_ar_all" id="note_ar_all"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php include "footer.php"; ?> |
@ -1,29 +1,29 @@ |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
/* 已進入簽核流程 |
|||
$db_query = "select checker_1_result from bargin where id = '$id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
$row = mysqli_fetch_array($res, MYSQLI_ASSOC); |
|||
if (!$row || $row["checker_1_result"]) { |
|||
mysqli_free_result($res); |
|||
mysqli_close($link); |
|||
echo "<script>"; |
|||
//echo "alert('審核中,已無法刪除');"; |
|||
echo "alert('資料無法刪除');"; |
|||
echo "location.href='pricereview-index.php'"; |
|||
echo "</script>"; |
|||
exit; |
|||
} |
|||
*/ |
|||
$db_query = "delete from bargain_supplier where bid = '$id'"; |
|||
if ($rs = mysqli_query($link, $db_query)) { |
|||
$db_query = "delete from bargain where id = '$id'"; |
|||
mysqli_query($link, $db_query); |
|||
} |
|||
|
|||
header("Refresh:0; url=bargain-index.php?function_name=bargain&".$token_link); |
|||
ob_end_flush(); |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
/* 已進入簽核流程 |
|||
$db_query = "select checker_1_result from bargin where id = '$id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
$row = mysqli_fetch_array($res, MYSQLI_ASSOC); |
|||
if (!$row || $row["checker_1_result"]) { |
|||
mysqli_free_result($res); |
|||
mysqli_close($link); |
|||
echo "<script>"; |
|||
//echo "alert('審核中,已無法刪除');"; |
|||
echo "alert('資料無法刪除');"; |
|||
echo "location.href='pricereview-index.php'"; |
|||
echo "</script>"; |
|||
exit; |
|||
} |
|||
*/ |
|||
$db_query = "delete from bargain_supplier where bid = '$id'"; |
|||
if ($rs = mysqli_query($link, $db_query)) { |
|||
$db_query = "delete from bargain where id = '$id'"; |
|||
mysqli_query($link, $db_query); |
|||
} |
|||
|
|||
header("Refresh:0; url=bargain-index.php?function_name=bargain&".$token_link); |
|||
ob_end_flush(); |
|||
?> |
@ -1,375 +1,375 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
|
|||
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; |
|||
|
|||
$db_query = "select * from bargain where id = '$id'"; |
|||
$data = mysqli_query($link, $db_query); |
|||
|
|||
$department_arr = []; |
|||
$sql = "select department_id, name from department"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$department_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
foreach($data as $data) : |
|||
$sql = "select name from account where accountid = '".$data['creater']."'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
list($creater_name) = $row; |
|||
mysqli_free_result($res); |
|||
|
|||
$item_arr = []; |
|||
$sql = "select * from bargain_supplier where bid = '$id' order by supplier_id"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$item_arr[$row['supplier_id']]['id'] = $row['id']; |
|||
$item_arr[$row['supplier_id']]['supplier'] = $row['supplier']; |
|||
$item_arr[$row['supplier_id']]['supplier_attatch_be'] = $row['supplier_attatch_be']; |
|||
$item_arr[$row['supplier_id']]['quote_amt_be'] = $row['quote_amt_be']; |
|||
$item_arr[$row['supplier_id']]['note_be'] = $row['note_be']; |
|||
$item_arr[$row['supplier_id']]['supplier_attatch_ar'] = $row['supplier_attatch_ar']; |
|||
$item_arr[$row['supplier_id']]['quote_amt_ar'] = $row['quote_amt_ar']; |
|||
$item_arr[$row['supplier_id']]['note_ar'] = $row['note_ar']; |
|||
} |
|||
mysqli_free_result($res); |
|||
?> |
|||
<style> |
|||
|
|||
</style> |
|||
<script> |
|||
function commafy(num) { |
|||
num = num + ""; |
|||
var re = /(-?\d+)(\d{3})/ |
|||
while (re.test(num)) { |
|||
num = num.replace(re, "$1,$2") |
|||
} |
|||
return num; |
|||
} |
|||
|
|||
$(function(){ |
|||
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$("input[name=quote_amt_be]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$("input[name=quote_amt_ar]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$('#btnadd').click(function(){ |
|||
if ($('tr[name=supplier_templ]').is(':visible') == false) $('tr[name=supplier_templ]').show(); |
|||
else { |
|||
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end()); |
|||
//$('#tb1 tr:last').find('td').first().html($("tr[name='supplier_templ']").length); |
|||
} |
|||
}); |
|||
$('#update').click(function(){ |
|||
var bsidArr = []; |
|||
$("input[name='bsid']").each(function(){ bsidArr.push($(this).val()); }) |
|||
$('#bsid_all').val(bsidArr); |
|||
var supIdArr = []; |
|||
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); }) |
|||
$('#sup_id_all').val(supIdArr); |
|||
var supplierArr = []; |
|||
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); }) |
|||
$('#supplier_all').val(supplierArr); |
|||
var supplierAttatchBeAllArr = []; |
|||
$("input[name='supplier_attatch_be']").each(function(){ supplierAttatchBeAllArr.push($(this).val()); }) |
|||
$('#supplier_attatch_be_all').val(supplierAttatchBeAllArr); |
|||
var quoteAmtBeArr = []; |
|||
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_be_all').val(quoteAmtBeArr); |
|||
var noteBeArr = []; |
|||
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); }) |
|||
$('#note_be_all').val(noteBeArr); |
|||
var supplierAttatchArArr = []; |
|||
$("input[name='supplier_attatch_ar']").each(function(){ supplierAttatchArArr.push($(this).val()); }) |
|||
$('#supplier_attatch_ar_all').val(supplierAttatchArArr); |
|||
var quoteAmtArArr = []; |
|||
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_ar_all').val(quoteAmtArArr); |
|||
var noteArArr = []; |
|||
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); }) |
|||
$('#note_ar_all').val(noteArArr); |
|||
//console.log(noteArArr); |
|||
//return false; |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="bargain-record-update.php" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="bargainno">申請單號</label> |
|||
<input type="text" name="bargainno" id="bargainno" value="<?php echo $data['bargainno']; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="department">作成單位</label> |
|||
<input type="text" name="department" id="department" value="<?php echo $department_arr[$data['department_id']]; ?>" disabled> |
|||
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data['department_id']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="proposer">作成者</label> |
|||
<input type="text" name="proposer" id="proposer" value="<?php echo $creater_name; ?>" disabled> |
|||
</div> |
|||
<div> |
|||
<label for="receiver">收文單位</label> |
|||
<select name="receiver" id="receiver" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($department_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["receiver"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="response_dt">回答期限</label><br> |
|||
<input type="date" name="response_dt" id="response_dt" value="<?php echo $data['response_dt']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="item">項目名稱</label> |
|||
<input type="text" name="item" id="item" size="60" maxlength="50" value="<?php echo $data['item']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="annual">年度議價件</label> |
|||
<select name="annual" id="annual"> |
|||
<option value="Y"<?php if ($data['annual']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['annual']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="urgent">緊急件</label> |
|||
<select name="urgent" id="urgent"> |
|||
<option value="Y"<?php if ($data['urgent']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['urgent']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="vendor">指定廠商</label> |
|||
<select name="vendor" id="vendor"> |
|||
<option value="Y"<?php if ($data['vendor']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['vendor']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="prospecting">現場勘查</label> |
|||
<select name="prospecting" id="prospecting"> |
|||
<option value="Y"<?php if ($data['prospecting']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['prospecting']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="category">類別</label> |
|||
<select name="category" id="category" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["category"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="dealer">原廠或原代理商</label> |
|||
<select name="dealer" id="dealer" required> |
|||
<option value="Y"<?php if ($data['dealer']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['dealer']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="reason">理由</label> |
|||
<input type="text" name="reason" id="reason" size="60" maxlength="50" value="<?php echo $data['reason']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="brand">品牌</label> |
|||
<input type="text" name="brand" id="brand" maxlength="25" value="<?php echo $data['brand']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="model">型號</label> |
|||
<input type="text" name="model" id="model" maxlength="25" value="<?php echo $data['model']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="quantity">預估數量</label> |
|||
<input type="text" name="quantity" id="quantity" value="<?php echo number_format($data['quantity']); ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="brandkeep">備選品牌</label> |
|||
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25" value="<?php echo $data['brandkeep']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="lead_time">交期/施工期(天)</label> |
|||
<input type="text" name="lead_time" id="lead_time" value="<?php echo number_format($data['lead_time']); ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="margin">質保金</label> |
|||
<select name="margin" id="margin"> |
|||
<option value="Y"<?php if ($data['margin']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['margin']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="margin_day">質保期限(天)</label> |
|||
<input type="text" name="margin_day" id="margin_day" value="<?php echo number_format($data['margin_day']); ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="acceptance">驗收標準</label> |
|||
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50" value="<?php echo $data['acceptance']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="purchase_history">歷史購買記錄</label> |
|||
<select name="purchase_history" id="purchase_history"> |
|||
<option value="Y"<?php if ($data['purchase_history']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['purchase_history']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="attatch1">附件1</label> |
|||
<?php |
|||
if ($data["attatch1"]) echo "<a href=\"".$data["attatch1"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)."</a>"; |
|||
?> |
|||
<div> |
|||
<input type="file" name="attatch1" id="attatch1"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="attatch2">附件2</label> |
|||
<?php |
|||
if ($data["attatch2"]) echo "<a href=\"".$data["attatch2"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)."</a>"; |
|||
?> |
|||
<div> |
|||
<input type="file" name="attatch2" id="attatch2"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="item_description">項目描述</label> |
|||
<input type="text" name="item_description" id="item_description" size="80" maxlength="120" value="<?php echo $data['item_description']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="repairno">設備維修單號</label> |
|||
<input type="text" name="repairno" id="repairno" maxlength="20" value="<?php echo $data['repairno']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="category_repair">類別</label> |
|||
<select name="category_repair" id="category_repair" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["category_repair"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="content">內容</label><br> |
|||
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"><?php echo $data['content']; ?></textarea> |
|||
</div> |
|||
<div> |
|||
<label for="quotation">採購報價單</label> |
|||
<input type="text" name="quotation" id="quotation" value="<?php echo $data['quotation']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div class="table-responsive" style="width:100%;margin-top:10px;"> |
|||
<table id="tb1" class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="8"><h4>附件上傳及信息維護</h4></th> |
|||
</tr> |
|||
<tr> |
|||
<th rowspan="2" nowrap>序號</th> |
|||
<th colspan="4">作成單位提供◎維護信息</th> |
|||
<th colspan="3">配合單位提供◎維護信息</th> |
|||
</tr> |
|||
<tr> |
|||
<th nowrap>供應商名稱</th> |
|||
<th nowrap>供應商報價單上傳</th> |
|||
<th nowrap>報價</th> |
|||
<th nowrap>備註</th> |
|||
<th nowrap>議價後報價單上傳</th> |
|||
<th nowrap>議價後報價</th> |
|||
<th nowrap>備註</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach ($item_arr as $supplier_id => $val) { |
|||
?> |
|||
<tr> |
|||
<td><?php echo $supplier_id; ?><input type="hidden" name="sup_id" value="<?php echo $supplier_id; ?>"><input type="hidden" name="bsid" value="<?php echo $val['id']; ?>"></td> |
|||
<td><input type="text" name="supplier" class="form-control input-sm" size="10" value="<?php echo $val['supplier']; ?>"></td> |
|||
<td> |
|||
<?php |
|||
if ($val['supplier_attatch_be']) echo "<a href=\"".$val['supplier_attatch_be']."\" target=\"_blank\">".substr($val['supplier_attatch_be'], strrpos($val['supplier_attatch_be'],"/")+1)."</a>"; |
|||
else echo "--"; |
|||
?> |
|||
</td> |
|||
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_be']); ?>"></td> |
|||
<td><input type="text" name="note_be" class="form-control input-sm" size="10" value="<?php echo $val['note_be']; ?>"></td> |
|||
<td> |
|||
<?php |
|||
if ($val['supplier_attatch_ar']) echo "<a href=\"".$val['supplier_attatch_ar']."\" target=\"_blank\">".substr($val['supplier_attatch_ar'], strrpos($val['supplier_attatch_ar'],"/")+1)."</a>"; |
|||
else echo "--"; |
|||
?> |
|||
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_ar']); ?>"></td> |
|||
<td><input type="text" name="note_ar" class="form-control input-sm" size="10" value="<?php echo $val['note_ar']; ?>"></td> |
|||
</tr> |
|||
<?php |
|||
} |
|||
|
|||
?> |
|||
<tr name="supplier_templ" style="display:none;"> |
|||
<td></td> |
|||
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_be[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_ar[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td> |
|||
</tr> |
|||
</tr> |
|||
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update" id="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="bsid_all" id="bsid_all"> |
|||
<input type="hidden" name="sup_id_all" id="sup_id_all"> |
|||
<input type="hidden" name="supplier_all" id="supplier_all"> |
|||
<input type="hidden" name="supplier_attatch_be_all" id="supplier_attatch_be_all"> |
|||
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all"> |
|||
<input type="hidden" name="note_be_all" id="note_be_all"> |
|||
<input type="hidden" name="supplier_attatch_ar_all" id="supplier_attatch_ar_all"> |
|||
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all"> |
|||
<input type="hidden" name="note_ar_all" id="note_ar_all"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
<?php |
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
|
|||
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; |
|||
|
|||
$db_query = "select * from bargain where id = '$id'"; |
|||
$data = mysqli_query($link, $db_query); |
|||
|
|||
$department_arr = []; |
|||
$sql = "select department_id, name from department"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$department_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
foreach($data as $data) : |
|||
$sql = "select name from account where accountid = '".$data['creater']."'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
list($creater_name) = $row; |
|||
mysqli_free_result($res); |
|||
|
|||
$item_arr = []; |
|||
$sql = "select * from bargain_supplier where bid = '$id' order by supplier_id"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_assoc($res)) { |
|||
$item_arr[$row['supplier_id']]['id'] = $row['id']; |
|||
$item_arr[$row['supplier_id']]['supplier'] = $row['supplier']; |
|||
$item_arr[$row['supplier_id']]['supplier_attatch_be'] = $row['supplier_attatch_be']; |
|||
$item_arr[$row['supplier_id']]['quote_amt_be'] = $row['quote_amt_be']; |
|||
$item_arr[$row['supplier_id']]['note_be'] = $row['note_be']; |
|||
$item_arr[$row['supplier_id']]['supplier_attatch_ar'] = $row['supplier_attatch_ar']; |
|||
$item_arr[$row['supplier_id']]['quote_amt_ar'] = $row['quote_amt_ar']; |
|||
$item_arr[$row['supplier_id']]['note_ar'] = $row['note_ar']; |
|||
} |
|||
mysqli_free_result($res); |
|||
?> |
|||
<style> |
|||
|
|||
</style> |
|||
<script> |
|||
function commafy(num) { |
|||
num = num + ""; |
|||
var re = /(-?\d+)(\d{3})/ |
|||
while (re.test(num)) { |
|||
num = num.replace(re, "$1,$2") |
|||
} |
|||
return num; |
|||
} |
|||
|
|||
$(function(){ |
|||
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) |
|||
$("input[name=quote_amt_be]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$("input[name=quote_amt_ar]").each(function(){ |
|||
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); |
|||
}); |
|||
$('#btnadd').click(function(){ |
|||
if ($('tr[name=supplier_templ]').is(':visible') == false) $('tr[name=supplier_templ]').show(); |
|||
else { |
|||
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end()); |
|||
//$('#tb1 tr:last').find('td').first().html($("tr[name='supplier_templ']").length); |
|||
} |
|||
}); |
|||
$('#update').click(function(){ |
|||
var bsidArr = []; |
|||
$("input[name='bsid']").each(function(){ bsidArr.push($(this).val()); }) |
|||
$('#bsid_all').val(bsidArr); |
|||
var supIdArr = []; |
|||
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); }) |
|||
$('#sup_id_all').val(supIdArr); |
|||
var supplierArr = []; |
|||
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); }) |
|||
$('#supplier_all').val(supplierArr); |
|||
var supplierAttatchBeAllArr = []; |
|||
$("input[name='supplier_attatch_be']").each(function(){ supplierAttatchBeAllArr.push($(this).val()); }) |
|||
$('#supplier_attatch_be_all').val(supplierAttatchBeAllArr); |
|||
var quoteAmtBeArr = []; |
|||
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_be_all').val(quoteAmtBeArr); |
|||
var noteBeArr = []; |
|||
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); }) |
|||
$('#note_be_all').val(noteBeArr); |
|||
var supplierAttatchArArr = []; |
|||
$("input[name='supplier_attatch_ar']").each(function(){ supplierAttatchArArr.push($(this).val()); }) |
|||
$('#supplier_attatch_ar_all').val(supplierAttatchArArr); |
|||
var quoteAmtArArr = []; |
|||
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); }) |
|||
$('#quote_amt_ar_all').val(quoteAmtArArr); |
|||
var noteArArr = []; |
|||
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); }) |
|||
$('#note_ar_all').val(noteArArr); |
|||
//console.log(noteArArr); |
|||
//return false; |
|||
}); |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="bargain-record-update.php" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="bargainno">申請單號</label> |
|||
<input type="text" name="bargainno" id="bargainno" value="<?php echo $data['bargainno']; ?>" readonly> |
|||
</div> |
|||
<div> |
|||
<label for="department">作成單位</label> |
|||
<input type="text" name="department" id="department" value="<?php echo $department_arr[$data['department_id']]; ?>" disabled> |
|||
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data['department_id']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="proposer">作成者</label> |
|||
<input type="text" name="proposer" id="proposer" value="<?php echo $creater_name; ?>" disabled> |
|||
</div> |
|||
<div> |
|||
<label for="receiver">收文單位</label> |
|||
<select name="receiver" id="receiver" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($department_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["receiver"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="response_dt">回答期限</label><br> |
|||
<input type="date" name="response_dt" id="response_dt" value="<?php echo $data['response_dt']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="item">項目名稱</label> |
|||
<input type="text" name="item" id="item" size="60" maxlength="50" value="<?php echo $data['item']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="annual">年度議價件</label> |
|||
<select name="annual" id="annual"> |
|||
<option value="Y"<?php if ($data['annual']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['annual']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="urgent">緊急件</label> |
|||
<select name="urgent" id="urgent"> |
|||
<option value="Y"<?php if ($data['urgent']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['urgent']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="vendor">指定廠商</label> |
|||
<select name="vendor" id="vendor"> |
|||
<option value="Y"<?php if ($data['vendor']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['vendor']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="prospecting">現場勘查</label> |
|||
<select name="prospecting" id="prospecting"> |
|||
<option value="Y"<?php if ($data['prospecting']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['prospecting']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="category">類別</label> |
|||
<select name="category" id="category" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["category"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="dealer">原廠或原代理商</label> |
|||
<select name="dealer" id="dealer" required> |
|||
<option value="Y"<?php if ($data['dealer']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['dealer']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="reason">理由</label> |
|||
<input type="text" name="reason" id="reason" size="60" maxlength="50" value="<?php echo $data['reason']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="brand">品牌</label> |
|||
<input type="text" name="brand" id="brand" maxlength="25" value="<?php echo $data['brand']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="model">型號</label> |
|||
<input type="text" name="model" id="model" maxlength="25" value="<?php echo $data['model']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="quantity">預估數量</label> |
|||
<input type="text" name="quantity" id="quantity" value="<?php echo number_format($data['quantity']); ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="brandkeep">備選品牌</label> |
|||
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25" value="<?php echo $data['brandkeep']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="lead_time">交期/施工期(天)</label> |
|||
<input type="text" name="lead_time" id="lead_time" value="<?php echo number_format($data['lead_time']); ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="margin">質保金</label> |
|||
<select name="margin" id="margin"> |
|||
<option value="Y"<?php if ($data['margin']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['margin']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="margin_day">質保期限(天)</label> |
|||
<input type="text" name="margin_day" id="margin_day" value="<?php echo number_format($data['margin_day']); ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="acceptance">驗收標準</label> |
|||
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50" value="<?php echo $data['acceptance']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="purchase_history">歷史購買記錄</label> |
|||
<select name="purchase_history" id="purchase_history"> |
|||
<option value="Y"<?php if ($data['purchase_history']=="Y") echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data['purchase_history']=="N") echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="attatch1">附件1</label> |
|||
<?php |
|||
if ($data["attatch1"]) echo "<a href=\"".$data["attatch1"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)."</a>"; |
|||
?> |
|||
<div> |
|||
<input type="file" name="attatch1" id="attatch1"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="attatch2">附件2</label> |
|||
<?php |
|||
if ($data["attatch2"]) echo "<a href=\"".$data["attatch2"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)."</a>"; |
|||
?> |
|||
<div> |
|||
<input type="file" name="attatch2" id="attatch2"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="item_description">項目描述</label> |
|||
<input type="text" name="item_description" id="item_description" size="80" maxlength="120" value="<?php echo $data['item_description']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="repairno">設備維修單號</label> |
|||
<input type="text" name="repairno" id="repairno" maxlength="20" value="<?php echo $data['repairno']; ?>"> |
|||
</div> |
|||
<div> |
|||
<label for="category_repair">類別</label> |
|||
<select name="category_repair" id="category_repair" required> |
|||
<option value="">請選擇</option> |
|||
<?php |
|||
foreach ($category_arr as $k => $v) { |
|||
echo "<option value=\"".$k."\""; |
|||
if ($data["category_repair"] == $k) echo " selected"; |
|||
echo ">".$v."</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="content">內容</label><br> |
|||
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"><?php echo $data['content']; ?></textarea> |
|||
</div> |
|||
<div> |
|||
<label for="quotation">採購報價單</label> |
|||
<input type="text" name="quotation" id="quotation" value="<?php echo $data['quotation']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div class="table-responsive" style="width:100%;margin-top:10px;"> |
|||
<table id="tb1" class="table table-bordered"> |
|||
<thead> |
|||
<tr> |
|||
<th colspan="8"><h4>附件上傳及信息維護</h4></th> |
|||
</tr> |
|||
<tr> |
|||
<th rowspan="2" nowrap>序號</th> |
|||
<th colspan="4">作成單位提供◎維護信息</th> |
|||
<th colspan="3">配合單位提供◎維護信息</th> |
|||
</tr> |
|||
<tr> |
|||
<th nowrap>供應商名稱</th> |
|||
<th nowrap>供應商報價單上傳</th> |
|||
<th nowrap>報價</th> |
|||
<th nowrap>備註</th> |
|||
<th nowrap>議價後報價單上傳</th> |
|||
<th nowrap>議價後報價</th> |
|||
<th nowrap>備註</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach ($item_arr as $supplier_id => $val) { |
|||
?> |
|||
<tr> |
|||
<td><?php echo $supplier_id; ?><input type="hidden" name="sup_id" value="<?php echo $supplier_id; ?>"><input type="hidden" name="bsid" value="<?php echo $val['id']; ?>"></td> |
|||
<td><input type="text" name="supplier" class="form-control input-sm" size="10" value="<?php echo $val['supplier']; ?>"></td> |
|||
<td> |
|||
<?php |
|||
if ($val['supplier_attatch_be']) echo "<a href=\"".$val['supplier_attatch_be']."\" target=\"_blank\">".substr($val['supplier_attatch_be'], strrpos($val['supplier_attatch_be'],"/")+1)."</a>"; |
|||
else echo "--"; |
|||
?> |
|||
</td> |
|||
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_be']); ?>"></td> |
|||
<td><input type="text" name="note_be" class="form-control input-sm" size="10" value="<?php echo $val['note_be']; ?>"></td> |
|||
<td> |
|||
<?php |
|||
if ($val['supplier_attatch_ar']) echo "<a href=\"".$val['supplier_attatch_ar']."\" target=\"_blank\">".substr($val['supplier_attatch_ar'], strrpos($val['supplier_attatch_ar'],"/")+1)."</a>"; |
|||
else echo "--"; |
|||
?> |
|||
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_ar']); ?>"></td> |
|||
<td><input type="text" name="note_ar" class="form-control input-sm" size="10" value="<?php echo $val['note_ar']; ?>"></td> |
|||
</tr> |
|||
<?php |
|||
} |
|||
|
|||
?> |
|||
<tr name="supplier_templ" style="display:none;"> |
|||
<td></td> |
|||
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_be[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td> |
|||
<td><input type="file" name="supplier_attatch_ar[]" multiple></td> |
|||
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td> |
|||
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td> |
|||
</tr> |
|||
</tr> |
|||
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update" id="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="bsid_all" id="bsid_all"> |
|||
<input type="hidden" name="sup_id_all" id="sup_id_all"> |
|||
<input type="hidden" name="supplier_all" id="supplier_all"> |
|||
<input type="hidden" name="supplier_attatch_be_all" id="supplier_attatch_be_all"> |
|||
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all"> |
|||
<input type="hidden" name="note_be_all" id="note_be_all"> |
|||
<input type="hidden" name="supplier_attatch_ar_all" id="supplier_attatch_ar_all"> |
|||
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all"> |
|||
<input type="hidden" name="note_ar_all" id="note_ar_all"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
<?php |
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
?> |
@ -1,144 +1,144 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
|
|||
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; |
|||
|
|||
$sql = "select department_id, name from department"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$department_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// sql語法存在變數中 |
|||
$sql = "select * from bargain order by id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<p> |
|||
<a href="bargain-create.php?function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
if($data): |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:bargain-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>型號</th> |
|||
<th>預估數量</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<th>修改</th> |
|||
<th>刪除</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['bargainno']; ?></td> |
|||
<td><?php echo $department_arr[$data['department_id']]; ?></td> |
|||
<td><?php echo $data['proposer']; ?></td> |
|||
<td><?php echo $department_arr[$data['receiver']]; ?></td> |
|||
<td><?php echo $data['response_dt']; ?></td> |
|||
<td><?php echo $data['item']; ?></td> |
|||
<td><?php echo $category_arr[$data['category']]; ?></td> |
|||
<td><?php echo $data['brand']; ?></td> |
|||
<td><?php echo $data['model']; ?></td> |
|||
<td><?php echo number_format($data['quantity']); ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<p> |
|||
<a href="bargain-edit.php?id=<?php echo $data['id']; ?>&function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td> |
|||
<p> |
|||
<a href="bargain-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
|
|||
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; |
|||
|
|||
$sql = "select department_id, name from department"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$department_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
// sql語法存在變數中 |
|||
$sql = "select * from bargain order by id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<p> |
|||
<a href="bargain-create.php?function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
if($data): |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:bargain-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>型號</th> |
|||
<th>預估數量</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<th>修改</th> |
|||
<th>刪除</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['bargainno']; ?></td> |
|||
<td><?php echo $department_arr[$data['department_id']]; ?></td> |
|||
<td><?php echo $data['proposer']; ?></td> |
|||
<td><?php echo $department_arr[$data['receiver']]; ?></td> |
|||
<td><?php echo $data['response_dt']; ?></td> |
|||
<td><?php echo $data['item']; ?></td> |
|||
<td><?php echo $category_arr[$data['category']]; ?></td> |
|||
<td><?php echo $data['brand']; ?></td> |
|||
<td><?php echo $data['model']; ?></td> |
|||
<td><?php echo number_format($data['quantity']); ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<p> |
|||
<a href="bargain-edit.php?id=<?php echo $data['id']; ?>&function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td> |
|||
<p> |
|||
<a href="bargain-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
?> |
@ -1,149 +1,149 @@ |
|||
<?php |
|||
$accountid= ""; |
|||
$facilityno= ""; |
|||
$issue_time= ""; |
|||
$process= ""; |
|||
$memo= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
$accountid_error= ""; |
|||
$facilityno_error= ""; |
|||
$issue_time_error= ""; |
|||
$process_error= ""; |
|||
$memo_error= ""; |
|||
$creater_error= ""; |
|||
$create_at_error= ""; |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
//print_r($_POST); |
|||
//print_r($_FILES);exit; |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
|
|||
$sql = "select max(bargainno) as maxno from bargain"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$bargainno_check = $row[0] ? $row[0]+1 : date("Ym")."001"; |
|||
if ($bargainno_check <> $bargainno) $bargainno = $bargainno_check; |
|||
|
|||
if ($_FILES["attatch1"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch1"]["name"]; |
|||
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch1"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file1)) unlink($target_file1); |
|||
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); |
|||
} else $target_file1 = ""; |
|||
|
|||
if ($_FILES["attatch2"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch2"]["name"]; |
|||
$temp_file_name = $_FILES["attatch2"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch2"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file2)) unlink($target_file2); |
|||
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); |
|||
} else $target_file2 = ""; |
|||
|
|||
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,資料請重建。');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$db_query = "insert into bargain (bargainno, department_id, proposer, receiver, response_dt, item, annual, urgent, vendor, prospecting, category, "; |
|||
$db_query .= "dealer, reason, brand, model, quantity, brandkeep, lead_time, margin, margin_day, acceptance, purchase_history, "; |
|||
$db_query .= "attatch1, attatch2, item_description, repairno, category_repair, content, quotation, creater, create_at) values ("; |
|||
$db_query .= "'$bargainno', '$department_id', '$proposer', '$receiver', '$response_dt', '$item', '$annual', '$urgent', '$vendor', '$prospecting', '$category', "; |
|||
$db_query .= "'$dealer', '$reason', '$brand', '$model', '$quantity', '$brandkeep', '$lead_time', '$margin', '$margin_day', '$acceptance', '$purchase_history', "; |
|||
$db_query .= "'$target_file1', '$target_file2', '$item_description', '$repairno', '$category_repair', '$content', '$quotation', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
if ($result && $sup_id_all != "") { |
|||
$bid = mysqli_insert_id($link); |
|||
$sup_id_arr = explode(",", $sup_id_all); |
|||
$supplier_arr = explode(",", $supplier_all); |
|||
$quote_amt_be_arr = explode(",", $quote_amt_be_all); |
|||
$note_be_arr = explode(",", $note_be_all); |
|||
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all); |
|||
$note_ar_arr = explode(",", $note_ar_all); |
|||
$item_no = 1; |
|||
|
|||
for ($i=0; $i<count($supplier_arr); $i++) { |
|||
if (!$sup_id_arr[$i]) $sup_id_arr[$i] = 0; |
|||
if (!$supplier_arr[$i]) continue; |
|||
|
|||
if ($_FILES["supplier_attatch_be"]["name"][$i] && ($_FILES["supplier_attatch_be"]["error"][$i] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_be"]["name"][$i]; |
|||
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$i]; |
|||
$file_size = $_FILES["supplier_attatch_be"]["size"][$i]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_be = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION); |
|||
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be); |
|||
} else $target_file_be = ""; |
|||
|
|||
if ($_FILES["supplier_attatch_ar"]["name"][$i] && ($_FILES["supplier_attatch_ar"]["error"][$i] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_ar"]["name"][$i]; |
|||
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$i]; |
|||
$file_size = $_FILES["supplier_attatch_ar"]["size"][$i]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_ar = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION); |
|||
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar); |
|||
} else $target_file_ar = ""; |
|||
|
|||
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) { |
|||
$sql = "delete from bargain where id = '$bid'"; |
|||
mysqli_query($link, $sql); |
|||
$sql = "delete from bargain_supplier where bid = '$bid'"; |
|||
mysqli_query($link, $sql); |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,資料請重建!".$sql."');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$quote_amt_be_arr[$i] = str_replace(",", "", $quote_amt_be_arr[$i]); |
|||
$quote_amt_ar_all[$i] = str_replace(",", "", $quote_amt_ar_all[$i]); |
|||
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, "; |
|||
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values ("; |
|||
$db_query .= "'$bid', '$item_no', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', "; |
|||
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$item_no++; |
|||
} |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('新增成功(申請單號:".$bargainno.")');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
<?php |
|||
$accountid= ""; |
|||
$facilityno= ""; |
|||
$issue_time= ""; |
|||
$process= ""; |
|||
$memo= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
$accountid_error= ""; |
|||
$facilityno_error= ""; |
|||
$issue_time_error= ""; |
|||
$process_error= ""; |
|||
$memo_error= ""; |
|||
$creater_error= ""; |
|||
$create_at_error= ""; |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
//print_r($_POST); |
|||
//print_r($_FILES);exit; |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
|
|||
$sql = "select max(bargainno) as maxno from bargain"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$bargainno_check = $row[0] ? $row[0]+1 : date("Ym")."001"; |
|||
if ($bargainno_check <> $bargainno) $bargainno = $bargainno_check; |
|||
|
|||
if ($_FILES["attatch1"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch1"]["name"]; |
|||
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch1"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file1)) unlink($target_file1); |
|||
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); |
|||
} else $target_file1 = ""; |
|||
|
|||
if ($_FILES["attatch2"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch2"]["name"]; |
|||
$temp_file_name = $_FILES["attatch2"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch2"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file2)) unlink($target_file2); |
|||
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); |
|||
} else $target_file2 = ""; |
|||
|
|||
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,資料請重建。');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$db_query = "insert into bargain (bargainno, department_id, proposer, receiver, response_dt, item, annual, urgent, vendor, prospecting, category, "; |
|||
$db_query .= "dealer, reason, brand, model, quantity, brandkeep, lead_time, margin, margin_day, acceptance, purchase_history, "; |
|||
$db_query .= "attatch1, attatch2, item_description, repairno, category_repair, content, quotation, creater, create_at) values ("; |
|||
$db_query .= "'$bargainno', '$department_id', '$proposer', '$receiver', '$response_dt', '$item', '$annual', '$urgent', '$vendor', '$prospecting', '$category', "; |
|||
$db_query .= "'$dealer', '$reason', '$brand', '$model', '$quantity', '$brandkeep', '$lead_time', '$margin', '$margin_day', '$acceptance', '$purchase_history', "; |
|||
$db_query .= "'$target_file1', '$target_file2', '$item_description', '$repairno', '$category_repair', '$content', '$quotation', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
if ($result && $sup_id_all != "") { |
|||
$bid = mysqli_insert_id($link); |
|||
$sup_id_arr = explode(",", $sup_id_all); |
|||
$supplier_arr = explode(",", $supplier_all); |
|||
$quote_amt_be_arr = explode(",", $quote_amt_be_all); |
|||
$note_be_arr = explode(",", $note_be_all); |
|||
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all); |
|||
$note_ar_arr = explode(",", $note_ar_all); |
|||
$item_no = 1; |
|||
|
|||
for ($i=0; $i<count($supplier_arr); $i++) { |
|||
if (!$sup_id_arr[$i]) $sup_id_arr[$i] = 0; |
|||
if (!$supplier_arr[$i]) continue; |
|||
|
|||
if ($_FILES["supplier_attatch_be"]["name"][$i] && ($_FILES["supplier_attatch_be"]["error"][$i] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_be"]["name"][$i]; |
|||
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$i]; |
|||
$file_size = $_FILES["supplier_attatch_be"]["size"][$i]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_be = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION); |
|||
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be); |
|||
} else $target_file_be = ""; |
|||
|
|||
if ($_FILES["supplier_attatch_ar"]["name"][$i] && ($_FILES["supplier_attatch_ar"]["error"][$i] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_ar"]["name"][$i]; |
|||
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$i]; |
|||
$file_size = $_FILES["supplier_attatch_ar"]["size"][$i]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_ar = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION); |
|||
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar); |
|||
} else $target_file_ar = ""; |
|||
|
|||
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) { |
|||
$sql = "delete from bargain where id = '$bid'"; |
|||
mysqli_query($link, $sql); |
|||
$sql = "delete from bargain_supplier where bid = '$bid'"; |
|||
mysqli_query($link, $sql); |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,資料請重建!".$sql."');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$quote_amt_be_arr[$i] = str_replace(",", "", $quote_amt_be_arr[$i]); |
|||
$quote_amt_ar_all[$i] = str_replace(",", "", $quote_amt_ar_all[$i]); |
|||
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, "; |
|||
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values ("; |
|||
$db_query .= "'$bid', '$item_no', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', "; |
|||
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$item_no++; |
|||
} |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('新增成功(申請單號:".$bargainno.")');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
@ -1,144 +1,144 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if (isset($_POST['update'])) { |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
//print_r($_POST); |
|||
//print_r($_FILES);exit; |
|||
|
|||
$sql_atta = ""; |
|||
|
|||
$quantity = str_replace(",", "", $quantity); |
|||
$lead_time = str_replace(",", "", $lead_time); |
|||
$margin_day = str_replace(",", "", $margin_day); |
|||
|
|||
if ($_FILES["attatch1"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch1"]["name"]; |
|||
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch1"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file1)) unlink($target_file1); |
|||
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); |
|||
$sql_atta .= "attatch1 = '$target_file1', "; |
|||
} else $target_file1 = ""; |
|||
|
|||
if ($_FILES["attatch2"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch2"]["name"]; |
|||
$temp_file_name = $_FILES["attatch2"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch2"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file2)) unlink($target_file2); |
|||
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); |
|||
$sql_atta .= "attatch2 = '$target_file2', "; |
|||
} else $target_file2 = ""; |
|||
|
|||
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,請重新操作。');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$db_query = "update bargain set receiver = '$receiver', response_dt = '$response_dt', item = '$item', annual = '$annual', urgent = '$urgent', "; |
|||
$db_query .= "vendor = '$vendor', prospecting = '$prospecting', category = '$category', dealer = '$dealer', reason = '$reason', brand = '$brand', "; |
|||
$db_query .= "model = '$model', quantity = '$quantity', brandkeep = '$brandkeep', lead_time = '$lead_time', margin = '$margin', margin_day = '$margin_day', "; |
|||
$db_query .= "acceptance = '$acceptance', purchase_history = '$purchase_history', item_description = '$item_description', repairno = '$repairno', "; |
|||
$db_query .= $sql_atta; |
|||
$db_query .= "category_repair = '$category_repair', content = '$content', quotation = '$quotation', create_dt = '$create_at' "; |
|||
$db_query .= "where id = '$id'"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
if ($result && $sup_id_all != "") { |
|||
$bsid_arr = explode(",", $bsid_all); |
|||
$sup_id_arr = explode(",", $sup_id_all); |
|||
$supplier_arr = explode(",", rtrim($supplier_all, ",")); |
|||
$quote_amt_be_arr = explode(",", $quote_amt_be_all); |
|||
$note_be_arr = explode(",", $note_be_all); |
|||
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all); |
|||
$note_ar_arr = explode(",", $note_ar_all); |
|||
$item_no = 1; |
|||
|
|||
// 有新增的供應商 |
|||
$new_sup_cnt = count($supplier_arr) - count($bsid_arr); |
|||
if ($new_sup_cnt > 0) $next_sup_id = max($sup_id_arr)+1; |
|||
$idx = 0; |
|||
for ($i=0; $i<count($supplier_arr); $i++) { |
|||
if ($new_sup_cnt > 0 && $bsid_arr[$i] == "") { // 新增 |
|||
$target_file_be = $target_file_ar = ""; |
|||
if ($_FILES["supplier_attatch_be"]["name"]) { // 有上傳檔案 |
|||
if ($_FILES["supplier_attatch_be"]["name"][$idx] && ($_FILES["supplier_attatch_be"]["error"][$idx] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_be"]["name"][$idx]; |
|||
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$idx]; |
|||
$file_size = $_FILES["supplier_attatch_be"]["size"][$idx]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_be = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION); |
|||
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be); |
|||
} |
|||
} |
|||
if ($_FILES["supplier_attatch_ar"]["name"]) { // 有上傳檔案 |
|||
if ($_FILES["supplier_attatch_ar"]["name"][$idx] && ($_FILES["supplier_attatch_ar"]["error"][$idx] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_ar"]["name"][$idx]; |
|||
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$idx]; |
|||
$file_size = $_FILES["supplier_attatch_ar"]["size"][$idx]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_ar = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION); |
|||
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar); |
|||
} |
|||
} |
|||
if ($upload_res_be || $upload_res_ar) $idx++; |
|||
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,請重新操作!".$sql."');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, "; |
|||
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values ("; |
|||
$db_query .= "'$id', '$next_sup_id', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', "; |
|||
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$next_sup_id++; |
|||
} else { // 修改(不支援重傳檔案) |
|||
$db_query = "update bargain_supplier set supplier = '$supplier_arr[$i]', quote_amt_be = '$quote_amt_be_arr[$i]', "; |
|||
$db_query .= "note_be = '$note_be_arr[$i]', quote_amt_ar = '$quote_amt_ar_arr[$i]', "; |
|||
$db_query .= "note_ar = '$note_ar_arr[$i]', create_at = '$create_at' "; |
|||
$db_query .= "where id = '$bsid_arr[$i]'"; |
|||
$result = mysqli_query($link, $db_query); |
|||
} |
|||
} |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if (isset($_POST['update'])) { |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
//print_r($_POST); |
|||
//print_r($_FILES);exit; |
|||
|
|||
$sql_atta = ""; |
|||
|
|||
$quantity = str_replace(",", "", $quantity); |
|||
$lead_time = str_replace(",", "", $lead_time); |
|||
$margin_day = str_replace(",", "", $margin_day); |
|||
|
|||
if ($_FILES["attatch1"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch1"]["name"]; |
|||
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch1"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file1)) unlink($target_file1); |
|||
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); |
|||
$sql_atta .= "attatch1 = '$target_file1', "; |
|||
} else $target_file1 = ""; |
|||
|
|||
if ($_FILES["attatch2"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch2"]["name"]; |
|||
$temp_file_name = $_FILES["attatch2"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch2"]["size"]; |
|||
$target_dir = "bargain-uploads/"; |
|||
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
//if (file_exists($target_file2)) unlink($target_file2); |
|||
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) { |
|||
unlink($todelfile); |
|||
} |
|||
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); |
|||
$sql_atta .= "attatch2 = '$target_file2', "; |
|||
} else $target_file2 = ""; |
|||
|
|||
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,請重新操作。');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$db_query = "update bargain set receiver = '$receiver', response_dt = '$response_dt', item = '$item', annual = '$annual', urgent = '$urgent', "; |
|||
$db_query .= "vendor = '$vendor', prospecting = '$prospecting', category = '$category', dealer = '$dealer', reason = '$reason', brand = '$brand', "; |
|||
$db_query .= "model = '$model', quantity = '$quantity', brandkeep = '$brandkeep', lead_time = '$lead_time', margin = '$margin', margin_day = '$margin_day', "; |
|||
$db_query .= "acceptance = '$acceptance', purchase_history = '$purchase_history', item_description = '$item_description', repairno = '$repairno', "; |
|||
$db_query .= $sql_atta; |
|||
$db_query .= "category_repair = '$category_repair', content = '$content', quotation = '$quotation', create_dt = '$create_at' "; |
|||
$db_query .= "where id = '$id'"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
if ($result && $sup_id_all != "") { |
|||
$bsid_arr = explode(",", $bsid_all); |
|||
$sup_id_arr = explode(",", $sup_id_all); |
|||
$supplier_arr = explode(",", rtrim($supplier_all, ",")); |
|||
$quote_amt_be_arr = explode(",", $quote_amt_be_all); |
|||
$note_be_arr = explode(",", $note_be_all); |
|||
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all); |
|||
$note_ar_arr = explode(",", $note_ar_all); |
|||
$item_no = 1; |
|||
|
|||
// 有新增的供應商 |
|||
$new_sup_cnt = count($supplier_arr) - count($bsid_arr); |
|||
if ($new_sup_cnt > 0) $next_sup_id = max($sup_id_arr)+1; |
|||
$idx = 0; |
|||
for ($i=0; $i<count($supplier_arr); $i++) { |
|||
if ($new_sup_cnt > 0 && $bsid_arr[$i] == "") { // 新增 |
|||
$target_file_be = $target_file_ar = ""; |
|||
if ($_FILES["supplier_attatch_be"]["name"]) { // 有上傳檔案 |
|||
if ($_FILES["supplier_attatch_be"]["name"][$idx] && ($_FILES["supplier_attatch_be"]["error"][$idx] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_be"]["name"][$idx]; |
|||
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$idx]; |
|||
$file_size = $_FILES["supplier_attatch_be"]["size"][$idx]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_be = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION); |
|||
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be); |
|||
} |
|||
} |
|||
if ($_FILES["supplier_attatch_ar"]["name"]) { // 有上傳檔案 |
|||
if ($_FILES["supplier_attatch_ar"]["name"][$idx] && ($_FILES["supplier_attatch_ar"]["error"][$idx] == 0)) { |
|||
$file_name = $_FILES["supplier_attatch_ar"]["name"][$idx]; |
|||
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$idx]; |
|||
$file_size = $_FILES["supplier_attatch_ar"]["size"][$idx]; |
|||
$target_dir = "bargain-uploads/supplier/"; |
|||
$target_file_ar = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name)); |
|||
$upload_ok = 1; |
|||
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION); |
|||
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar); |
|||
} |
|||
} |
|||
if ($upload_res_be || $upload_res_ar) $idx++; |
|||
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,請重新操作!".$sql."');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} |
|||
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, "; |
|||
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values ("; |
|||
$db_query .= "'$id', '$next_sup_id', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', "; |
|||
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$next_sup_id++; |
|||
} else { // 修改(不支援重傳檔案) |
|||
$db_query = "update bargain_supplier set supplier = '$supplier_arr[$i]', quote_amt_be = '$quote_amt_be_arr[$i]', "; |
|||
$db_query .= "note_be = '$note_be_arr[$i]', quote_amt_ar = '$quote_amt_ar_arr[$i]', "; |
|||
$db_query .= "note_ar = '$note_ar_arr[$i]', create_at = '$create_at' "; |
|||
$db_query .= "where id = '$bsid_arr[$i]'"; |
|||
$result = mysqli_query($link, $db_query); |
|||
} |
|||
} |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
@ -1,23 +1,23 @@ |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "update board set status = 'N', create_at = NOW() where id = '$id' and creater = '$user_id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
/* |
|||
$db_query = "select attach from board where id = '$id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
$row = mysqli_fetch_row($res); |
|||
$target_file = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
$db_query = "delete from board where id = '$id'"; |
|||
mysqli_query($link, $db_query); |
|||
unlink($target_file); |
|||
*/ |
|||
//header("Location:board-index.php"); |
|||
header("Refresh:0; url=board-index.php?function_name=board&".$token_link); |
|||
ob_end_flush(); |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "update board set status = 'N', create_at = NOW() where id = '$id' and creater = '$user_id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
/* |
|||
$db_query = "select attach from board where id = '$id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
$row = mysqli_fetch_row($res); |
|||
$target_file = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
$db_query = "delete from board where id = '$id'"; |
|||
mysqli_query($link, $db_query); |
|||
unlink($target_file); |
|||
*/ |
|||
//header("Location:board-index.php"); |
|||
header("Refresh:0; url=board-index.php?function_name=board&".$token_link); |
|||
ob_end_flush(); |
|||
?> |
@ -1,60 +1,60 @@ |
|||
<?php |
|||
exit; |
|||
require_once "database.php"; |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "select * from board where id = '$id'"; |
|||
$data = mysqli_query($link, $db_query); |
|||
|
|||
foreach($data as $data) : |
|||
?> |
|||
<script> |
|||
$(function(){ |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="board-record-update.php" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="title">主旨</label> |
|||
<input type="text" name="title" id="title" size="30" maxlength="25" value="<?php echo $data['title']; ?>" required> |
|||
</div> |
|||
<!--<div> |
|||
<label for="sdate">開始日期</label><br> |
|||
<input type="date" name="sdate" id="sdate" value="<?php echo $data['sdate']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="edate">結束日期</label><br> |
|||
<input type="date" name="edate" id="edate" value="<?php echo $data['edate']; ?>" required> |
|||
</div>--> |
|||
<div> |
|||
<label for="pin">置頂</label> |
|||
<select name="pin" id="pin"> |
|||
<option value="Y"<?php if ($data["pin"]>1) echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data["pin"]==1) echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="attatch1">附件上傳</label> |
|||
<a href="<?php echo $data['attach']; ?>" target="_blank"><?php echo str_replace("/wms/board-attach/","",$data['attach']); ?></a> |
|||
<div> |
|||
<input type="file" name="attatch1" id="attatch1"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="content">公告內容</label><br> |
|||
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required><?php echo $data['content']; ?></textarea> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update" id="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
</form> |
|||
</div> |
|||
<?php |
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
<?php |
|||
exit; |
|||
require_once "database.php"; |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "select * from board where id = '$id'"; |
|||
$data = mysqli_query($link, $db_query); |
|||
|
|||
foreach($data as $data) : |
|||
?> |
|||
<script> |
|||
$(function(){ |
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="board-record-update.php" enctype="multipart/form-data"> |
|||
<div> |
|||
<label for="title">主旨</label> |
|||
<input type="text" name="title" id="title" size="30" maxlength="25" value="<?php echo $data['title']; ?>" required> |
|||
</div> |
|||
<!--<div> |
|||
<label for="sdate">開始日期</label><br> |
|||
<input type="date" name="sdate" id="sdate" value="<?php echo $data['sdate']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="edate">結束日期</label><br> |
|||
<input type="date" name="edate" id="edate" value="<?php echo $data['edate']; ?>" required> |
|||
</div>--> |
|||
<div> |
|||
<label for="pin">置頂</label> |
|||
<select name="pin" id="pin"> |
|||
<option value="Y"<?php if ($data["pin"]>1) echo " selected"; ?>>是</option> |
|||
<option value="N"<?php if ($data["pin"]==1) echo " selected"; ?>>否</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="attatch1">附件上傳</label> |
|||
<a href="<?php echo $data['attach']; ?>" target="_blank"><?php echo str_replace("/wms/board-attach/","",$data['attach']); ?></a> |
|||
<div> |
|||
<input type="file" name="attatch1" id="attatch1"> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<label for="content">公告內容</label><br> |
|||
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required><?php echo $data['content']; ?></textarea> |
|||
</div> |
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update" id="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
</form> |
|||
</div> |
|||
<?php |
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
?> |
@ -1,19 +1,19 @@ |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "select attach from board where id = '$id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
header("Location: /wms/".$row[0]); |
|||
exit; |
|||
} else { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案下載失敗!');"; |
|||
echo "</script>"; |
|||
header("Refresh:0; url=board-index.php?function_name=board&".$token_link); |
|||
} |
|||
ob_end_flush(); |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "select attach from board where id = '$id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
if ($row = mysqli_fetch_row($res)) { |
|||
header("Location: /wms/".$row[0]); |
|||
exit; |
|||
} else { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案下載失敗!');"; |
|||
echo "</script>"; |
|||
header("Refresh:0; url=board-index.php?function_name=board&".$token_link); |
|||
} |
|||
ob_end_flush(); |
|||
?> |
@ -1,201 +1,201 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
|
|||
// sql語法存在變數中 |
|||
$sql = "select * from board where status = 'Y' order by id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link, $sql); |
|||
$data2 = $data; |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<p> |
|||
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
<?php |
|||
} |
|||
if ($data) : |
|||
?> |
|||
|
|||
<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; |
|||
|
|||
} |
|||
|
|||
|
|||
/* The Modal (background) */ |
|||
.modal { |
|||
display: none; |
|||
/* Hidden by default */ |
|||
position: fixed; |
|||
/* Stay in place */ |
|||
z-index: 1; |
|||
/* Sit on top */ |
|||
padding-top: 100px; |
|||
/* Location of the box */ |
|||
left: 0; |
|||
top: 0; |
|||
width: 100%; |
|||
/* Full width */ |
|||
height: 100%; |
|||
/* Full height */ |
|||
overflow: auto; |
|||
/* Enable scroll if needed */ |
|||
|
|||
} |
|||
|
|||
.modal .back { |
|||
position: absolute; |
|||
top: 0; |
|||
left: 0; |
|||
width: 100%; |
|||
height: 100%; |
|||
background-color: rgba(0, 0, 0, 0.4); |
|||
/* Black w/ opacity */ |
|||
} |
|||
|
|||
/* Modal Content */ |
|||
.modal-content { |
|||
z-index: 9; |
|||
background-color: #fefefe; |
|||
margin: auto; |
|||
padding: 20px; |
|||
border: 1px solid #888; |
|||
width: 80%; |
|||
} |
|||
|
|||
/* The Close Button */ |
|||
.close { |
|||
color: #aaaaaa; |
|||
float: right; |
|||
font-size: 28px; |
|||
font-weight: bold; |
|||
} |
|||
|
|||
.close:hover, |
|||
.close:focus { |
|||
color: #000; |
|||
text-decoration: none; |
|||
cursor: pointer; |
|||
} |
|||
</style> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<!-- <td><?php echo $data['title']; ?></td> --> |
|||
<td><a onclick="openModal('<?php echo $data['id']; ?>')" href="#"><?php echo $data['title']; ?></button></a> |
|||
<td><a href="/wms/board-file.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" target="_blank"><?php echo str_replace("board-attach/", "", $data['attach']); ?></a></td> |
|||
<!--<td><?php if ($data['pin'] > 1) echo "是"; |
|||
else echo "否"; ?></td>--> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<p> |
|||
<?php if (($data['creater'] == $user_id) && ($data['status'] == "Y")) { ?> |
|||
<a href="board-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('確認關閉公告嗎?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
<?php } else echo "-"; ?> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
foreach ($data2 as $data2) : |
|||
?> |
|||
|
|||
<div id="myModal<?php echo $data2['id']; ?>" class="modal"> |
|||
<div class="back"></div> |
|||
<div class="modal-content"> |
|||
<button type="button" class="close myCloseBtn" id="">X</button> |
|||
<div class='col-12' style='text-align:center'> |
|||
<h3><?php echo $data2['title']; ?></h3> |
|||
<br/> |
|||
<?php echo nl2br($data2['content']); ?> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<?php endforeach; ?> |
|||
|
|||
<script> |
|||
var modal = document.getElementById("myModal"); |
|||
|
|||
function openModal(id) { |
|||
$("#myModal" + id).show(); |
|||
} |
|||
$(".myCloseBtn").click(function(e) { |
|||
$(".modal").hide(); |
|||
}); |
|||
$(".back").click(function(e) { |
|||
$(".modal").hide(); |
|||
}); |
|||
</script> |
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
|
|||
// sql語法存在變數中 |
|||
$sql = "select * from board where status = 'Y' order by id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link, $sql); |
|||
$data2 = $data; |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth & 2) { ?> |
|||
<p> |
|||
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
<?php |
|||
} |
|||
if ($data) : |
|||
?> |
|||
|
|||
<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; |
|||
|
|||
} |
|||
|
|||
|
|||
/* The Modal (background) */ |
|||
.modal { |
|||
display: none; |
|||
/* Hidden by default */ |
|||
position: fixed; |
|||
/* Stay in place */ |
|||
z-index: 1; |
|||
/* Sit on top */ |
|||
padding-top: 100px; |
|||
/* Location of the box */ |
|||
left: 0; |
|||
top: 0; |
|||
width: 100%; |
|||
/* Full width */ |
|||
height: 100%; |
|||
/* Full height */ |
|||
overflow: auto; |
|||
/* Enable scroll if needed */ |
|||
|
|||
} |
|||
|
|||
.modal .back { |
|||
position: absolute; |
|||
top: 0; |
|||
left: 0; |
|||
width: 100%; |
|||
height: 100%; |
|||
background-color: rgba(0, 0, 0, 0.4); |
|||
/* Black w/ opacity */ |
|||
} |
|||
|
|||
/* Modal Content */ |
|||
.modal-content { |
|||
z-index: 9; |
|||
background-color: #fefefe; |
|||
margin: auto; |
|||
padding: 20px; |
|||
border: 1px solid #888; |
|||
width: 80%; |
|||
} |
|||
|
|||
/* The Close Button */ |
|||
.close { |
|||
color: #aaaaaa; |
|||
float: right; |
|||
font-size: 28px; |
|||
font-weight: bold; |
|||
} |
|||
|
|||
.close:hover, |
|||
.close:focus { |
|||
color: #000; |
|||
text-decoration: none; |
|||
cursor: pointer; |
|||
} |
|||
</style> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<!-- <td><?php echo $data['title']; ?></td> --> |
|||
<td><a onclick="openModal('<?php echo $data['id']; ?>')" href="#"><?php echo $data['title']; ?></button></a> |
|||
<td><a href="/wms/board-file.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" target="_blank"><?php echo str_replace("board-attach/", "", $data['attach']); ?></a></td> |
|||
<!--<td><?php if ($data['pin'] > 1) echo "是"; |
|||
else echo "否"; ?></td>--> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<p> |
|||
<?php if (($data['creater'] == $user_id) && ($data['status'] == "Y")) { ?> |
|||
<a href="board-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('確認關閉公告嗎?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
<?php } else echo "-"; ?> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
foreach ($data2 as $data2) : |
|||
?> |
|||
|
|||
<div id="myModal<?php echo $data2['id']; ?>" class="modal"> |
|||
<div class="back"></div> |
|||
<div class="modal-content"> |
|||
<button type="button" class="close myCloseBtn" id="">X</button> |
|||
<div class='col-12' style='text-align:center'> |
|||
<h3><?php echo $data2['title']; ?></h3> |
|||
<br/> |
|||
<?php echo nl2br($data2['content']); ?> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<?php endforeach; ?> |
|||
|
|||
<script> |
|||
var modal = document.getElementById("myModal"); |
|||
|
|||
function openModal(id) { |
|||
$("#myModal" + id).show(); |
|||
} |
|||
$(".myCloseBtn").click(function(e) { |
|||
$(".modal").hide(); |
|||
}); |
|||
$(".back").click(function(e) { |
|||
$(".modal").hide(); |
|||
}); |
|||
</script> |
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
?> |
@ -1,52 +1,52 @@ |
|||
<?php |
|||
exit; |
|||
require_once "database.php"; |
|||
|
|||
if (isset($_POST['update'])) { |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
//print_r($_POST); |
|||
//print_r($_FILES);exit; |
|||
|
|||
function get_basename($filename) { |
|||
return preg_replace('/^.+[\\\\\\/]/', '', $filename); |
|||
} |
|||
|
|||
$pin = ($pin == "Y") ? "99" : "1"; |
|||
$sql_atta = ""; |
|||
|
|||
if ($_FILES["attatch1"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch1"]["name"]; |
|||
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch1"]["size"]; |
|||
$target_dir = "board-attach/"; |
|||
$target_file1 = strtolower($target_dir.get_basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
if (file_exists($target_file1)) unlink($target_file1); |
|||
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); |
|||
$sql_atta .= "path = '$target_file1', "; |
|||
} else $target_file1 = ""; |
|||
|
|||
if ($target_file1 && !$upload_res_1) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,請重新操作。');"; |
|||
echo "location.href='board-index.php';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$db_query = "update board set title = '$title', pin = '$pin', "; |
|||
$db_query .= $sql_atta; |
|||
$db_query .= "content = '$content'"; |
|||
$db_query .= "where id = '$id'"; |
|||
$result = mysqli_query($link, $db_query); |
|||
|
|||
mysqli_close($link); |
|||
|
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('修改成功');"; |
|||
echo "location.href='board-index.php';"; |
|||
echo "</script>"; |
|||
} |
|||
<?php |
|||
exit; |
|||
require_once "database.php"; |
|||
|
|||
if (isset($_POST['update'])) { |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
//print_r($_POST); |
|||
//print_r($_FILES);exit; |
|||
|
|||
function get_basename($filename) { |
|||
return preg_replace('/^.+[\\\\\\/]/', '', $filename); |
|||
} |
|||
|
|||
$pin = ($pin == "Y") ? "99" : "1"; |
|||
$sql_atta = ""; |
|||
|
|||
if ($_FILES["attatch1"]["error"] == 0) { |
|||
$file_name = $_FILES["attatch1"]["name"]; |
|||
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; |
|||
$file_size = $_FILES["attatch1"]["size"]; |
|||
$target_dir = "board-attach/"; |
|||
$target_file1 = strtolower($target_dir.get_basename($file_name)); |
|||
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); |
|||
$upload_ok = 1; |
|||
if (file_exists($target_file1)) unlink($target_file1); |
|||
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); |
|||
$sql_atta .= "path = '$target_file1', "; |
|||
} else $target_file1 = ""; |
|||
|
|||
if ($target_file1 && !$upload_res_1) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('檔案上傳失敗,請重新操作。');"; |
|||
echo "location.href='board-index.php';"; |
|||
echo "</script>"; |
|||
} |
|||
|
|||
$db_query = "update board set title = '$title', pin = '$pin', "; |
|||
$db_query .= $sql_atta; |
|||
$db_query .= "content = '$content'"; |
|||
$db_query .= "where id = '$id'"; |
|||
$result = mysqli_query($link, $db_query); |
|||
|
|||
mysqli_close($link); |
|||
|
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('修改成功');"; |
|||
echo "location.href='board-index.php';"; |
|||
echo "</script>"; |
|||
} |
|||
?> |
@ -1,48 +1,48 @@ |
|||
<?php |
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
|
|||
require_once "database.php"; |
|||
|
|||
$token = $_REQUEST["token"]; |
|||
$token_link = "token=" . $_REQUEST["token"]; |
|||
list($user_id, $enc_user_name, $login_dt) = explode(".", $token); |
|||
|
|||
$old_pwd = $_REQUEST['old_pwd']; |
|||
$new_pwd = $_REQUEST['new_pwd']; |
|||
|
|||
$data = array(); # 設置一個空陣列來放資料 |
|||
$real_user_id = ""; |
|||
$real_pwd = ""; |
|||
$sql = "SELECT * FROM account where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; # sql語法存在變數中 |
|||
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
foreach ($data as $data) { |
|||
$real_user_id = $data['accountid']; |
|||
$real_pwd = $data['pwd']; |
|||
} |
|||
|
|||
#如果帳號密碼都正確才可update |
|||
if (strlen($real_user_id) > 0) { |
|||
$sql_query = "UPDATE account set pwd = '$new_pwd' where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; |
|||
mysqli_query($link, $sql_query); |
|||
$result_message = " |
|||
<script> |
|||
alert('修改成功!'); |
|||
location.href='change-password.php?" . $token_link . "'; |
|||
</script> |
|||
"; |
|||
} else { |
|||
$result_message = " |
|||
<script> |
|||
alert('帳號密碼錯誤!'); |
|||
location.href='change-password.php?" . $token_link . "'; |
|||
</script> |
|||
"; |
|||
} |
|||
echo $result_message; |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
?> |
|||
<script> |
|||
|
|||
<?php |
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
|
|||
require_once "database.php"; |
|||
|
|||
$token = $_REQUEST["token"]; |
|||
$token_link = "token=" . $_REQUEST["token"]; |
|||
list($user_id, $enc_user_name, $login_dt) = explode(".", $token); |
|||
|
|||
$old_pwd = $_REQUEST['old_pwd']; |
|||
$new_pwd = $_REQUEST['new_pwd']; |
|||
|
|||
$data = array(); # 設置一個空陣列來放資料 |
|||
$real_user_id = ""; |
|||
$real_pwd = ""; |
|||
$sql = "SELECT * FROM account where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; # sql語法存在變數中 |
|||
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
foreach ($data as $data) { |
|||
$real_user_id = $data['accountid']; |
|||
$real_pwd = $data['pwd']; |
|||
} |
|||
|
|||
#如果帳號密碼都正確才可update |
|||
if (strlen($real_user_id) > 0) { |
|||
$sql_query = "UPDATE account set pwd = '$new_pwd' where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; |
|||
mysqli_query($link, $sql_query); |
|||
$result_message = " |
|||
<script> |
|||
alert('修改成功!'); |
|||
location.href='change-password.php?" . $token_link . "'; |
|||
</script> |
|||
"; |
|||
} else { |
|||
$result_message = " |
|||
<script> |
|||
alert('帳號密碼錯誤!'); |
|||
location.href='change-password.php?" . $token_link . "'; |
|||
</script> |
|||
"; |
|||
} |
|||
echo $result_message; |
|||
} |
|||
|
|||
mysqli_close($link); |
|||
?> |
|||
<script> |
|||
|
|||
</script> |
@ -1,77 +1,77 @@ |
|||
<?php |
|||
if ($_REQUEST["token"]) { |
|||
$item = substr($_REQUEST["token"], 0, strpos($_REQUEST["token"], ".")); |
|||
if ($item) { |
|||
require_once "header.php"; |
|||
} |
|||
} |
|||
?> |
|||
|
|||
|
|||
|
|||
<!-- 主頁header --> |
|||
<?php |
|||
require_once "header.php"; |
|||
require_once "database.php"; # 載入db.php來連結資料庫 |
|||
$data = array(); # 設置一個空陣列來放資料 |
|||
$sql = "SELECT * FROM account where (accountid = '$user_id')"; # sql語法存在變數中 |
|||
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
|
|||
|
|||
foreach ($data as $data) { |
|||
$phone_call_help = $data['phone_call_help']; |
|||
} |
|||
|
|||
|
|||
?> |
|||
<div> |
|||
<div id="loader"> |
|||
<div class="spinner-border text-primary" role="status"></div> |
|||
</div> |
|||
<div class="appHeader bg-primary text-light"> |
|||
<div class="left"> |
|||
<a href="javascript:;" class="headerButton goBack"> |
|||
<ion-icon name="chevron-back-outline"></ion-icon> |
|||
</a> |
|||
</div> |
|||
<div class="pageTitle">變更密碼</div> |
|||
</div> |
|||
<div id="appCapsule"> |
|||
<div class="section full mt-2"> |
|||
<div class="section-title">請輸入變更前後密碼!</div> |
|||
<div class="wide-block pt-2 pb-2"> |
|||
<form action="change-password-update.php?token=<?php echo $_REQUEST["token"];?>" method="post" enctype="multipart/form-data"> |
|||
<!-- 以下是要傳遞的資料 --> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>" /> |
|||
<!-- 以上是要傳遞的資料 --> |
|||
<div class="form-group boxed"> |
|||
<div class="input-wrapper"> |
|||
<input type="text" class="form-control" name="old_pwd" placeholder="變更前密碼"> |
|||
<i class="clear-input"> |
|||
<ion-icon name="close-circle"></ion-icon> |
|||
</i> |
|||
</div> |
|||
</div> |
|||
<div class="form-group boxed"> |
|||
<div class="input-wrapper"> |
|||
<input type="text" class="form-control" name="new_pwd" placeholder="變更後密碼"> |
|||
<i class="clear-input"> |
|||
<ion-icon name="close-circle"></ion-icon> |
|||
</i> |
|||
</div> |
|||
</div> |
|||
<div class="mt-1"> |
|||
<button type="submit" class="btn btn-primary btn-lg btn-block"> |
|||
確定 |
|||
</button> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<!-- * App Capsule --> |
|||
</div> |
|||
<?php |
|||
|
|||
mysqli_close($link); |
|||
<?php |
|||
if ($_REQUEST["token"]) { |
|||
$item = substr($_REQUEST["token"], 0, strpos($_REQUEST["token"], ".")); |
|||
if ($item) { |
|||
require_once "header.php"; |
|||
} |
|||
} |
|||
?> |
|||
|
|||
|
|||
|
|||
<!-- 主頁header --> |
|||
<?php |
|||
require_once "header.php"; |
|||
require_once "database.php"; # 載入db.php來連結資料庫 |
|||
$data = array(); # 設置一個空陣列來放資料 |
|||
$sql = "SELECT * FROM account where (accountid = '$user_id')"; # sql語法存在變數中 |
|||
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
|
|||
|
|||
foreach ($data as $data) { |
|||
$phone_call_help = $data['phone_call_help']; |
|||
} |
|||
|
|||
|
|||
?> |
|||
<div> |
|||
<div id="loader"> |
|||
<div class="spinner-border text-primary" role="status"></div> |
|||
</div> |
|||
<div class="appHeader bg-primary text-light"> |
|||
<div class="left"> |
|||
<a href="javascript:;" class="headerButton goBack"> |
|||
<ion-icon name="chevron-back-outline"></ion-icon> |
|||
</a> |
|||
</div> |
|||
<div class="pageTitle">變更密碼</div> |
|||
</div> |
|||
<div id="appCapsule"> |
|||
<div class="section full mt-2"> |
|||
<div class="section-title">請輸入變更前後密碼!</div> |
|||
<div class="wide-block pt-2 pb-2"> |
|||
<form action="change-password-update.php?token=<?php echo $_REQUEST["token"];?>" method="post" enctype="multipart/form-data"> |
|||
<!-- 以下是要傳遞的資料 --> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>" /> |
|||
<!-- 以上是要傳遞的資料 --> |
|||
<div class="form-group boxed"> |
|||
<div class="input-wrapper"> |
|||
<input type="text" class="form-control" name="old_pwd" placeholder="變更前密碼"> |
|||
<i class="clear-input"> |
|||
<ion-icon name="close-circle"></ion-icon> |
|||
</i> |
|||
</div> |
|||
</div> |
|||
<div class="form-group boxed"> |
|||
<div class="input-wrapper"> |
|||
<input type="text" class="form-control" name="new_pwd" placeholder="變更後密碼"> |
|||
<i class="clear-input"> |
|||
<ion-icon name="close-circle"></ion-icon> |
|||
</i> |
|||
</div> |
|||
</div> |
|||
<div class="mt-1"> |
|||
<button type="submit" class="btn btn-primary btn-lg btn-block"> |
|||
確定 |
|||
</button> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<!-- * App Capsule --> |
|||
</div> |
|||
<?php |
|||
|
|||
mysqli_close($link); |
|||
?> |
@ -1,86 +1,86 @@ |
|||
<?php |
|||
include "header.php"; |
|||
?> |
|||
|
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "combo-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> |
|||
|
|||
|
|||
<div> |
|||
<label for="combono">保養套餐號</label> |
|||
<input type="text" name="combono" id="combono"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="part">部位</label> |
|||
<input type="text" name="part" id="part"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="partid">部位類別</label> |
|||
<input type="text" name="partid" id="partid"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="comboitem">部位類別序號</label> |
|||
<input type="text" name="comboitem" id="comboitem" value="1"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="detail">保養內容</label> |
|||
<input type="text" name="detail" id="detail"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="enable">是否啟用</label> |
|||
<Select name="enable" id="enable" required> |
|||
<option selected="selected" disabled="disabled" style="display: none" value=""></option> |
|||
<Option Value="1">啟用</Option> |
|||
<Option Value="0">停用</Option> |
|||
</Select> |
|||
<!-- <input type="text" name="enable" id="enable" value="1"> --> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div class="bottom-margin"> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php include "footer.php"; ?> |
|||
<?php |
|||
include "header.php"; |
|||
?> |
|||
|
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "combo-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> |
|||
|
|||
|
|||
<div> |
|||
<label for="combono">保養套餐號</label> |
|||
<input type="text" name="combono" id="combono"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="part">部位</label> |
|||
<input type="text" name="part" id="part"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="partid">部位類別</label> |
|||
<input type="text" name="partid" id="partid"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="comboitem">部位類別序號</label> |
|||
<input type="text" name="comboitem" id="comboitem" value="1"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="detail">保養內容</label> |
|||
<input type="text" name="detail" id="detail"> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="enable">是否啟用</label> |
|||
<Select name="enable" id="enable" required> |
|||
<option selected="selected" disabled="disabled" style="display: none" value=""></option> |
|||
<Option Value="1">啟用</Option> |
|||
<Option Value="0">停用</Option> |
|||
</Select> |
|||
<!-- <input type="text" name="enable" id="enable" value="1"> --> |
|||
|
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div class="bottom-margin"> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php include "footer.php"; ?> |
|||
|
@ -1,12 +1,12 @@ |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "DELETE FROM combo WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
|
|||
header("Refresh:0; url=combo-index.php?function_name=combo&".$token_link); |
|||
ob_end_flush(); |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "DELETE FROM combo WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
|
|||
header("Refresh:0; url=combo-index.php?function_name=combo&".$token_link); |
|||
ob_end_flush(); |
|||
?> |
@ -1,93 +1,93 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM combo WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
/* |
|||
include "inc/record_update.php"; |
|||
|
|||
try { |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM expert WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
}catch (Exception $e) { |
|||
echo 'Caught exception: ', $e->getMessage(), "\n"; |
|||
} |
|||
*/ |
|||
foreach($data as $data) : |
|||
?> |
|||
|
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="combo-record-update.php" enctype="multipart/form-data"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="combono">保養套餐號</label> |
|||
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="part">部位</label> |
|||
<input type="text" name="part" id="part" value="<?php echo $data['part']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="partid">部位類別</label> |
|||
<input type="text" name="partid" id="partid" value="<?php echo $data['partid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="comboitem">部位類別序號</label> |
|||
<input type="text" name="comboitem" id="comboitem" value="<?php echo $data['comboitem']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="detail">保養內容</label> |
|||
<input type="text" name="detail" id="detail" value="<?php echo $data['detail']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="enable">是否啟用</label> |
|||
<Select name="enable" id="enable" required> |
|||
<?php |
|||
if($data["enable"] == 1){ |
|||
echo "<Option Value='1' selected='selected'>啟用</Option> <Option Value='0'>停用</Option>"; |
|||
}else{ |
|||
echo "<Option Value='0' selected='selected'>停用</Option> <Option Value='1'>啟用</Option>"; |
|||
} |
|||
?> |
|||
</Select> |
|||
<!-- <input type="text" name="enable" id="enable" value=""> --> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
|
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM combo WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
/* |
|||
include "inc/record_update.php"; |
|||
|
|||
try { |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM expert WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
}catch (Exception $e) { |
|||
echo 'Caught exception: ', $e->getMessage(), "\n"; |
|||
} |
|||
*/ |
|||
foreach($data as $data) : |
|||
?> |
|||
|
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="combo-record-update.php" enctype="multipart/form-data"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="combono">保養套餐號</label> |
|||
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="part">部位</label> |
|||
<input type="text" name="part" id="part" value="<?php echo $data['part']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="partid">部位類別</label> |
|||
<input type="text" name="partid" id="partid" value="<?php echo $data['partid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="comboitem">部位類別序號</label> |
|||
<input type="text" name="comboitem" id="comboitem" value="<?php echo $data['comboitem']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="detail">保養內容</label> |
|||
<input type="text" name="detail" id="detail" value="<?php echo $data['detail']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="enable">是否啟用</label> |
|||
<Select name="enable" id="enable" required> |
|||
<?php |
|||
if($data["enable"] == 1){ |
|||
echo "<Option Value='1' selected='selected'>啟用</Option> <Option Value='0'>停用</Option>"; |
|||
}else{ |
|||
echo "<Option Value='0' selected='selected'>停用</Option> <Option Value='1'>啟用</Option>"; |
|||
} |
|||
?> |
|||
</Select> |
|||
<!-- <input type="text" name="enable" id="enable" value=""> --> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
|
|||
|
@ -1,140 +1,140 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
$sql = "SELECT * FROM combo $sql_cmd ORDER BY id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="combo-create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth&2) { ?> |
|||
<p> |
|||
<a href="combo-create.php?function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
} |
|||
|
|||
|
|||
|
|||
if($data): |
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:combo-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<?php if ($user_auth&2) { ?> |
|||
<th>修改</th> |
|||
<th>刪除</th> |
|||
<?php } ?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php foreach($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['combono']; ?></td> |
|||
<td><?php echo $data['part']; ?></td> |
|||
<td><?php echo $data['partid']; ?></td> |
|||
<td><?php echo $data['comboitem']; ?></td> |
|||
<td><?php echo $data['detail']; ?></td> |
|||
<td><?php echo $data['enable']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<?php if ($user_auth&2) { ?> |
|||
<td> |
|||
<p> |
|||
<a href="combo-edit.php?id=<?php echo $data['id']; ?>&function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td> |
|||
<p> |
|||
<a href="combo-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<?php } ?> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
|
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
$sql = "SELECT * FROM combo $sql_cmd ORDER BY id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="combo-create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth&2) { ?> |
|||
<p> |
|||
<a href="combo-create.php?function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
} |
|||
|
|||
|
|||
|
|||
if($data): |
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:combo-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<?php if ($user_auth&2) { ?> |
|||
<th>修改</th> |
|||
<th>刪除</th> |
|||
<?php } ?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php foreach($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['combono']; ?></td> |
|||
<td><?php echo $data['part']; ?></td> |
|||
<td><?php echo $data['partid']; ?></td> |
|||
<td><?php echo $data['comboitem']; ?></td> |
|||
<td><?php echo $data['detail']; ?></td> |
|||
<td><?php echo $data['enable']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<?php if ($user_auth&2) { ?> |
|||
<td> |
|||
<p> |
|||
<a href="combo-edit.php?id=<?php echo $data['id']; ?>&function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td> |
|||
<p> |
|||
<a href="combo-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<?php } ?> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
@ -1,42 +1,42 @@ |
|||
<?php |
|||
$combono= ""; |
|||
$part= ""; |
|||
$partid= ""; |
|||
$comboitem= ""; |
|||
$detail= ""; |
|||
$enable= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
$combono_error= ""; |
|||
$part_error= ""; |
|||
$partid_error= ""; |
|||
$comboitem_error= ""; |
|||
$detail_error= ""; |
|||
$enable_error= ""; |
|||
$creater_error = ""; |
|||
$create_at_error = ""; |
|||
|
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
include "combo-user-input.php"; |
|||
|
|||
$db_query = "INSERT INTO combo(combono, part, partid, comboitem,detail, enable,creater, create_at) VALUES ('$combono', '$part', '$partid', '$comboitem','$detail', '$enable','$creater', '$create_at')"; |
|||
$result = mysqli_query($link,$db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('新增成功');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
|||
<?php |
|||
$combono= ""; |
|||
$part= ""; |
|||
$partid= ""; |
|||
$comboitem= ""; |
|||
$detail= ""; |
|||
$enable= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
$combono_error= ""; |
|||
$part_error= ""; |
|||
$partid_error= ""; |
|||
$comboitem_error= ""; |
|||
$detail_error= ""; |
|||
$enable_error= ""; |
|||
$creater_error = ""; |
|||
$create_at_error = ""; |
|||
|
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
include "combo-user-input.php"; |
|||
|
|||
$db_query = "INSERT INTO combo(combono, part, partid, comboitem,detail, enable,creater, create_at) VALUES ('$combono', '$part', '$partid', '$comboitem','$detail', '$enable','$creater', '$create_at')"; |
|||
$result = mysqli_query($link,$db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('新增成功');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
|||
|
@ -1,41 +1,41 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
|
|||
$id = $_POST['id']; |
|||
$combono = user_input($_POST["combono"]); |
|||
$part = user_input($_POST["part"]); |
|||
$partid = user_input($_POST["partid"]); |
|||
$comboitem = user_input($_POST["comboitem"]); |
|||
$detail = user_input($_POST["detail"]); |
|||
$enable = user_input($_POST["enable"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
$db_query = "UPDATE combo set combono = '$combono', part = '$part', partid = '$partid', comboitem = '$comboitem', detail = '$detail', enable = '$enable',create_at = '$create_at' WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
|
|||
$id = $_POST['id']; |
|||
$combono = user_input($_POST["combono"]); |
|||
$part = user_input($_POST["part"]); |
|||
$partid = user_input($_POST["partid"]); |
|||
$comboitem = user_input($_POST["comboitem"]); |
|||
$detail = user_input($_POST["detail"]); |
|||
$enable = user_input($_POST["enable"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
$db_query = "UPDATE combo set combono = '$combono', part = '$part', partid = '$partid', comboitem = '$comboitem', detail = '$detail', enable = '$enable',create_at = '$create_at' WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
@ -1,54 +1,54 @@ |
|||
<?php |
|||
|
|||
//Function to filter the form input |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
$combono = user_input($_POST["combono"]); |
|||
$part = user_input($_POST["part"]); |
|||
$partid = user_input($_POST["partid"]); |
|||
$comboitem = user_input($_POST["comboitem"]); |
|||
$detail = user_input($_POST["detail"]); |
|||
$enable = user_input($_POST["enable"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
|
|||
|
|||
|
|||
/* |
|||
|
|||
if(empty($_POST["name"])) { |
|||
$name_error = "Name is required"; |
|||
} else { |
|||
$name = user_input($_POST["name"]); |
|||
|
|||
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { |
|||
$name_error = "Only letter and white space are allowed"; |
|||
} |
|||
} |
|||
|
|||
|
|||
/* |
|||
if(empty($_POST["website"])) { |
|||
$website_error = "Website address is required"; |
|||
} else { |
|||
$website = user_input($_POST["website"]); |
|||
|
|||
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { |
|||
$website_error = "Invalid website URL"; |
|||
} |
|||
} |
|||
|
|||
if(empty($_POST["comment"])) { |
|||
$comment = ""; |
|||
} else { |
|||
$comment = user_input($_POST["comment"]); |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
<?php |
|||
|
|||
//Function to filter the form input |
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
$combono = user_input($_POST["combono"]); |
|||
$part = user_input($_POST["part"]); |
|||
$partid = user_input($_POST["partid"]); |
|||
$comboitem = user_input($_POST["comboitem"]); |
|||
$detail = user_input($_POST["detail"]); |
|||
$enable = user_input($_POST["enable"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
|
|||
|
|||
|
|||
/* |
|||
|
|||
if(empty($_POST["name"])) { |
|||
$name_error = "Name is required"; |
|||
} else { |
|||
$name = user_input($_POST["name"]); |
|||
|
|||
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { |
|||
$name_error = "Only letter and white space are allowed"; |
|||
} |
|||
} |
|||
|
|||
|
|||
/* |
|||
if(empty($_POST["website"])) { |
|||
$website_error = "Website address is required"; |
|||
} else { |
|||
$website = user_input($_POST["website"]); |
|||
|
|||
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { |
|||
$website_error = "Invalid website URL"; |
|||
} |
|||
} |
|||
|
|||
if(empty($_POST["comment"])) { |
|||
$comment = ""; |
|||
} else { |
|||
$comment = user_input($_POST["comment"]); |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
@ -1,322 +1,324 @@ |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MICalculator |
|||
{ |
|||
/** |
|||
* 計算MI |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯報價 maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建MI' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MICalculator |
|||
{ |
|||
/** |
|||
* 計算MI |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯報價 maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
// echo $sql_get_price; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建MI' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
|
@ -1,322 +1,322 @@ |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MSCalculator |
|||
{ |
|||
/** |
|||
* 計算报价 |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯成本maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建標準成本' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MSCalculator |
|||
{ |
|||
/** |
|||
* 計算报价 |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯成本maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建標準成本' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
|
File diff suppressed because it is too large
@ -0,0 +1,912 @@ |
|||
<?php |
|||
require_once '../header_nomenu.php'; |
|||
require_once './FormHelper.php'; |
|||
require_once './wf_common.php'; |
|||
$vol_no = empty($_GET['vol_no']) ? "" : $_GET['vol_no']; |
|||
|
|||
|
|||
/*** |
|||
* 检查是否重复生成价审单 |
|||
* con_maintance_examine_apply |
|||
*/ |
|||
/* |
|||
list($cnt)=DB::fields("select count(*) cnt from con_maintance_examine_apply where vol_no='$vol_no'"); |
|||
if($cnt>0) { |
|||
echo"<script>alert('卷號".$vol_no."已生成價審單,請勿重複生成!');history.go(-1);</script>"; |
|||
exit; |
|||
} |
|||
*/ |
|||
|
|||
#係統ID |
|||
$system_id = 'con'; |
|||
#流程ID |
|||
$flow_id = 'con01'; |
|||
#表單號 $form_id; |
|||
$form_id = ""; |
|||
#價審單狀態 |
|||
$apply_st = ""; |
|||
list($apply_key, $form_key, $salesman) = DB::fields("SELECT apply_key, form_key,salesman FROM con_maintance_examine_apply WHERE vol_no='$vol_no' ORDER BY apply_key desc limit 0, 1"); |
|||
// echo '<pre>'; |
|||
// print_r($salesman); |
|||
// echo '</pre>'; |
|||
// exit; |
|||
if ($salesman != $user_id) { |
|||
echo '<script>alert("您並不是該單營業員,無法訪問。");history.go(-1);</script>'; |
|||
exit; |
|||
} |
|||
if (empty($apply_key)) $apply_st = 1; // 準備新增 |
|||
else { |
|||
//list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); |
|||
list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); |
|||
if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 |
|||
else $apply_st = 9; // 已到下一關,無法䖺改 |
|||
} |
|||
|
|||
// if ($apply_st > 2) { |
|||
// echo "<script>alert('卷號" . $vol_no . "已生成價審單,請勿重複生成!');history.go(-1);</script>"; |
|||
// exit; |
|||
// } |
|||
|
|||
if ($apply_st == 1) { |
|||
$wf = new WorkFlow($system_id, $flow_id, $form_id); |
|||
$wf->initWorkFlow($user_id); |
|||
$form_key = $wf->flowContext->getFormKey(); |
|||
} else { |
|||
$wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); |
|||
} |
|||
|
|||
#獲取簽核意見 |
|||
$assign_opinions = Assign::get_records($form_key); |
|||
|
|||
#會簽部門意見 |
|||
$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); |
|||
|
|||
//預設冇有摺扣 |
|||
$wf->setFormData(['discount' => 100]); |
|||
$flowName = $wf->getFlowName(); |
|||
$assigner = $wf->getAssignerList(); |
|||
$assign_status = $wf->getAssignStatus($assigner); |
|||
$if_show_assign = true; |
|||
//加載流程圖 |
|||
//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); |
|||
//$path = $fc[0]->wf_file; |
|||
//echo dirname(__DIR__)."/../"."$path"; |
|||
|
|||
//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); |
|||
#是否可會簽 |
|||
$isSplitable = $wf->isSplitable(); |
|||
|
|||
//表單數據 |
|||
#客戶表 |
|||
#1.電梯品牌選項 |
|||
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc "; |
|||
$elevator_brand_opt = DB::result($sql); |
|||
#2.保養方式 |
|||
$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; |
|||
$maintain_kind_opt = DB::result($sql); |
|||
#3.電梯類型 |
|||
$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'"; |
|||
$elevator_kind_opt = DB::result($sql); |
|||
#4.付款方式 |
|||
$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc"; |
|||
$payment_kind_opt = DB::result($sql); |
|||
#5.契約性質 |
|||
$sql = "select code_name value ,content label from code where field_name='contract_kind'"; |
|||
$contract_kind_opt = DB::result($sql); |
|||
#6.是否贈送M1 |
|||
$is_m1_bundle_opt = [ |
|||
['label' => '是', 'value' => 'Y'], |
|||
['label' => '否', 'value' => 'N'] |
|||
|
|||
]; |
|||
#7.機種 |
|||
$sql = "select code_name value ,content label from code where field_name='fp_kind'"; |
|||
$fp_kind_opt = DB::result($sql); |
|||
#抓取有望客戶資料 |
|||
|
|||
$vol_no = $_GET['vol_no']; |
|||
$where = " and vol_no='$vol_no'"; |
|||
$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; |
|||
$hope_contract = DB::result($sql); |
|||
$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; |
|||
#寫入 con_maintance_examine_apply |
|||
if ($apply_st == 1) { |
|||
#獲取評審單號 |
|||
$apply_key = get_sequnece_no('cmea_apply_key', date('ym')); |
|||
//var_dump($hope_contract); |
|||
$insert_data = [ |
|||
'apply_key' => $apply_key, |
|||
'vol_no' => $vol_no, |
|||
'form_key' => $form_key, |
|||
'address' => $hope_contract['address'], |
|||
'case_name' => $hope_contract['customer'], |
|||
'num' => $hope_contract['num'], |
|||
'brand' => '', |
|||
'customer' => $hope_contract['customer'], |
|||
'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], |
|||
'progress_remark' => $hope_contract['progress_status'] |
|||
//'platform_company'=>'', |
|||
// 'platforom_company_tel'=> '' |
|||
|
|||
]; |
|||
//var_dump($insert_data); |
|||
DB::insert_table('con_maintance_examine_apply', $insert_data); |
|||
} |
|||
#抓使用者主管 |
|||
$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; |
|||
list($result) = DB::result($sql); |
|||
if ($result['department_id'] == '511') { |
|||
$managerid = 'M0137'; |
|||
$managername = '劉永德'; |
|||
} else if ($result['department_id'] == '512') { |
|||
$managerid = 'M0137'; |
|||
$managername = '劉永德'; |
|||
} else if ($result['department_id'] == '513') { |
|||
$managerid = 'M0086'; |
|||
$managername = '李烘銘'; |
|||
} else if ($result['department_id'] == '514') { |
|||
$managerid = 'M0033'; |
|||
$managername = '吳育宗'; |
|||
} |
|||
|
|||
if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') { |
|||
$managerid = 'M0008'; |
|||
$managername = '詹益彰'; |
|||
} |
|||
|
|||
if ($result['department_id'] == 'M0008') { |
|||
$managerid = 'M0008'; |
|||
$managername = '詹益彰'; |
|||
} |
|||
$table = 'con_maintance_examine_apply'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'apply_key' => [ |
|||
'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', |
|||
'attr' => [ |
|||
'readonly=true ', |
|||
'class' => 'form-control form-control-sm' |
|||
] |
|||
], |
|||
'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], |
|||
'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], |
|||
'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], |
|||
'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], |
|||
'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], |
|||
'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
|
|||
'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], |
|||
|
|||
]; |
|||
$where = " and apply_key='$apply_key'"; |
|||
|
|||
$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; |
|||
$data = []; |
|||
$data = DB::result($sql); |
|||
|
|||
#電梯詳細資料 |
|||
$con_maintance_examine_clear_columm = [ |
|||
'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], |
|||
'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], |
|||
'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], |
|||
'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], |
|||
'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], |
|||
'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], |
|||
'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], |
|||
'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], |
|||
'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], |
|||
|
|||
'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], |
|||
'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], |
|||
'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], |
|||
|
|||
'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], |
|||
|
|||
'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], |
|||
'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], |
|||
'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], |
|||
'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], |
|||
|
|||
]; |
|||
$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . |
|||
" FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); |
|||
$j = 0; |
|||
$col_count = 12; |
|||
$cmecRow = " <tr>"; |
|||
|
|||
foreach ($con_maintance_examine_clear_columm as $key => $val) { |
|||
$fieldVal = ""; |
|||
$_input = $val['tag'] == 'select' ? |
|||
FormHelper::select('', $val['options'], $fieldVal, $val['attr']) |
|||
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); |
|||
// : "<input type='" . $val['tag'] . "' class=' form-control form-control-sm' " . $val['attr'] . " value='" . $fieldVal . "' name='${key}[]' id='$key' placeholder='請輸入'>"; |
|||
$cmecRow .= "<td colspan='" . (empty($val['attr']['colspan']) ? '' : $val['attr']['colspan']) . "' ><div class=' col-12' > $_input</td>"; |
|||
if ((++$j % $col_count) == 0) { |
|||
if ($j == $col_count) $cmecRow .= "<td><button onClick='delRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>"; |
|||
$cmecRow .= "</tr><tr>"; |
|||
} |
|||
} |
|||
|
|||
|
|||
$cmecRow .= "</tr>"; |
|||
function base_url($url) |
|||
{ |
|||
return "https://www.masada.com.tw/static/" . $url; |
|||
} |
|||
function get_sequnece_no($seq_name = '', $p_yyyymm = '') |
|||
{ |
|||
|
|||
if (empty($p_yyyymm) || empty($seq_name)) return null; |
|||
#當前年月 |
|||
list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); |
|||
if ($p_yyyymm != $yyyymm) { |
|||
DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); |
|||
} |
|||
// echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; |
|||
list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); |
|||
|
|||
|
|||
return $seq_no; |
|||
} |
|||
|
|||
|
|||
?> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" /> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/jquery.validate.min.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>"> |
|||
|
|||
</script> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100); ?>" /> |
|||
<script type="text/javascript"> |
|||
window.param = { |
|||
elevator_type: '', |
|||
floors: 1, |
|||
speed: 1, |
|||
persons: 6, |
|||
weight: 1000, |
|||
maintain_times: 1, //病床梯一月2次保養 |
|||
maintain_months: 12, |
|||
maintain_kind: 2, |
|||
maintain_period: 1, //預設為1月1次, 2是為2月一次 |
|||
is_m1_bundle: 'N', |
|||
}; |
|||
|
|||
let regDelStr = ""; |
|||
|
|||
$(document).ready(function() { |
|||
var tag_data; |
|||
$.ajax({ |
|||
url: 'https://www.masada.com.tw/fds/index.php/DesignFlow/get_assigner', |
|||
//url: 'http://localhost/fds/index.php/DesignFlow/get_assigner', |
|||
type: 'post', |
|||
dataType: 'json', |
|||
success: function(data) { |
|||
window.tag_data = data; |
|||
$('#selectPage').selectPage({ |
|||
showField: 'show_name', |
|||
keyField: 'val', |
|||
data: data, |
|||
multiple: true, |
|||
multipleControlbar: true, |
|||
pagination: false, |
|||
focusDropList: false |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
$.validator.addMethod('gt', function(value, element, param) { |
|||
return value > param; |
|||
}, $.validator.format("輸入值必須大於0")); |
|||
var assigner = eval('<?= json_encode($assigner) ?>'); |
|||
//console.log(assigner); |
|||
|
|||
var cmecRow = "<?= str_replace('"', '\'', $cmecRow) ?>"; |
|||
// $('#cmecTbody').append(cmecRow); |
|||
$('.sp_element_box').attr("disabled", true); |
|||
$("#assign_opinion").cleditor({ |
|||
height: 100, // height not including margins, borders or padding |
|||
controls: // controls to add to the toolbar |
|||
"bold italic underline strikethrough subscript superscript | font size " + |
|||
"style | color highlight removeformat | bullets numbering | outdent " + |
|||
"indent | alignleft center alignright justify | undo redo | " |
|||
}); |
|||
|
|||
$('#contract_begin_date').on('input propertychange', function(e) { |
|||
|
|||
var date = new Date(e.target.value); |
|||
var yyyy = date.getFullYear() + 1; |
|||
var mm = date.getMonth() + 1; |
|||
var dd = date.getDate(); |
|||
var time = yyyy + `-` + (mm < 10 ? '0' + mm : mm) + '-' + (dd < 10 ? '0' + dd : dd); |
|||
$('#contract_end_date').val(time); |
|||
}); |
|||
|
|||
$('#brand').change(function() { |
|||
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態 |
|||
if (_selected_status == 'Z') { |
|||
$('#brandModal').modal('show') |
|||
} |
|||
|
|||
}); |
|||
$('#assign_status').change(function() { |
|||
$("#next_users").empty(); |
|||
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態 |
|||
var _option_tmp = ""; //獲取下拉列表 |
|||
// for (a in assigner) { //遍曆assigner |
|||
// if (assigner[a][0] == _selected_status) { |
|||
// _tmp = assigner[a][1].split(','); |
|||
// for (var b in _tmp) { |
|||
// if (_tmp[b] == '') { |
|||
// continue; |
|||
// } |
|||
// _uname = _tmp[b].split('-')[1]; |
|||
// _uid = _tmp[b].split('-')[0]; |
|||
// /* console.log(_tmp[b]);*/ |
|||
// _option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>'; |
|||
// } |
|||
// } |
|||
// } |
|||
_option_tmp += '<option value=' + '<?php echo $managerid ?>' + '>' + '<?php echo $managername ?>' + '</option>'; |
|||
console.log(_option_tmp); |
|||
$("#next_users").append(_option_tmp); |
|||
}); |
|||
$('#maintain_kind').change(function() { |
|||
if ($('#cmecTbody tr').length > 0) { |
|||
alert("保養方式已更動,請開始輸入電梯資料!"); |
|||
$('#cmecTbody').find(':input').val(''); |
|||
return false; |
|||
} |
|||
}); |
|||
$("#form").validate(); |
|||
$("form").submit(function(e) { |
|||
$('#reg_del').val(regDelStr); |
|||
}); |
|||
}); |
|||
addRow = function() { |
|||
if ($('#maintain_kind').val() == "") { |
|||
alert("請選擇保養方式!"); |
|||
$('#maintain_kind').eq(0).focus(); |
|||
return false; |
|||
} |
|||
const cmecRow = $('#elevator_list').html(); |
|||
console.log(cmecRow); |
|||
$('#elevator_list').append(cmecRow); |
|||
$("select[name^='elevator_kind'],select[name^='is_m1_bundle']").on('change', function(obj) { |
|||
//console.log('#'+$(this).attr('name')+'#'); |
|||
var elen = 1; |
|||
if ('elevator_kind[]' == $(this).attr('name')) { |
|||
var children = $(this).parent().parent().parent(); |
|||
var elementObj = $(children).next('tr').find("input[name^='stand_price']"); |
|||
//var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle'] option:selected").val(); |
|||
} else if ('is_m1_bundle[]' == $(this).attr('name')) { |
|||
var children = $(this).parent().parent().parent().prev('tr'); |
|||
var elementObj = $(this).parent().parent().parent().find("input[name^='stand_price']"); |
|||
//var is_m1_bundle = $(this).val(); |
|||
} |
|||
|
|||
var element = elementObj; |
|||
if ('elevator_kind[]' == $(this).attr('name')) { |
|||
var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle'] option: selected").val(""); |
|||
} else if ('is_m1_bundle[]' == $(this).attr('name')) { |
|||
var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle']").val(); |
|||
} |
|||
|
|||
var floors = $(children).find("input[name^='floors']").val(); |
|||
var speed = $(children).find("input[name^='speed']").val(); |
|||
var weight = $(children).find("input[name^='weight']").val(); |
|||
var persons = $(children).find("input[name^='persons']").val(); |
|||
var maintain_times = $(children).find("input[name^='maintain_times']").val(); |
|||
var maintain_months = $(children).find("input[name^='maintain_months']").val(); |
|||
var maintain_period = $(children).find("input[name^='maintain_period']").val(); |
|||
var maintain_kind = $('#maintain_kind').val(); |
|||
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val(); |
|||
|
|||
var param1 = { |
|||
...param, |
|||
persons, |
|||
floors, |
|||
speed, |
|||
weight, |
|||
maintain_times, |
|||
maintain_months, |
|||
maintain_period, |
|||
maintain_kind, |
|||
elevator_type, |
|||
is_m1_bundle |
|||
} |
|||
setStandPrice(param1, element); |
|||
//console.info(param1); |
|||
}); |
|||
|
|||
$("input[name^='floors']" + |
|||
",input[name^='speed']" + |
|||
",input[name^='persons']" + |
|||
",input[name^='weight']" + |
|||
",input[name^='maintain_times']" + |
|||
",input[name^='maintain_months']" + |
|||
",input[name^='maintain_period']" |
|||
).on('input propertychange', function(obj) { |
|||
// $(obj).parent().parent().parent().remove(); |
|||
var children = $(this).parent().parent().parent().children(); |
|||
var floors = $(children).find("input[name^='floors']").val(); |
|||
var speed = $(children).find("input[name^='speed']").val(); |
|||
var weight = $(children).find("input[name^='weight']").val(); |
|||
var persons = $(children).find("input[name^='persons']").val(); |
|||
var maintain_times = $(children).find("input[name^='maintain_times']").val(); |
|||
var maintain_months = $(children).find("input[name^='maintain_months']").val(); |
|||
var maintain_period = $(children).find("input[name^='maintain_period']").val(); |
|||
var maintain_kind = $('#maintain_kind').val(); |
|||
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val(); |
|||
var is_m1_bundle = $(this).parent().parent().parent().next('tr').find("select[name^='is_m1_bundle'] option:selected").val(); |
|||
|
|||
var param1 = { |
|||
...param, |
|||
persons, |
|||
floors, |
|||
speed, |
|||
weight, |
|||
maintain_times, |
|||
maintain_months, |
|||
maintain_period, |
|||
maintain_kind, |
|||
elevator_type, |
|||
is_m1_bundle |
|||
} |
|||
var element = $(this).parent().parent().parent().next().children().find("input[name^='stand_price']"); |
|||
setStandPrice(param1, element); |
|||
|
|||
}); |
|||
} |
|||
delRow = function(btn) { |
|||
if ($(btn).attr('name') == 'btn1') { |
|||
// console.log($(btn).parent().parent().prev('tr').find('input[id=register_code]').val()); |
|||
regDelStr += $(btn).parent().parent().parent().find('input[id=register_code]').val() + ","; |
|||
$(btn).parent().parent().next('tr').remove(); |
|||
console.log(regDelStr) |
|||
} else { |
|||
// console.log($(btn).parent().parent().find('input[id=register_code]').val()); |
|||
$(btn).parent().parent().next('tr').remove(); |
|||
$(btn).parent().parent().remove(); |
|||
} |
|||
$(btn).parent().parent().parent().parent().remove(); |
|||
} |
|||
setStandPrice = function(p, obj) { |
|||
$.ajax({ |
|||
url: '../cont/t.php', |
|||
data: p, |
|||
type: 'get', |
|||
dataType: 'json', |
|||
//success: function(data) {}, |
|||
success: function(data) { |
|||
console.info(data); |
|||
if (data.status == 'ok') { |
|||
$(obj).val(data.price); |
|||
} else { |
|||
$(obj).val(data.message); |
|||
|
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
addNewBrand = function() { |
|||
var new_brand = $("#new_brand").val(); |
|||
if (new_brand != '') { |
|||
p = { |
|||
new_brand: new_brand, |
|||
method: 'add_brand' |
|||
} |
|||
$.ajax({ |
|||
url: 'async_req.php', |
|||
data: p, |
|||
type: 'post', |
|||
dataType: 'json', |
|||
success: function(data) { |
|||
console.info(data); |
|||
$("#brand").append("<option value='" + data.seq + "'>" + new_brand + "</option>"); |
|||
}, |
|||
error: function(data) { |
|||
console.info(data); |
|||
} |
|||
|
|||
}); |
|||
} |
|||
|
|||
} |
|||
</script> |
|||
|
|||
|
|||
<body> |
|||
|
|||
<div id="toolbarmenu"> |
|||
<!--<span id="objName" style="font-size:16px;margin-bottom:0px;margin-top:1px">流程:<?php echo $flowName; ?></span>--> |
|||
<!-- 導航欄 --> |
|||
|
|||
<ul class="nav nav-tabs" role="tablist" id="tablist"> |
|||
<li class=" nav-item "> |
|||
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">簽核表單</a> |
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
</div> |
|||
<!-- 導航欄 END--> |
|||
<div class="tab-content "> |
|||
|
|||
<div class="tab-pane active assign_content " id="tabassign"> |
|||
<form action="submit.php" id='form' method="post" style='width:98%;margin:0 auto'> |
|||
<!-- hidden域 --> |
|||
<input type="hidden" name="form_key" value='<?php echo $form_key; ?>' /> |
|||
<input type="hidden" name="token" value='<?= $_GET['token'] ?>' /> |
|||
<input type="hidden" name="reg_del" id="reg_del"> |
|||
<input type="hidden" name="form_src" id="form_src" value="apply_form"> |
|||
<!--表單start--> |
|||
<div class=" form container-fluid pt-5"> |
|||
<div class="row form_head "> |
|||
<div class=" col-12 form_head_title "> |
|||
<h4> 保養契約價格審核單</h4> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row " style='padding-top:30px;'> |
|||
<div class=" col-lg-12 form_row_header "> |
|||
<b>契約信息</b> |
|||
</div> |
|||
</div> |
|||
|
|||
<?php |
|||
//一行顯示三列 |
|||
$i = 0; |
|||
echo " <div class='row '>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
$j = (($i++) % 4); |
|||
$fieldVal = empty($data) ? "" : $data[0][$key]; |
|||
|
|||
$_input = $val['tag'] == 'select' ? |
|||
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) |
|||
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); |
|||
//"<input type='" . $val['tag'] . "' class=' form-control form-control-sm " . $val['class'] . "' |
|||
// value='" . $fieldVal . "' name='$key' id='$key' placeholder='請輸入'>"; |
|||
if ($i != 1 && $j == 0) { |
|||
echo " |
|||
</div> |
|||
<div class='row'> |
|||
"; |
|||
} |
|||
echo " <div class='col-1 form_field_title'> |
|||
" . $val['label'] . " |
|||
</div> |
|||
<div class=' col-2 form_field_content ' > |
|||
$_input |
|||
</div> |
|||
"; |
|||
} |
|||
echo "</div>"; |
|||
|
|||
?> |
|||
|
|||
<div id="assign_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>洽商進度</b> |
|||
</div> |
|||
<div class="col-12 " style="padding:0"> |
|||
|
|||
<textarea class='form-control textarea' id="progress_remark" name="progress_remark" value='12' rows='6'><?= $hope_contract['progress_status'] ?></textarea> |
|||
</div> |
|||
</div> |
|||
<div id="elevator_list_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>電梯詳細資料</b> |
|||
</div> |
|||
<table style='margin-top:0px;text-align:center' class=' table-condensed' id='elevator_list1'> |
|||
|
|||
<thead> |
|||
<tr> |
|||
<td colspan='18' style='text-align:left;font-size:13px'> |
|||
<b>註意事項:</b> |
|||
<p>1.速度單位是 米/分.</p> |
|||
<p>2.選擇贈送M1,保養月數需填寫60.</p> |
|||
<p>3.標準價格未帶出,請聯係業務部建立該規格報價.</p> |
|||
<p>4.無機房速度20~60米 以60米為標準.</p> |
|||
|
|||
|
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan='18' ;><button onClick='addRow()' type="button" style='float:right' class="btn btn-link btn-md">+新增</button></td> |
|||
</tr> |
|||
</thead> |
|||
</table> |
|||
<table class=' table-condensed' id='elevator_list'> |
|||
<thead> |
|||
<tr style=' margin-top:0px;text-align:center'> |
|||
<th colspan="2">電梯許可代碼</th> |
|||
<th colspan="2">品牌</th> |
|||
<th colspan="2">電梯類型</th> |
|||
<th colspan="2">規格型號</th> |
|||
<th>載重(KG)</th> |
|||
<th colspan="2">速度(m/min)</th> |
|||
<th>停數</th> |
|||
<th>層數</th> |
|||
<th>人乘</th> |
|||
<th colspan="2">保養次數</th> |
|||
<th>保養月數</th> |
|||
<th>保養周期</th> |
|||
<th>贈送M1</th> |
|||
</tr> |
|||
|
|||
</thead> |
|||
<tbody id='cmecTbody'> |
|||
<tr> |
|||
<td colspan="2"> |
|||
<div class=' col-12'><input id="register_code" name="register_code[]" type="text" value placeholder="無證號請輸入A、B..." repuired class="form-control form=control-sm"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class=' col-12'> |
|||
<select name="elevator_brand[]" id="" class="form-control form-control-sm"> |
|||
<option value=""></option> |
|||
<?php foreach ($elevator_brand_opt as $data) : ?> |
|||
<option value="<?php echo $data['value']; ?>"><?php echo $data['label'] ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
</div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class=' col-12'> |
|||
<select name="elevator_kind[]" id="" class="form-control form-control-sm"> |
|||
<option value=""></option> |
|||
<?php foreach ($elevator_kind_opt as $data) : ?> |
|||
<option value="<?php echo $data['value'] ?>"><?php echo $data['label'] ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
</div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class=' col-12'> |
|||
<select name="spec[]" id="" class="form-control form-control-sm"> |
|||
<option value=""></option> |
|||
<?php foreach ($fp_kind_opt as $data) : ?> |
|||
<option value="<?php echo $data['value'] ?>"><?php echo $data['label'] ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
</div> |
|||
</td> |
|||
<!-- <td><section name='spec'></section></td> --> |
|||
<td> |
|||
<div class=' col-12'><input type="digits" id="weight" name="weight[]" value gt="0" min="0" required class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class=' col-12'><input type="number" id="speed" name="speed[]" valaue gt="0" min="0" require class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td> |
|||
<div class=' col-12'><input type="number" id="stop" name="stop[]" class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td> |
|||
<div class=' col-12'><input type="digits" id="floors" name="floors[]" value min="1" required class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td> |
|||
<div class=' col-12'><input type="digits" id="persons" name="persons[]" value min='1' required class="form-control form-contorl-sm"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class=' col-12'><input type="digits" id="maintain_times" name="maintain_times[]" value='1' min='1' required class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td> |
|||
<div class=' col-12'><input type="digits" id="maintain_months" name="maintain_months[]" value="12" min='12' required class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td> |
|||
<div class=' col-12'><input type="digits" id="maintain_period" name="maintain_period[]" value="1" min='1' require class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td> |
|||
<div class='col-12'> |
|||
<select name="is_m1_bundle[]" id required class="form-control form-control-sm" id=""> |
|||
<option value=""></option> |
|||
<?php foreach ($is_m1_bundle_opt as $data) : ?> |
|||
<option value="<?php $data['value'] ?>"><?php echo $data['label'] ?></option> |
|||
<?php endforeach ?> |
|||
</select> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
<thead> |
|||
<tr style='margin-top:0px;text-align:center'> |
|||
<th colspan="2">竣工檢查年度</th> |
|||
<th colspan="2">上次年檢日期</th> |
|||
<th colspan="2">年檢費用(元)</th> |
|||
<th colspan="2">標準價格(元/月)</th> |
|||
<th colspan="2">契約報價(元/月)</th> |
|||
<th colspan="2">契約成交價(元/月)</th> |
|||
<th>刪除</th> |
|||
|
|||
<th colspan="6"></th> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody id='cmecTbody2'> |
|||
<tr> |
|||
<td colspan="2"> |
|||
<div class="col-12"><input type="text" id="useful_years" name="useful_years[]" type="digits" value colspan='2' required gt='0' min='0' class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class="col-12"><input type="number" id="last_check_date" name="last_check_date[]" value required colspan="2" class="form-control form-control-sn"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class="col-12"><input type="text" id="annual_survey_expense" name="annual_survey_exoense[]" type="number" value required colspan='2' class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class="col-12"><input type="text" id='stand_price' name="stand_price[]" value required readonly colspan='2' class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class="col-12"><input type="number" id="contract_price" name="contract_price[]" required colsapn="2" class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td colspan="2"> |
|||
<div class="col-12"><input type="number" id="sold_price" name="sold_price[]" colspan='2' class="form-control form-control-sm"></div> |
|||
</td> |
|||
<td> |
|||
<div class=' col-12'><button onclick="delRow(this)" name='btn1' type="button" class="btn btn-link btn md">刪除</button></div> |
|||
</td> |
|||
<td colspan="6"></td> |
|||
|
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
|
|||
</div> |
|||
|
|||
<div id="assign_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>簽核操作</b> |
|||
</div> |
|||
<div class="col-12 col-3 form_field_content " style="padding:0"> |
|||
<textarea id="assign_opinion" name="assign_opinion" required></textarea> |
|||
</div> |
|||
</div> |
|||
<div class="row"> |
|||
<div class=" col-3 form_field_title"> |
|||
<b style='float:right'>簽核狀態</b> |
|||
</div> |
|||
<div class=" col-2 form_field_content "> |
|||
<select name="assign_status" id="assign_status" required class='form-control form-control form-control-sm '> |
|||
<?php echo $assign_status; ?> |
|||
</select> |
|||
</div> |
|||
|
|||
<div class=" col-2 form_field_title"> |
|||
<b>下位簽核者</b> |
|||
</div> |
|||
<div class="col-2 form_field_content"> |
|||
<select lect name="next_users" id="next_users" class='form-control form-control-sm '></select> |
|||
|
|||
</div> |
|||
<div class="col-3 form_field_title "> |
|||
<button type="submit" name="btn_save" class="btn btn-warning btn-sm" value="save" style='float:left;margin-right:4px;'>保存</button> |
|||
<button type="submit" name="btn_save" class="btn btn-primary btn-sm" value="tosign" style='float:left'>提交</button> |
|||
</div> |
|||
|
|||
</div> |
|||
<div id="opinion_area " class="row form_comment "> |
|||
<div class='col-12 '> |
|||
<ul class=" form-control-md nav nav-tabs" role="tablist" style='line-height:20px'> |
|||
<li class="active nav-item "> |
|||
<a href="#main_flow_assign" aria-controls="main_flow_assign" role="tab" class=" active nav-link" role="tab" data-toggle="tab">簽核意見</a> |
|||
</li> |
|||
|
|||
</ul> |
|||
</div> |
|||
<div class="tab-content col-12"> |
|||
<div role="tabpanel" class="tab-pane active" id="main_flow_assign"> |
|||
|
|||
<div class="comment_items "> |
|||
<?php $cnt = 1; |
|||
$tmp_code = "0"; |
|||
foreach ($assign_opinions as $as) { ?> |
|||
<div class="comment-item"> |
|||
|
|||
<!-- <div class="comment-title"> |
|||
<b>大 </b> |
|||
</div>--> |
|||
<?php |
|||
if (($as['flow_code']) != $tmp_code) |
|||
echo ' <div class="comment-title"> |
|||
<b>' . $wf->getNodeDescriptions($as['flow_code']) . '</b> |
|||
</div>'; |
|||
$tmp_code = $as['flow_code']; |
|||
?> |
|||
<div class="comment-content <?php if ($cnt++ % 2 == 0) echo "comment-odd" ?>"> |
|||
<div class="comment-content-header"> |
|||
<span> |
|||
|
|||
<strong> |
|||
<?php echo Employee::get_employee($as['assigner'], 'name-employee_no') ?> |
|||
|
|||
<?php if ($as['lead_code'] < 90) echo |
|||
" <label class='comment-content-tag'>" . $as['position_name'] . " </label>"; ?> |
|||
|
|||
</strong> |
|||
</span> |
|||
<span> |
|||
|
|||
<strong> |
|||
|
|||
<?php if ($as['assign_status'] == 'S') echo |
|||
" <label class='comment-content-tag'>申請人 </label>"; ?> |
|||
<?php if (substr($as['assign_status'], 0, 1) == 'B') |
|||
echo " <label class='comment-content-tag red-tag'>退回</label>"; ?> |
|||
<?php if (substr($as['assign_status'], 0, 2) == 'X3') |
|||
echo " <label class='comment-content-tag red-tag'>會簽</label>"; ?> |
|||
</strong> |
|||
</span> |
|||
<span class="comment-content-header-time"> |
|||
簽核於:<?= $as['assign_date'] ?> |
|||
</span> |
|||
|
|||
<!-- <ul class="comment-content-tags"> |
|||
<li class="">不同意</li> |
|||
<li class="comment-content-tag-alert">退回</li> |
|||
</ul>--> |
|||
</div> |
|||
<div class="comment-content-body"> |
|||
<?= $as['assign_opinion'] ?> |
|||
</div> |
|||
<!-- <div class="comment-content-footer"> |
|||
<span>已上載附件: </span><a href="#">附件1</a> |
|||
</div>--> |
|||
</div> |
|||
|
|||
</div> |
|||
<?php } ?> |
|||
|
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
<!-- 模態框(Modal) --> |
|||
<div class="modal fade" id="brandModal" tabindex="-1" role="dialog" aria-labelledby="brandModalLabel" aria-hidden="true"> |
|||
<div class="modal-dialog"> |
|||
<div class="modal-content"> |
|||
<div class="modal-header"> |
|||
新增廠牌 |
|||
</div> |
|||
<div class="modal-body"> |
|||
<input type="text" class='form-control form-control form-control-sm ' id='new_brand'> |
|||
|
|||
</div> |
|||
<div class="modal-footer"> |
|||
<button type="button" class="btn btn-primary" onClick="addNewBrand()" data-dismiss="modal">保存</button> |
|||
|
|||
</div> |
|||
</div><!-- /.modal-content --> |
|||
</div><!-- /.modal --> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
</body> |
@ -0,0 +1,42 @@ |
|||
<?php |
|||
$envFile = __DIR__ . '/.env'; // .env 文件的路径 |
|||
|
|||
if (file_exists($envFile)) { |
|||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|||
if ($lines !== false) { |
|||
foreach ($lines as $line) { |
|||
list($key, $value) = explode('=', $line, 2); |
|||
$key = trim($key); |
|||
$value = trim($value); |
|||
// 设置环境变量 |
|||
putenv("$key=$value"); |
|||
} |
|||
} |
|||
} |
|||
$db_hostname = getenv('DB_HOST'); //資料庫主機名稱 |
|||
$db_username = getenv('DB_USERNAME'); //登入資料庫的管理者的帳號 |
|||
$db_password = getenv('DB_PASSWORD'); //登入密碼 |
|||
$db_name = getenv('DB_DATABASE'); //使用的資料庫 |
|||
$db_charset = 'utf8'; //設定字元編碼 |
|||
|
|||
//建立PDO的指定工作 |
|||
$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; |
|||
|
|||
try { |
|||
//使用PDO連接到MySQL資料庫,建立PDO物件 |
|||
$conn = new PDO($dsn, $db_username, $db_password); |
|||
|
|||
//當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException) |
|||
//PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定 |
|||
//PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊 |
|||
//PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 |
|||
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 |
|||
//設定主動以警告的形式報錯 |
|||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|||
//如果連接錯誤,將抛出一個PDOException異常對象 |
|||
} catch (PDOException $e) { |
|||
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
|
|||
//$conn = null; //關閉資料庫的連線 |
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,78 +1,79 @@ |
|||
<?php |
|||
//require_once "../database.php"; |
|||
require_once './wf_common.php'; |
|||
require_once './model/ConMaintanceExamineApplyModel.php'; |
|||
require_once './model/ConMaintanceExamineClearModel.php'; |
|||
//print_r($_POST);exit; |
|||
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST; |
|||
$tosign = ($request["btn_save"] == "tosign") ? 1 : 0; // 1:提交 |
|||
|
|||
if ($request["form_src"] == "apply_form" && $tosign && (!isset($request["register_code"]) || empty($request["register_code"][0]) || !isset($request["next_users"]) || empty($request["next_users"]))) { |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
echo "alert('請確認電梯資料或未選擇下位簽核者!');"; |
|||
echo "history.go(-1);"; |
|||
echo "</script>"; |
|||
exit; |
|||
} |
|||
|
|||
//更新表单ConMaintanceExamineApplyModel |
|||
$cmea = new ConMaintanceExamineApplyModel(); |
|||
$apply_key=$request['apply_key']; |
|||
$cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => ''])); |
|||
//更新电梯列表 |
|||
if (!empty($request["reg_del"])) { |
|||
$register_code_del_arr = explode(",", rtrim($request["reg_del"], ",")); |
|||
foreach ($register_code_del_arr as $val) { |
|||
$sql = "update con_maintance_examine_clear set cmstatus = 'D' where apply_key = '$apply_key' and register_code = '$val' and cmstatus <> 'D'"; |
|||
DB::query($sql); |
|||
} |
|||
} |
|||
if (!empty($request['register_code']) && count($request['register_code']) > 0) { |
|||
$cmec = new ConMaintanceExamineClearModel(); |
|||
for ($i = 0; $i < count($request['register_code']); $i++) { |
|||
$data = [ |
|||
'apply_key' => $request['apply_key'] |
|||
]; |
|||
$cols = array_diff($cmec->fillable, ['apply_key']); |
|||
foreach ($cols as $col) { |
|||
$data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i]; |
|||
if ($col=="annual_survey_expense") $data[$col] = '0.00'; |
|||
} |
|||
$cmec->create($data); |
|||
} |
|||
} |
|||
|
|||
//var_dump($_POST); |
|||
//var_dump($_GET); |
|||
|
|||
if ($tosign) { |
|||
#流程开始,var_dump($request); |
|||
$flow = new Flow($request['form_key']); |
|||
// 当前节点签核开始 |
|||
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']); |
|||
$wf->setFormData($request); |
|||
$wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']); |
|||
//当前节点签核结束 |
|||
$responses['flowName'] = $wf->getFlowName(); |
|||
$responses['form_key'] = $request['form_key']; |
|||
//var_dump($request); |
|||
#結案發通知給營業員 |
|||
if ($request['assign_status'] == 'F4') { |
|||
|
|||
list($salesman, $case_name ) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key. "' "); |
|||
$ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`) |
|||
VALUES ( '1', '契約價審單結案通知(" .$case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')"; |
|||
DB::query($ins_notice_sql); |
|||
// echo $ins_notice_sql; |
|||
} |
|||
} |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
//echo "<h4 style='text-align:center'>成功提交<a href='https://www.masada.com.tw/wms/sign/list.php?function_name=show&token=" . $request['token'] . "'>返回待签 </a></h4>"; |
|||
if ($tosign) { |
|||
echo "alert('成功提交');"; |
|||
echo "location.href='../cont/sign_list.php?function_name=sign_list&token=".$request['token']."';"; |
|||
} else { |
|||
echo "alert('資料已保存');"; |
|||
echo "location.href='../crm/crmm02-index.php?function_name=contract_customer&token=".$request['token']."';"; |
|||
} |
|||
echo "</script>"; |
|||
<?php |
|||
//require_once "../database.php"; |
|||
require_once './wf_common.php'; |
|||
require_once './model/ConMaintanceExamineApplyModel.php'; |
|||
require_once './model/ConMaintanceExamineClearModel.php'; |
|||
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST; |
|||
// print_r($request); |
|||
// exit; |
|||
$tosign = ($request["btn_save"] == "tosign") ? 1 : 0; // 1:提交 |
|||
|
|||
if ($request["form_src"] == "apply_form" && $tosign && (!isset($request["register_code"]) || empty($request["register_code"][0]) || !isset($request["next_users"]) || empty($request["next_users"]))) { |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
echo "alert('請確認電梯資料或未選擇下位簽核者!');"; |
|||
echo "history.go(-1);"; |
|||
echo "</script>"; |
|||
exit; |
|||
} |
|||
|
|||
//更新表单ConMaintanceExamineApplyModel |
|||
$cmea = new ConMaintanceExamineApplyModel(); |
|||
$apply_key = $request['apply_key']; |
|||
$cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => ''])); |
|||
//更新电梯列表 |
|||
if (!empty($request["reg_del"])) { |
|||
$register_code_del_arr = explode(",", rtrim($request["reg_del"], ",")); |
|||
foreach ($register_code_del_arr as $val) { |
|||
$sql = "UPDATE con_maintance_examine_clear SET cmstatus = 'D' WHERE apply_key = '$apply_key' AND register_code = '$val' AND cmstatus <> 'D'"; |
|||
DB::query($sql); |
|||
} |
|||
} |
|||
if (!empty($request['register_code']) && count($request['register_code']) > 0) { |
|||
$cmec = new ConMaintanceExamineClearModel(); |
|||
for ($i = 0; $i < count($request['register_code']); $i++) { |
|||
$data = [ |
|||
'apply_key' => $request['apply_key'] |
|||
]; |
|||
$cols = array_diff($cmec->fillable, ['apply_key']); |
|||
foreach ($cols as $col) { |
|||
$data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i]; |
|||
if ($col == "annual_survey_expense") $data[$col] = '0.00'; |
|||
} |
|||
$cmec->create($data); |
|||
} |
|||
} |
|||
|
|||
//var_dump($_POST); |
|||
//var_dump($_GET); |
|||
|
|||
if ($tosign) { |
|||
#流程开始,var_dump($request); |
|||
$flow = new Flow($request['form_key']); |
|||
// 当前节点签核开始 |
|||
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']); |
|||
$wf->setFormData($request); |
|||
$wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']); |
|||
//当前节点签核结束 |
|||
$responses['flowName'] = $wf->getFlowName(); |
|||
$responses['form_key'] = $request['form_key']; |
|||
//var_dump($request); |
|||
#結案發通知給營業員 |
|||
if ($request['assign_status'] == 'F4') { |
|||
|
|||
list($salesman, $case_name) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key . "' "); |
|||
$ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`) |
|||
VALUES ( '1', '契約價審單結案通知(" . $case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')"; |
|||
DB::query($ins_notice_sql); |
|||
// echo $ins_notice_sql; |
|||
} |
|||
} |
|||
echo "<script type = 'text/JavaScript'>"; |
|||
//echo "<h4 style='text-align:center'>成功提交<a href='https://www.masada.com.tw/wms/sign/list.php?function_name=show&token=" . $request['token'] . "'>返回待签 </a></h4>"; |
|||
if ($tosign) { |
|||
echo "alert('成功提交');"; |
|||
echo "location.href='../wms/index.php.php?function_name=sign_list&token=" . $request['token'] . "';"; |
|||
} else { |
|||
echo "alert('資料已保存');"; |
|||
echo "location.href='../crm/crmm02-index.php?function_name=contract_customer&token=" . $request['token'] . "';"; |
|||
} |
|||
echo "</script>"; |
|||
|
@ -1,84 +1,84 @@ |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set('dispaly_errors', "On"); |
|||
require_once './MSCalculator.php'; |
|||
|
|||
|
|||
/* //客梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'A', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
*/ |
|||
/* //货梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'B', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
*/ |
|||
|
|||
/*//病床梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'C', |
|||
'floors' => 28, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 2, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
];*/ |
|||
|
|||
/*//无机房 |
|||
$param = [ |
|||
'elevator_type' => 'D', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 3, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
*/ |
|||
//家用梯 |
|||
$param = [ |
|||
'elevator_type' => 'E', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 60, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'Y', |
|||
]; |
|||
|
|||
$mic = new MSCalculator(); |
|||
$price = $mic->cal($_GET); |
|||
echo json_encode($price); |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set('dispaly_errors', "On"); |
|||
require_once './MSCalculator.php'; |
|||
|
|||
|
|||
//客梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'A', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
//货梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'B', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
|
|||
//病床梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'C', |
|||
'floors' => 28, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 2, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
//无机房 |
|||
$param = [ |
|||
'elevator_type' => 'D', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 3, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
|
|||
//家用梯 |
|||
$param = [ |
|||
'elevator_type' => 'E', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 60, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'Y', |
|||
]; |
|||
|
|||
$mic = new MSCalculator(); |
|||
$price = $mic->cal($_GET); |
|||
echo json_encode($price); |
|||
|
@ -1,126 +1,126 @@ |
|||
<?php |
|||
include "header.php"; |
|||
?> |
|||
|
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "contract-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> |
|||
|
|||
|
|||
<div> |
|||
<label for="contracttype">合約類型(必填)</label> |
|||
<Select name="contracttype" id="contracttype" required> |
|||
<option selected="selected" disabled="disabled" style="display: none" value=""></option> |
|||
<Option Value="A">定期保養</Option> |
|||
<Option Value="B">單次保養</Option> |
|||
<Option Value="C">單次維修</Option> |
|||
</Select> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractno">合約號(必填)</label> |
|||
<input type="text" name="contractno" id="contractno" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="company">公司名稱</label> |
|||
<input type="text" name="company" id="company" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="taxid">統一編號</label> |
|||
<input type="text" name="taxid" id="taxid" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="promiser">立約人</label> |
|||
<input type="text" name="promiser" id="promiser"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="customerid">客戶維護帳號(必填)</label> |
|||
<input type="text" name="customerid" id="customerid" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractperson">業務聯繫人</label> |
|||
<input type="text" name="contractperson" id="contractperson" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractaddress">業務聯繫人地址</label> |
|||
<input type="text" name="contractaddress" id="contractaddress" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contracttel">業務聯繫人電話(必填)</label> |
|||
<input type="text" name="contracttel" id="contracttel" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractemail">業務聯繫人郵件地址</label> |
|||
<input type="text" name="contractemail" id="contractemail" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contract_employee">契約人員工號</label> |
|||
<input type="text" name="contract_employee" id="contract_employee" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="start_date">合約起始年月日(必填)</label><br> |
|||
<input type="text" data-date-format="yyyy-mm-dd" name="start_date" id="start_date" value="<?php echo date('Y-m-d'); ?>" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="end_date">合約終止年月日(必填)</label><br> |
|||
<input type="text" data-date-format="yyyy-mm-dd" name="end_date" id="end_date" value="<?php echo date('Y-m-d',strtotime('+364 day')); ?>" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php include "footer.php"; ?> |
|||
<?php |
|||
include "header.php"; |
|||
?> |
|||
|
|||
<div class="container"> |
|||
|
|||
<?php |
|||
|
|||
include "contract-record-submit.php"; |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
echo "<p class='success'>Record has added successfully</p>"; |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
|
|||
|
|||
|
|||
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> |
|||
|
|||
|
|||
<div> |
|||
<label for="contracttype">合約類型(必填)</label> |
|||
<Select name="contracttype" id="contracttype" required> |
|||
<option selected="selected" disabled="disabled" style="display: none" value=""></option> |
|||
<Option Value="A">定期保養</Option> |
|||
<Option Value="B">單次保養</Option> |
|||
<Option Value="C">單次維修</Option> |
|||
</Select> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractno">合約號(必填)</label> |
|||
<input type="text" name="contractno" id="contractno" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="company">公司名稱</label> |
|||
<input type="text" name="company" id="company" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="taxid">統一編號</label> |
|||
<input type="text" name="taxid" id="taxid" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="promiser">立約人</label> |
|||
<input type="text" name="promiser" id="promiser"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="customerid">客戶維護帳號(必填)</label> |
|||
<input type="text" name="customerid" id="customerid" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractperson">業務聯繫人</label> |
|||
<input type="text" name="contractperson" id="contractperson" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractaddress">業務聯繫人地址</label> |
|||
<input type="text" name="contractaddress" id="contractaddress" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contracttel">業務聯繫人電話(必填)</label> |
|||
<input type="text" name="contracttel" id="contracttel" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractemail">業務聯繫人郵件地址</label> |
|||
<input type="text" name="contractemail" id="contractemail" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contract_employee">契約人員工號</label> |
|||
<input type="text" name="contract_employee" id="contract_employee" > |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="start_date">合約起始年月日(必填)</label><br> |
|||
<input type="text" data-date-format="yyyy-mm-dd" name="start_date" id="start_date" value="<?php echo date('Y-m-d'); ?>" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="end_date">合約終止年月日(必填)</label><br> |
|||
<input type="text" data-date-format="yyyy-mm-dd" name="end_date" id="end_date" value="<?php echo date('Y-m-d',strtotime('+364 day')); ?>" required> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> |
|||
<p class="error"><?php echo $creater_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<!-- <label for="create_at">create_at</label> --> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> |
|||
<p class="error"><?php echo $create_at_error; ?></p> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="submit">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php include "footer.php"; ?> |
|||
|
@ -1,12 +1,12 @@ |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "DELETE FROM contract WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
|
|||
header("Refresh:0; url=contract-index.php?function_name=contract&".$token_link); |
|||
ob_end_flush(); |
|||
<?php |
|||
ob_start(); |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$db_query = "DELETE FROM contract WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
|
|||
header("Refresh:0; url=contract-index.php?function_name=contract&".$token_link); |
|||
ob_end_flush(); |
|||
?> |
@ -1,142 +1,142 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM contract WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
/* |
|||
include "inc/record_update.php"; |
|||
|
|||
try { |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM expert WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
}catch (Exception $e) { |
|||
echo 'Caught exception: ', $e->getMessage(), "\n"; |
|||
} |
|||
*/ |
|||
foreach($data as $data) : |
|||
?> |
|||
|
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="contract-record-update.php" enctype="multipart/form-data"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="contracttype">合約類型</label> |
|||
<Select name="contracttype" id="contracttype" required> |
|||
<?php |
|||
switch ($data['contracttype']) { |
|||
case "A": |
|||
echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>"; |
|||
break; |
|||
case "B": |
|||
echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>"; |
|||
break; |
|||
case "C": |
|||
echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>"; |
|||
break; |
|||
} |
|||
?> |
|||
</Select> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractno">合約號</label> |
|||
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="company">公司名稱</label> |
|||
<input type="text" name="company" id="company" value="<?php echo $data['company']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="taxid">統一編號</label> |
|||
<input type="text" name="taxid" id="taxid" value="<?php echo $data['taxid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="promiser">立約人</label> |
|||
<input type="text" name="promiser" id="promiser" value="<?php echo $data['promiser']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="customerid">客戶維護帳號</label> |
|||
<input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractperson">業務聯繫人</label> |
|||
<input type="text" name="contractperson" id="contractperson" value="<?php echo $data['contractperson']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractaddress">業務聯繫人地址</label> |
|||
<input type="text" name="contractaddress" id="contractaddress" value="<?php echo $data['contractaddress']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contracttel">業務聯繫人電話</label> |
|||
<input type="text" name="contracttel" id="contracttel" value="<?php echo $data['contracttel']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractemail">業務聯繫人郵件地址</label> |
|||
<input type="text" name="contractemail" id="contractemail" value="<?php echo $data['contractemail']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contract_employee">契約人員工號</label> |
|||
<input type="text" name="contract_employee" id="contract_employee" value="<?php echo $data['contract_employee']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="start_date">合約起始年月日</label> |
|||
<input type="text" name="start_date" id="start_date" value="<?php echo $data['start_date']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="end_date">合約終止年月日</label> |
|||
<input type="text" name="end_date" id="end_date" value="<?php echo $data['end_date']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM contract WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
/* |
|||
include "inc/record_update.php"; |
|||
|
|||
try { |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$db_query = "SELECT * FROM expert WHERE id=$id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$db_query); |
|||
}catch (Exception $e) { |
|||
echo 'Caught exception: ', $e->getMessage(), "\n"; |
|||
} |
|||
*/ |
|||
foreach($data as $data) : |
|||
?> |
|||
|
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="contract-record-update.php" enctype="multipart/form-data"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
|
|||
<div> |
|||
<label for="contracttype">合約類型</label> |
|||
<Select name="contracttype" id="contracttype" required> |
|||
<?php |
|||
switch ($data['contracttype']) { |
|||
case "A": |
|||
echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>"; |
|||
break; |
|||
case "B": |
|||
echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>"; |
|||
break; |
|||
case "C": |
|||
echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>"; |
|||
break; |
|||
} |
|||
?> |
|||
</Select> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractno">合約號</label> |
|||
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="company">公司名稱</label> |
|||
<input type="text" name="company" id="company" value="<?php echo $data['company']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="taxid">統一編號</label> |
|||
<input type="text" name="taxid" id="taxid" value="<?php echo $data['taxid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="address">地址</label> |
|||
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="tel">電話</label> |
|||
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="promiser">立約人</label> |
|||
<input type="text" name="promiser" id="promiser" value="<?php echo $data['promiser']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="customerid">客戶維護帳號</label> |
|||
<input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractperson">業務聯繫人</label> |
|||
<input type="text" name="contractperson" id="contractperson" value="<?php echo $data['contractperson']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractaddress">業務聯繫人地址</label> |
|||
<input type="text" name="contractaddress" id="contractaddress" value="<?php echo $data['contractaddress']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contracttel">業務聯繫人電話</label> |
|||
<input type="text" name="contracttel" id="contracttel" value="<?php echo $data['contracttel']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contractemail">業務聯繫人郵件地址</label> |
|||
<input type="text" name="contractemail" id="contractemail" value="<?php echo $data['contractemail']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="contract_employee">契約人員工號</label> |
|||
<input type="text" name="contract_employee" id="contract_employee" value="<?php echo $data['contract_employee']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="start_date">合約起始年月日</label> |
|||
<input type="text" name="start_date" id="start_date" value="<?php echo $data['start_date']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="end_date">合約終止年月日</label> |
|||
<input type="text" name="end_date" id="end_date" value="<?php echo $data['end_date']; ?>"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
|
@ -1,162 +1,162 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 工務總處可瀏覽全部資料 |
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = ""; |
|||
$sql = "SELECT * FROM contract $sql_cmd ORDER BY id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth&2) { ?> |
|||
<p> |
|||
<a href="contract-create.php?function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
<?php |
|||
} |
|||
if($data): |
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:contract-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>業務聯繫人</th> |
|||
<th>業務聯繫人地址</th> |
|||
<th>業務聯繫人電話</th> |
|||
<th>業務聯繫人郵件地址</th> |
|||
<th>契約人員工號</th> |
|||
<th>合約起始日</th> |
|||
<th>合約終止日</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<?php if ($user_auth&2) { ?> |
|||
<th>修改</th> |
|||
<!--<th>刪除</th>--> |
|||
<?php } ?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php foreach($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['contracttype']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['company']; ?></td> |
|||
<td><?php echo $data['taxid']; ?></td> |
|||
<td><?php echo $data['address']; ?></td> |
|||
<td><?php echo $data['tel']; ?></td> |
|||
<td><?php echo $data['promiser']; ?></td> |
|||
<td><?php echo $data['customerid']; ?></td> |
|||
<td><?php echo $data['contractperson']; ?></td> |
|||
<td><?php echo $data['contractaddress']; ?></td> |
|||
<td><?php echo $data['contracttel']; ?></td> |
|||
<td><?php echo $data['contractemail']; ?></td> |
|||
<td><?php echo $data['contract_employee']; ?></td> |
|||
<td><?php echo $data['start_date']; ?></td> |
|||
<td><?php echo $data['end_date']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<?php if ($user_auth&2) { ?> |
|||
<td> |
|||
<p> |
|||
<a href="contract-edit.php?id=<?php echo $data['id']; ?>&function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<!--<td> |
|||
<p> |
|||
<a href="contract-delete.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td>--> |
|||
<?php } ?> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
// 工務總處可瀏覽全部資料 |
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = ""; |
|||
$sql = "SELECT * FROM contract $sql_cmd ORDER BY id"; |
|||
|
|||
// 用mysqli_query方法執行(sql語法)將結果存在變數中 |
|||
$data = mysqli_query($link,$sql); |
|||
?> |
|||
|
|||
<!-- <a href="create.php"><h2>新增</h2></a> --> |
|||
<?php if ($user_auth&2) { ?> |
|||
<p> |
|||
<a href="contract-create.php?function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
<?php |
|||
} |
|||
if($data): |
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:contract-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
|
|||
<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> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>業務聯繫人</th> |
|||
<th>業務聯繫人地址</th> |
|||
<th>業務聯繫人電話</th> |
|||
<th>業務聯繫人郵件地址</th> |
|||
<th>契約人員工號</th> |
|||
<th>合約起始日</th> |
|||
<th>合約終止日</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<?php if ($user_auth&2) { ?> |
|||
<th>修改</th> |
|||
<!--<th>刪除</th>--> |
|||
<?php } ?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php foreach($data as $data) : ?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['contracttype']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['company']; ?></td> |
|||
<td><?php echo $data['taxid']; ?></td> |
|||
<td><?php echo $data['address']; ?></td> |
|||
<td><?php echo $data['tel']; ?></td> |
|||
<td><?php echo $data['promiser']; ?></td> |
|||
<td><?php echo $data['customerid']; ?></td> |
|||
<td><?php echo $data['contractperson']; ?></td> |
|||
<td><?php echo $data['contractaddress']; ?></td> |
|||
<td><?php echo $data['contracttel']; ?></td> |
|||
<td><?php echo $data['contractemail']; ?></td> |
|||
<td><?php echo $data['contract_employee']; ?></td> |
|||
<td><?php echo $data['start_date']; ?></td> |
|||
<td><?php echo $data['end_date']; ?></td> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<?php if ($user_auth&2) { ?> |
|||
<td> |
|||
<p> |
|||
<a href="contract-edit.php?id=<?php echo $data['id']; ?>&function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<!--<td> |
|||
<p> |
|||
<a href="contract-delete.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')"> |
|||
<span class="glyphicon glyphicon-remove"></span> |
|||
</a> |
|||
</p> |
|||
</td>--> |
|||
<?php } ?> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
|||
|
@ -1,61 +1,61 @@ |
|||
<?php |
|||
$contracttype= ""; |
|||
$contractno= ""; |
|||
$company= ""; |
|||
$taxid= ""; |
|||
$address= ""; |
|||
$tel= ""; |
|||
$promiser= ""; |
|||
$customerid= ""; |
|||
$contractperson= ""; |
|||
$contractaddress= ""; |
|||
$contracttel= ""; |
|||
$contractemail= ""; |
|||
$contract_employee= ""; |
|||
$start_date= ""; |
|||
$end_date= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
$contracttype_error= ""; |
|||
$contractno_error= ""; |
|||
$company_error= ""; |
|||
$taxid_error= ""; |
|||
$address_error= ""; |
|||
$tel_error= ""; |
|||
$promiser_error= ""; |
|||
$customerid_error= ""; |
|||
$contractperson_error= ""; |
|||
$contractaddress_error= ""; |
|||
$contracttel_error= ""; |
|||
$contractemail_error= ""; |
|||
$contract_employee_error= ""; |
|||
$start_date_error= ""; |
|||
$end_date_error= ""; |
|||
$creater_error = ""; |
|||
$create_at_error = ""; |
|||
|
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
include "contract-user-input.php"; |
|||
|
|||
$db_query = "INSERT INTO contract(contracttype, contractno, company, taxid, address, tel, promiser, customerid, contractperson, contractaddress, contracttel, contractemail,contract_employee,start_date,end_date, creater, create_at) VALUES ('$contracttype', '$contractno', '$company', '$taxid', '$address', '$tel', '$promiser', '$customerid', '$contractperson', '$contractaddress', '$contracttel', '$contractemail','$contract_employee','$start_date','$end_date', '$creater', '$create_at')"; |
|||
$result = mysqli_query($link,$db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
|
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('新增成功');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
|||
<?php |
|||
$contracttype= ""; |
|||
$contractno= ""; |
|||
$company= ""; |
|||
$taxid= ""; |
|||
$address= ""; |
|||
$tel= ""; |
|||
$promiser= ""; |
|||
$customerid= ""; |
|||
$contractperson= ""; |
|||
$contractaddress= ""; |
|||
$contracttel= ""; |
|||
$contractemail= ""; |
|||
$contract_employee= ""; |
|||
$start_date= ""; |
|||
$end_date= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
|
|||
$contracttype_error= ""; |
|||
$contractno_error= ""; |
|||
$company_error= ""; |
|||
$taxid_error= ""; |
|||
$address_error= ""; |
|||
$tel_error= ""; |
|||
$promiser_error= ""; |
|||
$customerid_error= ""; |
|||
$contractperson_error= ""; |
|||
$contractaddress_error= ""; |
|||
$contracttel_error= ""; |
|||
$contractemail_error= ""; |
|||
$contract_employee_error= ""; |
|||
$start_date_error= ""; |
|||
$end_date_error= ""; |
|||
$creater_error = ""; |
|||
$create_at_error = ""; |
|||
|
|||
|
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
include "contract-user-input.php"; |
|||
|
|||
$db_query = "INSERT INTO contract(contracttype, contractno, company, taxid, address, tel, promiser, customerid, contractperson, contractaddress, contracttel, contractemail,contract_employee,start_date,end_date, creater, create_at) VALUES ('$contracttype', '$contractno', '$company', '$taxid', '$address', '$tel', '$promiser', '$customerid', '$contractperson', '$contractaddress', '$contracttel', '$contractemail','$contract_employee','$start_date','$end_date', '$creater', '$create_at')"; |
|||
$result = mysqli_query($link,$db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
|
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('新增成功');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
|||
|
@ -1,50 +1,50 @@ |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
|
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
$id = $_POST['id']; |
|||
$contracttype = user_input($_POST["contracttype"]); |
|||
$contractno = user_input($_POST["contractno"]); |
|||
$company = user_input($_POST["company"]); |
|||
$taxid = user_input($_POST["taxid"]); |
|||
$address = user_input($_POST["address"]); |
|||
$tel = user_input($_POST["tel"]); |
|||
$promiser = user_input($_POST["promiser"]); |
|||
$customerid = user_input($_POST["customerid"]); |
|||
$contractperson = user_input($_POST["contractperson"]); |
|||
$contractaddress = user_input($_POST["contractaddress"]); |
|||
$contracttel = user_input($_POST["contracttel"]); |
|||
$contractemail = user_input($_POST["contractemail"]); |
|||
$contract_employee = user_input($_POST["contract_employee"]); |
|||
$start_date = user_input($_POST["start_date"]); |
|||
$end_date = user_input($_POST["end_date"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
$db_query = "UPDATE contract set contracttype = '$contracttype', contractno = '$contractno', company = '$company', taxid = '$taxid', address = '$address', tel = '$tel', promiser = '$promiser', customerid = '$customerid', contractperson = '$contractperson', contractaddress = '$contractaddress', contracttel = '$contracttel', contractemail = '$contractemail', contract_employee = '$contract_employee',start_date = '$start_date',end_date = '$end_date',create_at = '$create_at' WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
<?php |
|||
include "header.php"; |
|||
|
|||
if(isset($_POST['update'])) { |
|||
|
|||
function user_input( $data ) { |
|||
$data1 = trim($data); |
|||
$data2 = stripslashes($data1); |
|||
$data3 = htmlspecialchars($data2); |
|||
return $data3; |
|||
} |
|||
|
|||
$id = $_POST['id']; |
|||
$contracttype = user_input($_POST["contracttype"]); |
|||
$contractno = user_input($_POST["contractno"]); |
|||
$company = user_input($_POST["company"]); |
|||
$taxid = user_input($_POST["taxid"]); |
|||
$address = user_input($_POST["address"]); |
|||
$tel = user_input($_POST["tel"]); |
|||
$promiser = user_input($_POST["promiser"]); |
|||
$customerid = user_input($_POST["customerid"]); |
|||
$contractperson = user_input($_POST["contractperson"]); |
|||
$contractaddress = user_input($_POST["contractaddress"]); |
|||
$contracttel = user_input($_POST["contracttel"]); |
|||
$contractemail = user_input($_POST["contractemail"]); |
|||
$contract_employee = user_input($_POST["contract_employee"]); |
|||
$start_date = user_input($_POST["start_date"]); |
|||
$end_date = user_input($_POST["end_date"]); |
|||
$creater = user_input($_POST["creater"]); |
|||
$create_at = date('Y/m/d H:i:s'); |
|||
|
|||
$db_query = "UPDATE contract set contracttype = '$contracttype', contractno = '$contractno', company = '$company', taxid = '$taxid', address = '$address', tel = '$tel', promiser = '$promiser', customerid = '$customerid', contractperson = '$contractperson', contractaddress = '$contractaddress', contracttel = '$contracttel', contractemail = '$contractemail', contract_employee = '$contract_employee',start_date = '$start_date',end_date = '$end_date',create_at = '$create_at' WHERE id='$id'"; |
|||
mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
@ -0,0 +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()); |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
<?php |
|||
|
|||
class CreateComboNo{ |
|||
private $comboarr = [ |
|||
'week'=>'BW002', |
|||
'month'=>'EM002', |
|||
'quarter'=>'EQ002', |
|||
'half'=>'HY002', |
|||
'year'=>'EY002' |
|||
]; |
|||
private $bwarr = [ |
|||
'week','month','week','month','week','quarter', |
|||
'week','month','week','month','week','half', |
|||
'week','month','week','month','week','quarter', |
|||
'week','month','week','month','week','year' |
|||
]; |
|||
private $emarr = [ |
|||
'month','month','quarter','month','month','half', |
|||
'month','month','quarter','month','month','year' |
|||
]; |
|||
private $combo; |
|||
private $startdate; |
|||
private $enddate; |
|||
public function __construct($combo, $startdate, $enddate){ |
|||
$this->combo = $combo; |
|||
$this->startdate = $startdate; |
|||
$this->enddate = $enddate; |
|||
} |
|||
public function getComboNo(){ |
|||
$comboarr = (array) $this->combo === 'bw' ? $this->bwarr : $this->emarr; |
|||
|
|||
$startdate = new DateTime($this->startdate); |
|||
$enddate = new DateTime($this->enddate); |
|||
|
|||
$interval = date_diff($startdate, $enddate); |
|||
|
|||
$months = $interval->y * 12 + $interval->m; |
|||
$months = $this->combo === 'bw' ? $months*2 : $months; |
|||
|
|||
$newarr = []; |
|||
$idx = 0; |
|||
$ori_first_month = date('m', strtotime($this->startdate)); |
|||
$first_day = date('Y-m-d', strtotime($this->startdate. ' + 3 days')); |
|||
$new_first_month = date('m', strtotime($first_day)); |
|||
if($ori_first_month != $new_first_month){ |
|||
$first_day = date('Y-m-t', strtotime($this->startdate)); |
|||
} |
|||
$scheduleDate = new DateTime($first_day); |
|||
for ($i = 0; $i < $months; $i++){ |
|||
$newarr[] = [$this->comboarr[$comboarr[$idx]], $scheduleDate->format("Y-m-d")]; |
|||
$idx ++; |
|||
$scheduleDate = $startdate->modify("+1 month"); |
|||
if($idx >= count($comboarr)){ |
|||
$idx = 0; |
|||
} |
|||
} |
|||
return json_encode($newarr); |
|||
} |
|||
} |
@ -0,0 +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['repair_no']) && $_GET['repair_no'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') { |
|||
try { |
|||
$repair_no = $_GET['repair_no']; |
|||
$fail_arr = []; |
|||
$d_status = '1'; |
|||
// 判斷單號是否在合約簽核已建立 |
|||
$sql = "SELECT COUNT(*) AS num FROM contract_r_signed_back WHERE repair_no = :repair_no AND delete_status = :d_status "; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(":repair_no", $repair_no); |
|||
$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 repair_no = :repair_no"; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(":repair_no", $repair_no); |
|||
$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.repair_no = :repair_no "; |
|||
$stmt = $conn->prepare($sql); |
|||
|
|||
$stmt->bindParam(':repair_no', $repair_no); |
|||
$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()); |
|||
} |
|||
} |
@ -0,0 +1,518 @@ |
|||
<?php |
|||
//ini_set('display_errors', 'on'); |
|||
// 汰改 前三碼 流水號 + 後兩碼 號機 |
|||
// 新梯 流水號 |
|||
|
|||
// 新增 seq 的初始值 |
|||
// INSERT INTO `sequence` (`seq_name`, `current_val`, `increment_val`, `remark`, `yyyymm`, `prefix`, `creator`, `create_at`) VALUES ('bf_vol_no', '0', '1', '保養-作番編號', '202310', '', 'M0117', '2023-10-26 11:28:11'), ('mf_vol_no', '0', '1', '新梯-作番編號', '202310', '', 'M0117', '2023-10-26 11:28:11'), ('tf_vol_no', '0', '1', '汰改-作番編號', '202310', '', 'M0117', '2023-10-26 11:28:11') |
|||
|
|||
|
|||
class CreateFacilityNo |
|||
{ |
|||
/** |
|||
* 連接資料庫 |
|||
*/ |
|||
function connectionDB() |
|||
{ |
|||
$envFile = __DIR__ . '/../../../.env'; |
|||
if (file_exists($envFile)) { |
|||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|||
if ($lines !== false) { |
|||
foreach ($lines as $line) { |
|||
list($key, $value) = explode('=', $line, 2); |
|||
$key = trim($key); |
|||
$value = trim($value); |
|||
putenv("$key=$value"); |
|||
} |
|||
} |
|||
} |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$host = getenv('DB_HOST'); |
|||
$dbport = getenv('DB_PORT'); |
|||
$dbuser = getenv('DB_USERNAME'); |
|||
$dbpassword = getenv('DB_PASSWORD'); |
|||
$dbname = getenv('DB_DATABASE'); |
|||
|
|||
try { |
|||
$options = [ |
|||
PDO::ATTR_PERSISTENT => false, |
|||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
|||
PDO::ATTR_EMULATE_PREPARES => false, |
|||
PDO::ATTR_STRINGIFY_FETCHES => false, |
|||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', |
|||
]; |
|||
$pdo = new PDO('mysql:host=' . $host . ';port=' . $dbport . ';dbname=' . $dbname . '', $dbuser, $dbpassword, $options); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
return $pdo; |
|||
} catch (PDOException $e) { |
|||
die("Something wrong: {$e->getMessage()}"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 結束資料庫連線 |
|||
*/ |
|||
function endConnectionDB($pdo) |
|||
{ |
|||
unset($pdo); |
|||
} |
|||
|
|||
/** |
|||
* 取得下一個新的作番 |
|||
* @param string $facility_type : M:新梯 T:汰改 B:保養 |
|||
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 |
|||
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 |
|||
* @param int $num : 號機 |
|||
* @return array $new_facility_arr |
|||
*/ |
|||
function getNextFacilityNo($facility_type, $sale_type, $make_type, $num = 1) |
|||
{ |
|||
$this->checkYearAndResetAllSeq(); |
|||
$Y = substr(date("Y"), 3, 1); |
|||
|
|||
switch ($facility_type) { |
|||
case "M": |
|||
$next_seq = $this->getNextFacilitySeq("mf_vol_no") + 1; |
|||
$new_facility_arr = []; |
|||
for ($start_num = 1; $start_num <= $num; $start_num++) { |
|||
$facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1] |
|||
. str_pad($next_seq, 5, "0", STR_PAD_LEFT); |
|||
array_push($new_facility_arr, $facility_no_tmp); |
|||
$next_seq++; |
|||
} |
|||
return $new_facility_arr; |
|||
case "T": |
|||
$next_seq = $this->getNextFacilitySeq("tf_vol_no"); |
|||
$new_facility_arr = []; |
|||
for ($start_num = 1; $start_num <= $num; $start_num++) { |
|||
$facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1] |
|||
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) |
|||
. str_pad($start_num, 2, "0", STR_PAD_LEFT); |
|||
array_push($new_facility_arr, $facility_no_tmp); |
|||
} |
|||
return $new_facility_arr; |
|||
case "B": |
|||
$next_seq = $this->getNextFacilitySeq("bf_vol_no"); |
|||
$new_facility_arr = []; |
|||
for ($start_num = 1; $start_num <= $num; $start_num++) { |
|||
$facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1] |
|||
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) |
|||
. str_pad($start_num, 2, "0", STR_PAD_LEFT); |
|||
array_push($new_facility_arr, $facility_no_tmp); |
|||
} |
|||
return $new_facility_arr; |
|||
default: |
|||
return "不存在的作番類型"; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 建立新的作番 |
|||
* @param string $facility_type : M:新梯 T:汰改 B:保養 |
|||
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 |
|||
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 |
|||
* @param string $num : 號機 (非必填) |
|||
* @return string $new_facility_no |
|||
*/ |
|||
function makeFacilityNo($facility_type, $sale_type, $make_type, $num = null) |
|||
{ |
|||
|
|||
$this->checkYearAndResetAllSeq(); |
|||
|
|||
$faclikity_details = array( |
|||
'facility_type' => $facility_type, |
|||
'sale_type' => $sale_type, |
|||
'make_type' => $make_type, |
|||
'num' => $num |
|||
); |
|||
|
|||
switch ($facility_type) { |
|||
case "M": |
|||
return $this->makeNewMFacilityNo($faclikity_details); |
|||
break; |
|||
case "T": |
|||
return $this->makeNewTFacilityNo($faclikity_details); |
|||
break; |
|||
case "B": |
|||
return $this->makeNewBFacilityNo($faclikity_details); |
|||
break; |
|||
default: |
|||
return "不存在的作番類型"; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 建立作番 -- 新梯 |
|||
*/ |
|||
function makeNewMFacilityNo($faclikity_details) |
|||
{ |
|||
$Y = substr(date("Y"), 3, 1); |
|||
$sale_type = $faclikity_details['sale_type']; |
|||
$make_type = $faclikity_details['make_type']; |
|||
$num = $faclikity_details['num']; |
|||
$next_seq = $this->getNextFacilitySeq("mf_vol_no") + 1; |
|||
$new_facility_no_arr = []; |
|||
|
|||
for ($i = 1; $i <= $num; $i++) { |
|||
$new_facility_no = $Y . $sale_type . $make_type[$i - 1] |
|||
. str_pad($next_seq, 5, "0", STR_PAD_LEFT); |
|||
array_push($new_facility_no_arr, $new_facility_no); |
|||
$next_seq++; |
|||
} |
|||
|
|||
foreach ($new_facility_no_arr as $new_facility_no) { |
|||
if ($this->getMakeNewMFacilityNoStatus($faclikity_details) !== "1") { |
|||
return $new_facility_no . ":" . $this->getMakeNewTFacilityNoStatus($faclikity_details); |
|||
} |
|||
// seq +1 |
|||
$this->facilitySeqAddOne("M"); |
|||
} |
|||
return $new_facility_no_arr; |
|||
} |
|||
|
|||
/** |
|||
* 建立作番 -- 汰改 |
|||
*/ |
|||
function makeNewTFacilityNo($faclikity_details) |
|||
{ |
|||
|
|||
$Y = substr(date("Y"), 3, 1); |
|||
$sale_type = $faclikity_details['sale_type']; |
|||
$make_type = $faclikity_details['make_type']; |
|||
$num = $faclikity_details['num']; |
|||
$next_seq = $this->getNextFacilitySeq("tf_vol_no"); |
|||
$new_facility_no_arr = []; |
|||
|
|||
for ($i = 1; $i <= $num; $i++) { |
|||
$new_facility_no = $Y . $sale_type . $make_type[$i - 1] |
|||
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) |
|||
. str_pad($i, 2, "0", STR_PAD_LEFT); |
|||
array_push($new_facility_no_arr, $new_facility_no); |
|||
} |
|||
|
|||
foreach ($new_facility_no_arr as $new_facility_no) { |
|||
if ($this->getMakeNewTFacilityNoStatus($faclikity_details) !== "1") { |
|||
return $new_facility_no . ":" . $this->getMakeNewTFacilityNoStatus($faclikity_details); |
|||
} |
|||
// seq +1 |
|||
$this->facilitySeqAddOne("T"); |
|||
return $new_facility_no_arr; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 建立作番 -- 保養 |
|||
*/ |
|||
function makeNewBFacilityNo($faclikity_details) |
|||
{ |
|||
|
|||
$Y = substr(date("Y"), 3, 1); |
|||
$sale_type = $faclikity_details['sale_type']; |
|||
$make_type = $faclikity_details['make_type']; |
|||
$num = $faclikity_details['num']; |
|||
$next_seq = $this->getNextFacilitySeq("bf_vol_no"); |
|||
$new_facility_no_arr = []; |
|||
|
|||
for ($i = 1; $i <= $num; $i++) { |
|||
$new_facility_no = $Y . $sale_type . $make_type[$i - 1] |
|||
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT) |
|||
. str_pad($i, 2, "0", STR_PAD_LEFT); |
|||
array_push($new_facility_no_arr, $new_facility_no); |
|||
} |
|||
|
|||
foreach ($new_facility_no_arr as $new_facility_no) { |
|||
if ($this->getMakeNewBFacilityNoStatus($faclikity_details) !== "1") { |
|||
return $new_facility_no . ":" . $this->getMakeNewBFacilityNoStatus($faclikity_details); |
|||
} |
|||
// seq +1 |
|||
$this->facilitySeqAddOne("B"); |
|||
return $new_facility_no_arr; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 檢查作番編列狀態 - 新梯 |
|||
* @param array $faclikity_details |
|||
* @return string $status : 1:正確 else:error message |
|||
*/ |
|||
function getMakeNewMFacilityNoStatus($faclikity_details) |
|||
{ |
|||
$sale_type = $faclikity_details['sale_type']; |
|||
$make_type = $faclikity_details['make_type']; |
|||
|
|||
if ($this->checkSaleTypeStatus($sale_type) == false) |
|||
return "銷售代號錯誤"; |
|||
if ($this->checkMakeTypeStatus($make_type) == false) |
|||
return "製造編號類型錯誤"; |
|||
return "1"; |
|||
} |
|||
|
|||
/** |
|||
* 檢查作番編列狀態 - 汰改 |
|||
* @param array $faclikity_details |
|||
* @return string $status : 1:正確 else:error message |
|||
*/ |
|||
function getMakeNewTFacilityNoStatus($faclikity_details) |
|||
{ |
|||
$sale_type = $faclikity_details['sale_type']; |
|||
$make_type = $faclikity_details['make_type']; |
|||
|
|||
if ($this->checkSaleTypeStatus($sale_type) == false) |
|||
return "銷售代號錯誤"; |
|||
if ($this->checkMakeTypeStatus($make_type) == false) |
|||
return "製造編號類型錯誤"; |
|||
return "1"; |
|||
} |
|||
|
|||
/** |
|||
* 檢查作番編列狀態 - 保養 |
|||
* @param array $faclikity_details |
|||
* @return string $status : 1:正確 else:error message |
|||
*/ |
|||
function getMakeNewBFacilityNoStatus($faclikity_details) |
|||
{ |
|||
$sale_type = $faclikity_details['sale_type']; |
|||
$make_type = $faclikity_details['make_type']; |
|||
|
|||
if ($this->checkSaleTypeStatus($sale_type) == false) |
|||
return "銷售代號錯誤"; |
|||
if ($this->checkMakeTypeStatus($make_type) == false) |
|||
return "製造編號類型錯誤"; |
|||
return "1"; |
|||
} |
|||
|
|||
/** |
|||
* seq 取號 |
|||
* @param string $type M:新梯 T:汰改 B:保養 |
|||
*/ |
|||
function facilitySeqAddOne($type) |
|||
{ |
|||
$type_arr = array( |
|||
"M" => "mf_vol_no", |
|||
"T" => "tf_vol_no", |
|||
"B" => "bf_vol_no", |
|||
); |
|||
if (!empty($type_arr[$type])) { |
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$sth = $pdo->prepare('UPDATE sequence SET current_val = current_val + 1 WHERE `seq_name` = ?'); |
|||
$sth->bindValue(1, $type_arr[$type]); |
|||
$sth->execute(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 修正 seq 取號 |
|||
* @param string $type M:新梯 T:汰改 B:保養 |
|||
*/ |
|||
function facilityFixSeq($type) |
|||
{ |
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$type_arr = array( |
|||
"M" => "mf_vol_no", |
|||
"T" => "tf_vol_no", |
|||
"B" => "bf_vol_no", |
|||
); |
|||
$after_fix_seq = $this->getMaxSeq($type); |
|||
$sql = " |
|||
UPDATE sequence |
|||
SET current_val = ? |
|||
WHERE seq_name = ? |
|||
"; |
|||
$sth = $pdo->prepare($sql); |
|||
$sth->bindValue(1, $after_fix_seq); |
|||
$sth->bindValue(2, $type_arr[$type]); |
|||
$sth->execute(); |
|||
} |
|||
|
|||
function getMaxSeq($type) |
|||
{ |
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$Y = substr(date("Y"), 3, 1); |
|||
$seq_num = $type == 'M' ? 5 : 3; |
|||
$sql = " |
|||
SELECT MAX(SUBSTR(f.facilityno,4,?))+1 AS seq |
|||
FROM facility AS f |
|||
WHERE 1=1 |
|||
AND SUBSTR(f.facilityno,1,1) = ? |
|||
AND f.define = ? |
|||
ORDER BY SUBSTR(f.facilityno,4,3) ASC |
|||
"; |
|||
$sth = $pdo->prepare($sql); |
|||
$sth->bindValue(1, $seq_num); |
|||
$sth->bindValue(2, $Y); |
|||
$sth->bindValue(3, $type); |
|||
$sth->execute(); |
|||
$result = $sth->fetch(); |
|||
return $result['seq']; |
|||
} |
|||
|
|||
/** |
|||
* 檢查年月後 新梯及汰改seq歸零 |
|||
*/ |
|||
function checkYearAndResetAllSeq() |
|||
{ |
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$sth = $pdo->prepare('SELECT * FROM `sequence` WHERE `seq_name` = ?'); |
|||
$sth->bindValue(1, 'mf_vol_no'); |
|||
$sth->execute(); |
|||
$result = $sth->fetch(); |
|||
$yyyymm = $result['yyyymm']; |
|||
$dataY = substr($yyyymm, 0, 4); |
|||
$today_Y = date("Y"); |
|||
$today_Ym = date("Ym"); |
|||
if ($dataY != $today_Y) { |
|||
$sth = $pdo->prepare('UPDATE `sequence` SET `current_val` = ? , `yyyymm` = ? WHERE `seq_name` = ?'); |
|||
$sth->bindValue(1, '0'); |
|||
$sth->bindValue(2, $today_Ym); |
|||
$sth->bindValue(3, 'mf_vol_no'); |
|||
$sth->execute(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 檢查作番在 facility table 中是否重複 |
|||
* @param string|array $facility_no |
|||
* @return boolean $status : true:沒重複 false:重複 |
|||
*/ |
|||
function checkFacilityRepeatStatus($facility_no) |
|||
{ |
|||
if (gettype($facility_no) == "string") { |
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); |
|||
$sth->bindValue(1, $facility_no); |
|||
$sth->execute(); |
|||
if ($sth->rowCount() == 0) |
|||
return true; |
|||
return false; |
|||
} |
|||
if (gettype($facility_no) == "array") { |
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$status = true; |
|||
foreach ($facility_no as $row) { |
|||
$sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); |
|||
$sth->bindValue(1, $row); |
|||
$sth->execute(); |
|||
if ($sth->rowCount() !== 0) |
|||
$status = false; |
|||
} |
|||
return $status; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 檢查 $sale_type 是否有存在規則之中 |
|||
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 |
|||
* @return boolean $status : true:合法代碼 false:非法代碼 |
|||
*/ |
|||
function checkSaleTypeStatus($sale_type) |
|||
{ |
|||
|
|||
if (!in_array($sale_type, ['M', 'E', 'T', 'J', 'X'])) |
|||
return false; |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 檢查 $sale_type 是否有存在規則之中 |
|||
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 |
|||
* @return boolean $status : true:合法代碼 false:非法代碼 |
|||
*/ |
|||
function checkMakeTypeStatus($make_type) |
|||
{ |
|||
foreach ($make_type as $row) |
|||
if (!in_array($row, ['X', 'W', 'H', 'Z', 'F', 'B', 'Q', 'T', 'N', 'W', 'J', 'Y'])) |
|||
return false; |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 檢查 取得下個作番的 seq |
|||
* @param string $seq_name : 新梯:mf_vol_no 汰改:tf_vol_no 保養:bf_vol_no |
|||
* @return int $seq : 作番流水號 |
|||
*/ |
|||
function getNextFacilitySeq($seq_name) |
|||
{ |
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$sth = $pdo->prepare('SELECT * FROM `sequence` WHERE `seq_name` = ?'); |
|||
$sth->bindValue(1, $seq_name); |
|||
$sth->execute(); |
|||
$result = $sth->fetch(); |
|||
return $result['current_val']; |
|||
} |
|||
|
|||
/** |
|||
* 建立新的新梯作番 |
|||
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 |
|||
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 |
|||
* @param int $seq_name : 幾個案場 0-99 |
|||
* @return array $new_facilityno : 作番號 |
|||
*/ |
|||
function makeMFacilityNo($sale_type, $make_type, $num) |
|||
{ |
|||
if (count($make_type) !== $num) |
|||
return "陣列數量不一致!"; |
|||
$new_facility_no = $this->getNextFacilityNo("M", $sale_type, $make_type, $num); |
|||
if ($this->checkFacilityRepeatStatus($new_facility_no) == false) { |
|||
// 如果作番號重複 使用此函數修正 |
|||
$this->facilityFixSeq("M"); |
|||
} |
|||
return $this->makeFacilityNo("M", $sale_type, $make_type, $num); |
|||
} |
|||
|
|||
/** |
|||
* 建立新的汰改作番 |
|||
* @param array $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 |
|||
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 |
|||
* @param int $seq_name : 幾個案場 0-99 |
|||
* @return array $new_facilityno : 作番號 |
|||
*/ |
|||
function makeTFacilityNo($sale_type, $make_type, $num) |
|||
{ |
|||
if (count($make_type) !== $num) |
|||
return "陣列數量不一致!"; |
|||
$new_facility_no = $this->getNextFacilityNo("T", $sale_type, $make_type, $num); |
|||
if ($this->checkFacilityRepeatStatus($new_facility_no) == false) { |
|||
// 如果作番號重複 使用此函數修正 |
|||
$this->facilityFixSeq("T"); |
|||
} |
|||
return $this->makeFacilityNo("T", $sale_type, $make_type, $num); |
|||
} |
|||
|
|||
/** |
|||
* 建立新的保養作番 |
|||
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品 |
|||
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正 |
|||
* @param int $seq_name : 幾個案場 0-99 |
|||
* @return array $new_facilityno : 作番號 |
|||
*/ |
|||
function makeBFacilityNo($sale_type, $make_type, $num = 1) |
|||
{ |
|||
if (count($make_type) !== $num) |
|||
return "陣列數量不一致!"; |
|||
$new_facility_no = $this->getNextFacilityNo("B", $sale_type, $make_type, $num); |
|||
if ($this->checkFacilityRepeatStatus($new_facility_no) == false) { |
|||
// 如果作番號重複 使用此函數修正 |
|||
$this->facilityFixSeq("B"); |
|||
} |
|||
return $this->makeFacilityNo("B", $sale_type, $make_type, $num); |
|||
} |
|||
} |
|||
|
|||
|
|||
// $cfn = new CreateFacilityNo; |
|||
// // 建立作番號 - 新梯 |
|||
// print_r($cfn->makeMFacilityNo("M", ["X", "W"], 2)); |
|||
// echo "<br/><br/>"; |
|||
// // 建立作番號 - 汰改 |
|||
// print_r($cfn->makeTFacilityNo("M", ["X", "W"], 2)); |
|||
// echo "<br/><br/>"; |
|||
// // 建立作番號 - 保養 |
|||
// print_r($cfn->makeBFacilityNo("M", ["X", "W"], 2)); |
|||
// echo "<br/><br/>"; |
@ -0,0 +1,16 @@ |
|||
<?php |
|||
require_once('../conn.php'); |
|||
try{ |
|||
$id = $_GET['id']; |
|||
$sql_str = "SELECT * FROM pricereview_main WHERE id = :id"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':id',$id); |
|||
$stmt->execute(); |
|||
$prices = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
header("Content-Type: application/json"); |
|||
|
|||
echo json_encode(['prices'=> $prices]); |
|||
|
|||
}catch (PDOException $e ){ |
|||
die("ERROR!!!: ". $e->getMessage()); |
|||
} |
@ -0,0 +1,423 @@ |
|||
<?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') { |
|||
// echo $_POST; |
|||
// exit; |
|||
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'] : 1; |
|||
|
|||
$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", $repairid); |
|||
$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(); |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo $e->getMessage(); |
|||
die('Error!' . $e->getMessage()); |
|||
} |
|||
} |
@ -0,0 +1,68 @@ |
|||
<?php |
|||
require_once("../conn.php"); |
|||
ini_set ( 'date.timezone' , 'Asia/Taipei' ); |
|||
if(isset($_POST['vol_no']) && !empty($_POST['vol_no'])){ |
|||
$mid = $_POST['mid']; |
|||
$vol_no = $_POST['vol_no']; |
|||
$salesman = $_POST['salesman']; |
|||
$apply_date = $_POST['apply_date']; |
|||
$apply_type = $_POST['apply_type']; |
|||
$case_name = $_POST['case_name']; |
|||
$customer = $_POST['company']; |
|||
$manager = $_POST['manager']; |
|||
$vat = $_POST['vat']; |
|||
$total_price = $_POST['total_price']; |
|||
$buy_fee = $_POST['price_a']; |
|||
$install_fee = $_POST['price_b']; |
|||
$contact_address = $_POST['address']; |
|||
$workdeadline_a = $_POST['workdeadline_a']; |
|||
$workdeadline_b = $_POST['workdeadline_b']; |
|||
$test_time = $_POST['regulations']; |
|||
$freedeadline = $_POST['freedeadline']; |
|||
$trade_address = $_POST['tradeaddress']; |
|||
$tradedeadline = $_POST['tradedeadline']; |
|||
$progress = 0; |
|||
$status = 0; |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$created_by = $_POST['user_id']; |
|||
$isFirst = $_POST['isFirst']; |
|||
$conn->beginTransaction(); |
|||
try{ |
|||
if($isFirst == 1){ |
|||
$sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, progress, status, created_at, created_by) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :progress, :status, :created_at, :created_by)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt ->bindParam(':mid', $mid); |
|||
$stmt ->bindParam(':contractno', $vol_no); |
|||
$stmt ->bindParam(':sales_man', $salesman); |
|||
$stmt ->bindParam(':apply_date', $apply_date); |
|||
$stmt ->bindParam(':apply_type', $apply_type); |
|||
$stmt ->bindParam(':case_name', $case_name); |
|||
$stmt ->bindParam(':customer', $customer); |
|||
$stmt ->bindParam(':manager', $manager); |
|||
$stmt ->bindParam(':vat', $vat); |
|||
$stmt ->bindParam(':total_price', $total_price); |
|||
$stmt ->bindParam(':buy_fee', $buy_fee); |
|||
$stmt ->bindParam(':install_fee', $install_fee); |
|||
$stmt ->bindParam(':contact_address', $contact_address); |
|||
$stmt ->bindParam(':workdeadline_a', $workdeadline_a); |
|||
$stmt ->bindParam(':workdeadline_b', $workdeadline_b); |
|||
$stmt ->bindParam(':test_time', $test_time); |
|||
$stmt ->bindParam(':freedeadline', $freedeadline); |
|||
$stmt ->bindParam(':trade_address', $trade_address); |
|||
$stmt ->bindParam(':tradedeadline', $tradedeadline); |
|||
$stmt ->bindParam(':progress', $progress); |
|||
$stmt ->bindParam(':status', $status); |
|||
$stmt ->bindParam(':created_at', $created_at); |
|||
$stmt ->bindParam(':created_by', $created_by); |
|||
$stmt ->execute(); |
|||
header("HTTP/1.1 201 success!"); |
|||
$conn->commit(); |
|||
} |
|||
}catch(PDOException $e){ |
|||
$conn->rollback(); |
|||
echo $e->getMessage(); |
|||
die('Error!:'.$e->getMessage()); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,139 @@ |
|||
<?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($_SERVER['REQUEST_METHOD'] != 'POST'){ |
|||
exit(); |
|||
} |
|||
//新梯簽回 |
|||
if(isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'm') { |
|||
try{ |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$created_by = $_POST["user_id"]; |
|||
$contractno = $_POST["contractno"]; |
|||
$customer = $_POST["customer"]; |
|||
$manager = $_POST["manager"]; |
|||
$vat = $_POST["vat"]; |
|||
$case_name = $_POST["case_name"]; |
|||
$linkman = $_POST["linkman"]; |
|||
$lm_tel = $_POST["lm_tel"]; |
|||
$address = $_POST["address"]; |
|||
$salesman = $_POST["salesman"]; |
|||
$qc = $_POST["qc"]; |
|||
$contracttype = $_POST["contracttype"]; |
|||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|||
$files_id = null; |
|||
|
|||
$fail_arr = []; |
|||
if(empty($contractno)) $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 = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(":accountid",$salesman); |
|||
$stmt -> execute(); |
|||
$saleman = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$salesman_name = $saleman['name']; |
|||
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 = 'm' . $datetime; // 保養=>b + 日期時間 |
|||
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; |
|||
} |
|||
|
|||
$sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by, qc_official_type) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by, :qc)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(":contract_no",$contractno); |
|||
$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(":salesman_name",$salesman_name); |
|||
$stmt -> bindParam(":files_id",$files_id); |
|||
$stmt -> bindParam(":created_at",$created_at); |
|||
$stmt -> bindParam(":created_by",$created_by); |
|||
$stmt -> bindParam(":qc",$qc); |
|||
$stmt -> execute(); |
|||
|
|||
|
|||
$result = $conn->commit(); |
|||
if($result){ |
|||
header("HTTP/1.1 201 Created"); |
|||
} |
|||
|
|||
}catch(PDOException $e){ |
|||
$conn->rollback(); |
|||
header("HTTP/1.1 500 Internal Server Error"); |
|||
die('Error!:'.$e->getMessage()); |
|||
} |
|||
} |
@ -0,0 +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['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()); |
|||
// } |
|||
// } |
@ -0,0 +1,61 @@ |
|||
<?php |
|||
|
|||
function upload_chk( $file, $path, $max_size, $allow_ext, $file_name ){ |
|||
|
|||
$source_file_name = $file['name']; //上傳檔案的原來檔案名稱 |
|||
$file_type = $file['type']; //上傳檔案的類型(副檔名) |
|||
$tmp_name = $file['tmp_name']; //上傳到暫存空間的路徑/檔名 |
|||
$file_size = $file['size']; //上傳檔案的檔案大小(容量) |
|||
$error = $file['error']; //上傳工作傳回的錯誤訊息編號 |
|||
$msg = ''; //負責記錄回傳的訊息 |
|||
|
|||
//1.判斷錯誤編號只有為0時表示沒有錯誤發生,才表示上傳成功 ================= |
|||
if( $error == 0 ){ |
|||
|
|||
//取得檔案延伸的副檔名, 以下函數可以取得檔案延伸的副檔名 |
|||
//pathinfo(上傳檔案的原來檔案名稱, PATHINFO_EXTENSION) |
|||
$ext = pathinfo($source_file_name, PATHINFO_EXTENSION); |
|||
$ext = strtolower($ext); //將延伸的副檔名轉小寫 |
|||
|
|||
//2.判斷上傳檔案的大小 ==================================== |
|||
if( $file_size > $max_size ){ |
|||
//當目前檔案容量超過容量限制時, 以下準備顯示的資訊 |
|||
if( $max_size >= 4096*4096 ){ |
|||
$max_size /= (4096*4096); |
|||
$max_size .= 'M'; |
|||
}elseif( $max_size >= 4096 ){ |
|||
$max_size /= 4096; |
|||
$max_size .= 'K'; |
|||
} |
|||
$msg ='上傳檔案過大,請選擇容量小於 '.$max_size.' 的檔案'; |
|||
|
|||
//3.判斷檔案類型 =========================================== |
|||
//in_array($ext, $allow_ext) 判斷 $ext變數的值 是否在 $allow_ext 這個陣列變數中 |
|||
}elseif( !in_array( $ext, $allow_ext ) ){ |
|||
$allow_str = ''; //準備將允許檔案類型的陣列內容, 組合成字串 |
|||
foreach( $allow_ext as $key=>$value ){ |
|||
//if的縮寫語法:條件?成立執行的工作:不成立執行的工作; |
|||
$key==0? $allow_str.= $value : $allow_str.=', '.$value; |
|||
} |
|||
$msg = '檔案類型不符合,請選擇 '.$allow_str.' 檔案'; |
|||
|
|||
//4.以上條件都沒問題的話, 則進行最後else中的工作=============== |
|||
}else{ |
|||
//搬移檔案 move_uploaded_file(要搬移的檔案, 目的地位置及目的檔案名稱), 成功傳回true(1) |
|||
$msg = @move_uploaded_file($tmp_name, $path.$file_name); |
|||
} |
|||
}else{ |
|||
//這裡表示上傳有錯誤, 匹配錯誤編號顯示對應的訊息 ====================================== |
|||
switch ($error) { |
|||
case 1: $msg = '上傳檔案超過 upload_max_filesize 容量最大值'; break; |
|||
case 2: $msg = '上傳檔案超過 post_max_size 總容量最大值'; break; |
|||
case 3: $msg = '檔案只有部份被上傳'; break; |
|||
case 4: $msg = '沒有檔案被上傳'; break; |
|||
case 6: $msg = '找不到主機端暫存檔案的目錄位置'; break; |
|||
case 7: $msg = '檔案寫入失敗'; break; |
|||
case 8: $msg = '上傳檔案被PHP程式中斷,表示主機端系統錯誤'; break; |
|||
} |
|||
} //if( $error == 0 ){ ..... end |
|||
|
|||
return $msg; //回傳$msg的結果 |
|||
} |
@ -0,0 +1,43 @@ |
|||
<?php |
|||
$envFile = __DIR__ . '/.env'; // .env 文件的路径 |
|||
|
|||
if (file_exists($envFile)) { |
|||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|||
if ($lines !== false) { |
|||
foreach ($lines as $line) { |
|||
list($key, $value) = explode('=', $line, 2); |
|||
$key = trim($key); |
|||
$value = trim($value); |
|||
// 设置环境变量 |
|||
putenv("$key=$value"); |
|||
} |
|||
} |
|||
} |
|||
$db_hostname = getenv('DB_HOST'); //資料庫主機名稱 |
|||
$db_username = getenv('DB_USERNAME'); //登入資料庫的管理者的帳號 |
|||
$db_password = getenv('DB_PASSWORD'); //登入密碼 |
|||
$db_name = getenv('DB_DATABASE'); //使用的資料庫 |
|||
$db_charset = 'utf8'; //設定字元編碼 |
|||
|
|||
//建立PDO的指定工作 |
|||
$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; |
|||
|
|||
try{ |
|||
//使用PDO連接到MySQL資料庫,建立PDO物件 |
|||
$conn = new PDO($dsn, $db_username, $db_password); |
|||
|
|||
//當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException) |
|||
//PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定 |
|||
//PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊 |
|||
//PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 |
|||
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 |
|||
//設定主動以警告的形式報錯 |
|||
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); |
|||
//如果連接錯誤,將抛出一個PDOException異常對象 |
|||
} |
|||
catch ( PDOException $e ){ |
|||
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 |
|||
die("ERROR!!!: ". $e->getMessage()); |
|||
} |
|||
|
|||
//$conn = null; //關閉資料庫的連線 |
@ -0,0 +1,567 @@ |
|||
<?php |
|||
include "../header.php"; |
|||
require_once('./conn.php'); |
|||
//買賣1、2、3,安裝5、6 (4跟7很少有) |
|||
if (!empty($_GET['apply_key'])) { |
|||
try { |
|||
$apply_key = $_GET['apply_key']; |
|||
// $sql_str = "SELECT pricereview_main.*, pricereview_pay.*, pricereview_item.note, pricereview_item.item_qty, account.name as accountname, account.id as accountid |
|||
// FROM pricereview_main |
|||
// JOIN pricereview_pay ON pricereview_main.id = pricereview_pay.mid |
|||
// JOIN pricereview_item ON pricereview_main.id = pricereview_item.mid |
|||
// JOIN account ON pricereview_main.person = account.accountid |
|||
// WHERE pricereview_main.id = :id AND pricereview_item.item_group = 'A' ORDER BY pay_kind ASC"; |
|||
|
|||
// 價審資料 |
|||
$sql = "SELECT * FROM con_maintance_examine_apply AS a LEFT JOIN hope_contract_customer AS b ON a.vol_no = b.vol_no WHERE a.apply_key = :apply_key"; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(':apply_key', $apply_key); |
|||
$stmt->execute(); |
|||
$contract_maintance = $stmt->fetchALL(PDO::FETCH_ASSOC); |
|||
echo '<pre>'; |
|||
print_r($contract_maintance); |
|||
echo '</pre>'; |
|||
// echo $contract_maintance; |
|||
// $stmt = $conn->prepare($sql_str); |
|||
// $stmt->bindParam(':id',$id); |
|||
// $stmt->execute(); |
|||
// $contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
|
|||
|
|||
// $sql_str = "SELECT contract_new_apply.*, |
|||
// contract_new_apply_pays.pay_kind, contract_new_apply_pays.pay_scale, contract_new_apply_pays.pay_amount, contract_new_apply_pays.pay_period, contract_new_apply_pays.condition_date |
|||
// FROM contract_new_apply |
|||
// JOIN contract_new_apply_pays ON contract_new_apply.id = contract_new_apply_pays.contract_apply_id |
|||
// WHERE contract_new_apply.mid = :id"; |
|||
// $stmt = $conn->prepare($sql_str); |
|||
// $stmt->bindParam(':id', $id); |
|||
// $stmt->execute(); |
|||
// $contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
// $contract = $contracts[0]; |
|||
// $contract_apply_id = $contract['id']; |
|||
// if (($contract['status'] !== "YY" && $user_id != 'M0107') && $user_id != 'M0174' || $user_id != 'M0225') { |
|||
// echo '<script type="text/javascript"> |
|||
// alert("非法訪問。"); |
|||
// window.history.back(); |
|||
// </script>'; |
|||
// exit; |
|||
// } |
|||
|
|||
// 抓有望客戶的資料 |
|||
$sql_str = "SELECT * FROM hope_contract_customer WHERE vol_no = :vol_no"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contract_maintance['vol_no']); |
|||
$stmt->execute(); |
|||
$customer = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
// if (count($customer) <= 0) { |
|||
// echo "<script> |
|||
// alert('資料不齊或合約書已生成過。'); |
|||
// window.history.back(); |
|||
// </script>"; |
|||
// exit; |
|||
// } |
|||
|
|||
$buyArr = []; |
|||
$buyNo2Pay = false; |
|||
$buy_total_price = 0; |
|||
$installArr = []; |
|||
$install_total_price = 0; |
|||
// $noteArr = explode(",", $contracts[0]['note']); |
|||
$noteArr = array(1, 1, 1, 1, 1); |
|||
$qty = $contract_maintance[0]['num']; |
|||
// echo $qty; |
|||
// foreach ($contract_maintance as $idx => $amount) { |
|||
// $isset = false; |
|||
// if ($amount['payment_kind'] == 5 || $amount['payment_kind'] == 6) { |
|||
// if ($amount['pay_scale'] >= 0) { |
|||
// $install_total_price = $install_total_price + $amount['pay_amount']; |
|||
// $installArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; |
|||
// } |
|||
// } |
|||
// if ($amount['pay_kind'] == 1 || $amount['pay_kind'] == 2 || $amount['pay_kind'] == 3) { |
|||
// if ($amount['pay_scale'] > 0) { |
|||
// $buy_total_price = $buy_total_price + $amount['pay_amount']; |
|||
// foreach ($buyArr as $buy) { |
|||
// if ($buy['installment'] == $amount['pay_kind']) { |
|||
// $isset = true; |
|||
// } |
|||
// } |
|||
// if (!$isset) { { |
|||
// $buyArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; |
|||
// } |
|||
// if ($amount['pay_kind'] == 2) { |
|||
// $buyNo2Pay = true; |
|||
// } |
|||
// } |
|||
// } |
|||
// } |
|||
// } |
|||
$sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL"; |
|||
$sql_str = "SELECT contract_apply_files.*, contract_new_apply.id as apply_id FROM contract_apply_files LEFT JOIN contract_new_apply ON contract_apply_files.contract_id = contract_new_apply.id WHERE contract_new_apply.mid = :mid AND contract_apply_files.deleted_at IS NULL"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $id); |
|||
$stmt->execute(); |
|||
$files = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$files_count = count($files); |
|||
} catch (PDOException $e) { |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
} |
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.3/purify.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.3.3/html2canvas.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script> |
|||
<main x-data="contractDownload"> |
|||
<div class="sidebar"> |
|||
<ul> |
|||
<button :class="isbuyShow ? 'active' : ''" @click="isbuyShow = true">電梯買賣合約書</button> |
|||
<button :class="!isbuyShow ?'active' : ''" @click="isbuyShow = false">電梯安裝合約書</button> |
|||
<a href="..wms/cont/sign_list.php?function_name=pricereview&<?php echo $token_link; ?>">回列表</a> |
|||
</ul> |
|||
</div> |
|||
<div class="inputDiv" x-show="isbuyShow && isBuyInputIng"> |
|||
<!-- <label for=""> |
|||
<p>交貨期限(日)</p> |
|||
<input type="number" x-model="buyfill1" @keyup="sendBuyInputKeyupFn($event)" /> |
|||
</label> --> |
|||
<?php if ($buyNo2Pay) { ?> |
|||
<!-- <label for=""> |
|||
<p>第二期款交貨期限(日)</p> |
|||
<input type="number" x-model="buyfill2"> |
|||
</label> --> |
|||
<?php } ?> |
|||
<!-- <label for=""> |
|||
<p>附件數</p> |
|||
<select x-model="buyAffix"> |
|||
<option value="1">1</option> |
|||
<option value="2">2</option> |
|||
<option value="3">3</option> |
|||
<option value="4">4</option> |
|||
<option value="5">5</option> |
|||
</select> |
|||
</label> --> |
|||
<label for=""> |
|||
<button @click="sendBuyInputFn()">生成買賣合約書</button> |
|||
</label> |
|||
</div> |
|||
<div class="contract-material-component" x-show="isbuyShow && !isBuyInputIng"> |
|||
<div class="btn-list"> |
|||
<label for="standardBuyBtn"> |
|||
<p>制式合約</p> |
|||
<input type="checkbox" class="scorll" x-model="toggleBuyStandard"> |
|||
<!-- <input type="radio" checked id="standardBuyBtn" name="standardBuyBtn" @change="toggleBuyStandard = true" /> --> |
|||
</label> |
|||
<!-- <label for="noStandardBuyBtn"> |
|||
<input type="radio" id="noStandardBuyBtn" name="standardBuyBtn" @change="toggleBuyStandard = false" /> |
|||
非制式合約 |
|||
</label> --> |
|||
</div> |
|||
<button @click="isBuyInputIng = true" class="rebtn">重新輸入</button> |
|||
<button @click="exportFn(1)" class="prviewbtn">預覽</button> |
|||
<div class="contract" id="noStandardBuyContract" x-show="!toggleBuyStandard"> |
|||
<table class="my-2 contract" x-ref="contract1" id="contract1"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯買賣合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
立契約人 甲方:<article x-html="onstandardViewData.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
乙方:<article x-html="onstandardViewData.partyAcontractno.plaintext"></article> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="onstandardViewData.partyA.plaintext">一二營造有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="buyonstandardViewData.illustrate.editshow ? 'mouseover' : '' " x-on:mouseover="mouseover('illustrate', false)" x-on:mouseout="mouseout('illustrate')"> |
|||
<td> |
|||
<span x-html='buydata.illustrate.plaintext'></span> |
|||
<div class="buttons" x-show="buyonstandardViewData.illustrate.editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('更新合約書內容', 'illustrate', false, false)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="delete"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in buyonstandardViewData.list.plaintext" :key="item.id"> |
|||
<tr :class="buyonstandardViewData.list.plaintext[idx].editshow ? 'mouseover' : '' " @mouseover="mouseoverlist(idx, false)" @mouseout="mouseoutlist(idx)"> |
|||
<td class="list"> |
|||
<div class="buttons" x-show="buyonstandardViewData.list.plaintext[idx].editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('update contract list', idx, true, false)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="add" @click="modelshowAddUpFn(idx, false)"><i class="glyphicon glyphicon-arrow-up"></i></button> |
|||
<button class="add" @click="modelshowAddDownFn(idx, false)"><i class="glyphicon glyphicon-arrow-down"></i></button> |
|||
<button class="delete" @click="deleteEditor(idx, false)"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="buyonstandardViewData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
<div class="contract" id="standardBuyContract" x-show="toggleBuyStandard"> |
|||
<table class="my-2 contract" id="contract0"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯買賣合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
合約書編號:<article x-html="data.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="data.partyA.plaintext"> </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="buystandardData.illustrate.editshow ? 'mouseover' : '' "> |
|||
<td> |
|||
<span x-html='buystandardData.illustrate.plaintext'></span> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in buystandardData.list.plaintext" :key="item.id"> |
|||
<tr :class="buystandardData.list.plaintext[idx].editshow ? 'mouseover' : '' "> |
|||
<td class="list"> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="buystandardData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
<div class="contract-model" x-show="modelshow" x-cloak> |
|||
<div class="contract-back"></div> |
|||
<div class="contract-content"> |
|||
<div class="model-header"><span x-text='modelText'></span><i @click='modelcloseFn()' class="glyphicon glyphicon-remove"></i></div> |
|||
<div class="content"> |
|||
<textarea name="content" id="editor" x-ref="editor"></textarea> |
|||
<input type="submit" value="update" @click='updateEditor()' /> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="inputDiv" x-show="!isbuyShow && isInstallInputIng"> |
|||
<!-- <label for=""> |
|||
<p>安裝試車期限(日)</p> |
|||
<input type="number" x-model="installfill1" @keyup="sendInstallInputKeyupFn($event)" /> |
|||
</label> |
|||
<label for=""> |
|||
<p>免費保養月數(月)</p> |
|||
<input type="number" x-model="installfill2" @keyup="sendInstallInputKeyupFn($event)" /> |
|||
</label> --> |
|||
<!-- <label for=""> |
|||
<p>附件數</p> |
|||
<select x-model="installAffix" @keyup="sendInstallInputKeyupFn($event)"> |
|||
<option value="1">1</option> |
|||
<option value="2">2</option> |
|||
<option value="3">3</option> |
|||
<option value="4">4</option> |
|||
<option value="5">5</option> |
|||
</select> |
|||
</label> --> |
|||
<label for=""> |
|||
<button @click="sendInstallInputFn()">生成安裝合約書</button> |
|||
</label> |
|||
</div> |
|||
<div class="contract-install-component" x-show="!isbuyShow && !isInstallInputIng" x-cloak> |
|||
|
|||
<div class="btn-list"> |
|||
<label for="standardBtn"> |
|||
<p>制式合約</p> |
|||
<input type="checkbox" class="scorll" x-model="toggleBuyStandard"> |
|||
<!-- <input type="radio" checked id="standardBtn" name="standardBtn" @change="toggleInstallStandard = true" /> --> |
|||
</label> |
|||
<!-- <label for="noStandardBtn"> |
|||
<input type="radio" id="noStandardBtn" name="standardBtn" @change="toggleInstallStandard = false" /> |
|||
非制式合約 |
|||
</label> --> |
|||
</div> |
|||
<button @click="isInstallInputIng = true" class="rebtn">重新輸入</button> |
|||
<button @click="exportFn(2)" class="prviewbtn">預覽</button> |
|||
|
|||
|
|||
<div class="contract" id="noStandardContract" x-show="!toggleInstallStandard"> |
|||
<table class="my-2 contract" x-ref="contract1" id="contract1"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯安裝合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
合約書編號:<article x-html="onstandardViewData.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="onstandardViewData.partyA.plaintext">一二營造有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="onstandardViewData.illustrate.editshow ? 'mouseover' : '' " x-on:mouseover="mouseover('illustrate')" x-on:mouseout="mouseout('illustrate')"> |
|||
<td> |
|||
<span x-html='onstandardViewData.illustrate.plaintext'></span> |
|||
<div class="buttons" x-show="onstandardViewData.illustrate.editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('更新合約書內容', 'illustrate', false, true)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="delete"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in onstandardViewData.list.plaintext" :key="item.text"> |
|||
<tr :class="onstandardViewData.list.plaintext[idx].editshow ? 'mouseover' : '' " @mouseover="mouseoverlist(idx)" @mouseout="mouseoutlist(idx)"> |
|||
<td class="list"> |
|||
<div class="buttons" x-show="onstandardViewData.list.plaintext[idx].editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('update contract list', idx, true, true)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="add" @click="modelshowAddUpFn(idx)"><i class="glyphicon glyphicon-arrow-up"></i></button> |
|||
<button class="add" @click="modelshowAddDownFn(idx)"><i class="glyphicon glyphicon-arrow-down"></i></button> |
|||
<button class="delete" @click="deleteEditor(idx)"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="onstandardViewData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
|
|||
<div class="contract" id="standardContract" x-show="toggleInstallStandard"> |
|||
<table class="my-2 contract" id="contract0"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯安裝合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
合約書編號:<article x-html="data.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="data.partyA.plaintext">一二營造有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="standardData.illustrate.editshow ? 'mouseover' : '' "> |
|||
<td> |
|||
<span x-html='standardData.illustrate.plaintext'></span> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in standardData.list.plaintext"> |
|||
<tr :class="standardData.list.plaintext[idx].editshow ? 'mouseover' : '' "> |
|||
<td class="list"> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="standardData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
|
|||
<form action="prviewPdf.php?id=<?php echo $id; ?>&<?php echo $token_link; ?>" id="form" method="post" x-ref="form" style="display:none"> |
|||
<input type="hidden" name="contract_apply_id" id="contract_apply_id" value="<?php echo $contract_apply_id; ?>" /> |
|||
<input type="hidden" name="list" id="prview-list" /> |
|||
<input type="hidden" name="prviewType" id="prview-type" /> |
|||
<input type="hidden" name="standardList" id="standard-prview-list" /> |
|||
<input type="hidden" name="illustrate" id="illustrate" /> |
|||
<input type="hidden" name="standardIllustrate" id="standard-illustrate" /> |
|||
<input type="hidden" name="partyA" id="partyA" /> |
|||
<input type="hidden" name="partyAcontractno" id="partyAcontractno" /> |
|||
<input type="hidden" name="buystandard" x-model="toggleBuyStandard" /> |
|||
<input type="hidden" name="installstandard" x-model="toggleInstallStandard" /> |
|||
<input type="hidden" name="total_price" x-model="total_price" id="total_price" /> |
|||
<input type="hidden" name="person" id="person" value="<?php echo $contract['accountname']; ?>" /> |
|||
<input type="hidden" name="personid" id="personid" value="<?php echo $contract['accountid']; ?>" /> |
|||
<input type="hidden" name="delivery_term" id="delivery_term" x-model="buyfill1" /> |
|||
<input type="hidden" name="install_period" id="install_period" x-model="installfill1" /> |
|||
<input type="hidden" name="free_maintainance" id="free_maintainance" x-model="installfill2" /> |
|||
</form> |
|||
|
|||
</div> |
|||
</main> |
|||
<!-- <script src="../ckeditor4/ckeditor.js"></script> --> |
|||
<script> |
|||
const partyAcompany = <?php echo json_encode($contract_maintance['customer']); ?>; |
|||
const partyAcontractno = <?php echo json_encode($contract_maintance['apply_key']); ?>; |
|||
const partyAaddress = <?php echo json_encode($contcontract_maintanceract['address']); ?>; |
|||
const totalPrice = 0; |
|||
const totalInstallPrice = <?php echo $install_total_price; ?>; |
|||
const totalBuyPrice = <?php echo $buy_total_price; ?>; |
|||
// const secondPayDeadline = <?php echo $contract['secondPayDeadline']; ?>; |
|||
// const buyfill1 = <?php echo $contract['tradedeadline']; ?>; |
|||
// const installfill1 = "<?php echo $contract_maintance['test_time']; ?>"; |
|||
// const installfill2 = "<?php echo $contract_maintance['freedeadline']; ?>"; |
|||
// const buyArr = [...<?php echo json_encode($buyArr); ?>]; |
|||
// const installArr = [...<?php echo json_encode($installArr); ?>]; |
|||
let install_pay_text = '付款方式:<br> '; |
|||
let buy_pay_text = '' |
|||
const chineseArr = ['零', '一', '二', '三', '四', '五', '六', '七'] |
|||
const bigChineseArr = ['零', '壹', '貳', '參', '肆', '伍', '陸', '柒', '捌', '玖', '拾']; |
|||
const num = <?php echo $qty; ?>; |
|||
const people = <?php echo $noteArr[1]; ?>; |
|||
const floor = <?php echo $noteArr[2]; ?>; |
|||
const speed = <?php echo $noteArr[3]; ?>; |
|||
const buyAffix = ' <?php echo $files_count; ?>'; |
|||
// console.log(buyAffix); |
|||
// console.log(installArr); |
|||
buyArr.forEach((item, idx) => { |
|||
if (item.scale > 0) { |
|||
if (item.installment == 1) { |
|||
buy_pay_text = `${buy_pay_text}第${chineseArr[idx+1]}期款:合約簽定時,甲方應付合約定金新台幣 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} else if (item.installment == 2) { |
|||
buy_pay_text = `${buy_pay_text}第${chineseArr[idx+1]}期款:合約簽訂後 ____ 天付第二期款新台幣 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} else if (item.installment == 3) { |
|||
buy_pay_text = `${buy_pay_text}第${chineseArr[idx+1]}期款:產品貨到工地時應付新台幣 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )( 含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} |
|||
} |
|||
});; |
|||
buy_pay_text += '以上期款若以票據支付時,發票人需為本合約甲方,票面金額同於各期應付款項,票期於各期付款日三十日內,票據須屬有效並得兌現。<br>乙方收款帳戶名稱:永佳捷科技股份有限公司;收款銀行:兆豐國際商業銀行(桃興分行);帳戶號碼:207-09-08688-2。' |
|||
buy_pay_text = buy_pay_text.replace(/\n/g, "").replace(/\s+/g, '').trim(); |
|||
installArr.forEach((item, idx) => { |
|||
if (item.scale > 0) { |
|||
if (item.installment == 5) { |
|||
install_pay_text = `${install_pay_text}第${chineseArr[idx+1]}期款:甲方應於安裝及試車完成後給付安裝費用 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} else if (item.installment == 6) { |
|||
install_pay_text = `${install_pay_text}第二期款:甲方應於交車後給付 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} |
|||
} |
|||
}) |
|||
install_pay_text += '以上期款若以票據支付時,發票人需為本合約甲方,票面金額同於各期應付款項,票期於各期付款日三十日內,票據須屬有效並得兌現。<br> 乙方收款帳戶名稱:永佳捷科技股份有限公司;收款銀行:兆豐國際商業銀行(桃興分行);帳戶號碼:207-09-08688-2。' |
|||
install_pay_text = install_pay_text.replace(/\n/g, "").replace(/\s+/g, '').trim(); |
|||
|
|||
function numberWithCommas(x) { |
|||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
|||
} |
|||
|
|||
function numberToChinese(n) { |
|||
if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n)) return "Invalid number."; |
|||
let unit = "仟佰拾億仟佰拾萬仟佰拾元角分"; |
|||
let str = ""; |
|||
n += "00"; |
|||
let pos = n.indexOf('.'); |
|||
if (pos >= 0) { |
|||
n = n.substring(0, pos) + n.substr(pos + 1, 2); |
|||
} |
|||
unit = unit.substr(unit.length - n.length); |
|||
for (let i = 0; i < n.length; i++) { |
|||
str += '零壹貳參肆伍陸柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i); |
|||
} |
|||
str = ('_' + str + '_'); |
|||
return str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(萬|億|元)/g, "$1").replace(/(億)萬|壹(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "").replace("元", "").replace(/^\s+|\s+$/g, ''); |
|||
} |
|||
|
|||
function numberToSmallChinese(num) { |
|||
const chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; |
|||
const chineseUnits = ['', '十', '百', '千']; |
|||
|
|||
const numStr = num.toString(); |
|||
const numLength = numStr.length; |
|||
let chineseStr = ''; |
|||
|
|||
for (let i = 0; i < numLength; i++) { |
|||
const digit = parseInt(numStr.charAt(i)); |
|||
const unitPos = numLength - i - 1; |
|||
|
|||
if (digit !== 0) { |
|||
chineseStr += chineseNumbers[digit] + chineseUnits[unitPos]; |
|||
} else { |
|||
// 处理连续的零,只添加一个零到结果中 |
|||
if (i < numLength - 1 && parseInt(numStr.charAt(i + 1)) !== 0) { |
|||
chineseStr += chineseNumbers[digit]; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return chineseStr; |
|||
} |
|||
</script> |
|||
<script src="./js/alpine.js"></script> |
|||
<script> |
|||
const axiosClient = axios.create({ |
|||
baseURL: './', |
|||
}); |
|||
|
|||
|
|||
axiosClient.interceptors.request.use((config) => { |
|||
config.headers.Authorization = 'Bearer <?php echo $token ?>' |
|||
return config; |
|||
}, (error) => { |
|||
return Promise.reject(error); |
|||
}); |
|||
|
|||
axiosClient.interceptors.response.use((response) => { |
|||
return response; |
|||
}, (error) => { |
|||
if (error.response.status === 401) { |
|||
console.error(error); |
|||
} |
|||
throw error; |
|||
}); |
|||
</script> |
|||
<script> |
|||
</script> |
@ -0,0 +1,214 @@ |
|||
<?php |
|||
include("../header.php"); |
|||
require_once("./conn.php"); |
|||
$id = $_GET['contractid']; |
|||
$sql_str = "SELECT a.*,b.name FROM contract_r_signed_back AS a LEFT JOIN account AS b ON a.repaireid = b.accountid |
|||
WHERE a.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['contract_status'] + 1); |
|||
// 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="<?php echo $contract['repaireid'] ?>"><?php echo $contract['repaireid'] . '-' . $contract['name'] ?></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> |
@ -0,0 +1,185 @@ |
|||
<?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); |
|||
$persons = array_map(function ($person) { |
|||
return [ |
|||
'view' => $person['accountid'] . '-' . $person['name'], |
|||
'value' => $person['accountid'], |
|||
'name' => $person['name'] |
|||
]; |
|||
}, $contractpersons); |
|||
$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="repair_no" x-model="data.repair_no"> |
|||
|
|||
</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 style="vertical-align: middle"> |
|||
<select class="repaireid" id="repaireid" x-model="data.repairerid"> |
|||
<option value="<?php echo $contract['repaireid'] ?>"><?php echo $contract['repairerid'] . '-' . $contract['name'] ?></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="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"> |
|||
<option value="">選擇工程類別</option> |
|||
<?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> |
@ -0,0 +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> |
|||
<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> |
@ -0,0 +1,662 @@ |
|||
<?php |
|||
include_once("../header.php"); |
|||
require_once("./conn.php"); |
|||
// if (!(isset($_GET['id']) && !empty($_GET['id']))) { |
|||
// $para = "function_name=pricereview&" . $token_link; |
|||
// echo "<script>alert('非法訪問!!!');</script>"; |
|||
// echo "<script>window.history.go(-1);</script>"; |
|||
// exit; |
|||
// } |
|||
$id = $_GET["id"]; |
|||
|
|||
$sql_str = "SELECT contract_new_apply.*, account.name as review_person_name |
|||
FROM contract_new_apply |
|||
LEFT JOIN account ON contract_new_apply.review_person_id = account.accountid |
|||
WHERE contract_new_apply.mid = :mid"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $id); |
|||
$stmt->execute(); |
|||
$contract_new_apply = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$contract = $contract_new_apply; |
|||
$isFirst = empty($contract_new_apply) ? 1 : 0; |
|||
if (empty($contract_new_apply)) { |
|||
$sql_str = "SELECT pricereview_main.contractno, pricereview_main.ekind, pricereview_main.person, pricereview_main.company, pricereview_main.case_name, pricereview_main.address, pricereview_main.price_lowest, pricereview_main.price_total, pricereview_main.price_rate, pricereview_main.status as priceview_status, pricereview_main.id as mainid, account.name as accountname |
|||
FROM pricereview_main |
|||
JOIN account ON pricereview_main.person = account.accountid |
|||
WHERE pricereview_main.id = :id"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':id', $id); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
// print_r($contract); |
|||
$accounttype = "M"; |
|||
$sql_str = "SELECT * FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype', $accounttype); |
|||
$stmt->execute(); |
|||
$persons = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$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', $contract['contractno']); |
|||
$stmt->execute(); |
|||
$customer = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
|
|||
$mid = $contract['mainid']; |
|||
|
|||
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A'"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $mid); |
|||
$stmt->execute(); |
|||
$items = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$total_items = 0; |
|||
foreach ($items as $item) { |
|||
$total_items += $item['item_qty']; |
|||
} |
|||
$sql_str = "SELECT * FROM pricereview_pay WHERE mid = :mid ORDER BY pay_kind ASC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $mid); |
|||
$stmt->execute(); |
|||
$pays = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$price_a = 0; |
|||
$price_b = 0; |
|||
foreach ($pays as $pay) { |
|||
if ($pay['pay_kind'] <= 4) { |
|||
$price_a = $price_a + $pay['pay_amount']; |
|||
} else { |
|||
$price_b = $price_b + $pay['pay_amount']; |
|||
} |
|||
} |
|||
} else { |
|||
$mid = $contract['mid']; |
|||
$contract_new_apply_id = $contract_new_apply['id']; |
|||
$sql_str = "SELECT * FROM contract_new_apply_pays WHERE mid = :mid ORDER BY pay_kind ASC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $mid); |
|||
$stmt->execute(); |
|||
$pays = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
|
|||
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A'"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $mid); |
|||
$stmt->execute(); |
|||
$items = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$price_a = 0; |
|||
$price_b = 0; |
|||
foreach ($pays as $pay) { |
|||
if ($pay['pay_kind'] <= 4) { |
|||
$price_a = $price_a + $pay['pay_amount']; |
|||
} else { |
|||
$price_b = $price_b + $pay['pay_amount']; |
|||
} |
|||
} |
|||
|
|||
$sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contract_id', $id); |
|||
$stmt->execute(); |
|||
$files = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
print_r($files); |
|||
} |
|||
$secondPayDeadline = $contract['secondPayDeadline'] ?? 0; |
|||
$status = isset($contract['status']) ? $contract['status'] : -1; |
|||
$person = $contract['person']; |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.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" /> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
<div class="contract-new-apply-component" x-data="contractNewApply"> |
|||
<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" 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> |
|||
<div class="fixed" x-text="data.vol_no"></div> |
|||
<!-- <input class="form-control disabled_select" type="text" x-model="data.vol_no" > --> |
|||
<!-- <p class="alerttext" x-show="data.vol_no==''"><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.vat"> |
|||
<p class="alerttext" x-show="data.vat==''"><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" x-model="data.apply_date"> |
|||
<p class="alerttext" x-show="data.apply_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">申請類別</td> |
|||
<td style="vertical-align: middle"> |
|||
<select class="" id="apply_type" x-model="data.apply_type"> |
|||
<option value="A">制式新合約</option> |
|||
</select> |
|||
<p class="alerttext" x-show="data.apply_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">案件名稱</td> |
|||
<td style="vertical-align: middle" colspan="3"> |
|||
<input class="form-control disabled_select" type="text" x-model="data.case_name"> |
|||
<p class="alerttext" x-show="data.case_name==''"><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" 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"> |
|||
<input class="form-control disabled_select" type="text" x-model="data.manager"> |
|||
<p class="alerttext" x-show="data.manager==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">含稅給約總價</td> |
|||
<td colspan="3" style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="data.total_price"> |
|||
<p class="alerttext" x-show="data.total_price==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">含稅貸款(A)</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="data.price_a"> |
|||
<p class="alerttext" x-show="data.price_a==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">含稅安裝款(A)</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="data.price_b"> |
|||
<p class="alerttext" x-show="data.price_b==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">聯絡地址</td> |
|||
<td style="vertical-align: middle" 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" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<div class="ui label"> |
|||
貨抵工地 |
|||
</div> |
|||
<input type="text" placeholder="30" style="width:45px;padding:0 12px;" x-model="data.workdeadline_a"> |
|||
<div class="ui label"> |
|||
天內安裝完成,甲方應於貨底工地前 |
|||
</div> |
|||
<input type="text" placeholder="7" style="width:45px;padding:0 12px;" x-model="data.workdeadline_b"> |
|||
<div class="ui label"> |
|||
天完成並整理完善。 |
|||
</div> |
|||
</div> |
|||
<!-- <input class="form-control disabled_select" type="text" x-model="data.deadline" > --> |
|||
<p class="alerttext" x-show="data.deadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">附則</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<div class="ui label"> |
|||
乙方應於 |
|||
</div> |
|||
<input type="text" placeholder="10" style="width:45px;padding:0 12px;" x-model="data.regulations"> |
|||
<div class="ui label"> |
|||
天內試車完成 |
|||
</div> |
|||
</div> |
|||
<p class="alerttext" x-show="data.regulations==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">免保期限</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<input type="text" placeholder="18" style="width:45px;padding:0 12px;" x-model="data.freedeadline"> |
|||
<div class="ui label"> |
|||
個月 |
|||
</div> |
|||
</div> |
|||
<p class="alerttext" x-show="data.freedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">交貨地點</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<input class="form-control disabled_select" type="text" x-model="data.tradeaddress"> |
|||
<p class="alerttext" x-show="data.tradeaddress==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">交貨期限</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<div class="ui label"> |
|||
圖色確認第 |
|||
</div> |
|||
<input type="text" placeholder="90" style="width:45px;padding:0 12px;" x-model="data.tradedeadline"> |
|||
<div class="ui label"> |
|||
天出貨 |
|||
</div> |
|||
</div> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead style="font-weight: bolder;margin-bottom: 20px"> |
|||
<tr> |
|||
<td colspan="1"> |
|||
<p style='text-align:center'>項次</p> |
|||
</td> |
|||
<td colspan="3"> |
|||
<p style='text-align:center'>規格</p> |
|||
</td> |
|||
<td colspan="1"> |
|||
<p style='text-align:center'>數量</p> |
|||
</td> |
|||
<td colspan="3"> |
|||
<p style='text-align:center'>金額</p> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px"> |
|||
<template x-for="(item, idx) in data.items"> |
|||
<tr> |
|||
<td style="vertical-align: middle"> |
|||
<p x-text="idx+1"></p> |
|||
</td> |
|||
<td colspan="3" style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="text" x-model="item.item_spec"> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle"> |
|||
<span x-text="item.item_qty + '台'" style="padding:0 20px"></span> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td colspan="3" style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="item.item_price_ct"> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
<tr> |
|||
<td colspan=4></td> |
|||
<td>電梯總數</td> |
|||
<td colspan='3'> <span x-text="data.total_items + '台'" style="padding:0 20px"></span></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
|
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead style="font-weight: bolder;margin-bottom: 20px"> |
|||
<tr> |
|||
<td> |
|||
<p style='text-align:center'>合約類別</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>款別</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>條件名稱</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>收款條件日期區分</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>條件日期</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>票期</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>付款比率</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>金額</p> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px"> |
|||
<?php |
|||
$day = 0; |
|||
$styles = [ |
|||
1 => "訂金", |
|||
2 => "二次款", |
|||
3 => "貨到款", |
|||
4 => "", |
|||
5 => "安裝款", |
|||
6 => "尾款", |
|||
7 => "", |
|||
]; |
|||
$paydate = [ |
|||
1 => "合約日", |
|||
2 => "合約日", |
|||
3 => "出貨日", |
|||
4 => "", |
|||
5 => "竣檢日", |
|||
6 => "交車日", |
|||
7 => "" |
|||
]; |
|||
?> |
|||
<?php foreach ($pays as $pay) : |
|||
if ($pay['pay_scale'] == 0) continue; |
|||
?> |
|||
<tr> |
|||
<td> |
|||
<p style='text-align:center'><?php echo ($pay['pay_kind'] <= 4) ? "銷售" : "按裝"; ?></p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'><?php echo $styles[$pay['pay_kind']]; ?></p> |
|||
</td> |
|||
<td> |
|||
<?php if ($pay['pay_kind'] == 1) { ?> |
|||
<template x-if="pays[1] > 0"> |
|||
<p style='text-align:center'>簽約後<span x-text="pays[1]"></span>天付訂金</p> |
|||
</template> |
|||
<template x-if="pays[1] <= 0"> |
|||
<p style='text-align:center'>簽約後付訂金</p> |
|||
</template> |
|||
<?php } elseif ($pay['pay_kind'] == 2) { ?> |
|||
<template x-if="pays[2] > 0"> |
|||
<p style='text-align:center'>簽約後<span x-text="pays[2]"></span>天付二次款</p> |
|||
</template> |
|||
<template x-if="pays[2] <= 0"> |
|||
<p style='text-align:center'>簽約後付二次款</p> |
|||
</template> |
|||
<?php } elseif ($pay['pay_kind'] == 3) { ?> |
|||
<p style='text-align:center'>貨抵工地付貨到款</p> |
|||
<?php } elseif ($pay['pay_kind'] == 5) { ?> |
|||
<template x-if="pays[5] > 0"> |
|||
<p style='text-align:center'>安裝完成後<span x-text="pays[5]"></span>天收款</p> |
|||
</template> |
|||
<template x-if="pays[5] <= 0"> |
|||
<p style='text-align:center'>安裝完成後收款</p> |
|||
</template> |
|||
<?php } elseif ($pay['pay_kind'] == 6) { ?> |
|||
<template x-if="pays[6] > 0"> |
|||
<p style='text-align:center'>交車後<span x-text="pays[6]"></span>天付尾款</p> |
|||
</template> |
|||
<template x-if="pays[6] <= 0"> |
|||
<p style='text-align:center'>交車後付尾款</p> |
|||
</template> |
|||
<?php } else { ?> |
|||
<p style='text-align:center'>-</p> |
|||
<?php } ?> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'><?php echo $paydate[$pay['pay_kind']]; ?></p> |
|||
</td> |
|||
<td> |
|||
<div class="ui labeled input"> |
|||
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind']; ?>].condition_date"> |
|||
<div class="ui label"> |
|||
天 |
|||
</div> |
|||
</div> |
|||
</td> |
|||
<td> |
|||
<div class="ui labeled input"> |
|||
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind']; ?>].pay_period"> |
|||
<div class="ui label"> |
|||
天 |
|||
</div> |
|||
</div> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center' x-text="pays[<?php echo $pay['pay_kind']; ?>].scale + '%'"><?php echo $pay['pay_scale'] ?>%</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center' x-text="localnumber(data.total_price * pays[<?php echo $pay['pay_kind']; ?>].scale/100)"></p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
<template x-if="pays[2].pay_period > 0"> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px"> |
|||
<tr> |
|||
<td>第二期款交貨期限(日)</td> |
|||
<td> |
|||
<input type="number" class="form-control" x-model="data.secondPayDeadline" /> |
|||
<p class="alerttext" x-show="data.secondPayDeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</template> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead style="font-weight: bolder;margin-bottom: 20px;"> |
|||
<tr> |
|||
<td colspan=8> |
|||
<h4 style='text-align:center;font-weight: bolder'>附件上傳</h4> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
|
|||
<tbody> |
|||
<tr> |
|||
<td colspan="4">附件上傳</td> |
|||
<td colspan="4"> |
|||
<?php if ($status < 1) : ?> |
|||
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> |
|||
<?php endif; ?> |
|||
<?php foreach ($files as $file) : ?> |
|||
<a href="./images/contracts_new_files/<?php echo $file['file_name']; ?>" download><?php echo $file['file_name']; ?></a> <?php if ($status < 1) : ?><span style="margin-left:10px;cursor:pointer;color:#f019">X</span><?php endif; ?><br /> |
|||
<?php endforeach; ?> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead style="font-weight: bolder;margin-bottom: 20px;"> |
|||
<tr> |
|||
<td colspan=8> |
|||
<h4 style='text-align:center;font-weight: bolder'>簽核流程</h4> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td>審核</td> |
|||
<td>審核人</td> |
|||
<td>結果</td> |
|||
<td colspan=2>意見</td> |
|||
<td>時間</td> |
|||
<td colspan=2><?php if ($user_id === "M0174" && $status == 1) : ?>審核意見<?php endif; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>營業員</td> |
|||
<td><span x-text="data.salesmanname + '(' + data.salesman + ')'"></span></td> |
|||
<td> |
|||
<?php if ($status >= 1) : ?><span class="successtext">已送審</span><?php endif; ?> |
|||
<?php if ($status == 0) : ?><span class="readtext">暫存</span><?php endif; ?> |
|||
<?php if ($status == -1) : ?><span class="">未提交</span><?php endif; ?> |
|||
</td> |
|||
<td colspan=2>---</td> |
|||
<td><?php echo ($contract['submit_date']) ?? "---"; ?> </td> |
|||
<td colspan=2 rowspan="2"> |
|||
<?php if ($user_id === "M0174" && $status == 1) : ?> |
|||
<textarea class="form-control opinion" x-model="data.review_comment"></textarea> |
|||
<?php endif; ?> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>業務承辦人</td> |
|||
<td><span><?php echo (isset($contract['review_person_name']) || empty($contract['review_person_name'])) ? "---" : $contract['review_person_name'] . "(" . $contract['review_person_id'] . ")"; ?></span></td> |
|||
<td> |
|||
<?php if ($status == 3) : ?><span class="successtext">結案同意</span><?php endif; ?> |
|||
<?php if ($status == 2) : ?><span class="failtext">結案不同意</span><?php endif; ?> |
|||
<?php if ($status < 2) : ?><span>---</span><?php endif; ?> |
|||
</td> |
|||
<td colspan=2><?php echo $contract['review_comment'] ?? "---"; ?></td> |
|||
<td><?php echo $contract['review_date'] ?? "---"; ?></td> |
|||
</tr> |
|||
<!-- <tr> |
|||
<td colspan="2" style="font-weight:bold">業務部承辦人</td> |
|||
<td colspan="2"> |
|||
<template x-if="false"> |
|||
<span class="failtext">已退件</span> |
|||
</template> |
|||
<?php if ($status == 1) : ?> |
|||
<span class="readtext">審核中...</span> |
|||
<?php endif; ?> |
|||
<template x-if="false"> |
|||
<span class="successtext">已通過</span> |
|||
</template> |
|||
</td> |
|||
<td colspan="2" style="font-weight:bold">營業員</td> |
|||
<td colspan="2"><span x-text="data.salesmanname + '(' + data.salesman + ')'"></span></td> |
|||
</tr> --> |
|||
</tbody> |
|||
</table> |
|||
<button @click="window.history.go(-1)" type="button" class="btn btn-primary btn-lg pull-right savebtn">回前頁</button> |
|||
<?php if (($isFirst == 1 && ($person == $user_id || $user_id == "M0174")) || ($isFirst == 0 && $status == 0 && ($person == $user_id || $user_id == "M0174"))) : ?> |
|||
<button x-show="true" x-on:click="submit()" :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="true" x-on:click="storageFn()" :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> |
|||
<?php endif; ?> |
|||
<?php if ($status == 1 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0174")) : ?> |
|||
<button x-show="true" x-on:click="agree()" :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="true" x-on:click="disagree()" :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> |
|||
<?php endif; ?> |
|||
</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> |
|||
window.onload = () => { |
|||
const lock = document.getElementsByClassName('lock'); |
|||
for (let i = 0; i < lock.length; i++) { |
|||
lock[i].disabled = true |
|||
} |
|||
} |
|||
</script> |
|||
<?php if (empty($contract_new_apply)) : ?> |
|||
<script> |
|||
const contractno = '<?php echo $contract['contractno'] ?? ''; ?>'; |
|||
const salesman = '<?php echo $contract['person'] ?? ''; ?>'; |
|||
const salesmanname = '<?php echo $contract['accountname'] ?? ''; ?>'; |
|||
const apply_date = '<?php echo date('Y-m-d') ?>'; |
|||
const case_name = '<?php echo $contract['case_name'] ?? ''; ?>'; |
|||
const company = '<?php echo $contract['company'] ?? ''; ?>'; |
|||
const manager = '<?php echo $customer['manager'] ?? ''; ?>'; |
|||
const vat = '<?php echo $customer['uscc'] ?? ''; ?>'; |
|||
const price_total = <?php echo $contract['price_total'] ?? ''; ?>; |
|||
const address = '<?php echo $contract['address'] ?? ''; ?>'; |
|||
const price_a = <?php echo $price_a ?? ''; ?>; |
|||
const price_b = <?php echo $price_b ?? ''; ?>; |
|||
const items = [...<?php echo json_encode($items) ?? []; ?>]; |
|||
const user_id = '<?php echo $user_id ?>'; |
|||
const mid = '<?php echo $_GET['id']; ?>'; |
|||
const pays = [...<?php echo json_encode($pays) ?? []; ?>]; |
|||
const secondPayDeadline = ''; |
|||
const tradeaddress = '<?php echo $contract['address'] ?? ''; ?>'; |
|||
const tradedeadline = 90 |
|||
const freedeadline = 18; |
|||
const regulations = 10; |
|||
const workdeadline_a = 60; |
|||
const workdeadline_b = 7; |
|||
const total_items = <?php echo $total_items ?? ''; ?>; |
|||
const isFirst = <?php echo $isFirst; ?>; |
|||
</script> |
|||
<?php else : ?> |
|||
<script> |
|||
const contractno = '<?php echo $contract['contractno'] ?? ''; ?>'; |
|||
const salesman = '<?php echo $contract['person'] ?? ''; ?>'; |
|||
const salesmanname = '<?php echo $contract['personname'] ?? ''; ?>'; |
|||
const apply_date = '<?php echo date('Y-m-d') ?>'; |
|||
const case_name = '<?php echo $contract['case_name'] ?? ''; ?>'; |
|||
const company = '<?php echo $contract['customer'] ?? ''; ?>'; |
|||
const manager = '<?php echo $contract['manager'] ?? ''; ?>'; |
|||
const vat = '<?php echo $contract['vat'] ?? ''; ?>'; |
|||
const price_total = <?php echo $contract['total_price'] ?? ''; ?>; |
|||
const address = '<?php echo $contract['contact_address'] ?? ''; ?>'; |
|||
const price_a = <?php echo $contract['buy_fee'] ?? ''; ?>; |
|||
const price_b = <?php echo $contract['install_fee'] ?? ''; ?>; |
|||
const items = [...<?php echo json_encode($items) ?? []; ?>]; |
|||
const user_id = '<?php echo $user_id ?? ''; ?>'; |
|||
const mid = '<?php echo $_GET['id']; ?>'; |
|||
const pays = [...<?php echo json_encode($pays) ?? []; ?>]; |
|||
const isFirst = <?php echo $isFirst; ?>; |
|||
const tradeaddress = '<?php echo $contract['trade_address'] ?? ''; ?>'; |
|||
const tradedeadline = '<?php echo $contract['tradedeadline'] ?? ''; ?>'; |
|||
const freedeadline = '<?php echo $contract['freedeadline'] ?? ''; ?>'; |
|||
const regulations = '<?php echo $contract['test_time'] ?? ''; ?>'; |
|||
const workdeadline_a = '<?php echo $contract['workdeadline_a'] ?? ''; ?>'; |
|||
const workdeadline_b = '<?php echo $contract['workdeadline_b'] ?? ''; ?>'; |
|||
const secondPayDeadline = <?php echo $secondPayDeadline ?? ''; ?>; |
|||
const total_items = <?php echo $contract['total_items'] ?? ''; ?>; |
|||
const contract_new_apply_id = <?php echo $contract_new_apply_id; ?>; |
|||
</script> |
|||
|
|||
|
|||
<?php endif; ?> |
|||
<?php if ($status > 0 || ($person != $user_id && $user_id != "M0174")) : ?> |
|||
<script> |
|||
window.onload = () => { |
|||
const input = document.querySelectorAll('input'); |
|||
const alerttext = document.querySelectorAll('p.alerttext'); |
|||
const select = document.querySelectorAll('select'); |
|||
for (let i = 0; i < input.length; i++) { |
|||
input[i].disabled = true |
|||
} |
|||
for (let i = 0; i < select.length; i++) { |
|||
select[i].disabled = true |
|||
} |
|||
for (let i = 0; i < alerttext.length; i++) { |
|||
alerttext[i].style.display = "none" |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<?php endif; ?> |
@ -0,0 +1,842 @@ |
|||
const contractDownload = () => { |
|||
return { |
|||
init() { |
|||
this.standarDate = this.deepClone(this.data); |
|||
this.onstandarViewData = this.deepClone(this.data); |
|||
this.buystandarData = this.deepClone(this.buydata); |
|||
this.buyonstandardViewData = this.deepClone(this.buydata); |
|||
}, |
|||
css: `table { background - color: #fff; border: none; margin - top: 30px; font - family: '標楷體'; width: 600px; } table tr: nth - child(even), table tr: nth - child(odd) { background - color: #fff; } table tr { font - size: 12pt; width: 100 %; } table tr h2 { font - size: 18pt; } table tr td { width: 100 %; height: 100 %; line - height: 2; display: flex; } table tr td.center { display: flex; justify - content: center; align - items: center; } table tr td.list { width: 100 %; height: 100 %; white - space: nowrap; display: flex; } table tr td.list span { width: 60px; min - height: 100 %; display: block; } table tr td.list > p { display: block; text - align: justify; } table tr td.list div { max - width: calc(100 % - 60px); white - space: normal; } table tr td.list div.text - justify { display: flex; width: 100 %; justify - content: space - between; } table tr.date td > div { width: 100 %; text - align: right; } table tr.date td > div.text - justify { display: flex; justify - content: space - between; } table td, table th { padding: 8px; }`, |
|||
data: { |
|||
illustrate: { |
|||
editshow: false, |
|||
plaintext: '茲因甲乙雙方就電梯設備保養.檢修事宜,同意訂定本契約,議定條款如后,並相互遵守條款約定。', |
|||
}, |
|||
partyA: { |
|||
editshow: false, |
|||
plaintext: partyAcompany, |
|||
}, |
|||
partyAcontractno: { |
|||
editshow: false, |
|||
plaintext: partyAcontractno, |
|||
}, |
|||
list: { |
|||
plaintext: [ |
|||
{ |
|||
editshow: false, |
|||
origin: true, |
|||
text: ``, |
|||
deleted: false, |
|||
id: 0, |
|||
input_id: null |
|||
}, |
|||
{ |
|||
editshow: false, |
|||
origin: true, |
|||
text: `規格`, |
|||
type: 'title', |
|||
deleted: false, |
|||
id: 1, |
|||
input_id: null |
|||
}, |
|||
{ |
|||
editshow: false |
|||
} |
|||
] |
|||
} |
|||
}, |
|||
buydata: { |
|||
|
|||
}, |
|||
exportFn(type) { |
|||
const form = this.$refs.form; |
|||
const prviewType = this.$refs.form.querySelector('#prview-type'); |
|||
const list = this.$refs.form.querySelector('#privew-list'); |
|||
const standardList = this.$refs.form.querySelector('#standard-prview-list'); |
|||
const illustrate = this.$refs.form.querySelector('illustrate'); |
|||
const standardIllustrate = this.$refs.form.querySelector('#standard-illustrate'); |
|||
const partyA = this.$refs.form.querySelector('#partyA'); |
|||
const partyAcontractno = this.$refs.form.querySelector('#partyAcontractno'); |
|||
const total_price = this.$refs.form.querySelector('#total_price'); |
|||
prviewType.value = type; |
|||
if (type === 1) { |
|||
const standarJsonText = this.buystandarDate.list.plaintext.map((item, idx) => { |
|||
let text = ''; |
|||
text = item.text.replace(/\s+/g, ""); |
|||
this.buydata.list.plaintext[idx].text = this.buydata.list.plaintext[idx].text.replace(/\s+/g, ""); |
|||
|
|||
return { |
|||
text: text, |
|||
id: item.id |
|||
} |
|||
}); |
|||
|
|||
const jsonText = this.buydata.list.plaintext.map(item => { |
|||
let text = ''; |
|||
text = item.text; |
|||
return { |
|||
text: text, |
|||
origin: item.origin ? 1 : 0, |
|||
deleted: item.deleted ? 1 : 0, |
|||
id: item.id, |
|||
updated: item.updated ? 1 : 0 |
|||
} |
|||
}); |
|||
list.value = JSON.stringify(jsonText); |
|||
standardList.value = JSON.stringify(standarJsonText); |
|||
illustrate.value = this.buydata.illustrate.plaintext; |
|||
standardIllustrate.value = this.buyonstandardViewData.illustrate.plaintext; |
|||
partyA.value = this.buydata.partyA.plaintext; |
|||
partyAcontractno.value = this.buydata.partyAcontractno.plaintext; |
|||
total_price.value = totalBuyPrice; |
|||
form.submit(); |
|||
return; |
|||
} |
|||
|
|||
if (type === 2) { |
|||
const standardJsonText = this.standarData.list.plaintext.map((item, idx) => { |
|||
let text = ''; |
|||
text = item.text.replace(/\s+/g, ""); |
|||
if (this.data.list.plaintext[idx] !== undefined) { |
|||
this.data.list.plaintext[idx].text = this.data.list.plaintext[idx].text.replace(/\s+/g, ""); |
|||
} |
|||
return { |
|||
text: text, |
|||
id: item.id |
|||
} |
|||
}) |
|||
const jsonText = this.data.list.plaintext.map(item => { |
|||
let text = ''; |
|||
item.text; |
|||
text = item.text; |
|||
return { |
|||
text: text, |
|||
origin: item.origin ? 1 : 0, |
|||
deleted: item.deleted ? 1 : 0, |
|||
id: item.id, |
|||
updated: item.updated ? 1 : 0 |
|||
} |
|||
}) |
|||
list.value = JSON.stringify(jsonText); |
|||
standardList.value = JSON.stringify(standarJsonText); |
|||
illustrate.value = this.data.illustrate.plaintext; |
|||
standardIllustrate.value = this.standardData.illustrate.plaintext; |
|||
partyA.value = this.data.partyA.plaintext; |
|||
partyAcontractno.value = this.data.partyAcontractno.plaintext; |
|||
total_price.value = totalInstallPrice; |
|||
form.submit(); |
|||
|
|||
return; |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
}; |
|||
|
|||
const contractNewInput = () => { |
|||
return { |
|||
init() { }, |
|||
data: { |
|||
contractno: '', |
|||
customer: '', |
|||
manager: '', |
|||
vat: '', |
|||
case_name: '', |
|||
linkman: '', |
|||
lm_tel: '', |
|||
address: '', |
|||
salesman: '', |
|||
qc: '', |
|||
qc: '', |
|||
// files:[],
|
|||
}, |
|||
step: 1, |
|||
isLoading: false, |
|||
customize: false, |
|||
nextStepFn() { |
|||
if (this.data.contractno == '') return alert('合約號為必填') |
|||
this.isLoading = true |
|||
if (this.step == 1) { |
|||
this.getContractDate(); |
|||
} |
|||
}, |
|||
nextStepKeyupFn(e) { |
|||
if (e.keyCode != 13) return |
|||
if (this.step == 1) { |
|||
this.getContractDate(); |
|||
console.log(this.step); |
|||
} |
|||
}, |
|||
preStepFn() { |
|||
if (this.step == 2) { |
|||
this.step = 1 |
|||
} |
|||
}, |
|||
getContractDate() { |
|||
axios.get('./api/getContractData.php?contracttype=m&contractno=' + this.data.contractno).then(res => { |
|||
if (!res.data) { |
|||
this.step = 2 |
|||
this.isLoading = false |
|||
return |
|||
} |
|||
if (!this.customize) { |
|||
console.log(res.data); |
|||
this.data.customer = res.data.customer |
|||
this.data.manager = res.data.manager |
|||
this.data.vat = res.data.uscc |
|||
this.data.case_name = res.data.case_name |
|||
this.data.linkman = res.data.linkman |
|||
this.data.lm_tel = res.data.lm_tel |
|||
this.data.address = res.data.address |
|||
this.data.salesman = res.data.salesman |
|||
this.data.qc = res.data.qc |
|||
} |
|||
this.step = 2 |
|||
this.isLoading = false |
|||
}).catch(err => { |
|||
console.error(err) |
|||
this.isLoading = false |
|||
}) |
|||
}, |
|||
save() { |
|||
this.isLoading = true |
|||
const form = new FormData(); |
|||
form.append('contractno', this.data.contractno); |
|||
form.append('customer', this.data.customer); |
|||
form.append('manager', this.data.manager); |
|||
form.append('vat', this.data.vat); |
|||
form.append('case_name', this.data.case_name); |
|||
form.append('linkman', this.data.linkman); |
|||
form.append('lm_tel', this.data.lm_tel); |
|||
form.append('address', this.data.address); |
|||
form.append('salesman', this.data.salesman); |
|||
form.append('qc', this.data.qc); |
|||
form.append('contracttype', 'm'); |
|||
form.append('user_id', user_id); |
|||
for (var i = 0; i < this.data.files.length; i++) { |
|||
form.append('files[]', this.data.files[i]); |
|||
} |
|||
axios.post('./api/postNewContractData.php', form).then(res => { |
|||
console.log(res); |
|||
if (res.status === 201) { |
|||
alert('儲存成功'); |
|||
this.step = 1 |
|||
this.data.contractno = '' |
|||
this.data.customer = '' |
|||
this.data.manager = '' |
|||
this.data.vat = '' |
|||
this.data.case_name = '' |
|||
this.data.linkman = '' |
|||
this.data.lm_tel = '' |
|||
this.data.address = '' |
|||
this.data.salesman = '' |
|||
this.data.qc = '' |
|||
this.data.files = [] |
|||
this.customize = false |
|||
|
|||
} else { |
|||
alert('儲存失敗!可能為以下錯誤:\n' + res.data) |
|||
} |
|||
this.isLoading = false |
|||
}).catch(error => { |
|||
let code = error.response.status; |
|||
if (code == 422) { |
|||
this.fail_arr = error.response.data |
|||
this.errorFn(); |
|||
} |
|||
if (code == 500) { |
|||
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data) |
|||
} |
|||
|
|||
this.isLoading = false |
|||
}) |
|||
}, |
|||
errorFn() { |
|||
let msg = '' |
|||
for (let i = 0; i < this.fail_arr.length; i++) { |
|||
msg += this.fail_arr[i] + '、' |
|||
} |
|||
alert(msg) |
|||
}, |
|||
uploadFiles(e) { |
|||
this.data.files = e.target.files |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
//////////////////////////////
|
|||
//// 合約簽回(修理)
|
|||
////
|
|||
//// 製作人:梓誠
|
|||
/// 時間 :
|
|||
//////////////////////////////
|
|||
const contractRepair = () => { |
|||
return { |
|||
init() { }, |
|||
data: { |
|||
contractno: '', |
|||
company: '', |
|||
repairer: '', |
|||
repaireid: '', |
|||
facilityno: '', |
|||
taxid: '', |
|||
invoice: '', //發票抬頭
|
|||
type: '', //工程類別需新增,用 post
|
|||
address: '', |
|||
repair_no: '', |
|||
total_price: '', |
|||
sign_date: '', |
|||
contract_status: '' |
|||
}, |
|||
step: 1, |
|||
isLoading: false, |
|||
customize: false, |
|||
|
|||
|
|||
nextStepFn() { |
|||
if (this.data.contractno == '') return alert('合約號為必填') |
|||
this.isLoading = true |
|||
if (this.step == 1) { |
|||
this.getContractDate(); |
|||
} |
|||
}, |
|||
nextStepKeyupFn(e) { |
|||
if (e.keyCode != 13) return |
|||
if (this.step == 1) { |
|||
this.getContractDate(); |
|||
console.log(this.step); |
|||
} |
|||
}, |
|||
// 抓資料
|
|||
getContractDate() { |
|||
axios.get('./api/getContractData.php?contracttype=r&repair_no=' + this.data.repair_no).then(res => { |
|||
if (!res.data) { |
|||
this.step = 2; |
|||
this.isLoading = false; |
|||
// console.log(123);
|
|||
return |
|||
} |
|||
if (!this.customize) { |
|||
// console.log(res.data);
|
|||
this.data.contractno = res.data.contractno; |
|||
this.data.company = res.data.company; |
|||
this.data.repairer = res.data.name; |
|||
this.data.facilityno = res.data.facilityno; |
|||
this.data.taxid = res.data.taxid; |
|||
this.data.invoice = res.data.invoice; |
|||
this.data.address = res.data.address; |
|||
this.data.repair_no = res.data.repair_no; |
|||
this.data.total_price = res.data.total_price; |
|||
this.data.repaireid = res.data.repairerid; |
|||
this.data.sign_date = res.data.sign_date; |
|||
this.data.contract_status = res.data.contract_status; |
|||
} |
|||
this.step = 2; |
|||
this.isLoading = false; |
|||
// console.log(user_name);
|
|||
// console.log(this.data.sign_date);
|
|||
}).catch(err => { |
|||
console.log(err); |
|||
alert(err.response.data); |
|||
this.isLoading = false |
|||
}) |
|||
}, |
|||
preStepFn() { |
|||
if (this.step == 2) { |
|||
if (confirm('回到上一頁會初始化資料,確定要返回嗎?')) { |
|||
this.step = 1; |
|||
this.data.contractno = ''; |
|||
this.data.company = ''; |
|||
this.data.repairer = ''; |
|||
this.data.facilityno = ''; |
|||
this.data.taxid = ''; |
|||
this.data.invoice = ''; |
|||
this.data.address = ''; |
|||
this.data.repair_no = ''; |
|||
this.data.total_price = ''; |
|||
this.data.repaireid = ''; |
|||
this.data.sign_date = ''; |
|||
this.data.contract_status = ''; |
|||
|
|||
return; |
|||
} |
|||
} |
|||
}, |
|||
save() { |
|||
this.isLoading = true; |
|||
const form = new FormData(); |
|||
form.append('contractno', this.data.contractno); |
|||
form.append('company', this.data.company); |
|||
form.append('repairid', this.data.repaireid); |
|||
form.append('facilityno', this.data.facilityno); |
|||
form.append('taxid', this.data.taxid); |
|||
form.append('invoice', this.data.invoice); |
|||
form.append('address', this.data.address); |
|||
form.append('repair_no', this.data.repair_no); |
|||
form.append('total_price', this.data.total_price); |
|||
form.append('sign_date', this.data.sign_date); |
|||
form.append('contract_status', this.data.contract_status); |
|||
form.append('contracttype', 'r'); |
|||
form.append('user_id', user_id); |
|||
form.append('type', this.data.type); |
|||
axios.post('./api/postContractData.php', form).then(res => { |
|||
console.log(res.status); |
|||
if (res.status === 200) { |
|||
alert('儲存成功'); |
|||
this.step = 1; |
|||
this.data.contractno = ''; |
|||
this.data.company = ''; |
|||
this.data.repaireid = ''; |
|||
this.data.facilityno = ''; |
|||
this.data.repairer = ''; |
|||
this.data.taxid = ''; |
|||
this.data.invoice = ''; |
|||
this.data.address = ''; |
|||
this.data.repair_no = ''; |
|||
this.data.total_price = ''; |
|||
this.data.user_id = ''; |
|||
this.data.type = ''; |
|||
this.data.sign_date = ''; |
|||
this.data.contract_status = ''; |
|||
} |
|||
this.isLoading = false; |
|||
}).catch(error => { |
|||
let code = error.response.status; |
|||
if (code == 422) { |
|||
this.fail_arr = error.response.data; |
|||
this.errorFn(); |
|||
console.log(error.response.data); |
|||
} |
|||
if (code == 500) { |
|||
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data); |
|||
} |
|||
|
|||
this.isLoading = false; |
|||
}) |
|||
}, |
|||
errorFn() { |
|||
let msg = ''; |
|||
for (let i = 0; i < this.fail_arr.length; i++) { |
|||
msg += this.fail_arr[i] + '、'; |
|||
} |
|||
alert(msg); |
|||
}, |
|||
uploadFiles(e) { |
|||
this.data.files = e.target.files; |
|||
} |
|||
|
|||
} |
|||
}; |
|||
|
|||
const contractInput = () => { |
|||
return { |
|||
init() { |
|||
$('.contract-input-component .form .dropdown').dropdown(); |
|||
|
|||
axios.get('./twzip.json').then(res => { |
|||
this.cities = res.data.cities |
|||
}) |
|||
}, |
|||
cities: [], |
|||
data: { |
|||
contractno: 'B23100060', |
|||
total_price: '', //合約總價
|
|||
vat: '', //統一編號
|
|||
mtype: 'A', //維修型態
|
|||
phone: '', //客戶電話
|
|||
email: '', //Email
|
|||
mworker: '', //保養員
|
|||
mcycle: '', //保養頻率
|
|||
salesman: '', //營業員
|
|||
contract_begin_date: '', //合約開始時間
|
|||
contract_end_date: '', //合約終止時間
|
|||
area: '', //區域
|
|||
zip: '', //郵遞區號
|
|||
address: '', //地址
|
|||
customer: '', //立約人
|
|||
partyA: '', //業務聯繫人
|
|||
partyAaddress: '', //業務聯繫人地址
|
|||
partyAphone: '', //業務聯繫人電話
|
|||
partyAemail: '', //業務聯繫人email
|
|||
files: [], //附件檔案
|
|||
num: '', //電梯數量
|
|||
disabled: false, //資料庫是否有電梯數量資料
|
|||
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
|
|||
}, |
|||
customize: false, |
|||
step: 1, |
|||
isLoading: false, |
|||
fail_arr: [], |
|||
nextStepFn() { |
|||
if (this.step == 1) { |
|||
if (this.data.repair_no == '') return alert('請輸入合約號'); |
|||
this.isLoading = true |
|||
this.getContractDate(); |
|||
} else if (this.step == 2) { |
|||
if (this.data.num <= 0) return alert('請填寫電梯數量!') |
|||
if (!this.data.disabled) { |
|||
this.createElevator(); |
|||
} |
|||
this.step = 3 |
|||
} |
|||
}, |
|||
nextStepKeyupFn(e) { |
|||
if (e.keyCode !== 13) return |
|||
if (this.step == 1) { |
|||
if (this.data.repair_no == '') return alert('請輸入合約號'); |
|||
this.isLoading = true |
|||
this.getContractDate(); |
|||
|
|||
} else if (this.step == 2) { |
|||
this.step = 3 |
|||
} |
|||
}, |
|||
createElevator() { |
|||
for (let i = 0; i < this.data.num; i++) { |
|||
this.data.elevators.push({ |
|||
spec: '', //規格
|
|||
weight: '', //載重
|
|||
speed: '', //速度
|
|||
persons: '', //人乘
|
|||
stop: '', //樓停
|
|||
floors: '', //樓層
|
|||
latitude: '', //緯度
|
|||
longitude: '', //經度
|
|||
elevator_brand: '', //廠牌
|
|||
opendoor: '', //開門方式
|
|||
maintainance: '', //保養別
|
|||
takecertificatedate: '', //竣檢日
|
|||
useful_date: '', //許可證有效日期
|
|||
}) |
|||
} |
|||
}, |
|||
getContractDate() { |
|||
axios.get('./api/getContractData.php?contracttype=b&contractno=' + this.data.contractno).then(res => { |
|||
if (!res.data) { |
|||
this.step = 2 |
|||
this.isLoading = false |
|||
return |
|||
} |
|||
if (!this.customize) { |
|||
console.log(res.data); |
|||
this.data.total_price = res.data.sold_price |
|||
this.data.salesman = res.data.salesman |
|||
this.data.contract_begin_date = res.data.contract_begin_date |
|||
this.data.contract_end_date = res.data.contract_end_date |
|||
this.data.address = res.data.address |
|||
this.data.customer = res.data.customer |
|||
this.data.partyA = res.data.customer |
|||
this.data.partyAaddress = res.data.address |
|||
this.data.num = res.data.num |
|||
this.data.disabled = (res.data.num > 0) ? true : false; |
|||
this.data.elevators = res.data.elevators |
|||
let cityIndex = this.data.address.indexOf('市'); |
|||
console.log(cityIndex); |
|||
if (cityIndex == -1) { |
|||
cityIndex = this.data.address.indexOf('縣'); |
|||
} |
|||
if (cityIndex > 1) { |
|||
// 獲取''市''前面的兩個字
|
|||
let city = this.data.address.substring(cityIndex - 2, cityIndex + 1); |
|||
this.data.area = city; |
|||
} else { |
|||
this.data.area = '' |
|||
} |
|||
} |
|||
this.step = 2 |
|||
this.isLoading = false |
|||
}).catch(err => { |
|||
console.error(err) |
|||
this.isLoading = false |
|||
}) |
|||
}, |
|||
preStepFn() { |
|||
if (this.step == 2) { |
|||
if (confirm('回到上一頁會將會初始化資料,確定返回嗎?')) { |
|||
this.step = 1 |
|||
this.data.total_price = '' |
|||
this.data.salesman = '' |
|||
this.data.contract_begin_date = '' |
|||
this.data.contract_end_date = '' |
|||
this.data.address = '' |
|||
this.data.customer = '' |
|||
this.data.partyA = '' |
|||
this.data.partyAaddress = '' |
|||
this.step = 1 |
|||
this.data.num = '' |
|||
this.data.disabled = false |
|||
this.data.elevators = [] |
|||
this.data.files = [] |
|||
this.data.vat = '' |
|||
this.data.mtype = '' |
|||
this.data.phone = '' |
|||
this.data.email = '' |
|||
this.data.mworker = '' |
|||
this.data.mcycle = '' |
|||
this.data.area = '' |
|||
this.data.zip = '' |
|||
this.data.partyAphone = '' |
|||
this.data.partyAemail = '' |
|||
return; |
|||
} |
|||
} else if (this.step == 3) { |
|||
this.step = 2 |
|||
} |
|||
}, |
|||
save() { |
|||
this.isLoading = true |
|||
const form = new FormData(); |
|||
form.append('contractno', this.data.contractno); |
|||
form.append('total_price', this.data.total_price); |
|||
form.append('vat', this.data.vat); |
|||
form.append('mtype', this.data.mtype); |
|||
form.append('phone', this.data.phone); |
|||
form.append('email', this.data.email); |
|||
form.append('mworker', this.data.mworker); |
|||
form.append('mcycle', this.data.mcycle); |
|||
form.append('salesman', this.data.salesman); |
|||
form.append('contract_begin_date', this.data.contract_begin_date); |
|||
form.append('contract_end_date', this.data.contract_end_date); |
|||
form.append('address', this.data.address); |
|||
form.append('area', this.data.area); |
|||
form.append('customer', this.data.customer); |
|||
form.append('partyA', this.data.partyA); |
|||
form.append('partyAaddress', this.data.partyAaddress); |
|||
form.append('partyAphone', this.data.partyAphone); |
|||
form.append('partyAemail', this.data.partyAemail); |
|||
form.append('user_id', user_id); |
|||
form.append('user_name', user_name); |
|||
form.append('num', this.data.num); |
|||
form.append('elevators', JSON.stringify(this.data.elevators)); |
|||
form.append('contracttype', 'b'); |
|||
|
|||
// 如果有附件檔案,可以逐一加入
|
|||
for (var i = 0; i < this.data.files.length; i++) { |
|||
form.append('files[]', this.data.files[i]); |
|||
} |
|||
axios.post('./api/postContractData.php', form).then(res => { |
|||
console.log(res.status); |
|||
if (res.status === 200) { |
|||
alert('儲存成功'); |
|||
this.step = 1 |
|||
this.data.total_price = '' |
|||
this.data.salesman = '' |
|||
this.data.contract_begin_date = '' |
|||
this.data.contract_end_date = '' |
|||
this.data.address = '' |
|||
this.data.customer = '' |
|||
this.data.partyA = '' |
|||
this.data.partyAaddress = '' |
|||
this.step = 1 |
|||
this.data.num = '' |
|||
this.data.disabled = false |
|||
this.data.elevators = [] |
|||
this.data.files = [] |
|||
this.data.vat = '' |
|||
this.data.mtype = '' |
|||
this.data.phone = '' |
|||
this.data.email = '' |
|||
this.data.mworker = '' |
|||
this.data.mcycle = '' |
|||
this.data.area = '' |
|||
this.data.zip = '' |
|||
this.data.partyAphone = '' |
|||
this.data.partyAemail = '' |
|||
} |
|||
this.isLoading = false |
|||
}).catch(error => { |
|||
let code = error.response.status; |
|||
if (code == 422) { |
|||
this.fail_arr = error.response.data |
|||
this.errorFn(); |
|||
} |
|||
if (code == 500) { |
|||
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data) |
|||
} |
|||
|
|||
this.isLoading = false |
|||
}) |
|||
}, |
|||
errorFn() { |
|||
let msg = '' |
|||
for (let i = 0; i < this.fail_arr.length; i++) { |
|||
msg += this.fail_arr[i] + '、' |
|||
} |
|||
alert(msg) |
|||
}, |
|||
uploadFiles(e) { |
|||
this.data.files = e.target.files |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
const contractNewApply = () => { |
|||
return { |
|||
step: 1, |
|||
isLoading: false, |
|||
data: { |
|||
mid: mid, |
|||
vol_no: contractno, |
|||
salesman: salesman, |
|||
salesmanname: salesmanname, |
|||
apply_date: apply_date, |
|||
apply_type: 'A', |
|||
case_name: case_name, |
|||
company: company, |
|||
manager: manager, |
|||
vat: vat, |
|||
total_price: price_total, |
|||
price_a: price_a, |
|||
price_b: price_b, |
|||
address: address, |
|||
workdeadline_a: 30, //完工期限: 幾天內安裝完成,預設30
|
|||
workdeadline_b: 7, //完工期限: 幾天內整理完善,預設7
|
|||
regulations: 10, //附則
|
|||
freedeadline: 18, //免保期限(月)
|
|||
tradeaddress: '', //交貨地點
|
|||
tradedeadline: 90, //交貨期限
|
|||
items: items, |
|||
}, |
|||
pays: { |
|||
1: 0, |
|||
2: 0, |
|||
3: 0, |
|||
4: 0, |
|||
5: 0, |
|||
6: 0, |
|||
7: 0, |
|||
}, |
|||
tickets: { |
|||
1: 0, |
|||
2: 0, |
|||
3: 0, |
|||
4: 0, |
|||
5: 0, |
|||
6: 0, |
|||
7: 0, |
|||
}, |
|||
localnumber(num) { |
|||
return num.toLocaleString(); |
|||
}, |
|||
storageFn() { |
|||
this.isLoading = true |
|||
const isFirst = 1; |
|||
const form = new FormData(); |
|||
form.append('mid', this.data.mid); |
|||
form.append('vol_no', this.data.vol_no); |
|||
form.append('salesman', this.data.salesman); |
|||
form.append('apply_date', this.data.apply_date); |
|||
form.append('apply_type', this.data.apply_type); |
|||
form.append('case_name', this.data.case_name); |
|||
form.append('company', this.data.company); |
|||
form.append('manager', this.data.manager); |
|||
form.append('vat', this.data.vat); |
|||
form.append('total_price', this.data.total_price); |
|||
form.append('price_a', this.data.price_a); |
|||
form.append('price_b', this.data.price_b); |
|||
form.append('address', this.data.address); |
|||
form.append('workdeadline_a', this.data.workdeadline_a); |
|||
form.append('workdeadline_b', this.data.workdeadline_b); |
|||
form.append('regulations', this.data.regulations); |
|||
form.append('freedeadline', this.data.freedeadline); |
|||
form.append('tradeaddress', this.data.tradeaddress); |
|||
form.append('tradedeadline', this.data.tradedeadline); |
|||
form.append('isFirst', isFirst); |
|||
form.append('user_id', user_id); |
|||
axios.post('./api/postContractNewApplyData.php', form).then(res => { |
|||
if (res.status === 200) { |
|||
alert('暫存成功'); |
|||
console.log(res.data); |
|||
} |
|||
this.isLoading = false |
|||
}).catch(error => { |
|||
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data) |
|||
this.isLoading = false |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
|
|||
const contract_edit = () => { |
|||
console.log(contract_status); |
|||
return { |
|||
isLoading: false, |
|||
data: { |
|||
id: id, |
|||
repair_no: repair_no, |
|||
contractno: contractno, |
|||
company: company, |
|||
taxid: taxid, |
|||
facilityno: facilityno, |
|||
address: address, |
|||
type: type, |
|||
invoice: invoice, |
|||
repaireid: repaireid, |
|||
total_price: total_price, |
|||
sign_date: sign_date, |
|||
user_id: user_id, |
|||
contract_status: contract_status |
|||
|
|||
}, |
|||
fail_arr: [], |
|||
deleteFileFn(id) { |
|||
if (!confirm("確定要刪除嗎?")) return |
|||
this.data.files = this.data.files.filter(file => id != file.id) |
|||
this.data.deletefiles.push(id) |
|||
console.log(this.data.deletefiles); |
|||
}, |
|||
save() { |
|||
this.isLoading = true |
|||
const form = new FormData(); |
|||
form.append("id", this.data.id); |
|||
form.append("repair_no", this.data.repair_no); |
|||
form.append("contractno", this.data.contractno); |
|||
form.append("company", this.data.company); |
|||
form.append("taxid", this.data.taxid); |
|||
form.append("facilityno", this.data.facilityno); |
|||
form.append("address", this.data.address); |
|||
form.append("type", this.data.type); |
|||
form.append("invoice", this.data.invoice); |
|||
form.append("repaireid", this.data.repaireid); |
|||
form.append("total_price", this.data.total_price); |
|||
form.append("sign_date", this.data.sign_date); |
|||
form.append("user_id", user_id); |
|||
form.append("contract_status", this.data.contract_status); |
|||
form.append('contracttype', 'r'); |
|||
|
|||
axios.post("./api/putContractData.php", form).then(res => { |
|||
console.log(res); |
|||
if (res.status === 200) { |
|||
alert("更新成功"); |
|||
window.location.reload(); |
|||
} |
|||
this.isLoading = false |
|||
}).catch(error => { |
|||
console.log(this.data); |
|||
console.log(error); |
|||
let code = error.response.status; |
|||
if (code == 422) { |
|||
this.fail_arr = error.response.data |
|||
this.errorFn() |
|||
} |
|||
if (code == 500) { |
|||
alert("更新失敗!可能為以下錯誤:\n" + error.response.data) |
|||
} |
|||
this.isLoading = false |
|||
}) |
|||
|
|||
}, |
|||
uploadFiles(e) { |
|||
this.data.newfiles = e.target.files |
|||
}, |
|||
errorFn() { |
|||
let msg = "" |
|||
for (let i = 0; i < this.fail_arr.length; i++) { |
|||
msg += this.fail_arr[i] + "、" |
|||
} |
|||
alert(msg) |
|||
} |
|||
} |
|||
|
|||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,25 @@ |
|||
|
|||
const axiosClient = axios.create({ |
|||
baseURL : `${import.meta.env.VITE_API_BASE_URL}/api`, |
|||
}); |
|||
|
|||
|
|||
axiosClient.interceptors.request.use( (config)=> { |
|||
config.headers.Authorization = `Bearer ${store.state.user.token}` |
|||
return config; |
|||
}, (error)=> { |
|||
return Promise.reject(error); |
|||
}); |
|||
|
|||
axiosClient.interceptors.response.use( (response)=> { |
|||
return response; |
|||
}, (error)=>{ |
|||
if(error.response.status === 401){ |
|||
store.commit('setToken', null) |
|||
sessionStorage.removeItem('TOKEN') |
|||
router.push({name:'login'}) |
|||
} |
|||
throw error; |
|||
}); |
|||
|
|||
export default axiosClient; |
File diff suppressed because one or more lines are too long
@ -0,0 +1,48 @@ |
|||
export default { |
|||
data() { |
|||
return { |
|||
options: [], |
|||
value: [], |
|||
list: [], |
|||
loading: false, |
|||
states: ["Alabama", "Alaska", "Arizona", |
|||
"Arkansas", "California", "Colorado", |
|||
"Connecticut", "Delaware", "Florida", |
|||
"Georgia", "Hawaii", "Idaho", "Illinois", |
|||
"Indiana", "Iowa", "Kansas", "Kentucky", |
|||
"Louisiana", "Maine", "Maryland", |
|||
"Massachusetts", "Michigan", "Minnesota", |
|||
"Mississippi", "Missouri", "Montana", |
|||
"Nebraska", "Nevada", "New Hampshire", |
|||
"New Jersey", "New Mexico", "New York", |
|||
"North Carolina", "North Dakota", "Ohio", |
|||
"Oklahoma", "Oregon", "Pennsylvania", |
|||
"Rhode Island", "South Carolina", |
|||
"South Dakota", "Tennessee", "Texas", |
|||
"Utah", "Vermont", "Virginia", |
|||
"Washington", "West Virginia", "Wisconsin", |
|||
"Wyoming"] |
|||
} |
|||
}, |
|||
mounted() { |
|||
this.list = this.states.map(item => { |
|||
return { value: `value:${item}`, label: `label:${item}` }; |
|||
}); |
|||
}, |
|||
methods: { |
|||
remoteMethod(query) { |
|||
if (query !== '') { |
|||
this.loading = true; |
|||
setTimeout(() => { |
|||
this.loading = false; |
|||
this.options = this.list.filter(item => { |
|||
return item.label.toLowerCase() |
|||
.indexOf(query.toLowerCase()) > -1; |
|||
}); |
|||
}, 200); |
|||
} else { |
|||
this.options = []; |
|||
} |
|||
} |
|||
} |
|||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,649 @@ |
|||
<?php |
|||
include "../header.php"; |
|||
require_once('./conn.php'); |
|||
if ($_POST['list']) { |
|||
$contract_id = $_POST['contract_apply_id']; |
|||
if ($_POST['prviewType'] == 1) { |
|||
$isStand = ($_POST['buystandard'] == "true") ? 1 : 0; |
|||
} else { |
|||
$isStand = $_POST['installstandard'] == "true" ? 1 : 0; |
|||
} |
|||
$type = $_POST['prviewType'] == '1' ? "電梯買賣合約書" : "電梯安裝合約書"; |
|||
$list = json_decode($_POST['list']); |
|||
$standardList = json_decode($_POST['standardList']); |
|||
$illustrate = $_POST['illustrate']; |
|||
$updatedIllustrate = false; |
|||
$standardIllustrate = $_POST['standardIllustrate']; |
|||
$partyA = $_POST['partyA']; |
|||
$partyAcontractno = $_POST['partyAcontractno']; |
|||
$total_price = $_POST['total_price']; |
|||
$person = $_POST['person']; |
|||
$personid = $_POST['personid']; |
|||
$delivery_term = $_POST['delivery_term']; |
|||
$install_period = $_POST['install_period']; |
|||
$free_maintainance = $_POST['free_maintainance']; |
|||
// $originArr = array_filter(json_decode(json_encode($list), true), fn($item)=> $item['origin'] == 1); |
|||
$standardArr = json_decode(json_encode($standardList), true); |
|||
$nostandardArr = json_decode(json_encode($list), true); |
|||
$newlist = array_values(array_filter($list, fn ($item) => $item->deleted == 0)); |
|||
foreach ($nostandardArr as $idx => &$item) { |
|||
if ($item['origin'] === 1) { |
|||
if (strip_tags($item['text']) != strip_tags($standardArr[$item['id']]['text'])) { |
|||
$item['updated'] = 1; |
|||
} else { |
|||
$item['updated'] = 0; |
|||
} |
|||
} |
|||
} |
|||
unset($item); |
|||
if (strip_tags($illustrate) != strip_tags($standardIllustrate)) { |
|||
$updatedIllustrate = true; |
|||
} |
|||
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $partyAcontractno); |
|||
$stmt->execute(); |
|||
$customer = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
if (count($customer) <= 0) { |
|||
echo "<script> |
|||
alert('資料不齊或合約書已生成過。'); |
|||
window.history.back(); |
|||
</script>"; |
|||
} |
|||
$sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contract_id', $contract_id); |
|||
$stmt->execute(); |
|||
$files = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
function numberToChinese($num) |
|||
{ |
|||
$chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']; |
|||
$units = ['', '十', '百', '千', '万']; |
|||
|
|||
if ($num <= 10) { |
|||
return $chineseNumbers[$num]; |
|||
} elseif ($num < 20) { |
|||
return $units[1] . $chineseNumbers[$num % 10]; |
|||
} elseif ($num < 100) { |
|||
return $chineseNumbers[intval($num / 10)] . $units[1] . ($num % 10 > 0 ? $chineseNumbers[$num % 10] : ''); |
|||
} else { |
|||
// 處理大於 99 的数字 |
|||
$result = ''; |
|||
$strNum = strval($num); |
|||
$length = strlen($strNum); |
|||
for ($i = 0; $i < $length; $i++) { |
|||
$currentDigit = intval($strNum[$i]); |
|||
if ($currentDigit > 0) { |
|||
$result .= $chineseNumbers[$currentDigit] . $units[$length - $i - 1]; |
|||
} else { |
|||
$result .= $chineseNumbers[$currentDigit]; |
|||
} |
|||
} |
|||
return $result; |
|||
} |
|||
} |
|||
function removeTrailingBr($string) |
|||
{ |
|||
//刪除字串尾巴的<br>或<br /> |
|||
return preg_replace('/(<br\s*\/?>)+$/', '', $string); |
|||
} |
|||
|
|||
?> |
|||
|
|||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.3/purify.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.3.3/html2canvas.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js" integrity="sha512-E8QSvWZ0eCLGk4km3hxSsNmGWbLtSCSUcewDQPQWZF6pEU8GlT8a5fF32wOl1i8ftdMhssTrF/OhyGWwonTcXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
|||
<style> |
|||
.container { |
|||
background-color: transparent !important; |
|||
width: 100% !important; |
|||
} |
|||
|
|||
.prview, |
|||
.footer { |
|||
width: 800px; |
|||
border: 1px #ccc solid; |
|||
padding: 20px; |
|||
font-family: '標楷體'; |
|||
} |
|||
|
|||
.prview.none { |
|||
display: none; |
|||
} |
|||
|
|||
.prview h2 { |
|||
font-size: 18pt; |
|||
text-align: center; |
|||
} |
|||
|
|||
.prview p { |
|||
font-size: 12pt; |
|||
margin: 0; |
|||
padding: 0; |
|||
} |
|||
|
|||
td tr table th { |
|||
border: none !important; |
|||
background-color: #fff !important; |
|||
} |
|||
|
|||
tr:nth-child(even) { |
|||
background-color: #fff !important; |
|||
} |
|||
|
|||
.colorDiv { |
|||
display: flex; |
|||
margin: 10px 0; |
|||
} |
|||
|
|||
.colorDiv .block { |
|||
width: 18px; |
|||
height: 18px; |
|||
} |
|||
|
|||
.colorDiv span { |
|||
font-size: 15px; |
|||
margin: 0 5px 0 2px; |
|||
font-weight: 600; |
|||
} |
|||
|
|||
.colorDiv .block.gray { |
|||
background-color: #DDDDDD; |
|||
} |
|||
|
|||
.colorDiv .block.green { |
|||
background-color: #00B900; |
|||
} |
|||
|
|||
.colorDiv .block.red { |
|||
background-color: #D11919; |
|||
} |
|||
|
|||
#btn, |
|||
.pre { |
|||
background-color: #0D559D; |
|||
color: #fff; |
|||
outline: none; |
|||
border: none; |
|||
border: 1px #ccc solid; |
|||
width: 100px; |
|||
height: 32px; |
|||
font-weight: 600; |
|||
border-radius: 6px; |
|||
margin-right: 5px; |
|||
} |
|||
|
|||
.pre { |
|||
background-color: #40C474; |
|||
} |
|||
</style> |
|||
|
|||
<div class="container" x-data="{ |
|||
css:'', |
|||
random:'', |
|||
init(){ |
|||
|
|||
const characters = '012345678901234567890123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
|||
const charactersLength = characters.length; |
|||
let randomString = ''; |
|||
const length = 15; |
|||
|
|||
for (let i = 0; i < length; i++) { |
|||
const randomIndex = Math.floor(Math.random() * charactersLength); |
|||
randomString += characters.charAt(randomIndex); |
|||
} |
|||
this.random = randomString; |
|||
console.log(files); |
|||
}, |
|||
exportFn(){ |
|||
|
|||
const now = new Date(); |
|||
|
|||
// 獲取年、月、日、小時、分鐘、秒 |
|||
const year = now.getFullYear(); |
|||
const month = now.getMonth() + 1; // 月份是從0開始的,所以要加1 |
|||
const day = now.getDate(); |
|||
const hours = now.getHours(); |
|||
const minutes = now.getMinutes(); |
|||
const seconds = now.getSeconds(); |
|||
// 格式化日期和時間 |
|||
const formattedDate = `${year}${month}${day}${hours}${minutes}${seconds}`; |
|||
|
|||
let token = formattedDate + '<?php echo $partyAcontractno; ?><?php echo $partyA; ?>永佳捷<?php echo $total_price; ?>' |
|||
let newtoken = formattedDate + '-' + CryptoJS.MD5(CryptoJS.SHA256(CryptoJS.SHA256(CryptoJS.MD5(token).toString()).toString() + this.random).toString()).toString() |
|||
console.log(newtoken); |
|||
let html = this.$refs.prview.innerHTML |
|||
let footer = this.$refs.footer.innerHTML |
|||
let affix1 = this.$refs.affix1.innerHTML |
|||
// html = this.$refs.footer.innerHTML |
|||
// axios.post('./export-pdf.php', {'html':html}).then(res=>{ |
|||
// console.log(res); |
|||
// }) |
|||
const form = new FormData(); |
|||
form.append('html', html); |
|||
form.append('footer', footer); |
|||
form.append('affix1', affix1); |
|||
form.append('css',this.css); |
|||
form.append('user_name', '<?php echo $user_name; ?>'); |
|||
form.append('contract_no', '<?php echo $partyAcontractno; ?>'); |
|||
form.append('party_a', '<?php echo $partyA; ?>'); |
|||
form.append('total_price', '<?php echo $total_price; ?>'); |
|||
form.append('person', '<?php echo $person; ?>'); |
|||
form.append('token', newtoken); |
|||
form.append('formattedDate', formattedDate); |
|||
axiosClient({ |
|||
method:'post', |
|||
responseType:'blob', |
|||
url:'./export-pdf.php', |
|||
data:form |
|||
}).then(response=>{ |
|||
const url = window.URL.createObjectURL(new Blob([response.data])); |
|||
const link = document.createElement('a'); |
|||
link.href = url; |
|||
link.setAttribute('download', formattedDate + '.pdf'); // 指定下载的文件名 |
|||
document.body.appendChild(link); |
|||
link.click(); |
|||
document.body.removeChild(link); |
|||
this.store(newtoken, formattedDate) |
|||
|
|||
for(let i=0;i<files.length;i++){ |
|||
let filename = document.createElement('a'); |
|||
filename.href = './images/contracts_new_files/' + files[i].file_name; |
|||
filename.setAttribute('download', filename.href); // 指定下载的文件名 |
|||
document.body.appendChild(filename); |
|||
filename.click(); |
|||
document.body.removeChild(filename); |
|||
} |
|||
|
|||
}) |
|||
}, |
|||
store(newtoken, formattedDate){ |
|||
const form = new FormData(); |
|||
form.append('contract_id', '<?php echo $partyAcontractno; ?>') |
|||
form.append('uscc', '<?php echo $customer['uscc']; ?>') |
|||
form.append('ekind', '新梯') |
|||
form.append('new_elevator', '<?php $_POST['prviewType'] == '1' ? "買賣" : "安裝"; ?>') |
|||
form.append('party_a', '<?php echo $partyA; ?>') |
|||
form.append('total_price', <?php echo (int)$total_price; ?>) |
|||
form.append('accound_id', '<?php echo $personid; ?>') |
|||
form.append('times', 1) |
|||
form.append('random', this.random) |
|||
form.append('hash', newtoken) |
|||
form.append('url', formattedDate+'.pdf' ); |
|||
form.append('created_by', '<?php echo $user_id; ?>') |
|||
form.append('delivery_term', '<?php echo $delivery_term; ?>') |
|||
form.append('install_period', '<?php echo $install_period; ?>') |
|||
form.append('free_maintainance', '<?php echo $free_maintainance; ?>') |
|||
axiosClient({ |
|||
method:'post', |
|||
url:'./store-contract.php', |
|||
data:form |
|||
}).then(res=>{ |
|||
console.log(res); |
|||
}) |
|||
}, |
|||
}"> |
|||
|
|||
|
|||
<button @click="history.go(-1)" class="pre">回前頁</button> |
|||
<button id="btn" @click="exportFn()">點我下載</button> |
|||
<?php if ($isStand == 0) { ?> |
|||
<div class="colorDiv"> |
|||
<div class="block gray"></div> |
|||
<span>修改的條列</span> |
|||
<div class="block green"></div> |
|||
<span>新增的條列</span> |
|||
<div class="block red"></div> |
|||
<span>刪除的條列</span> |
|||
</div> |
|||
<?php } ?> |
|||
<div class="prview" id="prview" x-ref="prview" style="font-family:'標楷體'" x-show="false"> |
|||
<h2 style="text-align:center;font-size:18pt;"><?php echo $type; ?></h2> |
|||
<p style="font-size: 12pt;">合約書編號:<?php echo $_POST['partyAcontractno'] ?></p> |
|||
<table> |
|||
<tr> |
|||
<td style="width:100px"></td> |
|||
<td style="width:200px"><?php echo $_POST['partyA'] ?></td> |
|||
<td>(即買方,以下簡稱為甲方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;">立合約書人</p> |
|||
<table> |
|||
<tr> |
|||
<td style="width:100px"></td> |
|||
<td style="width:200px">永佳捷科技股份有限公司</td> |
|||
<td>(即賣方,以下簡稱為乙方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;width:440px"><?php echo $illustrate; ?></p> |
|||
<table style="width:100%"> |
|||
<?php foreach ($newlist as $idx => $item) { |
|||
?> |
|||
<tr style="display:block;"> |
|||
<td style="width:60px;">第<?php echo numberToChinese($idx + 1); ?>條</td> |
|||
<td style="width:445px;"><?php echo nl2br(removeTrailingBr(json_decode(json_encode($item), true)['text'])); ?></td> |
|||
</tr> |
|||
<?php } ?> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<section style="display:flex;justify-content:center;"> |
|||
<div class="prview" style="font-family:'標楷體';background-color:#fff;"> |
|||
<h2 style="text-align:center;font-size:18pt;"><?php echo $type; ?></h2> |
|||
<p style="font-size: 12pt;">合約書編號:<?php echo $_POST['partyAcontractno'] ?></p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px;"></td> |
|||
<td style="border:none;width:200px"><?php echo $_POST['partyA'] ?></td> |
|||
<td style="border:none">(即買方,以下簡稱為甲方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;">立合約書人</p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px"></td> |
|||
<td style="border:none;width:200px">永佳捷科技股份有限公司</td> |
|||
<td style="border:none">(即賣方,以下簡稱為乙方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;width:800px"><?php echo $standardIllustrate; ?></p> |
|||
<table style="width:100%;border:none"> |
|||
<?php foreach ($standardList as $idx => $item) { |
|||
?> |
|||
<tr style="margin-bottom:10px;display:block;border:none"> |
|||
<td style="width:100px;border:none">第<?php echo numberToChinese($idx + 1); ?>條</td> |
|||
<td style="border:none"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
</tr> |
|||
<?php } ?> |
|||
</table> |
|||
</div> |
|||
<?php if ($isStand == 0) { ?> |
|||
<div class="prview nostandard" style="font-family:'標楷體'" x-ref="nostandard"> |
|||
<h2 style="text-align:center;font-size:18pt;"><?php echo $type; ?></h2> |
|||
<p style="font-size: 12pt;">合約書編號:<?php echo $_POST['partyAcontractno'] ?></p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px;"></td> |
|||
<td style="border:none;width:200px"><?php echo $_POST['partyA'] ?></td> |
|||
<td style="border:none">(即買方,以下簡稱為甲方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;">立合約書人</p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px"></td> |
|||
<td style="border:none;width:200px">永佳捷科技股份有限公司</td> |
|||
<td style="border:none">(即賣方,以下簡稱為乙方)</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
<p style="font-size: 12pt;width:800px;<?php if ($updatedIllustrate) { |
|||
echo 'background-color:#ddd'; |
|||
} ?>"><?php echo $illustrate; ?></p> |
|||
<table style="width:100%;border:none"> |
|||
<?php foreach ($nostandardArr as $idx => $item) { |
|||
?> |
|||
|
|||
<tr style="margin-bottom:10px;display:block;border:none"> |
|||
<td style="width:100px;border:none">第<?php echo numberToChinese($idx + 1); ?>條</td> |
|||
<?php if ($item['updated'] == 1) { ?> |
|||
<td style="border:none;background-color:#ddd;"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
<?php } elseif ($item['deleted'] == 1) { ?> |
|||
<td style="border:none;background-color:#D11919;text-decoration:line-through"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
<?php } elseif ($item['id'] > 15) { ?> |
|||
<td style="border:none;background-color:#00B900;"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
<?php } else { ?> |
|||
<td style="border:none"><?php echo nl2br(removeTrailingBr(json_decode(json_encode($item), true)['text'])); ?></td> |
|||
<?php } ?> |
|||
</tr> |
|||
<?php } ?> |
|||
</table> |
|||
</div> |
|||
<?php } ?> |
|||
</section> |
|||
<div class="footer" x-ref="footer" x-show="false"> |
|||
<br /> |
|||
<p> 立合約書人:</p> |
|||
<table> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none">甲</td> |
|||
<td style="width:30px;border:none;text-align:right">方</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> <?php echo $_POST['partyA']; ?></td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:20px;border:none;">代</td> |
|||
<td style="width:20px;border:none;text-align:center">表</td> |
|||
<td style="width:20px;border:none;text-align:right">人</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
<td style="border:none"> <?php echo $customer['manager']; ?></td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:15px;border:none;">統</td> |
|||
<td style="width:15px;border:none;text-align:center">一</td> |
|||
<td style="width:15px;border:none;text-align:center">編</td> |
|||
<td style="width:15px;border:none;text-align:right">號</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
<td style="border:none"> <?php echo $customer['uscc']; ?></td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none;">地</td> |
|||
<td style="width:30px;border:none;text-align:right">址</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
<td style="border:none"> <?php echo $customer['address']; ?></td> |
|||
</tr> |
|||
</table> |
|||
<p style="line-height:0.1"> </p> |
|||
<table> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none">乙</td> |
|||
<td style="width:30px;border:none;text-align:right">方</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 永佳捷科技股份有限公司</td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:20px;border:none;">總</td> |
|||
<td style="width:20px;border:none;text-align:center">經</td> |
|||
<td style="width:20px;border:none;text-align:right">理</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 蔡定憲</td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:15px;border:none;">統</td> |
|||
<td style="width:15px;border:none;text-align:center">一</td> |
|||
<td style="width:15px;border:none;text-align:center">編</td> |
|||
<td style="width:15px;border:none;text-align:right">號</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 90493119</td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none;">地</td> |
|||
<td style="width:30px;border:none;text-align:right">址</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 臺北市中山區敬業一路128巷39號3樓之1</td> |
|||
</tr> |
|||
</table> |
|||
<p> </p> |
|||
<!-- <table> |
|||
<tr> |
|||
<td style="width:200px;border:none;text-align:justify">中華民國</td> |
|||
<td style="width:100px;border:none;text-align:right">年</td> |
|||
<td style="width:100px;border:none;text-align:right">月</td> |
|||
<td style="width:100px;border:none;text-align:right">日</td> |
|||
</tr> |
|||
</table> --> |
|||
</div> |
|||
<div class="affix1" x-ref="affix1" x-show="false"> |
|||
<h1 style="text-align:center">升降設備除外工程表</h1> |
|||
<table> |
|||
<tr> |
|||
<td style="width:40px">一、</td> |
|||
<td>機械室之建造,含預留出入口、通風照明、自動閉鎖裝置,及天花板上之保養用吊鉤。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">二、</td> |
|||
<td style="width:460px">通往機械室之樓梯及加護欄杆工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">三、</td> |
|||
<td style="width:460px">機械室基礎台需用防濕之瀝青鐵筋混凝土及地板防塵工事。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">四、</td> |
|||
<td style="width:460px">機械室及升降路中間之橫樑或工字樑之安裝工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">五、</td> |
|||
<td style="width:460px">自屋外至機械室之動力及照明用配線電源開關插座,及接地線等電路工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">六、</td> |
|||
<td style="width:460px">升降路及機械室以外監視盤、電鈴、電話之配管與配線工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">七、</td> |
|||
<td style="width:460px">升降路之建造及底部之防水工程及緩衝器水泥台工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">八、</td> |
|||
<td style="width:460px">機坑照明保養用之開關及插座,鐵爬梯。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">九、</td> |
|||
<td style="width:460px">各樓按鈕開關之留洞工程及安裝後之固定與週邊裝飾工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十、</td> |
|||
<td style="width:460px">升降路內甲方不得裝設有任何與升降設備無關之配線、電線配管、水管、風管等設備。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十一、</td> |
|||
<td style="width:460px">安裝所需水泥、砂石、水電與供試車用動力電源。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十二、</td> |
|||
<td style="width:460px">升降路及機房之建造,電源設備之容量及位置等,需符合國家標準(CNS-2866)及建築法規等規定。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十三、</td> |
|||
<td style="width:460px">機械運抵工地後供給儲存倉庫。</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="2">備註:CNS-2866國家標準建築物電梯有關之法規: </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">1.</td> |
|||
<td style="width:475px">機械室內應設有照明及通風設備,以利管理檢查,照明應在100LUX(米一燭光)以上,通風設備應能使室內溫度保持在攝氏40度以下。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">2.</td> |
|||
<td style="width:475px">機械室之出入口應加鎖,其裝置應良好。 </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">3.</td> |
|||
<td style="width:475px">由機械室至走廊,樓梯間應便於通行,樓梯應加裝扶手,其與水平面之傾斜角度,應不超過60度。 </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">4.</td> |
|||
<td style="width:475px">機械室出入門之構造,應有下述裝置: <br> |
|||
A:能自動關閉者。 <br> |
|||
B:有彈簧鎖或其類似裝置,以便室內不用鎖匙,而能開門。 <br> |
|||
C:除屋頂開口部份以外,機械式牆壁,應能耐火。(二小時防火時效) |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">5.</td> |
|||
<td style="width:475px">升降路內不得設置與升降機無關之配管及配線。 </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">6.</td> |
|||
<td style="width:475px">任一升降路下部之任何部份,供人使用或類似使用時配重側比照車廂,同樣必須裝設緊急安全裝置。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">7.</td> |
|||
<td style="width:475px">若有火警受信總機時,甲方需提供"火警受信總機"檢出信號及通往升降道內之配管配線(0.75MM² × 3) </td> |
|||
</tr> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<script> |
|||
const files = <?php echo json_encode($files); ?>; |
|||
const axiosClient = axios.create({ |
|||
baseURL: ``, |
|||
}); |
|||
|
|||
|
|||
axiosClient.interceptors.request.use((config) => { |
|||
config.headers.Authorization = `Bearer ${123}` |
|||
return config; |
|||
}, (error) => { |
|||
return Promise.reject(error); |
|||
}); |
|||
|
|||
axiosClient.interceptors.response.use((response) => { |
|||
return response; |
|||
}, (error) => { |
|||
if (error.response.status === 401) {} |
|||
throw error; |
|||
}); |
|||
|
|||
|
|||
const btn = document.getElementById('btn') |
|||
console.log(<?php echo $contract_id; ?>); |
|||
</script> |
|||
<?php |
|||
} else { |
|||
echo "<script>alert('非法訪問!');window.history.back();</script>"; |
|||
} |
|||
?> |
@ -0,0 +1,5 @@ |
|||
last 2 versions |
|||
> 1% |
|||
opera 12.1 |
|||
bb 10 |
|||
android 4 |
@ -0,0 +1,322 @@ |
|||
{ |
|||
"remove-empty-rulesets": true, |
|||
"always-semicolon": true, |
|||
"color-case": "upper", |
|||
"block-indent": " ", |
|||
"color-shorthand": false, |
|||
"element-case": "lower", |
|||
"leading-zero": true, |
|||
"space-after-colon": " ", |
|||
"space-before-combinator": " ", |
|||
"space-after-combinator": " ", |
|||
"space-between-declarations": "\n", |
|||
"space-before-opening-brace": " ", |
|||
"space-after-opening-brace": "\n", |
|||
"space-after-selector-delimiter": "\n", |
|||
"space-before-selector-delimiter": "", |
|||
"space-before-closing-brace": "\n", |
|||
"strip-spaces": true, |
|||
"tab-size": true, |
|||
"vendor-prefix-align": true, |
|||
"sort-order": [ |
|||
[ |
|||
"display", |
|||
"visibility", |
|||
"float", |
|||
"clear", |
|||
"overflow", |
|||
"overflow-x", |
|||
"overflow-y", |
|||
"-webkit-box-sizing", |
|||
"-moz-box-sizing", |
|||
"box-sizing", |
|||
"-ms-overflow-x", |
|||
"-ms-overflow-y", |
|||
"clip", |
|||
"zoom", |
|||
"flex-direction", |
|||
"flex-order", |
|||
"flex-pack", |
|||
"flex-align" |
|||
], |
|||
[ |
|||
"position", |
|||
"z-index", |
|||
"top", |
|||
"right", |
|||
"bottom", |
|||
"left" |
|||
], |
|||
[ |
|||
"font", |
|||
"font-family", |
|||
"font-size", |
|||
"font-weight", |
|||
"font-style", |
|||
"font-variant", |
|||
"font-size-adjust", |
|||
"font-stretch", |
|||
"font-effect", |
|||
"font-emphasize", |
|||
"font-emphasize-position", |
|||
"font-emphasize-style", |
|||
"font-smooth", |
|||
"line-height" |
|||
], |
|||
[ |
|||
"width", |
|||
"min-width", |
|||
"max-width", |
|||
"height", |
|||
"min-height", |
|||
"max-height", |
|||
"margin", |
|||
"margin-top", |
|||
"margin-right", |
|||
"margin-bottom", |
|||
"margin-left", |
|||
"padding", |
|||
"padding-top", |
|||
"padding-right", |
|||
"padding-bottom", |
|||
"padding-left" |
|||
], |
|||
[ |
|||
"table-layout", |
|||
"empty-cells", |
|||
"caption-side", |
|||
"border-spacing", |
|||
"border-collapse", |
|||
"list-style", |
|||
"list-style-position", |
|||
"list-style-type", |
|||
"list-style-image" |
|||
], |
|||
[ |
|||
"opacity", |
|||
"filter:progid:DXImageTransform.Microsoft.Alpha(Opacity", |
|||
"-ms-filter:\\'progid:DXImageTransform.Microsoft.Alpha", |
|||
"-ms-interpolation-mode", |
|||
"color", |
|||
"border", |
|||
"border-width", |
|||
"border-style", |
|||
"border-color", |
|||
"border-top", |
|||
"border-top-width", |
|||
"border-top-style", |
|||
"border-top-color", |
|||
"border-right", |
|||
"border-right-width", |
|||
"border-right-style", |
|||
"border-right-color", |
|||
"border-bottom", |
|||
"border-bottom-width", |
|||
"border-bottom-style", |
|||
"border-bottom-color", |
|||
"border-left", |
|||
"border-left-width", |
|||
"border-left-style", |
|||
"border-left-color", |
|||
"-webkit-border-radius", |
|||
"-moz-border-radius", |
|||
"border-radius", |
|||
"-webkit-border-top-left-radius", |
|||
"-moz-border-radius-topleft", |
|||
"border-top-left-radius", |
|||
"-webkit-border-top-right-radius", |
|||
"-moz-border-radius-topright", |
|||
"border-top-right-radius", |
|||
"-webkit-border-bottom-right-radius", |
|||
"-moz-border-radius-bottomright", |
|||
"border-bottom-right-radius", |
|||
"-webkit-border-bottom-left-radius", |
|||
"-moz-border-radius-bottomleft", |
|||
"border-bottom-left-radius", |
|||
"-webkit-border-image", |
|||
"-moz-border-image", |
|||
"-o-border-image", |
|||
"border-image", |
|||
"-webkit-border-image-source", |
|||
"-moz-border-image-source", |
|||
"-o-border-image-source", |
|||
"border-image-source", |
|||
"-webkit-border-image-slice", |
|||
"-moz-border-image-slice", |
|||
"-o-border-image-slice", |
|||
"border-image-slice", |
|||
"-webkit-border-image-width", |
|||
"-moz-border-image-width", |
|||
"-o-border-image-width", |
|||
"border-image-width", |
|||
"-webkit-border-image-outset", |
|||
"-moz-border-image-outset", |
|||
"-o-border-image-outset", |
|||
"border-image-outset", |
|||
"-webkit-border-image-repeat", |
|||
"-moz-border-image-repeat", |
|||
"-o-border-image-repeat", |
|||
"border-image-repeat", |
|||
"outline", |
|||
"outline-width", |
|||
"outline-style", |
|||
"outline-color", |
|||
"outline-offset", |
|||
"background", |
|||
"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader", |
|||
"background-color", |
|||
"background-image", |
|||
"background-repeat", |
|||
"background-attachment", |
|||
"background-position", |
|||
"background-position-x", |
|||
"-ms-background-position-x", |
|||
"background-position-y", |
|||
"-ms-background-position-y", |
|||
"-webkit-background-clip", |
|||
"-moz-background-clip", |
|||
"background-clip", |
|||
"background-origin", |
|||
"-webkit-background-size", |
|||
"-moz-background-size", |
|||
"-o-background-size", |
|||
"background-size", |
|||
"box-decoration-break", |
|||
"-webkit-box-shadow", |
|||
"-moz-box-shadow", |
|||
"box-shadow", |
|||
"filter:progid:DXImageTransform.Microsoft.gradient", |
|||
"-ms-filter:\\'progid:DXImageTransform.Microsoft.gradient", |
|||
"text-shadow" |
|||
], |
|||
|
|||
[ |
|||
"content", |
|||
"quotes", |
|||
"counter-reset", |
|||
"counter-increment", |
|||
"resize", |
|||
"cursor", |
|||
"-webkit-user-select", |
|||
"-moz-user-select", |
|||
"-ms-user-select", |
|||
"user-select", |
|||
"nav-index", |
|||
"nav-up", |
|||
"nav-right", |
|||
"nav-down", |
|||
"nav-left", |
|||
"-webkit-transition", |
|||
"-moz-transition", |
|||
"-ms-transition", |
|||
"-o-transition", |
|||
"transition", |
|||
"-webkit-transition-delay", |
|||
"-moz-transition-delay", |
|||
"-ms-transition-delay", |
|||
"-o-transition-delay", |
|||
"transition-delay", |
|||
"-webkit-transition-timing-function", |
|||
"-moz-transition-timing-function", |
|||
"-ms-transition-timing-function", |
|||
"-o-transition-timing-function", |
|||
"transition-timing-function", |
|||
"-webkit-transition-duration", |
|||
"-moz-transition-duration", |
|||
"-ms-transition-duration", |
|||
"-o-transition-duration", |
|||
"transition-duration", |
|||
"-webkit-transition-property", |
|||
"-moz-transition-property", |
|||
"-ms-transition-property", |
|||
"-o-transition-property", |
|||
"transition-property", |
|||
"-webkit-transform", |
|||
"-moz-transform", |
|||
"-ms-transform", |
|||
"-o-transform", |
|||
"transform", |
|||
"-webkit-transform-origin", |
|||
"-moz-transform-origin", |
|||
"-ms-transform-origin", |
|||
"-o-transform-origin", |
|||
"transform-origin", |
|||
"-webkit-animation", |
|||
"-moz-animation", |
|||
"-ms-animation", |
|||
"-o-animation", |
|||
"animation", |
|||
"-webkit-animation-name", |
|||
"-moz-animation-name", |
|||
"-ms-animation-name", |
|||
"-o-animation-name", |
|||
"animation-name", |
|||
"-webkit-animation-duration", |
|||
"-moz-animation-duration", |
|||
"-ms-animation-duration", |
|||
"-o-animation-duration", |
|||
"animation-duration", |
|||
"-webkit-animation-play-state", |
|||
"-moz-animation-play-state", |
|||
"-ms-animation-play-state", |
|||
"-o-animation-play-state", |
|||
"animation-play-state", |
|||
"-webkit-animation-timing-function", |
|||
"-moz-animation-timing-function", |
|||
"-ms-animation-timing-function", |
|||
"-o-animation-timing-function", |
|||
"animation-timing-function", |
|||
"-webkit-animation-delay", |
|||
"-moz-animation-delay", |
|||
"-ms-animation-delay", |
|||
"-o-animation-delay", |
|||
"animation-delay", |
|||
"-webkit-animation-iteration-count", |
|||
"-moz-animation-iteration-count", |
|||
"-ms-animation-iteration-count", |
|||
"-o-animation-iteration-count", |
|||
"animation-iteration-count", |
|||
"-webkit-animation-direction", |
|||
"-moz-animation-direction", |
|||
"-ms-animation-direction", |
|||
"-o-animation-direction", |
|||
"animation-direction", |
|||
"text-align", |
|||
"-webkit-text-align-last", |
|||
"-moz-text-align-last", |
|||
"-ms-text-align-last", |
|||
"text-align-last", |
|||
"vertical-align", |
|||
"white-space", |
|||
"text-decoration", |
|||
"text-emphasis", |
|||
"text-emphasis-color", |
|||
"text-emphasis-style", |
|||
"text-emphasis-position", |
|||
"text-indent", |
|||
"-ms-text-justify", |
|||
"text-justify", |
|||
"letter-spacing", |
|||
"word-spacing", |
|||
"-ms-writing-mode", |
|||
"text-outline", |
|||
"text-transform", |
|||
"text-wrap", |
|||
"text-overflow", |
|||
"-ms-text-overflow", |
|||
"text-overflow-ellipsis", |
|||
"text-overflow-mode", |
|||
"-ms-word-wrap", |
|||
"word-wrap", |
|||
"word-break", |
|||
"-ms-word-break", |
|||
"-moz-tab-size", |
|||
"-o-tab-size", |
|||
"tab-size", |
|||
"-webkit-hyphens", |
|||
"-moz-hyphens", |
|||
"hyphens", |
|||
"pointer-events" |
|||
] |
|||
] |
|||
} |
@ -0,0 +1,18 @@ |
|||
{ |
|||
"vendor-prefix" : true, |
|||
"duplicate-properties" : true, |
|||
"display-property-grouping" : true, |
|||
"empty-rules" : true, |
|||
|
|||
"adjoining-classes" : false, |
|||
"box-model" : false, |
|||
"compatible-vendor-prefixes" : false, |
|||
"box-sizing" : false, |
|||
"duplicate-background-images" : false, |
|||
"floats" : false, |
|||
"important" : false, |
|||
"overqualified-elements" : false, |
|||
"rules-count" : false, |
|||
"shorthand" : false, |
|||
"zero-units" : false |
|||
} |
@ -0,0 +1,24 @@ |
|||
✖ USAGE QUESTIONS → Use these dedicated resources: |
|||
Docs - http://www.semantic-ui.com |
|||
Chat - https://gitter.im/Semantic-Org/Semantic-UI |
|||
SO - https://stackoverflow.com/questions/tagged/semantic-ui?sort=votes |
|||
|
|||
✔ Enhancements → Be specific. Assume backwards compatibility is a necessity. Suggest implementation when possible. |
|||
✔ BUGS → ❤❤❤. Keep in mind some bugs may not be immediately fixable due to backwards compatibility or CSS limitations. |
|||
|
|||
### Title (Put in field above) |
|||
Use the format: [Component] Component Should Do X |
|||
i.e. [Checkbox] onChange Should Fire When Update Triggered via DOM |
|||
|
|||
### Steps |
|||
|
|||
### Expected Result |
|||
|
|||
### Actual Result |
|||
|
|||
### Version |
|||
x.y.z |
|||
|
|||
### Testcase |
|||
[Fork, update, and replace to show the bug]: |
|||
https://jsfiddle.net/ca0rovs3/ |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue