-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproducts_6storagelocations.php
130 lines (118 loc) · 6.2 KB
/
products_6storagelocations.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
<?php
if(isset($_POST['add_storageLocation']))
{
$number = GetProperty("prefix_storage").'-'.$_POST['number'];
$name = $_POST['name'];
$location = $_POST['location'];
$slots = $_POST['slots'];
$isUpdate=true;
if(!MySQLResultExists("SELECT * FROM storage_locations WHERE storage_id = '$number'"))
{
$isUpdate=false;
MySQLNonQuery("INSERT INTO storage_locations (storage_id) VALUES ('$number')");
}
MySQLNonQuery("UPDATE storage_locations SET storage_name = '$name', storage_location = '$location', storage_slots = '$slots' WHERE storage_id = '$number'");
if($isUpdate) NotificationBanner("Lagerstandort aktualisiert.","check");
else NotificationBanner("Lagerstandort hinzugefügt.","check");
Redirect("products?storagelocations");
die();
}
if(isset($_POST['delete_storage']))
{
$id = $_POST['delete_storage'];
if(!MySQLResultExists("SELECT * FROM products WHERE storage_location = '$id'"))
{
MySQLNonQuery("DELETE FROM storage_locations WHERE storage_id = '$id'");
NotificationBanner("Lagerstandort entfernt.","check");
}
else NotificationBanner("Es befinden sich noch ".fetch_count("products","storage_location",$id)." Produkte in diesem Lager.","cross");
Redirect(ThisPage());
die();
}
echo '<h2>Lagerstandorte</h2>';
echo '
<form action="'.ThisPage().'" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<center>
<table class="data_inputbox_m">
<tr>
<td colspan=2><h3>'.((isset($_GET['edit'])) ? 'Lagerstandort bearbeiten' : 'Neuen Lagerstandort eintragen').'</h3></td>
</tr>
<tr>
<td style="text-align:right;">Lager-Nummer:</td>
<td>
<input class="textfield_mod t_textfield" style="width:60px;margin-right:0px;" value="'.GetProperty("prefix_storage").'-" readonly><input name="number" value="'.((isset($_GET['edit'])) ? (str_replace(GetProperty("prefix_storage").'-','',fetch("storage_locations","storage_id","storage_id",$_GET['edit']))) : '').'" class="textfield_mod t_textfield" style="width:231px;margin-left:0px" placeholder="Nummer..." '.((isset($_GET['edit'])) ? 'readonly' : 'required').' >
</td>
</tr>
<tr>
<td style="text-align:right;">Lager-Name:</td>
<td>
<input name="name" class="textfield_m t_textfield" placeholder="Name..." value="'.((isset($_GET['edit'])) ? (fetch("storage_locations","storage_name","storage_id",$_GET['edit'])) : '').'" required>
</td>
</tr>
<tr>
<td style="text-align:right;">Lager-Ort:</td>
<td>
<textarea name="location" class="textarea_m t_textarea" placeholder="Adresse, Raum, Gebäude,..." required>'.((isset($_GET['edit'])) ? (fetch("storage_locations","storage_location","storage_id",$_GET['edit'])) : '').'</textarea>
</td>
</tr>
<tr>
<td style="text-align:right;">Lagerplätze:</td>
<td>
<input name="slots" type="number" class="textfield_m t_textfield" value="'.((isset($_GET['edit'])) ? (fetch("storage_locations","storage_slots","storage_id",$_GET['edit'])) : '').'" placeholder="Anzahl..." required>
</td>
</tr>
<tr>
<td colspan=2 style="text-align:center">
<br><br>
<button type="submit" name="add_storageLocation" class="t_button button_m">'.((isset($_GET['edit'])) ? 'Lager aktualisieren' : 'Lager eintragen').'</button><br>
'.((isset($_GET['edit'])) ? '<a href="products?storagelocations"><button type="button" class="t_button button_m">Abbrechen</button></a>' : '').'
</td>
</tr>
</table>
<br><br>
</form>
<form action="'.ThisPage().'" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<table class="orders_table">
';
$i=0;
$strSQL = "SELECT * FROM storage_locations";
$rs=mysqli_query($link,$strSQL);
while($row=mysqli_fetch_assoc($rs))
{
$style_color = ($i%2==0) ? 'style="background:#DBEDFF;"' : 'style="background:#F2F2F2;"';
$style_id = ($i++%2==0) ? 'id="shaded_cell"' : '';
echo '
<tr>
<td '.$style_id.'>
<a href="products?storagelocations&edit='.$row['storage_id'].'"><span style="color: #FFA500">✍ <u>Bearbeiten</u></span></a><br>
<a href="#delete'.$row['storage_id'].'"><span style="color: #CC0000">✘ <u>Löschen</u></a></span>
</td>
<td '.$style_id.'>
<b>'.$row['storage_id'].'</b><br>
'.$row['storage_name'].'
</td>
<td '.$style_id.'>
<b><u>Ort:</u></b><br>
'.nl2br($row['storage_location']).'
</td>
<td '.$style_id.'>
<b><u>Lagerplätze:</u></b><br>
'.$row['storage_slots'].' Plätze
</td>
</tr>
<tr>
<td colspan=4 class="foldup_cell" id="delete'.$row['storage_id'].'" '.$style_color.'>
<center>
<button class="t_button_warning button_m" type="submit" name="delete_storage" value="'.$row['storage_id'].'">Löschen bestätigen</button><br>
<a href="#close"><button class="t_button button_m" type="button">Abbrechen</button></a>
</center>
</td>
</tr>
';
}
echo '
</table>
</center>
</form>
';
?>