22 changed files with 885 additions and 544 deletions
@ -1,8 +1,48 @@ |
|||
<html> |
|||
<head> |
|||
<meta http-equiv="refresh" content="0;url= https://masada-tw.com/ "> |
|||
</head> |
|||
<body> |
|||
|
|||
</body> |
|||
<head> |
|||
<!-- <meta http-equiv="refresh" content="0;url= https://masada-tw.com/ "> --> |
|||
<meta charset="utf-8"> |
|||
<script src="https://cdn.tailwindcss.com"></script> |
|||
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script> |
|||
<script> |
|||
tailwind.config = { |
|||
theme: { |
|||
extend: { |
|||
colors: { |
|||
clifford: '#da373d', |
|||
} |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style type="text/tailwindcss"> |
|||
@layer utilities { |
|||
.content-auto { |
|||
content-visibility: auto; |
|||
} |
|||
} |
|||
</style> |
|||
</head> |
|||
|
|||
<body> |
|||
<div class="flex justify-center items-center h-screen bg-blue-500"> |
|||
<div class="bg-white p-8 rounded-lg"> |
|||
<img src="/wms/assets/img/logo.png" alt="LOGO" class="mb-4 mx-auto w-[350]"> |
|||
<h1 class="text-2xl font-bold mb-4 text-center">開發連結</h1> |
|||
<ul> |
|||
<li class="p-3 text-cyan-700"> |
|||
<a href="/wms">wms</a> |
|||
</li> |
|||
<li class="p-3 text-cyan-700"> |
|||
<a href="/app">app</a> |
|||
</li> |
|||
<li class="p-3 text-cyan-700"> |
|||
<a href="http://10.10.1.3/phpmyadmin" target="_blank">開發用資料庫</a> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
</div> |
|||
</body> |
|||
|
|||
</html> |
@ -1,75 +1,153 @@ |
|||
<?php |
|||
$id= ""; |
|||
$accounttype= ""; |
|||
$accountid= ""; |
|||
$pwd= ""; |
|||
$name= ""; |
|||
$tel= ""; |
|||
$address= ""; |
|||
$email= ""; |
|||
$lineid= ""; |
|||
$wechatid= ""; |
|||
$phone_call_help= ""; |
|||
$chat_for_help= ""; |
|||
$remote_help= ""; |
|||
$repairerid= ""; |
|||
$manager= ""; |
|||
$creater= ""; |
|||
$create_at= ""; |
|||
$id = ""; |
|||
$accounttype = ""; |
|||
$accountid = ""; |
|||
$pwd = ""; |
|||
$name = ""; |
|||
$tel = ""; |
|||
$address = ""; |
|||
$email = ""; |
|||
$lineid = ""; |
|||
$wechatid = ""; |
|||
$phone_call_help = ""; |
|||
$chat_for_help = ""; |
|||
$remote_help = ""; |
|||
$repairerid = ""; |
|||
$manager = ""; |
|||
$creater = ""; |
|||
$create_at = ""; |
|||
|
|||
|
|||
|
|||
$id_error = ""; |
|||
$accounttype_error= ""; |
|||
$accountid_error= ""; |
|||
$pwd_error= ""; |
|||
$name_error= ""; |
|||
$tel_error= ""; |
|||
$address_error= ""; |
|||
$email_error= ""; |
|||
$lineid_error= ""; |
|||
$wechatid_error= ""; |
|||
$phone_call_help_error= ""; |
|||
$chat_for_help_error= ""; |
|||
$remote_help_error= ""; |
|||
$repairerid_error= ""; |
|||
$manager_error= ""; |
|||
$creater_error= ""; |
|||
$create_at_error= ""; |
|||
$accounttype_error = ""; |
|||
$accountid_error = ""; |
|||
$pwd_error = ""; |
|||
$name_error = ""; |
|||
$tel_error = ""; |
|||
$address_error = ""; |
|||
$email_error = ""; |
|||
$lineid_error = ""; |
|||
$wechatid_error = ""; |
|||
$phone_call_help_error = ""; |
|||
$chat_for_help_error = ""; |
|||
$remote_help_error = ""; |
|||
$repairerid_error = ""; |
|||
$manager_error = ""; |
|||
$creater_error = ""; |
|||
$create_at_error = ""; |
|||
$department_id_error = ""; |
|||
$role_id_error = ""; |
|||
|
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
include "account-user-input.php"; |
|||
|
|||
$db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, department_id, role_id, creater, create_at) VALUES "; |
|||
$db_query .= "('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$department_id', '$role_id', '$creater', '$create_at')"; |
|||
$result = mysqli_query($link,$db_query); |
|||
include "account-user-input.php"; |
|||
|
|||
// 新增權限 |
|||
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M"|| $accounttype == "W") && $department_id && $role_id) { |
|||
$db_query = "insert into account_auth (accountid, permission) "; |
|||
$db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'"; |
|||
$res = mysqli_query($link, $db_query); |
|||
// 檢查連接是否成功 |
|||
if ($link->connect_errno) { |
|||
echo "連接 MySQL 失敗:" . $link->connect_error; |
|||
exit(); |
|||
} |
|||
|
|||
// mysqli_insert_id可以抓到第一筆的id |
|||
//$new_id= mysqli_insert_id ($link); |
|||
#echo "新增後的id為 {$id} "; |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
// 如果有一筆以上代表有更新 |
|||
echo "<script>"; |
|||
echo "alert('新增成功');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
// 開始事務 |
|||
$link->begin_transaction(); |
|||
try { |
|||
|
|||
if (in_array($accounttype, ["B", "E", "M", "W"])) { |
|||
if (empty($department_id)) { |
|||
$department_id_error = "部門未填寫"; |
|||
throw new Exception('部門未填寫'); |
|||
} |
|||
if (empty($role_id)) { |
|||
$role_id_error = "職別未填寫"; |
|||
throw new Exception('職別未填寫'); |
|||
} |
|||
} |
|||
|
|||
|
|||
// 新增帳號 table account |
|||
$sql = "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( |
|||
?,?,?,?,?,?,?,?,?,?, |
|||
?,?,?,?,?,?,?,? |
|||
) |
|||
"; |
|||
$stmt = $link->prepare($sql); |
|||
$stmt->bind_param( |
|||
'ssssssssssssssssss', |
|||
$i_data['accounttype'], |
|||
$i_data['accountid'], |
|||
$i_data['pwd'], |
|||
$i_data['name'], |
|||
$i_data['tel'], |
|||
$i_data['address'], |
|||
$i_data['email'], |
|||
$i_data['lineid'], |
|||
$i_data['wechatid'], |
|||
$i_data['phone_call_help'], |
|||
$i_data['chat_for_help'], |
|||
$i_data['remote_help'], |
|||
$i_data['repairerid'], |
|||
$i_data['manager'], |
|||
$i_data['department_id'], |
|||
$i_data['role_id'], |
|||
$i_data['creater'], |
|||
$i_data['create_at'] |
|||
); |
|||
$stmt->execute(); |
|||
|
|||
// 新增權限 table account_auth |
|||
if (in_array($accounttype, ["B", "E", "M", "W"])) { |
|||
$sql = "INSERT INTO account_auth (accountid, permission) |
|||
SELECT '$accountid', permission FROM department WHERE department_id = ? AND role_id = ? |
|||
"; |
|||
$stmt2 = $link->prepare($sql); |
|||
$stmt2->bind_param('ss', $department_id, $role_id); |
|||
$stmt2->execute(); |
|||
} |
|||
|
|||
// 新增帳號 table employee |
|||
$sql = " |
|||
INSERT INTO employee ( |
|||
employee_no, |
|||
depart_no, |
|||
name, |
|||
mail |
|||
)VALUES( |
|||
?, |
|||
?, |
|||
?, |
|||
? |
|||
); |
|||
"; |
|||
$stmt3 = $link->prepare($sql); |
|||
$stmt3->bind_param('ssss', $i_data['accountid'], $i_data['department_id'], $i_data['name'], $i_data['email']); |
|||
$stmt3->execute(); |
|||
|
|||
$link->commit(); |
|||
|
|||
$url = "location.href='account-index.php?function_name=account&" . $token_link . "';"; |
|||
redircetTo($url); |
|||
} catch (Exception $e) { |
|||
// 如果發生任何錯誤,回滾事務 |
|||
$link->rollback(); |
|||
// echo "rollback:" . $e->getMessage(); |
|||
} |
|||
|
|||
// 關閉連接 |
|||
$link->close(); |
|||
} |
|||
|
|||
|
|||
function redircetTo($url) |
|||
{ |
|||
echo "<script type='text/JavaScript'>"; |
|||
echo "alert('新增失敗');"; |
|||
echo "location.href='" . $url . "';"; |
|||
echo "</script>"; |
|||
} |
|||
?> |
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue