Subversion-Projekte lars-tiefland.ci

Revision

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