function save()
 {
     $tax_id = JRequest::getInt("tax_id");
     $tax = JSFactory::getTable('tax', 'jshop');
     $post = JRequest::get("post");
     $post['tax_value'] = saveAsPrice($post['tax_value']);
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSaveTax', array(&$tax));
     if (!$tax->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=taxes");
         return 0;
     }
     if (!$tax->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=taxes");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveTax', array(&$tax));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=taxes&task=edit&tax_id=" . $tax->tax_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=taxes");
     }
 }
Exemple #2
0
 function save()
 {
     $dispatcher = JDispatcher::getInstance();
     $currency_id = JRequest::getInt("currency_id");
     $apply = JRequest::getVar("apply");
     $currency = JSFactory::getTable('currency', 'jshop');
     $post = JRequest::get("post");
     $post['currency_value'] = saveAsPrice($post['currency_value']);
     $dispatcher->trigger('onBeforeSaveCurrencie', array(&$post));
     if (!$currency->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=currencies");
         return 0;
     }
     if ($currency->currency_value == 0) {
         $currency->currency_value = 1;
     }
     $this->_reorderCurrency($currency);
     if (!$currency->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=currencies");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveCurrencie', array(&$currency));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=currencies&task=edit&currency_id=" . $currency->currency_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=currencies");
     }
 }
 public function getPriceFrom()
 {
     if (isset($this->request['price_from'])) {
         $price_from = saveAsPrice($this->request['price_from']);
     } else {
         $price_from = null;
     }
     return $price_from;
 }
 function savegroup()
 {
     $jshopConfig = JSFactory::getConfig();
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforSaveListProduct', array());
     $cid = JRequest::getVar('cid');
     $post = JRequest::get('post');
     $_products = $this->getModel("products");
     foreach ($cid as $id) {
         $product = JTable::getInstance('product', 'jshop');
         $product->load($id);
         if ($post['access'] != -1) {
             $product->set('access', $post['access']);
         }
         if ($post['product_publish'] != -1) {
             $product->set('product_publish', $post['product_publish']);
         }
         if ($post['product_weight'] != "") {
             $product->set('product_weight', $post['product_weight']);
         }
         if ($post['product_quantity'] != "") {
             $product->set('product_quantity', $post['product_quantity']);
             $product->set('unlimited', 0);
         }
         if (isset($post['unlimited']) && $post['unlimited']) {
             $product->set('product_quantity', 1);
             $product->set('unlimited', 1);
         }
         if (isset($post['product_template']) && $post['product_template'] != -1) {
             $product->set('product_template', $post['product_template']);
         }
         if (isset($post['product_tax_id']) && $post['product_tax_id'] != -1) {
             $product->set('product_tax_id', $post['product_tax_id']);
         }
         if (isset($post['product_manufacturer_id']) && $post['product_manufacturer_id'] != -1) {
             $product->set('product_manufacturer_id', $post['product_manufacturer_id']);
         }
         if (isset($post['vendor_id']) && $post['vendor_id'] != -1) {
             $product->set('vendor_id', $post['vendor_id']);
         }
         if (isset($post['delivery_times_id']) && $post['delivery_times_id'] != -1) {
             $product->set('delivery_times_id', $post['delivery_times_id']);
         }
         if (isset($post['label_id']) && $post['label_id'] != -1) {
             $product->set('label_id', $post['label_id']);
         }
         if (isset($post['weight_volume_units']) && $post['weight_volume_units'] != "") {
             $product->set('weight_volume_units', $post['weight_volume_units']);
             $product->set('basic_price_unit_id', $post['basic_price_unit_id']);
         }
         if ($post['product_price'] != "") {
             $oldprice = $product->product_price;
             $price = $_products->getModPrice($product->product_price, saveAsPrice($post['product_price']), $post['mod_price']);
             $product->set('product_price', $price);
             if ($post['use_old_val_price'] == 1) {
                 $product->set('product_old_price', $oldprice);
             }
         }
         if (isset($post['product_old_price']) && $post['product_old_price'] != "") {
             $price = $_products->getModPrice($product->product_old_price, saveAsPrice($post['product_old_price']), $post['mod_old_price']);
             $product->set('product_old_price', $price);
         }
         if (isset($post['product_price']) && $post['product_price'] != "" || $post['product_old_price'] != "") {
             $product->set('currency_id', $post['currency_id']);
         }
         if (isset($post['category_id']) && $post['category_id']) {
             $_products->setCategoryToProduct($id, $post['category_id']);
         }
         $_products->updatePriceAndQtyDependAttr($id, $post);
         $product->store();
         if ($post['product_price'] != "") {
             $mprice = $product->getMinimumPrice();
             $product->set('min_price', $mprice);
         }
         if (!$product->unlimited) {
             $qty = $product->getFullQty();
             $product->set('product_quantity', $qty);
         }
         $product->date_modify = getJsDate();
         $product->store();
         unset($product);
     }
     $dispatcher->trigger('onAfterSaveListProductEnd', array($cid, $post));
     $this->setRedirect("index.php?option=com_jshopping&controller=products", _JSHOP_PRODUCT_SAVED);
 }
 function savegroup()
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforSaveListProduct', array());
     $cid = JRequest::getVar('cid');
     $post = JRequest::get('post');
     $_products = JSFactory::getModel("products");
     foreach ($cid as $id) {
         $product = JSFactory::getTable('product', 'jshop');
         $product->load($id);
         if ($post['access'] != -1) {
             $product->set('access', $post['access']);
         }
         if ($post['product_publish'] != -1) {
             $product->set('product_publish', $post['product_publish']);
         }
         if ($post['product_weight'] != "") {
             $product->set('product_weight', $post['product_weight']);
         }
         if ($post['product_quantity'] != "") {
             $product->set('product_quantity', $post['product_quantity']);
             $product->set('unlimited', 0);
         }
         if (isset($post['unlimited']) && $post['unlimited']) {
             $product->set('product_quantity', 1);
             $product->set('unlimited', 1);
         }
         if (isset($post['product_template']) && $post['product_template'] != -1) {
             $product->set('product_template', $post['product_template']);
         }
         if (isset($post['product_tax_id']) && $post['product_tax_id'] != -1) {
             $product->set('product_tax_id', $post['product_tax_id']);
         }
         if (isset($post['product_manufacturer_id']) && $post['product_manufacturer_id'] != -1) {
             $product->set('product_manufacturer_id', $post['product_manufacturer_id']);
         }
         if (isset($post['vendor_id']) && $post['vendor_id'] != -1) {
             $product->set('vendor_id', $post['vendor_id']);
         }
         if (isset($post['delivery_times_id']) && $post['delivery_times_id'] != -1) {
             $product->set('delivery_times_id', $post['delivery_times_id']);
         }
         if (isset($post['label_id']) && $post['label_id'] != -1) {
             $product->set('label_id', $post['label_id']);
         }
         if (isset($post['weight_volume_units']) && $post['weight_volume_units'] != "") {
             $product->set('weight_volume_units', $post['weight_volume_units']);
             $product->set('basic_price_unit_id', $post['basic_price_unit_id']);
         }
         if ($post['product_price'] != "") {
             $oldprice = $product->product_price;
             $price = $_products->getModPrice($product->product_price, saveAsPrice($post['product_price']), $post['mod_price']);
             $product->set('product_price', $price);
             if ($post['use_old_val_price'] == 1) {
                 $product->set('product_old_price', $oldprice);
             }
         }
         if (isset($post['product_old_price']) && $post['product_old_price'] != "") {
             $price = $_products->getModPrice($product->product_old_price, saveAsPrice($post['product_old_price']), $post['mod_old_price']);
             $product->set('product_old_price', $price);
         }
         if (isset($post['product_price']) && $post['product_price'] != "" || $post['product_old_price'] != "") {
             $product->set('currency_id', $post['currency_id']);
         }
         if (isset($post['category_id']) && $post['category_id']) {
             $_products->setCategoryToProduct($id, $post['category_id']);
         }
         if ($jshopConfig->admin_show_product_extra_field) {
             $_productfields = JSFactory::getModel("productFields");
             $list_productfields = $_productfields->getList(1);
             foreach ($list_productfields as $v) {
                 $_nef = 'extra_field_' . $v->id;
                 switch ($v->type) {
                     case 0:
                         if (isset($post['productfields'][$_nef]) and is_array($post['productfields'][$_nef]) and count($post['productfields'][$_nef]) > 0) {
                             if ($v->multilist == 1 || ($v->multilist == 0 and !in_array(0, $post['productfields'][$_nef]))) {
                                 $product->set($_nef, implode(',', $post['productfields'][$_nef]));
                             }
                         }
                         break;
                     case 1:
                         if (isset($post[$_nef]) and $post[$_nef] != '') {
                             $product->set($_nef, $post[$_nef]);
                         }
                         break;
                 }
             }
         }
         $_products->updatePriceAndQtyDependAttr($id, $post);
         $product->store();
         if ($post['product_price'] != "") {
             $mprice = $product->getMinimumPrice();
             $product->set('min_price', $mprice);
         }
         if (!$product->unlimited) {
             $qty = $product->getFullQty();
             $product->set('product_quantity', $qty);
         }
         $product->date_modify = getJsDate();
         $product->store();
         unset($product);
     }
     $dispatcher->trigger('onAfterSaveListProductEnd', array($cid, $post));
     $this->setRedirect("index.php?option=com_jshopping&controller=products", _JSHOP_PRODUCT_SAVED);
 }
 function savePrices($sh_pr_method_id, $array_post)
 {
     $db = JFactory::getDBO();
     $query = "DELETE FROM `#__jshopping_shipping_method_price_weight` WHERE `sh_pr_method_id` = '" . $db->escape($sh_pr_method_id) . "'";
     $db->setQuery($query);
     $db->query();
     if (!is_array($array_post['shipping_price'])) {
         return 0;
     }
     foreach ($array_post['shipping_price'] as $key => $value) {
         if (!$array_post['shipping_weight_from'][$key] && !$array_post['shipping_weight_to'][$key]) {
             continue;
         }
         $sh_method = JSFactory::getTable('shippingMethodPriceWeight', 'jshop');
         $sh_method->sh_pr_method_id = $sh_pr_method_id;
         $sh_method->shipping_price = saveAsPrice($array_post['shipping_price'][$key]);
         $sh_method->shipping_package_price = saveAsPrice($array_post['shipping_package_price'][$key]);
         $sh_method->shipping_weight_from = saveAsPrice($array_post['shipping_weight_from'][$key]);
         $sh_method->shipping_weight_to = saveAsPrice($array_post['shipping_weight_to'][$key]);
         if (!$sh_method->store()) {
             JError::raiseWarning("", "Error saving to database" . $sh_method->_db->stderr());
         }
     }
 }
