-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsumable.php
200 lines (163 loc) · 5.47 KB
/
consumable.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
session_start();
echo '<html>';
echo '<head>';
echo '</head>';
echo '<body>';
/*echo '<pre>';
print_r($GLOBALS);
echo '</pre>';*/
include 'common.php';
if(!login_varify())
{
exit();
}
main_menu();
$source_of_information=array(
'Reagent',
'Instrument',
'Glassware/Plasticware',
'Linen',
'Unclassified'
);
function read_new_Item()
{
global $source_of_information;
echo '<table bgcolor=lightgreen border=1><tr>';
echo '<td colspan=10><h1>Inventory</h1></td></tr>';
echo '<form method=post>';
//20111231246060
echo '<tr><td bgcolor=lightpink><input type=submit name=action value=show_Item></td></tr>';
echo '
<tr><td bgcolor=lightblue>source_of_information</td><td>';
mk_select_from_array_return_value('source_of_information',$source_of_information,'','');
echo ' </td></tr>
<tr><td bgcolor=lightblue>Item_Name</td><td><textarea name=Item_Name rows=2 cols=80></textarea></td></tr>
<tr><td bgcolor=lightblue>Specification</td><td><textarea name=Specification rows=5 cols=80></textarea></tr>
<tr><td bgcolor=lightblue>Details</td><td><textarea name=Details rows=5 cols=80></textarea></tr>
<tr><td bgcolor=lightpink><input type=submit name=action value=save_new_Item></td></tr>';
echo '</form>';
echo '</table>';
}
function save_new_Item()
{
global $source_of_information;
//12345678901234
//yyyymmddhhmmss
//INSERT INTO `Inventory_record`(`source_of_information`, `Item_Name`, `Specification`, `Details`) VALUES ([value-1],[value-2],[value-3],[value-4])
//printf("%s",$nonconformity_id);
//print_r($_POST);
$sql='insert into Inventory_record values(
\''.$Inventory_ID.'\',
\''.$_POST['source_of_information'].'\',
\''.$_POST['Item_Name'].'\',
\''.$_POST['Specification'].'\',
\''.$_POST['Details'].'\'
)';
$link=start_nchsls();
if(!$result=mysql_query($sql,$link))
{
echo mysql_error();
}
}
function read_edit_Item()
{
global $source_of_information;
$Inventory_ID = $_POST['Inventory_ID'];
$Item_Name = $_POST['Item_Name'];
$Specification = $_POST['Specification'];
$Details = $_POST['Details'];
echo '<table bgcolor=lightgreen border=1><tr>';
echo '<td colspan=10><h1>Edit Item</h1></td></tr>';
echo '<form method=post>';
//20111231246060
echo ' <tr><td bgcolor=lightblue>Inventory_ID</td><td><textarea readonly name=Inventory_ID rows=1 cols=15>'.$Inventory_ID.'</textarea></td></tr>
<tr><td bgcolor=lightblue>source_of_information</td><td>';
mk_select_from_array_return_value('source_of_information',$source_of_information,'','');
echo ' </td></tr>
<tr><td bgcolor=lightblue>Item_Name</td><td><textarea name=Item_Name rows=5 cols=80>'.$Item_Name.'</textarea></td></tr>
<tr><td bgcolor=lightblue>Specification</td><td><textarea name=Specification rows=2 cols=80>'.$Specification.'</textarea></tr>
<tr><td bgcolor=lightblue>Details</td><td><textarea name=Details rows=2 cols=80>'.$Details.'</textarea></tr>
<tr><td bgcolor=lightpink><input type=submit name=action value=save_edit_Item></td></tr>';
echo '</form>';
echo '</table>';
}
function save_edit_Item()
{
$sql='update Inventory_record set
source_of_information=\''.$_POST['source_of_information'].'\',
Item_Name=\''.$_POST['Item_Name'].'\',
Specification=\''.$_POST['Specification'].'\',
Details=\''.$_POST['Details'].'\'
where
Inventory_ID=\''.$_POST['Inventory_ID'].'\'
';
//echo $sql;
$link=start_nchsls();
if(!$result=mysql_query($sql,$link))
{
echo mysql_error();
}
}
function show_Item()
{
$sql='select * from Inventory_record where Inventory_ID>
\''.$Inventory_ID.'\' order by Inventory_ID desc limit 100';
//echo $sql;
$link=start_nchsls();
if(!$result=mysql_query($sql,$link))
{
echo mysql_error();
}
echo '<table><tr bgcolor=lightpink><th colspan=20 >Inventory Records</th></tr>
<tr>
<td bgcolor=lightblue>Inventory_ID</td>
<td bgcolor=lightblue>source</td>
<td bgcolor=lightblue>Item_Name</td>
<td bgcolor=lightblue>Specification</td>
<td bgcolor=lightblue>Details</td>
</tr>';
while($array=mysql_fetch_assoc($result))
{
//print_r($array);
echo '<form method=post>';
echo '
<tr>
<td valign=top><button type=submit name=action value=read_edit_Item>'.$array['Inventory_ID'].'</button></td>
<input type=hidden name=Inventory_ID value=\''.$array['Inventory_ID'].'\'>
<td valign=top><textarea readonly name=source_of_information rows=4 cols=20>'.$array['source_of_information'].'</textarea></td>
<td valign=top><textarea readonly name=Item_Name rows=4 cols=40>'.$array['Item_Name'].'</textarea></td>
<td valign=top><textarea readonly name=Specification rows=4 cols=20>'.$array['Specification'].'</textarea>
<td valign=top><textarea readonly name=Details rows=4 cols=20>'.$array['Details'].'</textarea>
</tr>';
echo '</form>';
}
echo '</table>';
}
if(!isset($_POST['action']))
{
read_new_Item();
}
else
{
if($_POST['action']=='show_Item')
{
read_new_Item();
show_Item();
}
if($_POST['action']=='save_new_Item')
{
save_new_Item();
read_new_Item();
}
if($_POST['action']=='read_edit_Item')
{
read_edit_Item();
}
if($_POST['action']=='save_edit_Item')
{
save_edit_Item();
read_new_Item();
}
}
?>