Verified Commit 3e69142c authored by Kiryuu Sakuya's avatar Kiryuu Sakuya 🎵
Browse files

Update admin.php

parent e74b132c
......@@ -83,6 +83,12 @@
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<div class="container">
<div class="alert alert-warning" role="alert">
本页面还在无限期工事中,如需增加和搜索请访问<a href="/old/" class="alert-link">旧管理后台</a>,谢谢!
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<h1 class="mt-5">Admin Page</h1>
<div class="d-flex justify-content-between input-group">
<div class="dropdown">
......@@ -100,7 +106,7 @@
</div>
<div class="mt-1 mt-md-0" role="toolbar" aria-label="Basic example">
<button type="button" class="btn btn-primary">Add</button>
<button type="button" class="btn btn-success">Modify</button>
<button type="button" class="btn btn-success" checked="checked">Modify</button>
<button type="button" class="btn btn-danger">Delete</button>
</div>
<form class="form-inline mt-2 mt-md-0">
......@@ -265,7 +271,7 @@
</div>
</footer>
<script crossorigin="anonymous" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" src="https://lib.baomitu.com/jquery/3.4.1/jquery.slim.min.js"></script>
<script crossorigin="anonymous" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" src="https://lib.baomitu.com/jquery/3.4.1/jquery.min.js"></script>
<script crossorigin="anonymous" integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" src="https://lib.baomitu.com/twitter-bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
<script src="../js/bootstable.js"></script>
<script src="../js/admin.js"></script>
......
(function() {
function checkTime(i) {
return (i < 10) ? "0" + i : i;
}
var Moment = "sale_item";
(
function() {
function checkTime(i) {
return (i < 10) ? "0" + i : i;
}
function startTime() {
var today = new Date(),
h = checkTime(today.getHours()),
m = checkTime(today.getMinutes()),
s = checkTime(today.getSeconds());
document.getElementById('time').innerHTML = h + ":" + m + ":" + s;
t = setTimeout(function() {
startTime()
}, 500);
}
startTime();
function startTime() {
var today = new Date(),
h = checkTime(today.getHours()),
m = checkTime(today.getMinutes()),
s = checkTime(today.getSeconds());
document.getElementById('time').innerHTML = h + ":" + m + ":" + s;
t = setTimeout(function() {
startTime()
}, 500);
}
startTime();
function switchTables() {
$(document).ready(function() {
$('.dropdown-table-content').hide();
$('#sale_item').show();
$(".dropdown-item").click(function() {
function switchTables() {
$(document).ready(function() {
$('.dropdown-table-content').hide();
$('#' + $(this).data("target")).show();
});
}).change();
}
switchTables();
modifyTables();
$('#sale_item').show();
$(".dropdown-item").click(function() {
//$('.dropdown-table-content').style.position = "static";
//$('.dropdown-table-content').style.zIndex = "1";
$('.dropdown-table-content').hide();
$('#' + $(this).data("target")).show();
Moment = $(this).data("target");
//$('#' + $(this).data("target")).style.zIndex = "2";
});
}).change();
}
switchTables();
function modifyTable() {
$(document).ready(function() {
// IF Statement to check current table?
$('#sale_item').SetEditable({
// Also, when choose current table multiple times, this will overlay.
columnsEd: "0,1,2,3,4,5",
onEdit: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
var prod_id = columnsEd[0].childNodes[3].innerHTML;
var qty = columnsEd[0].childNodes[5].innerHTML;
var unit_price = columnsEd[0].childNodes[7].innerHTML;
var order_date = columnsEd[0].childNodes[9].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, prod_id: prod_id, qty: qty, unit_price: unit_price, order_date: order_date, action: 'edit' },
success: function(response) {
if (response.status) {
// show update message
}
}
function modifyButton() {
$('.btn-success').click(function() {
var $input = $(this).find('input');
$(this).toggleClass('btn-dark btn-success');
if ($(this).hasClass('btn-dark')) {
$input.removeAttr('checked');
modifyTable();
// In the else part, there is a bug.
//$(this).prop("disabled", true);
} else {
// Bug warning, this can't be turn off
$input.attr('checked', '');
alert("Do not turn off this! Bug here.");
  • 在这里预计取消掉 bootstable.js 所做的向表中添加按钮的更改,但是基于目前水平无法实现。

Please register or sign in to reply
//$('#employee').off("modifyTable");
}
})
}
modifyButton();
function modifyTable() {
switch (Moment) {
case "sale_item":
$('#sale_item').SetEditable({
columnsEd: "0,1,2,3,4",
onEdit: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
var prod_id = columnsEd[0].childNodes[3].innerHTML;
var qty = columnsEd[0].childNodes[5].innerHTML;
var unit_price = columnsEd[0].childNodes[7].innerHTML;
var order_date = columnsEd[0].childNodes[9].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, prod_id: prod_id, qty: qty, unit_price: unit_price, order_date: order_date, action: 'edit' },
success: function(response) {
if (response.status) {
// show update message
}
}
});
},
onBeforeDelete: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, action: 'delete' },
success: function(response) {
if (response.status) {
// show delete message
}
}
});
},
});
break;
case "employee":
$('#employee').SetEditable({
columnsEd: "0,1,2,3,4,5,6,7,8",
onEdit: function(columnsEd) {
var emp_no = columnsEd[0].childNodes[1].innerHTML;
var emp_name = columnsEd[0].childNodes[3].innerHTML;
var emp_sex = columnsEd[0].childNodes[5].innerHTML;
var emp_dept = columnsEd[0].childNodes[7].innerHTML;
var emp_title = columnsEd[0].childNodes[9].innerHTML;
var emp_date_hired = columnsEd[0].childNodes[11].innerHTML;
var emp_birthday = columnsEd[0].childNodes[13].innerHTML;
var emp_salary = columnsEd[0].childNodes[15].innerHTML;
var emp_addr = columnsEd[0].childNodes[17].innerHTML;
$.ajax({
type: 'POST',
url: "action_customer.php",
dataType: "json",
data: { emp_no: emp_no, emp_name: emp_name, emp_sex: emp_sex, emp_dept: emp_dept, emp_title: emp_title, emp_date_hired: emp_date_hired, emp_birthday: emp_birthday, emp_salary: emp_salary, emp_addr: emp_addr, action: 'edit' },
success: function(response) {
if (response.status) {
alert("Modify Success");
}
}
});
},
onBeforeDelete: function(columnsEd) {
var emp_no = columnsEd[0].childNodes[1].innerHTML;
$.ajax({
type: 'POST',
url: "action_customer.php",
dataType: "json",
data: { emp_no: emp_no, action: 'delete' },
success: function(response) {
if (response.status) {
alert("Delete Success");
}
}
});
},
});
break;
case "product":
$('#product').SetEditable({
columnsEd: "0,1",
onEdit: function(columnsEd) {
var prod_id = columnsEd[0].childNodes[1].innerHTML;
var prod_name = columnsEd[0].childNodes[3].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { prod_id: prod_id, prod_name: prod_name, action: 'edit' },
success: function(response) {
if (response.status) {
// show update message
}
}
});
},
onBeforeDelete: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, action: 'delete' },
success: function(response) {
if (response.status) {
// show delete message
}
}
});
},
});
break;
case "sales":
$('#sales').SetEditable({
columnsEd: "0,1,2,3,4,5,6",
onEdit: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
var cust_id = columnsEd[0].childNodes[3].innerHTML;
var sale_id = columnsEd[0].childNodes[5].innerHTML;
var tot_amt = columnsEd[0].childNodes[7].innerHTML;
var order_date = columnsEd[0].childNodes[9].innerHTML;
var ship_date = columnsEd[0].childNodes[11].innerHTML;
var invoice_no = columnsEd[0].childNodes[13].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, cust_id: cust_id, sale_id: sale_id, tot_amt: tot_amt, order_date: order_date, ship_date: ship_date, invoice_no: invoice_no, action: 'edit' },
success: function(response) {
if (response.status) {
// show update message
}
}
});
},
onBeforeDelete: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, action: 'delete' },
success: function(response) {
if (response.status) {
// show delete message
}
}
});
},
});
},
onBeforeDelete: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, action: 'delete' },
success: function(response) {
if (response.status) {
// show delete message
}
}
break;
case "customer":
$('#customer').SetEditable({
columnsEd: "0,1,2,3,4",
onEdit: function(columnsEd) {
var cust_id = columnsEd[0].childNodes[1].innerHTML;
var cust_name = columnsEd[0].childNodes[3].innerHTML;
var addr = columnsEd[0].childNodes[5].innerHTML;
var tel_no = columnsEd[0].childNodes[7].innerHTML;
var zip = columnsEd[0].childNodes[9].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { cust_id: cust_id, cust_name: cust_name, addr: addr, tel_no: tel_no, zip: zip, action: 'edit' },
success: function(response) {
if (response.status) {
// show update message
}
}
});
},
onBeforeDelete: function(columnsEd) {
var order_no = columnsEd[0].childNodes[1].innerHTML;
$.ajax({
type: 'POST',
url: "action.php",
dataType: "json",
data: { order_no: order_no, action: 'delete' },
success: function(response) {
if (response.status) {
// show delete message
}
}
});
},
});
},
});
});
deleteTables();
}
})();
\ No newline at end of file
break;
}
}
})();
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment