Subversion-Projekte lars-tiefland.ci

Revision

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