function getAllList($display = 0)
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $query = "SELECT id, `" . $lang->get("name") . "` as name, field_id FROM `#__jshopping_products_extra_field_values` order by ordering";
     extract(js_add_trigger(get_defined_vars(), "before"));
     $db->setQuery($query);
     if ($display == 0) {
         return $db->loadObjectList();
     } elseif ($display == 1) {
         $rows = $db->loadObjectList();
         $list = array();
         foreach ($rows as $k => $row) {
             $list[$row->id] = $row->name;
             unset($rows[$k]);
         }
         return $list;
     } else {
         $rows = $db->loadObjectList();
         $list = array();
         foreach ($rows as $k => $row) {
             $list[$row->field_id][$row->id] = $row->name;
             unset($rows[$k]);
         }
         return $list;
     }
 }
Beispiel #2
0
 function getList($groupordering = 0, $order = null, $orderDir = null, $filter = array())
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $ordering = "F.ordering";
     if ($order && $orderDir) {
         $ordering = $order . " " . $orderDir;
     }
     if ($groupordering) {
         $ordering = "G.ordering, " . $ordering;
     }
     $where = '';
     $_where = array();
     if ($filter['group']) {
         $_where[] = " F.group = '" . $db->escape($filter['group']) . "' ";
     }
     if ($filter['text_search']) {
         $text_search = $filter['text_search'];
         $word = addcslashes($db->escape($text_search), "_%");
         $_where[] = "(LOWER(F.`" . $lang->get('name') . "`) LIKE '%" . $word . "%' OR LOWER(F.`" . $lang->get('description') . "`) LIKE '%" . $word . "%' OR F.id LIKE '%" . $word . "%')";
     }
     if (count($_where) > 0) {
         $where = " WHERE " . implode(" AND ", $_where);
     }
     $query = "SELECT F.id, F.`" . $lang->get("name") . "` as name, F.`" . $lang->get("description") . "` as description, F.allcats, F.type, F.cats, F.ordering, F.`group`, G.`" . $lang->get("name") . "` as groupname, multilist FROM `#__jshopping_products_extra_fields` as F left join `#__jshopping_products_extra_field_groups` as G on G.id=F.group " . $where . " order by " . $ordering;
     $db->setQuery($query);
     return $db->loadObjectList();
 }
 public static function getCategory($catid, $order = 'id', $ordering = 'asc', $limit, $publish = 0)
 {
     $_db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $user = JFactory::getUser();
     $add_where = $publish ? " AND category_publish = '1' " : "";
     $groups = implode(',', $user->getAuthorisedViewLevels());
     $add_where .= ' AND access IN (' . $groups . ')';
     if ($order == "id") {
         $orderby = "category_id";
     }
     if ($order == "name") {
         $orderby = "`" . $lang->get('name') . "`";
     }
     if ($order == "ordering") {
         $orderby = "ordering";
     }
     if (!$orderby) {
         $orderby = "ordering";
     }
     if ($limit > 0) {
         $_limit = " LIMIT 0 , " . $limit;
     } else {
         $_limit = "";
     }
     $query = "SELECT `" . $lang->get('name') . "` as name,`" . $lang->get('description') . "` as description,`" . $lang->get('short_description') . "` as short_description, category_id, category_publish, ordering, category_image FROM `#__jshopping_categories`\r\n                   WHERE category_id IN (" . $catid . ") " . $add_where . "\r\n                   ORDER BY " . $orderby . " " . $ordering . " " . $_limit;
     $_db->setQuery($query);
     $categories = $_db->loadObjectList();
     foreach ($categories as $key => $value) {
         $categories[$key]->link = SEFLink('index.php?option=com_jshopping&controller=category&task=view&category_id=' . $categories[$key]->category_id, 1);
     }
     return $categories;
 }
