Exemple #1
0
 public function load_order()
 {
     $session = JFactory::getSession();
     $model = $this->getModel('profile');
     $order = $model->getOrder();
     $session->set('shopcart_discount', $order->coupon);
     $session->set('shop_order_id', $order->id);
     $this->setRedirect(JRoute::_('index.php?option=com_ksenmart&view=cart&Itemid=' . KSSystem::getShopItemid(), false));
 }
Exemple #2
0
 function close_order()
 {
     $session = JFactory::getSession();
     $order_id = $session->get('shop_order_id', 0);
     if ($order_id != 0) {
         $model = $this->getModel('cart');
         $model->closeOrder();
         $this->setRedirect(JRoute::_('index.php?option=com_ksenmart&view=cart&layout=congratulation&Itemid=' . KSSystem::getShopItemid(), false));
     }
 }
Exemple #3
0
 public function add_comment()
 {
     $app = JFactory::getApplication();
     $model = $this->getModel('Product', 'KsenmartModel');
     $comments_model = $this->getModel('Comments', 'KsenmartModel');
     $return_url = JRoute::_('index.php?option=com_ksenmart&view=product&id=' . $model->_id . '&Itemid=' . KSSystem::getShopItemid());
     $requestData = $this->input->post->get('jform', array(), 'array');
     $data = array();
     if (count($requestData)) {
         $model->form = 'review';
         $form = $model->getForm();
         if (!$form) {
             JError::raiseError(500, $model->getError());
             return false;
         }
         $data = $model->validate($form, $requestData);
         if ($data === false) {
             $errors = $model->getErrors();
             for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
                 if ($errors[$i] instanceof Exception) {
                     $app->enqueueMessage($errors[$i]->getMessage(), 'warning');
                 } else {
                     $app->enqueueMessage($errors[$i], 'warning');
                 }
             }
             $this->setRedirect($return_url);
             return false;
         }
     } else {
         $data = array();
         $data['comment_name'] = $this->input->post->get('comment_name', $user->name, 'string');
         $data['comment_rate'] = $this->input->post->get('comment_rate', 0, 'int');
         $data['comment_comment'] = $this->input->post->get('comment_comment', null, 'string');
         $data['comment_good'] = $this->input->post->get('comment_good', null, 'string');
         $data['comment_name'] = $this->input->post->get('comment_bad', null, 'string');
     }
     $data['product_id'] = $model->_id;
     $comments_model->addComment($data);
     if (!isset($_SESSION['rated']) || !is_array($_SESSION['rated'])) {
         $_SESSION['rated'] = array();
     }
     $_SESSION['rated'][$model->_id] = 1;
     $this->setMessage('Ваш отзыв принят');
     $this->setRedirect($return_url);
     return true;
 }
Exemple #4
0
 public static function AddHeadTags()
 {
     if (self::$_headAdded == true) {
         return;
     }
     $session = JFactory::getSession();
     $document = JFactory::getDocument();
     JDispatcher::getInstance()->trigger('onLoadKsen', array('ksenmart.KSM', array('common'), array(), array('angularJS' => 0)));
     KSLoader::loadLocalHelpers(array('common'));
     $params = JComponentHelper::getParams('com_ksenmart');
     $document->addScript(JURI::base() . 'administrator/components/com_ksenmart/js/jquery.custom.min.js');
     $document->addScript(JURI::base() . 'components/com_ksenmart/js/common.js');
     $document->addStyleSheet(JURI::base() . 'components/com_ksenmart/css/common.css');
     if ($params->get('include_css', 1)) {
         $document->addStyleSheet(JURI::base() . 'components/com_ksenmart/css/template.css');
     }
     $js = "\n        var URI_ROOT='" . JURI::root() . "';\n        var km_cart_link='" . JRoute::_('index.php?option=com_ksenmart&view=cart&Itemid=' . KSSystem::getShopItemid()) . "';\n        var shopItemid='" . KSSystem::getShopItemid() . "';\n        var order_type='ordering';\n        var order_dir='asc';    \n        var limit=" . $params->get('site_product_limit', 30) . ";\n        var limitstart=0;   \n        var use_pagination=" . $params->get('site_use_pagination', 0) . ";\n        var order_process=" . $params->get('order_process', 0) . ";\n        var cat_id=" . JRequest::getInt('id', 0) . ";\n        var user_id=" . JFactory::getUser()->id . ";\n        var page=1;\n        var session_id='" . $session->getId() . "';\n        ";
     $document->addScriptDeclaration($js);
     self::$_headAdded = true;
     KSSystem::loadPlugins();
 }
