<?php
/**
 * Marketplace - Component Marketplace 
 * ******************************************************************
 *
 * PHP version 7.0
 *
 * @category   Component
 * @package    Joomla
 * @author     WebKul software private limited <support@webkul.com>
 * @copyright  2010 WebKul software private limited
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version    GIT:5.2
 * @filesource http://store.webkul.com
 * @link       Technical Support:  webkul.uvdesk.com
 * ******************************************************************
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');
jimport('joomla.html.html');
jimport('joomla.html.behavior');
/**
 * MarketplaceViewProducts class
 * 
 * @category Component
 * @package  Joomla
 * @author   WebKul software private limited <support@webkul.com>
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link     Technical Support:  webkul.uvdesk.com
 */
class MarketplaceViewProducts extends JViewLegacy
{
    protected $items;
    protected $pagination;
    protected $state;
    public $filterForm;
    public $activeFilters;
    public $sortColumn;
    public $sortDirection;
    public $searchterms;
    /**
     * Display function
     *
     * @param [type] $tpl var
     * 
     * @return void
     */
    function display($tpl = null)
    { 
        global $option;
        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');
        $this->state = $this->get('State');
        $this->filterForm    = $this->get('FilterForm');
        $this->activeFilters = $this->get('ActiveFilters');
        $app=JFactory::getApplication();
        $app->setUserState('com_marketplace.products'.'.filter.status', 1);
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode('<br />', $errors));
            return false;
        }
        $this->addToolBar();
        $this->sidebar = JHtmlSidebar::render();
        parent::display($tpl);
    }
    /**
     * AddToolBar function
     *
     * @return void
     */
    protected function addToolBar() 
    {
        include_once JPATH_COMPONENT . '/helpers/marketplace.php';
        JToolBarHelper::publishList($task = 'products.published');
        JToolBarHelper::unpublishList($task = 'products.unpublished');
        JToolBarHelper::title(JText::_('COM_MARKETPLACE_PRODUCTS'), 'products');
        JToolBarHelper::preferences('com_marketplace');
        JToolBarHelper::custom(
            'products.deleteproduct', 'delete.png',
            'iconname.png', 'Delete', true, true
        );
    }
    /**
     * GetSortFields function
     *
     * @return void
     */
    protected function getSortFields()
    {
        return array(  
            'a.published' => JText::_('JSTATUS'),
            'a.productname' => JText::_('PRODUCT_NAME'),
            'a.virtuemart_product_id' => JText::_('JGRID_HEADING_ID')
        );
    }
}
