Subversion-Projekte lars-tiefland.ci

Revision

Revision 1391 | Revision 1399 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1131 lars 1
<?php
2
 
3
/**
4
 * User
5
 *
6
 * @package
7
 * @author WebanOS CI
8
 * @copyright Lars Tiefland
9
 * @version 2016
10
 * @access public
11
 */
12
class Order extends CI_Controller
13
{
14
 
15
	public function __construct()
16
	{
17
		parent::__construct();
18
		$this->load->model('order_model', 'order');
19
	}
20
	/**
21
	 * User::index()
22
	 *
23
	 * @return
24
	 */
1329 lars 25
	public function index($anker = '')
1131 lars 26
	{
1391 lars 27
		//Wenn der Filter zurücksetzen gedrück wird, dann wird $filter nicht gesetzt und die Session muss dann geleert werden damit die Filter die Standard auswahl haben
28
		if ($mode == "resetFilter")
29
		{
30
			unset($_SESSION["filter"]);
31
		}
32
		if (isset($_SESSION["filter"]) && $_SESSION["filter"])
33
		{
34
			$filter = $_SESSION["filter"];
35
		}
36
		if (isset($_GET["filter"]) && $_GET["filter"])
37
		{
38
			$filter = $_GET["filter"];
39
		}
40
		elseif (isset($_POST["filter"]) && $_POST["filter"])
41
		{
42
			$filter = $_POST["filter"];
43
		}
44
		if ($web_rechte["Warenwirtschaft"]["bestellung"]["neu"])
45
		{
46
			$arr = explode(";", $web_rechte["Warenwirtschaft"]["bestellung"]["neu"]);
47
			foreach ($arr as $f)
48
			{
49
				list($fname, $fWert) = explode("=", $f);
50
				if (!isset($filter[$fname]))
51
				{
52
					$filter[$fname] = $fWert;
53
					$_SESSION["filter"][$fname] = $fWert;
54
				}
55
			}
56
		}
57
		if (!isset($filter["ausgabeart"]))
58
		{
59
			$filter["ausgabeart"] = 0;
60
		}
61
		if (!isset($filter["laender"]))
62
		{
63
			$filter["laender"] = 0;
64
		}
65
		if (!isset($filter["status"]))
66
		{
67
			$filter["status"] = "";
68
		}
69
		if (!isset($filter["bStatus"]))
70
		{
71
			$filter["bStatus"] = "of_fr_ve";
72
		}
73
		if (!isset($filter["logistiker"]))
74
		{
75
			$filter["logistiker"] = 0;
76
		}
77
		if (!isset($filter["zeit"]))
78
		{
79
			$filter["zeit"] = 0;
80
		}
81
		if (!isset($filter["kundensuche"]))
82
		{
83
			$filter["kundensuche"] = "";
84
		}
85
		if (!isset($filter["paketnummer"]))
86
		{
87
			$filter["paketnummer"] = "";
88
		}
89
		if (!isset($filter["rechnungsstatus"]))
90
		{
91
			$filter["rechnungsstatus"] = "";
92
		}
93
		if (!isset($filter["shopID"]))
94
		{
95
			$filter["shopID"] = "";
96
		}
97
		if (!isset($filter["bestellart_id"]))
98
		{
99
			$filter["bestellart_id"] = "";
100
		}
101
		if (!isset($filter["artikelsuche"]))
102
		{
103
			$filter["artikelsuche"] = "";
104
		}
105
		if (!isset($filter["fremd_ID"]))
106
		{
107
			$filter["fremd_ID"] = "";
108
		}
109
		if (!isset($filter["bestellung_ID"]))
110
		{
111
			$filter["bestellung_ID"] = "";
112
		}
113
		if (!isset($_GET["login_id"]))
114
		{
115
			$_GET["login_id"] = "";
116
		}
117
		if (!isset($filter["order"]))
118
		{
119
			$filter["order"] = "";
120
		}
121
		if (!isset($filter["shortline1"]))
122
		{
123
			$filter["shortline1"] = "";
124
		}
125
		if (!isset($filter["status1"]))
126
		{
127
			$filter["status1"] = "";
128
		}
129
		/* Neue Ausgabefilte: 18.03.2008 Markus N. */
130
		if (!$filter['ausgabe'])
131
		{
132
			$filter['ausgabe'] = "bestellung";
133
		}
134
		if (isset($filter["order"]) && $order == "")
135
		{
136
			$order = $filter["order"];
137
		}
138
		// wenn ausgabeart: Schnelleditor/Bestellung
139
 
140
		if (!isset($desc))
141
		{
142
			$desc = false;
143
		}
144
 
145
		if ($order && $order[0] == "_")
146
		{
147
			$order = substr($order, 1);
148
			$desc = true;
149
		}
150
		if (is_null($filter['bestellart_id']))
151
		{
152
			if (!isset($web_rechte["Warenwirtschaft"]["bestellung"]["bestellart"]))
153
			{
154
				$filter["bestellart_id"] = -1;
155
			}
156
			else
157
			{
158
				$filter['bestellart_id'] = 1;
159
			}
160
		}
161
		if (isset($web_rechte["Warenwirtschaft"]["bezahlstatus"]["bezahlstatus"]))
162
		{
163
			if (!isset($filter["bezahlstatus"]))
164
			{
165
				$filter["bezahlstatus"] = "";
166
			}
167
		}
168
		if (isset($web_rechte["Warenwirtschaft"]["bestellung"]["versandstatus"]))
169
		{
170
			if (!isset($filter["versandstatus"]))
171
			{
172
				$filter["versandstatus"] = "";
173
			}
174
		}
175
		$this->session->filter = $filter;
1388 lars 176
		$ausgabearten = array(
177
			array(
178
				"id" => 0,
179
				"name" => "Bestellung",
180
				),
181
			array(
182
				"id" => 1,
183
				"name" => "Artikel",
184
				),
185
			array(
186
				"id" => 2,
187
				"name" => "Schnelleditor",
188
				),
189
			array(
190
				"id" => 3,
191
				"name" => "Bestelldetail",
192
				),
193
			);
1379 lars 194
 
1388 lars 195
		$ausgabearten_sel = select_tpl("filter[ausgabeart]", $ausgabearten, "id", "name",
196
			$filter["ausgabeart"], true);
197
		$bestellarten_sel = "";
198
		if (is_array($bestellarten))
199
		{
200
			$showAlle = (isset($user_rechte["Warenwirtschaft"]["bestellung"]["bestellart"]) &&
201
				isset($_SESSION["datenquellen"]["bestellarten"]) && count($_SESSION["datenquellen"]["bestellarten"]) <=
202
				1);
203
			$bestellarten_sel = select_tpl("filter[bestellart_id]", $bestellarten, "id",
204
				"name", $filter["bestellart_id"], $showAlle);
205
		}
206
		$shops_neu = getShops();
207
		$showAlle = (isset($_SESSION["datenquellen"]["shops"]) && count($_SESSION["datenquellen"]["shops"]) <=
208
			1);
209
		$shops_sel = select_tpl("filter[shopID]", $shops_neu, "ID", "Name", $filter["shopID"],
210
			$showAlle);
1379 lars 211
 
1388 lars 212
		$stati = array(
213
			"" => "alle",
214
			"op_ib" => "offen und in B.",
215
			"op_ib_re" => "of.,in B.u.res.",
216
			"op" => "offene Posten",
217
			"ib" => "in Bearbeitung",
218
			"re" => "reserviert",
219
			"er" => "erledigt",
220
			"ab" => "abgeschlossen",
221
			);
222
		$zeiten = array(
223
			"alle",
224
			"heute",
225
			"gestern",
226
			"vorgestern",
227
			"lfd. Woche",
228
			"letzte Woche",
229
			strftime("%B %G"),
230
			strftime("%B %G", strtotime("-1 month")),
231
			strftime("%B %G", strtotime("-2 months")),
232
			strftime("%B %G", strtotime("-3 months")),
233
			strftime("%B %G", strtotime("-4 months")),
234
			strftime("%B %G", strtotime("-5 months")),
235
			strftime("%B %G", strtotime("-6 months")),
236
			strftime("%B %G", strtotime("-7 months")),
237
			strftime("%Y", time()),
238
			strftime("%Y", strtotime("-1 year")));
239
		$rstati = array(
240
			"" => "alle",
241
			"S" => "schreiben",
242
			"G" => "geschrieben",
243
			"B" => "bezahlt",
244
			"O" => "ohne",
245
			);
1379 lars 246
 
247
		$laender_filter = getBestelllaender();
248
 
249
		if (isset($GLOBALS["web_rechte"]["Warenwirtschaft"]["logistiker"]["logistiker"]))
250
		{
251
			$logistiker_filter = getLogistikerFilter();
252
			$this->smarty->assign("logistiker_filter", $logistiker_filter);
253
			$this->smarty->assign("logistiker_filter_sel", $filter["logistiker"]);
254
		}
1398 lars 255
 
256
		$bStatusAll = array(
257
			"of_fr_ve" => "of., fr., ve.",
258
			"offen" => "offen",
259
			"freigegeben" => "freigegeben",
260
			"versand" => "versand",
261
			"wartend" => "wartend",
262
			"storniert" => "storniert",
263
			"alle" => "alle",
264
			);
265
 
266
		$bStatusDB = parseEnumSet("Bestellung", "status");
267
		var_dump($bStatusDB);
268
 
269
		foreach ($bStatusAll as $ind => $val)
270
		{
271
			if (in_array($val, $bStatusDB["werte"]) || $val == "alle" || $ind == "of_fr_ve")
272
			{
273
				$bStatus[$ind] = $val;
274
			}
275
		}
1379 lars 276
		// Variablen zu Template zuweisen
277
		$this->smarty->assign("stati", $stati);
278
		$this->smarty->assign("stati_sel", $filter["status"]);
279
		$this->smarty->assign("rstati", $rstati);
280
		$this->smarty->assign("rstati_sel", $filter["rechnungsstatus"]);
281
		$this->smarty->assign("zeiten", $zeiten);
282
		$this->smarty->assign("zeiten_sel", $filter["zeit"]);
283
		$this->smarty->assign("bStatus", $bStatus);
284
		$this->smarty->assign("bStatus_sel", $filter["bStatus"]);
285
		$this->smarty->assign("ausgabearten", $ausgabearten_sel);
286
		$this->smarty->assign("bestellarten", $bestellarten_sel);
287
		$this->smarty->assign("bestellart", $bestellart);
288
		$this->smarty->assign("bestellung_ID", $filter["bestellung_ID"]);
289
		$this->smarty->assign("fremd_ID", $filter["fremd_ID"]);
290
		$this->smarty->assign("artikelsuche", $filter["artikelsuche"]);
291
		$this->smarty->assign("kundensuche", $filter["kundensuche"]);
292
		$this->smarty->assign("paketnummer", $filter["paketnummer"]);
293
		$this->smarty->assign("start", $filter["start"]);
294
		$this->smarty->assign("shortline1", $filter["shortline1"]);
295
		$this->smarty->assign("status1", $filter["status1"]);
296
		$this->smarty->assign("dokument", $filter["dokument"]);
297
		$this->smarty->assign("bezahlstatus", $filter["bezahlstatus"]);
298
		$this->smarty->assign("versandstatus", $filter["versandstatus"]);
299
		$this->smarty->assign("shops", $shops_sel);
300
		$this->smarty->assign("filter_maske", $filter_maske);
301
		$this->smarty->assign("laender_filter", $laender_filter);
302
		$this->smarty->assign("laender_filter_sel", $filter["laender"]);
303
 
304
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"]))
305
		{
306
			if ($GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"])
307
			{
308
				list($shortline1_name, $shortline1_size) = explode(";", $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"]);
309
			}
310
			else
311
			{
312
				$shortline1_name = "Shortline1:";
313
				$shortline1_size = 10;
314
			}
315
 
316
			$this->smarty->assign("shortline1_size", $shortline1_size);
317
			$this->smarty->assign("shortline1_name", $shortline1_name);
318
		}
319
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["status1"]))
320
		{
321
			if ($GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["status1"])
322
			{
323
				list($status1_name, $status1_option_str) = explode(";", $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["status1"],
324
					2);
325
				$status1_options_arr = explode(";", $status1_option_str);
326
				$status1_options = array("");
327
				$status1_options_filter = array("alle");
328
				foreach ($status1_options_arr as $option)
329
				{
330
					$status1_options[$option] = $option;
331
					$status1_options_filter[$option] = $option;
332
				}
333
				//$status1_options = array_merge( $status1_options );
334
			}
335
			$this->smarty->assign("status1_name", $status1_name);
336
			$this->smarty->assign("status1_options", $status1_options);
337
			$this->smarty->assign("status1_options_filter", $status1_options_filter);
338
		}
339
		// Versandstatus
340
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["versandstatus"]))
341
		{
342
			$versandstatus_options_filter = array(
343
				"alle",
344
				"offen",
345
				"freigegeben",
346
				"versand",
347
				"ohne",
348
				"offen+ohne",
349
				);
350
			$this->smarty->assign("versandstatus_options_filter", $versandstatus_options_filter);
351
		}
