Subversion-Projekte lars-tiefland.ci

Revision

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