<?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');
if (!class_exists('VmConfig')) {
    include JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/config.php';
}
VmConfig::loadConfig();
VmConfig::loadJLang('com_virtuemart', true);
/**
 * MarketplaceViewAdminproducts 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 MarketplaceViewAdminproducts extends JViewLegacy
{
    protected $items;
    protected $pagination;
    protected $state;
    /**
     * Display function
     *
     * @param [type] $tpl var
     * 
     * @return void
     */
    function display($tpl = null)
    {
        $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');
        $this->form=$this->get('form');
        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';
        $canDo = MarketplaceHelper::getActions(
            $this->state->get('filter.virtuemart_product_id')
        );
        JToolBarHelper::title(
            JText::_('COM_MARKETPLACE_ADMINPRODUCTS'), 'adminproducts'
        );
            
        if ($canDo->get('core.admin')) {
            JToolBarHelper::custom(
                'adminproducts.getProductInfo',
                'move', '',
                JText::_('ASSIGN_PRODUCT_TO_SELLER'), true
            );
            JToolBarHelper::divider();
            JToolbarHelper::deleteList(
                '', 'adminproducts.deleteproduct', 'Delete', true, true
            );
            JToolBarHelper::preferences('com_marketplace');
            JToolBarHelper::custom(
                'adminproducts.adminpublished', 'publish',
                '', JText::_('Publish'), true
            );
            JToolBarHelper::custom(
                'adminproducts.adminunpublished', 'unpublish',
                '', JText::_('Unpublish'), true
            );
        }
        JHtmlSidebar::setAction(
            'index.php?option=com_marketplace&view=adminproducts'
        );
    }
}
