-
Notifications
You must be signed in to change notification settings - Fork 2
/
list_product.php
154 lines (145 loc) · 5.25 KB
/
list_product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/**
* Created by PhpStorm.
* User: Think
* Date: 2015/10/18
* Time: 14:46
*/
require_once('sql/mysql.php');
require_once('sql/operate.php');
session_start();
$user = $_SESSION['user'];
$level = $_SESSION[$user];
$db = new \sql\MysqlPDO($level);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>产品列表</title>
<link type="text/css" rel="stylesheet" href="res/css/custom/list.css">
<link type="text/css" rel="stylesheet" href="res/css/custom/button.css">
<script type="text/javascript" src="res/libs/jquery/jquery-2.2.0.min.js"></script>
<script>
function addCol() {
$col = $("<td>删除</td>");
$("#product>tbody>tr").append($col);
}
function edit() {
var line = document.getElementById("product").getElementsByTagName("tr");
for (var i = 0; i < line.length - 2; i++) {
var td = line[i + 1].getElementsByTagName("td")[0];
var value = td.innerText;
td.innerHTML = "<a href=edit_product.php?material_num=" + value + ">" + value + "<a>";
}
}
function doDel(id) {
if (confirm("确定要删除吗?")) {
window.location = 'data/action_product.php?action=del&id=' + id;
}
}
function addCraft(id) {
if (confirm("确定添加?")) {
window.location = 'data/add_craft.php?id=' + id;
}
}
function report(id) {
window.location = 'data/generate_report.php?id=' + id;
}
function scan(id) {
window.location = 'data/control_panel?id=' + id;
}
$('#account_list')
</script>
</head>
<body>
<h1 align="center">产品目录</h1>
<div align="center">
<form action="add/add_product.html" method="post">
<table id="product" class="show-list ">
<?php
// $head = array(
// '物料编码',
// '产品名称',
// '产品型号',
// );
// $key = array(
// 'material_num',
// 'name',
// 'model'
// );
// $data = $db->get_choice_select(PRODUCT, $key);
// if ($data == null) {
// simple_table($head);
// } else {
// $temp = two_key_value($key, $data);
// simple_table($head, $temp);
// }
// ?>
<tr>
<th>物料编码</th>
<th>工艺编号</th>
<th>产品名称</th>
<th>产品型号</th>
<th>产品类别</th>
<th>工艺类型</th>
<th>编辑</th>
</tr>
<tr>
<?php
$key = array(
'id',
'material_num',
'craft_num',
'name',
'model',
'belong',
'craft_type'
);
$data = $db->get_choice_select(PRODUCT, $key);
if ($data == null) {
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td> </td>";
} else {
$list = two_key_value($key, $data);
foreach ($list as $cell) {
foreach ($cell as $name => $value) {
if ($name != 'id') {
echo "<td>{$value}</td>";
}
}
echo "<td>
<a href='edit/edit_product.php?id={$cell['id']}'>编辑</a>
<a href='javascript:addCraft({$cell['id']})'>添加工艺</a>
<a href='javascript:scan({$cell['id']})'>查看</a>
<a href='javascript:report({$cell['id']})'>报表</a>
<a href='javascript:doDel({$cell['id']})'>删除</a>
</td>";
echo "</tr>";
}
}
?>
<tr>
<td><input type="text" name="material_num" required="required"></td>
<td><input type="text" name="craft_num" required="required"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<div class="list-button">
<input class="button white" type="submit" value="提交">
<input class="button white" type="reset" value="重置">
<input class="button white" type="button" onclick="edit()" value="编辑">
</div>
</form>
</div>
</body>
</html>