-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproducts.php
332 lines (290 loc) Β· 15.4 KB
/
products.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
<?php
include("header.php");
// PRODUCT ===============================================================================
if(isset($_POST['add_product']))
{
$error = 0;
$name = $_POST['name'];
$number = GetProperty("prefix_product").'-'.$_POST['number'];
$description = $_POST['description'];
$unit = $_POST['unit'];
$comment = $_POST['comment'];
$resell_price = $_POST['resell_price'];
$attributes = $_POST['attributes'];
$sellable = (isset($_POST['sellable'])) ? 1 : 0;
$number_id = ($_POST['add_product']=="new") ? $number : $_POST['add_product'];
if($_POST['add_product']=='new')
{
if((fetch_count("products","number",$number_id) + fetch_count("products","number",$number))==0) MySQLNonQuery("INSERT INTO products (number) VALUES ('$number')");
else $error=1;
}
if($number != $number_id) rename('files/products/products/'.$number_id.'/','files/products/products/'.$number.'/');
if($error!=1)
{
$path = 'files/products/products/'.$number.'/';
MultiFileUpload($path);
ThumbnailUpload($path,$number);
$strSQL = "UPDATE products SET number = '$number', name = '$name', description = '$description', unit = '$unit', comment = '$comment', resell_price = '$resell_price', attributes = '$attributes', sellable = '$sellable' WHERE number = '$number_id'";
MySQLNonQuery($strSQL);
MySQLNonQuery("UPDATE product_contains SET parent = '$number' WHERE parent = '$number_id'");
MySQLNonQuery("UPDATE product_contains SET child = '$number' WHERE child = '$number_id'");
}
MySQLNonQuery("DELETE FROM product_contains WHERE parent LIKE '$number'");
$parent = $number;
$prefix_semiproduct = GetProperty("prefix_semiproduct");
$strSQL = "SELECT * FROM products WHERE number LIKE '$prefix_semiproduct%'";
$rs=mysqli_query($link,$strSQL);
while($row=mysqli_fetch_assoc($rs))
{
if(isset($_POST['check'.$row['number']]))
{
$id = uniqid();
$child = $row['number'];
$amt = $_POST['amt'.$row['number']];
MySQLNonQuery("INSERT INTO product_contains (id,parent,child,quantity) VALUES ('$id','$parent','$child','$amt')");
}
}
$prefix_raw = GetProperty("prefix_raw");
$strSQL = "SELECT * FROM products WHERE number LIKE '$prefix_raw%'";
$rs=mysqli_query($link,$strSQL);
while($row=mysqli_fetch_assoc($rs))
{
if(isset($_POST['check'.$row['number']]))
{
$id = uniqid();
$child = $row['number'];
$amt = $_POST['amt'.$row['number']];
MySQLNonQuery("INSERT INTO product_contains (id,parent,child,quantity) VALUES ('$id','$parent','$child','$amt')");
}
}
$prefix_support = GetProperty("prefix_support");
$strSQL = "SELECT * FROM products WHERE number LIKE '$prefix_support%'";
$rs=mysqli_query($link,$strSQL);
while($row=mysqli_fetch_assoc($rs))
{
if(isset($_POST['check'.$row['number']]))
{
$id = uniqid();
$child = $row['number'];
$amt = $_POST['amt'.$row['number']];
MySQLNonQuery("INSERT INTO product_contains (id,parent,child,quantity) VALUES ('$id','$parent','$child','$amt')");
}
}
NotificationBanner((($_POST['add_product']=="new") ? "Neues Produkt wurde angelegt." : "Produkt wurde aktualisiert"),"check");
Redirect("products?products&show");
}
if(isset($_POST['delete_product']))
{
MySQLNonQuery('DELETE FROM products WHERE number = \''.$_POST['delete_product'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE parent = \''.$_POST['delete_product'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE child = \''.$_POST['delete_product'].'\'');
DeleteFolder('files/products/products/'.$_POST['delete_product'].'/');
NotificationBanner("Produkt wurde gelöscht.","check");
Redirect("products?products&show");
}
// SEMIPRODUCT ===========================================================================
if(isset($_POST['add_semiproduct']))
{
$error = 0;
$name = $_POST['name'];
$number = GetProperty("prefix_semiproduct").'-'.$_POST['number'];
$description = $_POST['description'];
$unit = $_POST['unit'];
$comment = $_POST['comment'];
$number_id = ($_POST['add_semiproduct']=="new") ? $number : $_POST['add_semiproduct'];
if($_POST['add_semiproduct']=='new')
{
if((fetch_count("products","number",$number_id) + fetch_count("products","number",$number))==0) MySQLNonQuery("INSERT INTO products (number) VALUES ('$number')");
else $error=1;
}
if($number != $number_id) rename('files/products/semiproducts/'.$number_id.'/','files/products/semiproducts/'.$number.'/');
if($error!=1)
{
$path = 'files/products/semiproducts/'.$number.'/';
MultiFileUpload($path);
ThumbnailUpload($path,$number);
$strSQL = "UPDATE products SET number = '$number', name = '$name', description = '$description', unit = '$unit', comment = '$comment' WHERE number = '$number_id'";
MySQLNonQuery($strSQL);
MySQLNonQuery("UPDATE product_contains SET parent = '$number' WHERE parent = '$number_id'");
MySQLNonQuery("UPDATE product_contains SET child = '$number' WHERE child = '$number_id'");
}
MySQLNonQuery("DELETE FROM product_contains WHERE parent LIKE '$number'");
$parent = $number;
$prefix_raw = GetProperty("prefix_raw");
$strSQL = "SELECT * FROM products WHERE number LIKE '$prefix_raw%'";
$rs=mysqli_query($link,$strSQL);
while($row=mysqli_fetch_assoc($rs))
{
if(isset($_POST['check'.$row['number']]))
{
$id = uniqid();
$child = $row['number'];
$amt = $_POST['amt'.$row['number']];
MySQLNonQuery("INSERT INTO product_contains (id,parent,child,quantity) VALUES ('$id','$parent','$child','$amt')");
}
}
$prefix_support = GetProperty("prefix_support");
$strSQL = "SELECT * FROM products WHERE number LIKE '$prefix_support%'";
$rs=mysqli_query($link,$strSQL);
while($row=mysqli_fetch_assoc($rs))
{
if(isset($_POST['check'.$row['number']]))
{
$id = uniqid();
$child = $row['number'];
$amt = $_POST['amt'.$row['number']];
MySQLNonQuery("INSERT INTO product_contains (id,parent,child,quantity) VALUES ('$id','$parent','$child','$amt')");
}
}
NotificationBanner((($_POST['add_semiproduct']=="new") ? "Neues Halbprodukt wurde angelegt." : "Halbprodukt wurde aktualisiert"),"check");
Redirect("products?semiproducts&show");
}
if(isset($_POST['delete_semiproduct']))
{
MySQLNonQuery('DELETE FROM products WHERE number = \''.$_POST['delete_semiproduct'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE parent = \''.$_POST['delete_semiproduct'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE child = \''.$_POST['delete_semiproduct'].'\'');
DeleteFolder('files/products/semiproducts/'.$_POST['delete_semiproduct'].'/');
NotificationBanner("Halbprodukt wurde gelöscht.","check");
Redirect("products?semiproduct&show");
}
// RAW-PRODUCT ===========================================================================
if(isset($_POST['add_raw_product']))
{
$error = 0;
$name = $_POST['name'];
$number = (!isset($_POST['declarationAssistent'])) ? (GetProperty("prefix_raw").'-'.$_POST['numberDefault']) : $_POST['numberAssist'];
$description = $_POST['description'];
$unit = $_POST['unit'];
$price = $_POST['price'];
$per_item = $_POST['per_item'];
$company = $_POST['company'];
$retailer = $_POST['retailer'];
$link = $_POST['link'];
$comment = $_POST['comment'];
$max_stock = $_POST['max_stock'];
$reorder_stock = $_POST['reorder_stock'];
$security_stock = $_POST['security_stock'];
$storage_location = $_POST['storage_location'];
$number_id = ($_POST['add_raw_product']=="new") ? $number : $_POST['add_raw_product'];
if($_POST['add_raw_product']=='new')
{
if((fetch_count("products","number",$number_id) + fetch_count("products","number",$number))==0) MySQLNonQuery("INSERT INTO products (number) VALUES ('$number')");
else $error=1;
}
if($number != $number_id) rename('files/products/raw_products/'.$number_id.'/','files/products/raw_products/'.$number.'/');
if($error!=1)
{
$path = 'files/products/raw_products/'.$number.'/';
MultiFileUpload($path);
ThumbnailUpload($path,$number);
$strSQL = "UPDATE products SET number = '$number', name = '$name', description = '$description', unit = '$unit', price = '$price', per_item = '$per_item', production_company = '$company', retail_company = '$retailer', link = '$link', comment = '$comment', max_stock = '$max_stock', reorder_stock = '$reorder_stock', security_stock = '$security_stock', storage_location = '$storage_location' WHERE number = '$number_id'";
echo $strSQL;
MySQLNonQuery($strSQL);
MySQLNonQuery("UPDATE product_contains SET parent = '$number' WHERE parent = '$number_id'");
MySQLNonQuery("UPDATE product_contains SET child = '$number' WHERE child = '$number_id'");
}
NotificationBanner((($_POST['add_raw_product']=="new") ? "Neues Rohteil wurde angelegt." : "Rohteil wurde aktualisiert"),"check");
//Redirect("products?raw&show");
}
if(isset($_POST['delete_raw_item']))
{
MySQLNonQuery('DELETE FROM products WHERE number = \''.$_POST['delete_raw_item'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE parent = \''.$_POST['delete_raw_item'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE child = \''.$_POST['delete_raw_item'].'\'');
DeleteFolder('files/products/raw_products/'.$_POST['delete_raw_item'].'/');
NotificationBanner("Rohteil wurde gelöscht.","check");
Redirect("products?raw&show");
}
// SUPPORT ===============================================================================
if(isset($_POST['add_support_product']))
{
$error = 0;
$name = $_POST['name'];
$number = GetProperty("prefix_support").'-'.$_POST['number'];
$description = $_POST['description'];
$unit = $_POST['unit'];
$price = $_POST['price'];
$per_item = $_POST['per_item'];
$company = $_POST['company'];
$retailer = $_POST['retailer'];
$link = $_POST['link'];
$comment = $_POST['comment'];
$max_stock = $_POST['max_stock'];
$reorder_stock = $_POST['reorder_stock'];
$security_stock = $_POST['security_stock'];
$storage_location = $_POST['storage_location'];
$number_id = ($_POST['add_support_product']=="new") ? $number : $_POST['add_support_product'];
if($_POST['add_support_product']=='new')
{
if((fetch_count("products","number",$number_id) + fetch_count("products","number",$number))==0) MySQLNonQuery("INSERT INTO products (number) VALUES ('$number')");
else $error=1;
}
if($number != $number_id) rename('files/products/support_products/'.$number_id.'/','files/products/support_products/'.$number.'/');
if($error!=1)
{
$path = 'files/products/support_products/'.$number.'/';
MultiFileUpload($path);
ThumbnailUpload($path,$number);
$strSQL = "UPDATE products SET number = '$number', name = '$name', description = '$description', unit = '$unit', price = '$price', per_item = '$per_item', production_company = '$company', retail_company = '$retailer', link = '$link', comment = '$comment', max_stock = '$max_stock', reorder_stock = '$reorder_stock', security_stock = '$security_stock', storage_location = '$storage_location' WHERE number = '$number_id'";
MySQLNonQuery($strSQL);
MySQLNonQuery("UPDATE product_contains SET parent = '$number' WHERE parent = '$number_id'");
MySQLNonQuery("UPDATE product_contains SET child = '$number' WHERE child = '$number_id'");
}
NotificationBanner((($_POST['add_support_product']=="new") ? "Neues Hilfsprodukt wurde angelegt." : "Hilfsprodukt wurde aktualisiert"),"check");
Redirect("products?support&show");
}
if(isset($_POST['delete_support_item']))
{
MySQLNonQuery('DELETE FROM products WHERE number = \''.$_POST['delete_support_item'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE parent = \''.$_POST['delete_support_item'].'\'');
MySQLNonQuery('DELETE FROM product_contains WHERE child = \''.$_POST['delete_support_item'].'\'');
DeleteFolder('files/products/support_products/'.$_POST['delete_support_item'].'/');
NotificationBanner("Hilfsprodukt wurde gelöscht.","check");
Redirect("products?support&show");
}
// =======================================================================================
echo '<div id="fade_in"><h1>'.langlib("Produkte").'</h1></div>';
echo RegisterCards("","Produkte|!|products","Halbprodukte||semiproducts","Rohteile||raw","Hilfsmittel||support","|||","Warenstruktur||structure","Lagerstandorte||storagelocations");
if(isset($_GET['products']))
{
echo RegisterCards("products","Produkte anzeigen|!|show","Neues Produkt eintragen||new","Produkt bearbeiten||edit","Produkt löschen||delete");
echo '<div id="content_fade_in">';
require "products_1product.php";
echo '</div>';
}
if(isset($_GET['semiproducts']))
{
echo RegisterCards("semiproducts","Halbprodukte anzeigen|!|show","Neues Halbprodukt eintragen||new","Halbprodukt bearbeiten||edit","Halbprodukt löschen||delete");
echo '<div id="content_fade_in">';
require "products_2semiproduct.php";
echo '</div>';
}
if(isset($_GET['raw']))
{
echo RegisterCards("raw","Rohteile anzeigen|!|show","Neues Rohteil eintragen||new","Rohteil bearbeiten||edit","Rohteil löschen||delete","Deklarationsassistent||declaration#sg1");
echo '<div id="content_fade_in">';
require "products_3raw.php";
echo '</div>';
}
if(isset($_GET['support']))
{
echo RegisterCards("support","Hilfsmittel anzeigen|!|show","Neues Hilfsmittel eintragen||new","Hilfsmittel bearbeiten||edit","Hilfsmittel löschen||delete");
echo '<div id="content_fade_in">';
require "products_4support.php";
echo '</div>';
}
if(isset($_GET['structure']))
{
echo '<div id="content_fade_in">';
require "products_5structure.php";
echo '</div>';
}
if(isset($_GET['storagelocations']))
{
echo '<div id="content_fade_in">';
require "products_6storagelocations.php";
echo '</div>';
}
include("footer.php");
?>