352
 
353
		$start_date = date('Y-m-d', strtotime("-10 days"));
354
		$i = 0;
355
		$versanddatum_options_filter[''] = 'Alle';
356
		while ($i <= 30)
357
		{
358
			$i = $i + 1;
359
			$date = new DateTime($start_date);
360
			$date->modify('+'.$i.' day');
361
			$versanddatum_options_filter[$date->format('Y-m-d')] = $date->format('d.m.Y');
362
		}
363
		$this->smarty->assign("versanddatum_options_filter", $versanddatum_options_filter);
364
 
365
		// Bezahlstatus SELECT BOX
366
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bezahlstatus"]["bezahlstatus"]))
367
		{
368
			$bezahlstatus_options_filter[] = "alle";
369
			$bezahlstatus_options_filter[] = "offen";
370
			$bezahlstatus_options_filter[] = "bezahlt";
371
			if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bezahlstatus"]["vorbezahlt_setzen"]))
372
			{
373
				$bezahlstatus_options_filter[] = "vorbezahlt";
374
				$bezahlstatus_options_filter[] = "bezahlt und vorbezahlt";
375
			}
376
 
377
			$this->smarty->assign("bezahlstatus_name", $bezahlstatus_name);
378
			$this->smarty->assign("bezahlstatus_options", $bezahlstatus_options);
379
			$this->smarty->assign("bezahlstatus_options_filter", $bezahlstatus_options_filter);
380
		}
