Subversion-Projekte lars-tiefland.ci

Revision

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

<?php

/**
 * @author Lars Tiefland
 * @copyright 2016
 */

class Herstellerkatalog_model extends CI_Model
{
        public function __construct()
        {
                parent::__construct();
                $this->load->model('artikel_model', 'artikel');
                $this->load->model('alias_model', 'alias');
                $this->load->model('preise_model', 'preise');
        }

        public function get_info($hId)
        {
                $res = $this->db->get_where('Herstellerkatalog', array('id' => $hId));
                $row = $res->row_array();
                return $row;
        }
        public function list_hersteller($begin = '', $limit = null, $Eigenschaft_1 = 0,
                $Eigenschaft_2 = 0)
        {
                $where = " EXISTS (SELECT 1 FROM artikel a WHERE a.hersteller=h.id AND a.father > 0 AND a.status=0)";
                if ($begin)
                {
                        $where .= " AND name LIKE '".$begin."%'";
                }
                if ($Eigenschaft_1)
                {
                        $where .= " AND Eigenschaft_1=1";
                }
                if ($Eigenschaft_2)
                {
                        $where .= " AND Eigenschaft_2=1";
                }
                $this->db->distinct();
                $this->db->order_by('name', 'ASC');
                $res = $this->db->get_where('Herstellerkatalog h', $where);
                $rows = $res->result_array();
                return $rows;
        }

        public function list_items($hersteller = Null)
        {
                $this->db->select('ID');
                if (is_null($hersteller))
                {
                        $arr = array(
                                'language' => 'DE',
                                'status' => 0,
                                );
                }
                else
                {
                        $arr = array(
                                "hersteller" => $hersteller,
                                'language' => 'DE',
                                'status' => 0,
                                );
                }
                if (isset($_GET['kat']) && $_GET{'kat'})
                {
                        list($kat_id, $kat_name) = explode("-", $_GET['kat'], 2);
                        $this->smarty->assign('kat_name', $kat_name);
                        $arr['father'] = $kat_id;
                }
                $res = $this->db->get_where('artikel', $arr);
                while ($row = $res->unbuffered_row('array'))
                {
                        $a_id = $row['ID'];
                        $item = $this->artikel->get_artikel($a_id, true);
                        $items[] = $item;
                }
                return $items;
        }
}

?>