Subversion-Projekte lars-tiefland.ci

Revision

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

<?php

class Artikel extends CI_Controller
{
        public function __construct()
        {
                parent::__construct();
                $this->load->model('artikel_model', 'artikel');
                $this->load->model('herstellerkatalog_model', 'hersteller');
                $this->load->model('preise_model', 'preise');
                $this->load->model('medien_model', 'medien');
                if (isset($GLOBALS["web_rechte"]["online_shop"]["artikel"]["status"]) && $GLOBALS["web_rechte"]["online_shop"]["artikel"]["status"]) {
                        $artikelstatus = explode(";", $GLOBALS["web_rechte"]["online_shop"]["artikel"]["status"]);
                        $this->smarty->assign('artikelstatus', $artikelstatus);
                }
                if (isset($GLOBALS["web_rechte"]["online_shop"]["artikel"]["Lieferstatus"]) && $GLOBALS["web_rechte"]["online_shop"]["artikel"]["Lieferstatus"]) {
                        $lieferstatus = explode(";", $GLOBALS["web_rechte"]["online_shop"]["artikel"]["Lieferstatus"]);
                        $this->smarty->assign('lieferstatus', $lieferstatus);
                }
                if (isset($GLOBALS["web_rechte"]["online_shop"]["artikel"]["LieferstatusMaintainer"]) &&
                        $GLOBALS["web_rechte"]["online_shop"]["artikel"]["LieferstatusMaintainer"]) {
                        $lieferstatusMaintainer = explode(";", $GLOBALS["web_rechte"]["online_shop"]["artikel"]["LieferstatusMaintainer"]);
                        $this->smarty->assign('lieferstatusMaintainer', $lieferstatusMaintainer);
                }
                $robots = array(
                        "index,follow",
                        "index,nofollow",
                        "noindex,follow",
                        "noindex,nofollow",
                        );
                $hersteller = $this->hersteller->get_list('dropdown');
                $preiseNamen = explode(";", ";" . $GLOBALS["web_rechte"]["online_shop"]["artikel"]["preise"]);
                $this->smarty->assign('preisNamen', $preiseNamen);
                $this->smarty->assign('robots', $robots);
                $this->smarty->assign('hersteller', $hersteller);
        }

        public function create($father)
        {
                $daten = array("Father" => $father, );
                $this->smarty->assign('daten', $daten);
                $this->smarty->view('artikel.tpl');
        }
        public function edit($id = null)
        {
                $daten = array();
                if ($id) {
                        $daten = $this->artikel->get($id);
                }
                $this->smarty->assign('daten', $daten);
                $this->smarty->view('artikel.tpl');
        }

        public function medien($id)
        {
                $medien = $this->medien->get_artikel_medien($id);
                $this->smarty->assign("artikelId", $id);
                $this->smarty->assign('medien', $medien);
                $this->smarty->view('medien.tpl');
        }

        public function del($id = null)
        {
                if ($id) {
                        $daten = $this->artikel->get($id);
                        $name = $daten["kurzbezeichnung"];
                        $typ = "Artikel";
                        $this->smarty->assign('name', $name);
                        $this->smarty->assign('id', $id);
                        $this->smarty->assign('typ', $typ);
                        $this->smarty->view('del.tpl');
                } elseif ($this->input->post('id')) {
                        $this->artikel->del($this->input->post('id'));
                }
        }

        public function reset_cache($id)
        {
                $res = $this->artikel->reset_cache($id);
        }

        public function save()
        {
                if ($this->form_validation->run() !== false) {
                        $artikel = $this->input->post('artikel');
                        $this->artikel->save($artikel);
                } else {
                        echo validation_errors();
                }
        }
}