Subversion-Projekte lars-tiefland.ci

Revision

Revision 1398 | Revision 1401 | 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
 
268
		foreach ($bStatusAll as $ind => $val)
269
		{
270
			if (in_array($val, $bStatusDB["werte"]) || $val == "alle" || $ind == "of_fr_ve")
271
			{
272
				$bStatus[$ind] = $val;
273
			}
274
		}
1379 lars 275
		// Variablen zu Template zuweisen
276
		$this->smarty->assign("stati", $stati);
277
		$this->smarty->assign("stati_sel", $filter["status"]);
278
		$this->smarty->assign("rstati", $rstati);
279
		$this->smarty->assign("rstati_sel", $filter["rechnungsstatus"]);
280
		$this->smarty->assign("zeiten", $zeiten);
281
		$this->smarty->assign("zeiten_sel", $filter["zeit"]);
282
		$this->smarty->assign("bStatus", $bStatus);
283
		$this->smarty->assign("bStatus_sel", $filter["bStatus"]);
284
		$this->smarty->assign("ausgabearten", $ausgabearten_sel);
285
		$this->smarty->assign("bestellarten", $bestellarten_sel);
286
		$this->smarty->assign("bestellart", $bestellart);
287
		$this->smarty->assign("bestellung_ID", $filter["bestellung_ID"]);
288
		$this->smarty->assign("fremd_ID", $filter["fremd_ID"]);
289
		$this->smarty->assign("artikelsuche", $filter["artikelsuche"]);
290
		$this->smarty->assign("kundensuche", $filter["kundensuche"]);
291
		$this->smarty->assign("paketnummer", $filter["paketnummer"]);
292
		$this->smarty->assign("start", $filter["start"]);
293
		$this->smarty->assign("shortline1", $filter["shortline1"]);
294
		$this->smarty->assign("status1", $filter["status1"]);
295
		$this->smarty->assign("dokument", $filter["dokument"]);
296
		$this->smarty->assign("bezahlstatus", $filter["bezahlstatus"]);
297
		$this->smarty->assign("versandstatus", $filter["versandstatus"]);
298
		$this->smarty->assign("shops", $shops_sel);
299
		$this->smarty->assign("filter_maske", $filter_maske);
300
		$this->smarty->assign("laender_filter", $laender_filter);
301
		$this->smarty->assign("laender_filter_sel", $filter["laender"]);
302
 
303
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"]))
304
		{
305
			if ($GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"])
306
			{
307
				list($shortline1_name, $shortline1_size) = explode(";", $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"]);
308
			}
309
			else
310
			{
311
				$shortline1_name = "Shortline1:";
312
				$shortline1_size = 10;
313
			}
314
 
315
			$this->smarty->assign("shortline1_size", $shortline1_size);
316
			$this->smarty->assign("shortline1_name", $shortline1_name);
317
		}
318
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["status1"]))
319
		{
320
			if ($GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["status1"])
321
			{
322
				list($status1_name, $status1_option_str) = explode(";", $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["status1"],
323
					2);
324
				$status1_options_arr = explode(";", $status1_option_str);
325
				$status1_options = array("");
326
				$status1_options_filter = array("alle");
327
				foreach ($status1_options_arr as $option)
328
				{
329
					$status1_options[$option] = $option;
330
					$status1_options_filter[$option] = $option;
331
				}
332
				//$status1_options = array_merge( $status1_options );
333
			}
334
			$this->smarty->assign("status1_name", $status1_name);
335
			$this->smarty->assign("status1_options", $status1_options);
336
			$this->smarty->assign("status1_options_filter", $status1_options_filter);
337
		}
338
		// Versandstatus
339
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["versandstatus"]))
340
		{
341
			$versandstatus_options_filter = array(
342
				"alle",
343
				"offen",
344
				"freigegeben",
345
				"versand",
346
				"ohne",
347
				"offen+ohne",
348
				);
349
			$this->smarty->assign("versandstatus_options_filter", $versandstatus_options_filter);
350
		}
351
 
352
		$start_date = date('Y-m-d', strtotime("-10 days"));
353
		$i = 0;
354
		$versanddatum_options_filter[''] = 'Alle';
355
		while ($i <= 30)
356
		{
357
			$i = $i + 1;
358
			$date = new DateTime($start_date);
359
			$date->modify('+'.$i.' day');
360
			$versanddatum_options_filter[$date->format('Y-m-d')] = $date->format('d.m.Y');
361
		}
362
		$this->smarty->assign("versanddatum_options_filter", $versanddatum_options_filter);
363
 
364
		// Bezahlstatus SELECT BOX