Exemple #5
0
 public function getInput()
 {
     $db = JFactory::getDBO();
     $this->value = is_array($this->value) ? $this->value : array();
     $html = '<style>.form-horizontal .controls {margin:0px;}</style>';
     $html .= '<table class="table table-striped" id="articleList">';
     $html .= '	<thead>';
     $html .= '		<tr>';
     $html .= '			<th class="title">' . JText::_('ksm_plugin_modules_module_title') . '</th>';
     $html .= '			<th width="10%" class="nowrap hidden-phone">' . JText::_('ksm_plugin_modules_module_position') . '</th>';
     $html .= '			<th width="30%" class="nowrap hidden-phone">' . JText::_('ksm_plugin_modules_module_pages') . '</th>';
     $html .= '			<th width="30%" class="hidden-phone">' . JText::_('ksm_plugin_modules_module_categories') . '</th>';
     $html .= '		</tr>';
     $html .= '	</thead>';
     $query = $db->getQuery(true);
     $query->select('a.id, a.title, a.position, a.published, map.menuid')->from('#__modules AS a')->join('LEFT', sprintf('#__modules_menu AS map ON map.moduleid = a.id AND map.menuid IN (0, %1$d, -%1$d)', KSSystem::getShopItemid()))->select('(SELECT COUNT(*) FROM #__modules_menu WHERE moduleid = a.id AND menuid < 0) AS ' . $db->quoteName('except'));
     $query->select('ag.title AS access_title')->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access')->where('a.published >= 0')->where('a.client_id = 0')->where('a.title != ' . $db->quote(''))->order('a.position, a.ordering');
     $db->setQuery($query);
     $modules = $db->loadObjectList();
     $page_options = array(JHtml::_('select.option', 0, JText::_('JALL')), JHtml::_('select.option', -1, JText::_('ksm_plugin_modules_noone')));
     foreach ($this->pages as $key => $page) {
         $page_options[] = JHtml::_('select.option', $key, JText::_('ksm_plugin_modules_page_' . $page));
     }
     $cat_options = $this->getCatOptions();
     foreach ($modules as $module) {
         if (is_null($module->menuid) && (!$module->except || $module->menuid < 0)) {
             continue;
         }
         $selected_pages = isset($this->value[$module->position][$module->id]['pages']) ? $this->value[$module->position][$module->id]['pages'] : array(0);
         $selected_cats = isset($this->value[$module->position][$module->id]['categories']) ? $this->value[$module->position][$module->id]['categories'] : array(0);
         $html .= '<tr>';
         $html .= '	<td class="title">' . $module->title . '</th>';
         $html .= '	<td width="10%" class="nowrap hidden-phone">' . $module->position . '</th>';
         $html .= '	<td width="30%" class="nowrap hidden-phone">' . JHtml::_('select.genericlist', $page_options, $this->name . '[' . $module->position . '][' . $module->id . '][pages][]', 'multiple="multiple"', 'value', 'text', $selected_pages) . '</th>';
         $html .= '	<td width="30%" class="hidden-phone">' . JHtml::_('select.genericlist', $cat_options, $this->name . '[' . $module->position . '][' . $module->id . '][categories][]', 'multiple="multiple"', 'value', 'text', $selected_cats) . '</th>';
         $html .= '</tr>';
     }
     $html .= '</table>';
     return $html;
 }
