-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_item_details.php
376 lines (303 loc) · 10.6 KB
/
upload_item_details.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?php
include 'init.php';
if (logged_in_system()) {
include 'template/header.php';
?>
<h3> Detalles items </h3>
<?php
//Recoger los datos para actualizar
if (isset($_GET['id_itd'])) {
$datos = $_GET['id_itd'];
$obtain_data = "SELECT * FROM items_detail WHERE id_itd='$datos'";
$re = mysql_query($obtain_data) or die("There was an error while obtaining the data") . mysql_error();
while ($campo_act = mysql_fetch_array($re)) {
$id_itd = $campo_act['id_itd'];
$id_item = $campo_act['id_item'];
$id_size = $campo_act['id_size'];
$id_color = $campo_act['id_color'];
$id_qua = $campo_act['id_qua'];
$bclass = 'update';
$enviar_value = 'Actualizar';
}
} else {
$enviar_value = 'Registrar';
$bclass = 'save';
//$limpiar_tb= reset;
}
?>
<?php
//Asking if infomation has beens saved or updated correctly
if (isset($_GET['saved']) == true && $_GET['saved'] == true) {
echo '<div class="success"> La informacion ha sido guardada correctamente </div>';
} else {
if (isset($_GET['updated']) == true && $_GET['updated'] == true) {
echo '<div class="success"> La informacion ha sido actualizada correctamente </div>';
} else {
if (isset($_GET['deleted']) == true && $_GET['deleted'] == true) {
echo '<div class="success"> La informacion ha sido eliminada correctamente </div>';
}
}
}
?>
<!-- ERRORS -->
<div id="non-number"> </div>
<div id="non-cero"> </div>
<div id="non-positive"> </div>
<?php
if (isset($_POST['id_itd'], $_POST['id_size'], $_POST['id_color'], $_POST['id_qua'], $_GET['id_item'])) {
$id_itd = $_POST['id_itd'];
$id_item = $_GET['id_item'];
$id_size = $_POST['id_size'];
$id_color = $_POST['id_color'];
$id_qua = $_POST['id_qua'];
$id_usu = $_SESSION['id'];
//$usu_id= mysql_insert_id();
if (isset($bnuevo)) {
header('Location:upload_item_details.php');
exit();
}
$errors = array();
if (empty($id_itd) || $id_size == '--Select--' || $id_color == '--Select--' || empty($id_qua)) {
$ast = 1;
$errors[] = '<div class="errors">All filds required</div>';
} else {
if (deit_exists($id_itd) == true) {
if (!isset($_GET['id_itd'])) {
$errors[] = '<div class="errors">El codigo del articulo ya existe</div>';
}
}
if (deit_exists_de($id_itd, $id_item, $id_size, $id_color) == true) {
if (empty($_GET['id_itd'])) {
$astde = 1;
$errors[] = '<div class="errors">El articulo que esta intentando ingresar ya existe</div>';
}
}
}
//print_r($errors);
if (!empty($errors)) {
foreach ($errors as $error) {
echo $error, '<br/>';
}
} else {
//Register our user
$register = deit_register($id_itd, $id_item, $id_size, $id_color, $id_qua, $id_usu);
// $_SESSION['id'] = $register; Inicia una sesion con el id especificado
if ($bclass == 'save') {
header('Location: upload_item_details.php?saved=true');
exit();
} else {
header('Location: upload_item_details.php?updated=true');
exit();
}
}
}
//Obtener el maximo auto id
$query_max_id = mysql_query("SELECT MAX(`items_detail`.`id_itd`) FROM `items_detail`");
$resultado = mysql_fetch_array($query_max_id);
$cur_auto_id = $resultado['MAX(`items_detail`.`id_itd`)'] + 1;
?>
<?php
if (isset($_POST['limpiar'])) {
unset($id_itd);
unset($id_size);
}
?>
<!-- DETAILS -->
<form action= '' method='POST'>
<table border="1" width="100%" align="center" class="stanbla">
<tr>
<td width="20%" class="trstanbla">Codigo </td><td><input type="text" <?php
if (isset($_GET['id_itd'])) {
echo 'readonly="readonly"';
}
?> id="id-itd" class=" <?php
if (isset($_GET['id_itd'])) {
echo 'disabled';
}
?>" name="id_itd" size="10px" value="<?php
if (isset($_GET['id_itd'])) {
echo $id_itd;
} else {
printf("%05s", $cur_auto_id);
}
?>" />
<td rowspan="5">
<?php
//FOTO
?>
</td>
</tr>
<tr>
<td width="20%" class="trstanbla">Codigo del item</td><td><input type="text" id="id-item" name="id_item" size="10px" value="<?php
if (isset($_GET['id_item']) == true) {
echo $_GET['id_item'];
} else {
if (isset($id_item) == true) {
echo $id_item;
}
}
?>">
<a href="javascript:void(0)" onClick="openbox('Busqueda de articulos', 0)"> <input type="button" autofocus="autofocus" name="buscar" value="Buscar" tabindex="1"/> </a>
</td>
</tr>
<tr>
<td class="trstanbla">Tamaño</td>
<td>
<select name="id_size" tabindex="2" id="tsize">
<option> --Select-- </option>
<?php
$sql = "select * FROM sizes WHERE del_est_size = 0 ORDER BY des_size ASC";
$re = mysql_query($sql) or die("Error al ejecutar consulta 1") . mysqlerror();
while ($campo = mysql_fetch_array($re)) {
?>
<option value="<?php
echo $campo['id_size'];
?>" <?php
if (isset($id_size) == true) {
if ($campo['id_size'] == $id_size) {
echo "SELECTED";
}
}
?> > <?php
echo $campo['des_size'];
}
?>
</option>
</select> <?php
if (isset($id_size) == true) {
if ($id_size == '--Select--' && $ast == 1) {
echo '<strong class="asterisk">*</strong>';
}
}
?>
</td>
</tr>
<tr>
<td class="trstanbla">Color disponible</td>
<td>
<select name="id_color" tabindex="9" id="tcolor">
<option> --Select-- </option>
<?php
$sql = "select * FROM colors WHERE del_est_color = 0 ORDER BY id_color ASC";
$re = mysql_query($sql) or die("Error al ejecutar consulta 1") . mysqlerror();
while ($campo = mysql_fetch_array($re)) {
?>
<option value="<?php
echo $campo['id_color'];
?>" <?php
if (isset($id_color) == true) {
if ($campo['id_color'] == $id_color) {
echo "SELECTED";
}
} elseif (isset($_GET['id_color'])) {
if ($campo['id_color'] == $_GET['id_color']) {
echo "SELECTED";
}
}
?> > <?php
echo $campo['des_color'];
}
?>
</option>
</select> <?php
if (isset($id_color) == true) {
if ($id_color == '--Select--' && $ast == 1) {
echo '<strong class="asterisk">*</strong>';
}
}
?>
</td>
</tr>
<tr>
<td class="trstanbla">Cantidad</td>
<td><input type="number" id="did-qua" name="id_qua" value="<?php
if (isset($id_qua) == true) {
echo $id_qua;
}
?>" /></td>
</tr>
</table>
<td colspan="2" class="trstanbla">
<div class="b_center">
<input type="submit" value="Nuevo" accesskey="u" name="bnuevo" title="alt + u" tabindex="10" class="<?php
if (!isset($_GET['id_itd'])) {
echo 'd_new';
} else {
echo 'new';
}
?> " <?php
if (!isset($_GET['id_itd'])) {
echo 'disabled="disabled"';
}
?> />
<input type="submit" value="<?php
echo $enviar_value;
?>" id="<?php
if ($bclass == bguardar) {
echo 'areg-submit';
}
?>" accesskey="r" title ="alt + r" name="<?php
echo $bname;
?>" tabindex="9" class=" <?php
echo $bclass;
?>" />
<!-- name=benviar -->
<a class="bnada" href="delete.item.det.php?id_itd=<?php
echo $datos;
?>">
<input type="button" value="Eliminar" title="alt + i" accesskey="i" tabindex="12" class="<?php
if (!isset($_GET['id_itd'])) {
echo 'd_delete';
} else {
echo 'delete';
}
?> " <?php
if (!isset($_GET['id_itd'])) {
echo 'disabled="disabled"';
}
?> name="beliminar" onclick="return confirm('¿Seguro que desea eliminar este articulo?')" /></a>
<input type="reset" value="Limpiar" title="alt + l" accesskey="l" tabindex="11" name="limpiar" class="<?php
if (!isset($_GET['id_itd'])) {
echo 'clear';
} else {
echo 'd_clear';
}
?> " />
</div>
</td>
</tr>
</form>
<p> </p>
<p> </p>
<p> </p>
<table border="0" align="center" class="display" width="100%" id="datatables">
<thead>
<tr>
<th width="5%"> <strong>Codigo</strong> </th> <th width="30%"> <strong>Id item</strong></th> <th width="30%"> <strong> Size </strong></th> <th width="30%"> <strong>Color </strong></th> <th width="30%"> <strong>Cantidad </strong></th> <th width="5%"> <strong>Editar </strong></th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT it.id_item, itd.id_item, itd.id_itd,itd.id_size, itd.id_color, itd.id_qua, si.id_size, si.des_size, co.id_color, co.des_color FROM items AS it, sizes AS si, colors AS co, items_detail AS itd WHERE it.id_item=itd.id_item AND si.id_size=itd.id_size AND co.id_color=itd.id_color AND itd.del_est_itd = '0' ORDER BY id_itd DESC";
$re = mysql_query($sql) or die("Error al ejecutar consulta 3") . mysql_error();
while ($campo2 = mysql_fetch_array($re)) {
echo '<tr class="tr1"><td width="5%" class="td1">' . $campo2['id_itd'] . '</td> <td width="30%">' . $campo2['id_item'] . '</td> <td width="30%">' . $campo2['des_size'] . '</td> <td width="30%">' . $campo2['des_color'] . '</td> <td width="30%">' . $campo2['id_qua'] . '</td> <td width="5%">' . '<a href="upload_item_details.php?id_itd=' . $campo2['id_itd'] . '&id_item=' . $campo2['id_item'] . '">' . '<img src="images/icons/Edit/edit-file-icon.png"/></a>' . '</td> </tr>';
}
?>
</tbody>
</table>
<p> </p>
<p> </p>
<?php
include 'jsbform_items.php';
include 'template/footer.php';
} else {
header('Location: index.php');
exit();
}
?>
<link type="text/css" rel="stylesheet" href="css/lightbox-form.css">
<script src="js/lightbox-form.js" type="text/javascript"></script>