Ejemplo n.º 1
0
 public function renderDetails($tpl = null)
 {
     $app = JFactory::getApplication();
     $category_id = $app->input->get('category_id');
     if (!isset($this->context) || empty($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     if (!JeproshopShopModelShop::isFeaturePublished() && count(JeproshopCategoryModelCategory::getCategoriesWithoutParent()) > 1 && $category_id) {
         $categories_tree = array(get_object_vars($this->context->controller->category->getTopCategory()));
     } else {
         $categories_tree = $this->context->controller->category->getParentsCategories();
         $end = end($categories_tree);
         if (isset($categories_tree) && !JeproshopShopModelShop::isFeaturePublished() && (isset($end) && $end->parent_id != 0)) {
             $categories_tree = array_merge($categories_tree, array(get_object_vars($this->context->controller->category->getTopCategory())));
         }
     }
     $count_categories_without_parent = count(JeproshopCategoryModelCategory::getCategoriesWithoutParent());
     if (empty($categories_tree) && ($this->context->controller->category->category_id != 1 || $category_id) && (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && !JeproshopShopModelShop::isFeaturePublished() && $count_categories_without_parent > 1)) {
         $categories_tree = array(array('name' => $this->context->controller->category->name[$this->context->language->lang_id]));
     }
     $categories_tree = array_reverse($categories_tree);
     $this->assignRef('categories_tree', $categories_tree);
     $this->assignRef('categories_tree_current_id', $this->context->controller->category->category_id);
     $categoryModel = new JeproshopCategoryModelCategory();
     $categories = $categoryModel->getCategoriesList();
     $pagination = $categoryModel->getPagination();
     $this->assignRef('pagination', $pagination);
     $this->assignRef('categories', $categories);
     $this->setLayout('default');
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 public function initialize()
 {
     parent::initialize();
     // Check if we can add a customer
     if (JeproshopShopModelShop::isFeaturePublished() && (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_ALL || JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_GROUP)) {
         $this->can_add_customer = false;
     }
 }
Ejemplo n.º 3
0
 protected function getWarningDomainName()
 {
     $warning = false;
     if (JeproshopShopModelShop::isFeaturePublished()) {
         return null;
     }
     $shop = JeproshopContext::getContext()->shop;
     return $warning;
 }
Ejemplo n.º 4
0
 public function initialize()
 {
     $app = JFactory::getApplication();
     $context = JeproshopContext::getContext();
     parent::initialize();
     $category_id = $app->input->get('category_id');
     $task = $app->input->get('task');
     if ($category_id && $task != 'delete') {
         $this->category = new JeproshopCategoryModelCategory($category_id);
     } else {
         if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
             $this->category = new JeproshopCategoryModelCategory($context->shop->category_id);
         } elseif (count(JeproshopCategoryModelCategory::getCategoriesWithoutParent()) > 1 && JeproshopSettingModelSetting::getValue('multishop_feature_active') && count(JeproshopShopModelShop::getShops(true, null, true)) != 1) {
             $this->category = JeproshopCategoryModelCategory::getTopCategory();
         } else {
             $this->category = new JeproshopCategoryModelCategory(JeproshopSettingModelSetting::getValue('root_category'));
         }
     }
     if (JeproshopTools::isLoadedObject($this->category, 'category_id') && !$this->category->isAssociatedToShop() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
         $app->redirect('index.php?option=com_jeproshop&view=category&task=edit&category_id=' . (int) $context->shop->getCategoryId() . '&' . JeproshopTools::getCategoryToken() . '=1');
     }
 }
Ejemplo n.º 5
0
                </div>
                <div class="control-group" >
                    <div class="control-label" ><label for="jform_" title="<?php 
echo JText::_('COM_JEPROSHOP_PUBLISHED_TITLE_DESC');
?>
" ><?php 
echo JText::_('COM_JEPROSHOP_PUBLISHED_LABEL');
?>
</label> </div>
                    <div class="controls" ><?php 
echo $this->helper->radioButton('published');
?>
</div>
                </div>
                <?php 
if (JeproshopShopModelShop::isFeaturePublished()) {
    ?>
                    <div class="control-group" >
                        <div class="control-label" ><label for="jform_" title="<?php 
    echo JText::_('COM_JEPROSHOP_ASSOCIATED_SHOP_TITLE_DESC');
    ?>
" ><?php 
    echo JText::_('COM_JEPROSHOP_ASSOCIATED_SHOP_LABEL');
    ?>
</label> </div>
                        <div class="controls" ><?php 
    echo $this->shop_tree;
    ?>
</div>
                    </div>
                <?php 
Ejemplo n.º 6
0
 public function getOrderStatusList()
 {
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     $context = JeproshopContext::getContext();
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int');
     $limitStart = $app->getUserStateFromRequest($option . $view . '.limit_start', 'limit_start', 0, 'int');
     $lang_id = $app->getUserStateFromRequest($option . $view . '.lang_id', 'lang_id', $context->language->lang_id, 'int');
     $order_by = $app->getUserStateFromRequest($option . $view . '.order_by', 'order_by', 'order_status_id', 'string');
     $order_way = $app->getUserStateFromRequest($option . $view . '.order_way', 'order_way', 'ASC', 'string');
     $select = $select_shop = $where_shop = $join_shop = "";
     $lang_join = " LEFT JOIN " . $db->quoteName('#__jeproshop_order_status_lang') . " AS order_status_lang ON(order_status_lang." . $db->quoteName('order_status_id');
     $lang_join .= " = order_status." . $db->quoteName('order_status_id') . " AND order_status_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")";
     /*if($shop_lang_id){
           if(!JeproshopShopModelShop::isFeaturePublished()){
               $lang_join .= " AND order_status_lang." . $db->quoteName('shop_id') . " = 1";
           }elseif(JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP){
               $lang_join .= " AND order_status_lang." . $db->quoteName('shop_id') . " = " . (int)$shop_lang_id;
           }else{
               $lang_join .= " AND order_status_lang." . $db->quoteName('shop_id') . " = order_status.default_shop_id";
           }
       }
       $lang_join .= ")"; */
     $having_clause = "";
     $where = "";
     if (JeproshopShopModelShop::isTableAssociated('order_status')) {
         if (JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_ALL || !$context->employee->isSuperAdmin()) {
             $test_join = "";
             if (JeproshopShopModelShop::isFeaturePublished() && $test_join && JeproshopShopModelShop::isTableAssociated('order_status')) {
                 $where .= " AND order_status." . $db->quoteName('order_status_id') . " IN (SELECT orders_status_shop." . $db->quoteName('order_status_id');
                 $where .= " FROM " . $db->quoteName('#__jeproshop_order_status_shop') . " AS order_status_shop WHERE order_status_shop.shop_id IN (";
                 $where .= implode(', ', JeproshopShopModelShop::getContextListShopIds()) . ") )";
             }
         }
     }
     $use_limit = true;
     if ($limit === false) {
         $use_limit = false;
     }
     $deleted = $group = $filter = $join = "";
     //", order_status." . $db->quoteName('logo') .
     do {
         $query = "SELECT SQL_CALC_FOUND_ROWS order_status." . $db->quoteName('order_status_id') . ", order_status_lang." . $db->quoteName('name');
         $query .= ", order_status." . $db->quoteName('send_email') . ", order_status.";
         $query .= $db->quoteName('delivery') . ", order_status." . $db->quoteName('invoice') . ", order_status_lang." . $db->quoteName('template');
         $query .= $select . $select_shop . " FROM " . $db->quoteName('#__jeproshop_order_status') . " AS order_status " . $lang_join . $join;
         $query .= $join_shop . " WHERE 1 " . $where . $deleted . $filter . $where_shop . $group . $having_clause . " ORDER BY ";
         $query .= (str_replace('`', '', $order_by) == 'order_status_id' ? "order_status." : "") . $order_by . " " . $order_way;
         $db->setQuery($query);
         $total = count($db->loadObjectList());
         $query .= $use_limit ? " LIMIT " . (int) $limitStart . ", " . (int) $limit : "";
         $db->setQuery($query);
         $orderStatus = $db->loadObjectList();
         if ($orderStatus == false) {
             break;
         }
         if ($use_limit) {
             $limitStart = (int) $limitStart - (int) $limit;
             if ($limitStart < 0) {
                 break;
             }
         } else {
             break;
         }
     } while (empty($orderStatus));
     $this->pagination = new JPagination($total, $limitStart, $limit);
     return $orderStatus;
 }
Ejemplo n.º 7
0
    public function getManufacturerList($explicitSelect = TRUE)
    {
        jimport('joomla.html.pagination');
        $db = JFactory::getDBO();
        $app = JFactory::getApplication();
        $option = $app->input->get('option');
        $view = $app->input->get('view');
        $context = JeproshopContext::getContext();
        $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int');
        $limitstart = $app->getUserStateFromRequest($option . $view . '.limit_start', 'limit_start', 0, 'int');
        $lang_id = $app->getUserStateFromRequest($option . $view . '.lang_id', 'lang_id', $context->language->lang_id, 'int');
        $shop_id = $app->getUserStateFromRequest($option . $view . '.shop_id', 'shop_id', $context->shop->shop_id, 'int');
        $shop_group_id = $app->getUserStateFromRequest($option . $view . '.shop_group_id', 'shop_group_id', $context->shop->shop_group_id, 'int');
        $category_id = $app->getUserStateFromRequest($option . $view . '.category_id', 'category_id', 0, 'int');
        $order_by = $app->getUserStateFromRequest($option . $view . '.order_by', 'order_by', 'manufacturer_id', 'string');
        $order_way = $app->getUserStateFromRequest($option . $view . '.order_way', 'order_way', 'ASC', 'string');
        $published = $app->getUserStateFromRequest($option . $view . '.published', 'published', 0, 'string');
        /* Manage default params values */
        $use_limit = true;
        if ($limit === false) {
            $use_limit = false;
        }
        $select = " COUNT(" . $db->quoteName('product_id') . ") AS " . $db->quoteName('products') . ", (SELECT ";
        $select .= "COUNT(address." . $db->quoteName('manufacturer_id') . ") AS " . $db->quoteName('addresses');
        $select .= " FROM " . $db->quoteName('#__jeproshop_address') . " AS address WHERE address.";
        $select .= $db->quoteName('manufacturer_id') . " = manufacturer." . $db->quoteName('manufacturer_id');
        $select .= " AND address." . $db->quoteName('deleted') . " = 0 GROUP BY address." . $db->quoteName('manufacturer_id');
        $select .= ") AS " . $db->quoteName('addresses');
        $join = "LEFT JOIN " . $db->quoteName('#__jeproshop_product') . " AS product ON (manufacturer.";
        $join .= $db->quoteName('manufacturer_id') . " = product." . $db->quoteName('manufacturer_id') . ") ";
        $group = " GROUP BY manufacturer." . $db->quoteName('manufacturer_id');
        if ($context->controller->multishop_context && JeproshopShopModelShop::isTableAssociated('manufacturer')) {
            if (JeproshopShopModelShop::getShopContext() != JeproshopShopMoelShop::CONTEXT_ALL || !$context->employee->isSuperAdmin()) {
                $test_join = !preg_match('#`?' . preg_quote('#__jeproshop_manufacturer_shop') . '`? *manufacturer-shop#', $join);
                if (JeproshopShopModelShop::isFeaturePublished() && $test_join && JeproshopModelShopShop::isTableAssociated('manufacturer')) {
                    $where .= ' AND a.' . $this->identifier . ' IN (
						SELECT sa.' . $this->identifier . '
						FROM `' . _DB_PREFIX_ . $this->table . '_shop` sa
						WHERE sa.id_shop IN (' . implode(', ', JeproshopShopModelShop::getContextListShopIds()) . ") )";
                }
            }
        }
        /* Query in order to get results with all fields */
        $lang_join = '';
        if ($context->language->lang_id) {
            $lang_join = "LEFT JOIN " . $db->quoteName('#__jeproshop_manufacturer_lang') . " AS manufacturer_lang ";
            $lang_join .= " ON (manufacturer_lang." . $db->quoteName('manufacturer_id') . " = manufacturer.";
            $lang_join .= $db->quoteName('manufacturer_id') . " AND manufacturer_lang." . $db->quoteName('lang_id');
            $lang_join .= " = " . (int) $lang_id . ") ";
        }
        $having_clause = '';
        if (isset($this->_filterHaving) || isset($this->_having)) {
            $having_clause = ' HAVING ';
            if (isset($this->_filterHaving)) {
                $having_clause .= ltrim($this->_filterHaving, ' AND ');
            }
            if (isset($this->_having)) {
                $having_clause .= $this->_having . ' ';
            }
        }
        do {
            $query = "SELECT SQL_CALC_FOUND_ROWS ";
            if (!$explicitSelect) {
                $query .= " manufacturer.name, manufacturer.published, ";
                //logo,
                /*
                				foreach($fields_list as $key => $value){
                					if(isset($select) && preg_match('/[\s]`?' . preg_quote($key, '/') . '`?\S*,/', $select)){
                						continue;
                					}
                						
                					if (isset($value['filter_key'])){
                						$query .= str_replace('!', '.', $value['filter_key']) . " AS " . $key . ", ";
                					}elseif ($key == 'manufacturer_id'){
                						$query .= "manufacture." . $db->quoteName($db->escape($key)) . ", ";
                					}elseif ($key != 'image' && !preg_match('/'. preg_quote($key, '/').'/i', $select)){
                						$query .= $db->quoteName($db->escape($key)) .", ";
                					}
                				}
                				$query = rtrim($query, ',') */
            } else {
                $query .= ($lang_id ? "manufacturer_lang.*, " : "") . "manufacturer.*, ";
            }
            $query .= (isset($select) ? rtrim($select, ", ") : "") . " FROM " . $db->quoteName('#__jeproshop_manufacturer');
            $query .= " AS manufacturer " . $lang_join . (isset($join) ? $join . " " : "") . " WHERE 1 " . (isset($where) ? $where . " " : "");
            $query .= (isset($filter) ? $filter : "") . (isset($group) ? $group . " " : "");
            $query .= $having_clause . " ORDER BY " . (str_replace('`', '', $order_by) == 'manufacturer_id' ? "manufacturer.manufacturer_id " : "");
            //. " manufacturer." . $db->quoteName($order_by) . " ";
            $query .= $db->escape($order_way) . ($use_limit === true ? " LIMIT " . (int) $limitstart . ", " . (int) $limit : "");
            $db->setQuery($query);
            $manufacturers = $db->loadObjectList();
            if ($use_limit == true) {
                $limitstart = (int) $limitstart - (int) $limit;
                if ($limitstart < 0) {
                    break;
                }
            } else {
                break;
            }
        } while (empty($manufacturers));
        $total = count($manufacturers);
        $this->pagination = new JPagination($total, $limitstart, $limit);
        return $manufacturers;
    }
Ejemplo n.º 8
0
 /**
  * Get current ID of shop group if context is CONTEXT_SHOP or CONTEXT_GROUP
  *
  * @param bool $null_value_without_multishop
  * @return int
  */
 public static function getContextShopGroupId($null_value_without_multishop = false)
 {
     if ($null_value_without_multishop && !JeproshopShopModelShop::isFeaturePublished()) {
         return null;
     }
     return self::$context_shop_group_id;
 }
Ejemplo n.º 9
0
 /**
  * Check if there is more than one entries in associated shop table for current entity
  *
  * @since 1.5.0
  * @return bool
  */
 public function hasMultishopEntries()
 {
     if (!JeproshopShopModelShop::isTableAssociated('product_attribute') || !JeproshopShopModelShop::isFeaturePublished()) {
         return false;
     }
     $db = JFactory::getDBO();
     $query = "SELECT COUNT(*) FROM " . $db->quoteName('#__jeproshop_product_attribute_shop') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $this->product_attribute_id;
     $db->quoteName($query);
     return (bool) $db->loadResult();
 }
Ejemplo n.º 10
0
 protected function loadObject($option = false)
 {
     $app = JFactory::getApplication();
     $product_id = $app->input->get('product_id');
     $isLoaded = false;
     $context = JeproshopContext::getContext();
     if ($product_id && JeproshopTools::isUnsignedInt($product_id)) {
         if (!$this->product) {
             $this->product = new JeproshopProductModelProduct($product_id, false, $context->language->lang_id);
         }
         if (!JeproshopTools::isLoadedObject($this->product, 'product_id')) {
             JError::raiseError(500, JText::_('COM_JEPROSHOP_PRODUCT_NOT_FOUND_MESSAGE'));
             $isLoaded = false;
         } else {
             $isLoaded = true;
         }
     } elseif ($option) {
         if (!$this->product) {
             $this->product = new JeproshopProductModelProduct();
         }
     } else {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_PRODUCT_DOES_NOT_EXIST_MESSAGE'));
         $isLoaded = false;
     }
     //specified
     if ($isLoaded && JeproshopTools::isLoadedObject($this->product, 'product_id')) {
         if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && JeproshopShopModelShop::isFeaturePublished() && !$this->product->isAssociatedToShop()) {
             $this->product = new JeproshopProductModelProduct((int) $this->product->product_id, false, $context->language->lang_id, (int) $this->product->default_shop_id);
         }
         $this->product->loadStockData();
     }
     return $isLoaded;
 }
Ejemplo n.º 11
0
 public function renderView($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
     }
     if ($this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     $db = JFactory::getDBO();
     $this->setLayout('view');
     $this->loadObject();
     if (!JeproshopTools::isLoadedObject($this->customer, 'customer_id')) {
         return;
     }
     $this->context->customer = $this->customer;
     $customer_stats = $this->customer->getStats();
     $query = "SELECT SUM(total_paid_real) FROM " . $db->quoteName('#__jeproshop_orders');
     $query .= " WHERE customer_id = " . (int) $this->customer->customer_id . " AND valid = 1";
     $db->setQuery($query);
     $total_customer = $db->loadResult();
     if ($total_customer) {
         $query = "SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM " . $db->quoteName('#__jeproshop_orders');
         $query .= " WHERE valid = 1 AND customer_id != " . (int) $this->customer->customer_id . " GROUP BY ";
         $query .= "customer_id HAVING SUM(total_paid_real) > " . (int) $total_customer;
         $db->setQuery($query);
         $db->loadResult();
         $count_better_customers = (int) $db->loadResult('SELECT FOUND_ROWS()') + 1;
     } else {
         $count_better_customers = '-';
     }
     $orders = JeproshopOrderModelOrder::getCustomerOrders($this->customer->customer_id, true);
     $total_orders = count($orders);
     for ($i = 0; $i < $total_orders; $i++) {
         $orders[$i]->total_paid_real_not_formated = $orders[$i]->total_paid_real;
         $orders[$i]->total_paid_real = JeproshopTools::displayPrice($orders[$i]->total_paid_real, new JeproshopCurrencyModelCurrency((int) $orders[$i]->currency_id));
     }
     $messages = JeproshopCustomerThreadModelCustomerThread::getCustomerMessages((int) $this->customer->customer_id);
     $total_messages = count($messages);
     for ($i = 0; $i < $total_messages; $i++) {
         $messages[$i]->message = substr(strip_tags(html_entity_decode($messages[$i]->message, ENT_NOQUOTES, 'UTF-8')), 0, 75);
         $messages[$i]->date_add = Tools::displayDate($messages[$i]->date_add, null, true);
     }
     $groups = $this->customer->getGroups();
     $total_groups = count($groups);
     for ($i = 0; $i < $total_groups; $i++) {
         $group = new JeproshopGroupModelGroup($groups[$i]);
         $groups[$i] = array();
         $groups[$i]['group_id'] = $group->group_id;
         $groups[$i]['name'] = $group->name[$this->context->controller->default_form_language];
     }
     $total_ok = 0;
     $orders_ok = array();
     $orders_ko = array();
     foreach ($orders as $order) {
         if (!isset($order->order_state)) {
             $order->order_state = JText::_('COM_JEPROSHOP_THERE_IS_NO_STATUS_DEFINED_FOR_THIS_ORDER_MESSAGE');
         }
         if ($order->valid) {
             $orders_ok[] = $order;
             $total_ok += $order->total_paid_real_not_formated;
         } else {
             $orders_ko[] = $order;
         }
     }
     $products = $this->customer->getBoughtProducts();
     $carts = JeproshopCartModelCart::getCustomerCarts($this->customer->customer_id);
     $total_carts = count($carts);
     for ($i = 0; $i < $total_carts; $i++) {
         $cart = new JeproshopCartModelCart((int) $carts[$i]->cart_id);
         $this->context->cart = $cart;
         $summary = $cart->getSummaryDetails();
         $currency = new JeproshopCurrencyModelCurrency((int) $carts[$i]->currency_id);
         $carrier = new JeproshopCarrierModelCarrier((int) $carts[$i]->carrier_id);
         $carts[$i]['id_cart'] = sprintf('%06d', $carts[$i]['id_cart']);
         $carts[$i]['date_add'] = JeproshopValidator::displayDate($carts[$i]->date_add, null, true);
         $carts[$i]['total_price'] = Tools::displayPrice($summary->total_price, $currency);
         $carts[$i]->name = $carrier->name;
     }
     $query = "SELECT DISTINCT cart_product.product_id, cart.cart_id, cart.shop_id, cart_product.shop_id ";
     $query .= " AS cart_product_shop_id FROM " . $db->quoteName('#__jeproshop_cart_product') . " AS cart_product";
     $query .= " JOIN " . $db->quoteName('#__jeproshop_cart') . " AS cart ON (cart.cart_id = cart_product.cart_id) ";
     $query .= "JOIN " . $db->quoteName('#__jeproshop_product') . " AS product ON (cart_product.product_id = product.";
     $query .= "product_id) WHERE cart.customer_id = " . (int) $this->customer->customer_id . " AND cart_product.product_id";
     $query .= " NOT IN ( SELECT product_id FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord JOIN ";
     $query .= $db->quoteName('#__jeproshop_order_detail') . " AS ord_detail ON (ord.order_id = ord_detail.order_id ) WHERE ";
     $query .= "ord.valid = 1 AND ord.customer_id = " . (int) $this->customer->customer_id . ")";
     $db->setQuery($query);
     $interested = $db->loadObjectList();
     $total_interested = count($interested);
     for ($i = 0; $i < $total_interested; $i++) {
         $product = new JeproshopProductModelProduct($interested[$i]->product_id, false, $this->context->controller->default_form_language, $interested[$i]->shop_id);
         if (!Validate::isLoadedObject($product, 'product_id')) {
             continue;
         }
         $interested[$i]->url = $this->context->controller->getProductLink($product->product_id, $product->link_rewrite, JeproshopCategoryModelCategory::getLinkRewrite($product->default_category_id, $this->context->controller->default_form_language), null, null, $interested[$i]->cp_shop_id);
         $interested[$i]->product_id = (int) $product->product_id;
         $interested[$i]->name = htmlentities($product->name);
     }
     $connections = $this->customer->getLastConnections();
     if (!is_array($connections)) {
         $connections = array();
     }
     $total_connections = count($connections);
     for ($i = 0; $i < $total_connections; $i++) {
         $connections[$i]->http_referer = $connections[$i]->http_referer ? preg_replace('/^www./', '', parse_url($connections[$i]->http_referer, PHP_URL_HOST)) : JText::_('COM_JEPROSHOP_DIRECT_LINK_LABEL');
     }
     $referrers = JeproshopReferrerModelReferrer::getReferrers($this->customer->customer_id);
     $total_referrers = count($referrers);
     for ($i = 0; $i < $total_referrers; $i++) {
         $referrers[$i]->date_add = JeproshopTools::displayDate($referrers[$i]->date_add, null, true);
     }
     $customerLanguage = new JeproshopLanguageModelLanguage($this->customer->lang_id);
     $shop = new JeproshopShopModelShop($this->customer->shop_id);
     //$this->assignRef('customer', $customer);
     /*'gender' => $gender,
     		/*	'gender_image' => $gender_image,
     		// General information of the customer */
     $registration = JeproshopTools::displayDate($this->customer->date_add, null, true);
     $this->assignRef('registration_date', $registration);
     $this->assignRef('customer_stats', $customer_stats);
     $last_visit = JeproshopTools::displayDate($customer_stats->last_visit, null, true);
     $this->assignRef('last_visit', $last_visit);
     $this->assignRef('count_better_customers', $count_better_customers);
     $shop_feature_active = JeproshopShopModelShop::isFeaturePublished();
     $this->assignRef('shop_is_feature_active', $shop_feature_active);
     $this->assignRef('shop_name', $shop->shop_name);
     $customerBirthday = JeproshopTools::displayDate($this->customer->birthday);
     $this->assignRef('customer_birthday', $customerBirthday);
     $last_update = JeproshopTools::displayDate($this->customer->date_upd, null, true);
     $this->assignRef('last_update', $last_update);
     $customerExists = JeproshopCustomerModelCustomer::customerExists($this->customer->email);
     $this->assignRef('customer_exists', $customerExists);
     $this->assignRef('lang_id', $this->customer->lang_id);
     $this->assignRef('customerLanguage', $customerLanguage);
     // Add a Private note
     $customerNote = JeproshopTools::htmlentitiesUTF8($this->customer->note);
     $this->assignRef('customer_note', $customerNote);
     // Messages
     $this->assignRef('messages', $messages);
     // Groups
     $this->assignRef('groups', $groups);
     // Orders
     $this->assignRef('orders', $orders);
     $this->assignRef('orders_ok', $orders_ok);
     $this->assignRef('orders_ko', $orders_ko);
     $total_ok = JeproshopTools::displayPrice($total_ok, $this->context->currency->currency_id);
     $this->assignRef('total_ok', $total_ok);
     // Products
     $this->assignRef('products', $products);
     // Addresses
     $addresses = $this->customer->getAddresses($this->context->controller->default_form_language);
     $this->assignRef('addresses', $addresses);
     // Discounts
     $discounts = JeproshopCartRuleModelCartRule::getCustomerCartRules($this->context->controller->default_form_language, $this->customer->customer_id, false, false);
     $this->assignRef('discounts', $discounts);
     // Carts
     $this->assignRef('carts', $carts);
     // Interested
     $this->assignRef('interested_products', $interested);
     // Connections
     $this->assignRef('connections', $connections);
     // Referrers
     $this->assignRef('referrers', $referrers);
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     parent::display($tpl);
 }
Ejemplo n.º 12
0
 /**
  * @static
  * @param JeproshopContext|null $context
  * @return mixed
  */
 public static function autoAddToCart(JeproshopContext $context = null)
 {
     if ($context === null) {
         $context = JeproshopContext::getContext();
     }
     if (!JeproshopCartRuleModelCartRule::isFeaturePublished() || !JeproshopValidator::isLoadedObject($context->cart, 'cart_id')) {
         return;
     }
     $db = JFactory::getDBO();
     $query = "SELECT cart_rule.* FROM " . $db->quoteName('#__jeproshop_cart_rule') . " AS cart_rule LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_shop');
     $query .= " AS cart_rule_shop ON cart_rule.cart_rule_id = cart_rule_shop.cart_rule_id ";
     $group_query = " LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_group') . " AS cart_rule_group ON cart_rule.cart_rule_id = cart_rule_group.cart_rule_id ";
     $query .= (!$context->customer->customer_id && JeproshopGroupModelGroup::isFeaturePublished() ? $group_query : "") . " LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_cart_rule_carrier') . " AS cart_rule_carrier ON cart_rule.cart_rule_id = cart_rule_carrier.cart_rule_id ";
     $query .= $context->cart->carrier_id ? " LEFT JOIN " . $db->quoteName('#__jeproshop_carrier') . " AS carrier ON (carrier.reference_id = cart_rule_carrier.carrier_id AND carrier.deleted = 0)" : "";
     $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_country') . " AS cart_rule_country ON cart_rule.cart_rule_id = cart_rule_country.";
     $query .= "cart_rule_id WHERE cart_rule.published = 1 AND cart_rule.code = '' AND cart_rule.quantity > 0 AND cart_rule.date_from < '" . date('Y-m-d H:i:s') . "'\tAND cart_rule.date_to > '";
     $query .= date('Y-m-d H:i:s') . "' AND ( cart_rule.customer_id = 0 " . ($context->customer->customer_id ? " OR cart_rule.customer_id = " . (int) $context->cart->customer_id : "");
     $query .= ") AND ( cart_rule." . $db->quoteName('carrier_restriction') . " = 0 " . ($context->cart->carrier_id ? " OR carrier.carrier_id = " . (int) $context->cart->carrier_id : "");
     $query .= " ) AND ( cart_rule." . $db->quoteName('shop_restriction') . " = 0 " . (JeproshopShopModelShop::isFeaturePublished() && $context->shop->shop_id ? " OR cart_rule_shop.shop_id = " . (int) $context->shop->shop_id : "");
     $query .= " ) AND ( cart_rule." . $db->quoteName('group_restriction') . " = 0 ";
     if ($context->customer->customer_id) {
         $query = " OR 0 < ( SELECT customer_group." . $db->quoteName('group_id') . " FROM " . $db->quoteName('#__jeproshop_customer_group') . " AS customer_group INNER JOIN " . $db->quoteName('#__jeproshop_cart_rule_group');
         $query .= " AS cart_rule_group ON customer_group.group_id = cart_rule_group.group_id WHERE cart_rule." . $db->quoteName('cart_rule_id') . " = cart_rule_group." . $db->quoteName('cart_rule_id') . " AND customer_group.";
         $query .= $db->quoteName('customer_id') . " = " . (int) $context->customer->customer_id . " LIMIT 1\t)";
     } else {
         if (JeproshopGroupModelGroup::isFeaturePublished()) {
             $query .= " OR cart_rule_group." . $db->quoteName('group_id') . " = " . (int) JeproshopSettingModelSetting::getValue('unidentified_group');
         }
     }
     $query .= " ) AND ( cart_rule." . $db->quoteName('`reduction_product') . " <= 0 OR cart_rule." . $db->quoteName('reduction_product') . " IN ( SELECT " . $db->quoteName('product_id') . " FROM ";
     $query .= $db->quoteName('#__jeproshop_cart_product') . " WHERE " . $db->quoteName('cart_id') . " = " . (int) $context->cart->cart_id . " ) ) AND cart_rule.cart_rule_id NOT IN (SELECT cart_rule_id FROM ";
     $query .= $db->quoteName('#__jeproshop_cart_cart_rule') . " WHERE car_id = " . (int) $context->cart->cart_id . ") ORDER BY priority";
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if ($result) {
         $cart_rules = ObjectModel::hydrateCollection('CartRule', $result);
         if ($cart_rules) {
             foreach ($cart_rules as $cart_rule) {
                 if ($cart_rule->checkValidity($context, false, false)) {
                     $context->cart->addCartRule($cart_rule->cart_rule_id);
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
 public function renderAddForm($tpl = null)
 {
     //print_r(JeproshopCustomerModelCustomer::searchByName('je'));
     $context = JeproshopContext::getContext();
     if ($context->shop->getShopContext() != JeproshopShopModelShop::CONTEXT_SHOP && JeproshopShopModelShop::isFeaturePublished()) {
         $context->controller->has_errors = true;
         $this->l('You have to select a shop before creating new orders.');
     }
     $app = JFactory::getApplication();
     $cart_id = (int) $app->input->get('cart_id');
     $cart = new JeproshopCartModelCart((int) $cart_id);
     if ($cart_id && !JeproshopTools::isLoadedObject($cart, 'cart_id')) {
         $context->controller->has_errors = true;
         $this->l('This cart does not exists');
     }
     if ($cart_id && JeproshopTools::isLoadedObject($cart, 'cart_id') && !$cart->customer_id) {
         $context->controller->has_errors = true;
         $this->l('The cart must have a customer');
     }
     if ($context->controller->has_errors) {
         return false;
     }
     /*parent::renderForm();
             unset($this->toolbar_btn['save']);
             $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
     */
     $defaults_order_statues = array('cheque' => (int) JeproshopSettingModelSetting::getValue('order_status_cheque'), 'bank_wire' => (int) JeproshopSettingModelSetting::getValue('order_status_bank_wire'), 'cash_on_delivery' => (int) JeproshopSettingModelSetting::getValue('order_status_preparation'), 'other' => (int) JeproshopSettingModelSetting::getValue('order_status_payment'));
     $payment_modules = array();
     /*  foreach (PaymentModule::getInstalledPaymentModules() as $p_module)
                 $payment_modules[] = Module::getInstanceById((int)$p_module['id_module']);
     */
     $recyclable_pack = (int) JeproshopSettingModelSetting::getValue('offer_recycled_wrapping');
     $this->assignRef('recyclable_pack', $recyclable_pack);
     $gift_wrapping = (int) JeproshopSettingModelSetting::getValue('offer_gift_wrapping');
     $this->assignRef('gift_wrapping', $gift_wrapping);
     $this->assignRef('cart', $cart);
     $this->assignRef('cart_id', $cart_id);
     $currencies = JeproshopCurrencyModelCurrency::getCurrenciesByShopId(JeproshopContext::getContext()->shop->shop_id);
     $this->assignRef('currencies', $currencies);
     $languages = JeproshopLanguageModelLanguage::getLanguages(true, JeproshopContext::getContext()->shop->shop_id);
     $this->assignRef('languages', $languages);
     $this->assignRef('payment_modules', $payment_modules);
     $order_statues = JeproshopOrderStatusModelOrderStatus::getOrderStatus((int) JeproshopContext::getContext()->language->lang_id);
     $this->assignRef('order_statues', $order_statues);
     $this->assignRef('defaults_order_statues', $defaults_order_statues);
     /*    'show_toolbar' => $this->show_toolbar,
               'toolbar_btn' => $this->toolbar_btn,
               'toolbar_scroll' => $this->toolbar_scroll,
               'title' => array($this->l('Orders'), $this->l('Create order'))
           ));* /
           $this->content .= $this->createTemplate('form.tpl')->fetch(); */
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
Ejemplo n.º 14
0
 public function update()
 {
     $db = JFactory::getDBO();
     $context = JeproshopContext::getContext();
     $input = JRequest::get('post');
     $inputData = $input['jform'];
     $query = "UPDATE " . $db->quoteName('#__jeproshop_tax_rules_group') . " SET " . $db->quoteName('name') . " = " . $db->quote($inputData['name']) . ", " . $db->quoteName('published') . " = ";
     $query .= (int) $inputData['published'] . " WHERE " . $db->quoteName('tax_rules_group_id') . " = " . $this->tax_rules_group_id;
     $db->setQuery($query);
     if ($db->query()) {
         //Update Associated Shops
         if (JeproshopShopModelShop::isFeaturePublished()) {
             $associatedShop = $this->getAssociatedShop();
             $query = "SELECT " . $db->quoteName('shop_id') . " FROM " . $db->quoteName('#__jeproshop_shop');
             $db->setQuery($query);
             $shopIds = $db->loadObjctList();
             foreach ($shopIds as $shop) {
                 if ($context->employee->hasAuthorutyOnShop($shop->shop_id)) {
                     $associatedShop[] = $shop->shop_id;
                 }
             }
             $query = "DELETE FROM " . $db->quoteName('#__jeproshop_tax_rules_group_shop') . " WHERE " . $db->quoteName('tax_rules_group_id') . " = " . (int) $this->tax_rules_group_id;
             $query .= $associatedShop ? " AND " . $db->quoteName('shop_id') . " NOT IN (" . implode(',', $associatedShop) . ")" : "";
             $db->setQuery($query);
             $query = "INSERT INTO " . $db->quoteName('#__jeproshop_tax_rules_group_shop') . "(" . $db->quoteName('tax_rules_group_id') . ", " . $db->quoteName('shop_id') . ") VALUES (";
             foreach ($associatedShop as $shop_id) {
                 $query .= "(" . (int) $this->tax_rules_group_id . ", " . (int) $shop_id . "), ";
             }
             $query = rtrim($query, ", ") . ")";
             $db->setQuery($query);
             $db->query();
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Returns a link to a product image for display
  * Note: the new image filesystem stores product images in subdirectories of img/p/
  *
  * @param string $name rewrite link of the image
  * @param string $ids id part of the image filename - can be "id_product-id_image" (legacy support, recommended) or "id_image" (new)
  * @param string $type
  * @return string
  */
 public function getImageLink($name, $ids, $type = null)
 {
     $not_default = false;
     if (is_array($name)) {
         $name = $name[JeproshopContext::getContext()->language->lang_id];
     }
     // legacy mode or default image
     $theme = JeproshopShopModelShop::isFeaturePublished() && file_exists(COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . $ids . ($type ? '_' . $type : '') . '_' . (int) JeproshopContext::getContext()->shop->theme_id . '.jpg') ? '_' . JeproshopContext::getContext()->shop->theme_id : '';
     if (JeproshopSettingModelSetting::getValue('legacy_images') && file_exists(COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . $ids . ($type ? '-' . $type : '') . $theme . '.jpg') || ($not_default = strpos($ids, 'default') !== false)) {
         if ($this->allow_link_rewrite == 1 && !$not_default) {
             echo $name;
             $uri_path = JURI::base() . $ids . ($type ? '_' . $type : '') . $theme . '/' . $name . '.jpg';
         } else {
             $uri_path = JURI::base() . 'components/com_jeproshop/assets/themes/' . $ids . ($type ? '_' . $type : '') . $theme . '.jpg';
         }
     } else {
         // if ids if of the form product_id-id_image, we want to extract the id_image part
         $split_ids = explode('_', $ids);
         $image_id = isset($split_ids[1]) ? $split_ids[1] : $split_ids[0];
         $theme = JeproshopShopModelShop::isFeaturePublished() && file_exists(COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . JeproshopImageModelImage::getStaticImageFolder($image_id) . $image_id . ($type ? '_' . $type : '') . '_' . (int) JeproshopContext::getContext()->shop->theme_id . '.jpg') ? '_' . JeproshopContext::getContext()->shop->theme_id : '';
         if ($this->allow_link_rewrite == 1) {
             $uri_path = JURI::base() . $image_id . ($type ? '_' . $type : '') . $theme . '/' . $name . '.jpg';
         } else {
             $uri_path = JURI::base() . COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . JeproshopImageModelImage::getStaticImageFolder($image_id) . $image_id . ($type ? '_' . $type : '') . $theme . '.jpg';
         }
     }
     //return JeproshopTools::getMediaServer($uri_path).$uri_path;
     return $uri_path;
 }