<?php

namespace Nextend\SmartSlider3Pro\Generator\Joomla\Redshop\Elements;

use Nextend\Framework\Database\Database;
use Nextend\Framework\Form\Element\Select;


class RedshopSuppliers extends Select {

    public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
        parent::__construct($insertAt, $name, $label, $default, $parameters);

        $query = 'SELECT name, id FROM #__redshop_supplier WHERE published = 1 ORDER BY id';

        $suppliers = Database::queryAll($query, false, "object");

        $this->options['0'] = n2_('All');

        if (count($suppliers)) {
            foreach ($suppliers AS $supplier) {
                $this->options[$supplier->id] = $supplier->name;
            }
        }
    }

}