381
		if (isset($_POST["anker"]))
382
		{
383
			$this->smarty->assign("anker", $_POST["anker"] + 1);
384
		}
1133 lars 385
		$orders = $this->order->get_list();
1329 lars 386
		$this->smarty->assign('anker', $anker);
1131 lars 387
		$this->smarty->assign('orders', $orders);
388
		$this->smarty->view('orders.tpl');
389
	}
390
 
391
	/**
392
	 * User::edit()
393
	 *
394
	 * @param mixed $id
395
	 * @return void
396
	 */
397
	public function edit($id = null)
398
	{
1271 lars 399
		$daten["artikel_stati"] = array(
400
			array(
401
				"name" => "offen",
402
				"short" => "O",
403
				"class" => "status_red"),
404
			array(
405
				"name" => "in Bearbeitung",
406
				"short" => "B",
407
				"class" => "status_yellow",
408
				),
409
			array(
410
				"name" => "reserviert",
411
				"short" => "R",
412
				"class" => "status_blue",
413
				),
414
			array(
415
				"name" => "erledigt",
416
				"short" => "E",
417
				"class" => "status_green",
418
				),
419
			array(
420
				"name" => "abgeschlossen",
421
				"short" => "A",
422
				"class" => "status_white",
423
				),
424
			);
425
		$daten["rechnung_stati"] = array(
426
			array(
427
				"name" => "schreiben",
428
				"short" => "S",
429
				"class" => "status_red"),
430
			array(
431
				"name" => "geschrieben",
432
				"short" => "G",
433
				"class" => "status_yellow",
434
				),
435
			array(
436
				"name" => "bezahlt",
437
				"short" => "B",
438
				"class" => "status_green",
439
				),
440
			);
441
		$daten["lieferschein_stati"] = array(
442
			array(
443
				"name" => "schreiben",
444
				"short" => "S",
445
				"class" => "status_yellow"),
446
			array(
447
				"name" => "geschrieben",
448
				"short" => "G",
449
				"class" => "status_green",
450
				),
451
			array(
452
				"name" => "offen",
453
				"short" => "O",
454
				"class" => "status_red",
455
				),
456
			);
457
		$daten["mahnung_stati"] = array(
458
			array(
459
				"name" => "mahnung1",
460
				"short" => "1",
461
				"class" => "status_green"),
462
			array(
463
				"name" => "mahnung2",
464
				"short" => "2",
465
				"class" => "status_yellow",
466
				),
467
			array(
468
				"name" => "mahnung3",
469
				"short" => "3",
470
				"class" => "status_red",
471
				),
472
			);
473
		$daten["garantie_stati"] = array(
474
			array(
475
				"name" => "eingereicht",
476
				"short" => "E",
477
				"class" => "status_red"),
478
			array(
479
				"name" => "abgeschlossen",
480
				"short" => "A",
481
				"class" => "status_green",
482
				),
483
			);
484
		// Modul dokumente
1288 lars 485
		$preise_anzeigen = 1;
486
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
487
		{
488
			if (!isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
489
			{
490
				// "<br>für bestimmte user preis verbergen";
491
				$preise_anzeigen = 0;
492
			}
493
		}
1172 lars 494
		$order = $this->order->get($id);
1293 lars 495
		$this->smarty->assign('title', 'Bestellung bearbeiten');
1289 lars 496
		$this->smarty->assign('preise_anzeigen', $preise_anzeigen);
1172 lars 497
		$this->smarty->assign('order', $order);
1271 lars 498
		$this->smarty->assign('daten', $daten);
1172 lars 499
		$this->smarty->view('single_order.tpl');
1131 lars 500
	}
501
 
502
	public function save()
503
	{
1336 lars 504
		$this->order->save();
1131 lars 505
	}
1172 lars 506
 
1131 lars 507
	public function del($id = null)
508
	{
509
	}
510
 
511
}