Exemple #6
0
 function getManufacturers($group)
 {
     $db = JFactory::getDBO();
     $session_manufacturers = JRequest::getVar('manufacturers', array());
     JArrayHelper::toInteger($session_manufacturers);
     $query = $db->getQuery(true);
     $query->select('
     		km.*,
     		kf.filename,
     		kf.folder,
     		kf.params
     	')->from('#__ksenmart_manufacturers as km')->leftjoin("#__ksenmart_countries as kc on km.country=kc.id")->leftjoin("#__ksenmart_files as kf on kc.id=kf.owner_id and kf.owner_type='country'")->where('km.published=1')->order('km.title');
     if ($group) {
         $query->select('
                 kc.id AS country_id,
                 kc.title AS country_title
             ');
     } else {
         $query->group('km.id');
     }
     $db->setQuery($query);
     $manufacturers = $db->loadObjectList('id');
     $tmpManufacturers = array();
     foreach ($manufacturers as &$manufacturer) {
         $manufacturer->selected = in_array($manufacturer->id, $session_manufacturers) ? true : false;
         if (!empty($manufacturer->folder)) {
             $manufacturer->small_img = KSMedia::resizeImage($manufacturer->filename, $manufacturer->folder, 25, 30, json_decode($manufacturer->params, true));
         }
         unset($manufacturer->filename);
         unset($manufacturer->folder);
         $manufacturer->link = JRoute::_('index.php?option=com_ksenmart&view=catalog&manufacturers[]=' . $manufacturer->id . '&Itemid=' . KSSystem::getShopItemid());
         if ($group) {
             $tmpManufacturers[$manufacturer->country_title][] = $manufacturer;
         }
     }
     if (!$tmpManufacturers) {
         $tmpManufacturers = $manufacturers;
     }
     return $tmpManufacturers;
 }
Exemple #7
0
		<td align="center"><b><?php 
echo JText::_('KSM_ORDER_MAIL_PRODUCT_PRICE');
?>
</b></td>
		<td align="center"><b><?php 
echo JText::_('KSM_ORDER_MAIL_PRODUCT_SUM');
?>
</b></td>
	</tr>
    <?php 
foreach ($this->order->items as $item) {
    ?>
    		<tr class="row_odd">
    			<td class="vid_produkt">
    				<a class="title_lookp" href="<?php 
    echo JURI::root() . JRoute::_('index.php?option=com_ksenmart&view=product&id=' . $item->product_id . ':' . $item->product->alias . '&Itemid=' . KSSystem::getShopItemid());
    ?>
" ><?php 
    echo $item->product->title;
    ?>
</a>
                    <?php 
    if ($item->product->product_code != '') {
        ?>
                        <i><?php 
        echo JText::_('KSM_ORDER_MAIL_PRODUCT_SKU');
        ?>
 <?php 
        echo $item->product->product_code;
        ?>
</i>
Exemple #8
0
<?php

defined('_JEXEC') or die;
$user = KSUsers::getUser();
$profile_link = JRoute::_('index.php?option=com_ksenmart&view=profile&Itemid=' . KSSystem::getShopItemid());
?>
<div class="accordion catalog-menu" id="dropdownCat">
	<h3><?php 
echo $module->title;
?>
</h3>
	<div class="user-info">
		<div class="avatar">
			<img src="<?php 
echo $user->logo_thumb;
?>
" alt="<?php 
echo $user->name;
?>
" class="border_ksen" />
		</div>
		<div class="user_name"><?php 
echo $user->name;
?>
</div>
		<br clear="both">
	</div>
	<div class="left-menu">
		<ul class="nav nav-list">
			<li><a href="<?php 
echo $profile_link;
Exemple #9
0
    echo $this->product->tag;
    ?>
</a></span>
		</div>
	</div>
<?php 
}
?>
	
<?php 
if (isset($this->product->manufacturer->country) && count($this->product->manufacturer->country) > 0) {
    ?>
	<div class="control-group">
		<label class="control-label"><?php 
    echo JText::_('KSM_PRODUCT_COUNTRY');
    ?>
</label>
		<div class="controls">
			<span><a href="<?php 
    echo JRoute::_('index.php?option=com_ksenmart&view=catalog&countries[]=' . $this->product->manufacturer->country->id . '&Itemid=' . KSSystem::getShopItemid() . '&clicked=countries');
    ?>
"><?php 
    echo $this->product->manufacturer->country->title;
    ?>
</a></span>
		</div>
	</div>
<?php 
}
?>
	
Exemple #10
0
 public function getCart()
 {
     $this->onExecuteBefore('getCart');
     $Itemid = KSSystem::getShopItemid();
     if (!empty($this->order_id)) {
         $cart = KSMOrders::getOrder($this->order_id);
         $this->setDefaultCartValues($cart);
         $cart->items = KSMOrders::getOrderItems($this->order_id);
         for ($k = 0; $k < count($cart->items); $k++) {
             $cart->items[$k]->del_link = JRoute::_('index.php?option=com_ksenmart&view=cart&task=cart.update_cart&item_id=' . $cart->items[$k]->id . '&count=0&Itemid=' . $Itemid);
             $cart->total_prds += $cart->items[$k]->count;
             $cart->products_sum += $cart->items[$k]->count * $cart->items[$k]->price;
         }
     } else {
         $this->setDefaultCartValues($cart);
     }
     $cart->products_sum_val = KSMPrice::showPriceWithTransform($cart->products_sum);
     $cart->total_sum = $cart->products_sum;
     $cart->total_sum_val = KSMPrice::showPriceWithTransform($cart->total_sum);
     $this->onExecuteAfter('getCart', array(&$cart));
     return $cart;
 }
<?php

defined('_JEXEC') or die;
$link = JRoute::_('index.php?option=com_ksenmart&view=cart&layout=congratulation&order_id=' . $this->order_id . '&Itemid=' . KSSystem::getShopItemid());
?>
<script>
    window.parent.location = '<?php 
echo $link;
?>
';
</script>
Exemple #12
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $path = $app->getPathway();
     $document = JFactory::getDocument();
     $this->params = JComponentHelper::getParams('com_ksenmart');
     $shop_name = $this->params->get('shop_name', 'магазине');
     $pref = $this->params->get('path_separator', '-');
     $doc_title = $shop_name . $pref . 'Отзывы';
     $id = $app->input->get('id', 0, 'int');
     $layout = $this->getLayout();
     $document->setTitle($doc_title);
     $document->addStyleSheet(JURI::base() . 'components/com_ksenmart/css/shop_reviews.css');
     switch ($layout) {
         case 'comments':
             if (!JFactory::getConfig()->get('config.caching', 0)) {
                 $path->addItem(JText::_('KSM_REVIEWS_LIST_PATH_TITLE'));
             }
             $comments = $this->get('comments');
             $pagination = $this->get('Pagination');
             $this->assignRef('pagination', $pagination);
             $this->assignRef('rows', $comments);
             break;
         case 'comment':
             if ($id > 0) {
                 if (!JFactory::getConfig()->get('config.caching', 0)) {
                     $path->addItem(JText::_('KSM_REVIEWS_LIST_PATH_TITLE'), 'index.php?option=com_ksenmart&view=comments&layout=comments&Itemid=' . KSSystem::getShopItemid());
                     $path->addItem(JText::_('KSM_REVIEW_ITEM_PATH_TITLE'));
                 }
                 $comment = $this->get('Comment');
                 if (!$comment) {
                     JError::raiseError(404, 'Page not found');
                     return false;
                 }
                 $this->assignRef('comment', $comment);
             } else {
                 JError::raiseError(404, 'Page not found');
                 return false;
             }
             break;
         case 'reviews':
             if (!JFactory::getConfig()->get('config.caching', 0)) {
                 $path->addItem(JText::_('KSM_SHOP_REVIEWS_PATH_TITLE'));
             }
             $reviews = $this->get('ShopReviewsList');
             $user = KSUsers::getUser();
             $isset_review = KSSystem::issetReview($user->id);
             $this->assignRef('reviews', $reviews);
             $this->assignRef('user', $user);
             $this->assignref('show_shop_review', $isset_review);
             break;
         case 'review':
             if ($id > 0) {
                 $user = KSUsers::getUser();
                 $this->params = JComponentHelper::getParams('com_ksenmart');
                 $model = $this->getModel();
                 $review = $model->getShopReviewById($id);
                 if (!$review) {
                     JError::raiseError(404, 'Page not found');
                     return false;
                 }
                 $isset_review = KSSystem::issetReview($user->id);
                 $this->assignRef('review', $review);
                 $this->assignRef('user', $user);
                 $this->assignref('show_shop_review', $isset_review);
                 $document->setTitle(JText::sprintf('KSM_SHOP_REVIEW_PATH_TITLE_TEXT', $review->user->name, $shop_name));
                 if (!JFactory::getConfig()->get('config.caching', 0)) {
                     $path->addItem(JText::_('KSM_SHOP_REVIEWS_PATH_TITLE'), 'index.php?option=com_ksenmart&view=comments&layout=reviews&Itemid=' . KSSystem::getShopItemid());
                     $path->addItem(JText::sprintf('KSM_SHOP_REVIEW_PATH_TITLE_TEXT', $review->user->name, $shop_name));
                 }
             } else {
                 JError::raiseError(404, 'Page not found');
                 return false;
             }
             break;
     }
     parent::display($tpl);
 }
Exemple #13
0
 private function getResult()
 {
     $Itemid = KSSystem::getShopItemid();
     $this->value = trim(htmlspecialchars($this->value));
     if (!empty($this->value)) {
         if (empty($this->model)) {
             $this->model = $this->getModel('search');
         }
         $affected_rows = false;
         $p_ids = $this->model->getItemsSearch($this->value);
         if ($p_ids) {
             $affected_rows = true;
         }
         $cat_search = $this->model->getCatSearch($this->value);
         $manufacture_search = $this->model->getManufactureSearch($this->value);
         if ($this->ajax_search) {
             $relevant_search = $this->model->getRelevantSearches($this->value);
         }
         if ($affected_rows) {
             if (!$cat_search) {
                 if (!is_numeric($this->value)) {
                     $this->model->setRelevants($this->value);
                 }
             }
         } else {
             $p_ids = $this->model->getItemsSearch($this->value, true);
             if ($p_ids) {
                 $affected_rows = true;
             }
             if (!$cat_search) {
                 $cat_search = $this->model->getCatSearch($this->model->_correct_string);
             }
             if (!$manufacture_search) {
                 $manufacture_search = $this->model->getManufactureSearch($this->model->_correct_string);
             }
             if ($this->ajax_search) {
                 $relevant_search = $this->model->getRelevantSearches($this->model->_correct_string);
             }
             if ($affected_rows) {
                 if (!$cat_search) {
                     if (!is_numeric($this->model->_correct_string)) {
                         $this->model->setRelevants($this->model->_correct_string);
                     }
                 }
             }
         }
         if (!empty($results)) {
             //$results = $this->model->setImages($results);
             //echo $this->model->generateSearchResult($results);
         }
         if (!empty($cat_search)) {
             foreach ($cat_search as $key => $item) {
                 $item->product_total = $this->model->getProductTotalCategory($item->cat_id);
                 if (!$item->product_total) {
                     unset($cat_search[$key]);
                 }
             }
             sort($cat_search);
         }
         $mids = array();
         if (!empty($manufacture_search)) {
             foreach ($manufacture_search as $key => $item) {
                 $mids[$item->id] = $item->id;
                 $item->product_total = $this->model->getProductTotalManufacture($item->id);
                 if (!$item->product_total) {
                     unset($manufacture_search[$key]);
                 }
             }
             sort($manufacture_search);
         }
         $manufacture_products = $this->model->getProductManufacturs($mids);
         $p_ids = array_merge($p_ids, $manufacture_products);
         if ($this->ajax_search) {
             if (!empty($relevant_search)) {
                 foreach ($relevant_search as $key => $item) {
                     $item->product_total = $this->model->getCountRelevantsResult($item->title);
                     if (!$item->product_total) {
                         unset($relevant_search[$key]);
                     }
                 }
                 sort($relevant_search);
             }
             $this->assign('relevant_search', $relevant_search);
         }
         $products = $this->model->getProductsObject($p_ids);
         $this->assignRef('cat_search', $cat_search);
         $this->assignRef('manufacture_search', $manufacture_search);
         $this->assignRef('products', $products);
         $this->assignRef('shop_id', $Itemid);
     }
     return false;
 }
Exemple #14
0
 private function make_tree($category, $level = 1, $params)
 {
     if (isset($category->children) && !empty($category->children)) {
         $categories = $params->get('categories', array());
         $children = array_keys($category->children);
         $intersect = array_intersect($children, $categories);
         $filter = count($intersect) ? true : false;
         foreach ($category->children as $key => $child) {
             if ($filter && !in_array($key, $categories)) {
                 unset($category->children[$key]);
                 continue;
             }
             $child->level = $level;
             $child->deeper = false;
             $child->shallower = false;
             $child->level_diff = 0;
             $child->link = JRoute::_('index.php?option=com_ksenmart&view=catalog&categories[0]=' . $child->id . '&Itemid=' . KSSystem::getShopItemid());
             if (isset($this->tree[count($this->tree) - 1])) {
                 $this->tree[count($this->tree) - 1]->deeper = $child->level > $this->tree[count($this->tree) - 1]->level;
                 $this->tree[count($this->tree) - 1]->shallower = $child->level < $this->tree[count($this->tree) - 1]->level;
                 $this->tree[count($this->tree) - 1]->level_diff = $this->tree[count($this->tree) - 1]->level - $child->level;
             }
             $this->tree[] = $child;
             if (isset($this->tree[count($this->tree) - 1])) {
                 $this->tree[count($this->tree) - 1]->deeper = 1 > $this->tree[count($this->tree) - 1]->level;
                 $this->tree[count($this->tree) - 1]->shallower = 1 < $this->tree[count($this->tree) - 1]->level;
                 $this->tree[count($this->tree) - 1]->level_diff = $this->tree[count($this->tree) - 1]->level - 1;
             }
             $this->make_tree($this->menu[$child->id], $level + 1, $params);
         }
     }
 }
Exemple #15
0
 public static function getAddToCartLink()
 {
     $params = JComponentHelper::getParams('com_ksenmart');
     $Itemid = KSSystem::getShopItemid();
     if ($params->get('order_process', 0) == 1) {
         $session = JFactory::getSession();
         $order_id = $session->get('shop_order_id', 0);
         if ($order_id == 0) {
             $add_link_cart = JRoute::_('index.php?option=com_ksenmart&view=order&Itemid=' . $Itemid);
         } else {
             $add_link_cart = JRoute::_('index.php?option=com_ksenmart&view=cart&Itemid=' . $Itemid);
         }
     } else {
         $add_link_cart = JRoute::_('index.php?option=com_ksenmart&view=cart&Itemid=' . $Itemid);
     }
     return $add_link_cart;
 }
Exemple #16
0
    function onBeforeViewKSMCatalog($view)
    {
        $app = JFactory::getApplication();
        $db = JFactory::getDBO();
        $jinput = $app->input;
        $exportym = $jinput->get('exportym', null);
        if (empty($exportym)) {
            return false;
        }
        $currencies = '';
        $categories = '';
        $offers = '';
        $Itemid = '&amp;Itemid=' . KSSystem::getShopItemid();
        $query = $db->getQuery(true);
        $query->select('value')->from('#__ksenmart_yandeximport')->where('setting = ' . $db->quote('shopname'));
        $db->setQuery($query);
        $shopname = $db->loadResult();
        $query = $db->getQuery(true);
        $query->select('value')->from('#__ksenmart_yandeximport')->where('setting = ' . $db->quote('company'));
        $db->setQuery($query);
        $company = $db->loadResult();
        $query = $db->getQuery(true);
        $query->select('value')->from('#__ksenmart_yandeximport')->where('setting = ' . $db->quote('categories'));
        $db->setQuery($query);
        $cats = $db->loadResult();
        $cats = json_decode($cats, true);
        if (!is_array($cats)) {
            $cats = array();
        }
        if (!count($cats)) {
            $cats[] = 0;
        }
        $query = $db->getQuery(true);
        $query->select('rate')->from('#__ksenmart_currencies')->where('code = ' . $db->quote('RUR'));
        $db->setQuery($query);
        $rur_rate = $db->loadResult();
        $query = $db->getQuery(true);
        $query->select('rate')->from('#__ksenmart_currencies')->where('code = ' . $db->quote('RUR'));
        $db->setQuery($query);
        $rur_rate = $db->loadResult();
        $query = $db->getQuery(true);
        $query->select('*')->from('#__ksenmart_currencies');
        $db->setQuery($query);
        $rows = $db->loadObjectList();
        foreach ($rows as $row) {
            $currencies .= '<currency id="' . $row->code . '" rate="' . round($rur_rate / $row->rate, 4) . '"/>';
        }
        $query = $db->getQuery(true);
        $query->select('*')->from('#__ksenmart_categories')->where('id in (' . implode(',', $cats) . ')');
        $db->setQuery($query);
        $rows = $db->loadObjectList();
        foreach ($rows as $row) {
            $categories .= '<category id="' . $row->id . '" ' . ($row->parent_id != 0 ? 'parentId="' . $row->parent_id . '"' : '') . '>' . $row->title . '</category>';
        }
        $query = $db->getQuery(true);
        $query->select('p.*,pc.category_id')->from('#__ksenmart_products as p');
        $query->select('(select filename from #__ksenmart_files where owner_id=p.id and owner_type=' . $db->quote('product') . ' and media_type=' . $db->quote('image') . ' order by ordering limit 1) as picture');
        $query->select('(select title from #__ksenmart_manufacturers where id=p.manufacturer) as manufacturer_name');
        $query->select('(select code from #__ksenmart_currencies where id=p.price_type) as code');
        $query->innerjoin('#__ksenmart_products_categories as pc on pc.product_id=p.id');
        $query->where('pc.category_id in (' . implode(',', $cats) . ')')->where('p.published=1')->where('p.price>0')->where('p.parent_id=0');
        $db->setQuery($query);
        $rows = $db->loadObjectList();
        foreach ($rows as $row) {
            if ($row->picture != '') {
                $row->picture = JURI::root() . 'media/com_ksenmart/images/products/original/' . $row->picture;
            } else {
                $row->picture = JURI::root() . 'media/com_ksenmart/images/products/original/no.jpg';
            }
            $offers .= '<offer id="' . $row->id . '" available="' . ($row->in_stock > 0 ? 'true' : 'false') . '" bid="1">
				<url>' . JURI::root() . 'index.php?option=com_ksenmart&amp;view=product&amp;id=' . $row->id . ':' . $row->alias . $Itemid . '</url>
				<price>' . $row->price . '</price>
				<currencyId>' . $row->code . '</currencyId>
				<categoryId>' . $row->category_id . '</categoryId>
				<picture>' . $row->picture . '</picture>	
				<delivery>true</delivery>
				<name>' . htmlspecialchars($row->title, ENT_QUOTES) . '</name>
				<vendor>' . htmlspecialchars($row->manufacturer_name, ENT_QUOTES) . '</vendor>	
				<description>' . htmlspecialchars($row->content, ENT_QUOTES) . '</description>
			</offer>';
        }
        header('Content-Type: text/xml;charset:utf-8');
        echo '<?xml version="1.0" encoding="utf-8"?>
		<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
		<yml_catalog date="' . date('Y-m-d H:i') . '">
		<shop>
			<name>' . $shopname . '</name>
			<company>' . $company . '</company>
			<url>' . JURI::root() . '</url>
			<platform>KsenMart based on Joomla</platform>
			<version>3.0</version>
			<agency>L.D.M. Co</agency>
			<email>boss.dm@gmail.com</email>	
			<currencies>
				' . $currencies . '
			</currencies>
			<categories>
				' . $categories . '
			</categories>
			<offers>
				' . $offers . '
			</offers>
		</shop>
		</yml_catalog>
		';
        $app->close();
    }
Exemple #17
0
 public static function sendOrderIndoAdmin($order_id)
 {
     $dispatcher = JDispatcher::getInstance();
     $db = JFactory::getDBO();
     $Itemid = KSSystem::getShopItemid();
     $query = "select * from #__ksenmart_orders where id='{$order_id}'";
     $db->setQuery($query);
     $order = $db->loadObject();
     $content = '';
     $content .= '
         <table class="cellpadding">
             <tr>
                 <td colspan="2">Информация</td>
             </tr>
             <tr>
                 <td>Имя:</td>
                 <td>' . $order->name . '</td>
             </tr>                           
             <tr>
                 <td>E-mail:</td>
                 <td>' . $order->email . '</td>
             </tr>
             <tr>
                 <td>Адрес доставки:</td>
                 <td>' . $order->address . '</td>
             </tr>
         </table>    
         <h2>Заказ</h2>
         <table id="cart_content_tbl" cellspacing="0">
             <colgroup>
                 <col width="50%" />
                 <col width="15%" />
                 <col width="20%" />
                 <col width="5%" />
             </colgroup>
             <tr id="cart_content_header">
                 <td><b>Продукт</b></td>
                 <td align="center"><b>Кол-во</b></td>
                 <td align="center"><b>Цена</b></td>
                 <td align="center"><b>Стоимость</b></td>
             </tr>
     ';
     $query = "select * from #__ksenmart_order_items where order_id='{$order_id}'";
     $db->setQuery($query);
     $order->items = $db->loadObjectList();
     foreach ($order->items as &$item) {
         $item_properties = array();
         $properties = explode(';', $item->properties);
         foreach ($properties as $property) {
             $property = explode(':', $property);
             $query = "select * from #__ksenmart_properties where id='{$property['0']}'";
             $this->_db->setQuery($query);
             $prop = $this->_db->loadObject();
             if (count($prop) > 0) {
                 $item_properties[] = new stdClass();
                 $item_properties[count($item_properties) - 1]->title = $prop->title;
                 if ($prop->type == 'select' || $prop->type == 'radio') {
                     $query = "select * from #__ksenmart_property_values where id='{$property['1']}'";
                     $this->_db->setQuery($query);
                     $val = $this->_db->loadObject();
                     if (count($val) > 0) {
                         $item_properties[count($item_properties) - 1]->value = $val->title . ' ' . $prop->finishing;
                     }
                 }
             }
         }
         $query = "select * from #__ksenmart_products where id='{$item->product_id}'";
         $db->setQuery($query);
         $item->product = $db->loadObject();
         $link = JURI::root() . JRoute::_('index.php?option=com_ksenmart&view=product&id=' . $item->product->id . ":" . $item->product->alias . '&Itemid=' . $Itemid);
         $content .= '        
         <tr class="row_odd">
             <td class="vid_produkt">
                 <a class="title_lookp" href="' . $link . '" >' . $item->product->title . '</a>
         ';
         if ($item->product->product_code != '') {
             $content .= ' <i>Арт. ' . $item->product->product_code . '</i>';
         }
         foreach ($item_properties as $item_property) {
             if (!empty($item_property->value)) {
                 $content .= '<br><span>' . $item_property->title . ':</span> ' . $item_property->value;
             } else {
                 $content .= '<br><span>' . $item_property->title . '</span>';
             }
         }
         $content .= '                            
                 <div class="cart_product_brief_description">
                     <p>' . $item->product->introcontent . '</p>
                 </div>
             </td>
             <td align="center">' . $item->count . '</td>
             <td align="center">' . KSMPrice::showPriceWithTransform($item->price) . '</td>
             <td align="center" nowrap="nowrap">
                 ' . KSMPrice::showPriceWithTransform($item->count * $item->price) . '
             </td>
         </tr>';
     }
     $order->total_cost = $order->cost;
     $dispatcher->trigger('onAfterGetOrder', array(&$order));
     $results = $dispatcher->trigger('onDisplayAfterLetterContent', array(&$order));
     $order->onDisplayAfterLetterContent = trim(implode("\n", $results));
     $content .= '
         <tr>
             <td id="cart_total_label">
                 Общая стоимость товаров
             </td>
             <td align="center"></td>
             <td></td>
             <td id="cart_total" align="center">' . KSMPrice::showPriceWithTransform($order->cost) . '</td>
         </tr>
     ';
     $content .= $order->onDisplayAfterLetterContent;
     $content .= '            
         <tr>
             <td id="cart_total_label">
                 Стоимость доставки:
             </td>
             <td align="center">
             </td>
             <td></td>
             <td id="cart_total" align="center">' . KSMPrice::showPriceWithTransform($order->delivery_cost) . '</td>
         </tr>
         <tr>
             <td id="cart_total_label">
                 Итого
             </td>
             <td align="center"></td>
             <td></td>
             <td id="cart_total" align="center">' . KSMPrice::showPriceWithTransform($order->total_cost + $order->delivery_cost) . '</td>
         </tr>
     </table>';
     $mail =& JFactory::getMailer();
     $mail->isHTML(true);
     $params = JComponentHelper::getParams('com_ksenmart');
     $sender = array($params->get('shop_email'), $params->get('shop_name'));
     $mail->setSender($sender);
     $mail->Subject = 'Новый заказ №' . $order_id;
     $mail->Body = $content;
     $mail->AddAddress($params->get('shop_email'), $params->get('shop_name'));
     $mail->Send();
 }
Exemple #18
0
 public static function generateProductLink($pid, $alias = '')
 {
     if (!empty($pid) && $pid > 0) {
         return JRoute::_('index.php?option=com_ksenmart&view=product&id=' . $pid . ':' . $alias . '&Itemid=' . KSSystem::getShopItemid());
     }
     return null;
 }
Exemple #19
0
 function onBeforeStartComponent()
 {
     $config = JFactory::getConfig();
     if (!$config->get('config.caching', 0)) {
         return false;
     }
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $path = $app->getPathway();
     $jinput = $app->input;
     $view = $jinput->get('view', 'catalog', 'string');
     $layout = $jinput->get('layout', 'default', 'string');
     switch ($view) {
         case 'catalog':
             $catalog_path = array();
             $categories = JRequest::getVar('categories', array());
             JArrayHelper::toInteger($categories);
             $manufacturers = JRequest::getVar('manufacturers', array());
             JArrayHelper::toInteger($manufacturers);
             $countries = JRequest::getVar('countries', array());
             JArrayHelper::toInteger($countries);
             if (count($categories) == 1) {
                 $catid = $categories[0];
                 while ((int) $catid != 0) {
                     $query = "select id,parent,title,alias from #__ksenmart_categories where id='{$catid}'";
                     $db->setQuery($query);
                     $cat = $db->loadObject();
                     $cat->link = JRoute::_('index.php?option=com_ksenmart&view=catalog&categories[]=' . $cat->id);
                     $catalog_path[] = array('title' => $cat->title, 'link' => $cat->link);
                     $catid = $cat->parent;
                 }
                 $catalog_path = array_reverse($catalog_path);
             } elseif (count($manufacturers) == 1) {
                 $query = "select title from #__ksenmart_manufacturers where id='{$manufacturers['0']}'";
                 $db->setQuery($query);
                 $title = $db->loadResult();
                 $catalog_path[] = array('title' => $title, 'link' => '');
             } elseif (count($countries) == 1) {
                 $query = "select title from #__ksenmart_countries where id='{$countries['0']}'";
                 $db->setQuery($query);
                 $title = $db->loadResult();
                 $catalog_path[] = array('title' => $title, 'link' => '');
             } else {
                 $catalog_path[] = array('title' => JText::_('KSM_CATALOG_TITLE'), 'link' => '');
             }
             $k = 0;
             foreach ($catalog_path as $c_path) {
                 $k++;
                 if ($k == count($catalog_path)) {
                     $path->addItem($c_path['title']);
                 } else {
                     $path->addItem($c_path['title'], $c_path['link']);
                 }
             }
             break;
         case 'comments':
             $id = $jinput->get('id', 0, 'int');
             if ($id == 0) {
                 $path->addItem(JText::_('KSM_REVIEWS_LIST_PATH_TITLE'));
             } else {
                 $path->addItem(JText::_('KSM_REVIEWS_LIST_PATH_TITLE'), 'index.php?option=com_ksenmart&view=comments&Itemid=' . KSSystem::getShopItemid());
                 $path->addItem(JText::_('KSM_REVIEW_ITEM_PATH_TITLE'));
             }
             break;
         case 'order':
             $path->addItem('Оформление заказа');
             break;
         case 'product':
             $id = $jinput->get('id', 0, 'int');
             KSMProducts::incProductHit($id);
             $cat_path = array();
             $final_categories = array();
             $sql = $db->getQuery(true);
             $sql->select('category_id')->from('#__ksenmart_products_categories')->where('product_id=' . $id)->where('is_default=1');
             $db->setQuery($sql);
             $default_category = $db->loadResult();
             $sql = $db->getQuery(true);
             $sql->select('category_id')->from('#__ksenmart_products_categories')->where('product_id=' . $id);
             $db->setQuery($sql);
             $product_categories = $db->loadObjectList();
             foreach ($product_categories as $product_category) {
                 if (!empty($default_category)) {
                     $id_default_way = false;
                 } else {
                     $id_default_way = true;
                 }
                 $categories = array();
                 $parent = $product_category->category_id;
                 while ($parent != 0) {
                     if ($parent == $default_category) {
                         $id_default_way = true;
                     }
                     $sql = $db->getQuery(true);
                     $sql->select('id,parent')->from('#__ksenmart_categories')->where('id=' . $parent);
                     $db->setQuery($sql);
                     $category = $db->loadObject();
                     $categories[] = $category->id;
                     $parent = $category->parent;
                 }
                 if ($id_default_way && count($categories) > count($final_categories)) {
                     $final_categories = $categories;
                 }
             }
             $final_categories = array_reverse($final_categories);
             foreach ($final_categories as $final_category) {
                 $sql = $db->getQuery(true);
                 $sql->select('title,id')->from('#__ksenmart_categories')->where('id=' . $final_category);
                 $db->setQuery($sql);
                 $category = $db->loadObject();
                 $category->link = JRoute::_('index.php?option=com_ksenmart&view=catalog&categories[]=' . $final_category . '&Itemid=' . KSSystem::getShopItemid());
                 $cat_path[] = $category;
             }
             foreach ($cat_path as $cat) {
                 $path->addItem($cat->title, $cat->link);
             }
             $query = "select title from #__ksenmart_products where id='{$id}'";
             $db->setQuery($query);
             $title = $db->loadResult();
             $path->addItem($title);
             break;
     }
     return true;
 }
Exemple #20
0
 public function site_reg()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $user = new JUser();
     $data = array();
     $login = JRequest::getVar('login', '');
     $first_name = JRequest::getVar('first_name', '');
     $last_name = JRequest::getVar('last_name', '');
     $middle_name = JRequest::getVar('middle_name', '');
     $password = JRequest::getVar('password', '');
     $subscribe = JRequest::getVar('subscribe', 0);
     $fields = JRequest::getVar('fields', array());
     $ajax = JRequest::getVar('ajax', false);
     $name = '';
     if (!empty($last_name)) {
         $name .= $last_name . ' ';
     }
     if (!empty($first_name)) {
         $name .= $first_name . ' ';
     }
     if (!empty($middle_name)) {
         $name .= $middle_name;
     }
     $data['name'] = $name;
     $data['username'] = $login;
     $data['email'] = $login;
     $data['email1'] = $login;
     $data['email2'] = $login;
     $data['password'] = $password;
     $data['password1'] = $password;
     $data['password2'] = $password;
     $data['groups'] = array(2);
     $data['activation'] = '';
     $data['block'] = 0;
     if (!$user->bind($data)) {
         if ($ajax) {
             print_r($user->getError());
             exit;
         } else {
             $app->enqueueMessage($user->getError(), 'warning');
             $this->setRedirect(JRoute::_('index.php?option=com_ksenmart&view=profile&layout=registration&Itemid=' . KSSystem::getShopItemid()));
             return false;
         }
     }
     JPluginHelper::importPlugin('user');
     if (!$user->save()) {
         if ($ajax) {
             print_r($user->getError());
             exit;
         } else {
             $app->enqueueMessage($user->getError(), 'warning');
             $this->setRedirect(JRoute::_('index.php?option=com_ksenmart&view=profile&layout=registration&Itemid=' . KSSystem::getShopItemid()));
             return false;
         }
     }
     $options = array();
     $options['remember'] = true;
     $options['return'] = '';
     $credentials = array();
     $credentials['username'] = $login;
     $credentials['password'] = $password;
     $app->login($credentials, $options);
     $params = JComponentHelper::getParams('com_ksenmart');
     $config = JFactory::getConfig();
     $data = $user->getProperties();
     $data['fromname'] = $params->get('shop_name', '');
     $data['mailfrom'] = $params->get('shop_email', '');
     $data['sitename'] = $config->get('sitename');
     $data['siteurl'] = JURI::root();
     $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $login, $data['sitename']);
     $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_BODY', $login, $data['sitename'], $data['siteurl'], $login, $password);
     $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $login, $emailSubject, $emailBody);
     $query = "insert into #__ksen_users (`id`,`first_name`,`last_name`,`middle_name`) values ('{$user->id}','{$first_name}','{$last_name}','{$middle_name}')";
     $db->setQuery($query);
     $db->Query();
     foreach ($fields as $key => $value) {
         $values = array('user_id' => $user->id, 'field_id' => $key, 'value' => $db->quote($value));
         $query = $db->getQuery(true);
         $query->insert('#__ksen_user_fields_values')->columns(implode(',', array_keys($values)))->values(implode(',', $values));
         $db->setQuery($query);
         $db->query();
     }
     $session = JFactory::getSession();
     $order_id = $session->get('shop_order_id', 0);
     if ($order_id != 0) {
         $query = "update #__ksenmart_orders set user_id='{$user->id}' where id='{$order_id}'";
         $db->setQuery($query);
         $db->Query();
     }
     if ($ajax) {
         $app->close('login');
     } else {
         $this->setRedirect('/');
     }
 }
