Subversion-Projekte lars-tiefland.ci

Revision

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