Your IP : 216.73.216.248


Current Path : /home/digilove/public_html/components/com_marketplace/models/
Upload File :
Current File : /home/digilove/public_html/components/com_marketplace/models/sellerlist.php

<?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.model');
if (!class_exists('MarketplaceModelSellerlist')) {
    /**
     * MarketplaceModelSellerlist 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 MarketplaceModelSellerlist extends JModelLegacy
    {
        var $_data = null;  
        var $_pagination = null;
        /**
         * __construct function
         */
        function __construct()
        {
            parent::__construct();
            global $mainframe, $option , $app;
            $app = JFactory::getApplication();
            $limit = $app->getUserStateFromRequest(
                'global.list.limit',
                'limit',
                $app->getCfg('list_limit'),
                'int'
            );
            $limitstart = $app->input->getInt('limitstart', 0); 
            $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
            $this->setState('limit', $limit);
            $this->setState('limitstart', $limitstart);
        }
        /**
         * GetData function
         *
         * @return void
         */
        public function getData()
        {
            $db = $this->getDbo();
            $query = $db->getQuery(true);
            $db = JFactory::getDBO();
            $params = JComponentHelper::getParams('com_marketplace');
            $lazy_limit=trim($params->get('wk_lazy_load_limit'));
            $query->select('a.*,b.email')
                ->from($db->quoteName('#__marketplace_sellerprofile')." as a")
                ->join(
                    'LEFT',
                    $db->quoteName('#__users').' as b ON a.seller_id = b.id'
                )
                ->where('a.is_seller=1')
                ->group('b.id');
            $db->setQuery($query);
            $comm_l = count($db->loadObjectlist());
            $db->setQuery($query);
            try{
                $comm = $db->loadObjectlist();
            }catch(Exception $e){
                JFactory::getApplication()->enqueueMessage(
                    $e->getMessage(),
                    'error'
                );
                return false;
            }
            $this->_data=$comm;
            return $this->_data;
        }
        /**
         * GetRecords function
         *
         * @param integer $start var
         * @param integer $limit var
         * 
         * @return void
         */
        public function getRecords($start=0,$limit=5)
        {
            $db = $this->getDbo();
            $query = $db->getQuery(true);
            $db = JFactory::getDBO();
            $query->select('a.*,b.email,c.phone_1')
                ->from($db->quoteName('#__marketplace_sellerprofile')." as a")
                ->join(
                    'LEFT',
                    $db->quoteName('#__users').' as b ON a.seller_id = b.id'
                )
                ->join(
                    'LEFT',
                    $db->quoteName('#__virtuemart_userinfos').
                    " AS c ON a.seller_id=c.virtuemart_user_id"
                )
                ->where('a.is_seller=1')
                ->group('b.id');
            try{
                $db->setQuery($query, $start, $limit);
                return $db->loadObjectList();
            }
            catch(Exception $e){
                JFactory::getApplication()->enqueueMessage(
                    $e->getMessage(),
                    'error'
                );
            }
        }
        /**
         * GetTotal function
         *
         * @return void
         */
        function getTotal()
        {
            if (empty($this->_data)) {
                $query = $this->_buildQuery();
                try{
                    $this->_total = $this->_getListCount($query);
                }catch(Exception $e){
                    JFactory::getApplication()->enqueueMessage(
                        $e->getMessage(),
                        'error'
                    );
                    return false;
                }
            }
            return $this->_total;
        }
        /**
         * GetPagination function
         *
         * @return void
         */
        function getPagination()
        {
            if (empty($this->_pagination)) {
                try{
                    $this->_pagination = new JPagination(
                        $this->getTotal(),
                        $this->getState('limitstart'),
                        $this->getState('limit')
                    );
                }catch(Exception $e){
                    JFactory::getApplication()->enqueueMessage(
                        $e->getMessage(),
                        'error'
                    );
                    return false;
                }
            }
            return $this->_pagination;
        }
    }
}