Exemple #21
0
 public function getCategoriesPath()
 {
     $this->onExecuteBefore('getCategoriesPath');
     $path = array();
     $final_categories = array();
     $parent_ids = array();
     $default_category = $this->getDefaultCategory();
     $product_categories = $this->getProductCategories();
     foreach ($product_categories as $product_category) {
         if (!empty($default_category)) {
             $id_default_way = false;
         } else {
             $id_default_way = true;
         }
         $categories = array();
         $parent = $product_category->category_id;
         while ($parent != 0) {
             if ($parent == $default_category) {
                 $id_default_way = true;
             }
             $category = KSSystem::getTableByIds(array($parent), 'categories', array('t.id', 't.parent_id'), true, false, true);
             $parent = 0;
             if ($category->id > 0) {
                 $categories[] = $category->id;
                 $parent = $category->parent_id;
             }
         }
         if ($id_default_way && count($categories) > count($final_categories)) {
             $final_categories = $categories;
         }
     }
     $final_categories = array_reverse($final_categories);
     $categories = KSSystem::getTableByIds($final_categories, 'categories', array('t.title', 't.id'), false);
     foreach ($categories as $category) {
         $category->link = JRoute::_('index.php?option=com_ksenmart&view=catalog&categories[]=' . $category->id . '&Itemid=' . KSSystem::getShopItemid());
         $path[] = $category;
     }
     $this->onExecuteAfter('getCategoriesPath', array(&$path));
     return $path;
 }
