Browse Source

header

main
Cheng 2 years ago
parent
commit
75a7bf5a5d
  1. 206
      wms/IncludeCommon.php
  2. 180
      wms/T8_APItest.php
  3. 99
      wms/T8_APItest_from_bpm.php
  4. 72
      wms/T8_Authorization.php
  5. 43
      wms/T8_Authorization_from_bpm.php
  6. 140
      wms/T8_assemble_apply.php
  7. 46
      wms/T8_purBillOrder_search.php
  8. 88
      wms/T8_purRequestOrder_create.php
  9. 360
      wms/account-create.php
  10. 36
      wms/account-delete.php
  11. 346
      wms/account-edit.php
  12. 170
      wms/account-index-submit.php
  13. 371
      wms/account-index.php
  14. 452
      wms/account-receivable-check.php
  15. 76
      wms/account-receivable-contract.php
  16. 51
      wms/account-receivable-excel.php
  17. 746
      wms/account-receivable-index.php
  18. 243
      wms/account-receivable-received-create.php
  19. 261
      wms/account-receivable-received-edit.php
  20. 180
      wms/account-receivable-received-submit.php
  21. BIN
      wms/account-receivable.xlsx
  22. 148
      wms/account-record-submit.php
  23. 130
      wms/account-record-update.php
  24. 130
      wms/account-user-input.php
  25. 354
      wms/account_auth-create.php
  26. 364
      wms/account_auth-edit.php
  27. 209
      wms/account_auth-index.php
  28. 128
      wms/account_auth-record-update.php
  29. 624
      wms/bargain-create.php
  30. 56
      wms/bargain-delete.php
  31. 748
      wms/bargain-edit.php
  32. 286
      wms/bargain-index.php
  33. 296
      wms/bargain-record-submit.php
  34. 286
      wms/bargain-record-update.php
  35. 129
      wms/board-create.php
  36. 44
      wms/board-delete.php
  37. 118
      wms/board-edit.php
  38. 36
      wms/board-file.php
  39. 307
      wms/board-index.php
  40. 103
      wms/board-record-submit.php
  41. 102
      wms/board-record-update.php
  42. 94
      wms/change-password-update.php
  43. 152
      wms/change-password.php
  44. 172
      wms/combo-create.php
  45. 22
      wms/combo-delete.php
  46. 186
      wms/combo-edit.php
  47. 278
      wms/combo-index.php
  48. 84
      wms/combo-record-submit.php
  49. 80
      wms/combo-record-update.php
  50. 108
      wms/combo-user-input.php
  51. 252
      wms/contract-create.php
  52. 22
      wms/contract-delete.php
  53. 284
      wms/contract-edit.php
  54. 324
      wms/contract-index.php
  55. 122
      wms/contract-record-submit.php
  56. 98
      wms/contract-record-update.php
  57. 126
      wms/contract-user-input.php
  58. 452
      wms/custom-create-contract.php
  59. 544
      wms/custom-create-facility.php
  60. 460
      wms/custom-create-schedule.php
  61. 766
      wms/custom-create.php
  62. 222
      wms/data_collection_merge_export_submit.php
  63. 84
      wms/database.php
  64. 184
      wms/delivery_info-create.php
  65. 22
      wms/delivery_info-delete.php
  66. 208
      wms/delivery_info-edit.php
  67. 292
      wms/delivery_info-index.php
  68. 98
      wms/delivery_info-record-submit.php
  69. 86
      wms/delivery_info-record-update.php
  70. 116
      wms/delivery_info-user-input.php
  71. 132
      wms/delivery_log-create.php
  72. 22
      wms/delivery_log-delete.php
  73. 150
      wms/delivery_log-edit.php
  74. 272
      wms/delivery_log-index.php
  75. 76
      wms/delivery_log-record-submit.php
  76. 74
      wms/delivery_log-record-update.php
  77. 106
      wms/delivery_log-user-input.php
  78. 8
      wms/demo.dart
  79. 376
      wms/ec_purchase_order_submit.php
  80. 200
      wms/equipment-create.php
  81. 22
      wms/equipment-delete.php
  82. 226
      wms/equipment-edit.php
  83. 300
      wms/equipment-index.php
  84. 244
      wms/equipment-record-submit.php
  85. 158
      wms/equipment-record-update.php
  86. 114
      wms/equipment-user-input.php
  87. 2676
      wms/estimated_shipping_date_report.php
  88. 488
      wms/excel-upload.php
  89. 262
      wms/expert-create.php
  90. 22
      wms/expert-delete.php
  91. 252
      wms/expert-edit.php
  92. 308
      wms/expert-index.php
  93. 272
      wms/expert-record-submit.php
  94. 168
      wms/expert-record-update.php
  95. 118
      wms/expert-user-input.php
  96. 252
      wms/facility-create.php
  97. 22
      wms/facility-delete.php
  98. 306
      wms/facility-edit.php
  99. 230
      wms/facility-excel-upload.php
  100. 320
      wms/facility-index.php

206
wms/IncludeCommon.php

@ -1,67 +1,65 @@
<?php <?php
class IncludeCommon class IncludeCommon
{ {
function CheckToken($token) function CheckToken($token) {
{ date_default_timezone_set("Asia/Taipei");
date_default_timezone_set("Asia/Taipei"); $encryption_code = "MASADA!^***";
$encryption_code = "MASADA!^***"; $time = date("Y-m-d H:i:s");
$time = date("Y-m-d H:i:s");
if (!isset($token) || empty($token)) {
if (!isset($token) || empty($token)) { $data['code'] = '400';
$data['code'] = '400'; $data['message'] = '非法请求';
$data['message'] = '非法请求'; return $data;
return $data; }
} //对比token
//对比token $explode = explode('.', $token); //以.分割token为数组
$explode = explode('.', $token); //以.分割token为数组 if (!empty($explode[0]) && !empty($explode[1]) && !empty($explode[2]) && !empty($explode[3]) && !empty($explode[4])) {
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]; //信息部分
$info = $explode[0] . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; //信息部分 $true_signature = hash_hmac('md5', $info, $encryption_code); //正确的签名
$true_signature = hash_hmac('md5', $info, $encryption_code); //正确的签名 if ($time > $explode[3]) {
if ($time > $explode[3]) { $data['user_id'] = '';
$data['user_id'] = ''; $data['code'] = '401';
$data['code'] = '401'; $data['message'] = 'Token已过期,请重新登录';
$data['message'] = 'Token已过期,请重新登录'; return $data;
return $data; }
} if (($true_signature == $explode[4])) {
if (($true_signature == $explode[4])) { $data['user_id'] = $explode[0];
$data['user_id'] = $explode[0]; $data['code'] = '200';
$data['code'] = '200'; $data['message'] = 'Token合法';
$data['message'] = 'Token合法'; return $data;
return $data; } else {
} else { $data['user_id'] = '';
$data['user_id'] = ''; $data['code'] = '400';
$data['code'] = '400'; $data['message'] = 'Token不合法';
$data['message'] = 'Token不合法'; return $data;
return $data; }
} } else {
} else { $data['user_id'] = '';
$data['user_id'] = ''; $data['code'] = '400';
$data['code'] = '400'; $data['message'] = 'Token不合法';
$data['message'] = 'Token不合法'; return $data;
return $data; }
} }
} //生成登录记录
//生成登录记录 function save_log_response($source_flag='web', $account, $response_result){
function save_log_response($account, $response_result, $source_flag = 'web') # 储存纪录并输出
{ #echo date("Y-m-d");
# 储存纪录并输出 $file_path = "account_log/" . $account . "-" . date("Y-m-d") . ".ini";
#echo date("Y-m-d"); $data = serialize($response_result). date("H:i:s") . "\n";
$file_path = "account_log/" . $account . "-" . date("Y-m-d") . ".ini"; $fp = fopen($file_path,"a"); # 如果档案不存在择尝试建立再写入
$data = serialize($response_result) . date("H:i:s") . "\n"; fwrite($fp, $data);
$fp = fopen($file_path, "a"); # 如果档案不存在择尝试建立再写入 fclose($fp);
fwrite($fp, $data); if ($source_flag == "web"){
fclose($fp); // header("Location: custom-create.php?function_list=" . serialize($response_result) .
if ($source_flag == "web") { // "&token=" . $response_result["token"]); #请输入使用者名称密码
// header("Location: custom-create.php?function_list=" . serialize($response_result) . // exit();
// "&token=" . $response_result["token"]); #请输入使用者名称密码 return true;
// exit(); }else{
return true; // echo json_encode($response_result, JSON_UNESCAPED_UNICODE);
} else { return false;
// echo json_encode($response_result, JSON_UNESCAPED_UNICODE); }
return false;
}
/* /*
if ($source_flag == "app"){ if ($source_flag == "app"){
echo json_encode($response_result, JSON_UNESCAPED_UNICODE); echo json_encode($response_result, JSON_UNESCAPED_UNICODE);
}elseif ($source_flag == "web"){ }elseif ($source_flag == "web"){
@ -70,28 +68,26 @@ class IncludeCommon
exit(); exit();
} }
*/ */
} }
//生成token //生成token
function CreateToken($user_id, $user_name) function CreateToken($user_id, $user_name) {
{ date_default_timezone_set("Asia/Taipei");
date_default_timezone_set("Asia/Taipei"); $start_time = date("Y-m-d H:i:s");
$start_time = date("Y-m-d H:i:s"); $end_time = date('Y-m-d H:i:s',strtotime('+24 hour')); #设定24小时
$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过期时间为一天
$info = $user_id . '.' . base64_encode(urlencode($user_name)) . '.' . $start_time . '.' . $end_time; //设置token过期时间为一天 $encryption_code = "MASADA!^***";
$encryption_code = "MASADA!^***"; //根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量)
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量) $signature = hash_hmac('md5', $info, $encryption_code);
$signature = hash_hmac('md5', $info, $encryption_code); //最后将这两部分拼接起来,得到最终的Token字符串
//最后将这两部分拼接起来,得到最终的Token字符串 return $token = $info . '.' . $signature;
return $token = $info . '.' . $signature; }
} //生成菜单
//生成菜单
/** /**
* 將模擬帳號寫入token * 將模擬帳號寫入token
*/ */
function FakeToken($fake_user_id, $token) function FakeToken($fake_user_id, $token) {
{
date_default_timezone_set("Asia/Taipei"); date_default_timezone_set("Asia/Taipei");
$encryption_code = "MASADA!^***"; $encryption_code = "MASADA!^***";
$time = date("Y-m-d H:i:s"); $time = date("Y-m-d H:i:s");
@ -101,32 +97,31 @@ class IncludeCommon
return $token = $info . '.' . $signature; return $token = $info . '.' . $signature;
} }
function menu($type, $from = 'tw') function menu ($from='tw',$type){
{ $function_type = array(
$function_type = array( "tw" => array(
"tw" => array( # F角色菜单
# F角色菜单 "F" => array(
"F" => array( "language" => "tw",
"language" => "tw", "type" => "manage",
"type" => "manage", "list" => array(
"list" => array( array("name" => "批量导入", "path" => "http://192.168.0.12/wms/excel-upload"),
array("name" => "批量导入", "path" => "http://192.168.0.12/wms/excel-upload"), ),
), "note" => "none",
"note" => "none", "token" => ""
"token" => "" ),
), )
) );
);
return $function_type[$from][$type];
return $function_type[$from][$type];
} }
/** /**
* 依帳號類別檢視功能目錄 * 依帳號類別檢視功能目錄
*/ */
function menu_v2($atype = "") function menu_v2($atype="") {
{
global $link; global $link;
if (!$atype) return; if (!$atype) return;
@ -145,8 +140,7 @@ class IncludeCommon
* 管理者可看到全部選單 * 管理者可看到全部選單
* 其餘人員依account_auth決定可檢視的選單 * 其餘人員依account_auth決定可檢視的選單
*/ */
function menu_v3($accounttype, $aid = "") function menu_v3($aid="", $accounttype) {
{
global $link; global $link;
if (!$aid) return; if (!$aid) return;
@ -155,7 +149,7 @@ class IncludeCommon
$sql_cmd = ($accounttype == "E") ? "" : "where status = 'Y'"; $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"; $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); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) { while ($row = mysqli_fetch_assoc($res)) {
$menu_arr[$row["mlink"]]["main_menu"] = $row["main_menu"]; $menu_arr[$row["mlink"]]["main_menu"] = $row["main_menu"];
@ -167,8 +161,8 @@ class IncludeCommon
$sql = "select permission from account_auth where accountid = '$aid'"; $sql = "select permission from account_auth where accountid = '$aid'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$permission = empty($row) ? json_encode([]) : $row[0]; // $permission = $row[0]; //P0044 修改于2023/6/13 16:30 $permission = empty($row)? json_encode([]): $row[0]; // $permission = $row[0]; //P0044 修改于2023/6/13 16:30
$permission_arr = json_decode($permission, true); $permission_arr = json_decode($permission, true);
foreach ($menu_arr as $key => $val) { foreach ($menu_arr as $key => $val) {
if (($accounttype == "E") || !empty($permission_arr[$key])) { if (($accounttype == "E") || !empty($permission_arr[$key])) {
@ -215,4 +209,4 @@ class IncludeCommon
return $str; return $str;
*/ */
} }
} }

180
wms/T8_APItest.php

@ -1,91 +1,91 @@
<?php <?php
include "T8_Authorization.php"; include "T8_Authorization.php";
echo "ii"; echo "ii";
?> ?>
<script> <script>
get_Auth(); get_Auth();
window.addEventListener('message', function(event) { window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
// if (event.origin === "https://masada.com.tw" && (typeof event.data === "string")) { // if (event.origin === "https://masada.com.tw" && (typeof event.data === "string")) {
var validation = event.data; var validation = event.data;
console.log("event"); console.log("event");
console.log(validation); console.log(validation);
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; // var corsurl = 'http://cors-anywhere.herokuapp.com/';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALDISPATCHLIST/GetERPData?pkValue=SS20230825001'; var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALDISPATCHLIST/GetERPData?pkValue=SS20230825001';
headerParam = { headerParam = {
CHI_Authorization: `${validation}`, CHI_Authorization: `${validation}`,
}; };
var body = [{ var body = [{
"name": "MasterTable", "name": "MasterTable",
"rows": [{ "rows": [{
"BillNo": "Z001", "BillNo": "Z001",
"BillDate": 20230930, "BillDate": 20230930,
"OrgId": "1000", "OrgId": "1000",
"TypeId": "OPV", "TypeId": "OPV",
"BizPartnerId": "03051501", "BizPartnerId": "03051501",
"CurrId": "RMB", "CurrId": "RMB",
"CurrLAmount":5, "CurrLAmount":5,
"TaxId": "ST005", "TaxId": "ST005",
"PersonId": "M0012", "PersonId": "M0012",
"DeptId": "220", "DeptId": "220",
"CompId": "1001", "CompId": "1001",
"CreditAgeDate": 20230930, "CreditAgeDate": 20230930,
"RecBizPartnerId": "03051501", "RecBizPartnerId": "03051501",
}] }]
}, },
{ {
"name": "DetailTable", "name": "DetailTable",
"rows": [{ "rows": [{
"BillNo": "Z001", "BillNo": "Z001",
"RowCode": 1, "RowCode": 1,
"RowNo": 1, "RowNo": 1,
"ItemType": 0, "ItemType": 0,
"MaterialId": "MX00000001", "MaterialId": "MX00000001",
"UnitId": "PCS", "UnitId": "PCS",
"MaterialSpec": "", "MaterialSpec": "",
"SQuantity": 10, "SQuantity": 10,
"SPrice": 141.18, "SPrice": 141.18,
"OAmount": 1344.57, "OAmount": 1344.57,
"OTax": 67.23, "OTax": 67.23,
"OAmountWithTax": 1411.8, "OAmountWithTax": 1411.8,
"TaxId": "ST005" "TaxId": "ST005"
}, },
{ {
"BillNo": "Z001", "BillNo": "Z001",
"RowCode": 2, "RowCode": 2,
"RowNo": 2, "RowNo": 2,
"ItemType": 0, "ItemType": 0,
"MaterialId": "MX00000001", "MaterialId": "MX00000001",
"UnitId": "PCS", "UnitId": "PCS",
"MaterialSpec": "", "MaterialSpec": "",
"SQuantity": 15, "SQuantity": 15,
"SPrice": 141.18, "SPrice": 141.18,
"OAmount": 2016.86, "OAmount": 2016.86,
"OTax": 100.84, "OTax": 100.84,
"OAmountWithTax": 2117.7, "OAmountWithTax": 2117.7,
"TaxId": "ST005" "TaxId": "ST005"
} }
] ]
} }
]; ];
var json = JSON.stringify(body); var json = JSON.stringify(body);
obj = { obj = {
type: 'GET', type: 'GET',
// url: `${corsurl}${apiurl}`, // url: `${corsurl}${apiurl}`,
url: `${apiurl}`, url: `${apiurl}`,
// dataType: 'json', // dataType: 'json',
headers: headerParam, headers: headerParam,
// data: json, // data: json,
// dataType: "json", // dataType: "json",
success: function(res) { success: function(res) {
console.log(res.Status); console.log(res.Status);
console.log(res.ErrorMsg); console.log(res.ErrorMsg);
console.log(res.Data); console.log(res.Data);
} }
}; };
jQuery.ajax(obj); jQuery.ajax(obj);
} }
}) })
</script> </script>

99
wms/T8_APItest_from_bpm.php

@ -0,0 +1,99 @@
<?php
ini_set('display_errors', 'on');
date_default_timezone_set('Asia/Taipei');
$referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : "";
$hashReferer = "https://bpm.masada.com.twMasada@2023";
if ($hashReferer == $referrer) {
include "T8_Authorization_from_bpm.php";
$user_id = "M0000";
$user_password = "M012290493119";
$validation = get_Auth("M0000", "M012290493119");
send_data_to_API($validation);
} else {
echo "非法訪問!";
exit;
}
function send_data_to_API($validation)
{
// $apiurl = 'http://60.244.87.101:880//twWebAPI/V1/STKASSY/PostERPData';
$apiurl = 'http://10.10.145.2:880//twWebAPI/V1/STKASSY/PostERPData';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData';
$headerParam = [
'CHI_Authorization: ' . $validation,
'Content-Type: application/json'
];
$body = [
[
"name" => "stkAssyMast",
"rows" => [
[
"BillNo" => "TEST06",
"OrgId" => "1000",
"TypeId" => "CA",
"MaterialId" => "3MH00302",
"PersonId" => "M0122",
"CompId" => "1001",
"DeptId" => "220",
"SQuantity" => 1,
"SUnitId" => "SET",
"CurrentState" => 2,
"CreatorId" => "M0122"
]
]
],
[
"name" => "stkAssySubMatInfo",
"rows" => [
[
"BillNo" => "TEST06",
"MaterialId" => "3MH00302P",
"ComponentBaseQty" => 1,
"UnitQty" => 1,
"SUnitId" => "SET",
"MarkerNo" => "3MH00302",
"CU_MaterialId" => "3MH00302"
],
[
"BillNo" => "TEST06",
"MaterialId" => "MX00000001",
"ComponentBaseQty" => 1,
"UnitQty" => 3,
"SUnitId" => "PCS",
"MarkerNo" => "3MH00302",
"CU_MaterialId" => "3MH00302"
]
]
]
];
$json = json_encode($body);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
echo $result['Status'] . "\n";
echo $result['ErrorMsg'] . "\n";
print_r($result['Data']);
}
curl_close($ch);
}

72
wms/T8_Authorization.php

@ -1,37 +1,37 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<?php <?php
$now = gmdate("YmdHis"); $now = gmdate("YmdHis");
$data = 'M0000.' . $now; $data = 'M0000.' . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
?> ?>
<script> <script>
function get_Auth() { function get_Auth() {
var api_key = 'B2D6395D2883E26C'; var api_key = 'B2D6395D2883E26C';
var validation = ""; var validation = "";
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; // var corsurl = 'http://cors-anywhere.herokuapp.com/';
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; // var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth' var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'
headerParam = { headerParam = {
UserId: 'M0000', UserId: 'M0000',
Pwd: 'M012290493119', Pwd: 'M012290493119',
TimestampUTC: <?= $now ?>, TimestampUTC: <?= $now ?>,
Sign: '<?= $sign ?>' Sign: '<?= $sign ?>'
}; };
obj = { obj = {
type: 'get', type: 'get',
// url: `${corsurl}${apiurl}`, // url: `${corsurl}${apiurl}`,
url: `${apiurl}`, url: `${apiurl}`,
dataType: 'json', dataType: 'json',
headers: headerParam, headers: headerParam,
success: function(res) { success: function(res) {
validation = res.Data['CHI_Authorization']; validation = res.Data['CHI_Authorization'];
console.log("validation:",validation); console.log("validation:",validation);
window.parent.postMessage(validation,'http://localhost:3000'); window.parent.postMessage(validation,'http://localhost:3000');
// window.parent.postMessage(validation,'https://masada.com.tw'); // window.parent.postMessage(validation,'https://masada.com.tw');
} }
}; };
jQuery.ajax(obj); jQuery.ajax(obj);
} }
</script> </script>

43
wms/T8_Authorization_from_bpm.php

@ -0,0 +1,43 @@
<?php
$user_id = "M0000";
$user_password = "M012290493119";
function get_Auth($user_id = "M0000", $user_password = "M012290493119")
{
$now = gmdate("YmdHis");
$data = "$user_id." . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
// $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
$apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
$headerParam = [
"UserId: $user_id",
"Pwd: $user_password",
"TimestampUTC: $now",
"Sign: $sign"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
// print_r($response);
// exit;
$result = json_decode($response, true);
$validation = $result['Data']['CHI_Authorization'];
return $validation;
}
curl_close($ch);
}

140
wms/T8_assemble_apply.php

@ -1,71 +1,71 @@
<?php <?php
//外購組裝單 (組裝申請單) //外購組裝單 (組裝申請單)
include "T8_Authorization.php"; include "T8_Authorization.php";
?> ?>
<script> <script>
get_Auth(); get_Auth();
window.addEventListener('message', function(event) { window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
var validation = event.data; var validation = event.data;
console.log(validation); console.log(validation);
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData'; var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData';
headerParam = { headerParam = {
CHI_Authorization: `${validation}`, CHI_Authorization: `${validation}`,
}; };
var body = [{ var body = [{
"name":"stkAssyMast", "name":"stkAssyMast",
"rows":[ "rows":[
{ {
"BillNo":"TEST02", "BillNo":"TEST02",
"OrgId":"1000", "OrgId":"1000",
"TypeId":"CA", "TypeId":"CA",
"MaterialId":"3MH00302", "MaterialId":"3MH00302",
"PersonId":"M0122", "PersonId":"M0122",
"CompId":"1001", "CompId":"1001",
"DeptId":"220", "DeptId":"220",
"SQuantity":1, "SQuantity":1,
"SUnitId":"SET", "SUnitId":"SET",
"CurrentState":2, "CurrentState":2,
"CreatorId":"M0122" "CreatorId":"M0122"
} }
] ]
},{ },{
"name":"stkAssySubMatInfo", "name":"stkAssySubMatInfo",
"rows":[ "rows":[
{ {
"BillNo":"TEST02", "BillNo":"TEST02",
"MaterialId":"3MH00302P", "MaterialId":"3MH00302P",
"ComponentBaseQty":1, "ComponentBaseQty":1,
"UnitQty":1, "UnitQty":1,
"SUnitId":"SET", "SUnitId":"SET",
"MarkerNo":"3MH00302", "MarkerNo":"3MH00302",
"CU_MaterialId":"3MH00302" "CU_MaterialId":"3MH00302"
},{ },{
"BillNo":"TEST02", "BillNo":"TEST02",
"MaterialId":"MX00000001", "MaterialId":"MX00000001",
"ComponentBaseQty":1, "ComponentBaseQty":1,
"UnitQty":3, "UnitQty":3,
"SUnitId":"PCS", "SUnitId":"PCS",
"MarkerNo":"3MH00302", "MarkerNo":"3MH00302",
"CU_MaterialId":"3MH00302" "CU_MaterialId":"3MH00302"
} }
] ]
}]; }];
var json = JSON.stringify(body); var json = JSON.stringify(body);
obj = { obj = {
type:'POST', type:'POST',
url:`${apiurl}`, url:`${apiurl}`,
headers:headerParam, headers:headerParam,
data: json, data: json,
dataType:"json", dataType:"json",
success: function(res){ success: function(res){
console.log(res.Status); console.log(res.Status);
console.log(res.ErrorMsg); console.log(res.ErrorMsg);
console.log(res.Data); console.log(res.Data);
} }
}; };
jQuery.ajax(obj); jQuery.ajax(obj);
} }
}) })
</script> </script>

46
wms/T8_purBillOrder_search.php

@ -1,23 +1,23 @@
<?php <?php
include "./header.php"; include "./header.php";
//假設供應商代碼為P //假設供應商代碼為P
$BizPartnerId = "P"; $BizPartnerId = "P";
$sql_purBillOrder = " $sql_purBillOrder = "
SELECT * FROM purBillOrderMaster WHERE BizPartnerId = '$BizPartnerId' AND CurrentState = 2"; SELECT * FROM purBillOrderMaster WHERE BizPartnerId = '$BizPartnerId' AND CurrentState = 2";
$purMaster = $conn->query($sql_purBillOrder); $purMaster = $conn->query($sql_purBillOrder);
//每筆採購單資料 //每筆採購單資料
foreach($purMaster as $master){ foreach($purMaster as $master){
//print_r($master); //print_r($master);
$BillNo = $master['BillNo']; $BillNo = $master['BillNo'];
//每筆採購單明細資料 //每筆採購單明細資料
$sql_purDetail = " $sql_purDetail = "
SELECT * FROM purBillOrderDetail WHERE BillNo = '$BillNo'"; SELECT * FROM purBillOrderDetail WHERE BillNo = '$BillNo'";
$purDetail = $conn->query($sql_purDetail); $purDetail = $conn->query($sql_purDetail);
foreach($purDetail as $detail){ foreach($purDetail as $detail){
print_r($detail); print_r($detail);
} }
echo "<br>----------------------<br>"; echo "<br>----------------------<br>";
} }

88
wms/T8_purRequestOrder_create.php

@ -1,45 +1,45 @@
<?php <?php
include "./header.php"; include "./header.php";
date_default_timezone_set('Asia/Taipei'); date_default_timezone_set('Asia/Taipei');
//表頭 //表頭
$BillNo ="TEST01"; $BillNo ="TEST01";
$BillDate = 20231204; $BillDate = 20231204;
$PersonId = "M0122"; $PersonId = "M0122";
$DeptId = "220"; $DeptId = "220";
// $ProjectId = "3MH00545"; // $ProjectId = "3MH00545";
$CreateTime = Date("YmdHis"); $CreateTime = Date("YmdHis");
$CurrentState = 2; $CurrentState = 2;
//表身 //表身
$ItemType = 0; $ItemType = 0;
$MaterialId = "MX00011078"; $MaterialId = "MX00011078";
$SUnitId = "PCS"; $SUnitId = "PCS";
$DemandSQty = 5; //核准數量 $DemandSQty = 5; //核准數量
$RequestSQty = 5; //請購數量 $RequestSQty = 5; //請購數量
$RequireDate=20231205; $RequireDate=20231205;
$CurrId="TWD"; $CurrId="TWD";
$UnTransQty = 5; //未轉採購基本數量 $UnTransQty = 5; //未轉採購基本數量
$TransQty = 0; //已轉採購基本數量 $TransQty = 0; //已轉採購基本數量
$SupplyQty = 5; //供給數量 $SupplyQty = 5; //供給數量
$ProjectId="3MH00545"; //合約號 $ProjectId="3MH00545"; //合約號
$SupplyId= "P"; //供應商 $SupplyId= "P"; //供應商
$UnTransOtherSQty = 5; $UnTransOtherSQty = 5;
$AllowTransOtherSQty = 5; $AllowTransOtherSQty = 5;
$CU_MaterialId="3MH00352"; //作番號 、預留標示號 $CU_MaterialId="3MH00352"; //作番號 、預留標示號
$sql = "INSERT INTO purRequestOrder(BillNo, BillDate, PersonId, DeptId, CreateTime, CurrentState, $sql = "INSERT INTO purRequestOrder(BillNo, BillDate, PersonId, DeptId, CreateTime, CurrentState,
TypeId, DemandOrgId, FOrgId,CreatorId, CompId) VALUES ('$BillNo',$BillDate,'$PersonId','$DeptId',$CreateTime,$CurrentState, TypeId, DemandOrgId, FOrgId,CreatorId, CompId) VALUES ('$BillNo',$BillDate,'$PersonId','$DeptId',$CreateTime,$CurrentState,
'PR','1000','1000','$user_id','1001')"; 'PR','1000','1000','$user_id','1001')";
$sql_sub = "INSERT INTO purApplyOrderDetail(BillNo,RowCode, RowNo, ItemType, MaterialId, SUnitId, $sql_sub = "INSERT INTO purApplyOrderDetail(BillNo,RowCode, RowNo, ItemType, MaterialId, SUnitId,
DemandSQty, DemandQty, RequestSQty,RequestQty, RequireDate, IsPriceWithTax, CurrId, DemandSQty, DemandQty, RequestSQty,RequestQty, RequireDate, IsPriceWithTax, CurrId,
PurOrgId, BpOrgId, SupplyId, UnTransQty, TransQty, SupplyQty, ProjectId, PlanRangeId, PurOrgId, BpOrgId, SupplyId, UnTransQty, TransQty, SupplyQty, ProjectId, PlanRangeId,
UnTransOtherSQty, AllowTransOtherSQty,P_A_DemandOrgId, PurCompId, CU_MaterialId, MarkerNo UnTransOtherSQty, AllowTransOtherSQty,P_A_DemandOrgId, PurCompId, CU_MaterialId, MarkerNo
) VALUES ('$BillNo',1,1,$ItemType,'$MaterialId','$SUnitId', ) VALUES ('$BillNo',1,1,$ItemType,'$MaterialId','$SUnitId',
$DemandSQty, $DemandSQty, $RequestSQty, $RequestSQty, $RequireDate, 1, '$CurrId', $DemandSQty, $DemandSQty, $RequestSQty, $RequestSQty, $RequireDate, 1, '$CurrId',
'1000', '1000', '$SupplyId', $UnTransQty, $TransQty, $SupplyQty, '$ProjectId', '1000', '1000', '1000', '$SupplyId', $UnTransQty, $TransQty, $SupplyQty, '$ProjectId', '1000',
$UnTransOtherSQty, $AllowTransOtherSQty,'1000','1001','$CU_MaterialId','$CU_MaterialId')"; $UnTransOtherSQty, $AllowTransOtherSQty,'1000','1001','$CU_MaterialId','$CU_MaterialId')";
$conn ->query($sql); $conn ->query($sql);
$conn ->query($sql_sub); $conn ->query($sql_sub);

360
wms/account-create.php

@ -1,180 +1,180 @@
<?php <?php
include "header.php"; include "header.php";
// 部門職別 // 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id"; $db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) { while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"]; $depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; $role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
} }
mysqli_free_result($res); mysqli_free_result($res);
?> ?>
<script> <script>
$(function(){ $(function(){
var jroleStr = '<?php echo json_encode($role_arr); ?>'; var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr); var jroleArr = JSON.parse(jroleStr);
var optStr = ""; var optStr = "";
$("select[name=department_id]").change(function(){ $("select[name=department_id]").change(function(){
if ($(this).val() != "") { if ($(this).val() != "") {
optStr = ""; optStr = "";
for (var i in jroleArr[$(this).val()]) { for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) { if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
} }
} }
$("select[name=role_id]").html(optStr); $("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); } else $("select[name=role_id]").html('<option value="">請選擇</option>');
}) })
}); });
</script> </script>
<div class="container"> <div class="container">
<?php <?php
include "account-record-submit.php"; include "account-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; echo "<p class='success'>Record has added successfully</p>";
} }
} }
*/ */
?> ?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div> <div>
<label for="accounttype">帳號類別(必選)</label> <label for="accounttype">帳號類別(必選)</label>
<select name="accounttype" id="accounttype" required> <select name="accounttype" id="accounttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<option value="A">客戶(A)</option> <option value="A">客戶(A)</option>
<option value="B">保養人員(B)</option> <option value="B">保養人員(B)</option>
<!-- <!--
<option value="C">檢查人員</option> <option value="C">檢查人員</option>
<option value="D">契約人員</option> <option value="D">契約人員</option>
--> -->
<option value="E">管理人員(E)</option> <option value="E">管理人員(E)</option>
<option value="M">永佳捷員工(M)</option> <option value="M">永佳捷員工(M)</option>
<option value="X">未分類(X)</option> <option value="X">未分類(X)</option>
</select> </select>
<!-- <input type="text" name="accounttype" id="accounttype" placeholder="帳號類別..." required> --> <!-- <input type="text" name="accounttype" id="accounttype" placeholder="帳號類別..." required> -->
</div> </div>
<div> <div>
<label for="accountid">請輸入員工、個人客戶ID或公司客戶統編(必填)</label> <label for="accountid">請輸入員工、個人客戶ID或公司客戶統編(必填)</label>
<input type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編...(必填)" maxlength="10" required> <input type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編...(必填)" maxlength="10" required>
</div> </div>
<div> <div>
<label for="pwd">密碼(必填)</label> <label for="pwd">密碼(必填)</label>
<input type="text" name="pwd" id="pwd" required> <input type="text" name="pwd" id="pwd" required>
</div> </div>
<div> <div>
<label for="name">姓名(必填)</label> <label for="name">姓名(必填)</label>
<input type="text" name="name" id="name" required> <input type="text" name="name" id="name" required>
</div> </div>
<div> <div>
<label for="tel">電話</label> <label for="tel">電話</label>
<input type="text" name="tel" id="tel" maxlength="16"> <input type="text" name="tel" id="tel" maxlength="16">
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address"> <input type="text" name="address" id="address">
</div> </div>
<div> <div>
<label for="email">電子郵箱</label> <label for="email">電子郵箱</label>
<input type="text" name="email" id="email"> <input type="text" name="email" id="email">
</div> </div>
<div> <div>
<label for="lineid">Line ID</label> <label for="lineid">Line ID</label>
<input type="text" name="lineid" id="lineid"> <input type="text" name="lineid" id="lineid">
</div> </div>
<div> <div>
<label for="wechatid">微信ID</label> <label for="wechatid">微信ID</label>
<input type="text" name="wechatid" id="wechatid"> <input type="text" name="wechatid" id="wechatid">
</div> </div>
<div> <div>
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label> <label for="phone_call_help">保養員聯絡手機號(客戶必填)</label>
<input type="text" name="phone_call_help" id="phone_call_help" maxlength="16"> <input type="text" name="phone_call_help" id="phone_call_help" maxlength="16">
</div> </div>
<div> <div>
<label for="chat_for_help">線上文字客服</label> <label for="chat_for_help">線上文字客服</label>
<input type="text" name="chat_for_help" id="chat_for_help"> <input type="text" name="chat_for_help" id="chat_for_help">
</div> </div>
<div> <div>
<label for="remote_help">遠端視頻帳號</label> <label for="remote_help">遠端視頻帳號</label>
<input type="text" name="remote_help" id="remote_help"> <input type="text" name="remote_help" id="remote_help">
</div> </div>
<div> <div>
<label for="repairerid">服務與支持人員工號(客戶必填)</label> <label for="repairerid">服務與支持人員工號(客戶必填)</label>
<input type="text" name="repairerid" id="repairerid" maxlength="10"> <input type="text" name="repairerid" id="repairerid" maxlength="10">
</div> </div>
<div> <div>
<label for="manager">直屬主管工號(員工必填)</label> <label for="manager">直屬主管工號(員工必填)</label>
<input type="text" name="manager" id="manager" maxlength="10"> <input type="text" name="manager" id="manager" maxlength="10">
</div> </div>
<div> <div>
<label for="department_id">部門(員工必填)</label> <label for="department_id">部門(員工必填)</label>
<select name="department_id"> <select name="department_id">
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($depart_arr as $k => $v) { foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>"; echo "<option value=\"".$k."\">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="role_id">職別(員工必填)</label> <label for="role_id">職別(員工必填)</label>
<select name="role_id"> <select name="role_id">
<option value="">請選擇</option> <option value="">請選擇</option>
</select> </select>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p> <p class="error"><?php echo $creater_error; ?></p>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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'); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<div> <div>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
<?php } ?> <?php } ?>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

36
wms/account-delete.php

@ -1,19 +1,19 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$sql = "select accountid from account where id = '$id'"; $sql = "select accountid from account where id = '$id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) { if ($row = mysqli_fetch_assoc($res)) {
$db_query = "delete from account where id = '$id'"; $db_query = "delete from account where id = '$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
$db_query = "delete from account_auth where accountid = '".$row["accountid"]."'"; $db_query = "delete from account_auth where accountid = '".$row["accountid"]."'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
} }
mysqli_free_result($res); mysqli_free_result($res);
header("Refresh:0; url=account-index.php?function_name=account&".$token_link); header("Refresh:0; url=account-index.php?function_name=account&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

346
wms/account-edit.php

@ -1,173 +1,173 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $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"; $db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) { while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"]; $depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; $role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
} }
mysqli_free_result($res); mysqli_free_result($res);
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM account WHERE id=$id"; $db_query = "SELECT * FROM account WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/record_update.php"; include "inc/record_update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<script> <script>
$(function(){ $(function(){
var jroleStr = '<?php echo json_encode($role_arr); ?>'; var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr); var jroleArr = JSON.parse(jroleStr);
var optStr = ""; var optStr = "";
$("select[name=department_id]").change(function(){ $("select[name=department_id]").change(function(){
if ($(this).val() != "") { if ($(this).val() != "") {
optStr = ""; optStr = "";
for (var i in jroleArr[$(this).val()]) { for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) { if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
} }
} }
$("select[name=role_id]").html(optStr); $("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); } else $("select[name=role_id]").html('<option value="">請選擇</option>');
}) })
}); });
</script> </script>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="account-record-update.php"> <form class="form-inline" method="post" action="account-record-update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="accounttype">帳號類別</label> <label for="accounttype">帳號類別</label>
<input type="text" name="accounttype" id="accounttype" value="<?php echo $data['accounttype']; ?>" readonly> <input type="text" name="accounttype" id="accounttype" value="<?php echo $data['accounttype']; ?>" readonly>
</div> </div>
<div> <div>
<label for="accountid">帳號</label> <label for="accountid">帳號</label>
<input type="text" name="accountid" id="accountid" value="<?php echo $data['accountid']; ?>" readonly> <input type="text" name="accountid" id="accountid" value="<?php echo $data['accountid']; ?>" readonly>
</div> </div>
<div> <div>
<label for="pwd">密碼(必填)</label> <label for="pwd">密碼(必填)</label>
<input type="text" name="pwd" id="pwd" value="<?php echo $data['pwd']; ?>"> <input type="text" name="pwd" id="pwd" value="<?php echo $data['pwd']; ?>">
</div> </div>
<div> <div>
<label for="name">姓名(必填)</label> <label for="name">姓名(必填)</label>
<input type="text" name="name" id="name" value="<?php echo $data['name']; ?>"> <input type="text" name="name" id="name" value="<?php echo $data['name']; ?>">
</div> </div>
<div> <div>
<label for="tel">電話</label> <label for="tel">電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> <input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> <input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div> </div>
<div> <div>
<label for="email">電子郵箱</label> <label for="email">電子郵箱</label>
<input type="text" name="email" id="email" value="<?php echo $data['email']; ?>"> <input type="text" name="email" id="email" value="<?php echo $data['email']; ?>">
</div> </div>
<div> <div>
<label for="lineid">Line ID</label> <label for="lineid">Line ID</label>
<input type="text" name="lineid" id="lineid" value="<?php echo $data['lineid']; ?>"> <input type="text" name="lineid" id="lineid" value="<?php echo $data['lineid']; ?>">
</div> </div>
<div> <div>
<label for="wechatid">微信ID</label> <label for="wechatid">微信ID</label>
<input type="text" name="wechatid" id="wechatid" value="<?php echo $data['wechatid']; ?>"> <input type="text" name="wechatid" id="wechatid" value="<?php echo $data['wechatid']; ?>">
</div> </div>
<div> <div>
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label> <label for="phone_call_help">保養員聯絡手機號(客戶必填)</label>
<input type="text" name="phone_call_help" id="phone_call_help" value="<?php echo $data['phone_call_help']; ?>"> <input type="text" name="phone_call_help" id="phone_call_help" value="<?php echo $data['phone_call_help']; ?>">
</div> </div>
<div> <div>
<label for="chat_for_help">線上文字客服</label> <label for="chat_for_help">線上文字客服</label>
<input type="text" name="chat_for_help" id="chat_for_help" value="<?php echo $data['chat_for_help']; ?>"> <input type="text" name="chat_for_help" id="chat_for_help" value="<?php echo $data['chat_for_help']; ?>">
</div> </div>
<div> <div>
<label for="remote_help">遠端視頻帳號</label> <label for="remote_help">遠端視頻帳號</label>
<input type="text" name="remote_help" id="remote_help" value="<?php echo $data['remote_help']; ?>"> <input type="text" name="remote_help" id="remote_help" value="<?php echo $data['remote_help']; ?>">
</div> </div>
<div> <div>
<label for="repairerid">服務與支持人員工號(客戶必填)</label> <label for="repairerid">服務與支持人員工號(客戶必填)</label>
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>"> <input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>">
</div> </div>
<div> <div>
<label for="manager">直屬主管工號(員工必填)</label> <label for="manager">直屬主管工號(員工必填)</label>
<input type="text" name="manager" id="manager" value="<?php echo $data['manager']; ?>"> <input type="text" name="manager" id="manager" value="<?php echo $data['manager']; ?>">
</div> </div>
<div> <div>
<label for="department_id">部門(員工必填)</label> <label for="department_id">部門(員工必填)</label>
<select name="department_id"> <select name="department_id">
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($depart_arr as $k => $v) { foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\""; echo "<option value=\"".$k."\"";
if ($data["department_id"] == $k) echo " selected"; if ($data["department_id"] == $k) echo " selected";
echo ">".$v."</option>"; echo ">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="role_id">職別(員工必填)</label> <label for="role_id">職別(員工必填)</label>
<select name="role_id"> <select name="role_id">
<?php <?php
foreach ($role_arr[$data["department_id"]] as $k => $v) { foreach ($role_arr[$data["department_id"]] as $k => $v) {
echo "<option value=\"".$k."\""; echo "<option value=\"".$k."\"";
if ($data["role_id"] == $k) echo " selected"; if ($data["role_id"] == $k) echo " selected";
echo ">".$v."</option>"; echo ">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div> <div>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

170
wms/account-index-submit.php

@ -1,85 +1,85 @@
<?php <?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
include "database.php"; include "database.php";
include 'class/Cmail.php'; include 'class/Cmail.php';
header('Content-Type: application/json'); header('Content-Type: application/json');
$method = $_POST['method']; $method = $_POST['method'];
$id = empty($_POST['id']) ? '' : $_POST['id']; $id = empty($_POST['id']) ? '' : $_POST['id'];
$sql = " $sql = "
SELECT * FROM account WHERE id = '$id' SELECT * FROM account WHERE id = '$id'
"; ";
$result = mysqli_query($link, $sql); $result = mysqli_query($link, $sql);
$data = mysqli_fetch_assoc($result); $data = mysqli_fetch_assoc($result);
$cmail = new Cmail(); $cmail = new Cmail();
$subject = "永佳捷新人文件"; $subject = "永佳捷新人文件";
$em_body = ""; $em_body = "";
$file_name = str_replace('/', '\\', __DIR__ . "/public/file/永佳捷雲端空間使用設定方式.pdf"); $file_name = str_replace('/', '\\', __DIR__ . "/public/file/永佳捷雲端空間使用設定方式.pdf");
$file[0] = [$file_name, "永佳捷雲端空間使用設定方式.pdf"]; $file[0] = [$file_name, "永佳捷雲端空間使用設定方式.pdf"];
$sendlist[0] = [$data['name'], $data['email']]; $sendlist[0] = [$data['name'], $data['email']];
// 保養人員 // 保養人員
if (in_array($data['accounttype'], ['B'])) { if (in_array($data['accounttype'], ['B'])) {
$em_body = " $em_body = "
您好,我是桃園資訊處的子苹, 您好,我是桃園資訊處的子苹,
以下是給新報到同仁的基本資訊,您再參考: 以下是給新報到同仁的基本資訊,您再參考:
員編:" . $data['accountid'] . " 員編:" . $data['accountid'] . "
公司手機門號:請和資訊人員聯絡 公司手機門號:請和資訊人員聯絡
你的email:" . $data['email'] . " 你的email:" . $data['email'] . "
web收信:http://webmail.masada.com.tw:8081 web收信:http://webmail.masada.com.tw:8081
帳號:" . explode('@', $data['email'])[0] . " 帳號:" . explode('@', $data['email'])[0] . "
密碼:" . $data['accountid'] . " 密碼:" . $data['accountid'] . "
登入後密碼可再自行更改 登入後密碼可再自行更改
除了這個web方式收信,你也可以點擊手機裡的gmail收發信 除了這個web方式收信,你也可以點擊手機裡的gmail收發信
桌面有安裝「維保APP系統」 桌面有安裝「維保APP系統」
登入帳號 " . $data['accountid'] . " 登入帳號 " . $data['accountid'] . "
密碼 " . explode('@', $data['email'])[0] . " 密碼 " . explode('@', $data['email'])[0] . "
GPS定位APP的登入帳密跟上面的一樣 GPS定位APP的登入帳密跟上面的一樣
http://oa.masada.com.tw http://oa.masada.com.tw
這是公司內部系統 這是公司內部系統
登入帳號:" . $data['accountid'] . " 登入帳號:" . $data['accountid'] . "
登入密碼:" . explode('@', $data['email'])[0] . " 登入密碼:" . explode('@', $data['email'])[0] . "
https://cloud.masada.com.tw:1846/ https://cloud.masada.com.tw:1846/
這是公司雲端系統 這是公司雲端系統
預設帳密在信箱 請記得去更改密碼 預設帳密在信箱 請記得去更改密碼
以上,有問題請隨時與資訊聯繫,謝謝! 以上,有問題請隨時與資訊聯繫,謝謝!
"; ";
} }
// 員工 // 員工
if (in_array($data['accounttype'], ['M', 'E'])) { if (in_array($data['accounttype'], ['M', 'E'])) {
$em_body = " $em_body = "
您好, 您好,
以下是給新報到同仁的基本資訊,您再參考: 以下是給新報到同仁的基本資訊,您再參考:
員編:" . $data['accountid'] . " 員編:" . $data['accountid'] . "
你的email:" . $data['email'] . " 你的email:" . $data['email'] . "
web收信:http://webmail.masada.com.tw:8081 web收信:http://webmail.masada.com.tw:8081
帳號:" . explode('@', $data['email'])[0] . " 帳號:" . explode('@', $data['email'])[0] . "
密碼:" . $data['accountid'] . " 密碼:" . $data['accountid'] . "
登入後密碼可再自行更改 登入後密碼可再自行更改
除了這個web方式收信,你也可以用電腦裡的outlook收發信 除了這個web方式收信,你也可以用電腦裡的outlook收發信
http://oa.masada.com.tw http://oa.masada.com.tw
這是公司內部系統 這是公司內部系統
登入帳號:" . $data['accountid'] . " 登入帳號:" . $data['accountid'] . "
登入密碼:" . explode('@', $data['email'])[0] . " 登入密碼:" . explode('@', $data['email'])[0] . "
https://cloud.masada.com.tw:1846/ https://cloud.masada.com.tw:1846/
這是公司雲端系統 這是公司雲端系統
預設帳密在信箱 請記得去更改密碼 預設帳密在信箱 請記得去更改密碼
以上,有問題請隨時與資訊聯繫,謝謝! 以上,有問題請隨時與資訊聯繫,謝謝!
"; ";
} }
$cmail->sendx($subject, $em_body, $sendlist, "永佳捷科技", "", $file); $cmail->sendx($subject, $em_body, $sendlist, "永佳捷科技", "", $file);
echo json_encode([1, "信件發送成功"]); echo json_encode([1, "信件發送成功"]);
} }

371
wms/account-index.php

@ -1,173 +1,198 @@
<?php <?php
include "header.php"; include "header.php";
$accounttype_arr = ["A" => "客戶", "B" => "保養人員", "C" => "檢查人員", "D" => "契約人員", "M" => "員工", "E" => "管理員(IT)", "X" => "未分類"]; #A=客戶 B=保養人員 C=檢查人員 D=契約人員 E=管理人員 M=永佳捷員工 X=未分類 $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'"; $sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$user_department_id = $row[0]; $user_department_id = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id); $sql_cmd = sql_myself($user_id);
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = ""; if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = "";
$sql = "SELECT * FROM account $sql_cmd ORDER BY id"; $sql = "SELECT * FROM account $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link, $sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth & 2) { ?>
<p> <p>
<a href="account-create.php?function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="account-create.php?function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if ($data) :
if($_SERVER["REQUEST_METHOD"] == "POST"){ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) {
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:account-index.php"); header("Location:account-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout: fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap: break-word;
} }
img { img {
width:125px; width: 125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width: 125px;
} }
table{ table {
width:100%; width: 100%;
} }
#table_index_filter{
float:right; #table_index_filter {
} float: right;
#table_index_paginate{ }
float:right;
} #table_index_paginate {
label { float: right;
display: inline-flex; }
margin-bottom: .5rem;
margin-top: .5rem; label {
display: inline-flex;
} margin-bottom: .5rem;
margin-top: .5rem;
</style>
}
<div style="overflow-x:auto;"> </style>
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <div style="overflow-x:auto;">
<tr> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<th>項次</th> <thead>
<th>帳號類型</th> <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>Line ID</th> <th>地址</th>
<th>微信id</th> <th>電子郵件</th>
<th>遠端協助</th> <th>Line ID</th>
<th>維修ID</th> <th>微信id</th>
<th>直屬主管</th> <th>遠端協助</th>
<th>建檔人</th> <th>維修ID</th>
<th>建檔時間</th> <th>直屬主管</th>
<?php if ($user_auth&2) { ?> <th>建檔人</th>
<th>修改</th> <th>建檔時間</th>
<!--<th>刪除</th>--> <?php if ($user_auth & 2) { ?>
<?php } ?> <th>修改</th>
</tr> <th>新人資料</th>
</thead> <!--<th>刪除</th>-->
<tbody> <?php } ?>
</tr>
<?php foreach($data as $data) : ?> </thead>
<tr> <tbody>
<td><?php echo $data['id']; ?></td>
<td data-toggle="tooltip" data-placement="right" title=" <?php foreach ($data as $data) : ?>
<?php <tr>
if (isset($accounttype_arr[$data['accounttype']])){ <td><?php echo $data['id']; ?></td>
echo $accounttype_arr[$data['accounttype']]; <td data-toggle="tooltip" data-placement="right" title="
}else{ <?php
echo $data['accounttype']; 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{ <?php
echo $data['accounttype']; if (isset($accounttype_arr[$data['accounttype']])) {
} echo $accounttype_arr[$data['accounttype']];
?></td> } else {
<td><?php echo $data['accountid']; ?></td> echo $data['accounttype'];
<!--<td><?php echo $data['pwd']; ?></td>--> }
<td><?php echo $data['name']; ?></td> ?></td>
<td><?php echo $data['tel']; ?></td> <td><?php echo $data['accountid']; ?></td>
<td><?php echo $data['address']; ?></td> <!--<td><?php echo $data['pwd']; ?></td>-->
<td><?php echo $data['email']; ?></td> <td><?php echo $data['name']; ?></td>
<td><?php echo $data['lineid']; ?></td> <td><?php echo $data['tel']; ?></td>
<td><?php echo $data['wechatid']; ?></td> <td><?php echo $data['address']; ?></td>
<td><a href="<?php echo $data['remote_help']; ?>">連結<a/></td> <td><?php echo $data['email']; ?></td>
<td><?php echo $data['repairerid']; ?></td> <td><?php echo $data['lineid']; ?></td>
<td><?php echo $data['manager']; ?></td> <td><?php echo $data['wechatid']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><a href="<?php echo $data['remote_help']; ?>">連結<a /></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['repairerid']; ?></td>
<?php if ($user_auth&2) { ?> <td><?php echo $data['manager']; ?></td>
<td> <td><?php echo $data['creater']; ?></td>
<p> <td><?php echo $data['create_at']; ?></td>
<a href="account-edit.php?id=<?php echo $data['id']; ?>&function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <?php if ($user_auth & 2) { ?>
<span class="glyphicon glyphicon-pencil"></span> <td>
</a> <p>
</p> <a href="account-edit.php?id=<?php echo $data['id']; ?>&function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
</td> <span class="glyphicon glyphicon-pencil"></span>
<!--<td> </a>
<p> </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?')"> </td>
<span class="glyphicon glyphicon-remove"></span> <!--<td>
</a> <p>
</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?')">
</td>--> <span class="glyphicon glyphicon-remove"></span>
<?php } ?> </a>
</tr> </p>
<?php endforeach; ?> </td>-->
</tbody> <?php } ?>
</table> <td>
</div> <button type="button" class="btn" onclick="sendJuniorStaffDoc(<?php echo $data['id']; ?>)">寄送</button>
</td>
<?php </tr>
<?php endforeach; ?>
else: </tbody>
echo "<h2>There is no record!</h2>"; </table>
endif; </div>
<script>
#代表結束連線 function sendJuniorStaffDoc(id) {
mysqli_close($link); $.ajax({
url: window.location.origin + '/wms/account-index-submit.php',
include "footer.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";
?>

452
wms/account-receivable-check.php

@ -1,199 +1,255 @@
<?php <?php
include "./header.php"; include "./header.php";
//企業名稱 統一編號 聯絡地址 $Bill = $_POST['Bill'];
$Bill = $_POST['Bill']; $Bill = json_decode($Bill, true);
$Bill = json_decode($Bill, true); print_r($Bill);
$sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
$pay_received = mysqli_query($link, $sql_received); // $sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
$had_received = 0; // $pay_received = mysqli_query($link, $sql_received);
if (mysqli_num_rows($pay_received) == 0) { // $had_received_amount = intval(0);
foreach ($pay_received as $received) { // $had_invoice_amount=intval(0);
$had_received += $received['received_amount']; // $status_summary = intval(0);
} // if (mysqli_num_rows($pay_received) > 0) {
} // foreach ($pay_received as $received) {
$unreceived = $Bill[12] - $had_received; // $had_received_amount += intval($received['received_amount']);
$data = json_encode($Bill); // $had_invoice_amount += intval($received['invoice_amount']);
?> // if(in_array(intval($received['status']),array(0,4,5,99))){
<style> // $tem_status = intval(0);
th { // }else{
text-align: center; // $tem_status = intval($received['status']);
} // }
// if($status_summary < $tem_status){
td { // $status_summary = $tem_status;
text-align: right; // }
} // }
</style> // }
<div style="width: 90%;">
// $unreceived_amount = intval($Bill[12]) - intval($had_received_amount);
<div style="padding-left: 2rem; padding-bottom: 1rem;"> // $uninvoice_amount = intval($Bill[12]) - intval($had_invoice_amount);
<a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg"> // $Bill[19] =$had_invoice_amount;
<span class="glyphicon glyphicon-home"></span> // $Bill[20] =$had_received_amount;
</a> // $Bill[21] =$uninvoice_amount;
</div> // $Bill[22] =$unreceived_amount;
// $Bill[23] =$status_summary;
</div> $data = json_encode($Bill);
<div class="container"> ?>
<div class="text-center" style="margin-bottom: 20px;"> <style>
<h3><strong><?= $Bill[4] ?></strong></h3> th {
</div> text-align: center;
<form class="form-horizontal"> }
<div class="form-group">
<div class="col-md-3"> td {
<label for="BillNo">合約號</label> text-align: right;
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[0] ?>" disabled> }
</div> </style>
<div class="col-md-3"> <div style="width: 90%;">
<label for="DeptId">部門</label>
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled> <div style="padding-left: 2rem; padding-bottom: 1rem;">
</div> <a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg">
<div class="col-md-3"> <span class="glyphicon glyphicon-home"></span>
<label for="Manager">經理</label> </a>
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled> </div>
</div>
<div class="col-md-3"> </div>
<label for="PersonName">營業員</label> <div class="container">
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[3] ?>" disabled> <div class="text-center" style="margin-bottom: 20px;">
</div> <h3><strong><?= $Bill[4] ?></strong></h3>
</div>
</div> <form class="form-horizontal">
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="EnterpriseName">抬頭</label> <label for="BillNo">合約號</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[14] ?>" disabled> <input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[10] ?>" disabled>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="TaxNo">統一編號</label> <label for="DeptId">部門</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" disabled> <input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled>
</div> </div>
<div class="col-md-6"> <div class="col-md-3">
<label for="ContactAddress">聯絡地址</label> <label for="Manager">經理</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[16] ?>" disabled> <input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled>
</div> </div>
</div> <div class="col-md-3">
<div> <label for="PersonName">營業員</label>
<label for="detail">狀態</label> <input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[4] ?>" disabled>
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill[13]) ?></textarea> </div>
</div>
</form> </div>
<div style="width: auto; margin-top: 30px;"> <div class="form-group">
<table class="table table-striped table-bordered" style="width:100%;"> <div class="col-md-3">
<thead> <label for="EnterpriseName">抬頭</label>
<tr> <input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[6] ?>" disabled>
<th>目前應收</th> </div>
<th>已開發票金額</th> <div class="col-md-3">
<th>未開發票金額</th> <label for="TaxNo">統一編號</label>
<th>已收金額</th> <input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[7] ?>" disabled>
<th>未收金額</th> </div>
<div class="col-md-6">
</tr> <label for="ContactAddress">聯絡地址</label>
</thead> <input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[8] ?>" disabled>
<tbody> </div>
<tr> </div>
<td><?= number_format(round($Bill[12])) ?></td> <div>
<td><?= number_format(round($Bill[19])) ?></td> <label for="detail">狀態</label>
<td><?= number_format(round($Bill[21])) ?></td> <textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill['facilities']) ?></textarea>
<td><?= number_format(round($Bill[20])) ?></td> </div>
<td><?= number_format(round($Bill[22])) ?></td> </form>
<div style="width: auto; margin-top: 30px;">
</tr> <table class="table table-striped table-bordered" style="width:100%;">
</tbody> <thead>
</table> <tr>
</div> <th>目前應收</th>
<!-- <th>已開發票金額</th>
<th>未開發票金額</th>
<div style="width: auto; margin-top: 30px;"> <th>已收金額</th>
<table class="table table-striped table-bordered" style="width:100%;"> <th>未收金額</th> -->
<thead>
<tr> </tr>
<th>簽約款</th> </thead>
<th>二次款</th> <tbody>
<th>貨抵工地款</th> <tr>
<th>安裝款</th> <td><?= number_format(round($Bill['receivable_budget'])) ?></td>
<th>試車款</th> <!-- <td><?= number_format(round($Bill[19])) ?></td>
<th>官檢款</th> <td><?= number_format(round($Bill[21])) ?></td>
<th>交車款</th> <td><?= number_format(round($Bill[20])) ?></td>
<td><?= number_format(round($Bill[22])) ?></td> -->
</tr>
</thead> </tr>
<tbody> </tbody>
<tr> </table>
<td><?= number_format(round($Bill[5])) ?></td> </div>
<td><?= number_format(round($Bill[6])) ?></td>
<td><?= number_format(round($Bill[7])) ?></td>
<td><?= number_format(round($Bill[8])) ?></td> <div style="width: auto; margin-top: 30px;">
<td><?= number_format(round($Bill[9])) ?></td> <table class="table table-striped table-bordered" style="width:100%;">
<td><?= number_format(round($Bill[10])) ?></td> <thead>
<td><?= number_format(round($Bill[11])) ?></td> <tr>
<th>簽約款</th>
</tr> <th>二次款</th>
</tbody> <th>貨抵工地款</th>
</table> <th>安裝款</th>
</div> <th>試車款</th>
</div> <th>官檢款</th>
<?php <th>交車款</th>
include "./footer.php"; <th>尾款</th>
?> </tr>
<?php </thead>
if ($user_id == "M0122") { <tbody>
?> <tr>
<button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;"> <td><?= number_format(round($Bill['sign'][1])) ?></td>
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button> <td><?= number_format(round($Bill['second'][1])) ?></td>
<?php <td><?= number_format(round($Bill['arrive'][1])) ?></td>
} <td><?= number_format(round($Bill['install'][1])) ?></td>
?> <td><?= number_format(round($Bill['tryrun'][1])) ?></td>
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;"> <td><?= number_format(round($Bill['check'][1])) ?></td>
<table class="table table-striped table-bordered" style="width:100%;"> <td><?= number_format(round($Bill['delivery'][1])) ?></td>
<thead> <td><?= number_format(round($Bill['final'][1])) ?></td>
<tr>
<th>發票日期</th> </tr>
<th>發票金額</th> </tbody>
<th>收款日期</th> </table>
<th>收款金額</th> </div>
<th>說明</th> </div>
<th style="width: 10%;">功能</th> <?php
</tr> include "./footer.php";
</thead>
<tbody> ?>
<?php if ($pay_received) { <?php
foreach ($pay_received as $received) { ?> if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) {
<tr> ?>
<td><?= $received['invoice_date'] ?></td> <button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
<td><?= number_format($received['invoice_amount']) ?></td> 新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button>
<td><?= $received['received_date'] ?></td> <?php
<td><?= number_format($received['received_amount']) ?></td> }
<td><?= $received['remark'] ?></td> ?>
<td><?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?> <div style="margin-right: 10%;margin-left: 10%; justify-content: center;">
<button type="button" onclick="create('edit',<?= $received['pay_id'] ?>)" class="btn btn-warning btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;"> <table class="table table-striped table-bordered" style="width:100%;">
<span class="glyphicon glyphicon-pencil"></span></button> <thead>
<a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm"> <tr>
<span class=" glyphicon glyphicon-trash"></span> <th>發票日期</th>
</a> <th>發票金額</th>
<?php } ?> <th>發票號碼</th>
</td> <th>收款日期</th>
</tr> <th>收款金額</th>
<?php } <th>備註</th>
} ?> <th>狀態</th>
</tbody> <?php if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) { ?>
</table> <th style="width: 10%;">功能</th>
</div> <?php } ?>
<script>
function create(type,pay_id) { </tr>
var BillData = <?= $data ?>; </thead>
var form = document.createElement("form"); <tbody>
form.method = 'POST'; <?php if ($pay_received) {
if(type === 'create'){ foreach ($pay_received as $received) { ?>
form.action = "account-receivable-received-create.php?<?= $token_link ?>"; <tr>
}else{ <td><?= $received['invoice_date'] ?></td>
form.action = "account-receivable-received-edit.php?pay_id="+pay_id+"&<?= $token_link ?>"; <td><?= number_format($received['invoice_amount']) ?></td>
} <td><?= $received['invoice_no'] ?></td>
<td><?= $received['received_date'] ?></td>
var input = document.createElement("input"); <td><?= number_format($received['received_amount']) ?></td>
input.type = "hidden"; <td><?= $received['remark'] ?></td>
input.name = "Bill"; <td style="text-align: center;">
input.value = JSON.stringify(BillData); <?php
form.appendChild(input); switch ($received['status']) {
document.body.appendChild(form); case 0:
form.submit(); 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>
<?php if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) { ?>
<td>
<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> -->
</td>
<?php } ?>
</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> </script>

76
wms/account-receivable-contract.php

@ -1,39 +1,39 @@
<?php <?php
include "header.php"; include "header.php";
// 合約收款款別名稱 // 合約收款款別名稱
$arrayData = []; $arrayData = [];
echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>"; 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 $sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName
FROM salOrderStagePay AS a FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4)"; WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4)";
$contract = $conn->query($sql_contract); $contract = $conn->query($sql_contract);
foreach ($contract as $cont) { foreach ($contract as $cont) {
if ($cont['BillNo'] == 'SO20230801002') { if ($cont['BillNo'] == 'SO20230801002') {
$BillNo = 'M231067'; $BillNo = 'M231067';
}else{ }else{
$BillNo = $cont['BillNo']; $BillNo = $cont['BillNo'];
}; };
$PayStage = $cont['PayStage']; $PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt']; $PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName']; $partnerName = $cont['BizPartnerName'];
if(isset($arrayData[$BillNo])){ if(isset($arrayData[$BillNo])){
array_push($arrayData[$BillNo], $PayStage); array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount); array_push($arrayData[$BillNo], $PayAmount);
}else{ }else{
$arrayData[$BillNo][0] = $BillNo; $arrayData[$BillNo][0] = $BillNo;
$arrayData[$BillNo][1] = $partnerName; $arrayData[$BillNo][1] = $partnerName;
array_push($arrayData[$BillNo], $PayStage); array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount); array_push($arrayData[$BillNo], $PayAmount);
} }
}; };
foreach($arrayData as $data){ foreach($arrayData as $data){
foreach($data as $value){ foreach($data as $value){
echo $value.";"; echo $value.";";
} }
echo "</br>"; echo "</br>";
} }

51
wms/account-receivable-excel.php

@ -0,0 +1,51 @@
<?php
include "./header.php";
require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$Bill = $_POST['Bill'];
$array_data = array();
$Bill = json_decode($Bill, true);
foreach($Bill as $key=>$value){
// for ($i = 0; $i < 17; $i++) {
// $value[$i] = (isset($value[$i])) ? $value[$i] : 0;
// }
$array_data[$key][0] = $key;
$array_data[$key][1] = $value[1];
$array_data[$key][2] = $value[2];
$array_data[$key][3] = $value[4];
$array_data[$key][4] = $value[5];
$array_data[$key][5] = $value[7];
$array_data[$key][6] = $value[8];
$array_data[$key][7] = $value[6];
$array_data[$key][8] = $value['sign'][1];
$array_data[$key][9] = $value['second'][1];
$array_data[$key][10] = $value['arrive'][1];
$array_data[$key][11] = $value['install'][1];
$array_data[$key][12] = $value['tryrun'][1];
$array_data[$key][13] = $value['check'][1];
$array_data[$key][14] = $value['delivery'][1];
$array_data[$key][15] = $value['final'][1];
$array_data[$key][16] = $value['receivable_budget'];
$array_data[$key][17] = str_replace('<br>','; ',$value['facilities']);
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$colomnHeader = ['合約號','部門','經理','營業員','客戶名稱','統一編號','聯絡地址','抬頭','簽約款',
'二次款','貨抵工地款','安裝款','試車款','官檢款','交車款','尾款','目前應收','作番狀態'];
$sheet->fromArray($colomnHeader,NULL,'A1');
$rowIndex = 2;
foreach($array_data as $key => $value){
$sheet->fromArray([$value], NULL, 'A' . $rowIndex);
$sheet->getStyle('R' . $rowIndex)->getAlignment()->setWrapText(true);
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable.xlsx';
$writer->save($excelFileName);
?>
<script>
window.location.href = "account-receivable-index.php?<?= $token_link ?>";
</script>

746
wms/account-receivable-index.php

@ -1,345 +1,403 @@
<?php <?php
include "header.php"; include "header.php";
require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
$follower = find_follow($user_id);
use PhpOffice\PhpSpreadsheet\Spreadsheet; $arrayData = [];
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls; $receivable_array = [];
//use PhpOffice\PhpSpreadsheet\Reader\Xls; $sql_received = "SELECT * FROM arWriteOffBillDetail WHERE (DATALENGTH(OrderBillNo) >0)";
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId,
$follower = find_follow($user_id); c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a
$arrayData = []; LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
$receivable_array = []; LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId
$received_array = []; WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) ";
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
//arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交 $sql_contract .= "AND (s.PersonId = '$user_id'";
$sql_received = "SELECT * from account_received"; $sql_received .= " AND (PersonId = '$user_id'";
if (count($follower) > 0) {
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName, s.PersonId, $column_str = "('$user_id'" . ",'";
c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a $column_str .= implode("','", $follower);
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo $column_str .= "')";
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId $sql_contract .= " OR s.PersonId IN $column_str)";
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) "; $sql_received .= " OR PersonId IN $column_str)";
if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) { } else {
$sql_contract .= "AND (s.PersonId = '$user_id'"; $sql_contract .= ")";
$sql_received .= " WHERE person_id = '$user_id'"; $sql_received .= ")";
if (count($follower) > 0) { };
$column_str = "('$user_id'" . ",'"; }
$column_str .= implode("','", $follower); $sign60 = array('簽訂後60天', '簽約60日', '簽約後60天', '簽訂後60日內', '訂金支付後60天');
$column_str .= "')"; $sign90 = array('簽約後90天', '簽約後90日', '簽訂後90天');
$sql_contract .= " OR s.PersonId IN $column_str)"; $sign120 = array('簽約後120天', '簽約後120日', '簽訂後120天');
$sql_received .= " OR person_id IN $column_str)"; $contract = $conn->query($sql_contract);
} else { $received_array = $conn->query($sql_received);
$sql_contract .= ")";
}; // 取收款資料 account_received
} // $received_data = mysqli_query($link, $sql_received);
// foreach ($received_data as $received) {
$contract = $conn->query($sql_contract); // if ($received['BillNo'] == 'SO20230801001') {
$received_data = mysqli_query($link, $sql_received); // $BillNo = 'M230947';
foreach ($received_data as $received) { // } elseif ($received['BillNo'] == 'SO20230801002') {
if ($received['BillNo'] == 'SO20230801001') { // $BillNo = 'M231067';
$BillNo = 'M230947'; // } else {
} elseif ($received['BillNo'] == 'SO20230801002') { // $BillNo = $received['BillNo'];
$BillNo = 'M231067'; // };
} else { // if (isset($received_array[$BillNo])) {
$BillNo = $received['BillNo']; // $received_array[$BillNo][0] += $received['invoice_amount'];
}; // $received_array[$BillNo][1] += $received['received_amount'];
if (isset($received_array[$BillNo])) { // $received['status'] = (intval($received['status']) < 4) ? intval($received['status']) : 0;
$received_array[$BillNo][0] += $received['invoice_amount']; // if ($received_array[$BillNo][2] < intval($received['status'])) {
$received_array[$BillNo][1] += $received['received_amount']; // $received_array[$BillNo][2] = intval($received['status']);
} else { // }
$received_array[$BillNo][0] = $received['invoice_amount']; // } else {
$received_array[$BillNo][1] = $received['received_amount']; // $received_array[$BillNo][0] = $received['invoice_amount'];
} // $received_array[$BillNo][1] = $received['received_amount'];
} // $received_array[$BillNo][2] = (intval($received['status']) < 4) ? intval($received['status']) : 0;
foreach ($contract as $cont) { // }
// print_r($cont); // }
// echo "<br>";
if ($cont['BillNo'] == 'SO20230801001') { // 將T8合約收款階段資料依據款別分類放進arraData裡
$BillNo = 'M230947'; foreach ($contract as $cont) {
} elseif ($cont['BillNo'] == 'SO20230801002') { if ($cont['BillNo'] == 'SO20230801001') {
$BillNo = 'M231067'; $BillNo = 'M230947';
} else { } elseif ($cont['BillNo'] == 'SO20230801002') {
$BillNo = $cont['BillNo']; $BillNo = 'M231067';
}; } else {
$PayStage = $cont['PayStage']; $BillNo = $cont['BillNo'];
$PayAmount = $cont['PlanPayAmt']; };
$partnerName = $cont['BizPartnerName']; $PayStage = $cont['PayStage'];
$EnterpriseName = $cont['EnterpriseName']; $PlanPayDate = $cont['PlanPayDate'];
$TaxNo = $cont['TaxNo']; $PayAmount = $cont['PlanPayAmt'];
$ContactAddress = $cont['ContactAddress']; $partnerName = $cont['BizPartnerName'];
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 $EnterpriseName = $cont['EnterpriseName'];
if (isset($arrayData[$BillNo])) { $TaxNo = $cont['TaxNo'];
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) { $ContactAddress = $cont['ContactAddress'];
$arrayData[$BillNo][5] = $PayAmount; //['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) { //['tryrun'] 0 試車款名 1試車金額 2 試車收款日期 ['check'] 0 官檢款名 1 官檢金額 2 官檢收款日期 ['delivery'] 0 交車款名 1 交車金額 2 交車收款日期 ['final'] 0 尾款名 1 尾款金額 2 尾款收款日期
$arrayData[$BillNo][4] = $PayAmount; if (!(isset($arrayData[$BillNo]))) {
} elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) { // 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址
$arrayData[$BillNo][6] = $PayAmount; $arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
} elseif (stristr($PayStage, '試車') || stristr($PayStage, '驗收完成')) { $arrayData[$BillNo][5] = $partnerName;
$arrayData[$BillNo][8] = $PayAmount; $arrayData[$BillNo][6] = $EnterpriseName;
} elseif (stristr($PayStage, '安裝')) { $arrayData[$BillNo][7] = $TaxNo;
$arrayData[$BillNo][7] = $PayAmount; $arrayData[$BillNo][8] = $ContactAddress;
} elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) { $arrayData[$BillNo]['received']= array();
$arrayData[$BillNo][10] = $PayAmount; $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;
} elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) { $arrayData[$BillNo]['facilities'] = "";
$arrayData[$BillNo][9] = $PayAmount; $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;
} else { }
$arrayData[$BillNo][12] = $PayAmount; if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
} $arrayData[$BillNo]['second'][0] = $PayStage;
} else { $arrayData[$BillNo]['second'][1] = $PayAmount;
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; $arrayData[$BillNo]['second'][2] = $PlanPayDate;
$arrayData[$BillNo][3] = $partnerName; if (isset($arrayData[$BillNo]['sign'][2]) && !is_null($arrayData[$BillNo]['sign'][2])) {
$arrayData[$BillNo][13] = $EnterpriseName; $signtime = strtotime(strval($arrayData[$BillNo]['sign'][2]));
$arrayData[$BillNo][14] = $TaxNo; if (in_array($PayStage, $sign60)) {
$arrayData[$BillNo][15] = $ContactAddress; $secondtime = $signtime + (60 * 86400);
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) { $secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo][5] = $PayAmount; $arrayData[$BillNo]['second'][2] = intval($secondtime);
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) { } elseif (in_array($PayStage, $sign90)) {
$arrayData[$BillNo][4] = $PayAmount; $secondtime = $signtime + (90 * 86400);
} elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) { $secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo][6] = $PayAmount; $arrayData[$BillNo]['second'][2] = intval($secondtime);
} elseif (stristr($PayStage, '試車') || stristr($PayStage, '驗收完成')) { } elseif (in_array($PayStage, $sign120)) {
$arrayData[$BillNo][8] = $PayAmount; $secondtime = $signtime + (120 * 86400);
} elseif (stristr($PayStage, '安裝')) { $secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo][7] = $PayAmount; $arrayData[$BillNo]['second'][2] = intval($secondtime);
} elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) { } elseif (stristr($PayStage, '簽訂後30天')) {
$arrayData[$BillNo][10] = $PayAmount; $secondtime = $signtime + (30 * 86400);
} elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) { $secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo][9] = $PayAmount; $arrayData[$BillNo]['second'][2] = intval($secondtime);
} else { }
$arrayData[$BillNo][12] = $PayAmount; }
} } elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工')) {
} $arrayData[$BillNo]['sign'][0] = $PayStage;
} $arrayData[$BillNo]['sign'][1] = $PayAmount;
$arrayData[$BillNo]['sign'][2] = $PlanPayDate;
foreach ($arrayData as $key => $value) { } elseif (stristr($PayStage, '試車')) {
$sql = "SELECT $arrayData[$BillNo]['tryrun'][0] = $PayStage;
tmp2.*, $arrayData[$BillNo]['tryrun'][1] = $PayAmount;
d.name AS depart_name $arrayData[$BillNo]['tryrun'][2] = $PlanPayDate;
FROM( } elseif (stristr($PayStage, '安裝') || stristr($PayStage, '貨抵工地且完工')) {
SELECT $arrayData[$BillNo]['install'][0] = $PayStage;
a.manager, $arrayData[$BillNo]['install'][1] = $PayAmount;
a2.name as manager_name, $arrayData[$BillNo]['install'][2] = $PlanPayDate;
a.name, } elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) {
a.department_id, $arrayData[$BillNo]['arrive'][0] = $PayStage;
w.salesid, $arrayData[$BillNo]['arrive'][1] = $PayAmount;
w.contractno, $arrayData[$BillNo]['arrive'][2] = $PlanPayDate;
w.facilityno, } elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) {
w.estimated_shipping_date, $arrayData[$BillNo]['delivery'][0] = $PayStage;
w.actual_tofactory_date, $arrayData[$BillNo]['delivery'][1] = $PayAmount;
w.real_arrival_date, $arrayData[$BillNo]['delivery'][2] = $PlanPayDate;
w.install_end_date, } elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) {
w.tryrun_end_date, $arrayData[$BillNo]['check'][0] = $PayStage;
w.official_check_date, $arrayData[$BillNo]['check'][1] = $PayAmount;
w.delivery_date $arrayData[$BillNo]['check'][2] = $PlanPayDate;
from wipwholestatus AS w } elseif (stristr($PayStage, '驗收完成')) {
left join account AS a $arrayData[$BillNo]['final'][0] = $PayStage;
ON w.salesid = a.accountid $arrayData[$BillNo]['final'][1] = $PayAmount;
left join account AS a2 $arrayData[$BillNo]['final'][2] = $PlanPayDate;
ON a2.accountid = a.manager } else {
where w.status = '1' AND w.contractno='" . $key . "'" . " $arrayData[$BillNo]['other'][1] = $PayAmount;
$arrayData[$BillNo]['other'][2] = $PlanPayDate;
)AS tmp2 }
left join ( }
SELECT DISTINCT $sql = "SELECT
department_id, tmp2.*,
name d.name AS depart_name
FROM department FROM(
SELECT
) AS d a.manager,
ON d.department_id = tmp2.department_id"; a2.name as manager_name,
$facitities = ""; a.name,
$total_facility_num = 0; a.department_id,
$arrive_num = 0; w.salesid,
$tryrun_num = 0; w.contractno,
$delivery_num = 0; w.facilityno,
$official_num = 0; w.estimated_shipping_date,
$wipwhole_array = mysqli_query($link, $sql); w.actual_tofactory_date,
foreach ($wipwhole_array as $wip) { w.real_arrival_date,
$value[0] = $wip['depart_name']; w.install_end_date,
$value[1] = $wip['manager_name']; w.tryrun_end_date,
$value[2] = $wip['name']; w.official_check_date,
$value[16] = isset($wip['department_id']) ? $wip['department_id'] : ''; w.delivery_date
$value[17] = isset($wip['salesid']) ? $wip['salesid'] : ''; from wipwholestatus AS w
if ($wip['delivery_date'] != NULL) { left join account AS a
$facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>"; ON w.salesid = a.accountid
$total_facility_num += 1; left join account AS a2
$arrive_num += 1; ON a2.accountid = a.manager
$tryrun_num += 1; where w.status = '1' AND w.contract_type='A'
$official_num += 1; )AS tmp2
$delivery_num += 1; left join (
} elseif ($wip['official_check_date'] != NULL) { SELECT DISTINCT
$facitities .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>"; department_id,
$total_facility_num += 1; name
$arrive_num += 1; FROM department
$tryrun_num += 1;
$official_num += 1; ) AS d
} elseif ($wip['tryrun_end_date'] != NULL) { ON d.department_id = tmp2.department_id";
$facitities .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>"; $wipwhole_array = mysqli_query($link, $sql);
$total_facility_num += 1; foreach ($wipwhole_array as $wip) {
$arrive_num += 1; if (isset($arrayData[$wip['contractno']])) {
$tryrun_num += 1; $arrayData[$wip['contractno']][0] = $wip['department_id'];;
} elseif ($wip['install_end_date'] != NULL) { $arrayData[$wip['contractno']][1] = $wip['depart_name'];
$facitities .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>"; $arrayData[$wip['contractno']][2] = $wip['manager_name'];
$total_facility_num += 1; $arrayData[$wip['contractno']][3] = $wip['salesid'];
$arrive_num += 1; $arrayData[$wip['contractno']][4] = $wip['name'];
} elseif ($wip['real_arrival_date'] != NULL) { $arrayData[$wip['contractno']][10] = $wip['contractno'];
$facitities .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>"; if (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前30天')) {
$total_facility_num += 1; $estimate_delivery_time = strtotime($wip['estimated_shipping_date']);
$arrive_num += 1; $secondtime = $estimate_delivery_time - (30 * 86400);
} elseif ($wip['actual_tofactory_date'] != NULL) { $secondtime = date('Ymd', $secondtime);
$facitities .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日) <br>"; $arrayData[$wip['contractno']]['second'][2] = intval($secondtime);
$total_facility_num += 1; } elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前90天')) {
} elseif ($wip['estimated_shipping_date'] != NULL) { $estimate_delivery_time = strtotime($wip['estimated_shipping_date']);
$facitities .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) <br>"; $secondtime = $estimate_delivery_time - (90 * 86400);
$total_facility_num += 1; $secondtime = date('Ymd', $secondtime);
} else { $arrayData[$wip['contractno']]['second'][2] = intval($secondtime);
$facitities .= $wip['facilityno'] . " (預計到港日待確認) <br>"; }
$total_facility_num += 1; if ($wip['delivery_date'] != NULL) {
} $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
} $arrayData[$wip['contractno']]['total_facility_num'] += 1;
$receivable_budget = 0; $arrayData[$wip['contractno']]['delivery_num'] += 1;
//這是錢 4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 $arrayData[$wip['contractno']]['check_num'] += 1;
//這是數量 arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交 $arrayData[$wip['contractno']]['tryrun_num'] += 1;
if ($total_facility_num > 0) { $arrayData[$wip['contractno']]['install_num'] += 1;
$receivable_budget = $value[4] + ($value[5] + $value[6]) * ($arrive_num / $total_facility_num) + $arrayData[$wip['contractno']]['arrive_num'] += 1;
($value[7] + $value[8]) * ($tryrun_num / $total_facility_num) + ($value[9]) * ($official_num / $total_facility_num) $arrayData[$wip['contractno']]['second_num'] += 1;
+ ($value[10]) * ($delivery_num / $total_facility_num); } elseif ($wip['official_check_date'] != NULL) {
$uninvoice_budget = $receivable_budget; $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$unreceived_budget = $receivable_budget; $arrayData[$wip['contractno']]['total_facility_num'] += 1;
$received_invoice = 0; $arrayData[$wip['contractno']]['check_num'] += 1;
$received_budget = 0; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
if (isset($received_array[$key][0])) { $arrayData[$wip['contractno']]['install_num'] += 1;
$uninvoice_budget = $receivable_budget - $received_array[$key][0]; $arrayData[$wip['contractno']]['arrive_num'] += 1;
$received_invoice = $received_array[$key][0]; $arrayData[$wip['contractno']]['second_num'] += 1;
}else{ } elseif ($wip['tryrun_end_date'] != NULL) {
$uninvoice_budget = $receivable_budget; $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
} $arrayData[$wip['contractno']]['total_facility_num'] += 1;
if (isset($received_array[$key][1])) { $arrayData[$wip['contractno']]['tryrun_num'] += 1;
$unreceived_budget = $receivable_budget - $received_array[$key][1]; $arrayData[$wip['contractno']]['install_num'] += 1;
$received_budget = $received_array[$key][1]; $arrayData[$wip['contractno']]['arrive_num'] += 1;
}else{ $arrayData[$wip['contractno']]['second_num'] += 1;
$unreceived_budget = $receivable_budget; } elseif ($wip['install_end_date'] != NULL) {
} $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
} $arrayData[$wip['contractno']]['total_facility_num'] += 1;
if (isset($value[0]) && ($value[0] != 0)) { $arrayData[$wip['contractno']]['install_num'] += 1;
$receivable_array[$key] = [$key, $value[0], $value[1], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $value[9], $arrayData[$wip['contractno']]['arrive_num'] += 1;
$value[10], $receivable_budget, $facitities, $value[13], $value[14], $value[15], $value[16], $value[17], $received_invoice, $received_budget, $arrayData[$wip['contractno']]['second_num'] += 1;
$uninvoice_budget, $unreceived_budget]; } elseif ($wip['real_arrival_date'] != NULL) {
} $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
} $arrayData[$wip['contractno']]['total_facility_num'] += 1;
$data = json_encode($receivable_array); $arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態</br>"; } elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) {
?> if ($wip['estimated_shipping_date'] != NULL) {
<style> $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出貨日) <br>";
table { $arrayData[$wip['contractno']]['total_facility_num'] += 1;
table-layout: fixed; $arrayData[$wip['contractno']]['second_num'] += 1;
width: 100%; } elseif ($wip['actual_tofactory_date'] != NULL) {
} $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
td { $arrayData[$wip['contractno']]['second_num'] += 1;
word-wrap: break-word; } else {
} $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
img { $arrayData[$wip['contractno']]['second_num'] += 1;
width: 125px; }
} } elseif ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) <br>";
.width_style_1 { $arrayData[$wip['contractno']]['total_facility_num'] += 1;
width: 125px; } else {
} $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計到港日待確認) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
table { }
width: 100%; }
} }
#table_index_filter {
float: right; foreach ($arrayData as &$value) {
} if ($value['total_facility_num'] > 0) {
$value['receivable_budget'] = $value['sign'][1] + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
#table_index_paginate { ($value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num'])) + ($value['install'][1] * ($value['install_num'] / $value['total_facility_num'])) +
float: right; ($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']));
}
label { }
display: inline-flex; // array_push($arrayData[$wip['contractno']]['received'], ['assaaa',123124,'sdrfrqa']);
margin-bottom: .5rem;
margin-top: .5rem; foreach($received_array as $received){
} if(isset($arrayData[$received['OrderBillNo']])){
</style> array_push($arrayData[$received['OrderBillNo']]['received'], [$received['BillNo'],$received['WriteOffBizPartnerId'],$received['OrderBillNo'],]);
<div style="width:98%;margin:1%">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;"> }
<thead> }
<tr>
<th style="width: 120px;">合約號</th> $data = json_encode($arrayData);
<th style="width: 120px;">部門</th>
<th style="width: 80px;">經理</th> ?>
<th style="width: 80px;">營業員</th> <style>
<th>客戶名稱</th> table {
<!-- <th style="width: 100px;">簽約款</th> table-layout: fixed;
<th style="width: 100px;">二次款</th> width: 100%;
<th style="width: 100px;">貨抵工地款</th> }
<th style="width: 100px;">安裝款</th>
<th style="width: 100px;">試車款</th> td {
<th style="width: 100px;">官檢款</th> word-wrap: break-word;
<th style="width: 100px;">交車款</th> --> }
<th style="width: 100px;">目前應收</th>
<th style="width: 150px;">未開發票金額</th> img {
<th style="width: 100px;">未收金額</th> width: 125px;
<th>狀態</th> }
<th style="width: 100px;">操作</th>
</tr> .width_style_1 {
</thead> width: 125px;
<tbody> }
<?php
foreach ($receivable_array as $contract) { table {
?> width: 100%;
<tr> }
<th><?= $contract[0] ?></th>
<td><?= $contract[1] ?></td> #table_index_filter {
<td><?= $contract[2] ?></td> float: right;
<td><?= $contract[3] ?></td> }
<td><?= $contract[4] ?></td>
<!-- <td><?= round($contract[5]) ?></td> #table_index_paginate {
<td><?= round($contract[6]) ?></td> float: right;
<td><?= round($contract[7]) ?></td> }
<td><?= round($contract[8]) ?></td>
<td><?= round($contract[9]) ?></td> label {
<td><?= round($contract[10]) ?></td> display: inline-flex;
<td><?= round($contract[11]) ?></td> --> margin-bottom: .5rem;
<td style="text-align: end;"><?= number_format(round($contract[12])) ?></td> margin-top: .5rem;
<td style="text-align: end;"><?= number_format(round($contract[21])) ?></td>
<td style="text-align: end;"><?= number_format(round($contract[22])) ?></td> }
<td style="text-align: start;"><?= $contract[13] ?></td> </style>
<td><button type="button" onclick="sendData('<?= $contract[0] ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button> <button type="button" onclick="downloadData()" class="btn btn-warning btn-lg pull-right"><span class="glyphicon glyphicon-download-alt"></span></button>
</td>
</tr> <div style="width:98%;margin:1%">
<?php <table id="table_index" class="table table-striped table-bordered" style="width:100%;">
} <thead>
?> <tr>
</tbody> <th style="width: 120px;">合約號</th>
</table> <th style="width: 120px;">部門</th>
</div> <th style="width: 80px;">經理</th>
<script> <th style="width: 80px;">營業員</th>
function sendData(BillNo) { <th>客戶名稱</th>
console.log(BillNo); <!-- <th style="width: 100px;">簽約款</th>
var BillData = <?= $data ?>; <th style="width: 100px;">二次款</th>
var Bill = BillData[BillNo]; <th style="width: 100px;">貨抵工地款</th>
console.log(Bill); <th style="width: 100px;">安裝款</th>
console.log(typeof(Bill)); <th style="width: 100px;">試車款</th>
var form = document.createElement("form"); <th style="width: 100px;">官檢款</th>
form.method = 'POST'; <th style="width: 100px;">交車款</th>
form.action = "account-receivable-check.php?<?= $token_link ?>"; <th style="width: 100px;">尾款</th> -->
var input = document.createElement("input"); <th style="width: 100px;">目前應收</th>
input.type = "hidden"; <!-- <th style="width: 150px;">未開發票金額</th>
input.name = "Bill"; <th style="width: 100px;">未收金額</th> -->
input.value = JSON.stringify(Bill); <th>作番狀態</th>
form.appendChild(input); <!-- <th style="width: 100px;">收款狀態</th> -->
document.body.appendChild(form); <th style="width: 100px;">操作</th>
form.submit(); </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 style="text-align: end;"><?= number_format(round($value['sign'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['second'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['arrive'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['install'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['tryrun'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['check'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['delivery'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['final'][1])) ?></td> -->
<td style="text-align: end;"><?= number_format(round($value['receivable_budget'])) ?></td>
<!-- <td style="text-align: end;"><?= number_format(round($value['total_facility_num'])) ?></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 downloadData() {
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 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> </script>

243
wms/account-receivable-received-create.php

@ -1,121 +1,124 @@
<?php <?php
include "./header.php"; include "./header.php";
$Bill = $_POST['Bill']; $Bill = $_POST['Bill'];
$BillData = json_decode($Bill, true); $BillData = json_decode($Bill, true);
?> ?>
<div style="width: 90%;"> <div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;"> <div style="padding-left: 2rem; padding-bottom: 1rem;">
<button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button> <button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<div class="text-center"> <div class="text-center">
<h3><strong><?= $BillData[4] ?></strong></h3> <h3><strong><?= $BillData[4] ?></strong></h3>
<h4>新增收款資訊</h4> <h4>新增收款資訊</h4>
</div> </div>
<form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=create&<?= $token_link ?>" enctype="multipart/form-data"> <form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=create&<?= $token_link ?>" enctype="multipart/form-data">
<div class="form-group" style="margin-left: 1%;margin-right: 1%;"> <div class="form-group" style="margin-left: 1%;margin-right: 1%;">
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="BillNo">合約號</label> <label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled> <input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="DeptName">部門</label> <label for="DeptName">部門</label>
<input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled> <input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="ManagerName">經理</label> <label for="ManagerName">經理</label>
<input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled> <input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="PersonName">營業員</label> <label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled> <input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="EnterpriseName">抬頭</label> <label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled> <input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="TaxNo">統一編號</label> <label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled> <input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label for="ContactAddress">聯絡地址</label> <label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled> <input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="InvoiceDate">發票開立日期</label> <label for="InvoiceDate">發票開立日期</label>
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" > <input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="InvoiceAmount">發票金額</label> <label for="InvoiceAmount">發票金額</label>
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" > <input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="InvoiceNo">發票號碼</label> <label for="InvoiceNo">發票號碼</label>
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" > <input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" >
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="ReceivedDate">收款日期</label> <label for="ReceivedDate">收款日期</label>
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" > <input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="ReceivedAmount">收款金額</label> <label for="ReceivedAmount">收款金額</label>
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" > <input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="remark">備註</label> <label for="remark">備註</label>
<input type="text" class="form-control" id="remark" name="remark" > <input type="text" class="form-control" id="remark" name="remark" >
</div> </div>
</div> </div>
<input type="hidden" name="DeptId" value="<?= $BillData[17] ?>"> <input type="hidden" name="DeptId" value="<?= $BillData[17] ?>">
<input type="hidden" name="PersonId" value="<?= $BillData[18] ?>"> <input type="hidden" name="PersonId" value="<?= $BillData[18] ?>">
<input type="hidden" name="CustName" value="<?= $BillData[4] ?>"> <input type="hidden" name="CustName" value="<?= $BillData[4] ?>">
</div> <input type="hidden" name="Bill" id="Bill" value="">
<div class="form-group"> </div>
<div class="col-md-3"> <div class="form-group">
</div> <div class="col-md-3">
<div class="col-md-9"> </div>
<button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button> <div class="col-md-9">
</div> <button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button>
</div> </div>
</form> </div>
</div> </form>
</div>
<script>
function backToIndex() { <script>
var Bill = <?= $Bill ?>; function backToIndex() {
var form = document.createElement("form"); var Bill = <?= $Bill ?>;
form.method = 'POST'; var form = document.createElement("form");
form.action = "account-receivable-check.php?<?= $token_link ?>"; form.method = 'POST';
var input = document.createElement("input"); form.action = "account-receivable-check.php?<?= $token_link ?>";
input.type = "hidden"; var input = document.createElement("input");
input.name = "Bill"; input.type = "hidden";
input.value = JSON.stringify(Bill); input.name = "Bill";
form.appendChild(input); input.value = JSON.stringify(Bill);
document.body.appendChild(form); form.appendChild(input);
form.submit(); document.body.appendChild(form);
} form.submit();
}
function send() {
event.preventDefault(); function send() {
$("#BillNo").prop("disabled", false); event.preventDefault();
$("#DeptName").prop("disabled", false); $("#BillNo").prop("disabled", false);
$("#ManagerName").prop("disabled", false); $("#DeptName").prop("disabled", false);
$("#PersonName").prop("disabled", false); $("#ManagerName").prop("disabled", false);
$("#PersonName").prop("disabled", false);
$("#pay_received").submit(); var Bill = <?= $Bill ?>;
} Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script> </script>

261
wms/account-receivable-received-edit.php

@ -1,121 +1,142 @@
<?php <?php
include "./header.php"; include "./header.php";
$Bill = $_POST['Bill']; $Bill = $_POST['Bill'];
$BillData = json_decode($Bill, true); $BillData = json_decode($Bill, true);
$pay_id = $_GET['pay_id']; $pay_id = $_GET['pay_id'];
// echo $pay_id."<br>"; // echo $pay_id."<br>";
// print_r($BillData); // print_r($BillData);
$sql_pay = "SELECT * from account_received where pay_id = '$pay_id'"; $sql_pay = "SELECT * from account_received where pay_id = '$pay_id'";
$pay = mysqli_query($link, $sql_pay); $pay = mysqli_query($link, $sql_pay);
$pay = mysqli_fetch_assoc($pay); $pay = mysqli_fetch_assoc($pay);
?> ?>
<div style="width: 90%;"> <div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;"> <div style="padding-left: 2rem; padding-bottom: 1rem;">
<button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button> <button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button>
</div> </div>
</div> </div>
<div class="container">
<div class="text-center">
<h3><strong><?= $BillData[4] ?></strong></h3> <div class="container">
<h4>編輯收款資訊</h4> <div class="text-center">
</div> <h3><strong><?= $BillData[4] ?></strong></h3>
<form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=edit&<?= $token_link ?>" enctype="multipart/form-data"> <h4>編輯收款資訊</h4>
<div class="form-group" style="margin-left: 1%;margin-right: 1%;"> </div>
<div class="form-group"> <form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=edit&<?= $token_link ?>" enctype="multipart/form-data">
<div class="col-md-3"> <div class="form-group" style="margin-left: 1%;margin-right: 1%;">
<label for="BillNo">合約號</label> <div class="form-group">
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled> <div class="col-md-3">
</div> <label for="BillNo">合約號</label>
<div class="col-md-3"> <input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled>
<label for="DeptName">部門</label> </div>
<input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled> <div class="col-md-3">
</div> <label for="DeptName">部門</label>
<div class="col-md-3"> <input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled>
<label for="ManagerName">經理</label> </div>
<input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled> <div class="col-md-3">
</div> <label for="ManagerName">經理</label>
<div class="col-md-3"> <input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled>
<label for="PersonName">營業員</label> </div>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled> <div class="col-md-3">
</div> <label for="PersonName">營業員</label>
</div> <input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled>
<div class="form-group"> </div>
<div class="col-md-3"> </div>
<label for="EnterpriseName">抬頭</label> <div class="form-group">
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled> <div class="col-md-3">
</div> <label for="EnterpriseName">抬頭</label>
<div class="col-md-3"> <input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled>
<label for="TaxNo">統一編號</label> </div>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled> <div class="col-md-3">
</div> <label for="TaxNo">統一編號</label>
<div class="col-md-6"> <input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled>
<label for="ContactAddress">聯絡地址</label> </div>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled> <div class="col-md-6">
</div> <label for="ContactAddress">聯絡地址</label>
</div> <input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled>
<div class="form-group"> </div>
<div class="col-md-3"> </div>
<label for="InvoiceDate">發票開立日期</label> <div class="form-group">
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" value="<?= $pay['invoice_date'] ?>"> <div class="col-md-3">
</div> <label for="InvoiceDate">發票開立日期</label>
<div class="col-md-3"> <input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" value="<?= $pay['invoice_date'] ?>">
<label for="InvoiceAmount">發票金額</label> </div>
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" value="<?= $pay['invoice_amount'] ?>"> <div class="col-md-3">
</div> <label for="InvoiceAmount">發票金額</label>
<div class="col-md-3"> <input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" value="<?= $pay['invoice_amount'] ?>">
<label for="InvoiceNo">發票號碼</label> </div>
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" value="<?= $pay['invoice_no'] ?>"> <div class="col-md-3">
</div> <label for="InvoiceNo">發票號碼</label>
</div> <input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" value="<?= $pay['invoice_no'] ?>">
<div class="form-group"> </div>
<div class="col-md-3"> </div>
<label for="ReceivedDate">收款日期</label> <div class="form-group">
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" value="<?= $pay['received_date'] ?>"> <div class="col-md-3">
</div> <label for="ReceivedDate">收款日期</label>
<div class="col-md-3"> <input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" value="<?= $pay['received_date'] ?>">
<label for="ReceivedAmount">收款金額</label> </div>
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" value="<?= $pay['received_amount'] ?>"> <div class="col-md-3">
</div> <label for="ReceivedAmount">收款金額</label>
<div class="col-md-3"> <input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" value="<?= $pay['received_amount'] ?>">
<label for="remark">備註</label> </div>
<input type="text" class="form-control" id="remark" name="remark" value="<?= $pay['remark'] ?>"> <div class="col-md-3">
</div> <label for="remark">備註</label>
</div> <input type="text" class="form-control" id="remark" name="remark" value="<?= $pay['remark'] ?>">
</div>
</div>
<input type="hidden" name="pay_id" value="<?= $pay['pay_id'] ?>"> <div class="form-group">
</div> <div class="col-md-3">
<div class="form-group"> <label for="status" style="color: red;">狀態</label>
<div class="col-md-3"> <select id="status" name="status">
</div> <option value=0 <?php if($pay['status'] == 0) echo "selected" ?>>進行中</option>
<div class="col-md-9"> <option value=1 <?php if($pay['status'] == 1) echo "selected" ?>>催收</option>
<button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button> <option value=2 <?php if($pay['status'] == 2) echo "selected" ?>>法務件 (發函)</option>
</div> <option value=3 <?php if($pay['status'] == 3) echo "selected" ?>>法務件 (訴訟)</option>
</div> <option value=4 <?php if($pay['status'] == 4) echo "selected" ?>>折讓</option>
</form> <option value=5 <?php if($pay['status'] == 5) echo "selected" ?>>壞帳</option>
</div> <option value=99 <?php if($pay['status'] == 99) echo "selected" ?>>完成</option>
</select>
</div>
</div>
<script>
function backToIndex() {
var Bill = <?= $Bill ?>; <input type="hidden" name="pay_id" value="<?= $pay['pay_id'] ?>">
var form = document.createElement("form"); <input type="hidden" name="Bill" id="Bill" value="">
form.method = 'POST'; </div>
form.action = "account-receivable-check.php?<?= $token_link ?>"; <div class="form-group">
var input = document.createElement("input"); <div class="col-md-3">
input.type = "hidden"; </div>
input.name = "Bill"; <div class="col-md-9">
input.value = JSON.stringify(Bill); <button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button>
form.appendChild(input); </div>
document.body.appendChild(form); </div>
form.submit(); </form>
} </div>
function send() {
event.preventDefault();
$("#pay_received").submit();
} <script>
function backToIndex() {
var Bill = <?= $Bill ?>;
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();
}
function send() {
event.preventDefault();
var Bill = <?= $Bill ?>;
Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script> </script>

180
wms/account-receivable-received-submit.php

@ -1,84 +1,96 @@
<?php <?php
include "./header.php"; include "./header.php";
$type = $_GET['type']; $type = $_GET['type'];
$InvoiceNo = empty($_POST['InvoiceNo']) ? NULL : str_replace('-', '', trim($_POST['InvoiceNo'])); $InvoiceNo = empty($_POST['InvoiceNo']) ? '' : str_replace('-', '', trim($_POST['InvoiceNo']));
$InvoiceDate = empty($_POST['InvoiceDate']) ? NULL: $_POST['InvoiceDate']; $InvoiceDate = isset($_POST['InvoiceDate']) ? $_POST['InvoiceDate'] : '';
$Bill = $_POST['Bill'];
$invoice_amount = empty($_POST['InvoiceAmount']) ? 0 : $_POST['InvoiceAmount'];
$received_amount = empty($_POST['ReceivedAmount']) ? 0 : $_POST['ReceivedAmount']; $invoice_amount = empty($_POST['InvoiceAmount']) ? 0 : $_POST['InvoiceAmount'];
$received_date = empty($_POST['ReceivedDate']) ? NULL : $_POST['ReceivedDate']; $received_amount = empty($_POST['ReceivedAmount']) ? 0 : $_POST['ReceivedAmount'];
$remark = empty($_POST['remark']) ? '' : $_POST['remark']; $received_date = isset($_POST['ReceivedDate']) ? $_POST['ReceivedDate'] : '';
$remark = isset($_POST['remark']) ? $_POST['remark'] : '';
if ($type == 'edit') {
$pay_id = $_POST['pay_id']; if ($type == 'edit') {
$sql_query_pay = "SELECT * from account_received where pay_id = $pay_id"; $pay_id = $_POST['pay_id'];
$pay = mysqli_query($link, $sql_query_pay); $status = $_POST['status'];
$pay = mysqli_fetch_assoc($pay); $sql_query_pay = "SELECT * from account_received where pay_id = $pay_id";
$pay = mysqli_query($link, $sql_query_pay);
$sql1 = "UPDATE account_received SET "; $pay = mysqli_fetch_assoc($pay);
if ($InvoiceNo !== $pay['invoice_no']) {
$sql1.="invoice_no = '$InvoiceNo',"; $sql1 = "UPDATE account_received SET ";
} if ($InvoiceNo !== $pay['invoice_no']) {
if($InvoiceDate !== $pay['invoice_date']){ $sql1 .= "invoice_no = '$InvoiceNo',";
$sql1.="invoice_date = '$InvoiceDate',"; }
} if ($InvoiceDate != $pay['invoice_date']) {
if($invoice_amount != $pay['invoice_amount']){
$sql1.="invoice_amount = $invoice_amount,"; $sql1 .= "invoice_date = '$InvoiceDate',";
} }
if($received_amount != $pay['received_amount']){ if ($invoice_amount != $pay['invoice_amount']) {
$sql1.="received_amount = $received_amount,"; $sql1 .= "invoice_amount = $invoice_amount,";
} }
if($received_date !== $pay['received_date']){ if ($received_amount != $pay['received_amount']) {
$sql1.="received_date = '$received_date',"; $sql1 .= "received_amount = $received_amount,";
} }
if($remark !== $pay['remark']){ if ($received_date != $pay['received_date']) {
$sql1.="remark = '$remark',"; $sql1 .= "received_date = '$received_date',";
} }
$sql1=substr($sql1,0,-1); if ($remark != $pay['remark']) {
$sql = $sql1 . " WHERE pay_id = $pay_id"; $sql1 .= "remark = '$remark',";
echo $sql; }
exit(); if ($status != $pay['status']) {
} else { $sql1 .= "status = $status,";
$BillNo = $_POST['BillNo']; }
$dept_id = $_POST['DeptId']; // $sql1 = substr($sql1, 0, -1);
$dept_name = $_POST['DeptName']; $sql = $sql1 . "LastOperatorId = '$user_id' WHERE pay_id = $pay_id";
$manager_name = $_POST['ManagerName']; } else {
$person_id = $_POST['PersonId']; $BillNo = $_POST['BillNo'];
$person_name = $_POST['PersonName']; $dept_id = $_POST['DeptId'];
$cust_name = $_POST['CustName']; $dept_name = $_POST['DeptName'];
$sql1 = "INSERT INTO account_received ( $manager_name = $_POST['ManagerName'];
BillNo,dept_id,dept_name,manager_name,person_id,person_name,cust_name"; $person_id = $_POST['PersonId'];
$sql2 = ",CreatorId) VALUES ('$BillNo','$dept_id','$dept_name','$manager_name','$person_id','$person_name','$cust_name'"; $person_name = $_POST['PersonName'];
if (!empty($InvoiceNo)) { $cust_name = $_POST['CustName'];
$sql1 .= ",invoice_no"; $sql1 = "INSERT INTO account_received (
$sql2 .= ",'$InvoiceNo'"; BillNo,dept_id,dept_name,manager_name,person_id,person_name,cust_name";
} $sql2 = ",CreatorId) VALUES ('$BillNo','$dept_id','$dept_name','$manager_name','$person_id','$person_name','$cust_name'";
if (isset($InvoiceDate)) { if (isset($InvoiceNo)) {
$sql1 .= ",invoice_date"; $sql1 .= ",invoice_no";
$sql2 .= ",'$InvoiceDate'"; $sql2 .= ",'$InvoiceNo'";
} }
if (!empty($invoice_amount)) { if ((!empty($InvoiceDate))) {
$sql1 .= ",invoice_amount"; $sql1 .= ",invoice_date";
$sql2 .= ",$invoice_amount"; $sql2 .= ",'$InvoiceDate'";
} }
if (!empty($received_amount)) { if (isset($invoice_amount)) {
$sql1 .= ",received_amount"; $sql1 .= ",invoice_amount";
$sql2 .= ",$received_amount"; $sql2 .= ",$invoice_amount";
} }
if (isset($received_date)) { if (isset($received_amount)) {
$sql1 .= ",received_date"; $sql1 .= ",received_amount";
$sql2 .= ",'$received_date'"; $sql2 .= ",$received_amount";
} }
if (!empty($remark)) { if (!(empty($received_date))) {
$sql1 .= ",remark"; $sql1 .= ",received_date";
$sql2 .= ",'$remark'"; $sql2 .= ",'$received_date'";
} }
$sql = $sql1 . $sql2 . ",'$user_id')"; if (!(empty($remark))) {
} $sql1 .= ",remark";
mysqli_query($link, $sql); $sql2 .= ",'$remark'";
if (mysqli_affected_rows($link)) { }
echo '<script>alert("新增/更新 成功")</script>'; $sql = $sql1 . $sql2 . ",'$user_id')";
echo $sql; }
} else { mysqli_query($link, $sql);
echo '<script>alert("新增/更新 失敗")</script>'; ?>
} <script>
var Bill = <?= $Bill ?>;
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>

BIN
wms/account-receivable.xlsx

Binary file not shown.

148
wms/account-record-submit.php

@ -1,75 +1,75 @@
<?php <?php
$id= ""; $id= "";
$accounttype= ""; $accounttype= "";
$accountid= ""; $accountid= "";
$pwd= ""; $pwd= "";
$name= ""; $name= "";
$tel= ""; $tel= "";
$address= ""; $address= "";
$email= ""; $email= "";
$lineid= ""; $lineid= "";
$wechatid= ""; $wechatid= "";
$phone_call_help= ""; $phone_call_help= "";
$chat_for_help= ""; $chat_for_help= "";
$remote_help= ""; $remote_help= "";
$repairerid= ""; $repairerid= "";
$manager= ""; $manager= "";
$creater= ""; $creater= "";
$create_at= ""; $create_at= "";
$id_error = ""; $id_error = "";
$accounttype_error= ""; $accounttype_error= "";
$accountid_error= ""; $accountid_error= "";
$pwd_error= ""; $pwd_error= "";
$name_error= ""; $name_error= "";
$tel_error= ""; $tel_error= "";
$address_error= ""; $address_error= "";
$email_error= ""; $email_error= "";
$lineid_error= ""; $lineid_error= "";
$wechatid_error= ""; $wechatid_error= "";
$phone_call_help_error= ""; $phone_call_help_error= "";
$chat_for_help_error= ""; $chat_for_help_error= "";
$remote_help_error= ""; $remote_help_error= "";
$repairerid_error= ""; $repairerid_error= "";
$manager_error= ""; $manager_error= "";
$creater_error= ""; $creater_error= "";
$create_at_error= ""; $create_at_error= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
include "account-user-input.php"; 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 = "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')"; $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); $result = mysqli_query($link,$db_query);
// 新增權限 // 新增權限
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) { if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) {
$db_query = "insert into account_auth (accountid, permission) "; $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'"; $db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
} }
// mysqli_insert_id可以抓到第一筆的id // mysqli_insert_id可以抓到第一筆的id
//$new_id= mysqli_insert_id ($link); //$new_id= mysqli_insert_id ($link);
#echo "新增後的id為 {$id} "; #echo "新增後的id為 {$id} ";
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
// 如果有一筆以上代表有更新 // 如果有一筆以上代表有更新
echo "<script>"; echo "<script>";
echo "alert('新增成功');"; echo "alert('新增成功');";
echo "location.href='account-index.php?function_name=account&".$token_link."';"; echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script>"; echo "<script>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='account-index.php?function_name=account&".$token_link."';"; echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

130
wms/account-record-update.php

@ -1,66 +1,66 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$id = $_POST['id']; $id = $_POST['id'];
$accounttype = user_input($_POST["accounttype"]); $accounttype = user_input($_POST["accounttype"]);
$accountid = user_input($_POST["accountid"]); $accountid = user_input($_POST["accountid"]);
$pwd = user_input($_POST["pwd"]); $pwd = user_input($_POST["pwd"]);
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]); $address = user_input($_POST["address"]);
$email = user_input($_POST["email"]); $email = user_input($_POST["email"]);
$lineid = user_input($_POST["lineid"]); $lineid = user_input($_POST["lineid"]);
$wechatid = user_input($_POST["wechatid"]); $wechatid = user_input($_POST["wechatid"]);
$phone_call_help = user_input($_POST["phone_call_help"]); $phone_call_help = user_input($_POST["phone_call_help"]);
$chat_for_help = user_input($_POST["chat_for_help"]); $chat_for_help = user_input($_POST["chat_for_help"]);
$remote_help = user_input($_POST["remote_help"]); $remote_help = user_input($_POST["remote_help"]);
$repairerid = user_input($_POST["repairerid"]); $repairerid = user_input($_POST["repairerid"]);
$manager = user_input($_POST["manager"]); $manager = user_input($_POST["manager"]);
$department_id = user_input($_POST["department_id"]); $department_id = user_input($_POST["department_id"]);
$role_id = user_input($_POST["role_id"]); $role_id = user_input($_POST["role_id"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE account set pwd = '$pwd', name = '$name', tel = '$tel', address = '$address', "; $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 .= "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 .= "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'"; $db_query .= "department_id = '$department_id', role_id = '$role_id', create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) { 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'"; $sql = "select permission from department where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_row($res)) { if ($row = mysqli_fetch_row($res)) {
$db_query = "update account_auth set permission = '$row[0]' where accountid = '$accountid'"; $db_query = "update account_auth set permission = '$row[0]' where accountid = '$accountid'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
} }
mysqli_free_result($res); mysqli_free_result($res);
} }
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='account-index.php?function_name=account&".$token_link."';"; echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='account-index.php?function_name=account&".$token_link."';"; echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

130
wms/account-user-input.php

@ -1,65 +1,65 @@
<?php <?php
//Function to filter the form input //Function to filter the form input
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$accounttype = user_input($_POST["accounttype"]); $accounttype = user_input($_POST["accounttype"]);
$accountid = user_input($_POST["accountid"]); $accountid = user_input($_POST["accountid"]);
#$accountid = $accounttype . $accountid; #$accountid = $accounttype . $accountid;
$pwd = user_input($_POST["pwd"]); $pwd = user_input($_POST["pwd"]);
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]); $address = user_input($_POST["address"]);
$email = user_input($_POST["email"]); $email = user_input($_POST["email"]);
$lineid = user_input($_POST["lineid"]); $lineid = user_input($_POST["lineid"]);
$wechatid = user_input($_POST["wechatid"]); $wechatid = user_input($_POST["wechatid"]);
$phone_call_help = user_input($_POST["phone_call_help"]); $phone_call_help = user_input($_POST["phone_call_help"]);
$chat_for_help = user_input($_POST["chat_for_help"]); $chat_for_help = user_input($_POST["chat_for_help"]);
$remote_help = user_input($_POST["remote_help"]); $remote_help = user_input($_POST["remote_help"]);
$repairerid = user_input($_POST["repairerid"]); $repairerid = user_input($_POST["repairerid"]);
$manager = user_input($_POST["manager"]); $manager = user_input($_POST["manager"]);
$department_id = user_input($_POST["department_id"]); $department_id = user_input($_POST["department_id"]);
$role_id = user_input($_POST["role_id"]); $role_id = user_input($_POST["role_id"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
/* /*
if(empty($_POST["name"])) { if(empty($_POST["name"])) {
$name_error = "Name is required"; $name_error = "Name is required";
} else { } else {
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed"; $name_error = "Only letter and white space are allowed";
} }
} }
/* /*
if(empty($_POST["website"])) { if(empty($_POST["website"])) {
$website_error = "Website address is required"; $website_error = "Website address is required";
} else { } else {
$website = user_input($_POST["website"]); $website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL"; $website_error = "Invalid website URL";
} }
} }
if(empty($_POST["comment"])) { if(empty($_POST["comment"])) {
$comment = ""; $comment = "";
} else { } else {
$comment = user_input($_POST["comment"]); $comment = user_input($_POST["comment"]);
} }
*/ */
?> ?>

354
wms/account_auth-create.php

@ -1,177 +1,177 @@
<?php <?php
include "header.php"; include "header.php";
// 部門職別 // 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id"; $db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) { while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"]; $depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"]; $role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
} }
mysqli_free_result($res); mysqli_free_result($res);
// 選單結構 // 選單結構
$data = array(); $data = array();
$db_query = "select * from menu order by main_menu_seq, sub_menu_seq"; $db_query = "select * from menu order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) { while ($row = mysqli_fetch_assoc($res)) {
$data[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"]; $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"]]["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"]]["link_content"] = $row["link_content"];
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"]; $data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"];
} }
mysqli_free_result($res); mysqli_free_result($res);
//print_r($data);exit; //print_r($data);exit;
?> ?>
<style> <style>
table { table {
margin-top:10px; margin-top:10px;
} }
.table-off, .table-off > td, .table-off > th { .table-off, .table-off > td, .table-off > th {
background-color: #d6d8db; background-color: #d6d8db;
} }
.label-checkbox { cursor: pointer; } .label-checkbox { cursor: pointer; }
</style> </style>
<script> <script>
$(function () { $(function () {
var jroleStr = '<?php echo json_encode($role_arr); ?>'; var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr); var jroleArr = JSON.parse(jroleStr);
var optStr = ""; var optStr = "";
$("select[name=department_id]").change(function(){ $("select[name=department_id]").change(function(){
if ($(this).val() != "") { if ($(this).val() != "") {
optStr = ""; optStr = "";
for (var i in jroleArr[$(this).val()]) { for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) { if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>'; optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
} }
} }
$("select[name=role_id]").html(optStr); $("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>'); } else $("select[name=role_id]").html('<option value="">請選擇</option>');
}) })
$('#submit').click(function(){ $('#submit').click(function(){
var optRStr = ""; var optRStr = "";
var optRArr = []; var optRArr = [];
$("input[name=opt_r]").each(function(){ $("input[name=opt_r]").each(function(){
optRStr = ""; optRStr = "";
optRStr += $(this).attr('data-auth'); optRStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optRStr += ";"+$(this).val(); if ($(this).prop('checked')) optRStr += ";"+$(this).val();
else optRStr += ";X"; else optRStr += ";X";
optRArr.push(optRStr); optRArr.push(optRStr);
}) })
$('#opt_r_all').val(optRArr); $('#opt_r_all').val(optRArr);
var optWStr = ""; var optWStr = "";
var optWArr = []; var optWArr = [];
$("input[name=opt_w]").each(function(){ $("input[name=opt_w]").each(function(){
optWStr = ""; optWStr = "";
optWStr += $(this).attr('data-auth'); optWStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optWStr += ";"+$(this).val(); if ($(this).prop('checked')) optWStr += ";"+$(this).val();
else optWStr += ";X"; else optWStr += ";X";
optWArr.push(optWStr); optWArr.push(optWStr);
}) })
$('#opt_w_all').val(optWArr); $('#opt_w_all').val(optWArr);
}); });
}); });
</script> </script>
<div class="container"> <div class="container">
<?php <?php
include "account_auth-record-submit.php"; include "account_auth-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; echo "<p class='success'>Record has added successfully</p>";
} }
} }
*/ */
?> ?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div> <div>
<label for="department_id">部門</label> <label for="department_id">部門</label>
<select name="department_id" required> <select name="department_id" required>
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($depart_arr as $k => $v) { foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>"; echo "<option value=\"".$k."\">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="role_id">職別</label> <label for="role_id">職別</label>
<select name="role_id" required> <select name="role_id" required>
<?php <?php
foreach ($role_arr[$data2["department_id"]] as $k => $v) { foreach ($role_arr[$data2["department_id"]] as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>"; echo "<option value=\"".$k."\">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th scope="col">主功能名稱</th> <th scope="col">主功能名稱</th>
<th scope="col">子功能名稱</th> <th scope="col">子功能名稱</th>
<th scope="col">控管</th> <th scope="col">控管</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach($data as $key => $val) { foreach($data as $key => $val) {
foreach($val as $k2 => $v2) { foreach($val as $k2 => $v2) {
if ($k2 == "main_menu") continue; if ($k2 == "main_menu") continue;
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : ''; $td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : '';
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"'; $sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"';
?> ?>
<tr<?php echo $sta_str; ?>> <tr<?php echo $sta_str; ?>>
<?php echo $td_str; ?> <?php echo $td_str; ?>
<td><?php echo $v2["sub_menu"]; ?></td> <td><?php echo $v2["sub_menu"]; ?></td>
<td> <td>
<label class="label-checkbox"> <label class="label-checkbox">
<input type="checkbox" name="opt_r" value="R" data-auth="<?php echo $key.";".$k2; ?>"> <input type="checkbox" name="opt_r" value="R" data-auth="<?php echo $key.";".$k2; ?>">
可讀</label> 可讀</label>
<label class="label-checkbox"> <label class="label-checkbox">
<input type="checkbox" name="opt_w" value="W" data-auth="<?php echo $key.";".$k2; ?>"> <input type="checkbox" name="opt_w" value="W" data-auth="<?php echo $key.";".$k2; ?>">
可寫</label> 可寫</label>
</td> </td>
</tr> </tr>
<?php <?php
} }
} }
?> ?>
</tbody> </tbody>
</table> </table>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p> <p class="error"><?php echo $creater_error; ?></p>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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"); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" id="submit" name="submit">確定</button> <button type="submit" id="submit" name="submit">確定</button>
</div> </div>
<input type="hidden" name="opt_r_all" id="opt_r_all"> <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="opt_w_all" id="opt_w_all">
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
include "footer.php"; include "footer.php";
?> ?>

364
wms/account_auth-edit.php

@ -1,182 +1,182 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
// 選單結構 // 選單結構
$menu = array(); $menu = array();
$db_query = "select * from menu where status = 'Y' order by main_menu_seq, sub_menu_seq"; $db_query = "select * from menu where status = 'Y' order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) { while ($row = mysqli_fetch_assoc($res)) {
$menu[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"]; $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"]]["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"]]["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"]]["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"]]["status"] = $row["status"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["id"] = $row["id"]; $menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["id"] = $row["id"];
} }
mysqli_free_result($res); mysqli_free_result($res);
$data = array(); $data = array();
// sql语法存在变数中 // sql语法存在变数中
$db_query = "select * from department where id = '$id'"; $db_query = "select * from department where id = '$id'";
// 用mysqli_query方法执行(sql语法)将结果存在变数中 // 用mysqli_query方法执行(sql语法)将结果存在变数中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
foreach($data as $data) : foreach($data as $data) :
$permission_arr = json_decode(urldecode($data["permission"]), true); $permission_arr = json_decode(urldecode($data["permission"]), true);
$person = ""; $person = "";
$sql = "select accountid, name from account where department_id = '".$data["department_id"]."' and role_id = '".$data["role_id"]."' and accounttype <> 'X'"; $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); $result = mysqli_query($link, $sql);
while ($row_a = mysqli_fetch_row($result)) { while ($row_a = mysqli_fetch_row($result)) {
$person .= $row_a[1]."(".$row_a[0].")、"; $person .= $row_a[1]."(".$row_a[0].")、";
} }
mysqli_free_result($result); mysqli_free_result($result);
?> ?>
<style> <style>
table { table {
margin-top:10px; margin-top:10px;
} }
.table-off, .table-off > td, .table-off > th { .table-off, .table-off > td, .table-off > th {
background-color: #d6d8db; background-color: #d6d8db;
} }
.label-checkbox { .label-checkbox {
cursor: pointer; cursor: pointer;
} }
body > div > form > table > thead > tr > th:nth-child(3) > label > span { body > div > form > table > thead > tr > th:nth-child(3) > label > span {
font-size:14px; font-size:14px;
} }
.nextline { .nextline {
width: 100%; width: 100%;
height: 0; height: 0;
} }
</style> </style>
<script> <script>
$(function () { $(function () {
$("input[name=rall]").click(function(){ $("input[name=rall]").click(function(){
$("input[name=opt_r]").not(this).prop('checked', this.checked); $("input[name=opt_r]").not(this).prop('checked', this.checked);
}); });
$("input[name=wall]").click(function(){ $("input[name=wall]").click(function(){
$("input[name=opt_w]").not(this).prop('checked', this.checked); $("input[name=opt_w]").not(this).prop('checked', this.checked);
}); });
$('#update').click(function(){ $('#update').click(function(){
var optRStr = ""; var optRStr = "";
var optRArr = []; var optRArr = [];
$("input[name=opt_r]").each(function(){ $("input[name=opt_r]").each(function(){
optRStr = ""; optRStr = "";
optRStr += $(this).attr('data-auth'); optRStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optRStr += ";"+$(this).val(); if ($(this).prop('checked')) optRStr += ";"+$(this).val();
else optRStr += ";0"; else optRStr += ";0";
optRArr.push(optRStr); optRArr.push(optRStr);
}) })
$('#opt_r_all').val(optRArr); $('#opt_r_all').val(optRArr);
var optWStr = ""; var optWStr = "";
var optWArr = []; var optWArr = [];
$("input[name=opt_w]").each(function(){ $("input[name=opt_w]").each(function(){
optWStr = ""; optWStr = "";
optWStr += $(this).attr('data-auth'); optWStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optWStr += ";"+$(this).val(); if ($(this).prop('checked')) optWStr += ";"+$(this).val();
else optWStr += ";0"; else optWStr += ";0";
optWArr.push(optWStr); optWArr.push(optWStr);
}) })
$('#opt_w_all').val(optWArr); $('#opt_w_all').val(optWArr);
}); });
}); });
</script> </script>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="account_auth-record-update.php"> <form class="form-inline" method="post" action="account_auth-record-update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="department_name">部門</label> <label for="department_name">部門</label>
<input type="text" name="department_name" id="department_name" value="<?php echo $data['name']; ?>" readonly> <input type="text" name="department_name" id="department_name" value="<?php echo $data['name']; ?>" readonly>
</div> </div>
<div> <div>
<label for="role_name">職別</label> <label for="role_name">職別</label>
<input type="text" name="role_name" id="role_name" value="<?php echo $data['role']; ?>" readonly> <input type="text" name="role_name" id="role_name" value="<?php echo $data['role']; ?>" readonly>
</div> </div>
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th scope="col">主功能名稱</th> <th scope="col">主功能名稱</th>
<th scope="col">子功能名稱</th> <th scope="col">子功能名稱</th>
<th scope="col"> <th scope="col">
<label class="label-checkbox"><input type="checkbox" name="rall"> <label class="label-checkbox"><input type="checkbox" name="rall">
全選</label> 全選</label>
</th> </th>
<th scope="col"> <th scope="col">
<label class="label-checkbox"><input type="checkbox" name="wall"> <label class="label-checkbox"><input type="checkbox" name="wall">
全選</label> 全選</label>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach($menu as $key => $val) { foreach($menu as $key => $val) {
foreach($val as $k2 => $v2) { foreach($val as $k2 => $v2) {
if ($k2 == "main_menu") continue; if ($k2 == "main_menu") continue;
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : ''; $td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : '';
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"'; $sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"';
$chk_r = $chk_w = ""; $chk_r = $chk_w = "";
if (!empty($permission_arr[$v2["mlink"]])) { if (!empty($permission_arr[$v2["mlink"]])) {
if ($permission_arr[$v2["mlink"]]&1) $chk_r = " checked"; if ($permission_arr[$v2["mlink"]]&1) $chk_r = " checked";
if ($permission_arr[$v2["mlink"]]&2) $chk_w = " checked"; if ($permission_arr[$v2["mlink"]]&2) $chk_w = " checked";
} }
?> ?>
<tr<?php echo $sta_str; ?>> <tr<?php echo $sta_str; ?>>
<?php echo $td_str; ?> <?php echo $td_str; ?>
<td> <td>
<?php echo $v2["sub_menu"]; ?> <?php echo $v2["sub_menu"]; ?>
</td> </td>
<td> <td>
<label class="label-checkbox"> <label class="label-checkbox">
<input type="checkbox" name="opt_r" value="1" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_r; ?>> <input type="checkbox" name="opt_r" value="1" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_r; ?>>
可讀</label> 可讀</label>
</td> </td>
<td> <td>
<label class="label-checkbox"> <label class="label-checkbox">
<input type="checkbox" name="opt_w" value="2" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_w; ?>> <input type="checkbox" name="opt_w" value="2" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_w; ?>>
可寫</label> 可寫</label>
</td> </td>
</tr> </tr>
<?php <?php
} }
} }
?> ?>
</tbody> </tbody>
</table> </table>
<div> <div>
<label>所屬人員</label> <label>所屬人員</label>
<textarea name="person-info" rows="6" cols="70" class="form-control" readonly><?php echo rtrim($person, "、"); ?></textarea> <textarea name="person-info" rows="6" cols="70" class="form-control" readonly><?php echo rtrim($person, "、"); ?></textarea>
</div> </div>
<div class="nextline"></div> <div class="nextline"></div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="update" id="update">確定</button> <button type="submit" name="update" id="update">確定</button>
</div> </div>
<input type="hidden" name="opt_r_all" id="opt_r_all"> <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="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="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="role_id" id="role_id" value="<?php echo $data["role_id"]; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>"> <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"); ?>"> <input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

209
wms/account_auth-index.php

@ -1,106 +1,105 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql = "select * from department order by department_id, role_id"; $sql = "select * from department order by department_id, role_id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<!-- <!--
<p> <p>
<a href="account_auth-create.php?function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <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> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
--> -->
<?php <?php
if($data): if($data):
?>
?> <style>
<style> table {
table { table-layout:fixed;
table-layout:fixed; width: 100%;
width: 100%; }
}
td {
td { word-wrap:break-word;
word-wrap:break-word; }
}
img {
img { width:125px;
width:125px; }
}
.width_style_1 {
.width_style_1 { width:125px;
width:125px; }
}
table{
table{ width:100%;
width:100%; }
} #table_index_filter{
#table_index_filter{ float:right;
float:right; }
} #table_index_paginate{
#table_index_paginate{ float:right;
float:right; }
} label {
label { display: inline-flex;
display: inline-flex; margin-bottom: .5rem;
margin-bottom: .5rem; margin-top: .5rem;
margin-top: .5rem;
}
} </style>
</style> <div style="overflow-x:auto;">
<div style="overflow-x:auto;"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <thead>
<thead> <tr>
<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> </tr>
</tr> </thead>
</thead> <tbody>
<tbody>
<?php foreach($data as $data) : ?>
<?php foreach($data as $data) : ?> <tr>
<tr> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['department_id']; ?></td>
<td><?php echo $data['department_id']; ?></td> <td><?php echo $data['name']; ?></td>
<td><?php echo $data['name']; ?></td> <td><?php echo $data['role_id']; ?></td>
<td><?php echo $data['role_id']; ?></td> <td><?php echo $data['role']; ?></td>
<td><?php echo $data['role']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['create_at']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td>
<td> <p>
<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">
<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>
<span class="glyphicon glyphicon-pencil"></span> </a>
</a> </p>
</p> </td>
</td> </tr>
</tr> <?php endforeach; ?>
<?php endforeach; ?> </tbody>
</tbody> </table>
</table> </div>
</div>
<?php
<?php
else:
else: echo "<h2>There is no record!</h2>";
echo "<h2>There is no record!</h2>"; endif;
endif;
#代表結束連線
#代表結束連線 mysqli_close($link);
mysqli_close($link); include "footer.php";
include "footer.php";
?> ?>

128
wms/account_auth-record-update.php

@ -1,65 +1,65 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
//print_r($_POST);exit; //print_r($_POST);exit;
// 選單各功能的權限 // 選單各功能的權限
$prog_arr = []; $prog_arr = [];
$opt_r_arr = explode(",", $opt_r_all); $opt_r_arr = explode(",", $opt_r_all);
$opt_w_arr = explode(",", $opt_w_all); $opt_w_arr = explode(",", $opt_w_all);
foreach ($opt_r_arr as $key => $val) { foreach ($opt_r_arr as $key => $val) {
list($menu_id, $auth_r) = explode(";", $val); list($menu_id, $auth_r) = explode(";", $val);
list($menu_id, $auth_w) = explode(";", $opt_w_arr[$key]); list($menu_id, $auth_w) = explode(";", $opt_w_arr[$key]);
// 找出相關程式 // 找出相關程式
$sql = "select link_content from menu where id = '$menu_id'"; $sql = "select link_content from menu where id = '$menu_id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) { if ($row = mysqli_fetch_assoc($res)) {
if ($row["link_content"]) { if ($row["link_content"]) {
$tmp_arr = explode("\r\n", $row["link_content"]); $tmp_arr = explode("\r\n", $row["link_content"]);
foreach ($tmp_arr as $v) { foreach ($tmp_arr as $v) {
$prog_arr[$v] = $auth_r|$auth_w; $prog_arr[$v] = $auth_r|$auth_w;
} }
} }
} }
mysqli_free_result($res); mysqli_free_result($res);
if (($key%10)==0) usleep(200000); if (($key%10)==0) usleep(200000);
} }
// 開始更新權限 // 開始更新權限
$permission = json_encode($prog_arr, JSON_UNESCAPED_SLASHES); $permission = json_encode($prog_arr, JSON_UNESCAPED_SLASHES);
$sql = "update department set permission = '$permission', create_at = '$create_at' where id = '$id'"; $sql = "update department set permission = '$permission', create_at = '$create_at' where id = '$id'";
mysqli_query($link, $sql); mysqli_query($link, $sql);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
// 更新user權限 // 更新user權限
$sql = "select accountid from account where department_id = '$department_id' and role_id = '$role_id'"; $sql = "select accountid from account where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
$db_query = "insert into account_auth (accountid, permission) values ('$row[0]', '$permission') "; $db_query = "insert into account_auth (accountid, permission) values ('$row[0]', '$permission') ";
$db_query .= "ON DUPLICATE KEY UPDATE accountid = '$row[0]', permission = '$permission'"; $db_query .= "ON DUPLICATE KEY UPDATE accountid = '$row[0]', permission = '$permission'";
$res_u = mysqli_query($link, $db_query); $res_u = mysqli_query($link, $db_query);
} }
mysqli_free_result($res); mysqli_free_result($res);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';"; echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';"; echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

624
wms/bargain-create.php

@ -1,313 +1,313 @@
<?php <?php
include "header.php"; include "header.php";
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; $category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$sql = "select max(bargainno) as maxno from bargain"; $sql = "select max(bargainno) as maxno from bargain";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$bargainno = $row[0] ? $row[0]+1 : date("Ym")."001"; $bargainno = $row[0] ? $row[0]+1 : date("Ym")."001";
$sql = "select department_id from account where accountid = '$user_id'"; $sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
list($department_id) = $row; list($department_id) = $row;
mysqli_free_result($res); mysqli_free_result($res);
$department_arr = []; $department_arr = [];
$sql = "select department_id, name from department"; $sql = "select department_id, name from department";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1]; $department_arr[$row[0]] = $row[1];
} }
mysqli_free_result($res); mysqli_free_result($res);
?> ?>
<style> <style>
</style> </style>
<script> <script>
function commafy(num) { function commafy(num) {
num = num + ""; num = num + "";
var re = /(-?\d+)(\d{3})/ var re = /(-?\d+)(\d{3})/
while (re.test(num)) { while (re.test(num)) {
num = num.replace(re, "$1,$2") num = num.replace(re, "$1,$2")
} }
return num; return num;
} }
$(function(){ $(function(){
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) $('#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, ",")); }) $('#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, ",")); }) $('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$("input[name=quote_amt_be]").each(function(){ $("input[name=quote_amt_be]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); $(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
}); });
$("input[name=quote_amt_ar]").each(function(){ $("input[name=quote_amt_ar]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); $(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
}); });
$('#btnadd').click(function(){ $('#btnadd').click(function(){
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end()); $('#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); $('#tb1 tr:last').prev().find('td').first().html($("tr[name='supplier_templ']").length);
}); });
$('#submit').click(function(){ $('#submit').click(function(){
var supIdArr = []; var supIdArr = [];
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); }) $("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); })
$('#sup_id_all').val(supIdArr); $('#sup_id_all').val(supIdArr);
var supplierArr = []; var supplierArr = [];
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); }) $("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); })
$('#supplier_all').val(supplierArr); $('#supplier_all').val(supplierArr);
var quoteAmtBeArr = []; var quoteAmtBeArr = [];
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); }) $("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_be_all').val(quoteAmtBeArr); $('#quote_amt_be_all').val(quoteAmtBeArr);
var noteBeArr = []; var noteBeArr = [];
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); }) $("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); })
$('#note_be_all').val(noteBeArr); $('#note_be_all').val(noteBeArr);
var quoteAmtArArr = []; var quoteAmtArArr = [];
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); }) $("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_ar_all').val(quoteAmtArArr); $('#quote_amt_ar_all').val(quoteAmtArArr);
var noteArArr = []; var noteArArr = [];
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); }) $("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); })
$('#note_ar_all').val(noteArArr); $('#note_ar_all').val(noteArArr);
//console.log(itemNameArr); //console.log(itemNameArr);
//return false; //return false;
}); });
}); });
</script> </script>
<div class="container"> <div class="container">
<?php <?php
include "bargain-record-submit.php"; include "bargain-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="bargainno">申請單號</label> <label for="bargainno">申請單號</label>
<input type="text" name="bargainno" id="bargainno" value="<?php echo $bargainno; ?>" readonly> <input type="text" name="bargainno" id="bargainno" value="<?php echo $bargainno; ?>" readonly>
</div> </div>
<div> <div>
<label for="department">作成單位</label> <label for="department">作成單位</label>
<input type="text" name="department" id="department" value="<?php echo $department_arr[$department_id]; ?>" readonly> <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; ?>"> <input type="hidden" name="department_id" id="department_id" value="<?php echo $department_id; ?>">
</div> </div>
<div> <div>
<label for="proposer">作成者</label> <label for="proposer">作成者</label>
<input type="text" name="proposer" id="proposer" value="<?php echo $user_name; ?>" readonly> <input type="text" name="proposer" id="proposer" value="<?php echo $user_name; ?>" readonly>
</div> </div>
<div> <div>
<label for="receiver">收文單位</label> <label for="receiver">收文單位</label>
<select name="receiver" id="receiver" required> <select name="receiver" id="receiver" required>
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($department_arr as $k => $v) { foreach ($department_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>"; echo "<option value=\"".$k."\">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="response_dt">回答期限</label><br> <label for="response_dt">回答期限</label><br>
<input type="date" name="response_dt" id="response_dt" required> <input type="date" name="response_dt" id="response_dt" required>
</div> </div>
<div> <div>
<label for="item">項目名稱</label> <label for="item">項目名稱</label>
<input type="text" name="item" id="item" size="60" maxlength="50" required> <input type="text" name="item" id="item" size="60" maxlength="50" required>
</div> </div>
<div> <div>
<label for="annual">年度議價件</label> <label for="annual">年度議價件</label>
<select name="annual" id="annual"> <select name="annual" id="annual">
<option value="Y"></option> <option value="Y"></option>
<option value="N"></option> <option value="N"></option>
</select> </select>
</div> </div>
<div> <div>
<label for="urgent">緊急件</label> <label for="urgent">緊急件</label>
<select name="urgent" id="urgent"> <select name="urgent" id="urgent">
<option value="Y"></option> <option value="Y"></option>
<option value="N"></option> <option value="N"></option>
</select> </select>
</div> </div>
<div> <div>
<label for="vendor">指定廠商</label> <label for="vendor">指定廠商</label>
<select name="vendor" id="vendor"> <select name="vendor" id="vendor">
<option value="Y"></option> <option value="Y"></option>
<option value="N"></option> <option value="N"></option>
</select> </select>
</div> </div>
<div> <div>
<label for="prospecting">現場勘查</label> <label for="prospecting">現場勘查</label>
<select name="prospecting" id="prospecting"> <select name="prospecting" id="prospecting">
<option value="Y"></option> <option value="Y"></option>
<option value="N"></option> <option value="N"></option>
</select> </select>
</div> </div>
<div> <div>
<label for="category">類別</label> <label for="category">類別</label>
<select name="category" id="category" required> <select name="category" id="category" required>
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($category_arr as $k => $v) { foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>"; echo "<option value=\"".$k."\">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="dealer">原廠或原代理商</label> <label for="dealer">原廠或原代理商</label>
<select name="dealer" id="dealer" required> <select name="dealer" id="dealer" required>
<option value="Y"></option> <option value="Y"></option>
<option value="N"></option> <option value="N"></option>
</select> </select>
</div> </div>
<div> <div>
<label for="reason">理由</label> <label for="reason">理由</label>
<input type="text" name="reason" id="reason" size="60" maxlength="50"> <input type="text" name="reason" id="reason" size="60" maxlength="50">
</div> </div>
<div> <div>
<label for="brand">品牌</label> <label for="brand">品牌</label>
<input type="text" name="brand" id="brand" maxlength="25"> <input type="text" name="brand" id="brand" maxlength="25">
</div> </div>
<div> <div>
<label for="model">型號</label> <label for="model">型號</label>
<input type="text" name="model" id="model" maxlength="25"> <input type="text" name="model" id="model" maxlength="25">
</div> </div>
<div> <div>
<label for="quantity">預估數量</label> <label for="quantity">預估數量</label>
<input type="text" name="quantity" id="quantity" required> <input type="text" name="quantity" id="quantity" required>
</div> </div>
<div> <div>
<label for="brandkeep">備選品牌</label> <label for="brandkeep">備選品牌</label>
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25"> <input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25">
</div> </div>
<div> <div>
<label for="lead_time">交期/施工期(天)</label> <label for="lead_time">交期/施工期(天)</label>
<input type="text" name="lead_time" id="lead_time"> <input type="text" name="lead_time" id="lead_time">
</div> </div>
<div> <div>
<label for="margin">質保金</label> <label for="margin">質保金</label>
<select name="margin" id="margin"> <select name="margin" id="margin">
<option value="Y"></option> <option value="Y"></option>
<option value="N"></option> <option value="N"></option>
</select> </select>
</div> </div>
<div> <div>
<label for="margin_day">質保期限(天)</label> <label for="margin_day">質保期限(天)</label>
<input type="text" name="margin_day" id="margin_day" required> <input type="text" name="margin_day" id="margin_day" required>
</div> </div>
<div> <div>
<label for="acceptance">驗收標準</label> <label for="acceptance">驗收標準</label>
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50"> <input type="text" name="acceptance" id="acceptance" size="104" maxlength="50">
</div> </div>
<div> <div>
<label for="purchase_history">歷史購買記錄</label> <label for="purchase_history">歷史購買記錄</label>
<select name="purchase_history" id="purchase_history"> <select name="purchase_history" id="purchase_history">
<option value="Y"></option> <option value="Y"></option>
<option value="N"></option> <option value="N"></option>
</select> </select>
</div> </div>
<div> <div>
<label for="attatch1">附件1</label> <label for="attatch1">附件1</label>
<div> <div>
<input type="file" name="attatch1" id="attatch1"> <input type="file" name="attatch1" id="attatch1">
</div> </div>
</div> </div>
<div> <div>
<label for="attatch2">附件2</label> <label for="attatch2">附件2</label>
<div> <div>
<input type="file" name="attatch2" id="attatch2"> <input type="file" name="attatch2" id="attatch2">
</div> </div>
</div> </div>
<div> <div>
<label for="item_description">項目描述</label> <label for="item_description">項目描述</label>
<input type="text" name="item_description" id="item_description" size="80" maxlength="120"> <input type="text" name="item_description" id="item_description" size="80" maxlength="120">
</div> </div>
<div> <div>
<label for="repairno">設備維修單號</label> <label for="repairno">設備維修單號</label>
<input type="text" name="repairno" id="repairno" maxlength="20"> <input type="text" name="repairno" id="repairno" maxlength="20">
</div> </div>
<div> <div>
<label for="category_repair">類別</label> <label for="category_repair">類別</label>
<select name="category_repair" id="category_repair" required> <select name="category_repair" id="category_repair" required>
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($category_arr as $k => $v) { foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>"; echo "<option value=\"".$k."\">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="content">內容</label><br> <label for="content">內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"></textarea> <textarea class="form-control2" name="content" id="content" rows="4" cols="100"></textarea>
</div> </div>
<div> <div>
<label for="quotation">採購報價單</label> <label for="quotation">採購報價單</label>
<input type="text" name="quotation" id="quotation" readonly> <input type="text" name="quotation" id="quotation" readonly>
</div> </div>
<div class="table-responsive" style="width:100%;margin-top:10px;"> <div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered"> <table id="tb1" class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th colspan="8"><h4>附件上傳及信息維護</h4></th> <th colspan="8"><h4>附件上傳及信息維護</h4></th>
</tr> </tr>
<tr> <tr>
<th rowspan="2" nowrap>序號</th> <th rowspan="2" nowrap>序號</th>
<th colspan="4">作成單位提供◎維護信息</th> <th colspan="4">作成單位提供◎維護信息</th>
<th colspan="3">配合單位提供◎維護信息</th> <th colspan="3">配合單位提供◎維護信息</th>
</tr> </tr>
<tr> <tr>
<th nowrap>供應商名稱</th> <th nowrap>供應商名稱</th>
<th nowrap>供應商報價單上傳</th> <th nowrap>供應商報價單上傳</th>
<th nowrap>報價</th> <th nowrap>報價</th>
<th nowrap>備註</th> <th nowrap>備註</th>
<th nowrap>議價後報價單上傳</th> <th nowrap>議價後報價單上傳</th>
<th nowrap>議價後報價</th> <th nowrap>議價後報價</th>
<th nowrap>備註</th> <th nowrap>備註</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr name="supplier_templ"> <tr name="supplier_templ">
<td>1</td> <td>1</td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></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="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="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="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="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="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> <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> <td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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"); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="submit" id="submit">確定</button> <button type="submit" name="submit" id="submit">確定</button>
</div> </div>
<input type="hidden" name="sup_id_all" id="sup_id_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_all" id="supplier_all">
<input type="hidden" name="quote_amt_be_all" id="quote_amt_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="note_be_all" id="note_be_all">
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_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="note_ar_all" id="note_ar_all">
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

56
wms/bargain-delete.php

@ -1,29 +1,29 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
/* 已進入簽核流程 /* 已進入簽核流程
$db_query = "select checker_1_result from bargin where id = '$id'"; $db_query = "select checker_1_result from bargin where id = '$id'";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
$row = mysqli_fetch_array($res, MYSQLI_ASSOC); $row = mysqli_fetch_array($res, MYSQLI_ASSOC);
if (!$row || $row["checker_1_result"]) { if (!$row || $row["checker_1_result"]) {
mysqli_free_result($res); mysqli_free_result($res);
mysqli_close($link); mysqli_close($link);
echo "<script>"; echo "<script>";
//echo "alert('審核中,已無法刪除');"; //echo "alert('審核中,已無法刪除');";
echo "alert('資料無法刪除');"; echo "alert('資料無法刪除');";
echo "location.href='pricereview-index.php'"; echo "location.href='pricereview-index.php'";
echo "</script>"; echo "</script>";
exit; exit;
} }
*/ */
$db_query = "delete from bargain_supplier where bid = '$id'"; $db_query = "delete from bargain_supplier where bid = '$id'";
if ($rs = mysqli_query($link, $db_query)) { if ($rs = mysqli_query($link, $db_query)) {
$db_query = "delete from bargain where id = '$id'"; $db_query = "delete from bargain where id = '$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
} }
header("Refresh:0; url=bargain-index.php?function_name=bargain&".$token_link); header("Refresh:0; url=bargain-index.php?function_name=bargain&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

748
wms/bargain-edit.php

@ -1,375 +1,375 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $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" => "維保電梯配件"]; $category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$db_query = "select * from bargain where id = '$id'"; $db_query = "select * from bargain where id = '$id'";
$data = mysqli_query($link, $db_query); $data = mysqli_query($link, $db_query);
$department_arr = []; $department_arr = [];
$sql = "select department_id, name from department"; $sql = "select department_id, name from department";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1]; $department_arr[$row[0]] = $row[1];
} }
mysqli_free_result($res); mysqli_free_result($res);
foreach($data as $data) : foreach($data as $data) :
$sql = "select name from account where accountid = '".$data['creater']."'"; $sql = "select name from account where accountid = '".$data['creater']."'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
list($creater_name) = $row; list($creater_name) = $row;
mysqli_free_result($res); mysqli_free_result($res);
$item_arr = []; $item_arr = [];
$sql = "select * from bargain_supplier where bid = '$id' order by supplier_id"; $sql = "select * from bargain_supplier where bid = '$id' order by supplier_id";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) { while ($row = mysqli_fetch_assoc($res)) {
$item_arr[$row['supplier_id']]['id'] = $row['id']; $item_arr[$row['supplier_id']]['id'] = $row['id'];
$item_arr[$row['supplier_id']]['supplier'] = $row['supplier']; $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']]['supplier_attatch_be'] = $row['supplier_attatch_be'];
$item_arr[$row['supplier_id']]['quote_amt_be'] = $row['quote_amt_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']]['note_be'] = $row['note_be'];
$item_arr[$row['supplier_id']]['supplier_attatch_ar'] = $row['supplier_attatch_ar']; $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']]['quote_amt_ar'] = $row['quote_amt_ar'];
$item_arr[$row['supplier_id']]['note_ar'] = $row['note_ar']; $item_arr[$row['supplier_id']]['note_ar'] = $row['note_ar'];
} }
mysqli_free_result($res); mysqli_free_result($res);
?> ?>
<style> <style>
</style> </style>
<script> <script>
function commafy(num) { function commafy(num) {
num = num + ""; num = num + "";
var re = /(-?\d+)(\d{3})/ var re = /(-?\d+)(\d{3})/
while (re.test(num)) { while (re.test(num)) {
num = num.replace(re, "$1,$2") num = num.replace(re, "$1,$2")
} }
return num; return num;
} }
$(function(){ $(function(){
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }) $('#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, ",")); }) $('#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, ",")); }) $('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$("input[name=quote_amt_be]").each(function(){ $("input[name=quote_amt_be]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); $(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
}); });
$("input[name=quote_amt_ar]").each(function(){ $("input[name=quote_amt_ar]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); }); $(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
}); });
$('#btnadd').click(function(){ $('#btnadd').click(function(){
if ($('tr[name=supplier_templ]').is(':visible') == false) $('tr[name=supplier_templ]').show(); if ($('tr[name=supplier_templ]').is(':visible') == false) $('tr[name=supplier_templ]').show();
else { else {
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end()); $('#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); //$('#tb1 tr:last').find('td').first().html($("tr[name='supplier_templ']").length);
} }
}); });
$('#update').click(function(){ $('#update').click(function(){
var bsidArr = []; var bsidArr = [];
$("input[name='bsid']").each(function(){ bsidArr.push($(this).val()); }) $("input[name='bsid']").each(function(){ bsidArr.push($(this).val()); })
$('#bsid_all').val(bsidArr); $('#bsid_all').val(bsidArr);
var supIdArr = []; var supIdArr = [];
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); }) $("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); })
$('#sup_id_all').val(supIdArr); $('#sup_id_all').val(supIdArr);
var supplierArr = []; var supplierArr = [];
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); }) $("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); })
$('#supplier_all').val(supplierArr); $('#supplier_all').val(supplierArr);
var supplierAttatchBeAllArr = []; var supplierAttatchBeAllArr = [];
$("input[name='supplier_attatch_be']").each(function(){ supplierAttatchBeAllArr.push($(this).val()); }) $("input[name='supplier_attatch_be']").each(function(){ supplierAttatchBeAllArr.push($(this).val()); })
$('#supplier_attatch_be_all').val(supplierAttatchBeAllArr); $('#supplier_attatch_be_all').val(supplierAttatchBeAllArr);
var quoteAmtBeArr = []; var quoteAmtBeArr = [];
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); }) $("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_be_all').val(quoteAmtBeArr); $('#quote_amt_be_all').val(quoteAmtBeArr);
var noteBeArr = []; var noteBeArr = [];
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); }) $("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); })
$('#note_be_all').val(noteBeArr); $('#note_be_all').val(noteBeArr);
var supplierAttatchArArr = []; var supplierAttatchArArr = [];
$("input[name='supplier_attatch_ar']").each(function(){ supplierAttatchArArr.push($(this).val()); }) $("input[name='supplier_attatch_ar']").each(function(){ supplierAttatchArArr.push($(this).val()); })
$('#supplier_attatch_ar_all').val(supplierAttatchArArr); $('#supplier_attatch_ar_all').val(supplierAttatchArArr);
var quoteAmtArArr = []; var quoteAmtArArr = [];
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); }) $("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_ar_all').val(quoteAmtArArr); $('#quote_amt_ar_all').val(quoteAmtArArr);
var noteArArr = []; var noteArArr = [];
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); }) $("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); })
$('#note_ar_all').val(noteArArr); $('#note_ar_all').val(noteArArr);
//console.log(noteArArr); //console.log(noteArArr);
//return false; //return false;
}); });
}); });
</script> </script>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="bargain-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="bargain-record-update.php" enctype="multipart/form-data">
<div> <div>
<label for="bargainno">申請單號</label> <label for="bargainno">申請單號</label>
<input type="text" name="bargainno" id="bargainno" value="<?php echo $data['bargainno']; ?>" readonly> <input type="text" name="bargainno" id="bargainno" value="<?php echo $data['bargainno']; ?>" readonly>
</div> </div>
<div> <div>
<label for="department">作成單位</label> <label for="department">作成單位</label>
<input type="text" name="department" id="department" value="<?php echo $department_arr[$data['department_id']]; ?>" disabled> <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']; ?>"> <input type="hidden" name="department_id" id="department_id" value="<?php echo $data['department_id']; ?>">
</div> </div>
<div> <div>
<label for="proposer">作成者</label> <label for="proposer">作成者</label>
<input type="text" name="proposer" id="proposer" value="<?php echo $creater_name; ?>" disabled> <input type="text" name="proposer" id="proposer" value="<?php echo $creater_name; ?>" disabled>
</div> </div>
<div> <div>
<label for="receiver">收文單位</label> <label for="receiver">收文單位</label>
<select name="receiver" id="receiver" required> <select name="receiver" id="receiver" required>
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($department_arr as $k => $v) { foreach ($department_arr as $k => $v) {
echo "<option value=\"".$k."\""; echo "<option value=\"".$k."\"";
if ($data["receiver"] == $k) echo " selected"; if ($data["receiver"] == $k) echo " selected";
echo ">".$v."</option>"; echo ">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="response_dt">回答期限</label><br> <label for="response_dt">回答期限</label><br>
<input type="date" name="response_dt" id="response_dt" value="<?php echo $data['response_dt']; ?>" required> <input type="date" name="response_dt" id="response_dt" value="<?php echo $data['response_dt']; ?>" required>
</div> </div>
<div> <div>
<label for="item">項目名稱</label> <label for="item">項目名稱</label>
<input type="text" name="item" id="item" size="60" maxlength="50" value="<?php echo $data['item']; ?>" required> <input type="text" name="item" id="item" size="60" maxlength="50" value="<?php echo $data['item']; ?>" required>
</div> </div>
<div> <div>
<label for="annual">年度議價件</label> <label for="annual">年度議價件</label>
<select name="annual" id="annual"> <select name="annual" id="annual">
<option value="Y"<?php if ($data['annual']=="Y") echo " selected"; ?>></option> <option value="Y"<?php if ($data['annual']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['annual']=="N") echo " selected"; ?>></option> <option value="N"<?php if ($data['annual']=="N") echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="urgent">緊急件</label> <label for="urgent">緊急件</label>
<select name="urgent" id="urgent"> <select name="urgent" id="urgent">
<option value="Y"<?php if ($data['urgent']=="Y") echo " selected"; ?>></option> <option value="Y"<?php if ($data['urgent']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['urgent']=="N") echo " selected"; ?>></option> <option value="N"<?php if ($data['urgent']=="N") echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="vendor">指定廠商</label> <label for="vendor">指定廠商</label>
<select name="vendor" id="vendor"> <select name="vendor" id="vendor">
<option value="Y"<?php if ($data['vendor']=="Y") echo " selected"; ?>></option> <option value="Y"<?php if ($data['vendor']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['vendor']=="N") echo " selected"; ?>></option> <option value="N"<?php if ($data['vendor']=="N") echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="prospecting">現場勘查</label> <label for="prospecting">現場勘查</label>
<select name="prospecting" id="prospecting"> <select name="prospecting" id="prospecting">
<option value="Y"<?php if ($data['prospecting']=="Y") echo " selected"; ?>></option> <option value="Y"<?php if ($data['prospecting']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['prospecting']=="N") echo " selected"; ?>></option> <option value="N"<?php if ($data['prospecting']=="N") echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="category">類別</label> <label for="category">類別</label>
<select name="category" id="category" required> <select name="category" id="category" required>
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($category_arr as $k => $v) { foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\""; echo "<option value=\"".$k."\"";
if ($data["category"] == $k) echo " selected"; if ($data["category"] == $k) echo " selected";
echo ">".$v."</option>"; echo ">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="dealer">原廠或原代理商</label> <label for="dealer">原廠或原代理商</label>
<select name="dealer" id="dealer" required> <select name="dealer" id="dealer" required>
<option value="Y"<?php if ($data['dealer']=="Y") echo " selected"; ?>></option> <option value="Y"<?php if ($data['dealer']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['dealer']=="N") echo " selected"; ?>></option> <option value="N"<?php if ($data['dealer']=="N") echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="reason">理由</label> <label for="reason">理由</label>
<input type="text" name="reason" id="reason" size="60" maxlength="50" value="<?php echo $data['reason']; ?>"> <input type="text" name="reason" id="reason" size="60" maxlength="50" value="<?php echo $data['reason']; ?>">
</div> </div>
<div> <div>
<label for="brand">品牌</label> <label for="brand">品牌</label>
<input type="text" name="brand" id="brand" maxlength="25" value="<?php echo $data['brand']; ?>"> <input type="text" name="brand" id="brand" maxlength="25" value="<?php echo $data['brand']; ?>">
</div> </div>
<div> <div>
<label for="model">型號</label> <label for="model">型號</label>
<input type="text" name="model" id="model" maxlength="25" value="<?php echo $data['model']; ?>"> <input type="text" name="model" id="model" maxlength="25" value="<?php echo $data['model']; ?>">
</div> </div>
<div> <div>
<label for="quantity">預估數量</label> <label for="quantity">預估數量</label>
<input type="text" name="quantity" id="quantity" value="<?php echo number_format($data['quantity']); ?>" required> <input type="text" name="quantity" id="quantity" value="<?php echo number_format($data['quantity']); ?>" required>
</div> </div>
<div> <div>
<label for="brandkeep">備選品牌</label> <label for="brandkeep">備選品牌</label>
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25" value="<?php echo $data['brandkeep']; ?>"> <input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25" value="<?php echo $data['brandkeep']; ?>">
</div> </div>
<div> <div>
<label for="lead_time">交期/施工期(天)</label> <label for="lead_time">交期/施工期(天)</label>
<input type="text" name="lead_time" id="lead_time" value="<?php echo number_format($data['lead_time']); ?>"> <input type="text" name="lead_time" id="lead_time" value="<?php echo number_format($data['lead_time']); ?>">
</div> </div>
<div> <div>
<label for="margin">質保金</label> <label for="margin">質保金</label>
<select name="margin" id="margin"> <select name="margin" id="margin">
<option value="Y"<?php if ($data['margin']=="Y") echo " selected"; ?>></option> <option value="Y"<?php if ($data['margin']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['margin']=="N") echo " selected"; ?>></option> <option value="N"<?php if ($data['margin']=="N") echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="margin_day">質保期限(天)</label> <label for="margin_day">質保期限(天)</label>
<input type="text" name="margin_day" id="margin_day" value="<?php echo number_format($data['margin_day']); ?>" required> <input type="text" name="margin_day" id="margin_day" value="<?php echo number_format($data['margin_day']); ?>" required>
</div> </div>
<div> <div>
<label for="acceptance">驗收標準</label> <label for="acceptance">驗收標準</label>
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50" value="<?php echo $data['acceptance']; ?>"> <input type="text" name="acceptance" id="acceptance" size="104" maxlength="50" value="<?php echo $data['acceptance']; ?>">
</div> </div>
<div> <div>
<label for="purchase_history">歷史購買記錄</label> <label for="purchase_history">歷史購買記錄</label>
<select name="purchase_history" id="purchase_history"> <select name="purchase_history" id="purchase_history">
<option value="Y"<?php if ($data['purchase_history']=="Y") echo " selected"; ?>></option> <option value="Y"<?php if ($data['purchase_history']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['purchase_history']=="N") echo " selected"; ?>></option> <option value="N"<?php if ($data['purchase_history']=="N") echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="attatch1">附件1</label> <label for="attatch1">附件1</label>
<?php <?php
if ($data["attatch1"]) echo "<a href=\"".$data["attatch1"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)."</a>"; if ($data["attatch1"]) echo "<a href=\"".$data["attatch1"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)."</a>";
?> ?>
<div> <div>
<input type="file" name="attatch1" id="attatch1"> <input type="file" name="attatch1" id="attatch1">
</div> </div>
</div> </div>
<div> <div>
<label for="attatch2">附件2</label> <label for="attatch2">附件2</label>
<?php <?php
if ($data["attatch2"]) echo "<a href=\"".$data["attatch2"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)."</a>"; if ($data["attatch2"]) echo "<a href=\"".$data["attatch2"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)."</a>";
?> ?>
<div> <div>
<input type="file" name="attatch2" id="attatch2"> <input type="file" name="attatch2" id="attatch2">
</div> </div>
</div> </div>
<div> <div>
<label for="item_description">項目描述</label> <label for="item_description">項目描述</label>
<input type="text" name="item_description" id="item_description" size="80" maxlength="120" value="<?php echo $data['item_description']; ?>"> <input type="text" name="item_description" id="item_description" size="80" maxlength="120" value="<?php echo $data['item_description']; ?>">
</div> </div>
<div> <div>
<label for="repairno">設備維修單號</label> <label for="repairno">設備維修單號</label>
<input type="text" name="repairno" id="repairno" maxlength="20" value="<?php echo $data['repairno']; ?>"> <input type="text" name="repairno" id="repairno" maxlength="20" value="<?php echo $data['repairno']; ?>">
</div> </div>
<div> <div>
<label for="category_repair">類別</label> <label for="category_repair">類別</label>
<select name="category_repair" id="category_repair" required> <select name="category_repair" id="category_repair" required>
<option value="">請選擇</option> <option value="">請選擇</option>
<?php <?php
foreach ($category_arr as $k => $v) { foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\""; echo "<option value=\"".$k."\"";
if ($data["category_repair"] == $k) echo " selected"; if ($data["category_repair"] == $k) echo " selected";
echo ">".$v."</option>"; echo ">".$v."</option>";
} }
?> ?>
</select> </select>
</div> </div>
<div> <div>
<label for="content">內容</label><br> <label for="content">內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"><?php echo $data['content']; ?></textarea> <textarea class="form-control2" name="content" id="content" rows="4" cols="100"><?php echo $data['content']; ?></textarea>
</div> </div>
<div> <div>
<label for="quotation">採購報價單</label> <label for="quotation">採購報價單</label>
<input type="text" name="quotation" id="quotation" value="<?php echo $data['quotation']; ?>" readonly> <input type="text" name="quotation" id="quotation" value="<?php echo $data['quotation']; ?>" readonly>
</div> </div>
<div class="table-responsive" style="width:100%;margin-top:10px;"> <div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered"> <table id="tb1" class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th colspan="8"><h4>附件上傳及信息維護</h4></th> <th colspan="8"><h4>附件上傳及信息維護</h4></th>
</tr> </tr>
<tr> <tr>
<th rowspan="2" nowrap>序號</th> <th rowspan="2" nowrap>序號</th>
<th colspan="4">作成單位提供◎維護信息</th> <th colspan="4">作成單位提供◎維護信息</th>
<th colspan="3">配合單位提供◎維護信息</th> <th colspan="3">配合單位提供◎維護信息</th>
</tr> </tr>
<tr> <tr>
<th nowrap>供應商名稱</th> <th nowrap>供應商名稱</th>
<th nowrap>供應商報價單上傳</th> <th nowrap>供應商報價單上傳</th>
<th nowrap>報價</th> <th nowrap>報價</th>
<th nowrap>備註</th> <th nowrap>備註</th>
<th nowrap>議價後報價單上傳</th> <th nowrap>議價後報價單上傳</th>
<th nowrap>議價後報價</th> <th nowrap>議價後報價</th>
<th nowrap>備註</th> <th nowrap>備註</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach ($item_arr as $supplier_id => $val) { foreach ($item_arr as $supplier_id => $val) {
?> ?>
<tr> <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><?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><input type="text" name="supplier" class="form-control input-sm" size="10" value="<?php echo $val['supplier']; ?>"></td>
<td> <td>
<?php <?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>"; 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 "--"; else echo "--";
?> ?>
</td> </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="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><input type="text" name="note_be" class="form-control input-sm" size="10" value="<?php echo $val['note_be']; ?>"></td>
<td> <td>
<?php <?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>"; 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 "--"; 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="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> <td><input type="text" name="note_ar" class="form-control input-sm" size="10" value="<?php echo $val['note_ar']; ?>"></td>
</tr> </tr>
<?php <?php
} }
?> ?>
<tr name="supplier_templ" style="display:none;"> <tr name="supplier_templ" style="display:none;">
<td></td> <td></td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></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="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="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="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="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="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> <td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td>
</tr> </tr>
</tr> </tr>
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td> <td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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"); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="update" id="update">確定</button> <button type="submit" name="update" id="update">確定</button>
</div> </div>
<input type="hidden" name="bsid_all" id="bsid_all"> <input type="hidden" name="bsid_all" id="bsid_all">
<input type="hidden" name="sup_id_all" id="sup_id_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_all" id="supplier_all">
<input type="hidden" name="supplier_attatch_be_all" id="supplier_attatch_be_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="quote_amt_be_all" id="quote_amt_be_all">
<input type="hidden" name="note_be_all" id="note_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="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="quote_amt_ar_all" id="quote_amt_ar_all">
<input type="hidden" name="note_ar_all" id="note_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="id" value="<?php echo $id; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

286
wms/bargain-index.php

@ -1,144 +1,144 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"]; $category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$sql = "select department_id, name from department"; $sql = "select department_id, name from department";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1]; $department_arr[$row[0]] = $row[1];
} }
mysqli_free_result($res); mysqli_free_result($res);
// sql語法存在變數中 // sql語法存在變數中
$sql = "select * from bargain order by id"; $sql = "select * from bargain order by id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<p> <p>
<a href="bargain-create.php?function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="bargain-create.php?function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:bargain-index.php"); header("Location:bargain-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <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> <th>型號</th>
<th>預估數量</th> <th>預估數量</th>
<th>建檔人</th> <th>建檔人</th>
<th>建檔時間</th> <th>建檔時間</th>
<th>修改</th> <th>修改</th>
<th>刪除</th> <th>刪除</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['bargainno']; ?></td> <td><?php echo $data['bargainno']; ?></td>
<td><?php echo $department_arr[$data['department_id']]; ?></td> <td><?php echo $department_arr[$data['department_id']]; ?></td>
<td><?php echo $data['proposer']; ?></td> <td><?php echo $data['proposer']; ?></td>
<td><?php echo $department_arr[$data['receiver']]; ?></td> <td><?php echo $department_arr[$data['receiver']]; ?></td>
<td><?php echo $data['response_dt']; ?></td> <td><?php echo $data['response_dt']; ?></td>
<td><?php echo $data['item']; ?></td> <td><?php echo $data['item']; ?></td>
<td><?php echo $category_arr[$data['category']]; ?></td> <td><?php echo $category_arr[$data['category']]; ?></td>
<td><?php echo $data['brand']; ?></td> <td><?php echo $data['brand']; ?></td>
<td><?php echo $data['model']; ?></td> <td><?php echo $data['model']; ?></td>
<td><?php echo number_format($data['quantity']); ?></td> <td><?php echo number_format($data['quantity']); ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<td> <td>
<p> <p>
<a href="bargain-edit.php?id=<?php echo $data['id']; ?>&function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <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> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<td> <td>
<p> <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?')"> <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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

296
wms/bargain-record-submit.php

@ -1,149 +1,149 @@
<?php <?php
$accountid= ""; $accountid= "";
$facilityno= ""; $facilityno= "";
$issue_time= ""; $issue_time= "";
$process= ""; $process= "";
$memo= ""; $memo= "";
$creater= ""; $creater= "";
$create_at= ""; $create_at= "";
$accountid_error= ""; $accountid_error= "";
$facilityno_error= ""; $facilityno_error= "";
$issue_time_error= ""; $issue_time_error= "";
$process_error= ""; $process_error= "";
$memo_error= ""; $memo_error= "";
$creater_error= ""; $creater_error= "";
$create_at_error= ""; $create_at_error= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
//print_r($_POST); //print_r($_POST);
//print_r($_FILES);exit; //print_r($_FILES);exit;
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
$sql = "select max(bargainno) as maxno from bargain"; $sql = "select max(bargainno) as maxno from bargain";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$bargainno_check = $row[0] ? $row[0]+1 : date("Ym")."001"; $bargainno_check = $row[0] ? $row[0]+1 : date("Ym")."001";
if ($bargainno_check <> $bargainno) $bargainno = $bargainno_check; if ($bargainno_check <> $bargainno) $bargainno = $bargainno_check;
if ($_FILES["attatch1"]["error"] == 0) { if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"]; $file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; $temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"]; $file_size = $_FILES["attatch1"]["size"];
$target_dir = "bargain-uploads/"; $target_dir = "bargain-uploads/";
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name)); $target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1; $upload_ok = 1;
//if (file_exists($target_file1)) unlink($target_file1); //if (file_exists($target_file1)) unlink($target_file1);
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) { foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
} else $target_file1 = ""; } else $target_file1 = "";
if ($_FILES["attatch2"]["error"] == 0) { if ($_FILES["attatch2"]["error"] == 0) {
$file_name = $_FILES["attatch2"]["name"]; $file_name = $_FILES["attatch2"]["name"];
$temp_file_name = $_FILES["attatch2"]["tmp_name"]; $temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"]; $file_size = $_FILES["attatch2"]["size"];
$target_dir = "bargain-uploads/"; $target_dir = "bargain-uploads/";
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name)); $target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1; $upload_ok = 1;
//if (file_exists($target_file2)) unlink($target_file2); //if (file_exists($target_file2)) unlink($target_file2);
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) { foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); $upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
} else $target_file2 = ""; } else $target_file2 = "";
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建。');"; echo "alert('檔案上傳失敗,資料請重建。');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} }
$db_query = "insert into bargain (bargainno, department_id, proposer, receiver, response_dt, item, annual, urgent, vendor, prospecting, category, "; $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 .= "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 .= "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 .= "'$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 .= "'$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')"; $db_query .= "'$target_file1', '$target_file2', '$item_description', '$repairno', '$category_repair', '$content', '$quotation', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
if ($result && $sup_id_all != "") { if ($result && $sup_id_all != "") {
$bid = mysqli_insert_id($link); $bid = mysqli_insert_id($link);
$sup_id_arr = explode(",", $sup_id_all); $sup_id_arr = explode(",", $sup_id_all);
$supplier_arr = explode(",", $supplier_all); $supplier_arr = explode(",", $supplier_all);
$quote_amt_be_arr = explode(",", $quote_amt_be_all); $quote_amt_be_arr = explode(",", $quote_amt_be_all);
$note_be_arr = explode(",", $note_be_all); $note_be_arr = explode(",", $note_be_all);
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all); $quote_amt_ar_arr = explode(",", $quote_amt_ar_all);
$note_ar_arr = explode(",", $note_ar_all); $note_ar_arr = explode(",", $note_ar_all);
$item_no = 1; $item_no = 1;
for ($i=0; $i<count($supplier_arr); $i++) { for ($i=0; $i<count($supplier_arr); $i++) {
if (!$sup_id_arr[$i]) $sup_id_arr[$i] = 0; if (!$sup_id_arr[$i]) $sup_id_arr[$i] = 0;
if (!$supplier_arr[$i]) continue; if (!$supplier_arr[$i]) continue;
if ($_FILES["supplier_attatch_be"]["name"][$i] && ($_FILES["supplier_attatch_be"]["error"][$i] == 0)) { if ($_FILES["supplier_attatch_be"]["name"][$i] && ($_FILES["supplier_attatch_be"]["error"][$i] == 0)) {
$file_name = $_FILES["supplier_attatch_be"]["name"][$i]; $file_name = $_FILES["supplier_attatch_be"]["name"][$i];
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$i]; $temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$i];
$file_size = $_FILES["supplier_attatch_be"]["size"][$i]; $file_size = $_FILES["supplier_attatch_be"]["size"][$i];
$target_dir = "bargain-uploads/supplier/"; $target_dir = "bargain-uploads/supplier/";
$target_file_be = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name)); $target_file_be = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION);
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be); $upload_res_be = move_uploaded_file($temp_file_name, $target_file_be);
} else $target_file_be = ""; } else $target_file_be = "";
if ($_FILES["supplier_attatch_ar"]["name"][$i] && ($_FILES["supplier_attatch_ar"]["error"][$i] == 0)) { if ($_FILES["supplier_attatch_ar"]["name"][$i] && ($_FILES["supplier_attatch_ar"]["error"][$i] == 0)) {
$file_name = $_FILES["supplier_attatch_ar"]["name"][$i]; $file_name = $_FILES["supplier_attatch_ar"]["name"][$i];
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$i]; $temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$i];
$file_size = $_FILES["supplier_attatch_ar"]["size"][$i]; $file_size = $_FILES["supplier_attatch_ar"]["size"][$i];
$target_dir = "bargain-uploads/supplier/"; $target_dir = "bargain-uploads/supplier/";
$target_file_ar = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name)); $target_file_ar = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION);
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar); $upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar);
} else $target_file_ar = ""; } else $target_file_ar = "";
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) { if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) {
$sql = "delete from bargain where id = '$bid'"; $sql = "delete from bargain where id = '$bid'";
mysqli_query($link, $sql); mysqli_query($link, $sql);
$sql = "delete from bargain_supplier where bid = '$bid'"; $sql = "delete from bargain_supplier where bid = '$bid'";
mysqli_query($link, $sql); mysqli_query($link, $sql);
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建!".$sql."');"; echo "alert('檔案上傳失敗,資料請重建!".$sql."');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} }
$quote_amt_be_arr[$i] = str_replace(",", "", $quote_amt_be_arr[$i]); $quote_amt_be_arr[$i] = str_replace(",", "", $quote_amt_be_arr[$i]);
$quote_amt_ar_all[$i] = str_replace(",", "", $quote_amt_ar_all[$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 = "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 .= "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 .= "'$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')"; $db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
$item_no++; $item_no++;
} }
} }
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功(申請單號:".$bargainno.")');"; echo "alert('新增成功(申請單號:".$bargainno.")');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

286
wms/bargain-record-update.php

@ -1,144 +1,144 @@
<?php <?php
include "header.php"; include "header.php";
if (isset($_POST['update'])) { if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
//print_r($_POST); //print_r($_POST);
//print_r($_FILES);exit; //print_r($_FILES);exit;
$sql_atta = ""; $sql_atta = "";
$quantity = str_replace(",", "", $quantity); $quantity = str_replace(",", "", $quantity);
$lead_time = str_replace(",", "", $lead_time); $lead_time = str_replace(",", "", $lead_time);
$margin_day = str_replace(",", "", $margin_day); $margin_day = str_replace(",", "", $margin_day);
if ($_FILES["attatch1"]["error"] == 0) { if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"]; $file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; $temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"]; $file_size = $_FILES["attatch1"]["size"];
$target_dir = "bargain-uploads/"; $target_dir = "bargain-uploads/";
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name)); $target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1; $upload_ok = 1;
//if (file_exists($target_file1)) unlink($target_file1); //if (file_exists($target_file1)) unlink($target_file1);
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) { foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
$sql_atta .= "attatch1 = '$target_file1', "; $sql_atta .= "attatch1 = '$target_file1', ";
} else $target_file1 = ""; } else $target_file1 = "";
if ($_FILES["attatch2"]["error"] == 0) { if ($_FILES["attatch2"]["error"] == 0) {
$file_name = $_FILES["attatch2"]["name"]; $file_name = $_FILES["attatch2"]["name"];
$temp_file_name = $_FILES["attatch2"]["tmp_name"]; $temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"]; $file_size = $_FILES["attatch2"]["size"];
$target_dir = "bargain-uploads/"; $target_dir = "bargain-uploads/";
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name)); $target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1; $upload_ok = 1;
//if (file_exists($target_file2)) unlink($target_file2); //if (file_exists($target_file2)) unlink($target_file2);
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) { foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) {
unlink($todelfile); unlink($todelfile);
} }
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2); $upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
$sql_atta .= "attatch2 = '$target_file2', "; $sql_atta .= "attatch2 = '$target_file2', ";
} else $target_file2 = ""; } else $target_file2 = "";
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) { if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作。');"; echo "alert('檔案上傳失敗,請重新操作。');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} }
$db_query = "update bargain set receiver = '$receiver', response_dt = '$response_dt', item = '$item', annual = '$annual', urgent = '$urgent', "; $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 .= "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 .= "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 .= "acceptance = '$acceptance', purchase_history = '$purchase_history', item_description = '$item_description', repairno = '$repairno', ";
$db_query .= $sql_atta; $db_query .= $sql_atta;
$db_query .= "category_repair = '$category_repair', content = '$content', quotation = '$quotation', create_dt = '$create_at' "; $db_query .= "category_repair = '$category_repair', content = '$content', quotation = '$quotation', create_dt = '$create_at' ";
$db_query .= "where id = '$id'"; $db_query .= "where id = '$id'";
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
if ($result && $sup_id_all != "") { if ($result && $sup_id_all != "") {
$bsid_arr = explode(",", $bsid_all); $bsid_arr = explode(",", $bsid_all);
$sup_id_arr = explode(",", $sup_id_all); $sup_id_arr = explode(",", $sup_id_all);
$supplier_arr = explode(",", rtrim($supplier_all, ",")); $supplier_arr = explode(",", rtrim($supplier_all, ","));
$quote_amt_be_arr = explode(",", $quote_amt_be_all); $quote_amt_be_arr = explode(",", $quote_amt_be_all);
$note_be_arr = explode(",", $note_be_all); $note_be_arr = explode(",", $note_be_all);
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all); $quote_amt_ar_arr = explode(",", $quote_amt_ar_all);
$note_ar_arr = explode(",", $note_ar_all); $note_ar_arr = explode(",", $note_ar_all);
$item_no = 1; $item_no = 1;
// 有新增的供應商 // 有新增的供應商
$new_sup_cnt = count($supplier_arr) - count($bsid_arr); $new_sup_cnt = count($supplier_arr) - count($bsid_arr);
if ($new_sup_cnt > 0) $next_sup_id = max($sup_id_arr)+1; if ($new_sup_cnt > 0) $next_sup_id = max($sup_id_arr)+1;
$idx = 0; $idx = 0;
for ($i=0; $i<count($supplier_arr); $i++) { for ($i=0; $i<count($supplier_arr); $i++) {
if ($new_sup_cnt > 0 && $bsid_arr[$i] == "") { // 新增 if ($new_sup_cnt > 0 && $bsid_arr[$i] == "") { // 新增
$target_file_be = $target_file_ar = ""; $target_file_be = $target_file_ar = "";
if ($_FILES["supplier_attatch_be"]["name"]) { // 有上傳檔案 if ($_FILES["supplier_attatch_be"]["name"]) { // 有上傳檔案
if ($_FILES["supplier_attatch_be"]["name"][$idx] && ($_FILES["supplier_attatch_be"]["error"][$idx] == 0)) { if ($_FILES["supplier_attatch_be"]["name"][$idx] && ($_FILES["supplier_attatch_be"]["error"][$idx] == 0)) {
$file_name = $_FILES["supplier_attatch_be"]["name"][$idx]; $file_name = $_FILES["supplier_attatch_be"]["name"][$idx];
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$idx]; $temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$idx];
$file_size = $_FILES["supplier_attatch_be"]["size"][$idx]; $file_size = $_FILES["supplier_attatch_be"]["size"][$idx];
$target_dir = "bargain-uploads/supplier/"; $target_dir = "bargain-uploads/supplier/";
$target_file_be = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name)); $target_file_be = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION);
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be); $upload_res_be = move_uploaded_file($temp_file_name, $target_file_be);
} }
} }
if ($_FILES["supplier_attatch_ar"]["name"]) { // 有上傳檔案 if ($_FILES["supplier_attatch_ar"]["name"]) { // 有上傳檔案
if ($_FILES["supplier_attatch_ar"]["name"][$idx] && ($_FILES["supplier_attatch_ar"]["error"][$idx] == 0)) { if ($_FILES["supplier_attatch_ar"]["name"][$idx] && ($_FILES["supplier_attatch_ar"]["error"][$idx] == 0)) {
$file_name = $_FILES["supplier_attatch_ar"]["name"][$idx]; $file_name = $_FILES["supplier_attatch_ar"]["name"][$idx];
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$idx]; $temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$idx];
$file_size = $_FILES["supplier_attatch_ar"]["size"][$idx]; $file_size = $_FILES["supplier_attatch_ar"]["size"][$idx];
$target_dir = "bargain-uploads/supplier/"; $target_dir = "bargain-uploads/supplier/";
$target_file_ar = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name)); $target_file_ar = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION);
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar); $upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar);
} }
} }
if ($upload_res_be || $upload_res_ar) $idx++; if ($upload_res_be || $upload_res_ar) $idx++;
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) { if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作!".$sql."');"; echo "alert('檔案上傳失敗,請重新操作!".$sql."');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} }
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, "; $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 .= "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 .= "'$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')"; $db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
$next_sup_id++; $next_sup_id++;
} else { // 修改(不支援重傳檔案) } else { // 修改(不支援重傳檔案)
$db_query = "update bargain_supplier set supplier = '$supplier_arr[$i]', quote_amt_be = '$quote_amt_be_arr[$i]', "; $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_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 .= "note_ar = '$note_ar_arr[$i]', create_at = '$create_at' ";
$db_query .= "where id = '$bsid_arr[$i]'"; $db_query .= "where id = '$bsid_arr[$i]'";
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
} }
} }
} }
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';"; echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

129
wms/board-create.php

@ -1,51 +1,80 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<script> <script>
$(function(){ $(function() {});
}); </script>
</script> <div class="container">
<div class="container"> <?php
<?php include "board-record-submit.php";
include "board-record-submit.php"; /*
/* if($_SERVER["REQUEST_METHOD"] == "POST"){
if($_SERVER["REQUEST_METHOD"] == "POST"){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ echo "<p class='error'>Please fill up the required field!</p>";
echo "<p class='error'>Please fill up the required field!</p>"; } else {
} else { echo "<p class='success'>Record has added successfully</p>";
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">
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> <div class='container'>
<div> <div class='row'>
<label for="title">主旨</label> <div class='col-md-6 col-12'>
<input type="text" name="title" id="title" size="30" maxlength="25" required> <label for="title">主旨</label>
</div> <input type="text" name="title" id="title" size="30" maxlength="25" required>
<!--<div> </div>
<label for="pin">置頂</label> <div class='col-md-6 col-12'>
<select name="pin" id="pin"> <label for="attatch1">附件上傳</label>
<option value="Y"></option> <div>
<option value="N" selected></option> <input type="file" name="attatch1" id="attatch1">
</select> </div>
</div>--> </div>
<div> </div>
<label for="attatch1">附件上傳</label> <div class='row'>
<div> <div class='col-md-3 col-3'>
<input type="file" name="attatch1" id="attatch1"> <label>連結名稱</label>
</div> <input type="text" id="linkName">
</div> </div>
<div> <div class='col-md-9 col-6'>
<label for="content">公告內容</label><br> <label>連結網址</label>
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required></textarea> <input type="text" id="linkURL">
</div> </div>
<div> <div class='col-md-2 col-2'>
<button type="submit" name="submit" id="submit">確定</button> <button type='button' onclick="insertLink()">插入超連結</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> </div>
</form> <div class='row'>
</div> <div class='col-md-12 col-12'>
<label for="content">公告內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required></textarea>
</div>
</div>
<br />
<div class='row'>
<div class='col-md-12 col-12'>
<input type="hidden" name="token" value="<?php echo $token; ?>">
<button type="submit" name="submit" id="submit">確定</button>
</div>
</div>
</form>
</div>
<script>
function insertLink() {
var linkName = document.getElementById('linkName').value;
var linkURL = document.getElementById('linkURL').value;
if (linkName !== '' && linkURL !== '') {
var textarea = document.getElementById('content');
var link = '<a style="color:blue" href="' + linkURL + '">' + linkName + '</a>';
// 插入超連結到 textarea 中
textarea.value += link;
} else {
alert('請輸入連結名稱和 URL');
}
}
</script>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

44
wms/board-delete.php

@ -1,23 +1,23 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $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'"; $db_query = "update board set status = 'N', create_at = NOW() where id = '$id' and creater = '$user_id'";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
/* /*
$db_query = "select attach from board where id = '$id'"; $db_query = "select attach from board where id = '$id'";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$target_file = $row[0]; $target_file = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
$db_query = "delete from board where id = '$id'"; $db_query = "delete from board where id = '$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
unlink($target_file); unlink($target_file);
*/ */
//header("Location:board-index.php"); //header("Location:board-index.php");
header("Refresh:0; url=board-index.php?function_name=board&".$token_link); header("Refresh:0; url=board-index.php?function_name=board&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

118
wms/board-edit.php

@ -1,60 +1,60 @@
<?php <?php
exit; exit;
require_once "database.php"; require_once "database.php";
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "select * from board where id = '$id'"; $db_query = "select * from board where id = '$id'";
$data = mysqli_query($link, $db_query); $data = mysqli_query($link, $db_query);
foreach($data as $data) : foreach($data as $data) :
?> ?>
<script> <script>
$(function(){ $(function(){
}); });
</script> </script>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="board-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="board-record-update.php" enctype="multipart/form-data">
<div> <div>
<label for="title">主旨</label> <label for="title">主旨</label>
<input type="text" name="title" id="title" size="30" maxlength="25" value="<?php echo $data['title']; ?>" required> <input type="text" name="title" id="title" size="30" maxlength="25" value="<?php echo $data['title']; ?>" required>
</div> </div>
<!--<div> <!--<div>
<label for="sdate">開始日期</label><br> <label for="sdate">開始日期</label><br>
<input type="date" name="sdate" id="sdate" value="<?php echo $data['sdate']; ?>" required> <input type="date" name="sdate" id="sdate" value="<?php echo $data['sdate']; ?>" required>
</div> </div>
<div> <div>
<label for="edate">結束日期</label><br> <label for="edate">結束日期</label><br>
<input type="date" name="edate" id="edate" value="<?php echo $data['edate']; ?>" required> <input type="date" name="edate" id="edate" value="<?php echo $data['edate']; ?>" required>
</div>--> </div>-->
<div> <div>
<label for="pin">置頂</label> <label for="pin">置頂</label>
<select name="pin" id="pin"> <select name="pin" id="pin">
<option value="Y"<?php if ($data["pin"]>1) echo " selected"; ?>></option> <option value="Y"<?php if ($data["pin"]>1) echo " selected"; ?>></option>
<option value="N"<?php if ($data["pin"]==1) echo " selected"; ?>></option> <option value="N"<?php if ($data["pin"]==1) echo " selected"; ?>></option>
</select> </select>
</div> </div>
<div> <div>
<label for="attatch1">附件上傳</label> <label for="attatch1">附件上傳</label>
<a href="<?php echo $data['attach']; ?>" target="_blank"><?php echo str_replace("/wms/board-attach/","",$data['attach']); ?></a> <a href="<?php echo $data['attach']; ?>" target="_blank"><?php echo str_replace("/wms/board-attach/","",$data['attach']); ?></a>
<div> <div>
<input type="file" name="attatch1" id="attatch1"> <input type="file" name="attatch1" id="attatch1">
</div> </div>
</div> </div>
<div> <div>
<label for="content">公告內容</label><br> <label for="content">公告內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required><?php echo $data['content']; ?></textarea> <textarea class="form-control2" name="content" id="content" rows="8" cols="100" required><?php echo $data['content']; ?></textarea>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="update" id="update">確定</button> <button type="submit" name="update" id="update">確定</button>
</div> </div>
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

36
wms/board-file.php

@ -1,19 +1,19 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "select attach from board where id = '$id'"; $db_query = "select attach from board where id = '$id'";
$res = mysqli_query($link, $db_query); $res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) { if ($row = mysqli_fetch_row($res)) {
header("Location: /wms/".$row[0]); header("Location: /wms/".$row[0]);
exit; exit;
} else { } else {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('檔案下載失敗!');"; echo "alert('檔案下載失敗!');";
echo "</script>"; echo "</script>";
header("Refresh:0; url=board-index.php?function_name=board&".$token_link); header("Refresh:0; url=board-index.php?function_name=board&".$token_link);
} }
ob_end_flush(); ob_end_flush();
?> ?>

307
wms/board-index.php

@ -1,108 +1,201 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql = "select * from board where status = 'Y' order by id"; $sql = "select * from board where status = 'Y' order by id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link, $sql);
?> $data2 = $data;
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <!-- <a href="create.php"><h2>新增</h2></a> -->
<p> <?php if ($user_auth & 2) { ?>
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <p>
<span class="glyphicon glyphicon-plus"></span> <a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
</a> <span class="glyphicon glyphicon-plus"></span>
</p> </a>
<?php </p>
} <?php
if($data): }
?> if ($data) :
?>
<style>
table { <style>
table-layout:fixed; table {
width: 100%; table-layout: fixed;
} width: 100%;
}
td {
word-wrap:break-word; td {
} word-wrap: break-word;
}
img {
width:125px; img {
} width: 125px;
}
.width_style_1 {
width:125px; .width_style_1 {
} width: 125px;
}
table{
width:100%; table {
} width: 100%;
#table_index_filter{ }
float:right;
} #table_index_filter {
#table_index_paginate{ float: right;
float:right; }
}
label { #table_index_paginate {
display: inline-flex; float: right;
margin-bottom: .5rem; }
margin-top: .5rem;
label {
} display: inline-flex;
margin-bottom: .5rem;
</style> margin-top: .5rem;
<div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> }
<thead>
<tr>
<th>項次</th> /* The Modal (background) */
<th>主旨</th> .modal {
<th>附件</th> display: none;
<!--<th>是否置頂</th>--> /* Hidden by default */
<th>建檔人</th> position: fixed;
<th>建檔時間</th> /* Stay in place */
<th>關閉公告</th> z-index: 1;
</tr> /* Sit on top */
</thead> padding-top: 100px;
<tbody> /* Location of the box */
<?php foreach($data as $data) : ?> left: 0;
<tr> top: 0;
<td><?php echo $data['id']; ?></td> width: 100%;
<td><?php echo $data['title']; ?></td> /* Full width */
<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> height: 100%;
<!--<td><?php if ($data['pin'] > 1) echo "是"; else echo "否"; ?></td>--> /* Full height */
<td><?php echo $data['creater']; ?></td> overflow: auto;
<td><?php echo $data['create_at']; ?></td> /* Enable scroll if needed */
<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('確認關閉公告嗎?')"> .modal .back {
<span class="glyphicon glyphicon-remove"></span> position: absolute;
</a> top: 0;
<?php } else echo "-"; ?> left: 0;
</p> width: 100%;
</td> height: 100%;
</tr> background-color: rgba(0, 0, 0, 0.4);
<?php endforeach; ?> /* Black w/ opacity */
</tbody> }
</table>
</div> /* Modal Content */
.modal-content {
<?php z-index: 9;
background-color: #fefefe;
else: margin: auto;
echo "<h2>There is no record!</h2>"; padding: 20px;
endif; border: 1px solid #888;
width: 80%;
#代表結束連線 }
mysqli_close($link);
/* The Close Button */
include "footer.php"; .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";
?> ?>

103
wms/board-record-submit.php

@ -1,52 +1,53 @@
<?php <?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
//print_r($_POST); //print_r($_POST);
//print_r($_FILES);exit; //print_r($_FILES);exit;
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); // $$k = htmlspecialchars(stripslashes(trim($v)));
} $$k = trim($v);
}
function get_basename($filename) {
return preg_replace('/^.+[\\\\\\/]/', '', $filename); function get_basename($filename) {
} return preg_replace('/^.+[\\\\\\/]/', '', $filename);
}
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"]; if ($_FILES["attatch1"]["error"] == 0) {
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; $file_name = $_FILES["attatch1"]["name"];
$file_size = $_FILES["attatch1"]["size"]; $temp_file_name = $_FILES["attatch1"]["tmp_name"];
$target_dir = "board-attach/"; $file_size = $_FILES["attatch1"]["size"];
$target_file1 = strtolower($target_dir.get_basename($file_name)); $target_dir = "board-attach/";
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $target_file1 = strtolower($target_dir.get_basename($file_name));
$upload_ok = 1; $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
if (file_exists($target_file1)) unlink($target_file1); $upload_ok = 1;
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); if (file_exists($target_file1)) unlink($target_file1);
} else $target_file1 = ""; $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
} else $target_file1 = "";
if ($target_file1 && !$upload_res_1) {
echo "<script type ='text/JavaScript'>"; if ($target_file1 && !$upload_res_1) {
echo "alert('檔案上傳失敗,資料請重建。');"; echo "<script type ='text/JavaScript'>";
echo "location.href='board-index.php?function_name=board&token=".$token."';"; echo "alert('檔案上傳失敗,資料請重建。');";
echo "</script>"; echo "location.href='board-index.php?function_name=board&token=".$token."';";
} echo "</script>";
}
$db_query = "insert into board (title, content, attach, pin, creater, create_at) values (";
$db_query .= "'$title', '$content', '$target_file1', '1', '".$user_id."', NOW())"; $db_query = "insert into board (title, content, attach, pin, creater, create_at) values (";
$result = mysqli_query($link, $db_query); $db_query .= "'$title', '$content', '$target_file1', '1', '".$user_id."', NOW())";
if (mysqli_affected_rows($link) > 0) { $result = mysqli_query($link, $db_query);
echo "<script type ='text/JavaScript'>"; if (mysqli_affected_rows($link) > 0) {
echo "alert('新增成功');"; echo "<script type ='text/JavaScript'>";
echo "location.href='board-index.php?function_name=board&token=".$token."';"; echo "alert('新增成功');";
echo "</script>"; echo "location.href='board-index.php?function_name=board&token=".$token."';";
} elseif (mysqli_affected_rows($link)==0) { echo "</script>";
echo "<script type ='text/JavaScript'>"; } elseif (mysqli_affected_rows($link)==0) {
echo "alert('無新增資料');"; echo "<script type ='text/JavaScript'>";
echo "location.href='board-index.php?function_name=board&token=".$token."';"; echo "alert('無新增資料');";
echo "</script>"; echo "location.href='board-index.php?function_name=board&token=".$token."';";
} else { echo "</script>";
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); } else {
} echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
mysqli_close($link);
} mysqli_close($link);
}
?> ?>

102
wms/board-record-update.php

@ -1,52 +1,52 @@
<?php <?php
exit; exit;
require_once "database.php"; require_once "database.php";
if (isset($_POST['update'])) { if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v))); $$k = htmlspecialchars(stripslashes(trim($v)));
} }
//print_r($_POST); //print_r($_POST);
//print_r($_FILES);exit; //print_r($_FILES);exit;
function get_basename($filename) { function get_basename($filename) {
return preg_replace('/^.+[\\\\\\/]/', '', $filename); return preg_replace('/^.+[\\\\\\/]/', '', $filename);
} }
$pin = ($pin == "Y") ? "99" : "1"; $pin = ($pin == "Y") ? "99" : "1";
$sql_atta = ""; $sql_atta = "";
if ($_FILES["attatch1"]["error"] == 0) { if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"]; $file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"]; $temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"]; $file_size = $_FILES["attatch1"]["size"];
$target_dir = "board-attach/"; $target_dir = "board-attach/";
$target_file1 = strtolower($target_dir.get_basename($file_name)); $target_file1 = strtolower($target_dir.get_basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION); $img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1; $upload_ok = 1;
if (file_exists($target_file1)) unlink($target_file1); if (file_exists($target_file1)) unlink($target_file1);
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1); $upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
$sql_atta .= "path = '$target_file1', "; $sql_atta .= "path = '$target_file1', ";
} else $target_file1 = ""; } else $target_file1 = "";
if ($target_file1 && !$upload_res_1) { if ($target_file1 && !$upload_res_1) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作。');"; echo "alert('檔案上傳失敗,請重新操作。');";
echo "location.href='board-index.php';"; echo "location.href='board-index.php';";
echo "</script>"; echo "</script>";
} }
$db_query = "update board set title = '$title', pin = '$pin', "; $db_query = "update board set title = '$title', pin = '$pin', ";
$db_query .= $sql_atta; $db_query .= $sql_atta;
$db_query .= "content = '$content'"; $db_query .= "content = '$content'";
$db_query .= "where id = '$id'"; $db_query .= "where id = '$id'";
$result = mysqli_query($link, $db_query); $result = mysqli_query($link, $db_query);
mysqli_close($link); mysqli_close($link);
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('修改成功');"; echo "alert('修改成功');";
echo "location.href='board-index.php';"; echo "location.href='board-index.php';";
echo "</script>"; echo "</script>";
} }
?> ?>

94
wms/change-password-update.php

@ -1,48 +1,48 @@
<?php <?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
require_once "database.php"; require_once "database.php";
$token = $_REQUEST["token"]; $token = $_REQUEST["token"];
$token_link = "token=" . $_REQUEST["token"]; $token_link = "token=" . $_REQUEST["token"];
list($user_id, $enc_user_name, $login_dt) = explode(".", $token); list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$old_pwd = $_REQUEST['old_pwd']; $old_pwd = $_REQUEST['old_pwd'];
$new_pwd = $_REQUEST['new_pwd']; $new_pwd = $_REQUEST['new_pwd'];
$data = array(); # 設置一個空陣列來放資料 $data = array(); # 設置一個空陣列來放資料
$real_user_id = ""; $real_user_id = "";
$real_pwd = ""; $real_pwd = "";
$sql = "SELECT * FROM account where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; # sql語法存在變數中 $sql = "SELECT * FROM account where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; # sql語法存在變數中
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中 $data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
foreach ($data as $data) { foreach ($data as $data) {
$real_user_id = $data['accountid']; $real_user_id = $data['accountid'];
$real_pwd = $data['pwd']; $real_pwd = $data['pwd'];
} }
#如果帳號密碼都正確才可update #如果帳號密碼都正確才可update
if (strlen($real_user_id) > 0) { if (strlen($real_user_id) > 0) {
$sql_query = "UPDATE account set pwd = '$new_pwd' where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; $sql_query = "UPDATE account set pwd = '$new_pwd' where ((accountid = '$user_id') and (pwd = '$old_pwd'))";
mysqli_query($link, $sql_query); mysqli_query($link, $sql_query);
$result_message = " $result_message = "
<script> <script>
alert('修改成功!'); alert('修改成功!');
location.href='change-password.php?" . $token_link . "'; location.href='change-password.php?" . $token_link . "';
</script> </script>
"; ";
} else { } else {
$result_message = " $result_message = "
<script> <script>
alert('帳號密碼錯誤!'); alert('帳號密碼錯誤!');
location.href='change-password.php?" . $token_link . "'; location.href='change-password.php?" . $token_link . "';
</script> </script>
"; ";
} }
echo $result_message; echo $result_message;
} }
mysqli_close($link); mysqli_close($link);
?> ?>
<script> <script>
</script> </script>

152
wms/change-password.php

@ -1,77 +1,77 @@
<?php <?php
if ($_REQUEST["token"]) { if ($_REQUEST["token"]) {
$item = substr($_REQUEST["token"], 0, strpos($_REQUEST["token"], ".")); $item = substr($_REQUEST["token"], 0, strpos($_REQUEST["token"], "."));
if ($item) { if ($item) {
require_once "header.php"; require_once "header.php";
} }
} }
?> ?>
<!-- 主頁header --> <!-- 主頁header -->
<?php <?php
require_once "header.php"; require_once "header.php";
require_once "database.php"; # 載入db.php來連結資料庫 require_once "database.php"; # 載入db.php來連結資料庫
$data = array(); # 設置一個空陣列來放資料 $data = array(); # 設置一個空陣列來放資料
$sql = "SELECT * FROM account where (accountid = '$user_id')"; # sql語法存在變數中 $sql = "SELECT * FROM account where (accountid = '$user_id')"; # sql語法存在變數中
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中 $data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
foreach ($data as $data) { foreach ($data as $data) {
$phone_call_help = $data['phone_call_help']; $phone_call_help = $data['phone_call_help'];
} }
?> ?>
<div> <div>
<div id="loader"> <div id="loader">
<div class="spinner-border text-primary" role="status"></div> <div class="spinner-border text-primary" role="status"></div>
</div> </div>
<div class="appHeader bg-primary text-light"> <div class="appHeader bg-primary text-light">
<div class="left"> <div class="left">
<a href="javascript:;" class="headerButton goBack"> <a href="javascript:;" class="headerButton goBack">
<ion-icon name="chevron-back-outline"></ion-icon> <ion-icon name="chevron-back-outline"></ion-icon>
</a> </a>
</div> </div>
<div class="pageTitle">變更密碼</div> <div class="pageTitle">變更密碼</div>
</div> </div>
<div id="appCapsule"> <div id="appCapsule">
<div class="section full mt-2"> <div class="section full mt-2">
<div class="section-title">請輸入變更前後密碼!</div> <div class="section-title">請輸入變更前後密碼!</div>
<div class="wide-block pt-2 pb-2"> <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"> <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; ?>" /> <input type="hidden" name="token" value="<?php echo $token; ?>" />
<!-- 以上是要傳遞的資料 --> <!-- 以上是要傳遞的資料 -->
<div class="form-group boxed"> <div class="form-group boxed">
<div class="input-wrapper"> <div class="input-wrapper">
<input type="text" class="form-control" name="old_pwd" placeholder="變更前密碼"> <input type="text" class="form-control" name="old_pwd" placeholder="變更前密碼">
<i class="clear-input"> <i class="clear-input">
<ion-icon name="close-circle"></ion-icon> <ion-icon name="close-circle"></ion-icon>
</i> </i>
</div> </div>
</div> </div>
<div class="form-group boxed"> <div class="form-group boxed">
<div class="input-wrapper"> <div class="input-wrapper">
<input type="text" class="form-control" name="new_pwd" placeholder="變更後密碼"> <input type="text" class="form-control" name="new_pwd" placeholder="變更後密碼">
<i class="clear-input"> <i class="clear-input">
<ion-icon name="close-circle"></ion-icon> <ion-icon name="close-circle"></ion-icon>
</i> </i>
</div> </div>
</div> </div>
<div class="mt-1"> <div class="mt-1">
<button type="submit" class="btn btn-primary btn-lg btn-block"> <button type="submit" class="btn btn-primary btn-lg btn-block">
確定 確定
</button> </button>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
<!-- * App Capsule --> <!-- * App Capsule -->
</div> </div>
<?php <?php
mysqli_close($link); mysqli_close($link);
?> ?>

172
wms/combo-create.php

@ -1,86 +1,86 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<div class="container"> <div class="container">
<?php <?php
include "combo-record-submit.php"; include "combo-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="combono">保養套餐號</label> <label for="combono">保養套餐號</label>
<input type="text" name="combono" id="combono"> <input type="text" name="combono" id="combono">
</div> </div>
<div> <div>
<label for="part">部位</label> <label for="part">部位</label>
<input type="text" name="part" id="part"> <input type="text" name="part" id="part">
</div> </div>
<div> <div>
<label for="partid">部位類別</label> <label for="partid">部位類別</label>
<input type="text" name="partid" id="partid"> <input type="text" name="partid" id="partid">
</div> </div>
<div> <div>
<label for="comboitem">部位類別序號</label> <label for="comboitem">部位類別序號</label>
<input type="text" name="comboitem" id="comboitem" value="1"> <input type="text" name="comboitem" id="comboitem" value="1">
</div> </div>
<div> <div>
<label for="detail">保養內容</label> <label for="detail">保養內容</label>
<input type="text" name="detail" id="detail"> <input type="text" name="detail" id="detail">
</div> </div>
<div> <div>
<label for="enable">是否啟用</label> <label for="enable">是否啟用</label>
<Select name="enable" id="enable" required> <Select name="enable" id="enable" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="1">啟用</Option> <Option Value="1">啟用</Option>
<Option Value="0">停用</Option> <Option Value="0">停用</Option>
</Select> </Select>
<!-- <input type="text" name="enable" id="enable" value="1"> --> <!-- <input type="text" name="enable" id="enable" value="1"> -->
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p> <p class="error"><?php echo $creater_error; ?></p>
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<!-- <label for="create_at">create_at</label> --> <!-- <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'); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

22
wms/combo-delete.php

@ -1,12 +1,12 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM combo WHERE id='$id'"; $db_query = "DELETE FROM combo WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("Refresh:0; url=combo-index.php?function_name=combo&".$token_link); header("Refresh:0; url=combo-index.php?function_name=combo&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

186
wms/combo-edit.php

@ -1,93 +1,93 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM combo WHERE id=$id"; $db_query = "SELECT * FROM combo WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/record_update.php"; include "inc/record_update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="combo-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="combo-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="combono">保養套餐號</label> <label for="combono">保養套餐號</label>
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>"> <input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>">
</div> </div>
<div> <div>
<label for="part">部位</label> <label for="part">部位</label>
<input type="text" name="part" id="part" value="<?php echo $data['part']; ?>"> <input type="text" name="part" id="part" value="<?php echo $data['part']; ?>">
</div> </div>
<div> <div>
<label for="partid">部位類別</label> <label for="partid">部位類別</label>
<input type="text" name="partid" id="partid" value="<?php echo $data['partid']; ?>"> <input type="text" name="partid" id="partid" value="<?php echo $data['partid']; ?>">
</div> </div>
<div> <div>
<label for="comboitem">部位類別序號</label> <label for="comboitem">部位類別序號</label>
<input type="text" name="comboitem" id="comboitem" value="<?php echo $data['comboitem']; ?>"> <input type="text" name="comboitem" id="comboitem" value="<?php echo $data['comboitem']; ?>">
</div> </div>
<div> <div>
<label for="detail">保養內容</label> <label for="detail">保養內容</label>
<input type="text" name="detail" id="detail" value="<?php echo $data['detail']; ?>"> <input type="text" name="detail" id="detail" value="<?php echo $data['detail']; ?>">
</div> </div>
<div> <div>
<label for="enable">是否啟用</label> <label for="enable">是否啟用</label>
<Select name="enable" id="enable" required> <Select name="enable" id="enable" required>
<?php <?php
if($data["enable"] == 1){ if($data["enable"] == 1){
echo "<Option Value='1' selected='selected'>啟用</Option> <Option Value='0'>停用</Option>"; echo "<Option Value='1' selected='selected'>啟用</Option> <Option Value='0'>停用</Option>";
}else{ }else{
echo "<Option Value='0' selected='selected'>停用</Option> <Option Value='1'>啟用</Option>"; echo "<Option Value='0' selected='selected'>停用</Option> <Option Value='1'>啟用</Option>";
} }
?> ?>
</Select> </Select>
<!-- <input type="text" name="enable" id="enable" value=""> --> <!-- <input type="text" name="enable" id="enable" value=""> -->
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

278
wms/combo-index.php

@ -1,140 +1,140 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id); $sql_cmd = sql_myself($user_id);
$sql = "SELECT * FROM combo $sql_cmd ORDER BY id"; $sql = "SELECT * FROM combo $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="combo-create.php"><h2>新增</h2></a> --> <!-- <a href="combo-create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<p> <p>
<a href="combo-create.php?function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="combo-create.php?function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:combo-index.php"); header("Location:combo-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <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) { ?> <?php if ($user_auth&2) { ?>
<th>修改</th> <th>修改</th>
<th>刪除</th> <th>刪除</th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['combono']; ?></td> <td><?php echo $data['combono']; ?></td>
<td><?php echo $data['part']; ?></td> <td><?php echo $data['part']; ?></td>
<td><?php echo $data['partid']; ?></td> <td><?php echo $data['partid']; ?></td>
<td><?php echo $data['comboitem']; ?></td> <td><?php echo $data['comboitem']; ?></td>
<td><?php echo $data['detail']; ?></td> <td><?php echo $data['detail']; ?></td>
<td><?php echo $data['enable']; ?></td> <td><?php echo $data['enable']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<td> <td>
<p> <p>
<a href="combo-edit.php?id=<?php echo $data['id']; ?>&function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <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> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<td> <td>
<p> <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?')"> <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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td> </td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

84
wms/combo-record-submit.php

@ -1,42 +1,42 @@
<?php <?php
$combono= ""; $combono= "";
$part= ""; $part= "";
$partid= ""; $partid= "";
$comboitem= ""; $comboitem= "";
$detail= ""; $detail= "";
$enable= ""; $enable= "";
$creater= ""; $creater= "";
$create_at= ""; $create_at= "";
$combono_error= ""; $combono_error= "";
$part_error= ""; $part_error= "";
$partid_error= ""; $partid_error= "";
$comboitem_error= ""; $comboitem_error= "";
$detail_error= ""; $detail_error= "";
$enable_error= ""; $enable_error= "";
$creater_error = ""; $creater_error = "";
$create_at_error = ""; $create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
include "combo-user-input.php"; 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')"; $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); $result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');"; echo "alert('新增成功');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

80
wms/combo-record-update.php

@ -1,41 +1,41 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$id = $_POST['id']; $id = $_POST['id'];
$combono = user_input($_POST["combono"]); $combono = user_input($_POST["combono"]);
$part = user_input($_POST["part"]); $part = user_input($_POST["part"]);
$partid = user_input($_POST["partid"]); $partid = user_input($_POST["partid"]);
$comboitem = user_input($_POST["comboitem"]); $comboitem = user_input($_POST["comboitem"]);
$detail = user_input($_POST["detail"]); $detail = user_input($_POST["detail"]);
$enable = user_input($_POST["enable"]); $enable = user_input($_POST["enable"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $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'"; $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); mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';"; echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

108
wms/combo-user-input.php

@ -1,54 +1,54 @@
<?php <?php
//Function to filter the form input //Function to filter the form input
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$combono = user_input($_POST["combono"]); $combono = user_input($_POST["combono"]);
$part = user_input($_POST["part"]); $part = user_input($_POST["part"]);
$partid = user_input($_POST["partid"]); $partid = user_input($_POST["partid"]);
$comboitem = user_input($_POST["comboitem"]); $comboitem = user_input($_POST["comboitem"]);
$detail = user_input($_POST["detail"]); $detail = user_input($_POST["detail"]);
$enable = user_input($_POST["enable"]); $enable = user_input($_POST["enable"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
/* /*
if(empty($_POST["name"])) { if(empty($_POST["name"])) {
$name_error = "Name is required"; $name_error = "Name is required";
} else { } else {
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed"; $name_error = "Only letter and white space are allowed";
} }
} }
/* /*
if(empty($_POST["website"])) { if(empty($_POST["website"])) {
$website_error = "Website address is required"; $website_error = "Website address is required";
} else { } else {
$website = user_input($_POST["website"]); $website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL"; $website_error = "Invalid website URL";
} }
} }
if(empty($_POST["comment"])) { if(empty($_POST["comment"])) {
$comment = ""; $comment = "";
} else { } else {
$comment = user_input($_POST["comment"]); $comment = user_input($_POST["comment"]);
} }
*/ */
?> ?>

252
wms/contract-create.php

@ -1,126 +1,126 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<div class="container"> <div class="container">
<?php <?php
include "contract-record-submit.php"; include "contract-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="contracttype">合約類型(必填)</label> <label for="contracttype">合約類型(必填)</label>
<Select name="contracttype" id="contracttype" required> <Select name="contracttype" id="contracttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option> <Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option> <Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option> <Option Value="C">單次維修</Option>
</Select> </Select>
</div> </div>
<div> <div>
<label for="contractno">合約號(必填)</label> <label for="contractno">合約號(必填)</label>
<input type="text" name="contractno" id="contractno" required> <input type="text" name="contractno" id="contractno" required>
</div> </div>
<div> <div>
<label for="company">公司名稱</label> <label for="company">公司名稱</label>
<input type="text" name="company" id="company" > <input type="text" name="company" id="company" >
</div> </div>
<div> <div>
<label for="taxid">統一編號</label> <label for="taxid">統一編號</label>
<input type="text" name="taxid" id="taxid" > <input type="text" name="taxid" id="taxid" >
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address" > <input type="text" name="address" id="address" >
</div> </div>
<div> <div>
<label for="tel">電話</label> <label for="tel">電話</label>
<input type="text" name="tel" id="tel" > <input type="text" name="tel" id="tel" >
</div> </div>
<div> <div>
<label for="promiser">立約人</label> <label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser"> <input type="text" name="promiser" id="promiser">
</div> </div>
<div> <div>
<label for="customerid">客戶維護帳號(必填)</label> <label for="customerid">客戶維護帳號(必填)</label>
<input type="text" name="customerid" id="customerid" required> <input type="text" name="customerid" id="customerid" required>
</div> </div>
<div> <div>
<label for="contractperson">業務聯繫人</label> <label for="contractperson">業務聯繫人</label>
<input type="text" name="contractperson" id="contractperson" > <input type="text" name="contractperson" id="contractperson" >
</div> </div>
<div> <div>
<label for="contractaddress">業務聯繫人地址</label> <label for="contractaddress">業務聯繫人地址</label>
<input type="text" name="contractaddress" id="contractaddress" > <input type="text" name="contractaddress" id="contractaddress" >
</div> </div>
<div> <div>
<label for="contracttel">業務聯繫人電話(必填)</label> <label for="contracttel">業務聯繫人電話(必填)</label>
<input type="text" name="contracttel" id="contracttel" required> <input type="text" name="contracttel" id="contracttel" required>
</div> </div>
<div> <div>
<label for="contractemail">業務聯繫人郵件地址</label> <label for="contractemail">業務聯繫人郵件地址</label>
<input type="text" name="contractemail" id="contractemail" > <input type="text" name="contractemail" id="contractemail" >
</div> </div>
<div> <div>
<label for="contract_employee">契約人員工號</label> <label for="contract_employee">契約人員工號</label>
<input type="text" name="contract_employee" id="contract_employee" > <input type="text" name="contract_employee" id="contract_employee" >
</div> </div>
<div> <div>
<label for="start_date">合約起始年月日(必填)</label><br> <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> <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>
<div> <div>
<label for="end_date">合約終止年月日(必填)</label><br> <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> <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>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p> <p class="error"><?php echo $creater_error; ?></p>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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'); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

22
wms/contract-delete.php

@ -1,12 +1,12 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM contract WHERE id='$id'"; $db_query = "DELETE FROM contract WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("Refresh:0; url=contract-index.php?function_name=contract&".$token_link); header("Refresh:0; url=contract-index.php?function_name=contract&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

284
wms/contract-edit.php

@ -1,142 +1,142 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM contract WHERE id=$id"; $db_query = "SELECT * FROM contract WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/record_update.php"; include "inc/record_update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="contract-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="contract-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="contracttype">合約類型</label> <label for="contracttype">合約類型</label>
<Select name="contracttype" id="contracttype" required> <Select name="contracttype" id="contracttype" required>
<?php <?php
switch ($data['contracttype']) { switch ($data['contracttype']) {
case "A": case "A":
echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>"; echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break; break;
case "B": case "B":
echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>"; echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break; break;
case "C": case "C":
echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>"; echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>";
break; break;
} }
?> ?>
</Select> </Select>
</div> </div>
<div> <div>
<label for="contractno">合約號</label> <label for="contractno">合約號</label>
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>"> <input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>">
</div> </div>
<div> <div>
<label for="company">公司名稱</label> <label for="company">公司名稱</label>
<input type="text" name="company" id="company" value="<?php echo $data['company']; ?>"> <input type="text" name="company" id="company" value="<?php echo $data['company']; ?>">
</div> </div>
<div> <div>
<label for="taxid">統一編號</label> <label for="taxid">統一編號</label>
<input type="text" name="taxid" id="taxid" value="<?php echo $data['taxid']; ?>"> <input type="text" name="taxid" id="taxid" value="<?php echo $data['taxid']; ?>">
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> <input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div> </div>
<div> <div>
<label for="tel">電話</label> <label for="tel">電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> <input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div> </div>
<div> <div>
<label for="promiser">立約人</label> <label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser" value="<?php echo $data['promiser']; ?>"> <input type="text" name="promiser" id="promiser" value="<?php echo $data['promiser']; ?>">
</div> </div>
<div> <div>
<label for="customerid">客戶維護帳號</label> <label for="customerid">客戶維護帳號</label>
<input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>"> <input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>">
</div> </div>
<div> <div>
<label for="contractperson">業務聯繫人</label> <label for="contractperson">業務聯繫人</label>
<input type="text" name="contractperson" id="contractperson" value="<?php echo $data['contractperson']; ?>"> <input type="text" name="contractperson" id="contractperson" value="<?php echo $data['contractperson']; ?>">
</div> </div>
<div> <div>
<label for="contractaddress">業務聯繫人地址</label> <label for="contractaddress">業務聯繫人地址</label>
<input type="text" name="contractaddress" id="contractaddress" value="<?php echo $data['contractaddress']; ?>"> <input type="text" name="contractaddress" id="contractaddress" value="<?php echo $data['contractaddress']; ?>">
</div> </div>
<div> <div>
<label for="contracttel">業務聯繫人電話</label> <label for="contracttel">業務聯繫人電話</label>
<input type="text" name="contracttel" id="contracttel" value="<?php echo $data['contracttel']; ?>"> <input type="text" name="contracttel" id="contracttel" value="<?php echo $data['contracttel']; ?>">
</div> </div>
<div> <div>
<label for="contractemail">業務聯繫人郵件地址</label> <label for="contractemail">業務聯繫人郵件地址</label>
<input type="text" name="contractemail" id="contractemail" value="<?php echo $data['contractemail']; ?>"> <input type="text" name="contractemail" id="contractemail" value="<?php echo $data['contractemail']; ?>">
</div> </div>
<div> <div>
<label for="contract_employee">契約人員工號</label> <label for="contract_employee">契約人員工號</label>
<input type="text" name="contract_employee" id="contract_employee" value="<?php echo $data['contract_employee']; ?>"> <input type="text" name="contract_employee" id="contract_employee" value="<?php echo $data['contract_employee']; ?>">
</div> </div>
<div> <div>
<label for="start_date">合約起始年月日</label> <label for="start_date">合約起始年月日</label>
<input type="text" name="start_date" id="start_date" value="<?php echo $data['start_date']; ?>"> <input type="text" name="start_date" id="start_date" value="<?php echo $data['start_date']; ?>">
</div> </div>
<div> <div>
<label for="end_date">合約終止年月日</label> <label for="end_date">合約終止年月日</label>
<input type="text" name="end_date" id="end_date" value="<?php echo $data['end_date']; ?>"> <input type="text" name="end_date" id="end_date" value="<?php echo $data['end_date']; ?>">
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

324
wms/contract-index.php

@ -1,162 +1,162 @@
<?php <?php
include "header.php"; include "header.php";
// 工務總處可瀏覽全部資料 // 工務總處可瀏覽全部資料
$sql = "select department_id from account where accountid = '$user_id'"; $sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$user_department_id = $row[0]; $user_department_id = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id); $sql_cmd = sql_myself($user_id);
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = ""; if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = "";
$sql = "SELECT * FROM contract $sql_cmd ORDER BY id"; $sql = "SELECT * FROM contract $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<p> <p>
<a href="contract-create.php?function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="contract-create.php?function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:contract-index.php"); header("Location:contract-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <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> <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) { ?> <?php if ($user_auth&2) { ?>
<th>修改</th> <th>修改</th>
<!--<th>刪除</th>--> <!--<th>刪除</th>-->
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['contracttype']; ?></td> <td><?php echo $data['contracttype']; ?></td>
<td><?php echo $data['contractno']; ?></td> <td><?php echo $data['contractno']; ?></td>
<td><?php echo $data['company']; ?></td> <td><?php echo $data['company']; ?></td>
<td><?php echo $data['taxid']; ?></td> <td><?php echo $data['taxid']; ?></td>
<td><?php echo $data['address']; ?></td> <td><?php echo $data['address']; ?></td>
<td><?php echo $data['tel']; ?></td> <td><?php echo $data['tel']; ?></td>
<td><?php echo $data['promiser']; ?></td> <td><?php echo $data['promiser']; ?></td>
<td><?php echo $data['customerid']; ?></td> <td><?php echo $data['customerid']; ?></td>
<td><?php echo $data['contractperson']; ?></td> <td><?php echo $data['contractperson']; ?></td>
<td><?php echo $data['contractaddress']; ?></td> <td><?php echo $data['contractaddress']; ?></td>
<td><?php echo $data['contracttel']; ?></td> <td><?php echo $data['contracttel']; ?></td>
<td><?php echo $data['contractemail']; ?></td> <td><?php echo $data['contractemail']; ?></td>
<td><?php echo $data['contract_employee']; ?></td> <td><?php echo $data['contract_employee']; ?></td>
<td><?php echo $data['start_date']; ?></td> <td><?php echo $data['start_date']; ?></td>
<td><?php echo $data['end_date']; ?></td> <td><?php echo $data['end_date']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<td> <td>
<p> <p>
<a href="contract-edit.php?id=<?php echo $data['id']; ?>&function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <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> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<!--<td> <!--<td>
<p> <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?')"> <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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td>--> </td>-->
<?php } ?> <?php } ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

122
wms/contract-record-submit.php

@ -1,61 +1,61 @@
<?php <?php
$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= "";
$creater= ""; $creater= "";
$create_at= ""; $create_at= "";
$contracttype_error= ""; $contracttype_error= "";
$contractno_error= ""; $contractno_error= "";
$company_error= ""; $company_error= "";
$taxid_error= ""; $taxid_error= "";
$address_error= ""; $address_error= "";
$tel_error= ""; $tel_error= "";
$promiser_error= ""; $promiser_error= "";
$customerid_error= ""; $customerid_error= "";
$contractperson_error= ""; $contractperson_error= "";
$contractaddress_error= ""; $contractaddress_error= "";
$contracttel_error= ""; $contracttel_error= "";
$contractemail_error= ""; $contractemail_error= "";
$contract_employee_error= ""; $contract_employee_error= "";
$start_date_error= ""; $start_date_error= "";
$end_date_error= ""; $end_date_error= "";
$creater_error = ""; $creater_error = "";
$create_at_error = ""; $create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
include "contract-user-input.php"; 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')"; $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); $result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');"; echo "alert('新增成功');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

98
wms/contract-record-update.php

@ -1,50 +1,50 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$id = $_POST['id']; $id = $_POST['id'];
$contracttype = user_input($_POST["contracttype"]); $contracttype = user_input($_POST["contracttype"]);
$contractno = user_input($_POST["contractno"]); $contractno = user_input($_POST["contractno"]);
$company = user_input($_POST["company"]); $company = user_input($_POST["company"]);
$taxid = user_input($_POST["taxid"]); $taxid = user_input($_POST["taxid"]);
$address = user_input($_POST["address"]); $address = user_input($_POST["address"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$promiser = user_input($_POST["promiser"]); $promiser = user_input($_POST["promiser"]);
$customerid = user_input($_POST["customerid"]); $customerid = user_input($_POST["customerid"]);
$contractperson = user_input($_POST["contractperson"]); $contractperson = user_input($_POST["contractperson"]);
$contractaddress = user_input($_POST["contractaddress"]); $contractaddress = user_input($_POST["contractaddress"]);
$contracttel = user_input($_POST["contracttel"]); $contracttel = user_input($_POST["contracttel"]);
$contractemail = user_input($_POST["contractemail"]); $contractemail = user_input($_POST["contractemail"]);
$contract_employee = user_input($_POST["contract_employee"]); $contract_employee = user_input($_POST["contract_employee"]);
$start_date = user_input($_POST["start_date"]); $start_date = user_input($_POST["start_date"]);
$end_date = user_input($_POST["end_date"]); $end_date = user_input($_POST["end_date"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $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'"; $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); mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';"; echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

126
wms/contract-user-input.php

@ -1,63 +1,63 @@
<?php <?php
//Function to filter the form input //Function to filter the form input
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$contracttype = user_input($_POST["contracttype"]); $contracttype = user_input($_POST["contracttype"]);
$contractno = user_input($_POST["contractno"]); $contractno = user_input($_POST["contractno"]);
$company = user_input($_POST["company"]); $company = user_input($_POST["company"]);
$taxid = user_input($_POST["taxid"]); $taxid = user_input($_POST["taxid"]);
$address = user_input($_POST["address"]); $address = user_input($_POST["address"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$promiser = user_input($_POST["promiser"]); $promiser = user_input($_POST["promiser"]);
$customerid = user_input($_POST["customerid"]); $customerid = user_input($_POST["customerid"]);
$contractperson = user_input($_POST["contractperson"]); $contractperson = user_input($_POST["contractperson"]);
$contractaddress = user_input($_POST["contractaddress"]); $contractaddress = user_input($_POST["contractaddress"]);
$contracttel = user_input($_POST["contracttel"]); $contracttel = user_input($_POST["contracttel"]);
$contractemail = user_input($_POST["contractemail"]); $contractemail = user_input($_POST["contractemail"]);
$contract_employee = user_input($_POST["contract_employee"]); $contract_employee = user_input($_POST["contract_employee"]);
$start_date = user_input($_POST["start_date"]); $start_date = user_input($_POST["start_date"]);
$end_date = user_input($_POST["end_date"]); $end_date = user_input($_POST["end_date"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
/* /*
if(empty($_POST["name"])) { if(empty($_POST["name"])) {
$name_error = "Name is required"; $name_error = "Name is required";
} else { } else {
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed"; $name_error = "Only letter and white space are allowed";
} }
} }
/* /*
if(empty($_POST["website"])) { if(empty($_POST["website"])) {
$website_error = "Website address is required"; $website_error = "Website address is required";
} else { } else {
$website = user_input($_POST["website"]); $website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL"; $website_error = "Invalid website URL";
} }
} }
if(empty($_POST["comment"])) { if(empty($_POST["comment"])) {
$comment = ""; $comment = "";
} else { } else {
$comment = user_input($_POST["comment"]); $comment = user_input($_POST["comment"]);
} }
*/ */
?> ?>

452
wms/custom-create-contract.php

@ -1,226 +1,226 @@
<?php <?php
// 載入db.php來連結資料庫 // 載入db.php來連結資料庫
require_once "database.php"; require_once "database.php";
include "header.php"; include "header.php";
// 查詢提交成功的賬戶信息 // 查詢提交成功的賬戶信息
$accountid=$_REQUEST['accountid']; $accountid=$_REQUEST['accountid'];
if(!empty($accountid)){ if(!empty($accountid)){
$sql = "SELECT * FROM account where accountid='$accountid'"; $sql = "SELECT * FROM account where accountid='$accountid'";
$accountdata = mysqli_query($link,$sql); $accountdata = mysqli_query($link,$sql);
$row = mysqli_fetch_array($accountdata, MYSQLI_ASSOC); $row = mysqli_fetch_array($accountdata, MYSQLI_ASSOC);
} }
if($_POST['type']=='contract'){ if($_POST['type']=='contract'){
$contracttype = $_POST["contracttype"]; $contracttype = $_POST["contracttype"];
$contractno = $_POST["contractno"]; $contractno = $_POST["contractno"];
$company = $_POST["company"]; $company = $_POST["company"];
$taxid = $_POST["taxid"]; $taxid = $_POST["taxid"];
$address = $_POST["address"]; $address = $_POST["address"];
$tel = $_POST["tel"]; $tel = $_POST["tel"];
$promiser = $_POST["promiser"]; $promiser = $_POST["promiser"];
$customerid = $_POST["customerid"]; $customerid = $_POST["customerid"];
$contractperson = $_POST["contractperson"]; $contractperson = $_POST["contractperson"];
$contractaddress = $_POST["contractaddress"]; $contractaddress = $_POST["contractaddress"];
$contracttel = $_POST["contracttel"]; $contracttel = $_POST["contracttel"];
$contractemail = $_POST["contractemail"]; $contractemail = $_POST["contractemail"];
$contract_employee = $_POST["contract_employee"]; $contract_employee = $_POST["contract_employee"];
$start_date = $_POST["start_date"]; $start_date = $_POST["start_date"];
$end_date = $_POST["end_date"]; $end_date = $_POST["end_date"];
$creater = $_POST["creater"]; $creater = $_POST["creater"];
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
//根據合約編號判斷合約是否存在 //根據合約編號判斷合約是否存在
$contractsql = "SELECT * FROM contract where contractno='$contractno'"; $contractsql = "SELECT * FROM contract where contractno='$contractno'";
$contract_nums_rows=mysqli_num_rows(mysqli_query($link,$contractsql)); $contract_nums_rows=mysqli_num_rows(mysqli_query($link,$contractsql));
if($contract_nums_rows==0) { if($contract_nums_rows==0) {
$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')"; $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')";
mysqli_query($link,$db_query); mysqli_query($link,$db_query);
if (mysqli_affected_rows($link)>0) { if (mysqli_affected_rows($link)>0) {
echo "合約添加成功"; echo "合約添加成功";
header('location:custom-create-facility.php?accountid='.$customerid.'&contractno='.$contractno); header('location:custom-create-facility.php?accountid='.$customerid.'&contractno='.$contractno);
exit(); exit();
} }
else{ else{
echo "<h1 class='text-center'>合約添加失敗</h1>"; echo "<h1 class='text-center'>合約添加失敗</h1>";
} }
} else{ } else{
} }
} }
?> ?>
<div class="container" id="accountadd"> <div class="container" id="accountadd">
<table class="table table-bordered" style="width:100%"> <table class="table table-bordered" style="width:100%">
<thead> <thead>
<tr> <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>Line ID</th> <th>Line ID</th>
<th>微信id</th> <th>微信id</th>
<th>維修ID</th> <th>維修ID</th>
<th>直屬主管</th> <th>直屬主管</th>
<th>建檔人</th> <th>建檔人</th>
<th>建檔時間</th> <th>建檔時間</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><?php echo $row['accounttype']; ?></td> <td><?php echo $row['accounttype']; ?></td>
<td><?php echo $row['accountid']; ?></td> <td><?php echo $row['accountid']; ?></td>
<td><?php echo $row['pwd']; ?></td> <td><?php echo $row['pwd']; ?></td>
<td><?php echo $row['name']; ?></td> <td><?php echo $row['name']; ?></td>
<td><?php echo $row['tel']; ?></td> <td><?php echo $row['tel']; ?></td>
<td><?php echo $row['address']; ?></td> <td><?php echo $row['address']; ?></td>
<td><?php echo $row['email']; ?></td> <td><?php echo $row['email']; ?></td>
<td><?php echo $row['lineid']; ?></td> <td><?php echo $row['lineid']; ?></td>
<td><?php echo $row['wechatid']; ?></td> <td><?php echo $row['wechatid']; ?></td>
<td><?php echo $row['repairerid']; ?></td> <td><?php echo $row['repairerid']; ?></td>
<td><?php echo $row['manager']; ?></td> <td><?php echo $row['manager']; ?></td>
<td><?php echo $row['creater']; ?></td> <td><?php echo $row['creater']; ?></td>
<td><?php echo $row['create_at']; ?></td> <td><?php echo $row['create_at']; ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="text-center"> <h3>合約資料添加</h3> </div> <div class="text-center"> <h3>合約資料添加</h3> </div>
<form class="form-horizontal" name="account" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> <form class="form-horizontal" name="account" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="contracttype">合約類型(必填)</label> <label for="contracttype">合約類型(必填)</label>
<Select class="form-control" name="contracttype" id="contracttype" required> <Select class="form-control" name="contracttype" id="contracttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option> <Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option> <Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option> <Option Value="C">單次維修</Option>
</Select> </Select>
</div> </div>
<div class="col-md-9 "> <div class="col-md-9 ">
<button type="submit" class="btn btn-primary btn-lg pull-right" >點擊後提交合約資料</button> <button type="submit" class="btn btn-primary btn-lg pull-right" >點擊後提交合約資料</button>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="contractno">合約號(必填)</label> <label for="contractno">合約號(必填)</label>
<input class="form-control" type="text" name="contractno" id="contractno" required> <input class="form-control" type="text" name="contractno" id="contractno" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="company">公司名稱</label> <label for="company">公司名稱</label>
<input class="form-control" type="text" name="company" id="company" > <input class="form-control" type="text" name="company" id="company" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="taxid">統一編號</label> <label for="taxid">統一編號</label>
<input class="form-control" type="text" name="taxid" id="taxid" > <input class="form-control" type="text" name="taxid" id="taxid" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="address">地址</label> <label for="address">地址</label>
<input class="form-control" type="text" name="address" id="address" > <input class="form-control" type="text" name="address" id="address" >
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3" > <div class="col-md-3" >
<label for="tel">電話</label> <label for="tel">電話</label>
<input class="form-control" type="text" name="tel" id="tel" > <input class="form-control" type="text" name="tel" id="tel" >
</div> </div>
<div class="col-md-3" > <div class="col-md-3" >
<label for="promiser">立約人</label> <label for="promiser">立約人</label>
<input class="form-control" type="text" name="promiser" id="promiser"> <input class="form-control" type="text" name="promiser" id="promiser">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="customerid">客戶維護帳號(必填)</label> <label for="customerid">客戶維護帳號(必填)</label>
<input class="form-control" type="text" name="customerid" id="customerid" value="<?php echo $row['accountid']; ?>" required> <input class="form-control" type="text" name="customerid" id="customerid" value="<?php echo $row['accountid']; ?>" required>
</div class="col-md-3"> </div class="col-md-3">
<div class="col-md-3"> <div class="col-md-3">
<label for="contractperson">業務聯繫人</label> <label for="contractperson">業務聯繫人</label>
<input class="form-control" type="text" name="contractperson" id="contractperson" > <input class="form-control" type="text" name="contractperson" id="contractperson" >
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="contractaddress">業務聯繫人地址</label> <label for="contractaddress">業務聯繫人地址</label>
<input class="form-control" type="text" name="contractaddress" id="contractaddress" > <input class="form-control" type="text" name="contractaddress" id="contractaddress" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="contracttel">業務聯繫人電話(必填)</label> <label for="contracttel">業務聯繫人電話(必填)</label>
<input class="form-control" type="text" name="contracttel" id="contracttel" required> <input class="form-control" type="text" name="contracttel" id="contracttel" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="contractemail">業務聯繫人郵件地址</label> <label for="contractemail">業務聯繫人郵件地址</label>
<input class="form-control" type="text" name="contractemail" id="contractemail" > <input class="form-control" type="text" name="contractemail" id="contractemail" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="contract_employee">契約人員工號</label> <label for="contract_employee">契約人員工號</label>
<input class="form-control" type="text" name="contract_employee" id="contract_employee" > <input class="form-control" type="text" name="contract_employee" id="contract_employee" >
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="start_date">合約起始年月日(必填)</label><br> <label for="start_date">合約起始年月日(必填)</label><br>
<input class="form-control" type="text" data-date-format="yyyy-mm-dd" name="start_date" id="start_date" value="<?php echo date('Y-m-d'); ?>" required> <input class="form-control" type="text" data-date-format="yyyy-mm-dd" name="start_date" id="start_date" value="<?php echo date('Y-m-d'); ?>" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="end_date">合約終止年月日(必填)</label><br> <label for="end_date">合約終止年月日(必填)</label><br>
<input class="form-control" 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> <input class="form-control" 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>
<div class="col-md-3"> <div class="col-md-3">
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input class="form-control" type="text" name="creater" id="creater" value="<?php echo $user_id;?>"> <input class="form-control" type="text" name="creater" id="creater" value="<?php echo $user_id;?>">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<input class="form-control" type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> <input class="form-control" type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<input class="form-control" type="hidden" name="type" id="create_at" value="contract"> <input class="form-control" type="hidden" name="type" id="create_at" value="contract">
</div> </div>
</div> </div>
</form> </form>
</div> </div>

544
wms/custom-create-facility.php

@ -1,272 +1,272 @@
<?php <?php
// 載入db.php來連結資料庫 // 載入db.php來連結資料庫
require_once "database.php"; require_once "database.php";
include "header.php"; include "header.php";
// 查詢提交成功的賬戶信息 // 查詢提交成功的賬戶信息
$accountid=$_REQUEST['accountid']; $accountid=$_REQUEST['accountid'];
$contractno=$_REQUEST['contractno']; $contractno=$_REQUEST['contractno'];
if(!empty($accountid)&&!empty($contractno)){ if(!empty($accountid)&&!empty($contractno)){
$accountsql = "SELECT * FROM account where accountid='$accountid'"; $accountsql = "SELECT * FROM account where accountid='$accountid'";
$accountdata = mysqli_query($link,$accountsql); $accountdata = mysqli_query($link,$accountsql);
$row = mysqli_fetch_array($accountdata, MYSQLI_ASSOC); $row = mysqli_fetch_array($accountdata, MYSQLI_ASSOC);
$contractsql = "SELECT * FROM contract where contractno='$contractno'"; $contractsql = "SELECT * FROM contract where contractno='$contractno'";
$contractdata=mysqli_query($link,$contractsql); $contractdata=mysqli_query($link,$contractsql);
$contractrows= mysqli_fetch_array($contractdata, MYSQLI_ASSOC); $contractrows= mysqli_fetch_array($contractdata, MYSQLI_ASSOC);
} }
if($_POST['type']=='facility'){ if($_POST['type']=='facility'){
$contractno = $_POST["contractno"];//合同號 $contractno = $_POST["contractno"];//合同號
$customerid = $_POST["customerid"];//客戶編號 $customerid = $_POST["customerid"];//客戶編號
$creater = $_POST["creater"];//建檔人 $creater = $_POST["creater"];//建檔人
$create_at = date('Y/m/d H:i:s');//創建時間 $create_at = date('Y/m/d H:i:s');//創建時間
$facilitynos=json_decode($_POST['facilitynos'], true); $facilitynos=json_decode($_POST['facilitynos'], true);
$weights=json_decode($_POST['weights'], true); $weights=json_decode($_POST['weights'], true);
$numberofstops=json_decode($_POST['numberofstops'], true); $numberofstops=json_decode($_POST['numberofstops'], true);
$numberoffloors=json_decode($_POST['numberoffloors'], true); $numberoffloors=json_decode($_POST['numberoffloors'], true);
$opentypes=json_decode($_POST['opentypes'], true); $opentypes=json_decode($_POST['opentypes'], true);
$speeds=json_decode($_POST['speeds'], true); $speeds=json_decode($_POST['speeds'], true);
$repairtypes=json_decode($_POST['repairtypes'], true); $repairtypes=json_decode($_POST['repairtypes'], true);
$longitudes=json_decode($_POST['longitudes'], true); $longitudes=json_decode($_POST['longitudes'], true);
$latitudes=json_decode($_POST['latitudes'], true); $latitudes=json_decode($_POST['latitudes'], true);
$addresss=json_decode($_POST['addresss'], true); $addresss=json_decode($_POST['addresss'], true);
$repairerids=json_decode($_POST['repairerids'], true); $repairerids=json_decode($_POST['repairerids'], true);
$repairernames=json_decode($_POST['repairernames'], true); $repairernames=json_decode($_POST['repairernames'], true);
$success=0; $success=0;
print_r($facilitynos); print_r($facilitynos);
for ($i = 0; $i<sizeof($facilitynos); $i++) { for ($i = 0; $i<sizeof($facilitynos); $i++) {
echo $db_query3 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofstop, numberoffloor,opentype,speed,repairtype,longitude, latitude, address,repairerid,repairername,creater, create_at) VALUES echo $db_query3 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofstop, numberoffloor,opentype,speed,repairtype,longitude, latitude, address,repairerid,repairername,creater, create_at) VALUES
('$contractno', '$facilitynos[$i]', '$customerid', '$weights[$i]','$numberofstops[$i]', '$numberoffloors[$i]','$opentypes[$i]','$speeds[$i]','$repairtypes[$i]','$longitudes[$i]', '$latitudes[$i]', '$addresss[$i]','$repairerids[$i]','$repairernames[$i]','$creater', '$create_at')"; ('$contractno', '$facilitynos[$i]', '$customerid', '$weights[$i]','$numberofstops[$i]', '$numberoffloors[$i]','$opentypes[$i]','$speeds[$i]','$repairtypes[$i]','$longitudes[$i]', '$latitudes[$i]', '$addresss[$i]','$repairerids[$i]','$repairernames[$i]','$creater', '$create_at')";
mysqli_query($link,$db_query3); mysqli_query($link,$db_query3);
if (mysqli_affected_rows($link)>0) { if (mysqli_affected_rows($link)>0) {
$success++; $success++;
} }
} }
echo $success; echo $success;
exit(); exit();
if($success>0){ if($success>0){
$jsonres['code']='200'; $jsonres['code']='200';
return json_encode($jsonres); return json_encode($jsonres);
// header('location:custom-create-schedule.php?accountid='.$customerid.'&contractno='.$contractno); // header('location:custom-create-schedule.php?accountid='.$customerid.'&contractno='.$contractno);
// exit(); // exit();
} ; } ;
} }
?> ?>
<div class="container" id="accountadd"> <div class="container" id="accountadd">
<table class="table table-bordered" style="width:100%"> <table class="table table-bordered" style="width:100%">
<thead> <thead>
<tr> <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>Line ID</th> <th>Line ID</th>
<th>微信id</th> <th>微信id</th>
<th>維修ID</th> <th>維修ID</th>
<th>直屬主管</th> <th>直屬主管</th>
<th>建檔人</th> <th>建檔人</th>
<th>建檔時間</th> <th>建檔時間</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><?php echo $row['accounttype']; ?></td> <td><?php echo $row['accounttype']; ?></td>
<td><?php echo $row['accountid']; ?></td> <td><?php echo $row['accountid']; ?></td>
<td><?php echo $row['pwd']; ?></td> <td><?php echo $row['pwd']; ?></td>
<td><?php echo $row['name']; ?></td> <td><?php echo $row['name']; ?></td>
<td><?php echo $row['tel']; ?></td> <td><?php echo $row['tel']; ?></td>
<td><?php echo $row['address']; ?></td> <td><?php echo $row['address']; ?></td>
<td><?php echo $row['email']; ?></td> <td><?php echo $row['email']; ?></td>
<td><?php echo $row['lineid']; ?></td> <td><?php echo $row['lineid']; ?></td>
<td><?php echo $row['wechatid']; ?></td> <td><?php echo $row['wechatid']; ?></td>
<td><?php echo $row['repairerid']; ?></td> <td><?php echo $row['repairerid']; ?></td>
<td><?php echo $row['manager']; ?></td> <td><?php echo $row['manager']; ?></td>
<td><?php echo $row['creater']; ?></td> <td><?php echo $row['creater']; ?></td>
<td><?php echo $row['create_at']; ?></td> <td><?php echo $row['create_at']; ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table class="table table-bordered" style="width:100%"> <table class="table table-bordered" style="width:100%">
<thead> <thead>
<tr> <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>--> <!-- <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> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><?php echo $contractrows['contracttype']; ?></td> <td><?php echo $contractrows['contracttype']; ?></td>
<td><?php echo $contractrows['contractno']; ?></td> <td><?php echo $contractrows['contractno']; ?></td>
<td><?php echo $contractrows['company']; ?></td> <td><?php echo $contractrows['company']; ?></td>
<td><?php echo $contractrows['taxid']; ?></td> <td><?php echo $contractrows['taxid']; ?></td>
<td><?php echo $contractrows['address']; ?></td> <td><?php echo $contractrows['address']; ?></td>
<td><?php echo $contractrows['tel']; ?></td> <td><?php echo $contractrows['tel']; ?></td>
<td><?php echo $contractrows['promiser']; ?></td> <td><?php echo $contractrows['promiser']; ?></td>
<td><?php echo $contractrows['customerid']; ?></td> <td><?php echo $contractrows['customerid']; ?></td>
<!-- <td>--><?php //echo $contractrows['contractperson']; ?><!--</td>--> <!-- <td>--><?php //echo $contractrows['contractperson']; ?><!--</td>-->
<!-- <td>--><?php //echo $contractrows['contractaddress']; ?><!--</td>--> <!-- <td>--><?php //echo $contractrows['contractaddress']; ?><!--</td>-->
<td><?php echo $contractrows['contracttel']; ?></td> <td><?php echo $contractrows['contracttel']; ?></td>
<td><?php echo $contractrows['contractemail']; ?></td> <td><?php echo $contractrows['contractemail']; ?></td>
<td><?php echo $contractrows['contract_employee']; ?></td> <td><?php echo $contractrows['contract_employee']; ?></td>
<td><?php echo $contractrows['start_date']; ?></td> <td><?php echo $contractrows['start_date']; ?></td>
<td><?php echo $contractrows['end_date']; ?></td> <td><?php echo $contractrows['end_date']; ?></td>
<td><?php echo $contractrows['creater']; ?></td> <td><?php echo $contractrows['creater']; ?></td>
<td><?php echo $contractrows['create_at']; ?></td> <td><?php echo $contractrows['create_at']; ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="text-center"> <h3>作番資料添加</h3> </div> <div class="text-center"> <h3>作番資料添加</h3> </div>
<div class="form-horizontal" > <div class="form-horizontal" >
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="contractno">合約號(必填)</label> <label for="contractno">合約號(必填)</label>
<input class="form-control contractno" type="text" id="contractno" value="<?php echo $contractrows['contractno']; ?>" required> <input class="form-control contractno" type="text" id="contractno" value="<?php echo $contractrows['contractno']; ?>" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="customerid">客戶編號(必填)</label> <label for="customerid">客戶編號(必填)</label>
<input class="form-control customerid" type="text" id="customerid" value="<?php echo $contractrows['customerid']; ?>" required> <input class="form-control customerid" type="text" id="customerid" value="<?php echo $contractrows['customerid']; ?>" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input class="form-control creater" type="text" id="creater" value="<?php echo $user_id;?>" > <input class="form-control creater" type="text" id="creater" value="<?php echo $user_id;?>" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<input class="form-control create_at" type="hidden" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> <input class="form-control create_at" type="hidden" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<input class="form-control type" type="hidden" id="type" value="facility"> <input class="form-control type" type="hidden" id="type" value="facility">
</div> </div>
<div class="col-md-3 "> <div class="col-md-3 ">
<button onclick="tijiao()" class="btn btn-primary btn-lg pull-right" >點擊後提交作番資料</button> <button onclick="tijiao()" class="btn btn-primary btn-lg pull-right" >點擊後提交作番資料</button>
</div> </div>
</div> </div>
<div id="facility"> <div id="facility">
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="facilityno">作番號(必填)</label> <label for="facilityno">作番號(必填)</label>
<input class="form-control facilitynos" type="text" id="facilityno" required> <input class="form-control facilitynos" type="text" id="facilityno" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="weight">重量(必填)</label> <label for="weight">重量(必填)</label>
<input class="form-control weights " type="text" id="weight" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input class="form-control weights " type="text" id="weight" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="numberofstop">停數(必填)</label> <label for="numberofstop">停數(必填)</label>
<input class="form-control numberofstops" type="text" id="numberofstop" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input class="form-control numberofstops" type="text" id="numberofstop" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div class="col-md-3" > <div class="col-md-3" >
<label for="numberoffloor">樓層數(必填)</label> <label for="numberoffloor">樓層數(必填)</label>
<input class="form-control numberoffloors" type="text" id="numberoffloor" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input class="form-control numberoffloors" type="text" id="numberoffloor" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3" > <div class="col-md-3" >
<label for="opentype">開門方式(必填)</label> <label for="opentype">開門方式(必填)</label>
<Select class="form-control opentypes" id="opentype" required> <Select class="form-control opentypes" id="opentype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="CO">CO</Option> <Option Value="CO">CO</Option>
<Option Value="SO">SO</Option> <Option Value="SO">SO</Option>
<Option Value="CO-SO">CO-SO</Option> <Option Value="CO-SO">CO-SO</Option>
</Select> </Select>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="speed">速度(必填)</label> <label for="speed">速度(必填)</label>
<input class="form-control speeds" type="text" id="speed" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required> <input class="form-control speeds" type="text" id="speed" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required>
</div class="col-md-3"> </div class="col-md-3">
<div class="col-md-3"> <div class="col-md-3">
<label for="repairtype">維修型態(必填)</label> <label for="repairtype">維修型態(必填)</label>
<Select class="form-control repairtypes" id="repairtype" required> <Select class="form-control repairtypes" id="repairtype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option> <Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option> <Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option> <Option Value="C">單次維修</Option>
</Select> </Select>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="address">地址</label> <label for="address">地址</label>
<input class="form-control addresss" type="text" id="address" > <input class="form-control addresss" type="text" id="address" >
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="longitude">經度(必填)</label> <label for="longitude">經度(必填)</label>
<input class="form-control longitudes" type="text" id="longitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required> <input class="form-control longitudes" type="text" id="longitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="latitude">緯度(必填)</label> <label for="latitude">緯度(必填)</label>
<input class="form-control latitudes" type="latitude" id="latitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required> <input class="form-control latitudes" type="latitude" id="latitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="repairerid">維修人員工號(必填)</label> <label for="repairerid">維修人員工號(必填)</label>
<input class="form-control repairerids" type="text" id="repairerid" required> <input class="form-control repairerids" type="text" id="repairerid" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="repairername">維修人員姓名(必填)</label> <label for="repairername">維修人員姓名(必填)</label>
<input class="form-control repairernames" type="text" id="repairername" required> <input class="form-control repairernames" type="text" id="repairername" required>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-12 text-center" > <div class="col-md-12 text-center" >
<h1 onclick="tan('f')" style="cursor: pointer;">+</h1> <h1 onclick="tan('f')" style="cursor: pointer;">+</h1>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

460
wms/custom-create-schedule.php

@ -1,230 +1,230 @@
<?php <?php
// 載入db.php來連結資料庫 // 載入db.php來連結資料庫
require_once "database.php"; require_once "database.php";
include "header.php"; include "header.php";
$accountid=$_REQUEST['accountid']; $accountid=$_REQUEST['accountid'];
$contractno=$_REQUEST['contractno']; $contractno=$_REQUEST['contractno'];
$facilitydata=[];//初始化 $facilitydata=[];//初始化
if(!empty($accountid)&&!empty($contractno)){ if(!empty($accountid)&&!empty($contractno)){
//查詢賬戶信息 //查詢賬戶信息
$accountsql = "SELECT * FROM account where accountid='$accountid'"; $accountsql = "SELECT * FROM account where accountid='$accountid'";
$accountdata = mysqli_query($link,$accountsql); $accountdata = mysqli_query($link,$accountsql);
$row = mysqli_fetch_array($accountdata, MYSQLI_ASSOC); $row = mysqli_fetch_array($accountdata, MYSQLI_ASSOC);
//查詢合同信息 //查詢合同信息
$contractsql = "SELECT * FROM contract where contractno='$contractno'"; $contractsql = "SELECT * FROM contract where contractno='$contractno'";
$contractdata=mysqli_query($link,$contractsql); $contractdata=mysqli_query($link,$contractsql);
$contractrows= mysqli_fetch_array($contractdata, MYSQLI_ASSOC); $contractrows= mysqli_fetch_array($contractdata, MYSQLI_ASSOC);
//查詢作番信息(可能多條) //查詢作番信息(可能多條)
$facilitysql = "SELECT * FROM facility where contractno='$contractno'"; $facilitysql = "SELECT * FROM facility where contractno='$contractno'";
$facilitydata=mysqli_query($link,$facilitysql); $facilitydata=mysqli_query($link,$facilitysql);
} }
?> ?>
<div class="container" id="accountadd"> <div class="container" id="accountadd">
<table class="table table-bordered" style="width:100%"> <table class="table table-bordered" style="width:100%">
<thead> <thead>
<tr> <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>Line ID</th> <th>Line ID</th>
<th>微信id</th> <th>微信id</th>
<th>維修ID</th> <th>維修ID</th>
<th>直屬主管</th> <th>直屬主管</th>
<th>建檔人</th> <th>建檔人</th>
<th>建檔時間</th> <th>建檔時間</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><?php echo $row['accounttype']; ?></td> <td><?php echo $row['accounttype']; ?></td>
<td><?php echo $row['accountid']; ?></td> <td><?php echo $row['accountid']; ?></td>
<td><?php echo $row['pwd']; ?></td> <td><?php echo $row['pwd']; ?></td>
<td><?php echo $row['name']; ?></td> <td><?php echo $row['name']; ?></td>
<td><?php echo $row['tel']; ?></td> <td><?php echo $row['tel']; ?></td>
<td><?php echo $row['address']; ?></td> <td><?php echo $row['address']; ?></td>
<td><?php echo $row['email']; ?></td> <td><?php echo $row['email']; ?></td>
<td><?php echo $row['lineid']; ?></td> <td><?php echo $row['lineid']; ?></td>
<td><?php echo $row['wechatid']; ?></td> <td><?php echo $row['wechatid']; ?></td>
<td><?php echo $row['repairerid']; ?></td> <td><?php echo $row['repairerid']; ?></td>
<td><?php echo $row['manager']; ?></td> <td><?php echo $row['manager']; ?></td>
<td><?php echo $row['creater']; ?></td> <td><?php echo $row['creater']; ?></td>
<td><?php echo $row['create_at']; ?></td> <td><?php echo $row['create_at']; ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table class="table table-bordered" style="width:100%"> <table class="table table-bordered" style="width:100%">
<thead> <thead>
<tr> <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>--> <!-- <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> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><?php echo $contractrows['contracttype']; ?></td> <td><?php echo $contractrows['contracttype']; ?></td>
<td><?php echo $contractrows['contractno']; ?></td> <td><?php echo $contractrows['contractno']; ?></td>
<td><?php echo $contractrows['company']; ?></td> <td><?php echo $contractrows['company']; ?></td>
<td><?php echo $contractrows['taxid']; ?></td> <td><?php echo $contractrows['taxid']; ?></td>
<td><?php echo $contractrows['address']; ?></td> <td><?php echo $contractrows['address']; ?></td>
<td><?php echo $contractrows['tel']; ?></td> <td><?php echo $contractrows['tel']; ?></td>
<td><?php echo $contractrows['promiser']; ?></td> <td><?php echo $contractrows['promiser']; ?></td>
<td><?php echo $contractrows['customerid']; ?></td> <td><?php echo $contractrows['customerid']; ?></td>
<!-- <td>--><?php //echo $contractrows['contractperson']; ?><!--</td>--> <!-- <td>--><?php //echo $contractrows['contractperson']; ?><!--</td>-->
<!-- <td>--><?php //echo $contractrows['contractaddress']; ?><!--</td>--> <!-- <td>--><?php //echo $contractrows['contractaddress']; ?><!--</td>-->
<td><?php echo $contractrows['contracttel']; ?></td> <td><?php echo $contractrows['contracttel']; ?></td>
<td><?php echo $contractrows['contractemail']; ?></td> <td><?php echo $contractrows['contractemail']; ?></td>
<td><?php echo $contractrows['contract_employee']; ?></td> <td><?php echo $contractrows['contract_employee']; ?></td>
<td><?php echo $contractrows['start_date']; ?></td> <td><?php echo $contractrows['start_date']; ?></td>
<td><?php echo $contractrows['end_date']; ?></td> <td><?php echo $contractrows['end_date']; ?></td>
<td><?php echo $contractrows['creater']; ?></td> <td><?php echo $contractrows['creater']; ?></td>
<td><?php echo $contractrows['create_at']; ?></td> <td><?php echo $contractrows['create_at']; ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table class="table table-striped table-bordered" style="width:100%"> <table class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <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> <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> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($facilitydata as $data) : ?> <?php foreach($facilitydata as $data) : ?>
<tr> <tr>
<td><?php echo $data['contractno']; ?></td> <td><?php echo $data['contractno']; ?></td>
<td><?php echo $data['facilityno']; ?></td> <td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['customerid']; ?></td> <td><?php echo $data['customerid']; ?></td>
<td><?php echo $data['weight']; ?></td> <td><?php echo $data['weight']; ?></td>
<td><?php echo $data['numberofstop']; ?></td> <td><?php echo $data['numberofstop']; ?></td>
<td><?php echo $data['numberoffloor']; ?></td> <td><?php echo $data['numberoffloor']; ?></td>
<td><?php echo $data['opentype']; ?></td> <td><?php echo $data['opentype']; ?></td>
<td><?php echo $data['speed']; ?></td> <td><?php echo $data['speed']; ?></td>
<td><?php echo $data['repairtype']; ?></td> <td><?php echo $data['repairtype']; ?></td>
<td><?php echo $data['longitude']; ?></td> <td><?php echo $data['longitude']; ?></td>
<td><?php echo $data['latitude']; ?></td> <td><?php echo $data['latitude']; ?></td>
<td><?php echo $data['address']; ?></td> <td><?php echo $data['address']; ?></td>
<td><?php echo $data['repairerid']; ?></td> <td><?php echo $data['repairerid']; ?></td>
<td><?php echo $data['repairername']; ?></td> <td><?php echo $data['repairername']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<div class="text-center"> <h3>保養行程資料添加</h3> </div> <div class="text-center"> <h3>保養行程資料添加</h3> </div>
<div class="form-horizontal"> <div class="form-horizontal">
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="contractno">合約號(必填)</label> <label for="contractno">合約號(必填)</label>
<input class="form-control contractno" type="text" id="contractno" value="<?php echo $contractrows['contractno']; ?>" required> <input class="form-control contractno" type="text" id="contractno" value="<?php echo $contractrows['contractno']; ?>" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input class="form-control creater" type="text" id="creater" value="<?php echo $user_id;?>" > <input class="form-control creater" type="text" id="creater" value="<?php echo $user_id;?>" >
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<input class="form-control create_at" type="hidden" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> <input class="form-control create_at" type="hidden" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<input class="form-control type" type="hidden" id="type" value="schedule"> <input class="form-control type" type="hidden" id="type" value="schedule">
</div> </div>
<div class="col-md-6 "> <div class="col-md-6 ">
<button onclick="tijiaosch()" class="btn btn-primary btn-lg pull-right" >點擊後提交保養行程資料</button> <button onclick="tijiaosch()" class="btn btn-primary btn-lg pull-right" >點擊後提交保養行程資料</button>
</div> </div>
</div> </div>
<div id="schedule"> <div id="schedule">
<div class="form-group" > <div class="form-group" >
<div class="col-md-3"> <div class="col-md-3">
<label for="facilityno">作番號(必填)</label> <label for="facilityno">作番號(必填)</label>
<input class="form-control facilitynos" type="text" id="facilityno" required> <input class="form-control facilitynos" type="text" id="facilityno" required>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<label for="combono">保養套餐編號(必填)</label> <label for="combono">保養套餐編號(必填)</label>
<input class="form-control combonos" type="text" id="combono" required> <input class="form-control combonos" type="text" id="combono" required>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<label for="duedate">應保養日期(必填)</label> <label for="duedate">應保養日期(必填)</label>
<input class="form-control duedates" type="text " id="duedate" value="<?php echo date('Y/m/d'); ?>" required> <input class="form-control duedates" type="text " id="duedate" value="<?php echo date('Y/m/d'); ?>" required>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<label for="repairerid">保養人員工號(必填)</label> <label for="repairerid">保養人員工號(必填)</label>
<input class="form-control repairerids" type="text" id="repairerid" required> <input class="form-control repairerids" type="text" id="repairerid" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="repairername">保養人員姓名(必填)</label> <label for="repairername">保養人員姓名(必填)</label>
<input class="form-control repairernames" type="text" id="repairername" required> <input class="form-control repairernames" type="text" id="repairername" required>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-12 text-center" > <div class="col-md-12 text-center" >
<h1 onclick="tan('s')" style="cursor: pointer;">+</h1> <h1 onclick="tan('s')" style="cursor: pointer;">+</h1>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

766
wms/custom-create.php

@ -1,383 +1,383 @@
<?php <?php
// 載入db.php來連結資料庫 // 載入db.php來連結資料庫
require_once "database.php"; require_once "database.php";
include "header.php"; include "header.php";
if($_POST['type']=='account'){ if($_POST['type']=='account'){
$accounttype = $_POST["accounttype"]; $accounttype = $_POST["accounttype"];
$accountid = $_POST["accountid"]; $accountid = $_POST["accountid"];
$pwd = $_POST["pwd"]; $pwd = $_POST["pwd"];
$name = $_POST["name"]; $name = $_POST["name"];
$tel = $_POST["tel"]; $tel = $_POST["tel"];
$address = $_POST["address"]; $address = $_POST["address"];
$email = $_POST["email"]; $email = $_POST["email"];
$lineid = $_POST["lineid"]; $lineid = $_POST["lineid"];
$wechatid = $_POST["wechatid"]; $wechatid = $_POST["wechatid"];
$phone_call_help = $_POST["phone_call_help"]; $phone_call_help = $_POST["phone_call_help"];
$chat_for_help = $_POST["chat_for_help"]; $chat_for_help = $_POST["chat_for_help"];
$remote_help = $_POST["remote_help"]; $remote_help = $_POST["remote_help"];
$repairerid = $_POST["repairerid"]; $repairerid = $_POST["repairerid"];
$manager = $_POST["manager"]; $manager = $_POST["manager"];
$creater = $_POST["creater"]; $creater = $_POST["creater"];
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
//查詢是否重複錄入 //查詢是否重複錄入
$sql = "SELECT * FROM account where accountid='$accountid'"; $sql = "SELECT * FROM account where accountid='$accountid'";
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
$nums_rows=mysqli_num_rows($data); $nums_rows=mysqli_num_rows($data);
if($nums_rows==0){ if($nums_rows==0){
//添加用戶 //添加用戶
$db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, creater, create_at) VALUES ('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$creater', '$create_at')"; $db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, creater, create_at) VALUES ('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$creater', '$create_at')";
mysqli_query($link,$db_query); mysqli_query($link,$db_query);
if (mysqli_affected_rows($link)>0) { if (mysqli_affected_rows($link)>0) {
header('location:custom-create-contract.php?accountid='.$accountid); header('location:custom-create-contract.php?accountid='.$accountid);
exit(); exit();
} }
elseif(mysqli_affected_rows($link)==0) { elseif(mysqli_affected_rows($link)==0) {
} }
} }
else{ else{
echo "<h1 class='text-center'>賬戶已經存在</h1>"; echo "<h1 class='text-center'>賬戶已經存在</h1>";
} }
} }
?> ?>
<script type ='text/JavaScript'> <script type ='text/JavaScript'>
function accounthide(){ function accounthide(){
$('#accountadd').addClass('hidden'); $('#accountadd').addClass('hidden');
} }
</script> </script>
<div class="container" id="accountadd"> <div class="container" id="accountadd">
<div class="text-center"> <h3>賬號資料添加</h3> </div> <div class="text-center"> <h3>賬號資料添加</h3> </div>
<form class="form-horizontal" name="account" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> <form class="form-horizontal" name="account" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="accounttype">帳號類別(必選)</label> <label for="accounttype">帳號類別(必選)</label>
<Select class="form-control" name="accounttype" id="accounttype" required> <Select class="form-control" name="accounttype" id="accounttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">客戶</Option> <Option Value="A">客戶</Option>
<Option Value="B">保養人員</Option> <Option Value="B">保養人員</Option>
<Option Value="C">檢查人員</Option> <Option Value="C">檢查人員</Option>
<Option Value="D">契約人員</Option> <Option Value="D">契約人員</Option>
<Option Value="E">管理人員</Option> <Option Value="E">管理人員</Option>
</Select> </Select>
</div> </div>
<div class="col-md-9 "> <div class="col-md-9 ">
<button type="submit" class="btn btn-primary btn-lg pull-right" >點擊後提交賬戶資料</button> <button type="submit" class="btn btn-primary btn-lg pull-right" >點擊後提交賬戶資料</button>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="accountid">員工、個人客戶ID或公司客戶統編(必填)</label> <label for="accountid">員工、個人客戶ID或公司客戶統編(必填)</label>
<input class="form-control" type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編(必填)" required> <input class="form-control" type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編(必填)" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="pwd">密碼(必填)</label> <label for="pwd">密碼(必填)</label>
<input class="form-control" type="text" name="pwd" id="pwd" required> <input class="form-control" type="text" name="pwd" id="pwd" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="name">姓名(必填)</label> <label for="name">姓名(必填)</label>
<input class="form-control" type="text" name="name" id="name" required> <input class="form-control" type="text" name="name" id="name" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="tel">電話</label> <label for="tel">電話</label>
<input class="form-control" type="text" name="tel" id="tel" maxlength="16"> <input class="form-control" type="text" name="tel" id="tel" maxlength="16">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="address">地址</label> <label for="address">地址</label>
<input class="form-control" type="text" name="address" id="address"> <input class="form-control" type="text" name="address" id="address">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="email">電子郵箱</label> <label for="email">電子郵箱</label>
<input class="form-control" type="text" name="email" id="email"> <input class="form-control" type="text" name="email" id="email">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="lineid">Line ID</label> <label for="lineid">Line ID</label>
<input class="form-control" type="text" name="lineid" id="lineid"> <input class="form-control" type="text" name="lineid" id="lineid">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="wechatid">微信ID</label> <label for="wechatid">微信ID</label>
<input class="form-control" type="text" name="wechatid" id="wechatid"> <input class="form-control" type="text" name="wechatid" id="wechatid">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="phone_call_help">聯絡手機號(必填)</label> <label for="phone_call_help">聯絡手機號(必填)</label>
<input class="form-control" type="text" name="phone_call_help" id="phone_call_help" maxlength="16" required> <input class="form-control" type="text" name="phone_call_help" id="phone_call_help" maxlength="16" required>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="chat_for_help">線上文字客服</label> <label for="chat_for_help">線上文字客服</label>
<input class="form-control" type="text" name="chat_for_help" id="chat_for_help"> <input class="form-control" type="text" name="chat_for_help" id="chat_for_help">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="remote_help">遠端視頻帳號</label> <label for="remote_help">遠端視頻帳號</label>
<input class="form-control" type="text" name="remote_help" id="remote_help"> <input class="form-control" type="text" name="remote_help" id="remote_help">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="repairerid">服務與支持人員工號(客戶必填)</label> <label for="repairerid">服務與支持人員工號(客戶必填)</label>
<input class="form-control" type="text" name="repairerid" id="repairerid" maxlength="10"> <input class="form-control" type="text" name="repairerid" id="repairerid" maxlength="10">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-3"> <div class="col-md-3">
<label for="manager">直屬主管工號(保養人員必填)</label> <label for="manager">直屬主管工號(保養人員必填)</label>
<input class="form-control" type="text" name="manager" id="manager" maxlength="10"> <input class="form-control" type="text" name="manager" id="manager" maxlength="10">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input class="form-control" type="text" name="creater" id="creater" value="<?php echo $user_id;?>"> <input class="form-control" type="text" name="creater" id="creater" value="<?php echo $user_id;?>">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<input class="form-control" type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>"> <input class="form-control" type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<input class="form-control" type="hidden" name="type" id="create_at" value="account"> <input class="form-control" type="hidden" name="type" id="create_at" value="account">
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<div class="container hidden"> <div class="container hidden">
<label for="fileToUpload">合約資料添加</label> <label for="fileToUpload">合約資料添加</label>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="contracttype">合約類型(必填)</label> <label for="contracttype">合約類型(必填)</label>
<Select name="contracttype" id="contracttype" required> <Select name="contracttype" id="contracttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option> <Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option> <Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option> <Option Value="C">單次維修</Option>
</Select> </Select>
</div> </div>
<div> <div>
<label for="contractno">合約號(必填)</label> <label for="contractno">合約號(必填)</label>
<input class="form-control" type="text" name="contractno" id="contractno" required> <input class="form-control" type="text" name="contractno" id="contractno" required>
</div> </div>
<div> <div>
<label for="company">公司名稱</label> <label for="company">公司名稱</label>
<input type="text" name="company" id="company" > <input type="text" name="company" id="company" >
</div> </div>
<div> <div>
<label for="taxid">統一編號</label> <label for="taxid">統一編號</label>
<input type="text" name="taxid" id="taxid" > <input type="text" name="taxid" id="taxid" >
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address" > <input type="text" name="address" id="address" >
</div> </div>
<div> <div>
<label for="tel">電話</label> <label for="tel">電話</label>
<input type="text" name="tel" id="tel" > <input type="text" name="tel" id="tel" >
</div> </div>
<div> <div>
<label for="promiser">立約人</label> <label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser"> <input type="text" name="promiser" id="promiser">
</div> </div>
<div> <div>
<label for="customerid">客戶維護帳號(必填)</label> <label for="customerid">客戶維護帳號(必填)</label>
<input type="text" name="customerid" id="customerid" required> <input type="text" name="customerid" id="customerid" required>
</div> </div>
<div> <div>
<label for="contractperson">業務聯繫人</label> <label for="contractperson">業務聯繫人</label>
<input type="text" name="contractperson" id="contractperson" > <input type="text" name="contractperson" id="contractperson" >
</div> </div>
<div> <div>
<label for="contractaddress">業務聯繫人地址</label> <label for="contractaddress">業務聯繫人地址</label>
<input type="text" name="contractaddress" id="contractaddress" > <input type="text" name="contractaddress" id="contractaddress" >
</div> </div>
<div> <div>
<label for="contracttel">業務聯繫人電話(必填)</label> <label for="contracttel">業務聯繫人電話(必填)</label>
<input type="text" name="contracttel" id="contracttel" required> <input type="text" name="contracttel" id="contracttel" required>
</div> </div>
<div> <div>
<label for="contractemail">業務聯繫人郵件地址</label> <label for="contractemail">業務聯繫人郵件地址</label>
<input type="text" name="contractemail" id="contractemail" > <input type="text" name="contractemail" id="contractemail" >
</div> </div>
<div> <div>
<label for="contract_employee">契約人員工號</label> <label for="contract_employee">契約人員工號</label>
<input type="text" name="contract_employee" id="contract_employee" > <input type="text" name="contract_employee" id="contract_employee" >
</div> </div>
<div> <div>
<label for="start_date">合約起始年月日(必填)</label><br> <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> <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>
<div> <div>
<label for="end_date">合約終止年月日(必填)</label><br> <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> <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>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater"> <input type="text" name="creater" id="creater">
<!-- <p class="error">--><?php //echo $creater_error; ?><!--</p>--> <!-- <p class="error">--><?php //echo $creater_error; ?><!--</p>-->
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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'); ?>"> <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>--> <!-- <p class="error">--><?php //echo $create_at_error; ?><!--</p>-->
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
</form </form
</div> </div>
<div class="container hidden"> <div class="container hidden">
<label for="fileToUpload">作番資料添加</label> <label for="fileToUpload">作番資料添加</label>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="contractno">合約號(必填)</label> <label for="contractno">合約號(必填)</label>
<input type="text" name="contractno" id="contractno" required> <input type="text" name="contractno" id="contractno" required>
</div> </div>
<div> <div>
<label for="facilityno">作番號(必填)</label> <label for="facilityno">作番號(必填)</label>
<input type="text" name="facilityno" id="facilityno" required> <input type="text" name="facilityno" id="facilityno" required>
</div> </div>
<div> <div>
<label for="customerid">客戶編號(必填)</label> <label for="customerid">客戶編號(必填)</label>
<input type="text" name="customerid" id="customerid" required> <input type="text" name="customerid" id="customerid" required>
</div> </div>
<div> <div>
<label for="weight">重量(必填)</label> <label for="weight">重量(必填)</label>
<input type="text" name="weight" id="weight" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="weight" id="weight" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="numberofstop">停數(必填)</label> <label for="numberofstop">停數(必填)</label>
<input type="text" name="numberofstop" id="numberofstop" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="numberofstop" id="numberofstop" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="numberoffloor">樓層數(必填)</label> <label for="numberoffloor">樓層數(必填)</label>
<input type="text" name="numberoffloor" id="numberoffloor" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="numberoffloor" id="numberoffloor" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="opentype">開門方式(必填)</label> <label for="opentype">開門方式(必填)</label>
<Select name="opentype" id="opentype" required> <Select name="opentype" id="opentype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="CO">CO</Option> <Option Value="CO">CO</Option>
<Option Value="SO">SO</Option> <Option Value="SO">SO</Option>
<Option Value="CO-SO">CO-SO</Option> <Option Value="CO-SO">CO-SO</Option>
</Select> </Select>
<!-- <input type="text" name="opentype" id="opentype" > --> <!-- <input type="text" name="opentype" id="opentype" > -->
</div> </div>
<div> <div>
<label for="speed">速度(必填)</label> <label for="speed">速度(必填)</label>
<input type="text" name="speed" id="speed" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required> <input type="text" name="speed" id="speed" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="repairtype">維修型態(必填)</label> <label for="repairtype">維修型態(必填)</label>
<Select name="repairtype" id="repairtype" required> <Select name="repairtype" id="repairtype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option> <Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option> <Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option> <Option Value="C">單次維修</Option>
</Select> </Select>
<!-- <input type="text" name="repairtype" id="repairtype" > --> <!-- <input type="text" name="repairtype" id="repairtype" > -->
</div> </div>
<div> <div>
<label for="longitude">經度(必填)</label> <label for="longitude">經度(必填)</label>
<input type="text" name="longitude" id="longitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required> <input type="text" name="longitude" id="longitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="latitude">緯度(必填)</label> <label for="latitude">緯度(必填)</label>
<input type="latitude" name="latitude" id="latitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required> <input type="latitude" name="latitude" id="latitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address" > <input type="text" name="address" id="address" >
</div> </div>
<div> <div>
<label for="repairerid">維修人員工號(必填)</label> <label for="repairerid">維修人員工號(必填)</label>
<input type="text" name="repairerid" id="repairerid" required> <input type="text" name="repairerid" id="repairerid" required>
</div> </div>
<div> <div>
<label for="repairername">維修人員姓名(必填)</label> <label for="repairername">維修人員姓名(必填)</label>
<input type="text" name="repairername" id="repairername" required> <input type="text" name="repairername" id="repairername" required>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater"> <input type="text" name="creater" id="creater">
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at"> <input type="hidden" name="create_at" id="create_at">
<p class="error"><?php echo $create_at_error; ?></p> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
</form> </form>
</div> </div>

222
wms/data_collection_merge_export_submit.php

@ -1,111 +1,111 @@
<?php <?php
#error_reporting(E_ALL); #error_reporting(E_ALL);
#ini_set('display_errors', "On"); #ini_set('display_errors', "On");
ob_start(); ob_start();
$user_id = '73376'; $user_id = '73376';
require_once "../database.php"; require_once "../database.php";
/** /**
*/ */
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
// include "header.php"; // include "header.php";
// 载入db.php来连结资料库 // 载入db.php来连结资料库
require_once "../database.php"; require_once "../database.php";
require_once '../PHPExcel/PHPExcel.php'; require_once '../PHPExcel/PHPExcel.php';
require_once '../PHPExcel/IOFactory.php'; require_once '../PHPExcel/IOFactory.php';
//$target_dir = "../inv-uploads/"; //$target_dir = "../inv-uploads/";
$target_file = 'data_collection_merge_template.xlsx'; $target_file = 'data_collection_merge_template.xlsx';
$EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION); $EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION);
if ($EXTENSION == 'xls') { if ($EXTENSION == 'xls') {
$objReader = PHPExcel_IOFactory::createReader('Excel5'); //支持xls $objReader = PHPExcel_IOFactory::createReader('Excel5'); //支持xls
} else { } else {
$objReader = PHPExcel_IOFactory::createReader('Excel2007'); //支持xlsx是 $objReader = PHPExcel_IOFactory::createReader('Excel2007'); //支持xlsx是
} }
$objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件 $objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件
$sheet = $objPHPExcel->getSheet(0); //拿到第一个sheet数据 $sheet = $objPHPExcel->getSheet(0); //拿到第一个sheet数据
$highestRow = $sheet->getHighestRow(); // 取得总行数 $highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数 $highestColumn = $sheet->getHighestColumn(); // 取得总列数
$highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字; $highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字;
$excelArray = array(); $excelArray = array();
$data = []; $data = [];
$data['yyyymm'] = $_POST['yyyymm']; $data['yyyymm'] = $_POST['yyyymm'];
$i = 2; $i = 2;
$sql_get = "select *From ec_purchase_order where yyyymm='" . $data['yyyymm'] . "' "; $sql_get = "select *From ec_purchase_order where yyyymm='" . $data['yyyymm'] . "' ";
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC); $res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC);
#excel 第一行 从B3-H3 #excel 第一行 从B3-H3
foreach ($res_get as $key => $val) { foreach ($res_get as $key => $val) {
// var_dump( $key); // var_dump( $key);
// $_val = $sheet->getCellByColumnAndRow(0, $i++)->getCalculatedValue(); // $_val = $sheet->getCellByColumnAndRow(0, $i++)->getCalculatedValue();
//if ($_val == "") return; //if ($_val == "") return;
// $value = $sheet->getCell($key)->getValue(); // $value = $sheet->getCell($key)->getValue();
// var_dump( $val); // var_dump( $val);
# 1 銀行編碼 # 1 銀行編碼
$sheet->setCellValueExplicit('A' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('A' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#2 繳款帳號 #2 繳款帳號
$sheet->setCellValueExplicit('B' . ($key + 2), date("Y-m-d"), \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('B' . ($key + 2), date("Y-m-d"), \PHPExcel_Cell_DataType::TYPE_STRING);
#3 客戶屬性 #3 客戶屬性
$sheet->setCellValueExplicit('C' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('C' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#4 幣別 #4 幣別
$sheet->setCellValueExplicit('D' . ($key + 2), 'TWD', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('D' . ($key + 2), 'TWD', \PHPExcel_Cell_DataType::TYPE_STRING);
#5 客戶代號 #5 客戶代號
$sheet->setCellValueExplicit('E' . ($key + 2), substr($val['customerid'], 1), \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('E' . ($key + 2), substr($val['customerid'], 1), \PHPExcel_Cell_DataType::TYPE_STRING);
# 6客戶名稱 # 6客戶名稱
$sheet->setCellValueExplicit('F' . ($key + 2), $val['customer_name'], \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('F' . ($key + 2), $val['customer_name'], \PHPExcel_Cell_DataType::TYPE_STRING);
# 7 繳費說明1 # 7 繳費說明1
$sheet->setCellValueExplicit('G' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('G' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
# 8 繳費說明2 # 8 繳費說明2
$sheet->setCellValueExplicit('H' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('H' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#9 繳費說明3 #9 繳費說明3
$sheet->setCellValueExplicit('I' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('I' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#10 繳費說明3 #10 繳費說明3
$sheet->setCellValueExplicit('J' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('J' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#11 繳費說明4 #11 繳費說明4
$sheet->setCellValueExplicit('K' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('K' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#12繳費說明5 #12繳費說明5
$sheet->setCellValueExplicit('L' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('L' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#13 繳款截止日 #13 繳款截止日
$sheet->setCellValueExplicit('M' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('M' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#14 期別說明 #14 期別說明
$sheet->setCellValueExplicit('N' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('N' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#15 繳費通路別-銀行 #15 繳費通路別-銀行
$sheet->setCellValueExplicit('O' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('O' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#16 繳費通路別-郵局 #16 繳費通路別-郵局
$sheet->setCellValueExplicit('P' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('P' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#17 應繳總額 #17 應繳總額
$sheet->setCellValueExplicit('Q' . ($key + 2), $val['summary_price'], \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('Q' . ($key + 2), $val['summary_price'], \PHPExcel_Cell_DataType::TYPE_STRING);
#18 保留欄1 #18 保留欄1
$sheet->setCellValueExplicit('R' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('R' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#19 保留欄2 #19 保留欄2
$sheet->setCellValueExplicit('S' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('S' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#20 收費項目 #20 收費項目
$sheet->setCellValueExplicit('T' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('T' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#21 應繳金額 #21 應繳金額
$sheet->setCellValueExplicit('U' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('U' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#22 說明 #22 說明
$sheet->setCellValueExplicit('V' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('V' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#23 收費項目 #23 收費項目
$sheet->setCellValueExplicit('W' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('W' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#24 應繳金額 #24 應繳金額
$sheet->setCellValueExplicit('X' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('X' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#25 說明 #25 說明
$sheet->setCellValueExplicit('Y' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('Y' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
#26 結尾符號 #26 結尾符號
$sheet->setCellValueExplicit('Z' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('Z' . ($key + 2), '', \PHPExcel_Cell_DataType::TYPE_STRING);
// $data[$excel_field_mapping[$key]] = (empty($value) || $value == '') ? 'null' : "'" . $value . "'"; //读取excel数据到数组 // $data[$excel_field_mapping[$key]] = (empty($value) || $value == '') ? 'null' : "'" . $value . "'"; //读取excel数据到数组
} }
//页面导出 //页面导出
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
//设置下载的文件名称 //设置下载的文件名称
header('Content-Disposition: attachment;filename=' . urlencode('代收資料匯入檔') . '.xlsx'); header('Content-Disposition: attachment;filename=' . urlencode('代收資料匯入檔') . '.xlsx');
header('Cache-Control: max-age=0'); header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1'); header('Cache-Control: max-age=1');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: cache, must-revalidate'); header('Cache-Control: cache, must-revalidate');
header('Pragma: public'); header('Pragma: public');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output'); $objWriter->save('php://output');
} }

84
wms/database.php

@ -1,42 +1,42 @@
<?php <?php
date_default_timezone_set("Asia/Taipei"); date_default_timezone_set("Asia/Taipei");
$envFile = __DIR__ . '/../.env'; // .env 文件的路径 $envFile = __DIR__ . '/../.env'; // .env 文件的路径
if (file_exists($envFile)) { if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) { if ($lines !== false) {
foreach ($lines as $line) { foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2); list($key, $value) = explode('=', $line, 2);
$key = trim($key); $key = trim($key);
$value = trim($value); $value = trim($value);
// 设置环境变量 // 设置环境变量
putenv("$key=$value"); putenv("$key=$value");
} }
} }
} }
date_default_timezone_set("Asia/Taipei"); date_default_timezone_set("Asia/Taipei");
$host = getenv('DB_HOST'); $host = getenv('DB_HOST');
$dbuser = getenv('DB_USERNAME'); $dbuser = getenv('DB_USERNAME');
$dbpassword = getenv('DB_PASSWORD'); $dbpassword = getenv('DB_PASSWORD');
$dbname = getenv('DB_DATABASE'); $dbname = getenv('DB_DATABASE');
$link = mysqli_connect($host, $dbuser, $dbpassword, $dbname); $link = mysqli_connect($host, $dbuser, $dbpassword, $dbname);
$sqlsrv = getenv('sqlsrv'); $sqlsrv = getenv('sqlsrv');
$Database = getenv('Database'); $Database = getenv('Database');
$Account = getenv('Account'); $Account = getenv('Account');
$Password = getenv('Password'); $Password = getenv('Password');
try { try {
$conn = new PDO("sqlsrv:Server=$sqlsrv;Database=$Database", "$Account", "$Password"); $conn = new PDO("sqlsrv:Server=$sqlsrv;Database=$Database", "$Account", "$Password");
if ($conn) { if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} }
} catch (PDOException $e) { } catch (PDOException $e) {
echo "fail"; echo "fail";
echo $e->getMessage(); echo $e->getMessage();
} }
if ($link) { if ($link) {
mysqli_query($link, 'SET NAMES utf8'); mysqli_query($link, 'SET NAMES utf8');
// echo "正確連接資料庫"; // echo "正確連接資料庫";
} else { } else {
echo "不正確連接資料庫</br>" . mysqli_connect_error(); echo "不正確連接資料庫</br>" . mysqli_connect_error();
} }

184
wms/delivery_info-create.php

@ -1,92 +1,92 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<div class="container"> <div class="container">
<?php <?php
include "delivery_info-record-submit.php"; include "delivery_info-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="deliver_no">貨運單號</label> <label for="deliver_no">貨運單號</label>
<input type="text" name="deliver_no" id="deliver_no" > <input type="text" name="deliver_no" id="deliver_no" >
</div> </div>
<div> <div>
<label for="orderer_id">訂購人編號</label> <label for="orderer_id">訂購人編號</label>
<input type="text" name="orderer_id" id="orderer_id" value="<?php echo $user_id; ?>"> <input type="text" name="orderer_id" id="orderer_id" value="<?php echo $user_id; ?>">
</div> </div>
<div> <div>
<label for="orderer_name">訂購人姓名</label> <label for="orderer_name">訂購人姓名</label>
<input type="text" name="orderer_name" id="orderer_name" value="<?php echo $user_name; ?>"> <input type="text" name="orderer_name" id="orderer_name" value="<?php echo $user_name; ?>">
</div> </div>
<div> <div>
<label for="contact_person">收件聯繫人</label> <label for="contact_person">收件聯繫人</label>
<input type="text" name="contact_person" id="contact_person" > <input type="text" name="contact_person" id="contact_person" >
</div> </div>
<div> <div>
<label for="tel">連絡電話</label> <label for="tel">連絡電話</label>
<input type="text" name="tel" id="tel" > <input type="text" name="tel" id="tel" >
</div> </div>
<div> <div>
<label for="address">收件地址</label> <label for="address">收件地址</label>
<input type="text" name="address" id="address" > <input type="text" name="address" id="address" >
</div> </div>
<div> <div>
<label for="total_price_equipments">物料總價</label> <label for="total_price_equipments">物料總價</label>
<input type="text" name="total_price_equipments" id="total_price_equipments" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="total_price_equipments" id="total_price_equipments" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="delivery_fee">運費</label> <label for="delivery_fee">運費</label>
<input type="text" name="delivery_fee" id="delivery_fee" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="delivery_fee" id="delivery_fee" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="tax_fee">稅金</label> <label for="tax_fee">稅金</label>
<input type="text" name="tax_fee" id="tax_fee" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="tax_fee" id="tax_fee" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="summation">合計</label> <label for="summation">合計</label>
<input type="text" name="summation" id="summation" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="summation" id="summation" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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'); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

22
wms/delivery_info-delete.php

@ -1,12 +1,12 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM delivery_info WHERE id='$id'"; $db_query = "DELETE FROM delivery_info WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("Refresh:0; url=delivery_info-index.php?function_name=delivery_info&".$token_link); header("Refresh:0; url=delivery_info-index.php?function_name=delivery_info&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

208
wms/delivery_info-edit.php

@ -1,104 +1,104 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM delivery_info WHERE id=$id"; $db_query = "SELECT * FROM delivery_info WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/record_update.php"; include "inc/record_update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="delivery_info-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="delivery_info-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="deliver_no">貨運單號</label> <label for="deliver_no">貨運單號</label>
<input type="text" name="deliver_no" id="deliver_no" value="<?php echo $data['deliver_no']; ?>"> <input type="text" name="deliver_no" id="deliver_no" value="<?php echo $data['deliver_no']; ?>">
</div> </div>
<div> <div>
<label for="orderer_id">訂購人編號</label> <label for="orderer_id">訂購人編號</label>
<input type="text" name="orderer_id" id="orderer_id" value="<?php echo $data['orderer_id']; ?>"> <input type="text" name="orderer_id" id="orderer_id" value="<?php echo $data['orderer_id']; ?>">
</div> </div>
<div> <div>
<label for="orderer_name">訂購人姓名</label> <label for="orderer_name">訂購人姓名</label>
<input type="text" name="orderer_name" id="orderer_name" value="<?php echo $data['orderer_name']; ?>"> <input type="text" name="orderer_name" id="orderer_name" value="<?php echo $data['orderer_name']; ?>">
</div> </div>
<div> <div>
<label for="contact_person">收件聯繫人</label> <label for="contact_person">收件聯繫人</label>
<input type="text" name="contact_person" id="contact_person" value="<?php echo $data['contact_person']; ?>"> <input type="text" name="contact_person" id="contact_person" value="<?php echo $data['contact_person']; ?>">
</div> </div>
<div> <div>
<label for="tel">連絡電話</label> <label for="tel">連絡電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> <input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div> </div>
<div> <div>
<label for="address">收件地址</label> <label for="address">收件地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> <input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div> </div>
<div> <div>
<label for="total_price_equipments">物料總價</label> <label for="total_price_equipments">物料總價</label>
<input type="text" name="total_price_equipments" id="total_price_equipments" value="<?php echo $data['total_price_equipments']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="total_price_equipments" id="total_price_equipments" value="<?php echo $data['total_price_equipments']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="delivery_fee">運費</label> <label for="delivery_fee">運費</label>
<input type="text" name="delivery_fee" id="delivery_fee" value="<?php echo $data['delivery_fee']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="delivery_fee" id="delivery_fee" value="<?php echo $data['delivery_fee']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="tax_fee">稅金</label> <label for="tax_fee">稅金</label>
<input type="text" name="tax_fee" id="tax_fee" value="<?php echo $data['tax_fee']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="tax_fee" id="tax_fee" value="<?php echo $data['tax_fee']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="summation">合計</label> <label for="summation">合計</label>
<input type="text" name="summation" id="summation" value="<?php echo $data['summation']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="summation" id="summation" value="<?php echo $data['summation']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo $data['create_at']; ?>"> <input type="hidden" name="create_at" id="create_at" value="<?php echo $data['create_at']; ?>">
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

292
wms/delivery_info-index.php

@ -1,147 +1,147 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id, "orderer_id"); $sql_cmd = sql_myself($user_id, "orderer_id");
$sql = "SELECT * FROM delivery_info $sql_cmd ORDER BY id"; $sql = "SELECT * FROM delivery_info $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<p> <p>
<a href="delivery_info-create.php?function_name=delivery_info&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="delivery_info-create.php?function_name=delivery_info&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:delivery_info-index.php"); header("Location:delivery_info-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <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> <th>稅金</th>
<th>合計</th> <th>合計</th>
<th>建檔日</th> <th>建檔日</th>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<th>修改</th> <th>修改</th>
<th>刪除</th> <th>刪除</th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['deliver_no']; ?></td> <td><?php echo $data['deliver_no']; ?></td>
<td><?php echo $data['orderer_id']; ?></td> <td><?php echo $data['orderer_id']; ?></td>
<td><?php echo $data['orderer_name']; ?></td> <td><?php echo $data['orderer_name']; ?></td>
<td><?php echo $data['contact_person']; ?></td> <td><?php echo $data['contact_person']; ?></td>
<td><?php echo $data['tel']; ?></td> <td><?php echo $data['tel']; ?></td>
<td><?php echo $data['address']; ?></td> <td><?php echo $data['address']; ?></td>
<td><?php echo $data['total_price_equipments']; ?></td> <td><?php echo $data['total_price_equipments']; ?></td>
<td><?php echo $data['delivery_fee']; ?></td> <td><?php echo $data['delivery_fee']; ?></td>
<td><?php echo $data['tax_fee']; ?></td> <td><?php echo $data['tax_fee']; ?></td>
<td><?php echo $data['summation']; ?></td> <td><?php echo $data['summation']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<td> <td>
<p> <p>
<a href="delivery_info-edit.php?id=<?php echo $data['id']; ?>&function_name=delivery_info&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="delivery_info-edit.php?id=<?php echo $data['id']; ?>&function_name=delivery_info&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<td> <td>
<p> <p>
<a href="delivery_info-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?')"> <a href="delivery_info-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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td> </td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

98
wms/delivery_info-record-submit.php

@ -1,49 +1,49 @@
<?php <?php
$deliver_no= ""; $deliver_no= "";
$orderer_id= ""; $orderer_id= "";
$orderer_name= ""; $orderer_name= "";
$contact_person= ""; $contact_person= "";
$tel= ""; $tel= "";
$address= ""; $address= "";
$total_price_equipments= ""; $total_price_equipments= "";
$delivery_fee= ""; $delivery_fee= "";
$tax_fee= ""; $tax_fee= "";
$summation= ""; $summation= "";
$create_at= ""; $create_at= "";
$deliver_no_error= ""; $deliver_no_error= "";
$orderer_id_error= ""; $orderer_id_error= "";
$orderer_name_error= ""; $orderer_name_error= "";
$contact_person_error= ""; $contact_person_error= "";
$tel_error= ""; $tel_error= "";
$address_error= ""; $address_error= "";
$total_price_equipments_error= ""; $total_price_equipments_error= "";
$delivery_fee_error= ""; $delivery_fee_error= "";
$tax_fee_error= ""; $tax_fee_error= "";
$summation_error= ""; $summation_error= "";
$create_at_error = ""; $create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
include "delivery_info-user-input.php"; include "delivery_info-user-input.php";
$db_query = "INSERT INTO delivery_info (deliver_no, orderer_id, orderer_name, contact_person, tel, address, total_price_equipments, delivery_fee, tax_fee, summation, create_at) VALUES ('$deliver_no', '$orderer_id', '$orderer_name', '$contact_person','$tel', '$address', '$total_price_equipments', '$delivery_fee', '$tax_fee', '$summation', '$create_at')"; $db_query = "INSERT INTO delivery_info (deliver_no, orderer_id, orderer_name, contact_person, tel, address, total_price_equipments, delivery_fee, tax_fee, summation, create_at) VALUES ('$deliver_no', '$orderer_id', '$orderer_name', '$contact_person','$tel', '$address', '$total_price_equipments', '$delivery_fee', '$tax_fee', '$summation', '$create_at')";
$result = mysqli_query($link,$db_query); $result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');"; echo "alert('新增成功');";
echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';"; echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';"; echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

86
wms/delivery_info-record-update.php

@ -1,44 +1,44 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$id = $_POST['id']; $id = $_POST['id'];
$deliver_no = user_input($_POST["deliver_no"]); $deliver_no = user_input($_POST["deliver_no"]);
$orderer_id = user_input($_POST["orderer_id"]); $orderer_id = user_input($_POST["orderer_id"]);
$orderer_name = user_input($_POST["orderer_name"]); $orderer_name = user_input($_POST["orderer_name"]);
$contact_person = user_input($_POST["contact_person"]); $contact_person = user_input($_POST["contact_person"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]); $address = user_input($_POST["address"]);
$total_price_equipments = user_input($_POST["total_price_equipments"]); $total_price_equipments = user_input($_POST["total_price_equipments"]);
$delivery_fee = user_input($_POST["delivery_fee"]); $delivery_fee = user_input($_POST["delivery_fee"]);
$tax_fee = user_input($_POST["tax_fee"]); $tax_fee = user_input($_POST["tax_fee"]);
$summation = user_input($_POST["summation"]); $summation = user_input($_POST["summation"]);
$create_at = user_input($_POST["create_at"]); $create_at = user_input($_POST["create_at"]);
$db_query = "UPDATE delivery_info set deliver_no = '$deliver_no', orderer_id = '$orderer_id', orderer_name = '$orderer_name', contact_person = '$contact_person', tel = '$tel', address = '$address', total_price_equipments = '$total_price_equipments', delivery_fee = '$delivery_fee', tax_fee = '$tax_fee', summation = '$summation', create_at = '$create_at' WHERE id='$id'"; $db_query = "UPDATE delivery_info set deliver_no = '$deliver_no', orderer_id = '$orderer_id', orderer_name = '$orderer_name', contact_person = '$contact_person', tel = '$tel', address = '$address', total_price_equipments = '$total_price_equipments', delivery_fee = '$delivery_fee', tax_fee = '$tax_fee', summation = '$summation', create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("location: delivery_info-index.php"); header("location: delivery_info-index.php");
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';"; echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';"; echo "location.href='delivery_info-index.php?function_name=delivery_info&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

116
wms/delivery_info-user-input.php

@ -1,58 +1,58 @@
<?php <?php
//Function to filter the form input //Function to filter the form input
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$deliver_no = user_input($_POST["deliver_no"]); $deliver_no = user_input($_POST["deliver_no"]);
$orderer_id = user_input($_POST["orderer_id"]); $orderer_id = user_input($_POST["orderer_id"]);
$orderer_name = user_input($_POST["orderer_name"]); $orderer_name = user_input($_POST["orderer_name"]);
$contact_person = user_input($_POST["contact_person"]); $contact_person = user_input($_POST["contact_person"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]); $address = user_input($_POST["address"]);
$total_price_equipments = user_input($_POST["total_price_equipments"]); $total_price_equipments = user_input($_POST["total_price_equipments"]);
$delivery_fee = user_input($_POST["delivery_fee"]); $delivery_fee = user_input($_POST["delivery_fee"]);
$tax_fee = user_input($_POST["tax_fee"]); $tax_fee = user_input($_POST["tax_fee"]);
$summation = user_input($_POST["summation"]); $summation = user_input($_POST["summation"]);
$create_at = user_input($_POST["create_at"]); $create_at = user_input($_POST["create_at"]);
/* /*
if(empty($_POST["name"])) { if(empty($_POST["name"])) {
$name_error = "Name is required"; $name_error = "Name is required";
} else { } else {
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed"; $name_error = "Only letter and white space are allowed";
} }
} }
/* /*
if(empty($_POST["website"])) { if(empty($_POST["website"])) {
$website_error = "Website address is required"; $website_error = "Website address is required";
} else { } else {
$website = user_input($_POST["website"]); $website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL"; $website_error = "Invalid website URL";
} }
} }
if(empty($_POST["comment"])) { if(empty($_POST["comment"])) {
$comment = ""; $comment = "";
} else { } else {
$comment = user_input($_POST["comment"]); $comment = user_input($_POST["comment"]);
} }
*/ */
?> ?>

132
wms/delivery_log-create.php

@ -1,66 +1,66 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<div class="container"> <div class="container">
<?php <?php
include "delivery_log-record-submit.php"; include "delivery_log-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="delivery_no">貨運單號</label> <label for="delivery_no">貨運單號</label>
<input type="text" name="delivery_no" id="delivery_no" > <input type="text" name="delivery_no" id="delivery_no" >
</div> </div>
<div> <div>
<label for="issue_time">實際抵達時間</label> <label for="issue_time">實際抵達時間</label>
<input type="text" name="issue_time" id="issue_time" value="<?php echo date('Y/m/d H:i:s'); ?>"> <input type="text" name="issue_time" id="issue_time" value="<?php echo date('Y/m/d H:i:s'); ?>">
</div> </div>
<div> <div>
<label for="location">地點</label> <label for="location">地點</label>
<input type="text" name="location" id="location"> <input type="text" name="location" id="location">
</div> </div>
<div> <div>
<label for="memo">備註</label> <label for="memo">備註</label>
<input type="text" name="memo" id="memo" > <input type="text" name="memo" id="memo" >
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p> <p class="error"><?php echo $creater_error; ?></p>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at"> <input type="hidden" name="create_at" id="create_at">
<p class="error"><?php echo $create_at_error; ?></p> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

22
wms/delivery_log-delete.php

@ -1,12 +1,12 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM delivery_log WHERE id='$id'"; $db_query = "DELETE FROM delivery_log WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("Refresh:0; url=delivery_log-index.php?function_name=delivery_log&".$token_link); header("Refresh:0; url=delivery_log-index.php?function_name=delivery_log&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

150
wms/delivery_log-edit.php

@ -1,75 +1,75 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM delivery_log WHERE id=$id"; $db_query = "SELECT * FROM delivery_log WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/record_update.php"; include "inc/record_update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="delivery_log-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="delivery_log-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="delivery_no">貨運單號</label> <label for="delivery_no">貨運單號</label>
<input type="text" name="delivery_no" id="delivery_no" value="<?php echo $data['deliver_no']; ?>"> <input type="text" name="delivery_no" id="delivery_no" value="<?php echo $data['deliver_no']; ?>">
</div> </div>
<div> <div>
<label for="issue_time">實際抵達時間</label> <label for="issue_time">實際抵達時間</label>
<input type="text" name="issue_time" id="issue_time" value="<?php echo $data['issue_time']; ?>"> <input type="text" name="issue_time" id="issue_time" value="<?php echo $data['issue_time']; ?>">
</div> </div>
<div> <div>
<label for="location">地點</label> <label for="location">地點</label>
<input type="text" name="location" id="location" value="<?php echo $data['location']; ?>"> <input type="text" name="location" id="location" value="<?php echo $data['location']; ?>">
</div> </div>
<div> <div>
<label for="memo">備註</label> <label for="memo">備註</label>
<input type="text" name="memo" id="memo" value="<?php echo $data['memo']; ?>"> <input type="text" name="memo" id="memo" value="<?php echo $data['memo']; ?>">
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div> <div>
<br> <br>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

272
wms/delivery_log-index.php

@ -1,137 +1,137 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id); $sql_cmd = sql_myself($user_id);
$sql = "SELECT * FROM delivery_log $sql_cmd ORDER BY id"; $sql = "SELECT * FROM delivery_log $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<p> <p>
<a href="delivery_log-create.php?function_name=delivery_log&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="delivery_log-create.php?function_name=delivery_log&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:delivery_log-index.php"); header("Location:delivery_log-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <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>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<th>修改</th> <th>修改</th>
<th>刪除</th> <th>刪除</th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['deliver_no']; ?></td> <td><?php echo $data['deliver_no']; ?></td>
<td><?php echo $data['issue_time']; ?></td> <td><?php echo $data['issue_time']; ?></td>
<td><?php echo $data['location']; ?></td> <td><?php echo $data['location']; ?></td>
<td><?php echo $data['memo']; ?></td> <td><?php echo $data['memo']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<td> <td>
<p> <p>
<a href="delivery_log-edit.php?id=<?php echo $data['id']; ?>&function_name=delivery_log&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="delivery_log-edit.php?id=<?php echo $data['id']; ?>&function_name=delivery_log&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<td> <td>
<p> <p>
<a href="delivery_log-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?')"> <a href="delivery_log-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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td> </td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

76
wms/delivery_log-record-submit.php

@ -1,38 +1,38 @@
<?php <?php
$deliver_no= ""; $deliver_no= "";
$issue_time= ""; $issue_time= "";
$location= ""; $location= "";
$memo= ""; $memo= "";
$creater= ""; $creater= "";
$create_at= ""; $create_at= "";
$deliver_no_error= ""; $deliver_no_error= "";
$issue_time_error= ""; $issue_time_error= "";
$location_error= ""; $location_error= "";
$memo_error= ""; $memo_error= "";
$creater_error = ""; $creater_error = "";
$create_at_error = ""; $create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
include "delivery_log-user-input.php"; include "delivery_log-user-input.php";
$db_query = "INSERT INTO delivery_log(deliver_no, issue_time, location, memo,creater,create_at) VALUES ('$deliver_no', '$issue_time', '$location', '$memo','$creater', '$create_at')"; $db_query = "INSERT INTO delivery_log(deliver_no, issue_time, location, memo,creater,create_at) VALUES ('$deliver_no', '$issue_time', '$location', '$memo','$creater', '$create_at')";
$result = mysqli_query($link,$db_query); $result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');"; echo "alert('新增成功');";
echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';"; echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';"; echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

74
wms/delivery_log-record-update.php

@ -1,38 +1,38 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$id = $_POST['id']; $id = $_POST['id'];
$deliver_no = user_input($_POST["delivery_no"]); $deliver_no = user_input($_POST["delivery_no"]);
$issue_time = user_input($_POST["issue_time"]); $issue_time = user_input($_POST["issue_time"]);
$location = user_input($_POST["location"]); $location = user_input($_POST["location"]);
$memo = user_input($_POST["memo"]); $memo = user_input($_POST["memo"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE delivery_log set deliver_no = '$deliver_no', issue_time = '$issue_time', location = '$location', memo = '$memo',create_at = '$create_at' WHERE id='$id'"; $db_query = "UPDATE delivery_log set deliver_no = '$deliver_no', issue_time = '$issue_time', location = '$location', memo = '$memo',create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';"; echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';"; echo "location.href='delivery_log-index.php?function_name=delivery_log&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

106
wms/delivery_log-user-input.php

@ -1,53 +1,53 @@
<?php <?php
//Function to filter the form input //Function to filter the form input
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$deliver_no = user_input($_POST["delivery_no"]); $deliver_no = user_input($_POST["delivery_no"]);
$issue_time = user_input($_POST["issue_time"]); $issue_time = user_input($_POST["issue_time"]);
$location = user_input($_POST["location"]); $location = user_input($_POST["location"]);
$memo = user_input($_POST["memo"]); $memo = user_input($_POST["memo"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
/* /*
if(empty($_POST["name"])) { if(empty($_POST["name"])) {
$name_error = "Name is required"; $name_error = "Name is required";
} else { } else {
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed"; $name_error = "Only letter and white space are allowed";
} }
} }
/* /*
if(empty($_POST["website"])) { if(empty($_POST["website"])) {
$website_error = "Website address is required"; $website_error = "Website address is required";
} else { } else {
$website = user_input($_POST["website"]); $website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL"; $website_error = "Invalid website URL";
} }
} }
if(empty($_POST["comment"])) { if(empty($_POST["comment"])) {
$comment = ""; $comment = "";
} else { } else {
$comment = user_input($_POST["comment"]); $comment = user_input($_POST["comment"]);
} }
*/ */
?> ?>

8
wms/demo.dart

@ -1,4 +1,4 @@
void main() { void main() {
String name="测试"; String name="测试";
print("1231v\${name}/${name}"); print("1231v\${name}/${name}");
} }

376
wms/ec_purchase_order_submit.php

@ -1,188 +1,188 @@
<?php <?php
//error_reporting(E_ALL); //error_reporting(E_ALL);
ob_start(); ob_start();
//ini_set('display_errors', "On"); //ini_set('display_errors', "On");
require_once "../database.php"; require_once "../database.php";
$customerid = ""; $customerid = "";
$inv_customer_id = ""; $inv_customer_id = "";
$inv_customer_name = ""; $inv_customer_name = "";
$customer_name = ""; $customer_name = "";
$item_no = ""; $item_no = "";
$item_name = ""; $item_name = "";
$num = ""; $num = "";
$unit_price = ""; $unit_price = "";
$pre_tax_price = ""; $pre_tax_price = "";
$business_tax = ""; $business_tax = "";
$summary_price = ""; $summary_price = "";
#$delivery_date = ""; #$delivery_date = "";
$summary = ""; $summary = "";
$contract_begin_date = ""; $contract_begin_date = "";
$contract_end_date = ""; $contract_end_date = "";
$salesman = ""; $salesman = "";
$operator_name = ""; $operator_name = "";
$enter_date = ""; $enter_date = "";
$creater = ""; $creater = "";
$create_at = ""; $create_at = "";
#excel字段與mysql表字段映射 #excel字段與mysql表字段映射
$excel_field_mapping = [ $excel_field_mapping = [
0 => "date_seq", 0 => "date_seq",
1 => "customerid", 1 => "customerid",
2 => "inv_customer_id", 2 => "inv_customer_id",
3 => "inv_customer_name", 3 => "inv_customer_name",
4 => "customer_name", 4 => "customer_name",
5 => "item_no", 5 => "item_no",
6 => "item_name", 6 => "item_name",
7 => "num", 7 => "num",
8 => "unit_price", 8 => "unit_price",
9 => "pre_tax_price", 9 => "pre_tax_price",
10 => "business_tax", 10 => "business_tax",
11 => "summary_price", 11 => "summary_price",
12 => "delivery_date", 12 => "delivery_date",
13 => "summary", 13 => "summary",
14 => "contract_begin_date", 14 => "contract_begin_date",
15 => "contract_end_date", 15 => "contract_end_date",
16 => "salesman", 16 => "salesman",
17 => "operator_name", 17 => "operator_name",
18 => "enter_date", 18 => "enter_date",
]; ];
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
include "header.php"; include "header.php";
// 载入db.php来连结资料库 // 载入db.php来连结资料库
require_once "../database.php"; require_once "../database.php";
require_once '../PHPExcel/PHPExcel.php'; require_once '../PHPExcel/PHPExcel.php';
require_once '../PHPExcel/IOFactory.php'; require_once '../PHPExcel/IOFactory.php';
$file_name = $_FILES["file"]["name"]; $file_name = $_FILES["file"]["name"];
$temp_file_name = $_FILES["file"]["tmp_name"]; $temp_file_name = $_FILES["file"]["tmp_name"];
//$target_dir = "../inv-uploads/ec/" . $_POST['yyyymm'] . "/"; //$target_dir = "../inv-uploads/ec/" . $_POST['yyyymm'] . "/";
//if (is_dir($target_dir) || mkdir($target_dir, '0777')); //if (is_dir($target_dir) || mkdir($target_dir, '0777'));
$target_dir = "../inv-uploads/"; $target_dir = "../inv-uploads/";
$target_file = strtolower($target_dir . strtotime("now") . "." . pathinfo($file_name, PATHINFO_EXTENSION)); $target_file = strtolower($target_dir . strtotime("now") . "." . pathinfo($file_name, PATHINFO_EXTENSION));
$EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION); $EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION);
if (move_uploaded_file($temp_file_name, $target_file)) { if (move_uploaded_file($temp_file_name, $target_file)) {
if ($EXTENSION == 'xls') { if ($EXTENSION == 'xls') {
$objReader = PHPExcel_IOFactory::createReader('Excel5'); //支持xls $objReader = PHPExcel_IOFactory::createReader('Excel5'); //支持xls
} else { } else {
$objReader = PHPExcel_IOFactory::createReader('Excel2007'); //支持xlsx是 $objReader = PHPExcel_IOFactory::createReader('Excel2007'); //支持xlsx是
} }
$objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件 $objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件
$sheet = $objPHPExcel->getSheet(0); //拿到第一个sheet数据 $sheet = $objPHPExcel->getSheet(0); //拿到第一个sheet数据
$highestRow = $sheet->getHighestRow(); // 取得总行数 $highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数 $highestColumn = $sheet->getHighestColumn(); // 取得总列数
$highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字; $highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字;
$excelArray = array(); $excelArray = array();
$success_in = 0; $success_in = 0;
$fail_in = 0; $fail_in = 0;
#循環讀取excel ec_purchase_order #循環讀取excel ec_purchase_order
/** /**
* 1.将表格存放在 ec_purchase_order_tmp表,group by 是否有重复记录,有则定向到ec_purchase_order_import显示 * 1.将表格存放在 ec_purchase_order_tmp表,group by 是否有重复记录,有则定向到ec_purchase_order_import显示
* 2.ec_purchase_order_tmp表group by 后无重复, 则union ec_purchase_order 是否有重复记录,有则定向到ec_purchase_order_import显示 * 2.ec_purchase_order_tmp表group by 后无重复, 则union ec_purchase_order 是否有重复记录,有则定向到ec_purchase_order_import显示
* 3.如果没有重复资料,则重定向到ec_purchase_order页面 * 3.如果没有重复资料,则重定向到ec_purchase_order页面
*/ */
# 1.将表格存放在 ec_purchase_order_tmp表,group by 是否有重复记录,有则定向到ec_purchase_order_import显示 # 1.将表格存放在 ec_purchase_order_tmp表,group by 是否有重复记录,有则定向到ec_purchase_order_import显示
mysqli_query($link, "delete from ec_purchase_order_tmp where form_key='" . $_POST['form_key'] . "'"); mysqli_query($link, "delete from ec_purchase_order_tmp where form_key='" . $_POST['form_key'] . "'");
for ($row = 3; $row <= $highestRow - 3; $row++) { for ($row = 3; $row <= $highestRow - 3; $row++) {
$val = $sheet->getCellByColumnAndRow(0, $row)->getCalculatedValue(); $val = $sheet->getCellByColumnAndRow(0, $row)->getCalculatedValue();
if ($val == "") return; if ($val == "") return;
$data = []; $data = [];
for ($column = 0; $column < $highestColumn; $column++) { for ($column = 0; $column < $highestColumn; $column++) {
$val = $sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue(); $val = $sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue();
//上午 오전 am 下午 오후 pm 2023-03-06 오후 12:47:28 //上午 오전 am 下午 오후 pm 2023-03-06 오후 12:47:28
#包含上午 오전 #包含上午 오전
if ($column == 18 && mb_strpos($val, '오전')) { if ($column == 18 && mb_strpos($val, '오전')) {
$_am = str_replace('오전', "", $val); $_am = str_replace('오전', "", $val);
//echo "_A:" . $_am . 'AM'; //echo "_A:" . $_am . 'AM';
$val = date("Y-m-d G:i:s", strtotime($_am . 'AM')); $val = date("Y-m-d G:i:s", strtotime($_am . 'AM'));
} elseif ($column == 18 && mb_strpos($val, '오후')) { } elseif ($column == 18 && mb_strpos($val, '오후')) {
$_pm = str_replace('오후', "", $val); $_pm = str_replace('오후', "", $val);
$val = date("Y-m-d G:i:s", strtotime($_pm . 'PM')); $val = date("Y-m-d G:i:s", strtotime($_pm . 'PM'));
} }
$data[$excel_field_mapping[$column]] = (empty($val) || $val == '') ? 'null' : "'" . $val . "'"; //读取excel数据到数组 $data[$excel_field_mapping[$column]] = (empty($val) || $val == '') ? 'null' : "'" . $val . "'"; //读取excel数据到数组
} }
$data['yyyymm'] = $_POST['yyyymm']; $data['yyyymm'] = $_POST['yyyymm'];
$data['form_key'] = $_POST['form_key']; $data['form_key'] = $_POST['form_key'];
$db_query1 = 'insert into ec_purchase_order_tmp(' . implode(array_keys($data), ',') . ') values (' . implode(array_values($data), ',') . ')'; $db_query1 = 'insert into ec_purchase_order_tmp(' . implode(array_keys($data), ',') . ') values (' . implode(array_values($data), ',') . ')';
mysqli_query($link, $db_query1); mysqli_query($link, $db_query1);
} }
#ec_purchase_order_tmp表group by 是否有重复记录,有则定向到ec_purchase_order_import显示 #ec_purchase_order_tmp表group by 是否有重复记录,有则定向到ec_purchase_order_import显示
#gorup by #gorup by
$sql_group_epot = " $sql_group_epot = "
SELECT count(*) cnt, SELECT count(*) cnt,
date_seq, date_seq,
customerid, customerid,
item_no, item_no,
num, num,
unit_price, unit_price,
pre_tax_price, pre_tax_price,
business_tax, business_tax,
summary_price, summary_price,
enter_date From ec_purchase_order_tmp enter_date From ec_purchase_order_tmp
WHERE form_key = '" . $_POST['form_key'] . "' WHERE form_key = '" . $_POST['form_key'] . "'
GROUP BY date_Seq, customerid, item_no, num, unit_price, pre_tax_price, business_tax, summary_price, enter_date GROUP BY date_Seq, customerid, item_no, num, unit_price, pre_tax_price, business_tax, summary_price, enter_date
HAVING COUNT(*) > 1"; HAVING COUNT(*) > 1";
$res_group_epot = mysqli_fetch_row(mysqli_query($link, $sql_group_epot)); $res_group_epot = mysqli_fetch_row(mysqli_query($link, $sql_group_epot));
#存在重复的记录ec_purchase_order_import #存在重复的记录ec_purchase_order_import
if (!empty($res_group_epot)) { if (!empty($res_group_epot)) {
header("location: ec_purchase_order_import.php?error_form_key=" . $_POST['form_key']); header("location: ec_purchase_order_import.php?error_form_key=" . $_POST['form_key']);
exit(); exit();
} }
$sql_group_epo = " $sql_group_epo = "
SELECT SELECT
count(*) cnt, count(*) cnt,
a.date_seq, a.date_seq,
a.customerid, a.customerid,
a.item_no, a.item_no,
a.num, a.num,
a.unit_price, a.unit_price,
a.pre_tax_price, a.pre_tax_price,
a.business_tax, a.business_tax,
a.summary_price, a.summary_price,
a.enter_date a.enter_date
FROM FROM
ec_purchase_order a, ec_purchase_order a,
ec_purchase_order_tmp b ec_purchase_order_tmp b
WHERE WHERE
a.date_seq = b.date_seq a.date_seq = b.date_seq
AND a.customerid = b.customerid AND a.customerid = b.customerid
AND a.item_no = b.item_no AND a.item_no = b.item_no
AND a.num = b.num AND a.num = b.num
AND a.unit_price = b.unit_price AND a.unit_price = b.unit_price
AND a.pre_tax_price = b.pre_tax_price AND a.pre_tax_price = b.pre_tax_price
AND a.business_tax = b.business_tax AND a.business_tax = b.business_tax
AND a.summary_price = b.summary_price AND a.summary_price = b.summary_price
AND a.enter_date = b.enter_date AND a.enter_date = b.enter_date
GROUP BY a.date_seq, a.customerid, a.item_no, a.num, a.unit_price, GROUP BY a.date_seq, a.customerid, a.item_no, a.num, a.unit_price,
a.pre_tax_price, a.business_tax, a.summary_price, a.enter_date"; a.pre_tax_price, a.business_tax, a.summary_price, a.enter_date";
$res_group_epo = mysqli_fetch_row(mysqli_query($link, $sql_group_epo)); $res_group_epo = mysqli_fetch_row(mysqli_query($link, $sql_group_epo));
// echo $sql_group_epo; // echo $sql_group_epo;
// exit(); // exit();
#存在重复的记录ec_purchase_order_import #存在重复的记录ec_purchase_order_import
if (!empty($res_group_epo)) { if (!empty($res_group_epo)) {
header("location: ec_purchase_order_import.php?error_form_key=" . $_POST['form_key']); header("location: ec_purchase_order_import.php?error_form_key=" . $_POST['form_key']);
exit(); exit();
} }
#不存在重复记录则插入到ec_purchase_order #不存在重复记录则插入到ec_purchase_order
$sql_ins_epo = "insert into ec_purchase_order(id,date_seq,customerid,inv_customer_id,inv_customer_name,customer_name,item_no,item_name,num,unit_price,pre_tax_price,business_tax,summary_price,delivery_date,summary,contract_begin_date,contract_end_date,salesman,operator_name,enter_date,yyyymm,form_key,creater,create_at ) $sql_ins_epo = "insert into ec_purchase_order(id,date_seq,customerid,inv_customer_id,inv_customer_name,customer_name,item_no,item_name,num,unit_price,pre_tax_price,business_tax,summary_price,delivery_date,summary,contract_begin_date,contract_end_date,salesman,operator_name,enter_date,yyyymm,form_key,creater,create_at )
select id,date_seq,customerid,inv_customer_id,inv_customer_name,customer_name,item_no,item_name,num,unit_price,pre_tax_price,business_tax,summary_price,delivery_date,summary,contract_begin_date,contract_end_date,salesman,operator_name,enter_date,yyyymm,form_key,creater,create_at From select id,date_seq,customerid,inv_customer_id,inv_customer_name,customer_name,item_no,item_name,num,unit_price,pre_tax_price,business_tax,summary_price,delivery_date,summary,contract_begin_date,contract_end_date,salesman,operator_name,enter_date,yyyymm,form_key,creater,create_at From
ec_purchase_order_tmp ec_purchase_order_tmp
where form_key='" . $_POST['form_key'] . "'"; where form_key='" . $_POST['form_key'] . "'";
mysqli_query($link, $sql_ins_epo); mysqli_query($link, $sql_ins_epo);
mysqli_query($link, "delete from ec_purchase_order_tmp where form_key='" . $_POST['form_key'] . "' "); mysqli_query($link, "delete from ec_purchase_order_tmp where form_key='" . $_POST['form_key'] . "' ");
mysqli_close($link); mysqli_close($link);
} }
} }
#echo $fail_in; #echo $fail_in;
header("location: ec_purchase_order.php"); header("location: ec_purchase_order.php");
die(); die();

200
wms/equipment-create.php

@ -1,100 +1,100 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<div class="container"> <div class="container">
<?php <?php
include "equipment-record-submit.php"; include "equipment-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="category">類別</label> <label for="category">類別</label>
<input type="text" name="category" id="category"> <input type="text" name="category" id="category">
</div> </div>
<div> <div>
<label for="equipment_id">部品號</label> <label for="equipment_id">部品號</label>
<input type="text" name="equipment_id" id="equipment_id"> <input type="text" name="equipment_id" id="equipment_id">
</div> </div>
<div> <div>
<label for="equipment_name">部品名稱</label> <label for="equipment_name">部品名稱</label>
<input type="text" name="equipment_name" id="equipment_name"> <input type="text" name="equipment_name" id="equipment_name">
</div> </div>
<div> <div>
<label for="brand">廠牌</label> <label for="brand">廠牌</label>
<input type="text" name="brand" id="brand"> <input type="text" name="brand" id="brand">
</div> </div>
<div> <div>
<label for="spec">規格</label> <label for="spec">規格</label>
<input type="text" name="spec" id="spec" > <input type="text" name="spec" id="spec" >
</div> </div>
<div> <div>
<label for="count_type">計量單位</label> <label for="count_type">計量單位</label>
<input type="text" name="count_type" id="count_type" > <input type="text" name="count_type" id="count_type" >
</div> </div>
<div> <div>
<label for="inventory">庫存數</label> <label for="inventory">庫存數</label>
<input type="text" name="inventory" id="inventory" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="inventory" id="inventory" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="list_price">牌價</label> <label for="list_price">牌價</label>
<input type="text" name="list_price" id="list_price"> <input type="text" name="list_price" id="list_price">
</div> </div>
<div> <div>
<label for="discount">折扣</label> <label for="discount">折扣</label>
<input type="text" name="discount" id="discount" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="discount" id="discount" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="final_price">最後售價</label> <label for="final_price">最後售價</label>
<input type="text" name="final_price" id="final_price" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="final_price" id="final_price" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at"> <input type="hidden" name="create_at" id="create_at">
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<label for="fileToUpload">上傳圖片</label> <label for="fileToUpload">上傳圖片</label>
<div> <div>
<input type="file" name="fileToUpload" id="fileToUpload"> <input type="file" name="fileToUpload" id="fileToUpload">
</div> </div>
</div> </div>
<p> <p>
<div> <div>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

22
wms/equipment-delete.php

@ -1,12 +1,12 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM equipment WHERE id='$id'"; $db_query = "DELETE FROM equipment WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("Refresh:0; url=equipment-index.php?function_name=equipment&".$token_link); header("Refresh:0; url=equipment-index.php?function_name=equipment&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

226
wms/equipment-edit.php

@ -1,113 +1,113 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM equipment WHERE id=$id"; $db_query = "SELECT * FROM equipment WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/record_update.php"; include "inc/record_update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="equipment-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="equipment-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="category">類別</label> <label for="category">類別</label>
<input type="text" name="category" id="category" value="<?php echo $data['category']; ?>"> <input type="text" name="category" id="category" value="<?php echo $data['category']; ?>">
</div> </div>
<div> <div>
<label for="equipment_id">部品號</label> <label for="equipment_id">部品號</label>
<input type="text" name="equipment_id" id="equipment_id" value="<?php echo $data['equipment_id']; ?>"> <input type="text" name="equipment_id" id="equipment_id" value="<?php echo $data['equipment_id']; ?>">
</div> </div>
<div> <div>
<label for="equipment_name">部品名稱</label> <label for="equipment_name">部品名稱</label>
<input type="text" name="equipment_name" id="equipment_name" value="<?php echo $data['equipment_name']; ?>"> <input type="text" name="equipment_name" id="equipment_name" value="<?php echo $data['equipment_name']; ?>">
</div> </div>
<div> <div>
<label for="brand">廠牌</label> <label for="brand">廠牌</label>
<input type="text" name="brand" id="brand" value="<?php echo $data['brand']; ?>"> <input type="text" name="brand" id="brand" value="<?php echo $data['brand']; ?>">
</div> </div>
<div> <div>
<label for="spec">規格</label> <label for="spec">規格</label>
<input type="text" name="spec" id="spec" value="<?php echo $data['spec']; ?>"> <input type="text" name="spec" id="spec" value="<?php echo $data['spec']; ?>">
</div> </div>
<div> <div>
<label for="count_type">計量單位</label> <label for="count_type">計量單位</label>
<input type="text" name="count_type" id="count_type" value="<?php echo $data['count_type']; ?>"> <input type="text" name="count_type" id="count_type" value="<?php echo $data['count_type']; ?>">
</div> </div>
<div> <div>
<label for="inventory">庫存數</label> <label for="inventory">庫存數</label>
<input type="text" name="inventory" id="inventory" value="<?php echo $data['inventory']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="inventory" id="inventory" value="<?php echo $data['inventory']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="list_price">牌價</label> <label for="list_price">牌價</label>
<input type="text" name="list_price" id="list_price" value="<?php echo $data['list_price']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="list_price" id="list_price" value="<?php echo $data['list_price']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="discount">折扣</label> <label for="discount">折扣</label>
<input type="text" name="discount" id="discount" value="<?php echo $data['discount']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="discount" id="discount" value="<?php echo $data['discount']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="final_price">最後售價</label> <label for="final_price">最後售價</label>
<input type="text" name="final_price" id="final_price" value="<?php echo $data['final_price']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required> <input type="text" name="final_price" id="final_price" value="<?php echo $data['final_price']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<label for="create_at">圖片</label> <label for="create_at">圖片</label>
<a><?php echo $data['picture']; ?></a> <a><?php echo $data['picture']; ?></a>
<img width="125px" src="<?php echo $data['picture']?>" alt="" class="index-image"> <img width="125px" src="<?php echo $data['picture']?>" alt="" class="index-image">
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<input type="file" name="fileToUpload" id="fileToUpload"> <input type="file" name="fileToUpload" id="fileToUpload">
</div> </div>
<div> <div>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

300
wms/equipment-index.php

@ -1,151 +1,151 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id); $sql_cmd = sql_myself($user_id);
$sql = "SELECT * FROM equipment $sql_cmd ORDER BY id"; $sql = "SELECT * FROM equipment $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<p> <p>
<a href="equipment-create.php?function_name=equipment&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="equipment-create.php?function_name=equipment&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:equipment-index.php"); header("Location:equipment-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <tr>
<th>項次</th> <th>項次</th>
<th>類別</th> <th>類別</th>
<th>部品號</th> <th>部品號</th>
<th>部品名稱</th> <th>部品名稱</th>
<th class="width_style_1" >照片</th> <th class="width_style_1" >照片</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>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<th>修改</th> <th>修改</th>
<th>刪除</th> <th>刪除</th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['category']; ?></td> <td><?php echo $data['category']; ?></td>
<td><?php echo $data['equipment_id']; ?></td> <td><?php echo $data['equipment_id']; ?></td>
<td><?php echo $data['equipment_name']; ?></td> <td><?php echo $data['equipment_name']; ?></td>
<td class="width_style_1"><img src="<?php echo $data['picture']; ?>" alt="" class="index-image"></td> <td class="width_style_1"><img src="<?php echo $data['picture']; ?>" alt="" class="index-image"></td>
<td><?php echo $data['brand']; ?></td> <td><?php echo $data['brand']; ?></td>
<td><?php echo $data['spec']; ?></td> <td><?php echo $data['spec']; ?></td>
<td><?php echo $data['count_type']; ?></td> <td><?php echo $data['count_type']; ?></td>
<td><?php echo $data['inventory']; ?></td> <td><?php echo $data['inventory']; ?></td>
<td><?php echo $data['list_price']; ?></td> <td><?php echo $data['list_price']; ?></td>
<td><?php echo $data['discount']; ?></td> <td><?php echo $data['discount']; ?></td>
<td><?php echo $data['final_price']; ?></td> <td><?php echo $data['final_price']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<td> <td>
<p> <p>
<a href="equipment-edit.php?id=<?php echo $data['id']; ?>&function_name=equipment&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="equipment-edit.php?id=<?php echo $data['id']; ?>&function_name=equipment&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<td> <td>
<p> <p>
<a href="equipment-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?')"> <a href="equipment-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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td> </td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

244
wms/equipment-record-submit.php

@ -1,123 +1,123 @@
<?php <?php
$category= ""; $category= "";
$equipment_id= ""; $equipment_id= "";
$equipment_name= ""; $equipment_name= "";
$brand= ""; $brand= "";
$spec= ""; $spec= "";
$count_type= ""; $count_type= "";
$inventory= ""; $inventory= "";
$list_price= ""; $list_price= "";
$discount= ""; $discount= "";
$final_price= ""; $final_price= "";
$creater= ""; $creater= "";
$create_at= ""; $create_at= "";
$fileToUpload = ""; $fileToUpload = "";
$category_error= ""; $category_error= "";
$equipment_id_error= ""; $equipment_id_error= "";
$equipment_name_error= ""; $equipment_name_error= "";
$brand_error= ""; $brand_error= "";
$spec_error= ""; $spec_error= "";
$count_type_error= ""; $count_type_error= "";
$inventory_error= ""; $inventory_error= "";
$list_price_error= ""; $list_price_error= "";
$discount_error= ""; $discount_error= "";
$final_price_error= ""; $final_price_error= "";
$creater_error = ""; $creater_error = "";
$create_at_error = ""; $create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
include "equipment-user-input.php"; include "equipment-user-input.php";
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$file_size = $_FILES["fileToUpload"]["size"]; $file_size = $_FILES["fileToUpload"]["size"];
$target_dir = "equipment-uploads/"; $target_dir = "equipment-uploads/";
$target_file = strtolower($target_dir . basename($file_name)); $target_file = strtolower($target_dir . basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file, PATHINFO_EXTENSION);
#$db_query = "INSERT INTO equipment(equipment_id, equipment_name, brand,spec, count_type,inventory,list_price,discount,final_price,picture,creater, create_at) VALUES ('$equipment_id', '$equipment_name', '$brand','$spec', '$count_type','$inventory','$list_price','$discount','$final_price','$target_file','$creater', '$create_at')"; #$db_query = "INSERT INTO equipment(equipment_id, equipment_name, brand,spec, count_type,inventory,list_price,discount,final_price,picture,creater, create_at) VALUES ('$equipment_id', '$equipment_name', '$brand','$spec', '$count_type','$inventory','$list_price','$discount','$final_price','$target_file','$creater', '$create_at')";
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$file_size = $_FILES["fileToUpload"]["size"]; $file_size = $_FILES["fileToUpload"]["size"];
$target_dir = "equipment-uploads/"; $target_dir = "equipment-uploads/";
$target_file = strtolower($target_dir . basename($file_name)); $target_file = strtolower($target_dir . basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file, PATHINFO_EXTENSION);
//Check if image is an actual image or fake image //Check if image is an actual image or fake image
if(strlen($target_file) <= strlen("equipment-uploads/")){ if(strlen($target_file) <= strlen("equipment-uploads/")){
$db_query = "INSERT INTO equipment(equipment_id, equipment_name, brand,spec, count_type,inventory,list_price,discount,final_price, creater, create_at) VALUES ('$equipment_id', '$equipment_name', '$brand','$spec', '$count_type','$inventory','$list_price','$discount','$final_price', '$creater', '$create_at')"; $db_query = "INSERT INTO equipment(equipment_id, equipment_name, brand,spec, count_type,inventory,list_price,discount,final_price, creater, create_at) VALUES ('$equipment_id', '$equipment_name', '$brand','$spec', '$count_type','$inventory','$list_price','$discount','$final_price', '$creater', '$create_at')";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$result = mysqli_query($link,$db_query); $result = mysqli_query($link,$db_query);
#echo $result; #echo $result;
}else { }else {
$check_img = getimagesize($temp_file_name); $check_img = getimagesize($temp_file_name);
if($check_img == false) { if($check_img == false) {
echo "<font color='#FF0000'>File is not an image</font>"; echo "<font color='#FF0000'>File is not an image</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//echo "File is an image - " . $check_img["mime"]; //echo "File is an image - " . $check_img["mime"];
$upload_ok = 1; $upload_ok = 1;
//Check if file already exists //Check if file already exists
if(file_exists($target_file)) { if(file_exists($target_file)) {
echo "<font color='#FF0000'>File is already uploaded!</font>"; echo "<font color='#FF0000'>File is already uploaded!</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Check file size //Check file size
if($file_size > 500000) { if($file_size > 500000) {
echo "<font color='#FF0000'>Please enter a file size between 5mb</font>"; echo "<font color='#FF0000'>Please enter a file size between 5mb</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Allow certain file formats //Allow certain file formats
if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") { if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") {
echo "<font color='#FF0000'>JPG, PNG, JPEG and GIF files are allowed</font>"; echo "<font color='#FF0000'>JPG, PNG, JPEG and GIF files are allowed</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Check if $upload_ok is set to 0 by an error //Check if $upload_ok is set to 0 by an error
if($upload_ok === 0) { if($upload_ok === 0) {
echo "<font color='#FF0000'>File has not been uploaded</font>"; echo "<font color='#FF0000'>File has not been uploaded</font>";
} else { } else {
if(move_uploaded_file($temp_file_name, $target_file)){ if(move_uploaded_file($temp_file_name, $target_file)){
// sql語法存在變數中 // sql語法存在變數中
// $db_query = "INSERT INTO expert (id, expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater, create_at) VALUE (`$id`, `$expert_id`, `$personal_id`, `$name`, `$title`, `$target_file`, `$major`, `$tel`, `$tel_count`, `$chat_id`, `$chat_count`, `$video_call`, `$video_count`, `$onsite_call`, `$onsite_count`, `$creater`, `$create_at`)"; // $db_query = "INSERT INTO expert (id, expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater, create_at) VALUE (`$id`, `$expert_id`, `$personal_id`, `$name`, `$title`, `$target_file`, `$major`, `$tel`, `$tel_count`, `$chat_id`, `$chat_count`, `$video_call`, `$video_count`, `$onsite_call`, `$onsite_count`, `$creater`, `$create_at`)";
$db_query = "INSERT INTO equipment(equipment_id, equipment_name, brand,spec, count_type,inventory,list_price,discount,final_price,picture,creater, create_at) VALUES ('$equipment_id', '$equipment_name', '$brand','$spec', '$count_type','$inventory','$list_price','$discount','$final_price','$target_file','$creater', '$create_at')"; $db_query = "INSERT INTO equipment(equipment_id, equipment_name, brand,spec, count_type,inventory,list_price,discount,final_price,picture,creater, create_at) VALUES ('$equipment_id', '$equipment_name', '$brand','$spec', '$count_type','$inventory','$list_price','$discount','$final_price','$target_file','$creater', '$create_at')";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$result = mysqli_query($link,$db_query); $result = mysqli_query($link,$db_query);
} }
} }
} }
} }
} }
} }
} }
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');"; echo "alert('新增成功');";
echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';"; echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';"; echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

158
wms/equipment-record-update.php

@ -1,80 +1,80 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$id = $_POST['id']; $id = $_POST['id'];
$category = $_POST['categoryd']; $category = $_POST['categoryd'];
$equipment_id = user_input($_POST["equipment_id"]); $equipment_id = user_input($_POST["equipment_id"]);
$equipment_name = user_input($_POST["equipment_name"]); $equipment_name = user_input($_POST["equipment_name"]);
$brand = user_input($_POST["brand"]); $brand = user_input($_POST["brand"]);
$spec = user_input($_POST["spec"]); $spec = user_input($_POST["spec"]);
$count_type = user_input($_POST["count_type"]); $count_type = user_input($_POST["count_type"]);
$inventory = user_input($_POST["inventory"]); $inventory = user_input($_POST["inventory"]);
$list_price = user_input($_POST["list_price"]); $list_price = user_input($_POST["list_price"]);
$discount = user_input($_POST["discount"]); $discount = user_input($_POST["discount"]);
$final_price = user_input($_POST["final_price"]); $final_price = user_input($_POST["final_price"]);
$picture = user_input($_POST["picture"]); $picture = user_input($_POST["picture"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$file_size = $_FILES["fileToUpload"]["size"]; $file_size = $_FILES["fileToUpload"]["size"];
$target_dir = "equipment-uploads/"; $target_dir = "equipment-uploads/";
$target_file = strtolower($target_dir . basename($file_name)); $target_file = strtolower($target_dir . basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file, PATHINFO_EXTENSION);
if(strlen($target_file) <= strlen("equipment-uploads/")){ if(strlen($target_file) <= strlen("equipment-uploads/")){
$db_query = "UPDATE equipment set category = '$category', equipment_id = '$equipment_id', equipment_name = '$equipment_name', brand = '$brand', spec = '$spec', count_type = '$count_type',inventory = '$inventory',list_price = '$list_price',discount = '$discount',final_price = '$final_price',create_at = '$create_at' WHERE id='$id'"; $db_query = "UPDATE equipment set category = '$category', equipment_id = '$equipment_id', equipment_name = '$equipment_name', brand = '$brand', spec = '$spec', count_type = '$count_type',inventory = '$inventory',list_price = '$list_price',discount = '$discount',final_price = '$final_price',create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
}else { }else {
if($file_size > 500000) { if($file_size > 500000) {
echo "<font color='#FF0000'>Please enter a file size between 5mb</font>"; echo "<font color='#FF0000'>Please enter a file size between 5mb</font>";
$upload_ok = 0; $upload_ok = 0;
} else { // } else { //
//Allow certain file formats //Allow certain file formats
if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") { if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") {
//echo "JPG, PNG, JPEG and GIF files are allowed"; //echo "JPG, PNG, JPEG and GIF files are allowed";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Check if $upload_ok is set to 0 by an error //Check if $upload_ok is set to 0 by an error
if($upload_ok === 0) { if($upload_ok === 0) {
echo "<font color='#FF0000'>File has not been uploaded</font>"; echo "<font color='#FF0000'>File has not been uploaded</font>";
} else { } else {
if(move_uploaded_file($temp_file_name, $target_file)){ if(move_uploaded_file($temp_file_name, $target_file)){
$db_query = "UPDATE equipment set category = '$category', equipment_id = '$equipment_id', equipment_name = '$equipment_name', brand = '$brand', spec = '$spec', count_type = '$count_type',inventory = '$inventory',list_price = '$list_price',discount = '$discount',final_price = '$final_price',picture = '$target_file',create_at = '$create_at' WHERE id='$id'"; $db_query = "UPDATE equipment set category = '$category', equipment_id = '$equipment_id', equipment_name = '$equipment_name', brand = '$brand', spec = '$spec', count_type = '$count_type',inventory = '$inventory',list_price = '$list_price',discount = '$discount',final_price = '$final_price',picture = '$target_file',create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("location: equipment-index.php"); header("location: equipment-index.php");
} }
} }
} }
} }
} }
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';"; echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';"; echo "location.href='equipment-index.php?function_name=equipment&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

114
wms/equipment-user-input.php

@ -1,57 +1,57 @@
<?php <?php
//Function to filter the form input //Function to filter the form input
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$category = user_input($_POST["category"]); $category = user_input($_POST["category"]);
$equipment_id = user_input($_POST["equipment_id"]); $equipment_id = user_input($_POST["equipment_id"]);
$equipment_name = user_input($_POST["equipment_name"]); $equipment_name = user_input($_POST["equipment_name"]);
$brand = user_input($_POST["brand"]); $brand = user_input($_POST["brand"]);
$spec = user_input($_POST["spec"]); $spec = user_input($_POST["spec"]);
$count_type = user_input($_POST["count_type"]); $count_type = user_input($_POST["count_type"]);
$inventory = user_input($_POST["inventory"]); $inventory = user_input($_POST["inventory"]);
$list_price = user_input($_POST["list_price"]); $list_price = user_input($_POST["list_price"]);
$discount = user_input($_POST["discount"]); $discount = user_input($_POST["discount"]);
$final_price = user_input($_POST["final_price"]); $final_price = user_input($_POST["final_price"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
/* /*
if(empty($_POST["name"])) { if(empty($_POST["name"])) {
$name_error = "Name is required"; $name_error = "Name is required";
} else { } else {
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed"; $name_error = "Only letter and white space are allowed";
} }
} }
/* /*
if(empty($_POST["website"])) { if(empty($_POST["website"])) {
$website_error = "Website address is required"; $website_error = "Website address is required";
} else { } else {
$website = user_input($_POST["website"]); $website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL"; $website_error = "Invalid website URL";
} }
} }
if(empty($_POST["comment"])) { if(empty($_POST["comment"])) {
$comment = ""; $comment = "";
} else { } else {
$comment = user_input($_POST["comment"]); $comment = user_input($_POST["comment"]);
} }
*/ */
?> ?>

2676
wms/estimated_shipping_date_report.php

File diff suppressed because it is too large

488
wms/excel-upload.php

@ -1,244 +1,244 @@
<?php <?php
include "header.php"; include "header.php";
require_once 'PHPExcel/PHPExcel.php'; require_once 'PHPExcel/PHPExcel.php';
require_once 'PHPExcel/IOFactory.php'; require_once 'PHPExcel/IOFactory.php';
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$target_dir = "excel-uploads/"; $target_dir = "excel-uploads/";
$target_file = strtolower($target_dir . iconv("UTF-8", "big5",basename($file_name))); $target_file = strtolower($target_dir . iconv("UTF-8", "big5",basename($file_name)));
$EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION); $EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION);
if (move_uploaded_file($temp_file_name, $target_file)) { if (move_uploaded_file($temp_file_name, $target_file)) {
if ($EXTENSION == 'xls') { if ($EXTENSION == 'xls') {
$objReader = PHPExcel_IOFactory::createReader('Excel5');//支持xls $objReader = PHPExcel_IOFactory::createReader('Excel5');//支持xls
} else { } else {
$objReader = PHPExcel_IOFactory::createReader('Excel2007');//支持xlsx $objReader = PHPExcel_IOFactory::createReader('Excel2007');//支持xlsx
} }
$objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件 $objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件
$sheet = $objPHPExcel->getSheet(0);//拿到第一个sheet数据 $sheet = $objPHPExcel->getSheet(0);//拿到第一个sheet数据
$highestRow = $sheet->getHighestRow(); // 取得总行数 $highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数 $highestColumn = $sheet->getHighestColumn(); // 取得总列数
$highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字; $highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字;
$excelArray = array(); $excelArray = array();
for ($row = 2; $row <= $highestRow; $row++) { for ($row = 2; $row <= $highestRow; $row++) {
$val = $sheet->getCellByColumnAndRow(0, $row)->getCalculatedValue(); $val = $sheet->getCellByColumnAndRow(0, $row)->getCalculatedValue();
if ($val == "") return; if ($val == "") return;
for ($column = 1; $column < $highestColumn; $column++) { for ($column = 1; $column < $highestColumn; $column++) {
$val = $sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue(); $val = $sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue();
$excelArray[$row][] = $val; //读取excel数据到数组 $excelArray[$row][] = $val; //读取excel数据到数组
} }
/* /*
( (
[2] => Array [2] => Array
( (
[0] => M230875 [0] => M230875
[1] => 3TX23001 [1] => 3TX23001
[2] => 桃園市中壢區榮民南路81巷8號 [2] => 桃園市中壢區榮民南路81巷8號
[3] => 121.25820796563 [3] => 121.25820796563
[4] => 24.955059621474 [4] => 24.955059621474
[5] => 梁智芳 [5] => 梁智芳
[6] => [6] =>
[7] => 921389826 [7] => 921389826
[8] => M0089 [8] => M0089
[9] => 郭玠德 [9] => 郭玠德
[10] => 0905-378-991 [10] => 0905-378-991
[11] => 2023/07/14 [11] => 2023/07/14
[12] => BW002 [12] => BW002
[13] => [13] =>
[14] => 45108 [14] => 45108
[15] => 45473 [15] => 45473
[16] => [16] =>
) )
)*/ )*/
//print_r($excelArray);exit; //print_r($excelArray);exit;
echo "第".$row; echo "第".$row;
// excel欄位名稱 // excel欄位名稱
list($contractno, $facilityno, $address, $longitude, $latitude, $name, $customerid, $tel, $repairerid, $repairer_name, $repairer_tel, $duedate, $combono, $receivable_date, $c_start_date, $c_end_date) = $excelArray[$row]; list($contractno, $facilityno, $address, $longitude, $latitude, $name, $customerid, $tel, $repairerid, $repairer_name, $repairer_tel, $duedate, $combono, $receivable_date, $c_start_date, $c_end_date) = $excelArray[$row];
$customerid = (!$customerid) ? $contractno : $customerid; $customerid = (!$customerid) ? $contractno : $customerid;
$repairer_tel = str_pad(str_replace("-", "", $repairer_tel), 10, "0", STR_PAD_LEFT); // 保養員手机号 $repairer_tel = str_pad(str_replace("-", "", $repairer_tel), 10, "0", STR_PAD_LEFT); // 保養員手机号
$combono = substr($combono,-5);//套餐编码 $combono = substr($combono,-5);//套餐编码
$area = mb_substr($address, 0, 3); $area = mb_substr($address, 0, 3);
if (is_numeric($duedate)) $duedate = date("Y-m-d", ($duedate-25569)*24*60*60); // 預保養日 if (is_numeric($duedate)) $duedate = date("Y-m-d", ($duedate-25569)*24*60*60); // 預保養日
if (is_numeric($c_start_date)) $c_start_date = date("Y-m-d", ($c_start_date-25569)*24*60*60); // 合約起始日 if (is_numeric($c_start_date)) $c_start_date = date("Y-m-d", ($c_start_date-25569)*24*60*60); // 合約起始日
if (is_numeric($c_end_date)) $c_end_date = date("Y-m-d", ($c_end_date-25569)*24*60*60); // 合約終止日 if (is_numeric($c_end_date)) $c_end_date = date("Y-m-d", ($c_end_date-25569)*24*60*60); // 合約終止日
// 创建客户信息 // 创建客户信息
$accountid= $contractno; //账户id $accountid= $contractno; //账户id
//判断账户是否存在 //判断账户是否存在
$sql = "select * from account where accountid = '$accountid'"; $sql = "select * from account where accountid = '$accountid'";
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
$nums_rows = mysqli_num_rows($data); $nums_rows = mysqli_num_rows($data);
if($nums_rows==0){ if($nums_rows==0){
//添加用户 //添加用户
$accounttype = "A"; //账户类型 $accounttype = "A"; //账户类型
$pwd = "123";//账户默认密码 $pwd = "123";//账户默认密码
//查询保养员电话 //查询保养员电话
$sqlfre = "SELECT name, tel FROM account where accountid = '$repairerid' and accounttype = 'B'"; $sqlfre = "SELECT name, tel FROM account where accountid = '$repairerid' and accounttype = 'B'";
$repairerdata = mysqli_query($link, $sqlfre); # 用mysqli_query方法执行(sql语法)将结果存在变数中 $repairerdata = mysqli_query($link, $sqlfre); # 用mysqli_query方法执行(sql语法)将结果存在变数中
if ($rowdata = mysqli_fetch_assoc($repairerdata)) { if ($rowdata = mysqli_fetch_assoc($repairerdata)) {
$db_repair_name = $rowdata['name']; $db_repair_name = $rowdata['name'];
$db_repair_tel = $rowdata['tel']; $db_repair_tel = $rowdata['tel'];
} }
mysqli_free_result($repairerdata); mysqli_free_result($repairerdata);
if ($db_repair_name == $repairer_name && (str_pad(str_replace("-", "", $db_repair_tel), 10, "0", STR_PAD_LEFT)) == $repairer_tel) { if ($db_repair_name == $repairer_name && (str_pad(str_replace("-", "", $db_repair_tel), 10, "0", STR_PAD_LEFT)) == $repairer_tel) {
$create_at = date('Y/m/d H:i:s');//账户创建时间 $create_at = date('Y/m/d H:i:s');//账户创建时间
$db_query1 = "insert into account(accounttype, accountid, pwd, name, tel, address,phone_call_help, repairerid, creater, create_at) values ("; $db_query1 = "insert into account(accounttype, accountid, pwd, name, tel, address,phone_call_help, repairerid, creater, create_at) values (";
$db_query1 .= "'$accounttype', '$accountid', '$pwd', '$name', '$tel', '$address', '$repairer_tel', '$repairerid','$user_id', '$create_at')"; $db_query1 .= "'$accounttype', '$accountid', '$pwd', '$name', '$tel', '$address', '$repairer_tel', '$repairerid','$user_id', '$create_at')";
mysqli_query($link,$db_query1); mysqli_query($link,$db_query1);
if (mysqli_affected_rows($link) > 0) { if (mysqli_affected_rows($link) > 0) {
echo "客户账户新增成功\r\n"; echo "客户账户新增成功\r\n";
$repair_right = 1; $repair_right = 1;
} }
elseif(mysqli_affected_rows($link)==0) { elseif(mysqli_affected_rows($link)==0) {
echo "无新增资料"; echo "无新增资料";
} }
} else { } else {
echo "保養員姓名或電話有誤"; echo "保養員姓名或電話有誤";
} }
} else { } else {
echo "账户已经存在"; echo "账户已经存在";
$repair_right = 1; $repair_right = 1;
} }
if ($repair_right) { if ($repair_right) {
//创建合约信息 //创建合约信息
//判断合约是否存在 //判断合约是否存在
$contractsql = "select * from contract where contractno = '$contractno'"; $contractsql = "select * from contract where contractno = '$contractno'";
$contract_nums_rows=mysqli_num_rows(mysqli_query($link,$contractsql)); $contract_nums_rows=mysqli_num_rows(mysqli_query($link,$contractsql));
if($contract_nums_rows==0){ if($contract_nums_rows==0){
$contracttype= "A"; $contracttype= "A";
$company= $name;//公司名称默认客户姓名 $company= $name;//公司名称默认客户姓名
$taxid= " ";//统一编码 $taxid= " ";//统一编码
$promiser= $name;//契约人,个人客户默认客户姓名 $promiser= $name;//契约人,个人客户默认客户姓名
$contractperson= $name;//联系人 $contractperson= $name;//联系人
$contractaddress= $address;//联系地址 $contractaddress= $address;//联系地址
$contracttel= $tel;//联络电话 $contracttel= $tel;//联络电话
$contractemail= ""; $contractemail= "";
$contract_employee= "";//契约员工号 $contract_employee= "";//契约员工号
$create_at = date('Y/m/d H:i:s');//合同创建时间 $create_at = date('Y/m/d H:i:s');//合同创建时间
$db_query2 = "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','$c_start_date','$c_end_date', '$user_id', '$create_at')"; $db_query2 = "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','$c_start_date','$c_end_date', '$user_id', '$create_at')";
mysqli_query($link,$db_query2); mysqli_query($link,$db_query2);
if (mysqli_affected_rows($link)>0) { if (mysqli_affected_rows($link)>0) {
echo "合约新增成功\r\n"; echo "合约新增成功\r\n";
} }
elseif(mysqli_affected_rows($link)==0) { elseif(mysqli_affected_rows($link)==0) {
echo "无新增资料"; echo "无新增资料";
} }
}else{ }else{
echo "合约已经存在"; echo "合约已经存在";
} }
//创建作番信息 //创建作番信息
switch ($facilityno) { switch ($facilityno) {
case (preg_match('/TX/', $facilityno) ? true : false): case (preg_match('/TX/', $facilityno) ? true : false):
case (preg_match('/JX/', $facilityno) ? true : false): case (preg_match('/JX/', $facilityno) ? true : false):
$facility_kind = "MAE100"; $facility_kind = "MAE100";
break; break;
case (preg_match('/TW/', $facilityno) ? true : false): case (preg_match('/TW/', $facilityno) ? true : false):
$facility_kind = "MAM200"; $facility_kind = "MAM200";
break; break;
case (preg_match('/TH/', $facilityno) ? true : false): case (preg_match('/TH/', $facilityno) ? true : false):
$facility_kind = "MAH100"; $facility_kind = "MAH100";
break; break;
case (preg_match('/TZ/', $facilityno) ? true : false): case (preg_match('/TZ/', $facilityno) ? true : false):
$facility_kind = "MAZ100"; $facility_kind = "MAZ100";
break; break;
case (preg_match('/TH/', $facilityno) ? true : false): case (preg_match('/TH/', $facilityno) ? true : false):
$facility_kind = "MAQ100"; $facility_kind = "MAQ100";
break; break;
default: default:
$facility_kind = ""; $facility_kind = "";
} }
$facilitsql = "SELECT * FROM facility where facilityno='$facilityno' and contractno='$contractno'"; $facilitsql = "SELECT * FROM facility where facilityno='$facilityno' and contractno='$contractno'";
$facilit_nums_rows=mysqli_num_rows(mysqli_query($link,$facilitsql)); $facilit_nums_rows=mysqli_num_rows(mysqli_query($link,$facilitsql));
if($facilit_nums_rows==0){ if($facilit_nums_rows==0){
$weight= "450";//重量 $weight= "450";//重量
$numberofpassenger = "6"; // 人乘 $numberofpassenger = "6"; // 人乘
$numberofstop= "2";//停数 $numberofstop= "2";//停数
$numberoffloor= "2";//楼层数 $numberoffloor= "2";//楼层数
$opentype= "CO-SO";//开门方式 $opentype= "CO-SO";//开门方式
$speed= "60";//速度 $speed= "60";//速度
$repairtype= "A";//维护类型 $repairtype= "A";//维护类型
$create_at = date('Y/m/d H:i:s');//作番创建时间 $create_at = date('Y/m/d H:i:s');//作番创建时间
$db_query3 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofpassenger,numberofstop, numberoffloor,opentype,speed,repairtype,facility_kind,longitude, latitude, address,repairerid,repairername,area,creater, create_at) VALUES ('$contractno', '$facilityno', '$customerid', '$weight','$numberofpassenger','$numberofstop', '$numberoffloor','$opentype','$speed','$repairtype','$facility_kind','$longitude', '$latitude', '$address','$repairerid','$repairer_name','$area','$user_id', '$create_at')"; $db_query3 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofpassenger,numberofstop, numberoffloor,opentype,speed,repairtype,facility_kind,longitude, latitude, address,repairerid,repairername,area,creater, create_at) VALUES ('$contractno', '$facilityno', '$customerid', '$weight','$numberofpassenger','$numberofstop', '$numberoffloor','$opentype','$speed','$repairtype','$facility_kind','$longitude', '$latitude', '$address','$repairerid','$repairer_name','$area','$user_id', '$create_at')";
mysqli_query($link,$db_query3); mysqli_query($link,$db_query3);
if (mysqli_affected_rows($link)>0) { if (mysqli_affected_rows($link)>0) {
echo "作番新增成功\n"; echo "作番新增成功\n";
} }
elseif(mysqli_affected_rows($link)==0) { elseif(mysqli_affected_rows($link)==0) {
echo "无新增资料"; echo "无新增资料";
} }
}else{ }else{
echo "作番已经存在"; echo "作番已经存在";
} }
//创建保养计划 //创建保养计划
echo "保养日期"; echo "保养日期";
$schedulesql = "SELECT * FROM schedule where facilityno='$facilityno' and duedate='$duedate'"; $schedulesql = "SELECT * FROM schedule where facilityno='$facilityno' and duedate='$duedate'";
$schedule_nums_rows=mysqli_num_rows(mysqli_query($link,$schedulesql)); $schedule_nums_rows=mysqli_num_rows(mysqli_query($link,$schedulesql));
if($schedule_nums_rows==0){ if($schedule_nums_rows==0){
$create_at = date('Y/m/d H:i:s');//作番创建时间 $create_at = date('Y/m/d H:i:s');//作番创建时间
$db_query4 = "INSERT INTO schedule(contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES ('$contractno', '$facilityno', '$combono', '$repairerid', '$repairer_name', '$duedate', '$user_id', '$create_at')"; $db_query4 = "INSERT INTO schedule(contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES ('$contractno', '$facilityno', '$combono', '$repairerid', '$repairer_name', '$duedate', '$user_id', '$create_at')";
$resiult=mysqli_query($link,$db_query4); $resiult=mysqli_query($link,$db_query4);
if (mysqli_affected_rows($link)>0) { if (mysqli_affected_rows($link)>0) {
echo $combono."作番保养计划新增成功\r\n"; echo $combono."作番保养计划新增成功\r\n";
} }
elseif(mysqli_affected_rows($link)==0) { elseif(mysqli_affected_rows($link)==0) {
echo "无新增资料"; echo "无新增资料";
} }
}else{ }else{
echo "作番保养计划已经存在"; echo "作番保养计划已经存在";
} }
} }
} }
mysqli_close($link); mysqli_close($link);
} }
//for ($i = 0; $i <= sizeof($excelArray); $i++) { //for ($i = 0; $i <= sizeof($excelArray); $i++) {
// //处理数据 // //处理数据
//// 创建客户信息 //// 创建客户信息
// echo "循环读取数据插入数据库---".$row."---"; // echo "循环读取数据插入数据库---".$row."---";
// echo$accounttype= "A"; //账户类型 // echo$accounttype= "A"; //账户类型
// echo$accountid= $excelArray[$row][6]; //账户id // echo$accountid= $excelArray[$row][6]; //账户id
// echo$pwd= "123";//账户默认密码 // echo$pwd= "123";//账户默认密码
// echo$name= $excelArray[$row][5];//账户姓名 // echo$name= $excelArray[$row][5];//账户姓名
// echo$address= $excelArray[$row][2];//账户地址 // echo$address= $excelArray[$row][2];//账户地址
// echo$phone_call_help=$excelArray[$row][7];//联络手机号 // echo$phone_call_help=$excelArray[$row][7];//联络手机号
// echo$repairerid=$excelArray[$row][8];//服务与支持人员工号 // echo$repairerid=$excelArray[$row][8];//服务与支持人员工号
// echo$creater = 'vensen';//建档人 // echo$creater = 'vensen';//建档人
// echo$create_at = date('Y/m/d H:i:s');//账户创建时间 // echo$create_at = date('Y/m/d H:i:s');//账户创建时间
////判断账户是否存在 ////判断账户是否存在
// $sqlselect='select * from account where accountid='.$accountid; // $sqlselect='select * from account where accountid='.$accountid;
// $res = mysqli_query($link,$sqlselect); // $res = mysqli_query($link,$sqlselect);
// echo "------结果".'<br>'; // echo "------结果".'<br>';
// print_r($res); // print_r($res);
// //
// echo "------".'<br>'; // echo "------".'<br>';
//} //}
// //
// var_dump($excelArray); // var_dump($excelArray);
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"
enctype="multipart/form-data"> enctype="multipart/form-data">
<div class="bottom-margin">資料 <div class="bottom-margin">資料
<label for="fileToUpload">上傳</label> <label for="fileToUpload">上傳</label>
<div> <div>
<input type="file" name="fileToUpload" id="fileToUpload"> <input type="file" name="fileToUpload" id="fileToUpload">
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
</div> </div>
<input type="hidden" name="token" value="<?php echo $_GET['token']; ?>"> <input type="hidden" name="token" value="<?php echo $_GET['token']; ?>">
</form> </form>
</div> </div>

262
wms/expert-create.php

@ -1,131 +1,131 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<div class="container"> <div class="container">
<?php <?php
include "expert-record-submit.php"; include "expert-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="expert_id">專家ID</label> <label for="expert_id">專家ID</label>
<input type="text" name="expert_id" id="expert_id" placeholder="請輸入專家ID..." required> <input type="text" name="expert_id" id="expert_id" placeholder="請輸入專家ID..." required>
<p class="error"><?php echo $expert_id_error; ?></p> <p class="error"><?php echo $expert_id_error; ?></p>
</div> </div>
<div> <div>
<label for="personal_id">身分證字號</label> <label for="personal_id">身分證字號</label>
<input type="text" name="personal_id" id="personal_id"> <input type="text" name="personal_id" id="personal_id">
<p class="error"><?php echo $personal_id_error; ?></p> <p class="error"><?php echo $personal_id_error; ?></p>
</div> </div>
<div> <div>
<label for="name">顯示姓名</label> <label for="name">顯示姓名</label>
<input type="text" name="name" id="name"> <input type="text" name="name" id="name">
<p class="error"><?php echo $name_error; ?></p> <p class="error"><?php echo $name_error; ?></p>
</div> </div>
<div> <div>
<label for="title">稱謂</label> <label for="title">稱謂</label>
<input type="text" name="title" id="title"> <input type="text" name="title" id="title">
<p class="error"><?php echo $title_error; ?></p> <p class="error"><?php echo $title_error; ?></p>
</div> </div>
<div> <div>
<label for="major">專長</label> <label for="major">專長</label>
<input type="text" name="major" id="major"> <input type="text" name="major" id="major">
<p class="error"><?php echo $major_error; ?></p> <p class="error"><?php echo $major_error; ?></p>
</div> </div>
<div> <div>
<label for="tel">電話</label> <label for="tel">電話</label>
<input type="text" name="tel" id="tel"> <input type="text" name="tel" id="tel">
<p class="error"><?php echo $tel_error; ?></p> <p class="error"><?php echo $tel_error; ?></p>
</div> </div>
<div> <div>
<label for="tel_count">電話支援次數</label> <label for="tel_count">電話支援次數</label>
<input type="text" name="tel_count" id="tel_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="tel_count" id="tel_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
<p class="error"><?php echo $tel_count_error; ?></p> <p class="error"><?php echo $tel_count_error; ?></p>
</div> </div>
<div> <div>
<label for="chat_id">文字客服連結</label> <label for="chat_id">文字客服連結</label>
<input type="text" name="chat_id" id="chat_id"> <input type="text" name="chat_id" id="chat_id">
<p class="error"><?php echo $chat_id_error; ?></p> <p class="error"><?php echo $chat_id_error; ?></p>
</div> </div>
<div> <div>
<label for="chat_count">文字客服次數</label> <label for="chat_count">文字客服次數</label>
<input type="text" name="chat_count" id="chat_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="chat_count" id="chat_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
<p class="error"><?php echo $chat_count_error; ?></p> <p class="error"><?php echo $chat_count_error; ?></p>
</div> </div>
<div> <div>
<label for="video_call">遠程視頻連結</label> <label for="video_call">遠程視頻連結</label>
<input type="text" name="video_call" id="video_call"> <input type="text" name="video_call" id="video_call">
<p class="error"><?php echo $video_call_error; ?></p> <p class="error"><?php echo $video_call_error; ?></p>
</div> </div>
<div> <div>
<label for="video_count">遠程視頻次數</label> <label for="video_count">遠程視頻次數</label>
<input type="text" name="video_count" id="video_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="video_count" id="video_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
<p class="error"><?php echo $video_count_error; ?></p> <p class="error"><?php echo $video_count_error; ?></p>
</div> </div>
<div> <div>
<label for="onsite_call">現場支援電話</label> <label for="onsite_call">現場支援電話</label>
<input type="text" name="onsite_call" id="onsite_call"> <input type="text" name="onsite_call" id="onsite_call">
<p class="error"><?php echo $onsite_call_error; ?></p> <p class="error"><?php echo $onsite_call_error; ?></p>
</div> </div>
<div> <div>
<label for="onsite_count">現場支援次數</label> <label for="onsite_count">現場支援次數</label>
<input type="text" name="onsite_count" id="onsite_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="onsite_count" id="onsite_count" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
<p class="error"><?php echo $onsite_count_error; ?></p> <p class="error"><?php echo $onsite_count_error; ?></p>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p> <p class="error"><?php echo $creater_error; ?></p>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <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'); ?>"> <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> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<label for="fileToUpload">上傳圖片</label> <label for="fileToUpload">上傳圖片</label>
<div> <div>
<input type="file" name="fileToUpload" id="fileToUpload"> <input type="file" name="fileToUpload" id="fileToUpload">
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

22
wms/expert-delete.php

@ -1,12 +1,12 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM expert WHERE id='$id'"; $db_query = "DELETE FROM expert WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("Refresh:0; url=expert-index.php?function_name=expert&".$token_link); header("Refresh:0; url=expert-index.php?function_name=expert&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

252
wms/expert-edit.php

@ -1,126 +1,126 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/expert-record-update.php"; include "inc/expert-record-update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="expert-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="expert-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="expert_id">專家ID</label> <label for="expert_id">專家ID</label>
<input type="text" name="expert_id" id="expert_id" value="<?php echo $data['expert_id']; ?>" required> <input type="text" name="expert_id" id="expert_id" value="<?php echo $data['expert_id']; ?>" required>
</div> </div>
<div> <div>
<label for="personal_id">身分證字號</label> <label for="personal_id">身分證字號</label>
<input type="text" name="personal_id" id="personal_id" value="<?php echo $data['personal_id']; ?>"> <input type="text" name="personal_id" id="personal_id" value="<?php echo $data['personal_id']; ?>">
</div> </div>
<div> <div>
<label for="name">顯示姓名</label> <label for="name">顯示姓名</label>
<input type="text" name="name" id="name" value="<?php echo $data['name']; ?>"> <input type="text" name="name" id="name" value="<?php echo $data['name']; ?>">
</div> </div>
<div> <div>
<label for="title">稱謂</label> <label for="title">稱謂</label>
<input type="text" name="title" id="title" value="<?php echo $data['title']; ?>"> <input type="text" name="title" id="title" value="<?php echo $data['title']; ?>">
</div> </div>
<div> <div>
<label for="major">專長</label> <label for="major">專長</label>
<input type="text" name="major" id="major" value="<?php echo $data['major']; ?>"> <input type="text" name="major" id="major" value="<?php echo $data['major']; ?>">
</div> </div>
<div> <div>
<label for="tel">電話</label> <label for="tel">電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>"> <input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div> </div>
<div> <div>
<label for="tel_count">電話支援次數</label> <label for="tel_count">電話支援次數</label>
<input type="text" name="tel_count" id="tel_count" value="<?php echo $data['tel_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="tel_count" id="tel_count" value="<?php echo $data['tel_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="chat_id">文字客服連結</label> <label for="chat_id">文字客服連結</label>
<input type="text" name="chat_id" id="chat_id" value="<?php echo $data['chat_id']; ?>"> <input type="text" name="chat_id" id="chat_id" value="<?php echo $data['chat_id']; ?>">
</div> </div>
<div> <div>
<label for="chat_count">文字客服次數</label> <label for="chat_count">文字客服次數</label>
<input type="text" name="chat_count" id="chat_count" value="<?php echo $data['chat_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="chat_count" id="chat_count" value="<?php echo $data['chat_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="video_call">遠程視頻連結</label> <label for="video_call">遠程視頻連結</label>
<input type="text" name="video_call" id="video_call" value="<?php echo $data['video_call']; ?>"> <input type="text" name="video_call" id="video_call" value="<?php echo $data['video_call']; ?>">
</div> </div>
<div> <div>
<label for="video_count">遠程視頻次數</label> <label for="video_count">遠程視頻次數</label>
<input type="text" name="video_count" id="video_count" value="<?php echo $data['video_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="video_count" id="video_count" value="<?php echo $data['video_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="onsite_call">現場支援電話</label> <label for="onsite_call">現場支援電話</label>
<input type="text" name="onsite_call" id="onsite_call" value="<?php echo $data['onsite_call']; ?>"> <input type="text" name="onsite_call" id="onsite_call" value="<?php echo $data['onsite_call']; ?>">
</div> </div>
<div> <div>
<label for="onsite_count">現場支援次數</label> <label for="onsite_count">現場支援次數</label>
<input type="text" name="onsite_count" id="onsite_count" value="<?php echo $data['onsite_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="onsite_count" id="onsite_count" value="<?php echo $data['onsite_count']; ?>" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<label for="create_at">頭像</label> <label for="create_at">頭像</label>
<a><?php echo $data['picture']; ?></a> <a><?php echo $data['picture']; ?></a>
<img width="125px" src="<?php echo $data['picture']?>" alt="" class="index-image"> <img width="125px" src="<?php echo $data['picture']?>" alt="" class="index-image">
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<input type="file" name="fileToUpload" id="fileToUpload"> <input type="file" name="fileToUpload" id="fileToUpload">
</div> </div>
<div> <div>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

308
wms/expert-index.php

@ -1,154 +1,154 @@
<?php <?php
include "header.php"; include "header.php";
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id); $sql_cmd = sql_myself($user_id);
$sql = "SELECT * FROM expert $sql_cmd ORDER BY id"; $sql = "SELECT * FROM expert $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="expert-account-create.php"><h2>新增</h2></a> --> <!-- <a href="expert-account-create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<p> <p>
<a href="expert-create.php?function_name=expert&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="expert-create.php?function_name=expert&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:expert-index.php"); header("Location:expert-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <tr>
<th>項次</th> <th>項次</th>
<th>專家ID</th> <th>專家ID</th>
<th>身分證字號</th> <th>身分證字號</th>
<th>顯示姓名</th> <th>顯示姓名</th>
<th>稱謂</th> <th>稱謂</th>
<th class="width_style_1">頭像</th> <th class="width_style_1">頭像</th>
<th class="width_style_1">專長</th> <th class="width_style_1">專長</th>
<th>電話</th> <th>電話</th>
<th>電話支援次數</th> <th>電話支援次數</th>
<th>Chat帳號</th> <th>Chat帳號</th>
<th>Chat支援次數</th> <th>Chat支援次數</th>
<th>Video帳號</th> <th>Video帳號</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) { ?> <?php if ($user_auth&2) { ?>
<th>修改</th> <th>修改</th>
<th>刪除</th> <th>刪除</th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['expert_id']; ?></td> <td><?php echo $data['expert_id']; ?></td>
<td><?php echo $data['personal_id']; ?></td> <td><?php echo $data['personal_id']; ?></td>
<td><?php echo $data['name']; ?></td> <td><?php echo $data['name']; ?></td>
<td><?php echo $data['title']; ?></td> <td><?php echo $data['title']; ?></td>
<td class="width_style_1"><img src="<?php echo $data['picture']; ?>" alt="" class="index-image"></td> <td class="width_style_1"><img src="<?php echo $data['picture']; ?>" alt="" class="index-image"></td>
<td class="width_style_1"><?php echo $data['major']; ?></td> <td class="width_style_1"><?php echo $data['major']; ?></td>
<td><?php echo $data['tel']; ?></td> <td><?php echo $data['tel']; ?></td>
<td><?php echo $data['tel_count']; ?></td> <td><?php echo $data['tel_count']; ?></td>
<td><a href="<?php echo $data['chat_id']; ?>">連結</a></td> <td><a href="<?php echo $data['chat_id']; ?>">連結</a></td>
<td><?php echo $data['chat_count']; ?></td> <td><?php echo $data['chat_count']; ?></td>
<td><a href="<?php echo $data['video_call']; ?>">連結</a></td> <td><a href="<?php echo $data['video_call']; ?>">連結</a></td>
<td><?php echo $data['video_count']; ?></td> <td><?php echo $data['video_count']; ?></td>
<td><?php echo $data['onsite_call']; ?></td> <td><?php echo $data['onsite_call']; ?></td>
<td><?php echo $data['onsite_count']; ?></td> <td><?php echo $data['onsite_count']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<td> <td>
<p> <p>
<a href="expert-edit.php?id=<?php echo $data['id']; ?>&function_name=expert&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="expert-edit.php?id=<?php echo $data['id']; ?>&function_name=expert&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<td> <td>
<p> <p>
<a href="expert-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?')"> <a href="expert-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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td> </td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

272
wms/expert-record-submit.php

@ -1,136 +1,136 @@
<?php <?php
$id = ""; $id = "";
$expert_id = ""; $expert_id = "";
$personal_id = ""; $personal_id = "";
$name = ""; $name = "";
$title = ""; $title = "";
$major = ""; $major = "";
$tel = ""; $tel = "";
$tel_count = ""; $tel_count = "";
$chat_id = ""; $chat_id = "";
$chat_count = ""; $chat_count = "";
$video_call = ""; $video_call = "";
$video_count = ""; $video_count = "";
$onsite_call = ""; $onsite_call = "";
$onsite_count = ""; $onsite_count = "";
$creater = ""; $creater = "";
$create_at = ""; $create_at = "";
$fileToUpload = ""; $fileToUpload = "";
$id_error = ""; $id_error = "";
$expert_id_error = ""; $expert_id_error = "";
$personal_id_error = ""; $personal_id_error = "";
$name_error = ""; $name_error = "";
$title_error = ""; $title_error = "";
$major_error = ""; $major_error = "";
$tel_error = ""; $tel_error = "";
$tel_count_error = ""; $tel_count_error = "";
$chat_id_error = ""; $chat_id_error = "";
$chat_count_error = ""; $chat_count_error = "";
$video_call_error = ""; $video_call_error = "";
$video_count_error = ""; $video_count_error = "";
$onsite_call_error = ""; $onsite_call_error = "";
$onsite_count_error = ""; $onsite_count_error = "";
$creater_error = ""; $creater_error = "";
$create_at_error = ""; $create_at_error = "";
# $name_error = $email_error = $comment_error = $website_error = ""; # $name_error = $email_error = $comment_error = $website_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
include "expert-user-input.php"; include "expert-user-input.php";
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$file_size = $_FILES["fileToUpload"]["size"]; $file_size = $_FILES["fileToUpload"]["size"];
$target_dir = "expert-uploads/"; $target_dir = "expert-uploads/";
$target_file = strtolower($target_dir . basename($file_name)); $target_file = strtolower($target_dir . basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file, PATHINFO_EXTENSION);
$db_query = "INSERT INTO expert (expert_id,personal_id,name,title,picture,major,tel,tel_count,chat_id,chat_count,video_call,video_count,onsite_call,onsite_count,creater) VALUES ('$expert_id', '$personal_id', '$name', '$title', '$target_file' ,'$major', '$tel', '$tel_count', '$chat_id', '$chat_count', '$video_call', '$video_count', '$onsite_call', '$onsite_count', '$creater')"; $db_query = "INSERT INTO expert (expert_id,personal_id,name,title,picture,major,tel,tel_count,chat_id,chat_count,video_call,video_count,onsite_call,onsite_count,creater) VALUES ('$expert_id', '$personal_id', '$name', '$title', '$target_file' ,'$major', '$tel', '$tel_count', '$chat_id', '$chat_count', '$video_call', '$video_count', '$onsite_call', '$onsite_count', '$creater')";
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$file_size = $_FILES["fileToUpload"]["size"]; $file_size = $_FILES["fileToUpload"]["size"];
$target_dir = "expert-uploads/"; $target_dir = "expert-uploads/";
$target_file = strtolower($target_dir . basename($file_name)); $target_file = strtolower($target_dir . basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file, PATHINFO_EXTENSION);
//Check if image is an actual image or fake image //Check if image is an actual image or fake image
if(strlen($target_file) <= strlen("expert-uploads/")){ if(strlen($target_file) <= strlen("expert-uploads/")){
$db_query = "INSERT INTO expert(expert_id, personal_id, name, title, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater) VALUES ('$expert_id', '$personal_id', '$name', '$title', '$major', '$tel', '$tel_count', '$chat_id', '$chat_count', '$video_call', '$video_count', '$onsite_call', '$onsite_count', '$creater')"; $db_query = "INSERT INTO expert(expert_id, personal_id, name, title, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater) VALUES ('$expert_id', '$personal_id', '$name', '$title', '$major', '$tel', '$tel_count', '$chat_id', '$chat_count', '$video_call', '$video_count', '$onsite_call', '$onsite_count', '$creater')";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$result = mysqli_query($link,$db_query); $result = mysqli_query($link,$db_query);
#echo $result; #echo $result;
}else { }else {
$check_img = getimagesize($temp_file_name); $check_img = getimagesize($temp_file_name);
if($check_img == false) { if($check_img == false) {
echo "<font color='#FF0000'>File is not an image</font>"; echo "<font color='#FF0000'>File is not an image</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//echo "File is an image - " . $check_img["mime"]; //echo "File is an image - " . $check_img["mime"];
$upload_ok = 1; $upload_ok = 1;
//Check if file already exists //Check if file already exists
if(file_exists($target_file)) { if(file_exists($target_file)) {
echo "<font color='#FF0000'>File is already uploaded!</font>"; echo "<font color='#FF0000'>File is already uploaded!</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Check file size //Check file size
if($file_size > 500000) { if($file_size > 500000) {
echo "<font color='#FF0000'>Please enter a file size between 5mb</font>"; echo "<font color='#FF0000'>Please enter a file size between 5mb</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Allow certain file formats //Allow certain file formats
if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") { if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") {
echo "<font color='#FF0000'>JPG, PNG, JPEG and GIF files are allowed</font>"; echo "<font color='#FF0000'>JPG, PNG, JPEG and GIF files are allowed</font>";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Check if $upload_ok is set to 0 by an error //Check if $upload_ok is set to 0 by an error
if($upload_ok === 0) { if($upload_ok === 0) {
echo "<font color='#FF0000'>File has not been uploaded</font>"; echo "<font color='#FF0000'>File has not been uploaded</font>";
} else { } else {
if(move_uploaded_file($temp_file_name, $target_file)){ if(move_uploaded_file($temp_file_name, $target_file)){
// sql語法存在變數中 // sql語法存在變數中
// $db_query = "INSERT INTO expert (id, expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater, create_at) VALUE (`$id`, `$expert_id`, `$personal_id`, `$name`, `$title`, `$target_file`, `$major`, `$tel`, `$tel_count`, `$chat_id`, `$chat_count`, `$video_call`, `$video_count`, `$onsite_call`, `$onsite_count`, `$creater`, `$create_at`)"; // $db_query = "INSERT INTO expert (id, expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater, create_at) VALUE (`$id`, `$expert_id`, `$personal_id`, `$name`, `$title`, `$target_file`, `$major`, `$tel`, `$tel_count`, `$chat_id`, `$chat_count`, `$video_call`, `$video_count`, `$onsite_call`, `$onsite_count`, `$creater`, `$create_at`)";
$db_query = "INSERT INTO expert(expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater) VALUES ('$expert_id', '$personal_id', '$name', '$title', '$target_file', '$major', '$tel', '$tel_count', '$chat_id', '$chat_count', '$video_call', '$video_count', '$onsite_call', '$onsite_count', '$creater')"; $db_query = "INSERT INTO expert(expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater) VALUES ('$expert_id', '$personal_id', '$name', '$title', '$target_file', '$major', '$tel', '$tel_count', '$chat_id', '$chat_count', '$video_call', '$video_count', '$onsite_call', '$onsite_count', '$creater')";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$result = mysqli_query($link,$db_query); $result = mysqli_query($link,$db_query);
} }
} }
} }
} }
} }
} }
} }
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');"; echo "alert('新增成功');";
echo "location.href='expert-index.php?function_name=expert&".$token_link."';"; echo "location.href='expert-index.php?function_name=expert&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');"; echo "alert('無新增資料');";
echo "location.href='expert-index.php?function_name=expert&".$token_link."';"; echo "location.href='expert-index.php?function_name=expert&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

168
wms/expert-record-update.php

@ -1,85 +1,85 @@
<?php <?php
include "header.php"; include "header.php";
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$id = $_POST['id']; $id = $_POST['id'];
$expert_id = user_input($_POST["expert_id"]); $expert_id = user_input($_POST["expert_id"]);
$personal_id = user_input($_POST["personal_id"]); $personal_id = user_input($_POST["personal_id"]);
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
$title = user_input($_POST["title"]); $title = user_input($_POST["title"]);
$major = user_input($_POST["major"]); $major = user_input($_POST["major"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$tel_count = user_input($_POST["tel_count"]); $tel_count = user_input($_POST["tel_count"]);
$chat_id = user_input($_POST["chat_id"]); $chat_id = user_input($_POST["chat_id"]);
$chat_count = user_input($_POST["chat_count"]); $chat_count = user_input($_POST["chat_count"]);
$video_call = user_input($_POST["video_call"]); $video_call = user_input($_POST["video_call"]);
$video_count = user_input($_POST["video_count"]); $video_count = user_input($_POST["video_count"]);
$onsite_call = user_input($_POST["onsite_call"]); $onsite_call = user_input($_POST["onsite_call"]);
$onsite_count = user_input($_POST["onsite_count"]); $onsite_count = user_input($_POST["onsite_count"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$file_size = $_FILES["fileToUpload"]["size"]; $file_size = $_FILES["fileToUpload"]["size"];
$target_dir = "expert-uploads/"; $target_dir = "expert-uploads/";
$target_file = strtolower($target_dir . basename($file_name)); $target_file = strtolower($target_dir . basename($file_name));
$upload_ok = 1; $upload_ok = 1;
$img_file_type = pathinfo($target_file, PATHINFO_EXTENSION); $img_file_type = pathinfo($target_file, PATHINFO_EXTENSION);
if(strlen($target_file) <= strlen("expert-uploads/")){ if(strlen($target_file) <= strlen("expert-uploads/")){
$db_query = "UPDATE expert set expert_id = '$expert_id', personal_id = '$personal_id', name = '$name', title = '$title', major = '$major', tel = '$tel', tel_count = '$tel_count', chat_id = '$chat_id', chat_count = '$chat_count', video_call = '$video_call', video_count = '$video_count', onsite_call = '$onsite_call', onsite_count = '$onsite_count', create_at = '$create_at' WHERE id='$id'"; $db_query = "UPDATE expert set expert_id = '$expert_id', personal_id = '$personal_id', name = '$name', title = '$title', major = '$major', tel = '$tel', tel_count = '$tel_count', chat_id = '$chat_id', chat_count = '$chat_count', video_call = '$video_call', video_count = '$video_count', onsite_call = '$onsite_call', onsite_count = '$onsite_count', create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
}else { }else {
if($file_size > 500000) { if($file_size > 500000) {
echo "<font color='#FF0000'>Please enter a file size between 5mb</font>"; echo "<font color='#FF0000'>Please enter a file size between 5mb</font>";
$upload_ok = 0; $upload_ok = 0;
} else { // } else { //
//Allow certain file formats //Allow certain file formats
if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") { if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") {
//echo "JPG, PNG, JPEG and GIF files are allowed"; //echo "JPG, PNG, JPEG and GIF files are allowed";
$upload_ok = 0; $upload_ok = 0;
} else { } else {
//Check if $upload_ok is set to 0 by an error //Check if $upload_ok is set to 0 by an error
if($upload_ok === 0) { if($upload_ok === 0) {
echo "<font color='#FF0000'>File has not been uploaded</font>"; echo "<font color='#FF0000'>File has not been uploaded</font>";
} else { } else {
if(move_uploaded_file($temp_file_name, $target_file)){ if(move_uploaded_file($temp_file_name, $target_file)){
$db_query = "UPDATE expert set expert_id = '$expert_id', personal_id = '$personal_id', name = '$name', title = '$title', picture = '$target_file', major = '$major', tel = '$tel', tel_count = '$tel_count', chat_id = '$chat_id', chat_count = '$chat_count', video_call = '$video_call', video_count = '$video_count', onsite_call = '$onsite_call', onsite_count = '$onsite_count', create_at = '$create_at' WHERE id='$id'"; $db_query = "UPDATE expert set expert_id = '$expert_id', personal_id = '$personal_id', name = '$name', title = '$title', picture = '$target_file', major = '$major', tel = '$tel', tel_count = '$tel_count', chat_id = '$chat_id', chat_count = '$chat_count', video_call = '$video_call', video_count = '$video_count', onsite_call = '$onsite_call', onsite_count = '$onsite_count', create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
} }
} }
} }
} }
} }
$affected = mysqli_affected_rows($link); $affected = mysqli_affected_rows($link);
mysqli_close($link); mysqli_close($link);
if ($affected > 0) { if ($affected > 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('update成功');"; echo "alert('update成功');";
echo "location.href='expert-index.php?function_name=expert&".$token_link."';"; echo "location.href='expert-index.php?function_name=expert&".$token_link."';";
echo "</script>"; echo "</script>";
} elseif ($affected == 0) { } elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>"; echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料')"; echo "alert('無新增資料')";
echo "location.href='expert-index.php?function_name=expert&".$token_link."';"; echo "location.href='expert-index.php?function_name=expert&".$token_link."';";
echo "</script>"; echo "</script>";
} else { } else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
} }
} }
?> ?>

118
wms/expert-user-input.php

@ -1,59 +1,59 @@
<?php <?php
//Function to filter the form input //Function to filter the form input
function user_input( $data ) { function user_input( $data ) {
$data1 = trim($data); $data1 = trim($data);
$data2 = stripslashes($data1); $data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2); $data3 = htmlspecialchars($data2);
return $data3; return $data3;
} }
$expert_id = user_input($_POST["expert_id"]); $expert_id = user_input($_POST["expert_id"]);
$personal_id = user_input($_POST["personal_id"]); $personal_id = user_input($_POST["personal_id"]);
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
$title = user_input($_POST["title"]); $title = user_input($_POST["title"]);
$major = user_input($_POST["major"]); $major = user_input($_POST["major"]);
$tel = user_input($_POST["tel"]); $tel = user_input($_POST["tel"]);
$tel_count = user_input($_POST["tel_count"]); $tel_count = user_input($_POST["tel_count"]);
$chat_id = user_input($_POST["chat_id"]); $chat_id = user_input($_POST["chat_id"]);
$chat_count = user_input($_POST["chat_count"]); $chat_count = user_input($_POST["chat_count"]);
$video_call = user_input($_POST["video_call"]); $video_call = user_input($_POST["video_call"]);
$video_count = user_input($_POST["video_count"]); $video_count = user_input($_POST["video_count"]);
$onsite_call = user_input($_POST["onsite_call"]); $onsite_call = user_input($_POST["onsite_call"]);
$onsite_count = user_input($_POST["onsite_count"]); $onsite_count = user_input($_POST["onsite_count"]);
$creater = user_input($_POST["creater"]); $creater = user_input($_POST["creater"]);
$create_at = user_input($_POST["create_at"]); $create_at = user_input($_POST["create_at"]);
/* /*
if(empty($_POST["name"])) { if(empty($_POST["name"])) {
$name_error = "Name is required"; $name_error = "Name is required";
} else { } else {
$name = user_input($_POST["name"]); $name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) { if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed"; $name_error = "Only letter and white space are allowed";
} }
} }
/* /*
if(empty($_POST["website"])) { if(empty($_POST["website"])) {
$website_error = "Website address is required"; $website_error = "Website address is required";
} else { } else {
$website = user_input($_POST["website"]); $website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) { if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL"; $website_error = "Invalid website URL";
} }
} }
if(empty($_POST["comment"])) { if(empty($_POST["comment"])) {
$comment = ""; $comment = "";
} else { } else {
$comment = user_input($_POST["comment"]); $comment = user_input($_POST["comment"]);
} }
*/ */
?> ?>

252
wms/facility-create.php

@ -1,126 +1,126 @@
<?php <?php
include "header.php"; include "header.php";
?> ?>
<div class="container"> <div class="container">
<?php <?php
include "facility-record-submit.php"; include "facility-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
echo "<p class='success'>Record has added successfully</p>"; 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"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div> <div>
<label for="contractno">合約號(必填)</label> <label for="contractno">合約號(必填)</label>
<input type="text" name="contractno" id="contractno" required> <input type="text" name="contractno" id="contractno" required>
</div> </div>
<div> <div>
<label for="facilityno">作番號(必填)</label> <label for="facilityno">作番號(必填)</label>
<input type="text" name="facilityno" id="facilityno" required> <input type="text" name="facilityno" id="facilityno" required>
</div> </div>
<div> <div>
<label for="customerid">客戶編號(必填)</label> <label for="customerid">客戶編號(必填)</label>
<input type="text" name="customerid" id="customerid" required> <input type="text" name="customerid" id="customerid" required>
</div> </div>
<div> <div>
<label for="weight">重量(必填)</label> <label for="weight">重量(必填)</label>
<input type="text" name="weight" id="weight" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="weight" id="weight" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="numberofstop">停數(必填)</label> <label for="numberofstop">停數(必填)</label>
<input type="text" name="numberofstop" id="numberofstop" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="numberofstop" id="numberofstop" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="numberoffloor">樓層數(必填)</label> <label for="numberoffloor">樓層數(必填)</label>
<input type="text" name="numberoffloor" id="numberoffloor" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="numberoffloor" id="numberoffloor" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="opentype">開門方式(必填)</label> <label for="opentype">開門方式(必填)</label>
<Select name="opentype" id="opentype" required> <Select name="opentype" id="opentype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="CO">CO</Option> <Option Value="CO">CO</Option>
<Option Value="SO">SO</Option> <Option Value="SO">SO</Option>
<Option Value="CO-SO">CO-SO</Option> <Option Value="CO-SO">CO-SO</Option>
</Select> </Select>
<!-- <input type="text" name="opentype" id="opentype" > --> <!-- <input type="text" name="opentype" id="opentype" > -->
</div> </div>
<div> <div>
<label for="speed">速度(必填)</label> <label for="speed">速度(必填)</label>
<input type="text" name="speed" id="speed" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required> <input type="text" name="speed" id="speed" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="repairtype">維修型態(必填)</label> <label for="repairtype">維修型態(必填)</label>
<Select name="repairtype" id="repairtype" required> <Select name="repairtype" id="repairtype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option> <option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option> <Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option> <Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option> <Option Value="C">單次維修</Option>
</Select> </Select>
<!-- <input type="text" name="repairtype" id="repairtype" > --> <!-- <input type="text" name="repairtype" id="repairtype" > -->
</div> </div>
<div> <div>
<label for="longitude">經度(必填)</label> <label for="longitude">經度(必填)</label>
<input type="text" name="longitude" id="longitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required> <input type="text" name="longitude" id="longitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="latitude">緯度(必填)</label> <label for="latitude">緯度(必填)</label>
<input type="latitude" name="latitude" id="latitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required> <input type="latitude" name="latitude" id="latitude" onkeyup="if(value<0)value=0;if(value.length>11)value=value.slice(0,11);value=value.replace(/^\D*(\d*(?:\.\d{0,7})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address" > <input type="text" name="address" id="address" >
</div> </div>
<div> <div>
<label for="repairerid">維修人員工號(必填)</label> <label for="repairerid">維修人員工號(必填)</label>
<input type="text" name="repairerid" id="repairerid" required> <input type="text" name="repairerid" id="repairerid" required>
</div> </div>
<div> <div>
<label for="repairername">維修人員姓名(必填)</label> <label for="repairername">維修人員姓名(必填)</label>
<input type="text" name="repairername" id="repairername" required> <input type="text" name="repairername" id="repairername" required>
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
</div> </div>
<div> <div>
<!-- <label for="create_at">create_at</label> --> <!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at"> <input type="hidden" name="create_at" id="create_at">
<p class="error"><?php echo $create_at_error; ?></p> <p class="error"><?php echo $create_at_error; ?></p>
</div> </div>
<div> <div>
<button type="submit" name="submit">確定</button> <button type="submit" name="submit">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php include "footer.php"; ?> <?php include "footer.php"; ?>

22
wms/facility-delete.php

@ -1,12 +1,12 @@
<?php <?php
ob_start(); ob_start();
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM facility WHERE id='$id'"; $db_query = "DELETE FROM facility WHERE id='$id'";
mysqli_query($link, $db_query); mysqli_query($link, $db_query);
header("Refresh:0; url=facility-index.php?function_name=facility&".$token_link); header("Refresh:0; url=facility-index.php?function_name=facility&".$token_link);
ob_end_flush(); ob_end_flush();
?> ?>

306
wms/facility-edit.php

@ -1,153 +1,153 @@
<?php <?php
include "header.php"; include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM facility WHERE id=$id"; $db_query = "SELECT * FROM facility WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
/* /*
include "inc/record_update.php"; include "inc/record_update.php";
try { try {
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id"; $db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query); $data = mysqli_query($link,$db_query);
}catch (Exception $e) { }catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
} }
*/ */
foreach($data as $data) : foreach($data as $data) :
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="facility-record-update.php" enctype="multipart/form-data"> <form class="form-inline" method="post" action="facility-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>">
<div> <div>
<label for="contractno">合約號</label> <label for="contractno">合約號</label>
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>" required> <input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>" required>
</div> </div>
<div> <div>
<label for="facilityno">作番號</label> <label for="facilityno">作番號</label>
<input type="text" name="facilityno" id="facilityno" value="<?php echo $data['facilityno']; ?>" required> <input type="text" name="facilityno" id="facilityno" value="<?php echo $data['facilityno']; ?>" required>
</div> </div>
<div> <div>
<label for="customerid">客戶編號</label> <label for="customerid">客戶編號</label>
<input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>" required> <input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>" required>
</div> </div>
<div> <div>
<label for="weight">重量</label> <label for="weight">重量</label>
<input type="text" name="weight" id="weight" value="<?php echo $data['weight']; ?>" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="weight" id="weight" value="<?php echo $data['weight']; ?>" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="numberofstop">停數</label> <label for="numberofstop">停數</label>
<input type="text" name="numberofstop" id="numberofstop" value="<?php echo $data['numberofstop']; ?>" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="numberofstop" id="numberofstop" value="<?php echo $data['numberofstop']; ?>" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="numberoffloor">樓層數</label> <label for="numberoffloor">樓層數</label>
<input type="text" name="numberoffloor" id="numberoffloor" value="<?php echo $data['numberoffloor']; ?>" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required> <input type="text" name="numberoffloor" id="numberoffloor" value="<?php echo $data['numberoffloor']; ?>" onkeyup="if(value<0)value=0;if(value.length>3)value=value.slice(0,3);value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="opentype">開門方式</label> <label for="opentype">開門方式</label>
<Select name="opentype" id="opentype" required> <Select name="opentype" id="opentype" required>
<?php <?php
switch ($data['opentype']) { switch ($data['opentype']) {
case "CO": case "CO":
echo "<Option Value='CO' selected='selected'>CO</Option> <Option Value='OS'>SO</Option> <Option Value='CO-SO'>CO-SO</Option>"; echo "<Option Value='CO' selected='selected'>CO</Option> <Option Value='OS'>SO</Option> <Option Value='CO-SO'>CO-SO</Option>";
break; break;
case "SO": case "SO":
echo "<Option Value='CO'>CO</Option> <Option Value='SO' selected='selected'>SO</Option> <Option Value='CO-SO'>CO-SO</Option>"; echo "<Option Value='CO'>CO</Option> <Option Value='SO' selected='selected'>SO</Option> <Option Value='CO-SO'>CO-SO</Option>";
break; break;
case "CO-SO": case "CO-SO":
echo "<Option Value='CO'>CO</Option> <Option Value='SO'>SO</Option> <Option Value='CO-SO' selected='selected'>CO-SO</Option>"; echo "<Option Value='CO'>CO</Option> <Option Value='SO'>SO</Option> <Option Value='CO-SO' selected='selected'>CO-SO</Option>";
break; break;
} }
?> ?>
</Select> </Select>
<!-- <input type="text" name="opentype" id="opentype" value=""> --> <!-- <input type="text" name="opentype" id="opentype" value=""> -->
</div> </div>
<div> <div>
<label for="speed">速度</label> <label for="speed">速度</label>
<input type="text" name="speed" id="speed" value="<?php echo $data['speed']; ?>" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required> <input type="text" name="speed" id="speed" value="<?php echo $data['speed']; ?>" onkeyup="if(value<0)value=0;if(value.length>4)value=value.slice(0,4);value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" required>
</div> </div>
<div> <div>
<label for="repairtype">維修型態</label> <label for="repairtype">維修型態</label>
<Select name="repairtype" id="repairtype" required> <Select name="repairtype" id="repairtype" required>
<?php <?php
switch ($data['repairtype']) { switch ($data['repairtype']) {
case "A": case "A":
echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>"; echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break; break;
case "B": case "B":
echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>"; echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break; break;
case "C": case "C":
echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>"; echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>";
break; break;
} }
?> ?>
</Select> </Select>
<!-- <input type="text" name="repairtype" id="repairtype" value=""> --> <!-- <input type="text" name="repairtype" id="repairtype" value=""> -->
</div> </div>
<div> <div>
<label for="longitude">經度(必填)</label> <label for="longitude">經度(必填)</label>
<input type="text" name="longitude" id="longitude" value="<?php echo $data['longitude']; ?>"> <input type="text" name="longitude" id="longitude" value="<?php echo $data['longitude']; ?>">
</div> </div>
<div> <div>
<label for="latitude">緯度(必填)</label> <label for="latitude">緯度(必填)</label>
<input type="latitude" name="latitude" id="latitude" value="<?php echo $data['latitude']; ?>"d> <input type="latitude" name="latitude" id="latitude" value="<?php echo $data['latitude']; ?>"d>
</div> </div>
<div> <div>
<label for="address">地址</label> <label for="address">地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>"> <input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div> </div>
<div> <div>
<label for="repairerid">維修人員工號</label> <label for="repairerid">維修人員工號</label>
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>"> <input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>">
</div> </div>
<div> <div>
<label for="repairername">維修人員姓名</label> <label for="repairername">維修人員姓名</label>
<input type="text" name="repairername" id="repairername" value="<?php echo $data['repairername']; ?>"> <input type="text" name="repairername" id="repairername" value="<?php echo $data['repairername']; ?>">
</div> </div>
<div> <div>
<label for="creater">建檔人</label> <label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> <input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div> </div>
<div> <div>
<button type="submit" name="update">確定</button> <button type="submit" name="update">確定</button>
</div> </div>
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
</form> </form>
</div> </div>
<?php <?php
endforeach; endforeach;
include "footer.php"; include "footer.php";
?> ?>

230
wms/facility-excel-upload.php

@ -1,115 +1,115 @@
<?php <?php
// 载入db.php来连结资料库 // 载入db.php来连结资料库
require_once "database.php"; require_once "database.php";
include "header.php"; include "header.php";
require_once 'PHPExcel/PHPExcel.php'; require_once 'PHPExcel/PHPExcel.php';
require_once 'PHPExcel/IOFactory.php'; require_once 'PHPExcel/IOFactory.php';
$file_name = $_FILES["fileToUpload"]["name"]; $file_name = $_FILES["fileToUpload"]["name"];
$temp_file_name = $_FILES["fileToUpload"]["tmp_name"]; $temp_file_name = $_FILES["fileToUpload"]["tmp_name"];
$target_dir = "expert-uploads/"; $target_dir = "expert-uploads/";
$target_file = strtolower($target_dir . iconv("UTF-8", "gbk", basename($file_name))); $target_file = strtolower($target_dir . iconv("UTF-8", "gbk", basename($file_name)));
$EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION); $EXTENSION = pathinfo($target_file, PATHINFO_EXTENSION);
if (move_uploaded_file($temp_file_name, $target_file)) { if (move_uploaded_file($temp_file_name, $target_file)) {
if ($EXTENSION == 'xls') { if ($EXTENSION == 'xls') {
$objReader = PHPExcel_IOFactory::createReader('Excel5');//支持xls $objReader = PHPExcel_IOFactory::createReader('Excel5');//支持xls
} else { } else {
$objReader = PHPExcel_IOFactory::createReader('Excel2007');//支持xlsx $objReader = PHPExcel_IOFactory::createReader('Excel2007');//支持xlsx
} }
$objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件 $objPHPExcel = $objReader->load($target_file); //读取上传到服务器的文件
$sheet = $objPHPExcel->getSheet(0);//拿到第一个sheet数据 $sheet = $objPHPExcel->getSheet(0);//拿到第一个sheet数据
$highestRow = $sheet->getHighestRow(); // 取得总行数 $highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数 $highestColumn = $sheet->getHighestColumn(); // 取得总列数
$highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字; $highestColumn = PHPExcel_Cell::columnIndexFromString($highestColumn); // 转换字母为对应的统计数字;
$excelArray = array(); $excelArray = array();
for ($row = 2; $row <= $highestRow; $row++) { for ($row = 2; $row <= $highestRow; $row++) {
$val = $sheet->getCellByColumnAndRow(0, $row)->getCalculatedValue(); $val = $sheet->getCellByColumnAndRow(0, $row)->getCalculatedValue();
if ($val == "") return; if ($val == "") return;
for ($column = 1; $column < $highestColumn; $column++) { for ($column = 1; $column < $highestColumn; $column++) {
$val = $sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue(); $val = $sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue();
$excelArray[$row][] = $val; //读取excel数据到数组 $excelArray[$row][] = $val; //读取excel数据到数组
} }
$facilityno = $excelArray[$row][1]; //作番id $facilityno = $excelArray[$row][1]; //作番id
$facilitsql = "SELECT * FROM facility where facilityno='$facilityno'"; $facilitsql = "SELECT * FROM facility where facilityno='$facilityno'";
$facilit_nums_rows = mysqli_num_rows(mysqli_query($link, $facilitsql)); $facilit_nums_rows = mysqli_num_rows(mysqli_query($link, $facilitsql));
if ($facilit_nums_rows == 0) { if ($facilit_nums_rows == 0) {
echo $row; echo $row;
$contractno = $excelArray[$row][0]?:'null'; //合约号 $contractno = $excelArray[$row][0]?:'null'; //合约号
$facilityno = $excelArray[$row][1]?:'null'; //作番号 $facilityno = $excelArray[$row][1]?:'null'; //作番号
$address = $excelArray[$row][2]?:'null'; //作番安装地址 $address = $excelArray[$row][2]?:'null'; //作番安装地址
$longitude = $excelArray[$row][3]?:'null';//纬度 $longitude = $excelArray[$row][3]?:'null';//纬度
$latitude = $excelArray[$row][4]?:'null';//经度 $latitude = $excelArray[$row][4]?:'null';//经度
$customerid = $excelArray[$row][5]?:'null'; //客户/业主名称 $customerid = $excelArray[$row][5]?:'null'; //客户/业主名称
$customercode = $excelArray[$row][6]?:'null'; //业主ID或统一信用代码 $customercode = $excelArray[$row][6]?:'null'; //业主ID或统一信用代码
$customerlinknumber = $excelArray[$row][7]?:'null'; //业主联络电话或手机 $customerlinknumber = $excelArray[$row][7]?:'null'; //业主联络电话或手机
$repairerid = $excelArray[$row][8]?:'null'; //保养员工号 $repairerid = $excelArray[$row][8]?:'null'; //保养员工号
$repairername = $excelArray[$row][9]?:'null'; //保养员姓名 $repairername = $excelArray[$row][9]?:'null'; //保养员姓名
$repairerphonenumber = $excelArray[$row][10]?:'null'; //保养员手机号 $repairerphonenumber = $excelArray[$row][10]?:'null'; //保养员手机号
$baoyangdate= $excelArray[$row][11]?:'null'; //保养日期 $baoyangdate= $excelArray[$row][11]?:'null'; //保养日期
$maintainance= $excelArray[$row][12]?:'null'; //保养计划类别.保養別\r\nA=全包\r\nB=半包\r\nC=清包\r\nD=半包:2個月保養一次 $maintainance= $excelArray[$row][12]?:'null'; //保养计划类别.保養別\r\nA=全包\r\nB=半包\r\nC=清包\r\nD=半包:2個月保養一次
$yingshoukuandate= $excelArray[$row][13]?:'null'; //应收款日期 $yingshoukuandate= $excelArray[$row][13]?:'null'; //应收款日期
$contractstartdate= $excelArray[$row][14]?:'null'; //合约起始年月日 $contractstartdate= $excelArray[$row][14]?:'null'; //合约起始年月日
$contractenddate= $excelArray[$row][15]?:'null'; //合约终止年月日 $contractenddate= $excelArray[$row][15]?:'null'; //合约终止年月日
$facilitychuchangno= $excelArray[$row][16]?:'null'; //原作番出厂编号 $facilitychuchangno= $excelArray[$row][16]?:'null'; //原作番出厂编号
$contractpersonid= $excelArray[$row][17]?:'null'; //契约人员工号 $contractpersonid= $excelArray[$row][17]?:'null'; //契约人员工号
$contractpersonname= $excelArray[$row][18]?:'null'; //契约人员姓名 $contractpersonname= $excelArray[$row][18]?:'null'; //契约人员姓名
$weight= $excelArray[$row][19]?:'null'; //载重/输送能力 $weight= $excelArray[$row][19]?:'null'; //载重/输送能力
$numberoffloor= $excelArray[$row][20]?:'null'; //层站,停数/提升高度 $numberoffloor= $excelArray[$row][20]?:'null'; //层站,停数/提升高度
$speed= $excelArray[$row][21]?:'null'; //速度 $speed= $excelArray[$row][21]?:'null'; //速度
$brand= $excelArray[$row][22]?:'null'; //品牌,型号 $brand= $excelArray[$row][22]?:'null'; //品牌,型号
$officialregistrationcode= $excelArray[$row][13]?:'null'; //官方注册代码 $officialregistrationcode= $excelArray[$row][13]?:'null'; //官方注册代码
$manufacturedate= $excelArray[$row][24]?:'null'; //制造日期 $manufacturedate= $excelArray[$row][24]?:'null'; //制造日期
$creater = "batch"; $creater = "batch";
$create_at = date('Y/m/d H:i:s'); $create_at = date('Y/m/d H:i:s');
//无效字段 //无效字段
$numberofstop='0'; $numberofstop='0';
$opentype='0'; $opentype='0';
$repairtype='0'; $repairtype='0';
echo $db_query1 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofstop, numberoffloor,opentype,speed,repairtype,longitude, latitude, address,repairerid,repairername,creater, create_at) VALUES ('$contractno', '$facilityno', '$customerid', '$weight','$numberofstop', '$numberoffloor','$opentype','$speed','$repairtype','$longitude', '$latitude', '$address','$repairerid','$repairername','$creater', '$create_at')"; echo $db_query1 = "INSERT INTO facility(contractno, facilityno, customerid, weight,numberofstop, numberoffloor,opentype,speed,repairtype,longitude, latitude, address,repairerid,repairername,creater, create_at) VALUES ('$contractno', '$facilityno', '$customerid', '$weight','$numberofstop', '$numberoffloor','$opentype','$speed','$repairtype','$longitude', '$latitude', '$address','$repairerid','$repairername','$creater', '$create_at')";
mysqli_query($link, $db_query1); mysqli_query($link, $db_query1);
if (mysqli_affected_rows($link) > 0) { if (mysqli_affected_rows($link) > 0) {
echo "作番新增成功\n"; echo "作番新增成功\n";
//添加作番拓展字段 //添加作番拓展字段
$facilityid=mysqli_insert_id($link); $facilityid=mysqli_insert_id($link);
$db_query2 = "INSERT INTO facility_extends(facilityid,facilitychuchangno,contractpersonid,contractpersonname,brand,officialregistrationcode,manufacturedate,creater, create_at) VALUES ("; $db_query2 = "INSERT INTO facility_extends(facilityid,facilitychuchangno,contractpersonid,contractpersonname,brand,officialregistrationcode,manufacturedate,creater, create_at) VALUES (";
$db_query2.=" '$facilityid', '$facilitychuchangno','$contractpersonid','$contractpersonname','$brand','$officialregistrationcode','$manufacturedate','$creater', '$create_at')"; $db_query2.=" '$facilityid', '$facilitychuchangno','$contractpersonid','$contractpersonname','$brand','$officialregistrationcode','$manufacturedate','$creater', '$create_at')";
mysqli_query($link, $db_query2); mysqli_query($link, $db_query2);
if (mysqli_affected_rows($link) > 0) { if (mysqli_affected_rows($link) > 0) {
echo '扩展添加成功'; echo '扩展添加成功';
} }
} elseif (mysqli_affected_rows($link) == 0) { } elseif (mysqli_affected_rows($link) == 0) {
echo "无新增资料"; echo "无新增资料";
} }
} else { } else {
echo "作番已经存在"; echo "作番已经存在";
echo $facilityno; echo $facilityno;
} }
//print_r($excelArray); //print_r($excelArray);
} }
mysqli_close($link); mysqli_close($link);
} }
?> ?>
<div class="container"> <div class="container">
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"
enctype="multipart/form-data"> enctype="multipart/form-data">
<div class="bottom-margin">资料 <div class="bottom-margin">资料
<label for="fileToUpload">上传</label> <label for="fileToUpload">上传</label>
<div> <div>
<input type="file" name="fileToUpload" id="fileToUpload"> <input type="file" name="fileToUpload" id="fileToUpload">
</div> </div>
<div class="bottom-margin"> <div class="bottom-margin">
<button type="submit" name="submit">确定</button> <button type="submit" name="submit">确定</button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>

320
wms/facility-index.php

@ -1,161 +1,161 @@
<?php <?php
include "header.php"; include "header.php";
// 工務總處可瀏覽全部資料 // 工務總處可瀏覽全部資料
$sql = "select department_id from account where accountid = '$user_id'"; $sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql); $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res); $row = mysqli_fetch_row($res);
$user_department_id = $row[0]; $user_department_id = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
// 設置一個空陣列來放資料 // 設置一個空陣列來放資料
$data = array(); $data = array();
// sql語法存在變數中 // sql語法存在變數中
$sql_cmd = sql_myself($user_id); $sql_cmd = sql_myself($user_id);
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = ""; if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = "";
$sql = "SELECT * FROM facility $sql_cmd ORDER BY id"; $sql = "SELECT * FROM facility $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中 // 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql); $data = mysqli_query($link,$sql);
?> ?>
<!-- <a href="create.php"><h2>新增</h2></a> --> <!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<p> <p>
<a href="facility-create.php?function_name=facility&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="facility-create.php?function_name=facility&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a>
</p> </p>
<?php <?php
} }
if($data): if($data):
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
} else { } else {
header("Location:facility-index.php"); header("Location:facility-index.php");
} }
} }
?> ?>
<style> <style>
table { table {
table-layout:fixed; table-layout:fixed;
width: 100%; width: 100%;
} }
td { td {
word-wrap:break-word; word-wrap:break-word;
} }
img { img {
width:125px; width:125px;
} }
.width_style_1 { .width_style_1 {
width:125px; width:125px;
} }
table{ table{
width:100%; width:100%;
} }
#table_index_filter{ #table_index_filter{
float:right; float:right;
} }
#table_index_paginate{ #table_index_paginate{
float:right; float:right;
} }
label { label {
display: inline-flex; display: inline-flex;
margin-bottom: .5rem; margin-bottom: .5rem;
margin-top: .5rem; margin-top: .5rem;
} }
</style> </style>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <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> <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) { ?> <?php if ($user_auth&2) { ?>
<th>修改</th> <th>修改</th>
<th>刪除</th> <th>刪除</th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($data as $data) : ?> <?php foreach($data as $data) : ?>
<tr> <tr>
<td><?php echo $data['id']; ?></td> <td><?php echo $data['id']; ?></td>
<td><?php echo $data['contractno']; ?></td> <td><?php echo $data['contractno']; ?></td>
<td><?php echo $data['facilityno']; ?></td> <td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['customerid']; ?></td> <td><?php echo $data['customerid']; ?></td>
<td><?php echo $data['weight']; ?></td> <td><?php echo $data['weight']; ?></td>
<td><?php echo $data['numberofstop']; ?></td> <td><?php echo $data['numberofstop']; ?></td>
<td><?php echo $data['numberoffloor']; ?></td> <td><?php echo $data['numberoffloor']; ?></td>
<td><?php echo $data['opentype']; ?></td> <td><?php echo $data['opentype']; ?></td>
<td><?php echo $data['speed']; ?></td> <td><?php echo $data['speed']; ?></td>
<td><?php echo $data['repairtype']; ?></td> <td><?php echo $data['repairtype']; ?></td>
<td><?php echo $data['longitude']; ?></td> <td><?php echo $data['longitude']; ?></td>
<td><?php echo $data['latitude']; ?></td> <td><?php echo $data['latitude']; ?></td>
<td><?php echo $data['address']; ?></td> <td><?php echo $data['address']; ?></td>
<td><?php echo $data['repairerid']; ?></td> <td><?php echo $data['repairerid']; ?></td>
<td><?php echo $data['repairername']; ?></td> <td><?php echo $data['repairername']; ?></td>
<td><?php echo $data['creater']; ?></td> <td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td> <td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?> <?php if ($user_auth&2) { ?>
<td> <td>
<p> <p>
<a href="facility-edit.php?id=<?php echo $data['id']; ?>&function_name=facility&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> <a href="facility-edit.php?id=<?php echo $data['id']; ?>&function_name=facility&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
</p> </p>
</td> </td>
<td> <td>
<p> <p>
<a href="facility-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?')"> <a href="facility-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> <span class="glyphicon glyphicon-remove"></span>
</a> </a>
</p> </p>
</td> </td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
else: else:
echo "<h2>There is no record!</h2>"; echo "<h2>There is no record!</h2>";
endif; endif;
#代表結束連線 #代表結束連線
mysqli_close($link); mysqli_close($link);
include "footer.php"; include "footer.php";
?> ?>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save