Exemple #7
0
 function result()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $lang = JSFactory::getLang();
     $user = JFactory::getUser();
     $session = JFactory::getSession();
     $session->set("jshop_end_page_buy_product", $_SERVER['REQUEST_URI']);
     $session->set("jshop_end_page_list_product", $_SERVER['REQUEST_URI']);
     $params = $mainframe->getParams();
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeLoadProductList', array());
     $product = JSFactory::getTable('product', 'jshop');
     $seo = JSFactory::getTable("seo", "jshop");
     $seodata = $seo->loadData("search-result");
     if (getThisURLMainPageShop()) {
         appendPathWay(_JSHOP_SEARCH);
         if ($seodata->title == "") {
             $seodata->title = _JSHOP_SEARCH;
         }
         setMetaData($seodata->title, $seodata->keyword, $seodata->description);
     } else {
         setMetaData($seodata->title, $seodata->keyword, $seodata->description, $params);
     }
     $post = JRequest::get('request');
     if (isset($post['setsearchdata']) && $post['setsearchdata'] == 1) {
         $session->set("jshop_end_form_data", $post);
     } else {
         $data = $session->get("jshop_end_form_data");
         if (count($data)) {
             $post = $data;
         }
     }
     $category_id = intval($post['category_id']);
     $manufacturer_id = intval($post['manufacturer_id']);
     if (isset($post['date_to'])) {
         $date_to = $post['date_to'];
     } else {
         $date_to = null;
     }
     if (isset($post['date_from'])) {
         $date_from = $post['date_from'];
     } else {
         $date_from = null;
     }
     if (isset($post['price_to'])) {
         $price_to = saveAsPrice($post['price_to']);
     } else {
         $price_to = null;
     }
     if (isset($post['price_from'])) {
         $price_from = saveAsPrice($post['price_from']);
     } else {
         $price_from = null;
     }
     if (isset($post['include_subcat'])) {
         $include_subcat = intval($post['include_subcat']);
     } else {
         $include_subcat = 0;
     }
     $search = trim($post['search']);
     $search_type = $post['search_type'];
     if (!$search_type) {
         $search_type = "any";
     }
     $context = "jshoping.searclist.front.product";
     $orderby = $mainframe->getUserStateFromRequest($context . 'orderby', 'orderby', $jshopConfig->product_sorting_direction, 'int');
     $order = $mainframe->getUserStateFromRequest($context . 'order', 'order', $jshopConfig->product_sorting, 'int');
     $limit = $mainframe->getUserStateFromRequest($context . 'limit', 'limit', $jshopConfig->count_products_to_page, 'int');
     if (!$limit) {
         $limit = $jshopConfig->count_products_to_page;
     }
     $limitstart = JRequest::getInt('limitstart', 0);
     if ($order == 4) {
         $order = 1;
     }
     if ($jshopConfig->admin_show_product_extra_field) {
         if (isset($post['extra_fields'])) {
             $extra_fields = $post['extra_fields'];
         } else {
             $extra_fields = array();
         }
         $extra_fields = filterAllowValue($extra_fields, "array_int_k_v+");
     }
     $categorys = array();
     if ($category_id) {
         if ($include_subcat) {
             $_category = JSFactory::getTable('category', 'jshop');
             $all_categories = $_category->getAllCategories();
             $cat_search[] = $category_id;
             searchChildCategories($category_id, $all_categories, $cat_search);
             foreach ($cat_search as $key => $value) {
                 $categorys[] = $value;
             }
         } else {
             $categorys[] = $category_id;
         }
     }
     $orderbyq = getQuerySortDirection($order, $orderby);
     $image_sort_dir = getImgSortDirection($order, $orderby);
     $filters = array();
     $filters['categorys'] = $categorys;
     if ($manufacturer_id) {
         $filters['manufacturers'][] = $manufacturer_id;
     }
     $filters['price_from'] = $price_from;
     $filters['price_to'] = $price_to;
     if ($jshopConfig->admin_show_product_extra_field) {
         $filters['extra_fields'] = $extra_fields;
     }
     $adv_query = "";
     $adv_from = "";
     $adv_result = $product->getBuildQueryListProductDefaultResult();
     $product->getBuildQueryListProduct("search", "list", $filters, $adv_query, $adv_from, $adv_result);
     if ($date_to && checkMyDate($date_to)) {
         $adv_query .= " AND prod.product_date_added <= '" . $db->escape($date_to) . "'";
     }
     if ($date_from && checkMyDate($date_from)) {
         $adv_query .= " AND prod.product_date_added >= '" . $db->escape($date_from) . "'";
     }
     $where_search = "";
     if ($search_type == "exact") {
         $word = addcslashes($db->escape($search), "_%");
         $tmp = array();
         foreach ($jshopConfig->product_search_fields as $field) {
             $tmp[] = "LOWER(" . getDBFieldNameFromConfig($field) . ") LIKE '%" . $word . "%'";
         }
         $where_search = implode(' OR ', $tmp);
     } else {
         $words = explode(" ", $search);
         $search_word = array();
         foreach ($words as $word) {
             $word = addcslashes($db->escape($word), "_%");
             $tmp = array();
             foreach ($jshopConfig->product_search_fields as $field) {
                 $tmp[] = "LOWER(" . getDBFieldNameFromConfig($field) . ") LIKE '%" . $word . "%'";
             }
             $where_search_block = implode(' OR ', $tmp);
             $search_word[] = "(" . $where_search_block . ")";
         }
         if ($search_type == "any") {
             $where_search = implode(" OR ", $search_word);
         } else {
             $where_search = implode(" AND ", $search_word);
         }
     }
     if ($where_search) {
         $adv_query .= " AND ({$where_search})";
     }
     $orderbyf = $jshopConfig->sorting_products_field_s_select[$order];
     $order_query = $product->getBuildQueryOrderListProduct($orderbyf, $orderbyq, $adv_from);
     $dispatcher->trigger('onBeforeQueryGetProductList', array("search", &$adv_result, &$adv_from, &$adv_query, &$order_query, &$filters));
     $query = "SELECT count(distinct prod.product_id) FROM `#__jshopping_products` AS prod\n                  LEFT JOIN `#__jshopping_products_to_categories` AS pr_cat ON pr_cat.product_id = prod.product_id\n                  LEFT JOIN `#__jshopping_categories` AS cat ON pr_cat.category_id = cat.category_id                  \n                  {$adv_from}\n                  WHERE prod.product_publish = '1' AND cat.category_publish='1'\n                  {$adv_query}";
     $db->setQuery($query);
     $total = $db->loadResult();
     if (!$total) {
         $view_name = "search";
         $view_config = array("template_path" => JPATH_COMPONENT . "/templates/" . $jshopConfig->template . "/" . $view_name);
         $view = $this->getView($view_name, getDocumentType(), '', $view_config);
         $view->setLayout("noresult");
         $view->assign('search', $search);
         $view->display();
         return 0;
     }
     $dispatcher->trigger('onBeforeFixLimitstartDisplayProductList', array(&$limitstart, &$total, 'search'));
     if ($limitstart >= $total) {
         $limitstart = 0;
     }
     $query = "SELECT {$adv_result} FROM `#__jshopping_products` AS prod\n                  LEFT JOIN `#__jshopping_products_to_categories` AS pr_cat ON pr_cat.product_id = prod.product_id\n                  LEFT JOIN `#__jshopping_categories` AS cat ON pr_cat.category_id = cat.category_id                  \n                  {$adv_from}\n                  WHERE prod.product_publish = '1' AND cat.category_publish='1'\n                  {$adv_query}\n                  GROUP BY prod.product_id " . $order_query;
     $db->setQuery($query, $limitstart, $limit);
     $rows = $db->loadObjectList();
     $rows = listProductUpdateData($rows);
     addLinkToProducts($rows, 0, 1);
     jimport('joomla.html.pagination');
     $pagination = new JPagination($total, $limitstart, $limit);
     $pagenav = $pagination->getPagesLinks();
     foreach ($jshopConfig->sorting_products_name_s_select as $key => $value) {
         $sorts[] = JHTML::_('select.option', $key, $value, 'sort_id', 'sort_value');
     }
     insertValueInArray($jshopConfig->count_products_to_page, $jshopConfig->count_product_select);
     foreach ($jshopConfig->count_product_select as $key => $value) {
         $product_count[] = JHTML::_('select.option', $key, $value, 'count_id', 'count_value');
     }
     $sorting_sel = JHTML::_('select.genericlist', $sorts, 'order', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"', 'sort_id', 'sort_value', $order);
     $product_count_sel = JHTML::_('select.genericlist', $product_count, 'limit', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"', 'count_id', 'count_value', $limit);
     $_review = JSFactory::getTable('review', 'jshop');
     $allow_review = $_review->getAllowReview();
     $action = xhtmlUrl($_SERVER['REQUEST_URI']);
     $dispatcher->trigger('onBeforeDisplayProductList', array(&$rows));
     $view_name = "search";
     $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name);
     $view = $this->getView($view_name, getDocumentType(), '', $view_config);
     $view->setLayout("products");
     $view->assign('search', $search);
     $view->assign('total', $total);
     $view->assign('config', $jshopConfig);
     $view->assign('template_block_list_product', "list_products/list_products.php");
     $view->assign('template_block_form_filter', "list_products/form_filters.php");
     $view->assign('template_block_pagination', "list_products/block_pagination.php");
     $view->assign('path_image_sorting_dir', $jshopConfig->live_path . 'images/' . $image_sort_dir);
     $view->assign('filter_show', 0);
     $view->assign('filter_show_category', 0);
     $view->assign('filter_show_manufacturer', 0);
     $view->assign('pagination', $pagenav);
     $view->assign('pagination_obj', $pagination);
     $view->assign('display_pagination', $pagenav != "");
     $view->assign('product_count', $product_count_sel);
     $view->assign('sorting', $sorting_sel);
     $view->assign('action', $action);
     $view->assign('orderby', $orderby);
     $view->assign('count_product_to_row', $jshopConfig->count_products_to_row);
     $view->assign('rows', $rows);
     $view->assign('allow_review', $allow_review);
     $view->assign('shippinginfo', SEFLink($jshopConfig->shippinginfourl, 1));
     $dispatcher->trigger('onBeforeDisplayProductListView', array(&$view));
     $view->display();
 }
 function save()
 {
     $sh_method_id = JRequest::getInt("sh_method_id");
     $shipping_id_back = JRequest::getInt("shipping_id_back");
     $dispatcher = JDispatcher::getInstance();
     $shippings = JSFactory::getModel("shippings");
     $shipping_pr = JSFactory::getTable('shippingMethodPrice', 'jshop');
     $post = JRequest::get("post");
     $post['shipping_stand_price'] = saveAsPrice($post['shipping_stand_price']);
     $dispatcher->trigger('onBeforeSaveShippingPrice', array(&$post));
     $countries = JRequest::getVar('shipping_countries_id');
     if (!$shipping_pr->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=shippingsprices");
         return 0;
     }
     if (isset($post['sm_params'])) {
         $shipping_pr->setParams($post['sm_params']);
     } else {
         $shipping_pr->setParams('');
     }
     if (!$shipping_pr->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=shippingsprices");
         return 0;
     }
     $shippings->savePrices($shipping_pr->sh_pr_method_id, $post);
     $shippings->saveCountries($shipping_pr->sh_pr_method_id, $countries);
     $dispatcher->trigger('onAfterSaveShippingPrice', array(&$shipping_pr));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=shippingsprices&task=edit&sh_pr_method_id=" . $shipping_pr->sh_pr_method_id . "&shipping_id_back=" . $shipping_id_back);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=shippingsprices&shipping_id_back=" . $shipping_id_back);
     }
 }