Exemple #22
0
                        </span>
                    </div>
    				<?php 
}
?>
    				
    				<div class="muted row-fluid bottom_info">
                        <div class="span6 brand">
                            <?php 
if (!empty($product->manufacturer_title)) {
    ?>
                            Бренд: <a href="index.php?option=com_ksenmart&view=catalog&manufacturers[0]=<?php 
    echo $product->manufacturer;
    ?>
&Itemid=<?php 
    echo KSSystem::getShopItemid();
    ?>
" title="<?php 
    echo $product->manufacturer_title;
    ?>
"><?php 
    echo $product->manufacturer_title;
    ?>
</a>
                            <?php 
}
?>
                        </div>
                        <div class="span6 rating">
                            <span class="title">Рейтинг: </span>
            				<?php 
Exemple #23
0
defined('_JEXEC') or die;
JDispatcher::getInstance()->trigger('onLoadKsen', array('ksenmart.KSM', array('common'), array(), array('angularJS' => 0)));
KSLoader::loadLocalHelpers(array('common'));
if (!class_exists('KsenmartHtmlHelper')) {
    require JPATH_ROOT . DS . 'components' . DS . 'com_ksenmart' . DS . 'helpers' . DS . 'head.php';
}
KsenmartHtmlHelper::AddHeadTags();
require_once dirname(__FILE__) . '/helper.php';
$modKsenmartSearchHelper = new modKsenmartSearchHelper();
$modKsenmartSearchHelper->init($params);
$mod_params = $modKsenmartSearchHelper->mod_params;
$price_min = $modKsenmartSearchHelper->price_min;
$price_max = $modKsenmartSearchHelper->price_max;
$manufacturers = $modKsenmartSearchHelper->manufacturers;
$countries = $modKsenmartSearchHelper->countries;
$properties = $modKsenmartSearchHelper->properties;
$class_sfx = htmlspecialchars($params->get('moduleclass_sfx', ''));
$form_action = JRoute::_('index.php?option=com_ksenmart&view=catalog&Itemid=' . KSSystem::getShopItemid());
$price_less = JRequest::getVar('price_less', $price_min);
$price_more = JRequest::getVar('price_more', $price_max);
$categories = $modKsenmartSearchHelper->categories;
JArrayHelper::toInteger($categories);
$order_type = JRequest::getVar('order_type', 'ordering');
$order_dir = JRequest::getVar('order_dir', 'asc');
$km_params = JComponentHelper::getParams('com_ksenmart');
$document = JFactory::getDocument();
$document->addScript(JURI::root() . 'modules/mod_km_filter/js/default.js');
if ($km_params->get('modules_styles', true)) {
    $document->addStyleSheet(JURI::base() . 'modules/mod_km_filter/css/default.css');
}
require JModuleHelper::getLayoutPath('mod_km_filter', $params->get('layout', 'default'));
Exemple #24
0
<?php

