Subversion-Projekte lars-tiefland.ci

Revision

Revision 1379 | Revision 1398 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

/**
 * User
 * 
 * @package   
 * @author WebanOS CI
 * @copyright Lars Tiefland
 * @version 2016
 * @access public
 */
class Order extends CI_Controller
{

        public function __construct()
        {
                parent::__construct();
                $this->load->model('order_model', 'order');
        }
        /**
         * User::index()
         * 
         * @return
         */
        public function index($anker = '')
        {
                $ausgabearten = array(
                        array(
                                "id" => 0,
                                "name" => "Bestellung",
                                ),
                        array(
                                "id" => 1,
                                "name" => "Artikel",
                                ),
                        array(
                                "id" => 2,
                                "name" => "Schnelleditor",
                                ),
                        array(
                                "id" => 3,
                                "name" => "Bestelldetail",
                                ),
                        );

                $ausgabearten_sel = select_tpl("filter[ausgabeart]", $ausgabearten, "id", "name",
                        $filter["ausgabeart"], true);
                $bestellarten_sel = "";
                if (is_array($bestellarten))
                {
                        $showAlle = (isset($user_rechte["Warenwirtschaft"]["bestellung"]["bestellart"]) &&
                                isset($_SESSION["datenquellen"]["bestellarten"]) && count($_SESSION["datenquellen"]["bestellarten"]) <=
                                1);
                        $bestellarten_sel = select_tpl("filter[bestellart_id]", $bestellarten, "id",
                                "name", $filter["bestellart_id"], $showAlle);
                }
                $shops_neu = getShops();
                $showAlle = (isset($_SESSION["datenquellen"]["shops"]) && count($_SESSION["datenquellen"]["shops"]) <=
                        1);
                $shops_sel = select_tpl("filter[shopID]", $shops_neu, "ID", "Name", $filter["shopID"],
                        $showAlle);

                $stati = array(
                        "" => "alle",
                        "op_ib" => "offen und in B.",
                        "op_ib_re" => "of.,in B.u.res.",
                        "op" => "offene Posten",
                        "ib" => "in Bearbeitung",
                        "re" => "reserviert",
                        "er" => "erledigt",
                        "ab" => "abgeschlossen",
                        );
                $zeiten = array(
                        "alle",
                        "heute",
                        "gestern",
                        "vorgestern",
                        "lfd. Woche",
                        "letzte Woche",
                        strftime("%B %G"),
                        strftime("%B %G", strtotime("-1 month")),
                        strftime("%B %G", strtotime("-2 months")),
                        strftime("%B %G", strtotime("-3 months")),
                        strftime("%B %G", strtotime("-4 months")),
                        strftime("%B %G", strtotime("-5 months")),
                        strftime("%B %G", strtotime("-6 months")),
                        strftime("%B %G", strtotime("-7 months")),
                        strftime("%Y", time()),
                        strftime("%Y", strtotime("-1 year")));
                $rstati = array(
                        "" => "alle",
                        "S" => "schreiben",
                        "G" => "geschrieben",
                        "B" => "bezahlt",
                        "O" => "ohne",
                        );

                $laender_filter = getBestelllaender();

                if (isset($GLOBALS["web_rechte"]["Warenwirtschaft"]["logistiker"]["logistiker"]))
                {
                        $logistiker_filter = getLogistikerFilter();
                        $this->smarty->assign("logistiker_filter", $logistiker_filter);
                        $this->smarty->assign("logistiker_filter_sel", $filter["logistiker"]);
                }
                // Variablen zu Template zuweisen
                $this->smarty->assign("stati", $stati);
                $this->smarty->assign("stati_sel", $filter["status"]);
                $this->smarty->assign("rstati", $rstati);
                $this->smarty->assign("rstati_sel", $filter["rechnungsstatus"]);
                $this->smarty->assign("zeiten", $zeiten);
                $this->smarty->assign("zeiten_sel", $filter["zeit"]);
                $this->smarty->assign("bStatus", $bStatus);
                $this->smarty->assign("bStatus_sel", $filter["bStatus"]);
                $this->smarty->assign("ausgabearten", $ausgabearten_sel);
                $this->smarty->assign("bestellarten", $bestellarten_sel);
                $this->smarty->assign("bestellart", $bestellart);
                $this->smarty->assign("bestellung_ID", $filter["bestellung_ID"]);
                $this->smarty->assign("fremd_ID", $filter["fremd_ID"]);
                $this->smarty->assign("artikelsuche", $filter["artikelsuche"]);
                $this->smarty->assign("kundensuche", $filter["kundensuche"]);
                $this->smarty->assign("paketnummer", $filter["paketnummer"]);
                $this->smarty->assign("start", $filter["start"]);
                $this->smarty->assign("shortline1", $filter["shortline1"]);
                $this->smarty->assign("status1", $filter["status1"]);
                $this->smarty->assign("dokument", $filter["dokument"]);
                $this->smarty->assign("bezahlstatus", $filter["bezahlstatus"]);
                $this->smarty->assign("versandstatus", $filter["versandstatus"]);
                $this->smarty->assign("user_rechte", $GLOBALS["user_rechte"]);
                $this->smarty->assign("web_rechte", $GLOBALS["web_rechte"]);
                $this->smarty->assign("web_settings", $web_settings);
                $this->smarty->assign("shops", $shops_sel);
                $this->smarty->assign("filter_maske", $filter_maske);
                $this->smarty->assign("laender_filter", $laender_filter);
                $this->smarty->assign("laender_filter_sel", $filter["laender"]);

                if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"]))
                {
                        if ($GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"])
                        {
                                list($shortline1_name, $shortline1_size) = explode(";", $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["shortline1"]);
                        }
                        else
                        {
                                $shortline1_name = "Shortline1:";
                                $shortline1_size = 10;
                        }

                        $this->smarty->assign("shortline1_size", $shortline1_size);
                        $this->smarty->assign("shortline1_name", $shortline1_name);
                }
                if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["status1"]))
                {
                        if ($GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["status1"])
                        {
                                list($status1_name, $status1_option_str) = explode(";", $GLOBALS["web_rechte"]["Warenwirtschaft"]["bestellung"]["status1"],
                                        2);
                                $status1_options_arr = explode(";", $status1_option_str);
                                $status1_options = array("");
                                $status1_options_filter = array("alle");
                                foreach ($status1_options_arr as $option)
                                {
                                        $status1_options[$option] = $option;
                                        $status1_options_filter[$option] = $option;
                                }
                                //$status1_options = array_merge( $status1_options );
                        }
                        $this->smarty->assign("status1_name", $status1_name);
                        $this->smarty->assign("status1_options", $status1_options);
                        $this->smarty->assign("status1_options_filter", $status1_options_filter);
                }
                // Versandstatus
                if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["versandstatus"]))
                {
                        $versandstatus_options_filter = array(
                                "alle",
                                "offen",
                                "freigegeben",
                                "versand",
                                "ohne",
                                "offen+ohne",
                                );
                        $this->smarty->assign("versandstatus_options_filter", $versandstatus_options_filter);
                }

                $start_date = date('Y-m-d', strtotime("-10 days"));
                $i = 0;
                $versanddatum_options_filter[''] = 'Alle';
                while ($i <= 30)
                {
                        $i = $i + 1;
                        $date = new DateTime($start_date);
                        $date->modify('+'.$i.' day');
                        $versanddatum_options_filter[$date->format('Y-m-d')] = $date->format('d.m.Y');
                }
                $this->smarty->assign("versanddatum_options_filter", $versanddatum_options_filter);

                // Bezahlstatus SELECT BOX
                if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bezahlstatus"]["bezahlstatus"]))
                {
                        $bezahlstatus_options_filter[] = "alle";
                        $bezahlstatus_options_filter[] = "offen";
                        $bezahlstatus_options_filter[] = "bezahlt";
                        if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bezahlstatus"]["vorbezahlt_setzen"]))
                        {
                                $bezahlstatus_options_filter[] = "vorbezahlt";
                                $bezahlstatus_options_filter[] = "bezahlt und vorbezahlt";
                        }

                        $this->smarty->assign("bezahlstatus_name", $bezahlstatus_name);
                        $this->smarty->assign("bezahlstatus_options", $bezahlstatus_options);
                        $this->smarty->assign("bezahlstatus_options_filter", $bezahlstatus_options_filter);
                }
                if (isset($_POST["anker"]))
                {
                        $this->smarty->assign("anker", $_POST["anker"] + 1);
                }
                $orders = $this->order->get_list();
                $this->smarty->assign('anker', $anker);
                $this->smarty->assign('orders', $orders);
                $this->smarty->view('orders.tpl');
        }

        /**
         * User::edit()
         * 
         * @param mixed $id
         * @return void
         */
        public function edit($id = null)
        {
                $daten["artikel_stati"] = array(
                        array(
                                "name" => "offen",
                                "short" => "O",
                                "class" => "status_red"),
                        array(
                                "name" => "in Bearbeitung",
                                "short" => "B",
                                "class" => "status_yellow",
                                ),
                        array(
                                "name" => "reserviert",
                                "short" => "R",
                                "class" => "status_blue",
                                ),
                        array(
                                "name" => "erledigt",
                                "short" => "E",
                                "class" => "status_green",
                                ),
                        array(
                                "name" => "abgeschlossen",
                                "short" => "A",
                                "class" => "status_white",
                                ),
                        );
                $daten["rechnung_stati"] = array(
                        array(
                                "name" => "schreiben",
                                "short" => "S",
                                "class" => "status_red"),
                        array(
                                "name" => "geschrieben",
                                "short" => "G",
                                "class" => "status_yellow",
                                ),
                        array(
                                "name" => "bezahlt",
                                "short" => "B",
                                "class" => "status_green",
                                ),
                        );
                $daten["lieferschein_stati"] = array(
                        array(
                                "name" => "schreiben",
                                "short" => "S",
                                "class" => "status_yellow"),
                        array(
                                "name" => "geschrieben",
                                "short" => "G",
                                "class" => "status_green",
                                ),
                        array(
                                "name" => "offen",
                                "short" => "O",
                                "class" => "status_red",
                                ),
                        );
                $daten["mahnung_stati"] = array(
                        array(
                                "name" => "mahnung1",
                                "short" => "1",
                                "class" => "status_green"),
                        array(
                                "name" => "mahnung2",
                                "short" => "2",
                                "class" => "status_yellow",
                                ),
                        array(
                                "name" => "mahnung3",
                                "short" => "3",
                                "class" => "status_red",
                                ),
                        );
                $daten["garantie_stati"] = array(
                        array(
                                "name" => "eingereicht",
                                "short" => "E",
                                "class" => "status_red"),
                        array(
                                "name" => "abgeschlossen",
                                "short" => "A",
                                "class" => "status_green",
                                ),
                        );
                // Modul dokumente
                $preise_anzeigen = 1;
                if (isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
                {
                        if (!isset($GLOBALS["user_rechte"]["Warenwirtschaft"]["bestellung"]["preise_anzeigen"]))
                        {
                                // "<br>für bestimmte user preis verbergen";
                                $preise_anzeigen = 0;
                        }
                }
                $order = $this->order->get($id);
                $this->smarty->assign('title', 'Bestellung bearbeiten');
                $this->smarty->assign('preise_anzeigen', $preise_anzeigen);
                $this->smarty->assign('order', $order);
                $this->smarty->assign('daten', $daten);
                $this->smarty->view('single_order.tpl');
        }

        public function save()
        {
                $this->order->save();
        }

        public function del($id = null)
        {
        }

}