Subversion-Projekte lars-tiefland.ci

Revision

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