Ejemplo n.º 1
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.º 2
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.º 3
0
 public function delete()
 {
     $db = JFactory::getDBO();
     $this->clearCache();
     $result = true;
     if (JeproshopShopModelShop::isTableAssociated('product_attribute')) {
         $shopListIds = JeproshopShopModelShop::getContextListShopIds();
         if (count($this->shop_list_id)) {
             $shopListIds = $this->shop_list_id;
         }
         $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attribute_shop') . " WHERE " . $db->quoteName('product_attribute_id') . " = " . (int) $this->product_attribute_id . " AND " . $db->quoteName('shop_id') . " IN (" . implode($shopListIds) . ")";
         $db->setQuery($query);
         $result &= $db->query();
     }
     $hasMultiShopEntries = $this->hasMultiShopEntries();
     if ($result && !$hasMultiShopEntries) {
         $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attribute') . " WHERE " . $db->quoteName('product_attribute_id') . " = " . (int) $this->product_attribute_id;
         $db->setQuery($query);
         $result &= $db->query();
     }
     if ($this->multi_lang && !$hasMultiShopEntries) {
         $query = "DELETE FROM " . $db->quoteName('#__jeproshop_product_attribute_lang') . " WHERE " . $db->quoteName('product_attribute_id') . " = " . (int) $this->product_attribute_id;
         $db->setQuery($query);
         $result &= $db->query();
     }
     if (!$result) {
         return false;
     }
     // Removes the product from StockAvailable, for the current shop
     JeproshopStockAvailableModelStockAvailable::removeProductFromStockAvailable((int) $this->product_id, (int) $this->product_attribute_id);
     if ($specific_prices = JeproshopSpecificPriceModelSpecificPrice::getByProductId((int) $this->product_id, (int) $this->product_attribute_id)) {
         foreach ($specific_prices as $specific_price) {
             $price = new JeproshopSpecificPriceModelSpecificPrice((int) $specific_price->specific_price_id);
             $price->delete();
         }
     }
     if (!$this->hasMultishopEntries() && !$this->deleteAssociations()) {
         return false;
     }
     $this->deleteFromSupplier($this->product_id);
     JeproshopProductModelProduct::updateDefaultAttribute($this->product_id);
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Add an sql restriction for shops fields
  *
  * @param boolean $share If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value
  * @param string $alias
  * @return string
  */
 public static function addSqlRestriction($share = false, $alias = null)
 {
     if ($alias) {
         $alias .= '.';
     }
     $group = JeproshopShopModelShop::getShopGroupFromShop(JeproshopShopModelShop::getContextShopID(), false);
     if ($share == JeproshopShopModelShop::SHARE_CUSTOMER && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && $group['share_customer']) {
         $restriction = " AND " . $alias . "shop_group_id = " . (int) JeproshopShopModelShop::getContextShopGroupId();
     } else {
         $restriction = " AND " . $alias . "shop_id IN (" . implode(', ', JeproshopShopModelShop::getContextListShopIds($share)) . ") ";
     }
     return $restriction;
 }
Ejemplo n.º 5
0
 public function delete()
 {
     $db = JFactory::getDBO();
     $this->clearCache();
     $result = true;
     if (JeproshopShopModelShop::isTableAssociated('image')) {
         $shopListIds = JeproshopShopModelShop::getContextListShopIds();
         if (count($this->shop_list_id)) {
             $shopListIds = $this->shop_list_id;
         }
         $query = "DELETE FROM " . $db->quoteName('#__jeproshop_image_shop') . " WHERE " . $db->quoteName('image_id') . " = " . (int) $this->image_id . " AND " . $db->quoteName('shop_id') . " IN(" . implode($shopListIds) . ")";
         $db->setQuery($query);
         $result &= $db->query();
     }
     $hasMultiShopEntries = $this->hasMultiShopEntries();
     if ($result && !$hasMultiShopEntries) {
         $query = " DELETE FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('image_id') . " = " . (int) $this->image_id;
         $db->setQuery($query);
         $result &= $db->query();
     }
     if (!$hasMultiShopEntries) {
         $query = " DELETE FROM " . $db->quoteName('#__jeproshop_image_lang') . " WHERE " . $db->quoteName('image_id') . " = " . (int) $this->image_id;
         $db->setQuery($query);
         $result &= $db->query();
     }
     if (!$result) {
         return false;
     }
     if ($this->hasMultishopEntries()) {
         return true;
     }
     if (!$this->deleteProductAttributeImage() || !$this->deleteImage()) {
         return false;
     }
     // update positions
     $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $this->product_id . " ORDER BY " . $db->quoteName('position');
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $i = 1;
     if ($result) {
         foreach ($result as $row) {
             $row->position = $i++;
             $query = "UPDATE " . $db->quoteName('#_jeproshop_image') . " SET " . $db->quoteName('position') . " = " . (int) $row->position . " WHERE " . $db->quoteName('image_id') . " = " . (int) $row->image_id;
             $db->setQuery($query);
             $db->query();
             Db::getInstance()->update($this->def['table'], $row, '`id_image` = ' . (int) $row['id_image'], 1);
         }
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * @see ObjectModel::add()
  */
 public function add()
 {
     $db = JFactory::getDBO();
     $this->date_add = date('Y-m-d H:i:s');
     $this->date_upd = date('Y-m-d H:i:s');
     if (JeproshopShopModelShop::isTableAssociated('address')) {
         $shopListIds = JeproshopShopModelShop::getContextListShopIds();
         if (count($this->shop_list_id) > 0) {
             $shopListIds = $this->shop_list_id;
         }
     }
     if (JeproshopShopModelShop::checkDefaultShopId('address')) {
         $this->default_shop_id = min($shopListIds);
     }
     $query = "INSERT INTO " . $db->quoteName('#__jeproshop_address');
     if (!parent::add($autodate, $null_values)) {
         return false;
     }
     if (JeproshopTools::isUnsignedInt($this->customer_id)) {
         JeproshopCustomerModelCustomer::resetAddressCache($this->customer_id);
     }
     return true;
 }
Ejemplo n.º 7
0
 /**
  * Removes a given product from the stock available
  *
  * @param int $product_id
  * @param int $product_attribute_id Optional
  * @param mixed $shop shop id or shop object Optional
  */
 public static function removeProductFromStockAvailable($product_id, $product_attribute_id = null, $shop = null)
 {
     if (!JeproshopTools::isUnsignedInt($product_id)) {
         return false;
     }
     $db = JFactory::getDBO();
     if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
         if (JeproshopShopModelShop::getContextShopGroup()->share_stock == 1) {
             $product_attribute_sql = '';
             if ($product_attribute_id !== null) {
                 $product_attribute_sql = '_attribute';
                 $product_attribute_id_sql = $product_attribute_id;
             } else {
                 $product_attribute_id_sql = $product_id;
             }
             $query = "SELECT COUNT(*) FROM " . $db->quoteName('#__jeproshop_product' . $product_attribute_sql . '_shop') . " WHERE " . $db->quoteName('product' . $product_attribute_sql . '_id') . " = ";
             $query .= (int) $product_attribute_id_sql . " AND " . $db->quoteName('shop_id') . " IN (" . implode(',', array_map('intval', JeproshopShopModelShop::getContextListShopIds(JeproshopShopModelShop::SHARE_STOCK))) . ")";
             $db->setQuery($query);
             $result = (int) $db->loadResult();
             if ($result) {
                 return true;
             }
         }
     }
     $query = "DELETE FROM " . $db->quoteName('#__jeproshop_stock_available') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product_id;
     $query .= ($product_attribute_id ? " AND " . $db->quoteName('product_attribute_id') . " = " . (int) $product_attribute_id : "") . JeproshopStockAvailableModelStockAvailable::addShopRestriction(null, $shop);
     $db->setQuery($query);
     $res = $db->query();
     if ($product_attribute_id) {
         if ($shop === null || !JeproshopTools::isLoadedObject($shop, 'shop_id')) {
             $shop_datas = new Object();
             JeproshopStockAvailableModelStockAvailable::addSqlShopParams($shop_datas);
             $shop_id = (int) $shop_datas->shop_id;
         } else {
             $shop_id = (int) $shop->shop_id;
         }
         $stock_available = new JeproshopStockAvailableModelStockAvailable();
         $stock_available->product_id = (int) $product_id;
         $stock_available->product_attribute_id = (int) $product_id;
         $stock_available->shop_id = (int) $shop_id;
         $stock_available->postSave();
     }
     JeproshopCache::clean('jeproshop_stock_available_get-quantity_Available_by_product_' . (int) $product_id . '_*');
     return $res;
 }
Ejemplo n.º 8
0
 public function deleteLite()
 {
     $db = JFactory::getDBO();
     // @hook actionObject*DeleteBefore
     Hook::exec('actionObjectDeleteBefore', array('object' => $this));
     Hook::exec('actionObject' . get_class($this) . 'DeleteBefore', array('object' => $this));
     $this->clearCache();
     $result = true;
     // Remove association to multishop table
     if (JeproshopShopModelShop::isTableAssociated('category')) {
         $shop_list_ids = JeproshopShopModelShop::getContextListShopIds();
         if (count($this->shop_list_ids)) {
             $shop_list_ids = $this->shop_list_ids;
         }
         $query = "DELETE FROM " . $db->quoteName('#__jeproshop_category_shop') . " WHERE " . $db->quoteName('category_id') . " = " . (int) $this->category_id . " AND " . $db->quoteName('shop_id') . " IN(" . implode(', ', $shop_list_ids) . ")";
         $db->setQuery($query);
         $result &= $db->query();
     }
     // Database deletion
     $has_multishop_entries = $this->hasMultishopEntries();
     if ($result && !$has_multishop_entries) {
         $query = "DELETE FROM " . $db->quoteName('#__jeproshop_category') . " WHERE " . $db->quoteName('category_id') . " = " . (int) $this->category_id;
         $db->setQuery($query);
         $result &= $db->query();
     }
     if (!$result) {
         return false;
     }
     // Database deletion for multilingual fields related to the object
     if (!empty($this->def['multilang']) && !$has_multishop_entries) {
         $query = "DELETE FROM " . $db->quoteName('#__jeproshop_category_lang') . " WHERE " . $db->quoteName('category_id') . " = " . (int) $this->category_id;
         $db->setQuery($query);
         $result &= $db->query();
     }
     // @hook actionObject*DeleteAfter
     Hook::exec('actionObjectDeleteAfter', array('object' => $this));
     Hook::exec('actionObject' . get_class($this) . 'DeleteAfter', array('object' => $this));
     return $result;
 }
Ejemplo n.º 9
0
 public function getCustomerList()
 {
     jimport('joomla.html.pagination');
     $context = JeproshopContext::getContext();
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     $context->controller->default_form_language = $context->language->lang_id;
     $lang_id = $app->getUserStateFromRequest($option . $view . '.lang_id', 'lang_id', $context->language->lang_id, 'int');
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int');
     $limitstart = $app->getUserStateFromRequest($option . $view . '.limit_start', 'limit_start', 0, 'int');
     $selectShop = ", shop.shop_name AS shop_name ";
     $joinShop = " LEFT JOIN " . $db->quoteName('#__jeproshop_shop') . " AS shop ON(customer." . $db->quoteName('shop_id') . " = shop." . $db->quoteName('shop_id') . ") ";
     $whereShop = JeproshopShopModelShop::addSqlRestriction(JeproshopShopModelShop::SHARE_CUSTOMER, 'customer');
     /* Manage default params values */
     $use_limit = true;
     if ($limit === false) {
         $use_limit = false;
     }
     do {
         $query = "SELECT SQL_CALC_FOUND_ROWS customer." . $db->quoteName('customer_id') . ", " . $db->quoteName('lastname') . ", " . $db->quoteName('firstname') . ", " . $db->quoteName('email') . $selectShop;
         if (JeproshopSettingModelSetting::getValue('enable_b2b_mode')) {
             $query .= ", customer." . $db->quoteName('company') . ", customer." . $db->quoteName('website');
         }
         $query .= ", customer.published AS published, customer." . $db->quoteName('newsletter') . ", customer." . $db->quoteName('optin') . ", customer.date_add, customer.title AS title, ( SELECT SUM(";
         $query .= "total_paid_tax_excl / conversion_rate) FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord WHERE ord.customer_id = customer.customer_id AND ord.shop_id IN (";
         $query .= implode(',', JeproshopShopModelShop::getContextListShopIds()) . ") AND customer.published = 1 ) AS total_spent, ( SELECT connection.date_add FROM " . $db->quoteName('#__jeproshop_guest');
         $query .= " AS guest LEFT JOIN " . $db->quoteName('#__jeproshop_connection') . " AS connection ON connection.guest_id = guest.guest_id  WHERE guest.customer_id = customer.customer_id ORDER BY ";
         $query .= " customer.date_add DESC LIMIT 1 ) AS connect FROM " . $db->quoteName('#__jeproshop_customer') . " AS customer ";
         //LEFT JOIN " . $db->quoteName('#__jeproshop_gender_lang') . " AS gender_lang ";
         $query .= $joinShop . " WHERE 1 AND customer." . $db->quoteName('deleted') . " = 0 ORDER BY ";
         $query .= $db->quoteName('date_add') . $whereShop;
         $db->setQuery($query);
         $total = count($db->loadObjectList());
         $query .= " ASC " . ($use_limit ? "LIMIT " . $limitstart . ", " . $limit : "");
         $db->setQuery($query);
         $customers = $db->loadObjectList();
         if ($use_limit == true) {
             $limitstart = (int) $limitstart - (int) $limit;
             if ($limitstart < 0) {
                 break;
             }
         } else {
             break;
         }
     } while (empty($customers));
     $this->pagination = new JPagination($total, $limitstart, $limit);
     return $customers;
 }
Ejemplo n.º 10
0
 public function addProduct()
 {
     $input = JRequest::get('post');
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     if ($this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     $input_data = $input['jform'];
     $this->date_add = date('Y-m-d H:i:s');
     $this->date_upd = date('Y-m-d H:i:s');
     $shop_list_ids = array();
     if (JeproshopShopModelShop::isTableAssociated('product')) {
         $shop_list_ids = JeproshopShopModelShop::getContextListShopIds();
         if (count($this->shop_list_id) > 0) {
             $shop_list_ids = $this->shop_list_id;
         }
     }
     if (JeproshopShopModelShop::checkDefaultShopId('product')) {
         $this->default_shop_id = min($shop_list_ids);
     }
     $languages = JeproshopLanguageModelLanguage::getLanguages(false);
     $reference = JeproshopTools::isReference($input_data['reference']) ? $input_data['reference'] : '';
     $ean13 = JeproshopTools::isEan13($input_data['ean13']) ? $input_data['ean13'] : '';
     $upc = JeproshopTools::isUpc($input_data['upc']) ? $input_data['upc'] : '';
     $product_redirect_id = JeproshopTools::isUnsignedInt($input_data['product_redirected_id']) ? (int) $input_data['product_redirected_id'] : 0;
     $available_for_order = isset($input_data['available_for_order']) ? 1 : 0;
     $show_price = isset($input_data['show_price']) ? 1 : 0;
     $online_only = isset($input_data['online_only']) ? 1 : 0;
     $query = "INSERT INTO " . $db->quoteName('#__jeproshop_product') . "(" . $db->quoteName('reference') . ", " . $db->quoteName('ean13') . ", " . $db->quoteName('upc') . ", " . $db->quoteName('published') . ", ";
     $query .= $db->quoteName('redirect_type') . ", " . $db->quoteName('visibility') . ", " . $db->quoteName('condition') . ", " . $db->quoteName('available_for_order') . ", " . $db->quoteName('show_price') . ", ";
     $query .= $db->quoteName('online_only') . ", " . $db->quoteName('default_shop_id') . ", " . $db->quoteName('product_redirected_id') . ", " . $db->quoteName('date_add') . ", " . $db->quoteName('date_upd') . " ) VALUES(";
     $query .= $db->quote($reference, true) . ", " . $db->quote($ean13, true) . ", " . $db->quote($upc, true) . ", " . $db->quote($input_data['published'], true) . ", " . $db->quote($input_data['redirect_type'], true) . ", ";
     $query .= $db->quote($input_data['visibility'], true) . ", " . $db->quote($input_data['condition']) . ", " . (int) $available_for_order . ", " . (int) $show_price . ", " . (int) $online_only . ", " . $this->default_shop_id . ", ";
     $query .= $product_redirect_id . ", " . $db->quote($this->date_add) . ", " . $db->quote($this->date_upd) . ") ";
     $db->setQuery($query);
     if ($db->query()) {
         $product_id = $db->insertid();
         if (JeproshopShopModelShop::isTableAssociated('product')) {
             /* Shop fields */
             foreach ($shop_list_ids as $shop_id) {
                 $query = "INSERT INTO " . $db->quoteName('#__jeproshop_product_shop') . "( " . $db->quoteName('product_id') . ", ";
                 $query .= $db->quoteName('shop_id') . ", " . $db->quoteName('online_only') . ", " . $db->quoteName('published') . ", ";
                 $query .= $db->quoteName('redirect_type') . ", " . $db->quoteName('product_redirected_id') . ", " . $db->quoteName('available_for_order');
                 $query .= ", " . $db->quoteName('condition') . ", " . $db->quoteName('show_price') . ", " . $db->quoteName('visibility') . ", ";
                 $query .= $db->quoteName('date_add') . ", " . $db->quoteName('date_upd') . ") VALUES( " . (int) $product_id . ", " . (int) $shop_id . ", ";
                 $query .= (int) $online_only . ", " . (int) $input_data['published'] . ", " . $db->quote($input_data['redirect_type']) . ", ";
                 $query .= (int) $input_data['product_redirected_id'] . ", " . (int) $available_for_order . ", " . $db->quote($input_data['condition']) . ", ";
                 $query .= (int) $show_price . ", " . $db->quote($input_data['visibility']) . ", " . $db->quote($this->date_add) . ", " . $db->quote($this->date_upd) . ") ";
                 $db->setQuery($query);
                 if ($db->query()) {
                     /* Multilingual fields */
                     foreach ($languages as $language) {
                         $query = "INSERT INTO " . $db->quoteName('#__jeproshop_product_lang') . "(" . $db->quoteName('product_id') . ", " . $db->quoteName('shop_id') . ", " . $db->quoteName('lang_id') . ", " . $db->quoteName('description') . ", ";
                         $query .= $db->quoteName('short_description') . ", " . $db->quoteName('name') . ") VALUES (" . (int) $product_id . ", " . (int) $shop_id . ", " . (int) $language->lang_id . ", " . $db->quote($input_data['description_' . $language->lang_id]);
                         $query .= ", " . $db->quote($input_data['short_description_' . $language->lang_id]) . ", ";
                         $query .= $db->quote($input_data['name_' . $language->lang_id]) . ")";
                         $db->setQuery($query);
                         $db->query();
                     }
                 }
             }
         }
         $product = new JeproshopProductModelProduct($product_id);
         if ($product->getType() == JeproshopProductModelProduct::VIRTUAL_PRODUCT) {
             JeproshopStockAvailableModelStockAvailable::setProductDependsOnStock((int) $product->product_id, 1);
             if ($product->published && !JeproshopSettingModelSetting::getValue('virtual_product_feature_active')) {
                 JeproshopSettingModelSetting::updateValue('virtual_product_feature_active', '1');
             }
         } else {
             JeproshopStockAvailableModelStockAvailable::setProductOutOfStock((int) $product->product_id, 2);
         }
         $product->setGroupReduction();
         return $product;
     }
     return null;
 }
Ejemplo n.º 11
0
 public function save()
 {
     $db = JFactory::getDBO();
     $input = JRequest::get('post');
     $inputData = $input['jform'];
     $query = "INSERT INTO " . $db->quoteName('#__jeproshop_tax_rules_group') . " ( " . $db->quoteName('name') . ", " . $db->quoteName('published') . ") VALUES(" . $db->quote($inputData['name']) . ", " . (int) $inputData['published'] . ")";
     $db->setQuery($query);
     if ($db->query()) {
         $result = true;
         $taxRuleGroupId = $db->insertid();
         $shopListIds = JeproshopShopModelShop::getContextListShopIds();
         if (count($this->shop_list_ids) > 0) {
             $shopListIds = $this->shop_list_ids;
         }
         if (JeproshopShopModelShop::checkDefaultShopId('tax_rules_group')) {
             $this->default_shop_id = min($shopListIds);
         }
         foreach ($shopListIds as $shop_id) {
             $query = "INSERT INTO " . $db->quoteName('#__jeproshop_tax_rules_group_shop') . " ( " . $db->quoteName('tax_rules_group_id') . ", " . $db->quoteName('shop_id') . ") VALUES ( " . (int) $taxRuleGroupId . ", " . (int) $shop_id . ")";
             $db->setQuery($query);
             $result &= $db->query();
         }
         $link = 'index.php?option=com_jeproshop&view=tax&task=groups';
         if (!$result) {
             $message = JText::_('COM_JEPROSHOP_');
         } else {
         }
     }
 }