Subversion-Projekte lars-tiefland.ci

Revision

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