Subversion-Projekte lars-tiefland.ci

Revision

Revision 1464 | Revision 1468 | 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 1467 2016-11-13 00:14:21Z 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');
1423 lars 23
		$bestellarten = $this->bestellart->get_list();
1391 lars 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
1467 lars 25
		$start = 0;
26
		if ($this->input->get('start'))
27
		{
28
			$start = $this->input->get('start');
29
		}
30
		elseif ($this->input->post('start'))
31
		{
32
			$start = $this->input->post('start');
33
		}
1391 lars 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
		}
1434 lars 385
	}
386
	/**
387
	 * User::index()
388
	 *
389
	 * @return
390
	 */
1453 lars 391
	public function index()
1434 lars 392
	{
1464 lars 393
		if (isset($_GET["anker"]))
1379 lars 394
		{
1464 lars 395
			$this->smarty->assign("anker", $_GET["anker"] + 1);
1379 lars 396
		}
1453 lars 397
		$ret = $this->order->get_list($start);
1401 lars 398
		$orders = $ret["orders"];
399
		$anz = $ret["orderAnz"];
1415 lars 400
		if ($anz == 1)
401
		{
402
			header("Location:/backend/order/edit/".$orders[0]["id"]);
403
			exit;
404
		}
1452 lars 405
		$config['base_url'] = $this->config->item('base_url').'/order/';
406
		$config['total_rows'] = $anz;
407
		$config['per_page'] = 100;
408
		$config['page_query_string'] = true;
1457 lars 409
		$config['query_string_segment'] = 'start';
1456 lars 410
		$config['num_links'] = 20;
1452 lars 411
		//$config['use_page_numbers'] = true;
412
		$config['cur_tag_open'] = '&nbsp;[&nbsp;<b>';
413
		$config['cur_tag_close'] = '</b>&nbsp;]';
414
		$config['num_tag_open'] = '&nbsp;[&nbsp;';
415
		$config['num_tag_close'] = '&nbsp;]';
416
		$config['first_tag_open'] = '&nbsp;[&nbsp;';
417
		$config['first_tag_close'] = '&nbsp;]';
418
		$config['last_tag_open'] = '&nbsp;[&nbsp;';
419
		$config['last_tag_close'] = '&nbsp;]';
420
		$config['next_tag_open'] = '&nbsp;[&nbsp;';
421
		$config['next_tag_close'] = '&nbsp;]';
422
		$config['prev_tag_open'] = '&nbsp;[&nbsp;';
423
		$config['prev_tag_close'] = '&nbsp;]';
1455 lars 424
		$config['last_link'] = 'Letzte &rsaquo;';
425
		$config['first_link'] = '&lsaquo; Erste';
1452 lars 426
		$this->pagination->initialize($config);
427
		$this->smarty->assign('pagination', $this->pagination->create_links());
1403 lars 428
		$this->smarty->assign('anz', $anz);
1131 lars 429
		$this->smarty->assign('orders', $orders);
430
		$this->smarty->view('orders.tpl');
431
	}
432
 
433
	/**
434
	 * User::edit()
435
	 *
436
	 * @param mixed $id
437
	 * @return void
438
	 */
439
	public function edit($id = null)
440
	{
1271 lars 441
		$daten["artikel_stati"] = array(
442
			array(
443
				"name" => "offen",
444
				"short" => "O",
445
				"class" => "status_red"),
446
			array(
447
				"name" => "in Bearbeitung",
448
				"short" => "B",
449
				"class" => "status_yellow",
450
				),
451
			array(
452
				"name" => "reserviert",
453
				"short" => "R",
454
				"class" => "status_blue",
455
				),
456
			array(
457
				"name" => "erledigt",
458
				"short" => "E",
459
				"class" => "status_green",
460
				),
461
			array(
462
				"name" => "abgeschlossen",
463
				"short" => "A",
464
				"class" => "status_white",
465
				),
466
			);
467
		$daten["rechnung_stati"] = array(
468
			array(
469
				"name" => "schreiben",
470
				"short" => "S",
471
				"class" => "status_red"),
472
			array(
473
				"name" => "geschrieben",
474
				"short" => "G",
475
				"class" => "status_yellow",
476
				),
477
			array(
478
				"name" => "bezahlt",
479
				"short" => "B",
480
				"class" => "status_green",
481
				),
482
			);
483
		$daten["lieferschein_stati"] = array(
484
			array(
485
				"name" => "schreiben",
486
				"short" => "S",
487
				"class" => "status_yellow"),
488
			array(
489
				"name" => "geschrieben",
490
				"short" => "G",
491
				"class" => "status_green",
492
				),
493
			array(
494
				"name" => "offen",
495
				"short" => "O",
496
				"class" => "status_red",
497
				),
498
			);
499
		$daten["mahnung_stati"] = array(
500
			array(
501
				"name" => "mahnung1",
502
				"short" => "1",
503
				"class" => "status_green"),
504
			array(
505
				"name" => "mahnung2",
506
				"short" => "2",
507
				"class" => "status_yellow",
508
				),
509
			array(
510
				"name" => "mahnung3",
511
				"short" => "3",
512
				"class" => "status_red",
513
				),
514
			);
515
		$daten["garantie_stati"] = array(
516
			array(
517
				"name" => "eingereicht",
518
				"short" => "E",
519
				"class" => "status_red"),
520
			array(
521
				"name" => "abgeschlossen",
522
				"short" => "A",
523
				"class" => "status_green",
524
				),
525
			);
526
		// Modul dokumente
1288 lars 527
		$preise_anzeigen = 1;
528
		if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
529
		{
530
			if (!isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
531
			{
532
				// "<br>für bestimmte user preis verbergen";
533
				$preise_anzeigen = 0;
534
			}
535
		}
1172 lars 536
		$order = $this->order->get($id);
1293 lars 537
		$this->smarty->assign('title', 'Bestellung bearbeiten');
1289 lars 538
		$this->smarty->assign('preise_anzeigen', $preise_anzeigen);
1172 lars 539
		$this->smarty->assign('order', $order);
1271 lars 540
		$this->smarty->assign('daten', $daten);
1172 lars 541
		$this->smarty->view('single_order.tpl');
1131 lars 542
	}
543
 
544
	public function save()
545
	{
1336 lars 546
		$this->order->save();
1131 lars 547
	}
1172 lars 548
 
1131 lars 549
	public function del($id = null)
550
	{
551
	}
552
 
553
}