Subversion-Projekte lars-tiefland.ci

Revision

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