Your IP : 216.73.216.11


Current Path : /home/digilove/public_html/components/com_marketplace/controllers/
Upload File :
Current File : /home/digilove/public_html/components/com_marketplace/controllers/category.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.controller');
jimport('joomla.filesystem.file');
if (!class_exists('VmConfig')) {
    include JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/config.php';
}
if (!class_exists('CurrencyDisplay')) {
    include JPATH_ADMINISTRATOR.
    '/components/com_virtuemart/helpers/currencydisplay.php';
}
if (!class_exists('MarketplaceHelper')) {
    include JPATH_ADMINISTRATOR.DIRECTORY_SEPARATOR.'components'.
    DIRECTORY_SEPARATOR.'com_marketplace'.DIRECTORY_SEPARATOR.'helpers'.
    DIRECTORY_SEPARATOR.'marketplace.php';
}
$obj=CurrencyDisplay::getInstance();
$wk_currency = $obj->getSymbol();
/**
 * MarketplaceControllerCategory 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 MarketplaceControllerCategory extends JControllerLegacy
{
    /**
     * Display function
     *
     * @param boolean $cachable  var
     * @param [type]  $urlparams var
     * 
     * @return void
     */
    function display($cachable = false, $urlparams = Array())
    {
        parent::display();
    }
    /**
     * SrchSrt function
     *
     * @return void
     */
    public function srchSrt()
    {
        $vmconfig=VmConfig::loadConfig();
        $currencyInstance = CurrencyDisplay::getInstance();
        $changeCurrency=$currencyInstance->getCurrencyForDisplay();
        $jinput =JFactory::getApplication()->input;
        $category_id = $jinput->get('category_id');
        $seller_id = $jinput->get('seller');
        $sort_by =$jinput->get('sort_by');
        $search =$jinput->get('search');
        $obj=CurrencyDisplay::getInstance();
        $wk_currency = $obj->getSymbol();
        $model = $this->getModel('Category');
        $latest_products = $model->catPro(
            $seller_id,
            $category_id,
            $sort_by,
            $search
        );
        $add_pro_menu = MarketplaceHelper::getMpMenuItem('addproduct');
        $user=JFactory::getUser();
        $u_id = $user->id;
        $pro="";
        $productModel=VmModel::getModel('product');
        $favModel=JModelLegacy::getInstance('Productlist', 'MarketplaceModel'); 
        foreach ($latest_products as $all_pro) {
            $proMod = $productModel->getProduct($all_pro->virtuemart_product_id);
            if (isset($all_pro->virtuemart_product_id)) {
                $product_edit_link = JRoute::_(
                    'index.php?option=com_marketplace&view=addproduct&'.
                    'virtuemart_product_id='.$all_pro->virtuemart_product_id.
                    '&Itemid='.$add_pro_menu->id,
                    false
                );
                $dis_price_indx = 0;
                foreach ($proMod->allPrices as $key => $value) {
                    if (isset($value["salesPrice"])) {
                        $dis_price_indx = $key;
                        break;
                    }
                }
                if ($all_pro->rating!=null) {
                    $rt=round($all_pro->rating);
                } else {
                    $rt=0;
                }
                if ($favModel->getFevorite($all_pro->virtuemart_product_id)==1) {
                    $col="#FA1517";
                } else {
                    $col="#FFF";
                }
                $pro=$pro.'<div class="recent_pro visible-desktop"><div class="pro_img"><a href="index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$all_pro->virtuemart_product_id.'"><img class="image_pro" width="100%" src="'.JURI::root().$all_pro->file_url.'"/></a></div><div class="pro_name">';
                        
                $pro=$pro.$all_pro->product_name.'</div><div class="pro_price">';
                if ($proMod->allPrices[$dis_price_indx]["basePriceWithTax"]>$proMod->allPrices[$dis_price_indx]["salesPrice"]) {
                    $pro.="<span style='text-decoration:line-through'>".$currencyInstance->getFormattedCurrency(
                        $currencyInstance->roundForDisplay(
                            $currencyInstance->convertCurrencyTo($changeCurrency, $proMod->allPrices[$dis_price_indx]["basePriceWithTax"], false)
                        )
                    )."</span>";
                }
                $pro.='<span class="current">'.$currencyInstance->getFormattedCurrency(
                    $currencyInstance->roundForDisplay(
                        $currencyInstance->convertCurrencyTo($changeCurrency, $proMod->allPrices[$dis_price_indx]["salesPrice"], false)
                    )
                ).'</span></div><div class="hover_product" style="display:none;"><div class="wk_heart_fevorite" >
                <a class="wk_fevorite_pro" id="'.$all_pro->virtuemart_product_id.'" href="javascript:void(0)" title="'.JText::_('CLICK_HERE_TO_FEVORITE').'"><span class="icon-heart" style="font-size:25px!important;color:'. $col.';" ></span></a>
                </div><div class="rating"><span class="yellow">';
                $xv= 5-$rt; 
                for ($i=0; $i < $rt ; $i++) {
                     $pro=$pro.'<i class="pad_none fa fa-star" style="font-size:15px !important;"></i>';
                }
                if ($xv>0) {
                    for ($i=0; $i <$xv ; $i++) {
                        $pro=$pro.'<i class="pad_none fa fa-star-o" style="font-size:15px !important;"></i>';
                    }
                }
                $pro=$pro.'</span></div><div class="pro_buy_grid"><div style="text-align:center;"><a class="btn btn-primary  btn-block" href="'.JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$all_pro->virtuemart_product_id).'">'.JText::_('BUY_NOW').'</a></div>';
                if ((int)$seller_id === (int)$u_id) {
                    $pro.='<div class="edit_pro"><a class="btn btn-success btn-block" href="'.
                    $product_edit_link.'">'.JText::_('MARKETPLACE_EDIT').'</a></div>';
                }
                $pro.='</div></div></div>';
            }
        }
        echo $pro;
        JFactory::getApplication()->close();
    }
    /**
     * SrchSrtLst function
     *
     * @return void
     */
    public function srchSrtLst()
    {
        $vmconfig=VmConfig::loadConfig();
        $currencyInstance = CurrencyDisplay::getInstance();
        $changeCurrency=$currencyInstance->getCurrencyForDisplay();
        $jinput =JFactory::getApplication()->input;
        $category_id = $jinput->get('category_id');
        $seller_id = $jinput->get('seller');
        $sort_by =$jinput->get('sort_by');
        $search =$jinput->get('search');
        $mode =$jinput->get('mode');
        $obj=CurrencyDisplay::getInstance();
        $wk_currency = $obj->getSymbol();
        $model = $this->getModel('Category');
        $latest_products = $model->catPro(
            $seller_id,
            $category_id,
            $sort_by,
            $search
        );
        if (!isset($latest_products)) {
            $latest_products=array();
        }
        $pro="";
        $add_pro_menu = MarketplaceHelper::getMpMenuItem('addproduct');
        $user=JFactory::getUser();
        $u_id = $user->id;
        $productModel=VmModel::getModel('product');
        foreach ($latest_products as $all_pro) {
            $proMod = $productModel->getProduct($all_pro->virtuemart_product_id);
            if (isset($all_pro->virtuemart_product_id)) {
                $product_edit_link = JRoute::_(
                    'index.php?option=com_marketplace&view=addproduct&'.
                    'virtuemart_product_id='.$all_pro->virtuemart_product_id.
                    '&Itemid='.$add_pro_menu->id,
                    false
                );
                $dis_price_indx = 0;
                foreach ($proMod->allPrices as $key => $value) {
                    if (isset($value["salesPrice"])) {
                        $dis_price_indx = $key;
                        break;
                    }
                }
                $t=time();
                $t=date("Y-m-d", $t);
                if (isset($item->created_on)) {
                    $time=$all_pro->created_on;
                } else {
                    $time=$t;
                }
                $dt1=explode("-", $time[0]);
                if (count($dt1)>2) {
                    $y1=(int)$dt1[0];
                    $m1=(int)$dt1[1];
                    $d1=(int)$dt1[2];

                    $dt2=explode("-", $t);
                    $y2=(int)$dt2[0];
                    $m2=(int)$dt2[1];
                    $d2=(int)$dt2[2];

                    $y3=$y2-$y1;
                    $m3=$m2-$m1;
                    $d3=$d2-$d1;
                }
                if ($all_pro->rating!=null) {
                    $rt=round($all_pro->rating);
                } else {
                    $rt=0;
                }
                if ($mode=="grid") {
                    $pro=$pro.'<div class="recent_pro_md hidden-desktop';
                } else {
                    $pro=$pro.'<div class="recent_pro_md';
                }
                $pro=$pro.'"><div class="pro_img"><a href="index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$all_pro->virtuemart_product_id.'" target=""><img class="image_pro" width="100%" src="'.JURI::root().$all_pro->file_url.'"/></a></div><div class="pro_name">';
                $pro=$pro.$all_pro->product_name.'<div class="rating">';
                $pro=$pro.'<span class="yellow">';
                $xv= 5-$rt;
                for ($i=0; $i < $rt ; $i++) { 
                    $pro=$pro.'<i class="pad_none fa fa-star" style="font-size:15px !important;"></i>';
                }
                if ($xv>0) {
                    for ($i=0; $i <$xv ; $i++) {
                        $pro=$pro.'<i class="pad_none fa fa-star-o" style="f'.
                        'ont-size:15px !important;"></i>';
                    }
                }
                $pro=$pro.'</span></div><div class="pro_price">';
                if ($proMod->allPrices[$dis_price_indx]["basePriceWithTax"]>$proMod->allPrices[$dis_price_indx]["salesPrice"]) {
                    $pro.="<span style='text-decoration:line-through'>".$currencyInstance->getFormattedCurrency(
                        $currencyInstance->roundForDisplay(
                            $currencyInstance->convertCurrencyTo($changeCurrency, $proMod->allPrices[$dis_price_indx]["basePriceWithTax"], false)
                        )
                    )."</span>";
                }
                $pro.='<span class="current">'.$currencyInstance->getFormattedCurrency(
                    $currencyInstance->roundForDisplay(
                        $currencyInstance->convertCurrencyTo($changeCurrency, $proMod->allPrices[$dis_price_indx]["salesPrice"], false)
                    )
                ).'</span></div>';
                $pro=$pro.'<div class="pro_buy_grid"><div style="text-align:center;"><a class="btn btn-primary  btn-block" href="'.JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$all_pro->virtuemart_product_id).'">'.JText::_('BUY_NOW').'</a></div></div>';
                if ((int)$seller_id === (int)$u_id) {
                    $pro.='<div class="edit_pro"><a class="btn btn-success btn-block" href="'.
                    $product_edit_link.'">'.JText::_('MARKETPLACE_EDIT').'</a></div>';
                }
                $pro.='</div></div></div>';
            }
        }
        echo $pro; 
        JFactory::getApplication()->close();
    }
}