31 changed files with 534 additions and 2171 deletions
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 2.6 KiB |
@ -0,0 +1,3 @@ |
|||
[ZoneTransfer] |
|||
ZoneId=3 |
|||
HostUrl=http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css |
@ -0,0 +1,3 @@ |
|||
[ZoneTransfer] |
|||
ZoneId=3 |
|||
HostUrl=https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css |
Binary file not shown.
@ -0,0 +1,3 @@ |
|||
[ZoneTransfer] |
|||
ZoneId=3 |
|||
HostUrl=http://code.jquery.com/jquery-1.9.1.js |
@ -0,0 +1,3 @@ |
|||
[ZoneTransfer] |
|||
ZoneId=3 |
|||
HostUrl=http://code.jquery.com/ui/1.10.4/jquery-ui.js |
@ -0,0 +1,3 @@ |
|||
[ZoneTransfer] |
|||
ZoneId=3 |
|||
HostUrl=https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js |
@ -1,302 +1,95 @@ |
|||
<style> |
|||
input, |
|||
select { |
|||
margin: 0 0 !important; |
|||
vertical-align: middle !important; |
|||
} |
|||
|
|||
.mybutton { |
|||
padding: 3px !important; |
|||
} |
|||
</style> |
|||
|
|||
<?php |
|||
include "header.php"; |
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
include "header.php"; |
|||
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
|||
|
|||
// sql语法存在变数中 |
|||
$db_query = "SELECT * FROM menu WHERE id = $id"; |
|||
// 用mysqli_query方法执行(sql语法)将结果存在变数中 |
|||
$result = mysqli_query($link, $db_query); |
|||
$data = mysqli_fetch_assoc($result); |
|||
mysqli_free_result($result); |
|||
$data = array(); |
|||
// sql语法存在变数中 |
|||
$db_query = "SELECT * FROM menu WHERE id = $id"; |
|||
// 用mysqli_query方法执行(sql语法)将结果存在变数中 |
|||
$data = mysqli_query($link, $db_query); |
|||
|
|||
$db_query = " |
|||
SELECT * FROM department |
|||
ORDER BY department_id ASC |
|||
"; |
|||
$result = mysqli_query($link, $db_query); |
|||
$data2 = mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
mysqli_free_result($result); |
|||
|
|||
//$link_content = str_replace(',', PHP_EOL, $data['link_content']); |
|||
foreach($data as $data) : |
|||
//$link_content = str_replace(',', PHP_EOL, $data['link_content']); |
|||
?> |
|||
<script> |
|||
$(function () { |
|||
|
|||
}); |
|||
</script> |
|||
<div class="container"> |
|||
<form class="form-inline" method="post" action="menu-record-update.php"> |
|||
<input type="hidden" name="id" value="<?php echo $id; ?>"> |
|||
<div class="row col-md-12 col-sm-12"> |
|||
<div class="col-md-2 col-sm-12"> |
|||
<label for="main_menu">主功能名稱</label> |
|||
<input type="text" name="main_menu" id="main_menu" value="<?php echo $data['main_menu']; ?>" required> |
|||
</div> |
|||
<div class="col-md-2 col-sm-12"> |
|||
<label for="main_menu_seq">主功能排序</label> |
|||
<select name="main_menu_seq" id="main_menu_seq"> |
|||
<?php |
|||
for ($i = 1; $i < 21; $i++) { |
|||
echo '<option value="' . $i . '"'; |
|||
if ($i == $data["main_menu_seq"]) echo " selected"; |
|||
echo '>' . $i . '</option>'; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div class="col-md-2 col-sm-12"> |
|||
<label for="sub_menu">子功能名稱</label> |
|||
<input type="text" name="sub_menu" id="sub_menu" value="<?php echo $data['sub_menu']; ?>" required> |
|||
</div> |
|||
<div class="col-md-2 col-sm-12"> |
|||
<label for="sub_menu_seq">子功能排序</label> |
|||
<select name="sub_menu_seq" id="sub_menu_seq"> |
|||
<?php |
|||
for ($i = 1; $i < 21; $i++) { |
|||
echo '<option value="' . $i . '"'; |
|||
if ($i == $data["sub_menu_seq"]) echo " selected"; |
|||
echo '>' . $i . '</option>'; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div class="col-md-2 col-sm-12"> |
|||
<label for="sub_menu_eng">子功能英文名</label> |
|||
<input type="text" name="sub_menu_eng" id="sub_menu_eng" value="<?php echo $data['sub_menu_eng']; ?>" required> |
|||
</div> |
|||
<div class="col-md-2 col-sm-12"> |
|||
<label for="mlink">主網址</label> |
|||
<input type="text" name="mlink" id="mlink" size="30" value="<?php echo $data['mlink']; ?>" required> |
|||
</div> |
|||
<div class="col-md-4 col-sm-12"> |
|||
<label for="status">狀態</label> |
|||
<select name="status" id="status"> |
|||
<option value="N" <?php if ($data["status"] == "N") echo " selected"; ?>>隱藏</option> |
|||
<!--<option value="T"<?php if ($data["status"] == "T") echo " selected"; ?>>測試</option>--> |
|||
<option value="Y" <?php if ($data["status"] == "Y") echo " selected"; ?>>正常</option> |
|||
</select> |
|||
</div> |
|||
<div class="col-md-4 col-sm-12"> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
<div class="col-md-12 col-sm-12" style="margin-top:15px;"> |
|||
<label class='col-md-12' for="link_content">程式列表</label> |
|||
<textarea name="link_content" id="link_content" rows="10" cols="60" class="form-control" required><?php echo $data['link_content']; ?></textarea> |
|||
</div> |
|||
<div> |
|||
<label for="main_menu">主功能名稱</label> |
|||
<input type="text" name="main_menu" id="main_menu" value="<?php echo $data['main_menu']; ?>" required> |
|||
</div> |
|||
|
|||
<div class="row col-md-12 col-sm-12" style="margin-top:15px;"> |
|||
<div class="col-md-4 col-sm-12"> |
|||
<label class='col-md-12' for="selectL1">可讀權限</label> |
|||
<select multiple="multiple" id="selectL1" style="width:100%;height:300px; border:4px #A0A0A4 outset; padding:4px; "> |
|||
<?php |
|||
foreach ($data2 as $row) { |
|||
$menu_permission = json_decode($row['permission']); |
|||
$status = false; |
|||
foreach ($menu_permission as $key => $value) { |
|||
if ($key == $data['mlink'] && in_array($value, ['1'])) { |
|||
$status = true; |
|||
break; |
|||
} |
|||
} |
|||
if (!$status) |
|||
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div class="col-md-1 col-sm-12"> |
|||
<label class='col-md-12' for="add"> </label> |
|||
<button id="add1" type="button" class="btn mybutton">添加</button> |
|||
<button id="remove1" type="button" class="btn mybutton">移除</button> |
|||
<button id="add_all1" type="button" class="btn mybutton">全部添加</button> |
|||
<button id="remove_all1" type="button" class="btn mybutton">全部移除</button> |
|||
</div> |
|||
<div class="col-md-4 col-sm-12"> |
|||
<label class='col-md-12' for="selectR1"> </label> |
|||
<select multiple="multiple" id="selectR1" name="can_read[]" style="width:100%;height:300px;;border:4px #A0A0A4 outset; padding:4px;"> |
|||
<?php |
|||
foreach ($data2 as $row) { |
|||
$menu_permission = json_decode($row['permission']); |
|||
foreach ($menu_permission as $key => $value) { |
|||
if ($key == $data['mlink'] && in_array($value, ['1'])) { |
|||
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>"; |
|||
} |
|||
} |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="main_menu_seq">主功能排序</label> |
|||
<select name="main_menu_seq" id="main_menu_seq"> |
|||
<?php |
|||
for ($i=1;$i<21;$i++) { |
|||
echo '<option value="'.$i.'"'; |
|||
if ($i == $data["main_menu_seq"]) echo " selected"; |
|||
echo '>'.$i.'</option>'; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
|
|||
<div class="row col-md-12 col-sm-12" style="margin-top:15px;"> |
|||
<div class="col-md-4 col-sm-12"> |
|||
<label class='col-md-12' for="selectL2">可寫權限</label> |
|||
<select multiple="multiple" id="selectL2" style="width:100%;height:300px; border:4px #A0A0A4 outset; padding:4px; "> |
|||
<?php |
|||
foreach ($data2 as $row) { |
|||
$menu_permission = json_decode($row['permission']); |
|||
$status = false; |
|||
foreach ($menu_permission as $key => $value) { |
|||
if ($key == $data['mlink'] && in_array($value, ['2', '3'])) { |
|||
$status = true; |
|||
break; |
|||
} |
|||
} |
|||
if (!$status) |
|||
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>"; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div class="col-md-1 col-sm-12"> |
|||
<label class='col-md-12' for="add"> </label> |
|||
<button id="add2" type="button" class="btn mybutton">添加</button> |
|||
<button id="remove2" type="button" class="btn mybutton">移除</button> |
|||
<button id="add_all2" type="button" class="btn mybutton">全部添加</button> |
|||
<button id="remove_all2" type="button" class="btn mybutton">全部移除</button> |
|||
</div> |
|||
<div class="col-md-4 col-sm-12"> |
|||
<label class='col-md-12' for="selectR2"> </label> |
|||
<select multiple="multiple" id="selectR2" name="can_write[]" style="width:100%;height:300px;;border:4px #A0A0A4 outset; padding:4px;"> |
|||
<?php |
|||
foreach ($data2 as $row) { |
|||
$menu_permission = json_decode($row['permission']); |
|||
foreach ($menu_permission as $key => $value) { |
|||
if ($key == $data['mlink'] && in_array($value, ['2', '3'])) { |
|||
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>"; |
|||
} |
|||
} |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="sub_menu">子功能名稱</label> |
|||
<input type="text" name="sub_menu" id="sub_menu" value="<?php echo $data['sub_menu']; ?>" required> |
|||
</div> |
|||
|
|||
<div class="row col-md-12 col-sm-12"> |
|||
<div class="col-md-12 col-sm-12"> |
|||
<button class="pull-right" type="submit" name="update" id="update_btn" disabled>請先鎖定再提交</button> |
|||
<button class="pull-right" type="button" onclick="lockAuthSelect()">鎖定權限</button> |
|||
</div> |
|||
<div> |
|||
<label for="sub_menu_seq">子功能排序</label> |
|||
<select name="sub_menu_seq" id="sub_menu_seq"> |
|||
<?php |
|||
for ($i=1;$i<21;$i++) { |
|||
echo '<option value="'.$i.'"'; |
|||
if ($i == $data["sub_menu_seq"]) echo " selected"; |
|||
echo '>'.$i.'</option>'; |
|||
} |
|||
?> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="sub_menu_eng">子功能英文名</label> |
|||
<input type="text" name="sub_menu_eng" id="sub_menu_eng" value="<?php echo $data['sub_menu_eng']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="mlink">主網址</label> |
|||
<input type="text" name="mlink" id="mlink" size="30" value="<?php echo $data['mlink']; ?>" required> |
|||
</div> |
|||
<div> |
|||
<label for="link_content">程式列表</label> |
|||
<textarea name="link_content" id="link_content" rows="10" cols="60" class="form-control" required><?php echo $data['link_content']; ?></textarea> |
|||
</div> |
|||
<div> |
|||
<label for="status">狀態</label> |
|||
<select name="status" id="status"> |
|||
<option value="N"<?php if ($data["status"]=="N") echo " selected"; ?>>隱藏</option> |
|||
<!--<option value="T"<?php if ($data["status"]=="T") echo " selected"; ?>>測試</option>--> |
|||
<option value="Y"<?php if ($data["status"]=="Y") echo " selected"; ?>>正常</option> |
|||
</select> |
|||
</div> |
|||
<div> |
|||
<label for="creater">建檔人</label> |
|||
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly> |
|||
</div> |
|||
|
|||
|
|||
<div> |
|||
<br> |
|||
<button type="submit" name="update">確定</button> |
|||
</div> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>"> |
|||
</form> |
|||
</div> |
|||
|
|||
<script> |
|||
$(function() { |
|||
lrSelectChange('selectL', 'selectR', '1'); |
|||
lrSelectChange('selectL', 'selectR', '2'); |
|||
}); |
|||
|
|||
function lockAuthSelect() { |
|||
$("#selectR1 option").prop("selected", true); |
|||
$("#selectR2 option").prop("selected", true); |
|||
$("#update_btn").text("提交").removeAttr("disabled"); |
|||
} |
|||
|
|||
function lrSelectChange(lSelect, rSelect, id) { |
|||
lSelect = lSelect + id; |
|||
rSelect = rSelect + id; |
|||
//移到右边 |
|||
$('#add' + id).click(function() { |
|||
//获取选中的选项,删除并追加给对方 |
|||
for (var i = 0; i < $('#' + lSelect + ' option:selected').length; i++) { |
|||
$('#' + lSelect + ' option:selected')[i].text = $('#' + lSelect + ' option:selected')[i].text |
|||
$('#' + lSelect + ' option:selected')[i].value = $('#' + lSelect + ' option:selected')[i].value |
|||
} |
|||
$('#' + lSelect + ' option:selected').appendTo('#' + rSelect); |
|||
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled"); |
|||
}); |
|||
//移到左边 |
|||
$('#remove' + id).click(function() { |
|||
for (var i = 0; i < $('#' + rSelect + ' option:selected').length; i++) { |
|||
$('#' + rSelect + ' option:selected')[i].text = $('#' + rSelect + ' option:selected')[i].text |
|||
$('#' + rSelect + ' option:selected')[i].value = $('#' + rSelect + ' option:selected')[i].value |
|||
} |
|||
$('#' + rSelect + ' option:selected').appendTo('#' + lSelect + ''); |
|||
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled"); |
|||
}); |
|||
//全部移到右边 |
|||
$('#add_all' + id).click(function() { |
|||
for (var i = 0; i < $('#' + lSelect + ' option').length; i++) { |
|||
$('#' + lSelect + ' option')[i].text = $('#' + lSelect + ' option')[i].text |
|||
$('#' + lSelect + ' option')[i].value = $('#' + lSelect + ' option')[i].value |
|||
} |
|||
//获取全部的选项,删除并追加给对方 |
|||
$('#' + lSelect + ' option').appendTo('#' + rSelect + ''); |
|||
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled"); |
|||
}); |
|||
//全部移到左边 |
|||
$('#remove_all' + id).click(function() { |
|||
for (var i = 0; i < $('#' + rSelect + ' option').length; i++) { |
|||
$('#' + rSelect + ' option')[i].text = $('#' + rSelect + ' option')[i].text |
|||
$('#' + rSelect + ' option')[i].value = $('#' + rSelect + ' option')[i].value |
|||
} |
|||
$('#' + rSelect + ' option').appendTo('#' + lSelect + ''); |
|||
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled"); |
|||
}); |
|||
//双击选项,左边到右边 |
|||
$('#' + lSelect + '').dblclick(function() { //绑定双击事件 |
|||
for (var i = 0; i < $('#' + lSelect + ' option:selected').length; i++) { |
|||
$('#' + lSelect + ' option:selected')[i].text = $('#' + lSelect + ' option:selected')[i].text |
|||
$('#' + lSelect + ' option:selected')[i].value = $('#' + lSelect + ' option:selected')[i].value |
|||
} |
|||
$('#' + lSelect + ' option:selected').appendTo('#' + rSelect + ''); |
|||
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled"); |
|||
}); |
|||
//双击选项,右边到左边 |
|||
$('#' + rSelect + '').dblclick(function() { |
|||
for (var i = 0; i < $('#selectR1 option:selected').length; i++) { |
|||
$('#' + rSelect + ' option:selected')[i].text = $('#' + rSelect + ' option:selected')[i].text |
|||
$('#' + rSelect + ' option:selected')[i].value = $('#' + rSelect + ' option:selected')[i].value |
|||
} |
|||
$('#' + rSelect + ' option:selected').appendTo('#' + lSelect + ''); |
|||
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled"); |
|||
}); |
|||
$('#' + rSelect + '').click(function() { |
|||
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled"); |
|||
if ($('#' + rSelect + ' option:selected').length > 1) { //右侧选中多个时,只允许点击一个使其变序 |
|||
return; |
|||
} |
|||
if (($("option:selected", this).text().substring($("option:selected", this).text().length - 4, $("option:selected", this).text().length)) == '(升序)') { |
|||
var a = $("option:selected", this).text(); |
|||
$("option:selected", this).prop('text', a) |
|||
var b = $("option:selected", this).val(); |
|||
b = b.replace("$asc", "$desc") |
|||
$("option:selected", this).prop('value', b) |
|||
return |
|||
} |
|||
if (($("option:selected", this).text().substring($("option:selected", this).text().length - 4, $("option:selected", this).text().length)) == '(降序)') { |
|||
var a = $("option:selected", this).text(); |
|||
$("option:selected", this).prop('text', a) |
|||
var b = $("option:selected", this).val(); |
|||
b = b.replace("$desc", "$asc") |
|||
$("option:selected", this).prop('value', b) |
|||
return |
|||
} |
|||
}); |
|||
} |
|||
|
|||
$(function() { |
|||
|
|||
|
|||
}); |
|||
</script> |
|||
|
|||
<?php |
|||
|
|||
|
|||
|
|||
include "footer.php"; |
|||
endforeach; |
|||
|
|||
include "footer.php"; |
|||
|
|||
?> |
@ -1,172 +1,29 @@ |
|||
<?php |
|||
ini_set('display_errors', 'on'); |
|||
include "header.php"; |
|||
|
|||
$auth_change_status = false; |
|||
|
|||
if (isset($_POST['update'])) { |
|||
|
|||
// foreach ($_POST as $k => $v) { |
|||
// $$k = htmlspecialchars(stripslashes(trim($v))); |
|||
// } |
|||
|
|||
if (!empty($_POST['can_read'])) { |
|||
$auth_change_status = true; |
|||
$link_content = explode("\r\n", $_POST['link_content']); |
|||
foreach ($_POST['can_read'] as $id) { |
|||
|
|||
// 更新部門可寫權限 json |
|||
$permission = []; |
|||
$department_id = 0; |
|||
$role_id = 0; |
|||
|
|||
$sql = " |
|||
SELECT |
|||
department_id, |
|||
role_id, |
|||
permission |
|||
FROM department |
|||
WHERE 1=1 |
|||
AND id = '$id' |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_assoc($result); |
|||
$department_id = $data['department_id']; |
|||
$role_id = $data['role_id']; |
|||
mysqli_free_result($result); |
|||
$permission = json_decode($data['permission'], true); |
|||
foreach ($link_content as $row) { |
|||
$permission[$row] = '1'; |
|||
} |
|||
$new_permiccion = json_encode($permission); |
|||
|
|||
// 更改此職位權限 |
|||
$sql = " |
|||
UPDATE department |
|||
SET permission = '$new_permiccion' |
|||
WHERE 1=1 |
|||
AND id = '$id' |
|||
"; |
|||
mysqli_query($link, $sql); |
|||
|
|||
// 更改此職位底下所有員工的權限 |
|||
$sql = " |
|||
SELECT accountid |
|||
FROM account |
|||
WHERE 1=1 |
|||
AND department_id = '$department_id' |
|||
AND role_id = '$role_id' |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data2 = mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
mysqli_free_result($result); |
|||
foreach ($data2 as $row) { |
|||
$sql = " |
|||
UPDATE account_auth |
|||
SET permission = '$new_permiccion' |
|||
WHERE 1=1 |
|||
AND accountid = '" . $row['accountid'] . "' |
|||
"; |
|||
mysqli_query($link, $sql); |
|||
} |
|||
} |
|||
if(isset($_POST['update'])) { |
|||
foreach ($_POST as $k => $v) { |
|||
$$k = htmlspecialchars(stripslashes(trim($v))); |
|||
} |
|||
|
|||
if (!empty($_POST['can_write'])) { |
|||
$auth_change_status = true; |
|||
$link_content = explode("\r\n", $_POST['link_content']); |
|||
foreach ($_POST['can_write'] as $id) { |
|||
|
|||
// 更新部門可寫權限 json |
|||
$permission = []; |
|||
$department_id = 0; |
|||
$role_id = 0; |
|||
|
|||
$sql = " |
|||
SELECT |
|||
department_id, |
|||
role_id, |
|||
permission |
|||
FROM department |
|||
WHERE 1=1 |
|||
AND id = '$id' |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_assoc($result); |
|||
$department_id = $data['department_id']; |
|||
$role_id = $data['role_id']; |
|||
mysqli_free_result($result); |
|||
$permission = json_decode($data['permission'], true); |
|||
foreach ($link_content as $row) { |
|||
$permission[$row] = '3'; |
|||
} |
|||
$new_permiccion = json_encode($permission); |
|||
|
|||
// 更改此職位權限 |
|||
$sql = " |
|||
UPDATE department |
|||
SET permission = '$new_permiccion' |
|||
WHERE 1=1 |
|||
AND id = '$id' |
|||
"; |
|||
mysqli_query($link, $sql); |
|||
|
|||
// 更改此職位底下所有員工的權限 |
|||
$sql = " |
|||
SELECT accountid |
|||
FROM account |
|||
WHERE 1=1 |
|||
AND department_id = '$department_id' |
|||
AND role_id = '$role_id' |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data2 = mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
mysqli_free_result($result); |
|||
foreach ($data2 as $row) { |
|||
$sql = " |
|||
UPDATE account_auth |
|||
SET permission = '$new_permiccion' |
|||
WHERE 1=1 |
|||
AND accountid = '" . $row['accountid'] . "' |
|||
"; |
|||
mysqli_query($link, $sql); |
|||
} |
|||
} |
|||
} |
|||
$main_menu_seq = empty($_POST['main_menu_seq']) ? '' : $_POST['main_menu_seq']; |
|||
$main_menu = empty($_POST['main_menu']) ? '' : $_POST['main_menu']; |
|||
$sub_menu_seq = empty($_POST['sub_menu_seq']) ? '' : $_POST['sub_menu_seq']; |
|||
$sub_menu = empty($_POST['sub_menu']) ? '' : $_POST['sub_menu']; |
|||
$sub_menu_eng = empty($_POST['sub_menu_eng']) ? '' : $_POST['sub_menu_eng']; |
|||
$mlink = empty($_POST['mlink']) ? '' : $_POST['mlink']; |
|||
$link_content = empty($_POST['link_content']) ? '' : $_POST['link_content']; |
|||
$status = empty($_POST['status']) ? '' : $_POST['status']; |
|||
$id = empty($_POST['id']) ? '' : $_POST['id']; |
|||
$create_at = date('Y-m-d H:i:s'); |
|||
|
|||
//$link_content = str_replace(PHP_EOL, ',', $link_content); |
|||
$db_query = "UPDATE menu set main_menu_seq = '$main_menu_seq', main_menu = '$main_menu', sub_menu_seq = '$sub_menu_seq', sub_menu = '$sub_menu', "; |
|||
$db_query .= "sub_menu_eng = '$sub_menu_eng', mlink = '$mlink', link_content = '$link_content', status = '$status', create_at = '$create_at' WHERE id='$id'"; |
|||
|
|||
mysqli_query($link, $db_query); |
|||
$affected = mysqli_affected_rows($link); |
|||
mysqli_close($link); |
|||
if ($affected > 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('update成功');"; |
|||
echo "location.href='menu-index.php?function_name=menu&" . $token_link . "';"; |
|||
echo "</script>"; |
|||
} elseif ($auth_change_status == true) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('權限調整成功');"; |
|||
echo "location.href='menu-index.php?function_name=menu&" . $token_link . "';"; |
|||
echo "location.href='menu-index.php?function_name=menu&".$token_link."';"; |
|||
echo "</script>"; |
|||
} elseif ($affected == 0) { |
|||
echo "<script type ='text/JavaScript'>"; |
|||
echo "alert('無新增資料');"; |
|||
echo "location.href='menu-index.php?function_name=menu&" . $token_link . "';"; |
|||
echo "</script>"; |
|||
echo "location.href='menu-index.php?function_name=menu&".$token_link."';"; |
|||
echo "</script>"; |
|||
} else { |
|||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
|||
} |
|||
} |
|||
?> |
Loading…
Reference in new issue