Beispiel #4
0
 function getProducts($filters, $order = null, $orderby = null, $limitstart = 0, $limit = 0)
 {
     $jshopConfig = JSFactory::getConfig();
     $lang = JSFactory::getLang();
     $adv_query = "";
     $adv_from = "";
     $adv_result = $this->getBuildQueryListProductDefaultResult();
     $this->getBuildQueryListProduct("vendor", "list", $filters, $adv_query, $adv_from, $adv_result);
     if ($this->main) {
         $query_vendor_id = "(prod.vendor_id = '" . $this->id . "' OR prod.vendor_id ='0')";
     } else {
         $query_vendor_id = "prod.vendor_id = '" . $this->id . "'";
     }
     $order_query = $this->getBuildQueryOrderListProduct($order, $orderby, $adv_from);
     JPluginHelper::importPlugin('jshoppingproducts');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeQueryGetProductList', array("vendor", &$adv_result, &$adv_from, &$adv_query, &$order_query, &$filters));
     $query = "SELECT {$adv_result} FROM `#__jshopping_products` AS prod\n                  LEFT JOIN `#__jshopping_products_to_categories` AS pr_cat USING (product_id)\n                  LEFT JOIN `#__jshopping_categories` AS cat ON pr_cat.category_id = cat.category_id                  \n                  {$adv_from}\n                  WHERE " . $query_vendor_id . " AND prod.product_publish = '1' AND cat.category_publish='1' " . $adv_query . "\n                  GROUP BY prod.product_id " . $order_query;
     if ($limit) {
         $this->_db->setQuery($query, $limitstart, $limit);
     } else {
         $this->_db->setQuery($query);
     }
     $products = $this->_db->loadObjectList();
     $products = listProductUpdateData($products);
     return $products;
 }
 function getName($status_id)
 {
     $lang = JSFactory::getLang();
     $query = "SELECT `" . $lang->get('name') . "` as name FROM `#__jshopping_order_status` WHERE status_id = '" . $this->_db->escape($status_id) . "'";
     $this->_db->setQuery($query);
     return $this->_db->loadResult();
 }
Beispiel #6
0
 function getAllPaymentMethods($publish = 1, $shipping_id = 0)
 {
     $db = JFactory::getDBO();
     $jshopConfig = JSFactory::getConfig();
     $query_where = $publish ? "WHERE payment_publish = '1'" : "";
     $lang = JSFactory::getLang();
     $query = "SELECT payment_id, `" . $lang->get("name") . "` as name, `" . $lang->get("description") . "` as description , payment_code, payment_class, scriptname, payment_publish, payment_ordering, payment_params, payment_type, price, price_type, tax_id, image FROM `#__jshopping_payment_method` {$query_where} ORDER BY payment_ordering";
     extract(js_add_trigger(get_defined_vars(), "query"));
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if ($shipping_id && $jshopConfig->step_4_3) {
         $sh = JSFactory::getTable('shippingMethod', 'jshop');
         $sh->load($shipping_id);
         $payments = $sh->getPayments();
         if (count($payments) > 0) {
             foreach ($rows as $k => $v) {
                 if (!in_array($v->payment_id, $payments)) {
                     unset($rows[$k]);
                 }
             }
             $rows = array_values($rows);
         }
     }
     return $rows;
 }