365
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bezahlstatus"]["bezahlstatus"]))
366
		{
367
			$bezahlstatus_options_filter[] = "alle";
368
			$bezahlstatus_options_filter[] = "offen";
369
			$bezahlstatus_options_filter[] = "bezahlt";
370
			if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bezahlstatus"]["vorbezahlt_setzen"]))
371
			{
372
				$bezahlstatus_options_filter[] = "vorbezahlt";
373
				$bezahlstatus_options_filter[] = "bezahlt und vorbezahlt";
374
			}
375
 
376
			$this->smarty->assign("bezahlstatus_name", $bezahlstatus_name);
377
			$this->smarty->assign("bezahlstatus_options", $bezahlstatus_options);
378
			$this->smarty->assign("bezahlstatus_options_filter", $bezahlstatus_options_filter);
379
		}
380
		if (isset($_POST["anker"]))
381
		{
382
			$this->smarty->assign("anker", $_POST["anker"] + 1);
383
		}
1133 lars 384
		$orders = $this->order->get_list();
1329 lars 385
		$this->smarty->assign('anker', $anker);
1131 lars 386
		$this->smarty->assign('orders', $orders);
387
		$this->smarty->view('orders.tpl');
388
	}
389
 
390
	/**
391
	 * User::edit()
392
	 *
393
	 * @param mixed $id
394
	 * @return void
395
	 */
396
	public function edit($id = null)
397
	{
1271 lars 398
		$daten["artikel_stati"] = array(
399
			array(
400
				"name" => "offen",
401
				"short" => "O",
402
				"class" => "status_red"),
403
			array(
404
				"name" => "in Bearbeitung",
405
				"short" => "B",
406
				"class" => "status_yellow",
407
				),
408
			array(
409
				"name" => "reserviert",
410
				"short" => "R",
411
				"class" => "status_blue",
412
				),
413
			array(
414
				"name" => "erledigt",
415
				"short" => "E",
416
				"class" => "status_green",
417
				),
418
			array(
419
				"name" => "abgeschlossen",
420
				"short" => "A",
421
				"class" => "status_white",
422
				),
423
			);
424
		$daten["rechnung_stati"] = array(
425
			array(
426
				"name" => "schreiben",
427
				"short" => "S",
428
				"class" => "status_red"),
429
			array(
430
				"name" => "geschrieben",
431
				"short" => "G",
432
				"class" => "status_yellow",
433
				),
434
			array(
435
				"name" => "bezahlt",
436
				"short" => "B",
437
				"class" => "status_green",
438
				),
439
			);
440
		$daten["lieferschein_stati"] = array(
441
			array(
442
				"name" => "schreiben",
443
				"short" => "S",
444
				"class" => "status_yellow"),
445
			array(
446
				"name" => "geschrieben",
447
				"short" => "G",
448
				"class" => "status_green",
449
				),
450
			array(
451
				"name" => "offen",
452
				"short" => "O",
453
				"class" => "status_red",
454
				),
455
			);
456
		$daten["mahnung_stati"] = array(
457
			array(
458
				"name" => "mahnung1",
459
				"short" => "1",
460
				"class" => "status_green"),
461
			array(
462
				"name" => "mahnung2",
463
				"short" => "2",
464
				"class" => "status_yellow",
465
				),
466
			array(
467
				"name" => "mahnung3",
468
				"short" => "3",
469
				"class" => "status_red",
470
				),
471
			);
472
		$daten["garantie_stati"] = array(
473
			array(
474
				"name" => "eingereicht",
475
				"short" => "E",
476
				"class" => "status_red"),
477
			array(
478
				"name" => "abgeschlossen",
479
				"short" => "A",
480
				"class" => "status_green",
481
				),
482
			);
483
		// Modul dokumente
1288 lars 484
		$preise_anzeigen = 1;
485
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
486
		{
487
			if (!isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
488
			{
489
				// "<br>für bestimmte user preis verbergen";
490
				$preise_anzeigen = 0;
491
			}
492
		}
1172 lars 493
		$order = $this->order->get($id);
1293 lars 494
		$this->smarty->assign('title', 'Bestellung bearbeiten');
1289 lars 495
		$this->smarty->assign('preise_anzeigen', $preise_anzeigen);
1172 lars 496
		$this->smarty->assign('order', $order);
1271 lars 497
		$this->smarty->assign('daten', $daten);
1172 lars 498
		$this->smarty->view('single_order.tpl');
1131 lars 499
	}
500
 
501
	public function save()
502
	{
1336 lars 503
		$this->order->save();
1131 lars 504
	}
1172 lars 505
 
1131 lars 506
	public function del($id = null)
507
	{
508
	}
509
 
510
}