Exemple #9
0
 function save()
 {
     $back_tax_id = JRequest::getInt("back_tax_id");
     $id = JRequest::getInt("id");
     $tax = JSFactory::getTable('taxExt', 'jshop');
     $post = JRequest::get("post");
     $post['tax'] = saveAsPrice($post['tax']);
     $post['firma_tax'] = saveAsPrice($post['firma_tax']);
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSaveExtTax', array(&$post));
     if (!$tax->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=exttaxes&back_tax_id=" . $back_tax_id);
         return 0;
     }
     $tax->setZones($post['countries_id']);
     if (!$tax->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=exttaxes&back_tax_id=" . $back_tax_id);
         return 0;
     }
     updateCountExtTaxRule();
     $dispatcher->trigger('onAfterSaveExtTax', array(&$tax));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=exttaxes&task=edit&id=" . $tax->id . "&back_tax_id=" . $back_tax_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=exttaxes&back_tax_id=" . $back_tax_id);
     }
 }
Exemple #10
0
 function updatePriceAndQtyDependAttr($product_id, $post)
 {
     $db = JFactory::getDBO();
     $_adv_query = array();
     if ($post['product_price'] != "") {
         $price = saveAsPrice($post['product_price']);
         if ($post['mod_price'] == '%') {
             $_adv_query[] = " `price`=`price` * '" . $price . "' / 100 ";
         } elseif ($post['mod_price'] == '=') {
             $_adv_query[] = " `price`= '" . $price . "' ";
         } else {
             $_adv_query[] = " `price`=`price` " . $post['mod_price'] . " '" . $price . "' ";
         }
     }
     if ($post['product_old_price'] != "") {
         $price = saveAsPrice($post['product_old_price']);
         if ($post['mod_old_price'] == '%') {
             $_adv_query[] = " `old_price`=`old_price` * '" . $price . "' / 100 ";
         } elseif ($post['mod_old_price'] == '=') {
             $_adv_query[] = " `old_price`= '" . $price . "' ";
         } else {
             $_adv_query[] = " `old_price`=`old_price` " . $post['mod_old_price'] . " '" . $price . "' ";
         }
     }
     if ($post['product_quantity'] != "") {
         $_adv_query[] = " `count`= '" . $db->escape($post['product_quantity']) . "' ";
     }
     if (count($_adv_query) > 0) {
         $adv_query = implode(" , ", $_adv_query);
         $query = "update `#__jshopping_products_attr` SET " . $adv_query . " where product_id='" . $db->escape($product_id) . "'";
         $db->setQuery($query);
         $db->query();
     }
 }
Exemple #11
0
 function save()
 {
     $jshopConfig = JSFactory::getConfig();
     require_once $jshopConfig->path . 'lib/image.lib.php';
     require_once $jshopConfig->path . 'lib/uploadfile.class.php';
     $dispatcher = JDispatcher::getInstance();
     $db = JFactory::getDBO();
     $post = JRequest::get('post');
     $_products = JSFactory::getModel("products");
     $product = JSFactory::getTable('product', 'jshop');
     $_alias = JSFactory::getModel("alias");
     $_lang = JSFactory::getModel("languages");
     $id_vendor_cuser = getIdVendorForCUser();
     if ($id_vendor_cuser && $post['product_id']) {
         checkAccessVendorToProduct($id_vendor_cuser, $post['product_id']);
     }
     $post['different_prices'] = 0;
     if (isset($post['product_is_add_price']) && $post['product_is_add_price']) {
         $post['different_prices'] = 1;
     }
     if (!isset($post['product_publish'])) {
         $post['product_publish'] = 0;
     }
     if (!isset($post['product_is_add_price'])) {
         $post['product_is_add_price'] = 0;
     }
     if (!isset($post['unlimited'])) {
         $post['unlimited'] = 0;
     }
     $post['product_price'] = saveAsPrice($post['product_price']);
     $post['product_old_price'] = saveAsPrice($post['product_old_price']);
     if (isset($post['product_buy_price'])) {
         $post['product_buy_price'] = saveAsPrice($post['product_buy_price']);
     } else {
         $post['product_buy_price'] = null;
     }
     $post['product_weight'] = saveAsPrice($post['product_weight']);
     if (!isset($post['related_products'])) {
         $post['related_products'] = array();
     }
     if (!$post['product_id']) {
         $post['product_date_added'] = getJsDate();
     }
     if (!isset($post['attrib_price'])) {
         $post['attrib_price'] = null;
     }
     if (!isset($post['attrib_ind_id'])) {
         $post['attrib_ind_id'] = null;
     }
     if (!isset($post['attrib_ind_price'])) {
         $post['attrib_ind_price'] = null;
     }
     if (!isset($post['attrib_ind_price_mod'])) {
         $post['attrib_ind_price_mod'] = null;
     }
     if (!isset($post['freeattribut'])) {
         $post['freeattribut'] = null;
     }
     $post['date_modify'] = getJsDate();
     $post['edit'] = intval($post['product_id']);
     if (!isset($post['product_add_discount'])) {
         $post['product_add_discount'] = 0;
     }
     $post['min_price'] = $_products->getMinimalPrice($post['product_price'], $post['attrib_price'], array($post['attrib_ind_id'], $post['attrib_ind_price_mod'], $post['attrib_ind_price']), $post['product_is_add_price'], $post['product_add_discount']);
     if ($id_vendor_cuser) {
         $post['vendor_id'] = $id_vendor_cuser;
     }
     if (isset($post['attr_count']) && is_array($post['attr_count'])) {
         $qty = 0;
         foreach ($post['attr_count'] as $key => $_qty) {
             $post['attr_count'][$key] = saveAsPrice($_qty);
             if ($_qty > 0) {
                 $qty += $post['attr_count'][$key];
             }
         }
         $post['product_quantity'] = $qty;
     }
     if ($post['unlimited']) {
         $post['product_quantity'] = 1;
     }
     $post['product_quantity'] = saveAsPrice($post['product_quantity']);
     if (isset($post['productfields']) && is_array($post['productfields'])) {
         foreach ($post['productfields'] as $productfield => $val) {
             if (is_array($val)) {
                 $post[$productfield] = implode(',', $val);
             }
         }
     }
     if ($jshopConfig->admin_show_product_extra_field) {
         $_productfields = JSFactory::getModel("productFields");
         $list_productfields = $_productfields->getList(1);
         foreach ($list_productfields as $v) {
             if ($v->type == 0 && !isset($post['extra_field_' . $v->id])) {
                 $post['extra_field_' . $v->id] = '';
             }
         }
     }
     if (is_array($post['attrib_price'])) {
         if (count(array_unique($post['attrib_price'])) > 1) {
             $post['different_prices'] = 1;
         }
     }
     if (is_array($post['attrib_ind_price'])) {
         $tmp_attr_ind_price = array();
         foreach ($post['attrib_ind_price'] as $k => $v) {
             $tmp_attr_ind_price[] = $post['attrib_ind_price_mod'][$k] . $post['attrib_ind_price'][$k];
         }
         if (count(array_unique($tmp_attr_ind_price)) > 1) {
             $post['different_prices'] = 1;
         }
     }
     $languages = $_lang->getAllLanguages(1);
     foreach ($languages as $lang) {
         $post['name_' . $lang->language] = trim($post['name_' . $lang->language]);
         if ($jshopConfig->create_alias_product_category_auto && $post['alias_' . $lang->language] == "") {
             $post['alias_' . $lang->language] = $post['name_' . $lang->language];
         }
         $post['alias_' . $lang->language] = JApplication::stringURLSafe($post['alias_' . $lang->language]);
         if ($post['alias_' . $lang->language] != "" && !$_alias->checkExistAlias2Group($post['alias_' . $lang->language], $lang->language, $post['product_id'])) {
             $post['alias_' . $lang->language] = "";
             JError::raiseWarning("", _JSHOP_ERROR_ALIAS_ALREADY_EXIST);
         }
         $post['description_' . $lang->language] = JRequest::getVar('description' . $lang->id, '', 'post', "string", 2);
         $post['short_description_' . $lang->language] = JRequest::getVar('short_description_' . $lang->language, '', 'post', "string", 2);
     }
     $dispatcher->trigger('onBeforeDisplaySaveProduct', array(&$post, &$product));
     if (!$product->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=products");
         return 0;
     }
     if (($product->min_price == 0 || $product->product_price == 0) && !$jshopConfig->user_as_catalog && $product->parent_id == 0) {
         JError::raiseNotice("", _JSHOP_YOU_NOT_SET_PRICE);
     }
     if (isset($post['set_main_image'])) {
         $image = JSFactory::getTable('image', 'jshop');
         $image->load($post['set_main_image']);
         if ($image->image_id) {
             $product->image = $image->image_name;
         }
     }
     if (!$product->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE . "<br>" . $product->_error);
         $this->setRedirect("index.php?option=com_jshopping&controller=products&task=edit&product_id=" . $product->product_id);
         return 0;
     }
     $product_id = $product->product_id;
     $dispatcher->trigger('onAfterSaveProduct', array(&$product));
     if ($jshopConfig->admin_show_product_video && $product->parent_id == 0) {
         $_products->uploadVideo($product, $product_id, $post);
     }
     $_products->uploadImages($product, $product_id, $post);
     if ($jshopConfig->admin_show_product_files) {
         $_products->uploadFiles($product, $product_id, $post);
     }
     $_products->saveAttributes($product, $product_id, $post);
     if ($jshopConfig->admin_show_freeattributes) {
         $_products->saveFreeAttributes($product_id, $post['freeattribut']);
     }
     if ($post['product_is_add_price']) {
         $_products->saveAditionalPrice($product_id, $post['product_add_discount'], $post['quantity_start'], $post['quantity_finish']);
     }
     if ($product->parent_id == 0) {
         $_products->setCategoryToProduct($product_id, $post['category_id']);
     }
     $_products->saveRelationProducts($product, $product_id, $post);
     $_products->saveProductOptions($product_id, (array) $post['options']);
     $dispatcher->trigger('onAfterSaveProductEnd', array($product->product_id));
     if ($product->parent_id != 0) {
         print "<script type='text/javascript'>window.close();</script>";
         die;
     }
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=products&task=edit&product_id=" . $product->product_id, _JSHOP_PRODUCT_SAVED);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=products", _JSHOP_PRODUCT_SAVED);
     }
 }
 function save()
 {
     $payment_id = JRequest::getInt("payment_id");
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $db = JFactory::getDBO();
     $payment = JTable::getInstance('paymentMethod', 'jshop');
     $post = JRequest::get("post");
     if (!isset($post['payment_publish'])) {
         $post['payment_publish'] = 0;
     }
     if (!isset($post['show_descr_in_email'])) {
         $post['show_descr_in_email'] = 0;
     }
     $post['price'] = saveAsPrice($post['price']);
     $post['payment_class'] = JRequest::getCmd("payment_class");
     if (!$post['payment_id']) {
         $post['payment_type'] = 1;
     }
     $dispatcher->trigger('onBeforeSavePayment', array(&$post));
     $_lang = $this->getModel("languages");
     $languages = $_lang->getAllLanguages(1);
     foreach ($languages as $lang) {
         $post['description_' . $lang->language] = JRequest::getVar('description' . $lang->id, '', 'post', "string", 2);
     }
     $payment->bind($post);
     $_payments = $this->getModel("payments");
     if (!$payment->payment_id) {
         $payment->payment_ordering = $_payments->getMaxOrdering() + 1;
     }
     if (isset($post['pm_params'])) {
         $parseString = new parseString($post['pm_params']);
         $payment->payment_params = $parseString->splitParamsToString();
     }
     if (!$payment->check()) {
         JError::raiseWarning("", $payment->getError());
         $this->setRedirect("index.php?option=com_jshopping&controller=payments&task=edit&payment_id=" . $payment->payment_id);
         return 0;
     }
     $payment->store();
     $dispatcher->trigger('onAfterSavePayment', array(&$payment));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=payments&task=edit&payment_id=" . $payment->payment_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=payments");
     }
 }
Exemple #13
0
 function productGroupUpdate($id, $post)
 {
     $jshopConfig = JSFactory::getConfig();
     $product = JSFactory::getTable('product', 'jshop');
     $product->load($id);
     if ($post['access'] != -1) {
         $product->set('access', $post['access']);
     }
     if ($post['product_publish'] != -1) {
         $product->set('product_publish', $post['product_publish']);
     }
     if ($post['product_weight'] != "") {
         $product->set('product_weight', $post['product_weight']);
     }
     if ($post['product_quantity'] != "") {
         $product->set('product_quantity', $post['product_quantity']);
         $product->set('unlimited', 0);
     }
     if (isset($post['unlimited']) && $post['unlimited']) {
         $product->set('product_quantity', 1);
         $product->set('unlimited', 1);
     }
     if (isset($post['product_template']) && $post['product_template'] != -1) {
         $product->set('product_template', $post['product_template']);
     }
     if (isset($post['product_tax_id']) && $post['product_tax_id'] != -1) {
         $product->set('product_tax_id', $post['product_tax_id']);
     }
     if (isset($post['product_manufacturer_id']) && $post['product_manufacturer_id'] != -1) {
         $product->set('product_manufacturer_id', $post['product_manufacturer_id']);
     }
     if (isset($post['vendor_id']) && $post['vendor_id'] != -1) {
         $product->set('vendor_id', $post['vendor_id']);
     }
     if (isset($post['delivery_times_id']) && $post['delivery_times_id'] != -1) {
         $product->set('delivery_times_id', $post['delivery_times_id']);
     }
     if (isset($post['label_id']) && $post['label_id'] != -1) {
         $product->set('label_id', $post['label_id']);
     }
     if (isset($post['weight_volume_units']) && $post['weight_volume_units'] != "") {
         $product->set('weight_volume_units', $post['weight_volume_units']);
         $product->set('basic_price_unit_id', $post['basic_price_unit_id']);
     }
     if ($post['product_price'] != "") {
         $oldprice = $product->product_price;
         $price = $this->getModPrice($product->product_price, saveAsPrice($post['product_price']), $post['mod_price']);
         $product->set('product_price', $price);
         if ($post['use_old_val_price'] == 1) {
             $product->set('product_old_price', $oldprice);
         }
     }
     if (isset($post['product_old_price']) && $post['product_old_price'] != "") {
         $price = $this->getModPrice($product->product_old_price, saveAsPrice($post['product_old_price']), $post['mod_old_price']);
         $product->set('product_old_price', $price);
     }
     if (isset($post['product_buy_price']) && $post['product_buy_price'] != "") {
         $product->set('product_buy_price', $post['product_buy_price']);
     }
     if (isset($post['product_price']) && $post['product_price'] != "" || $post['product_old_price'] != "") {
         $product->set('currency_id', $post['currency_id']);
     }
     if (isset($post['category_id']) && $post['category_id']) {
         $this->setCategoryToProduct($id, $post['category_id']);
     }
     if ($jshopConfig->admin_show_product_extra_field) {
         $_productfields = JSFactory::getModel("productFields");
         $list_productfields = $_productfields->getList(1);
         foreach ($list_productfields as $v) {
             $_nef = 'extra_field_' . $v->id;
             switch ($v->type) {
                 case 0:
                     if (isset($post['productfields'][$_nef]) and is_array($post['productfields'][$_nef]) and count($post['productfields'][$_nef]) > 0) {
                         if ($v->multilist == 1 || ($v->multilist == 0 and !in_array(0, $post['productfields'][$_nef]))) {
                             $product->set($_nef, implode(',', $post['productfields'][$_nef]));
                         }
                     }
                     break;
                 case 1:
                     if (isset($post[$_nef]) and $post[$_nef] != '') {
                         $product->set($_nef, $post[$_nef]);
                     }
                     break;
             }
         }
     }
     $this->updatePriceAndQtyDependAttr($id, $post);
     $product->store();
     if ($post['product_price'] != "") {
         $mprice = $product->getMinimumPrice();
         $product->set('min_price', $mprice);
     }
     if (!$product->unlimited) {
         $qty = $product->getFullQty();
         $product->set('product_quantity', $qty);
     }
     $product->date_modify = getJsDate();
     extract(js_add_trigger(get_defined_vars(), "beforeStore"));
     $product->store();
 }
Exemple #14
0
function getBuildFilterListProduct($contextfilter, $no_filter = array())
{
    $mainframe = JFactory::getApplication();
    $jshopConfig = JSFactory::getConfig();
    $category_id = JRequest::getInt('category_id');
    $manufacturer_id = JRequest::getInt('manufacturer_id');
    $label_id = JRequest::getInt('label_id');
    $vendor_id = JRequest::getInt('vendor_id');
    $price_from = saveAsPrice(JRequest::getVar('price_from'));
    $price_to = saveAsPrice(JRequest::getVar('price_to'));
    $categorys = $mainframe->getUserStateFromRequest($contextfilter . 'categorys', 'categorys', array());
    $categorys = filterAllowValue($categorys, "int+");
    $tmpcd = getListFromStr(JRequest::getVar('category_id'));
    if (is_array($tmpcd) && !$categorys) {
        $categorys = $tmpcd;
    }
    $manufacturers = $mainframe->getUserStateFromRequest($contextfilter . 'manufacturers', 'manufacturers', array());
    $manufacturers = filterAllowValue($manufacturers, "int+");
    $tmp = getListFromStr(JRequest::getVar('manufacturer_id'));
    if (is_array($tmp) && !$manufacturers) {
        $manufacturers = $tmp;
    }
    $labels = $mainframe->getUserStateFromRequest($contextfilter . 'labels', 'labels', array());
    $labels = filterAllowValue($labels, "int+");
    $tmplb = getListFromStr(JRequest::getVar('label_id'));
    if (is_array($tmplb) && !$labels) {
        $labels = $tmplb;
    }
    $vendors = $mainframe->getUserStateFromRequest($contextfilter . 'vendors', 'vendors', array());
    $vendors = filterAllowValue($vendors, "int+");
    $tmp = getListFromStr(JRequest::getVar('vendor_id'));
    if (is_array($tmp) && !$vendors) {
        $vendors = $tmp;
    }
    if ($jshopConfig->admin_show_product_extra_field) {
        $extra_fields = $mainframe->getUserStateFromRequest($contextfilter . 'extra_fields', 'extra_fields', array());
        $extra_fields = filterAllowValue($extra_fields, "array_int_k_v+");
    }
    $fprice_from = $mainframe->getUserStateFromRequest($contextfilter . 'fprice_from', 'fprice_from');
    $fprice_from = saveAsPrice($fprice_from);
    if (!$fprice_from) {
        $fprice_from = $price_from;
    }
    $fprice_to = $mainframe->getUserStateFromRequest($contextfilter . 'fprice_to', 'fprice_to');
    $fprice_to = saveAsPrice($fprice_to);
    if (!$fprice_to) {
        $fprice_to = $price_to;
    }
    $filters = array();
    $filters['categorys'] = $categorys;
    $filters['manufacturers'] = $manufacturers;
    $filters['price_from'] = $fprice_from;
    $filters['price_to'] = $fprice_to;
    $filters['labels'] = $labels;
    $filters['vendors'] = $vendors;
    if ($jshopConfig->admin_show_product_extra_field) {
        $filters['extra_fields'] = $extra_fields;
    }
    if ($category_id && !$filters['categorys']) {
        $filters['categorys'][] = $category_id;
    }
    if ($manufacturer_id && !$filters['manufacturers']) {
        $filters['manufacturers'][] = $manufacturer_id;
    }
    if ($label_id && !$filters['labels']) {
        $filters['labels'][] = $label_id;
    }
    if ($vendor_id && !$filters['vendors']) {
        $filters['vendors'][] = $vendor_id;
    }
    if (is_array($filters['vendors'])) {
        $main_vendor = JSFactory::getMainVendor();
        foreach ($filters['vendors'] as $vid) {
            if ($vid == $main_vendor->id) {
                $filters['vendors'][] = 0;
            }
        }
    }
    foreach ($no_filter as $filterkey) {
        unset($filters[$filterkey]);
    }
    JPluginHelper::importPlugin('jshoppingproducts');
    $dispatcher = JDispatcher::getInstance();
    $dispatcher->trigger('afterGetBuildFilterListProduct', array(&$filters));
    return $filters;
}
 function save()
 {
     $coupon_id = JRequest::getInt("coupon_id");
     $coupon = JSFactory::getTable('coupon', 'jshop');
     $dispatcher = JDispatcher::getInstance();
     $post = JRequest::get("post");
     $post['coupon_code'] = JRequest::getCmd("coupon_code");
     $post['coupon_publish'] = JRequest::getInt("coupon_publish");
     $post['finished_after_used'] = JRequest::getInt("finished_after_used");
     $post['coupon_value'] = saveAsPrice($post['coupon_value']);
     $dispatcher->trigger('onBeforeSaveCoupon', array(&$post));
     if (!$post['coupon_code']) {
         JError::raiseWarning("", _JSHOP_ERROR_COUPON_CODE);
         $this->setRedirect("index.php?option=com_jshopping&controller=coupons&task=edit&coupon_id=" . $coupon->coupon_id);
         return 0;
     }
     if ($post['coupon_value'] < 0 || $post['coupon_value'] > 100 && $post['coupon_type'] == 0) {
         JError::raiseWarning("", _JSHOP_ERROR_COUPON_VALUE);
         $this->setRedirect("index.php?option=com_jshopping&controller=coupons&task=edit&coupon_id=" . $coupon->coupon_id);
         return 0;
     }
     if (!$coupon->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=coupons");
         return 0;
     }
     if ($coupon->getExistCode()) {
         JError::raiseWarning("", _JSHOP_ERROR_COUPON_EXIST);
         $this->setRedirect("index.php?option=com_jshopping&controller=coupons");
         return 0;
     }
     if (!$coupon->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=coupons");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveCoupon', array(&$coupon));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=coupons&task=edit&coupon_id=" . $coupon->coupon_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=coupons");
     }
 }
    $manufacturers = $mainframe->getUserStateFromRequest($contextfilter . 'manufacturers', 'manufacturers', array());
    $manufacturers = filterAllowValue($manufacturers, "int+");
    $filter_manufactures = $category->getManufacturers();
}
if ($manufacturer_id && $show_categorys) {
    $manufacturer = JTable::getInstance('manufacturer', 'jshop');
    $manufacturer->load($manufacturer_id);
    $categorys = $mainframe->getUserStateFromRequest($contextfilter . 'categorys', 'categorys', array());
    $categorys = filterAllowValue($categorys, "int+");
    $filter_categorys = $manufacturer->getCategorys();
}
if ($show_prices) {
    $fprice_from = $mainframe->getUserStateFromRequest($contextfilter . 'fprice_from', 'fprice_from');
    $fprice_from = saveAsPrice($fprice_from);
    $fprice_to = $mainframe->getUserStateFromRequest($contextfilter . 'fprice_to', 'fprice_to');
    $fprice_to = saveAsPrice($fprice_to);
}
if ($show_characteristics && $jshopConfig->admin_show_product_extra_field) {
    $characteristic_fields = JSFactory::getAllProductExtraField();
    $characteristic_fieldvalues = JSFactory::getAllProductExtraFieldValueDetail();
    $characteristic_displayfields = JSFactory::getDisplayFilterExtraFieldForCategory($category_id);
    $extra_fields_active = $mainframe->getUserStateFromRequest($contextfilter . 'extra_fields', 'extra_fields', array());
    $extra_fields_active = filterAllowValue($extra_fields_active, "array_int_k_v+");
}
$date_from = $mainframe->getUserStateFromRequest($contextfilter . 'dfrom', 'dfrom', date('d/m/Y'));
$date_to = $mainframe->getUserStateFromRequest($contextfilter . 'dto', 'dto', date('d/m/Y', time() + 60 * 60 * 24));
if ($date_from == '') {
    $date_from = date('d/m/Y');
}
if ($date_to == '') {
    $date_to = date('d/m/Y', time() + 60 * 60 * 24);
Exemple #17
0
 function saveOrderItem($order_id, $post, $old_items)
 {
     $db = JFactory::getDBO();
     if (!isset($post['product_name'])) {
         $post['product_name'] = array();
     }
     $edit_order_items = array();
     foreach ($post['product_name'] as $k => $v) {
         $order_item_id = intval($post['order_item_id'][$k]);
         $edit_order_items[] = $order_item_id;
         $order_item = JTable::getInstance('orderItem', 'jshop');
         $order_item->order_item_id = $order_item_id;
         $order_item->order_id = $order_id;
         $order_item->product_id = $post['product_id'][$k];
         $order_item->product_ean = $post['product_ean'][$k];
         $order_item->product_name = $post['product_name'][$k];
         $order_item->product_quantity = saveAsPrice($post['product_quantity'][$k]);
         $order_item->product_item_price = $post['product_item_price'][$k];
         $order_item->product_tax = $post['product_tax'][$k];
         $order_item->product_attributes = $post['product_attributes'][$k];
         $order_item->product_freeattributes = $post['product_freeattributes'][$k];
         $order_item->weight = $post['weight'][$k];
         if (isset($post['delivery_times_id'][$k])) {
             $order_item->delivery_times_id = $post['delivery_times_id'][$k];
         } else {
             $order_item->delivery_times_id = 0;
         }
         $order_item->vendor_id = $post['vendor_id'][$k];
         $order_item->thumb_image = $post['thumb_image'][$k];
         $order_item->files = serialize(array());
         $order_item->store();
         unset($order_item);
     }
     foreach ($old_items as $k => $v) {
         if (!in_array($v->order_item_id, $edit_order_items)) {
             $order_item = JTable::getInstance('orderItem', 'jshop');
             $order_item->delete($v->order_item_id);
         }
     }
     return 1;
 }