/**
 * @copyright   Copyright (C) 2013. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
$Itemid = KSSystem::getShopItemid();
$link = JRoute::_('index.php?option=com_ksenmart&view=cart&Itemid=' . $Itemid);
?>
<a href="<?php 
echo $link;
?>
">
	<b class="muted"><?php 
echo JText::_('KSM_CART_MINICART_LABEL');
?>
 [0]</b>
	<small class="muted"><?php 
echo JText::_('KSM_CART_MINICART_TEXT');
?>
</small>
</a>
Exemple #25
0
 /**
  * KsenMartModelcatalog::getManufacturers()
  * 
  * @return
  */
 public function getManufacturers()
 {
     $this->onExecuteBefore('getManufacturers');
     $where[] = "(m.published=1)";
     $query = $this->_db->getQuery(true);
     $query->select('
             m.id,
             m.title,
             m.alias,
             m.content,
             m.introcontent,
             m.country,
             m.metatitle,
             m.metadescription,
             m.metakeywords,
             f.filename,
             f.folder,
             f.params
         ')->from('#__ksenmart_manufacturers AS m')->order('m.title');
     if (count($this->_countries) > 0) {
         $query->innerjoin("#__ksenmart_countries AS c ON m.country=c.id");
         $where[] = "(c.id in (" . implode(',', $this->_countries) . "))";
     }
     $query->leftjoin("#__ksenmart_files AS f ON m.id=f.owner_id AND f.owner_type='manufacturer'")->where(implode(' AND ', $where))->order('m.ordering')->group('m.id');
     $this->_db->setQuery($query);
     $manufacturers = $this->_db->loadObjectList();
     foreach ($manufacturers as &$manufacturer) {
         if (!empty($manufacturer->folder)) {
             $manufacturer->img_link = JURI::root() . 'media/com_ksenmart/images/' . $manufacturer->folder . '/original/' . $manufacturer->filename;
         } else {
             $manufacturer->img_link = JURI::root() . 'media/com_ksenmart/images/manufacturers/no.jpg';
         }
         $manufacturer->small_img = KSMedia::resizeImage($manufacturer->filename, $manufacturer->folder, $this->_params->get('thumb_width'), $this->_params->get('thumb_height'));
         $manufacturer->link = JRoute::_('index.php?option=com_ksenmart&view=catalog&manufacturers[]=' . $manufacturer->id . '&Itemid=' . KSSystem::getShopItemid());
     }
     $this->onExecuteAfter('getManufacturers', array(&$manufacturers));
     return $manufacturers;
 }