Beispiel #7
0
 /**
  * get list country
  * 
  * @param int $publish (0-all, 1-publish, 2-unpublish)
  * @param int $limitstart
  * @param int $limit
  * @param int $orderConfig use order config
  * @return array
  */
 function getAllCountries($publish = 1, $limitstart = null, $limit = null, $orderConfig = 1, $order = null, $orderDir = null)
 {
     $db = JFactory::getDBO();
     $jshopConfig = JSFactory::getConfig();
     if ($publish == 0) {
         $where = " ";
     } else {
         if ($publish == 1) {
             $where = " WHERE country_publish = '1' ";
         } else {
             if ($publish == 2) {
                 $where = " WHERE country_publish = '0' ";
             }
         }
     }
     $ordering = "ordering";
     if ($orderConfig && $jshopConfig->sorting_country_in_alphabet) {
         $ordering = "name";
     }
     if ($order && $orderDir) {
         $ordering = $order . " " . $orderDir;
     }
     $lang = JSFactory::getLang();
     $query = "SELECT country_id, country_publish, ordering, country_code, country_code_2, `" . $lang->get("name") . "` as name FROM `#__jshopping_countries` " . $where . " ORDER BY " . $ordering;
     $db->setQuery($query, $limitstart, $limit);
     return $db->loadObjectList();
 }
 function getCountries()
 {
     $lang = JSFactory::getLang();
     $query = "SELECT sh_country.country_id, countries.`" . $lang->get('name') . "` as name\n                  FROM `#__jshopping_shipping_method_price_countries` AS sh_country\n                  INNER JOIN `#__jshopping_countries` AS countries ON countries.country_id = sh_country.country_id\n                  WHERE sh_country.sh_pr_method_id = '" . $this->_db->escape($this->sh_pr_method_id) . "'";
     $this->_db->setQuery($query);
     return $this->_db->loadObjectList();
 }
 function fetchElement()
 {
     $db = JFactory::getDBO();
     require_once JPATH_SITE . "/components/com_jshopping/lib/factory.php";
     $lang = JSFactory::getLang();
     $query = "SELECT m.category_id AS id, `" . $lang->get('name') . "` AS title, `" . $lang->get('name') . "` AS name, m.category_parent_id AS parent_id, m.category_parent_id as parent\r\n              FROM #__jshopping_categories AS m\r\n              LEFT JOIN #__jshopping_products_to_categories AS f\r\n              ON m.category_id = f.category_id\r\n              WHERE m.category_publish = 1\r\n              ORDER BY ordering";
     $db->setQuery($query);
     $menuItems = $db->loadObjectList();
     $children = array();
     if ($menuItems) {
         foreach ($menuItems as $v) {
             $pt = $v->parent_id;
             $list = isset($children[$pt]) ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     jimport('joomla.html.html.menu');
     $options = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $this->_xml->addChild('option', 'Root')->addAttribute('value', 0);
     $optgroup = $this->_xml->addChild('optgroup', '');
     $optgroup->addAttribute('label', 'Categories');
     if (count($options)) {
         foreach ($options as $option) {
             $optgroup->addChild('option', htmlspecialchars($option->treename))->addAttribute('value', $option->id);
         }
     }
     $this->_value = $this->_form->get($this->_name, $this->_default);
     $html = parent::fetchElement();
     return $html;
 }
Beispiel #10
0
 function getBuildQueryListProduct($type, $restype, &$filters, &$adv_query, &$adv_from, &$adv_result)
 {
     $jshopConfig = JSFactory::getConfig();
     $lang = JSFactory::getLang();
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $originaladvres = $adv_result;
     $groups = implode(',', $user->getAuthorisedViewLevels());
     if ($type == "category") {
         $adv_query .= ' AND prod.access IN (' . $groups . ')';
     } else {
         $adv_query .= ' AND prod.access IN (' . $groups . ') AND cat.access IN (' . $groups . ')';
     }
     if ($jshopConfig->show_delivery_time) {
         $adv_result .= ", prod.delivery_times_id";
     }
     if ($jshopConfig->admin_show_product_extra_field) {
         $adv_result .= getQueryListProductsExtraFields();
     }
     if ($jshopConfig->product_list_show_vendor) {
         $adv_result .= ", prod.vendor_id";
     }
     if ($jshopConfig->hide_product_not_avaible_stock) {
         $adv_query .= " AND prod.product_quantity > 0";
     }
     if (isset($filters['categorys']) && $type != "category" && is_array($filters['categorys']) && count($filters['categorys'])) {
         $adv_query .= " AND cat.category_id in (" . implode(",", $filters['categorys']) . ")";
     }
     if (isset($filters['manufacturers']) && $type != "manufacturer" && is_array($filters['manufacturers']) && count($filters['manufacturers'])) {
         $adv_query .= " AND prod.product_manufacturer_id in (" . implode(",", $filters['manufacturers']) . ")";
     }
     if (isset($filters['labels']) && is_array($filters['labels']) && count($filters['labels'])) {
         $adv_query .= " AND prod.label_id in (" . implode(",", $filters['labels']) . ")";
     }
     if (isset($filters['vendors']) && $type != "vendor" && is_array($filters['vendors']) && count($filters['vendors'])) {
         $adv_query .= " AND prod.vendor_id in (" . implode(",", $filters['vendors']) . ")";
     }
     if (isset($filters['extra_fields']) && is_array($filters['extra_fields'])) {
         foreach ($filters['extra_fields'] as $f_id => $vals) {
             if (is_array($vals) && count($vals)) {
                 $tmp = array();
                 foreach ($vals as $val_id) {
                     $tmp[] = " find_in_set('" . $val_id . "', prod.`extra_field_" . $f_id . "`) ";
                 }
                 $_tmp_adv_query = implode(' OR ', $tmp);
                 $adv_query .= " AND (" . $_tmp_adv_query . ")";
             } elseif (is_string($vals) && $vals != "") {
                 $adv_query .= " AND prod.`extra_field_" . $f_id . "`='" . $db->escape($vals) . "'";
             }
         }
     }
     $this->getBuildQueryListProductFilterPrice($filters, $adv_query, $adv_from);
     if ($jshopConfig->product_list_show_qty_stock) {
         $adv_result .= ", prod.unlimited";
     }
     if ($restype == "count") {
         $adv_result = $originaladvres;
     }
 }
Beispiel #11
0
 function displayEdit($tpl = null)
 {
     JToolBarHelper::title($temp = $this->edit ? _JSHOP_UNITS_MEASURE_EDIT . ' / ' . $this->units->{JSFactory::getLang()->get('name')} : _JSHOP_UNITS_MEASURE_NEW, 'generic.png');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Beispiel #12
0
 function loadData($alias)
 {
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $query = "SELECT id, alias, `" . $lang->get('text') . "` as text FROM `#__jshopping_config_statictext` where alias='" . $db->escape($alias) . "'";
     $db->setQuery($query);
     return $db->loadObject();
 }
Beispiel #13
0
 public function getNameForId($id)
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $query = "SELECT `" . $lang->get("name") . "` as name FROM `" . $this->_tbl . "` WHERE `" . $this->_tbl_key . "` = '" . $db->escape($id) . "'";
     $db->setQuery($query);
     return $db->loadResult();
 }
 function getList()
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $query = "SELECT id, `" . $lang->get("name") . "` as name, ordering FROM `#__jshopping_attr_groups` order by ordering";
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Beispiel #15
0
 function getList()
 {
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $query = "SELECT id, alias FROM `#__jshopping_config_statictext` ORDER BY id";
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Beispiel #16
0
 function getList()
 {
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $query = "SELECT id, alias, `" . $lang->get('title') . "` as title, `" . $lang->get('keyword') . "` as keyword, `" . $lang->get('description') . "` as description FROM `#__jshopping_config_seo` ORDER BY ordering";
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Beispiel #17
0
 function getUnits()
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $query = "SELECT id, `" . $lang->get('name') . "` as name FROM `#__jshopping_unit` ORDER BY name";
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Beispiel #18
0
 function getProdNameById($id)
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $query = "select pr.`" . $lang->get('name') . "` as name from #__jshopping_products  as pr where pr.product_id = '{$id}' LIMIT 1";
     $db->setQuery($query);
     return $db->loadResult();
 }
Beispiel #19
0
 function loadData($alias)
 {
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $query = "SELECT id, alias, `" . $lang->get('title') . "` as title, `" . $lang->get('keyword') . "` as keyword, `" . $lang->get('description') . "` as description FROM `#__jshopping_config_seo` where alias='" . $db->escape($alias) . "'";
     $db->setQuery($query);
     return $db->loadObject();
 }
Beispiel #20
0
 function getList()
 {
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $query = "SELECT id, alias, `" . $lang->get('title') . "` as title, `" . $lang->get('keyword') . "` as keyword, `" . $lang->get('description') . "` as description FROM `#__jshopping_config_seo` ORDER BY ordering";
     extract(js_add_trigger(get_defined_vars(), "before"));
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Beispiel #21
0
 function getName()
 {
     $lang = JSFactory::getLang();
     $field = $lang->get("name");
     $name = $this->{$field};
     if ($name == '') {
         $name = $thid->usergroup_name;
     }
 }
Beispiel #22
0
 function getAllAttributes($result = 0, $categorys = null, $order = null, $orderDir = null)
 {
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $ordering = "A.attr_ordering asc";
     if ($order && $orderDir) {
         $ordering = $order . " " . $orderDir;
     }
     $query = "SELECT A.attr_id, A.`" . $lang->get("name") . "` as name, A.attr_type, A.attr_ordering, A.independent, A.allcats, A.cats, G.`" . $lang->get("name") . "` as groupname\r\n                  FROM `#__jshopping_attr` as A left join `#__jshopping_attr_groups` as G on A.`group`=G.id\r\n                  ORDER BY " . $ordering;
     extract(js_add_trigger(get_defined_vars(), "before"));
     $db->setQuery($query);
     $list = $db->loadObjectList();
     if (is_array($categorys) && count($categorys)) {
         foreach ($list as $k => $v) {
             if (!$v->allcats) {
                 if ($v->cats != "") {
                     $cats = unserialize($v->cats);
                 } else {
                     $cats = array();
                 }
                 $enable = 0;
                 foreach ($categorys as $cid) {
                     if (in_array($cid, $cats)) {
                         $enable = 1;
                     }
                 }
                 if (!$enable) {
                     unset($list[$k]);
                 }
             }
         }
     }
     if ($result == 0) {
         return $list;
     }
     if ($result == 1) {
         $attributes_format1 = array();
         foreach ($list as $v) {
             $attributes_format1[$v->attr_id] = $v;
         }
         return $attributes_format1;
     }
     if ($result == 2) {
         $attributes_format2 = array();
         $attributes_format2['independent'] = array();
         $attributes_format2['dependent'] = array();
         foreach ($list as $v) {
             if ($v->independent) {
                 $key_dependent = "independent";
             } else {
                 $key_dependent = "dependent";
             }
             $attributes_format2[$key_dependent][$v->attr_id] = $v;
         }
         return $attributes_format2;
     }
 }
Beispiel #23
0
 function getUnits()
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $query = "SELECT id, `" . $lang->get('name') . "` as name FROM `#__jshopping_unit` ORDER BY name";
     extract(js_add_trigger(get_defined_vars(), "before"));
     $db->setQuery($query);
     return $db->loadObjectList();
 }
 function getList()
 {
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $query = "SELECT id, `" . $lang->get("name") . "` as name, ordering FROM `#__jshopping_attr_groups` order by ordering";
     extract(js_add_trigger(get_defined_vars(), "before"));
     $db->setQuery($query);
     return $db->loadObjectList();
 }
Beispiel #25
0
 function getAllAttributes($result = 0, $categorys = null, $order = null, $orderDir = null)
 {
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $ordering = "attr_ordering asc";
     if ($order && $orderDir) {
         $ordering = $order . " " . $orderDir;
     }
     $query = "SELECT attr_id, `" . $lang->get("name") . "` as name, attr_type, attr_ordering, independent, allcats, cats FROM `#__jshopping_attr` ORDER BY " . $ordering;
     $db->setQuery($query);
     $list = $db->loadObjectList();
     if (is_array($categorys) && count($categorys)) {
         foreach ($list as $k => $v) {
             if (!$v->allcats) {
                 if ($v->cats != "") {
                     $cats = unserialize($v->cats);
                 } else {
                     $cats = array();
                 }
                 $enable = 0;
                 foreach ($categorys as $cid) {
                     if (in_array($cid, $cats)) {
                         $enable = 1;
                     }
                 }
                 if (!$enable) {
                     unset($list[$k]);
                 }
             }
         }
     }
     if ($result == 0) {
         return $list;
     }
     if ($result == 1) {
         $attributes_format1 = array();
         foreach ($list as $v) {
             $attributes_format1[$v->attr_id] = $v;
         }
         return $attributes_format1;
     }
     if ($result == 2) {
         $attributes_format2 = array();
         $attributes_format2['independent'] = array();
         $attributes_format2['dependent'] = array();
         foreach ($list as $v) {
             if ($v->independent) {
                 $key_dependent = "independent";
             } else {
                 $key_dependent = "dependent";
             }
             $attributes_format2[$key_dependent][$v->attr_id] = $v;
         }
         return $attributes_format2;
     }
 }
Beispiel #26
0
 function displayEdit($tpl = null)
 {
     JToolBarHelper::title($temp = $this->row->id ? _JSHOP_EDIT . ' / ' . $this->row->{JSFactory::getLang()->get('name')} : _JSHOP_NEW, 'generic.png');
     JToolBarHelper::save();
     JToolBarHelper::spacer();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
 function displayEdit($tpl = null)
 {
     JToolBarHelper::title($this->category->category_id ? _JSHOP_EDIT_CATEGORY . ' / ' . $this->category->{JSFactory::getLang()->get('name')} : _JSHOP_NEW_CATEGORY, 'generic.png');
     JToolBarHelper::save();
     JToolBarHelper::spacer();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Beispiel #28
0
 function displayEdit($tpl = null)
 {
     JToolBarHelper::title($temp = $this->edit ? _JSHOP_DELIVERY_TIME_EDIT . ' / ' . $this->deliveryTimes->{JSFactory::getLang()->get('name')} : _JSHOP_DELIVERY_TIME_NEW, 'generic.png');
     JToolBarHelper::save();
     JToolBarHelper::spacer();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Beispiel #29
0
 function displayEdit($tpl = null)
 {
     JToolBarHelper::title($temp = $this->attributValue->value_id ? _JSHOP_EDIT_ATTRIBUT_VALUE . ' / ' . $this->attributValue->{JSFactory::getLang()->get('name')} : _JSHOP_NEW_ATTRIBUT_VALUE, 'generic.png');
     JToolBarHelper::save();
     JToolBarHelper::spacer();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }
Beispiel #30
0
 function displayEdit($tpl = null)
 {
     JToolBarHelper::title($temp = $this->edit ? _JSHOP_EDIT_MANUFACTURER . ' / ' . $this->manufacturer->{JSFactory::getLang()->get('name')} : _JSHOP_NEW_MANUFACTURER, 'generic.png');
     JToolBarHelper::save();
     JToolBarHelper::spacer();
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }