function save()
 {
     $id = JRequest::getInt("id");
     $configdisplayprice = JSFactory::getTable('configDisplayPrice', 'jshop');
     $post = JRequest::get("post");
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSaveConfigDisplayPrice', array(&$post));
     if (!$post['countries_id']) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=configdisplayprice&task=edit&id=" . $post['id']);
         return 0;
     }
     if (!$configdisplayprice->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=configdisplayprice");
         return 0;
     }
     $configdisplayprice->setZones($post['countries_id']);
     if (!$configdisplayprice->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=configdisplayprice");
         return 0;
     }
     updateCountConfigDisplayPrice();
     $dispatcher->trigger('onAftetSaveConfigDisplayPrice', array(&$configdisplayprice));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=configdisplayprice&task=edit&id=" . $configdisplayprice->id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=configdisplayprice");
     }
 }
Exemplo n.º 2
0
 function getDisplayPriceFront()
 {
     $display_price = $this->display_price_front;
     if ($this->use_extend_display_price_rule > 0) {
         $adv_user = JSFactory::getUserShop();
         $country_id = $adv_user->country;
         $client_type = $adv_user->client_type;
         if (!$adv_user->user_id) {
             $adv_user = JSFactory::getUserShopGuest();
             $country_id = $adv_user->country;
             $client_type = $adv_user->client_type;
         }
         if (!$country_id) {
             $country_id = $this->default_country;
         }
         if ($country_id) {
             $configDisplayPrice = JSFactory::getTable('configDisplayPrice', 'jshop');
             $rows = $configDisplayPrice->getList();
             foreach ($rows as $v) {
                 if (in_array($country_id, $v->countries)) {
                     if ($client_type == 2) {
                         $display_price = $v->display_price_firma;
                     } else {
                         $display_price = $v->display_price;
                     }
                 }
             }
         }
     }
     return $display_price;
 }
Exemplo n.º 3
0
 public function getListOrders()
 {
     $order = JSFactory::getTable('order', 'jshop');
     $this->list = $order->getOrdersForUser($this->user_id);
     $this->loadOrderLink();
     return $this->list;
 }
Exemplo n.º 4
0
 function save()
 {
     $mainframe = JFactory::getApplication();
     $id = JRequest::getInt("id");
     $deliveryTimes = JSFactory::getTable('deliveryTimes', 'jshop');
     $post = JRequest::get("post");
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSaveDeliveryTime', array(&$post));
     if (!$deliveryTimes->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes");
         return 0;
     }
     if (!$deliveryTimes->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveDeliveryTime', array(&$deliveryTimes));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes&task=edit&id=" . $deliveryTimes->id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes");
     }
 }
 private function getFreightPrice($weight, $type)
 {
     $vendor = JSFactory::getTable('vendor', 'jshop');
     $vendor->loadMain();
     $client = JSFactory::getUser();
     $cep = preg_replace('|[^\\d]|', '', $client->d_zip ? $client->d_zip : $client->zip);
     $cost = $this->getCache($weight, $type, $cep);
     if ($cost) {
         return $cost;
     }
     $data = array('email' => plgSystemLigminchaFreight::$pagseguro_email, 'token' => plgSystemLigminchaFreight::$pagseguro_token, 'currency' => 'BRL', 'itemId1' => 1, 'itemDescription1' => 'Livros do Ligmincha Brasil Loja', 'itemAmount1' => '1.00', 'itemQuantity1' => 1, 'itemWeight1' => $weight, 'reference' => strtoupper(substr(uniqid('LB'), 1, 6)), 'senderName' => $vendor->shop_name, 'senderAreaCode' => $vendor->zip, 'senderEmail' => $vendor->email, 'shippingType' => $type, 'shippingAddressStreet' => $client->d_street ? $client->d_street : $client->street, 'shippingAddressNumber' => $client->d_street_nr ? $client->d_street_nr : $client->street_nr, 'shippingAddressPostalCode' => $cep, 'shippingAddressCity' => $client->d_city ? $client->d_city : $client->city, 'shippingAddressState' => $client->d_state ? $client->d_state : $client->state, 'shippingAddressCountry' => 'BRA');
     $result = $this->post('https://ws.pagseguro.uol.com.br/v2/checkout/', $data);
     $code = preg_match('|<code>(.+?)</code>|', $result, $m) ? $m[1] : false;
     if ($code) {
         JFactory::getApplication()->enqueueMessage("Code: {$code}");
         $html = file_get_contents("https://pagseguro.uol.com.br/v2/checkout/payment.html?code={$code}");
         $cost = preg_match('|"freightRow".+?R\\$.+?([\\d,]+)|s', $html, $m) ? $m[1] : 0;
         $cost = str_replace(',', '.', $cost);
     } else {
         JError::raiseWarning('', curl_error($result));
     }
     if ($cost == 0) {
         JError::raiseWarning('', 'Failed to obtain freight price!');
     } else {
         $this->setCache($weight, $type, $cep, $cost);
     }
     return $cost;
 }
Exemplo n.º 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;
 }
Exemplo n.º 7
0
 private function updateUserGroup()
 {
     $user = JFactory::getUser();
     if (!$user->guest) {
         $from_summ_1 = $this->params->get('from_summ_1', 0);
         $to_summ_1 = $this->params->get('to_summ_1', 0);
         $group_id_1 = $this->params->get('group_id_1', 0);
         $from_summ_2 = $this->params->get('from_summ_2', 0);
         $to_summ_2 = $this->params->get('to_summ_2', 0);
         $group_id_2 = $this->params->get('group_id_2', 0);
         if ($from_summ_1 != 0 && $to_summ_1 != 0 && $group_id_1 != 0 || $from_summ_2 != 0 && $to_summ_2 != 0 && $group_id_2 != 0) {
             $db = JFactory::getDBO();
             $order = JSFactory::getTable('order', 'jshop');
             $orders = $order->getOrdersForUser($user->id);
             $total = 0;
             foreach ($orders as $order) {
                 $total += $order->order_total;
             }
             $this->groupIsPresent($db, 3);
             if ($total >= $from_summ_1 && $total <= $to_summ_1) {
                 if ($this->groupIsPresent($db, $group_id_1)) {
                     $this->setNewGroupId($db, $group_id_1, $user->id);
                 }
                 //}	elseif($total >= $from_summ_2 && $total <= $to_summ_2) {
             } else {
                 if ($this->groupIsPresent($db, $group_id_2)) {
                     $this->setNewGroupId($db, $group_id_2, $user->id);
                 }
                 //}	elseif($total >= $from_summ_2 && $total <= $to_summ_2) {
             }
             setNextUpdatePrices();
         }
     }
 }
Exemplo n.º 8
0
 function display($cachable = false, $urlparams = false)
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     JSFactory::getModel('productShop', 'jshop')->storeEndPages();
     $product = JSFactory::getTable('product', 'jshop');
     $params = JFactory::getApplication()->getParams();
     $header = getPageHeaderOfParams($params);
     $prefix = $params->get('pageclass_sfx');
     JshopHelpersMetadata::allProducts();
     $productlist = JSFactory::getModel('productList', 'jshop');
     $productlist->setModel($product);
     $productlist->load();
     $orderby = $productlist->getOrderBy();
     $image_sort_dir = $productlist->getImageSortDir();
     $filters = $productlist->getFilters();
     $action = $productlist->getAction();
     $products = $productlist->getProducts();
     $pagination = $productlist->getPagination();
     $pagenav = $productlist->getPagenav();
     $sorting_sel = $productlist->getHtmlSelectSorting();
     $product_count_sel = $productlist->getHtmlSelectCount();
     $willBeUseFilter = $productlist->getWillBeUseFilter();
     $display_list_products = $productlist->getDisplayListProducts();
     $manufacuturers_sel = $productlist->getHtmlSelectFilterManufacturer(1);
     $categorys_sel = $productlist->getHtmlSelectFilterCategory(1);
     $allow_review = $productlist->getAllowReview();
     $view = $this->getView('products');
     $view->setLayout("products");
     $view->assign('config', $jshopConfig);
     $view->assign('template_block_list_product', $productlist->getTmplBlockListProduct());
     $view->assign('template_no_list_product', $productlist->getTmplNoListProduct());
     $view->assign('template_block_form_filter', $productlist->getTmplBlockFormFilter());
     $view->assign('template_block_pagination', $productlist->getTmplBlockPagination());
     $view->assign('path_image_sorting_dir', $jshopConfig->live_path . 'images/' . $image_sort_dir);
     $view->assign('filter_show', 1);
     $view->assign('filter_show_category', 1);
     $view->assign('filter_show_manufacturer', 1);
     $view->assign('pagination', $pagenav);
     $view->assign('pagination_obj', $pagination);
     $view->assign('display_pagination', $pagenav != "");
     $view->assign("header", $header);
     $view->assign("prefix", $prefix);
     $view->assign("rows", $products);
     $view->assign("count_product_to_row", $productlist->getCountProductsToRow());
     $view->assign('action', $action);
     $view->assign('allow_review', $allow_review);
     $view->assign('orderby', $orderby);
     $view->assign('product_count', $product_count_sel);
     $view->assign('sorting', $sorting_sel);
     $view->assign('categorys_sel', $categorys_sel);
     $view->assign('manufacuturers_sel', $manufacuturers_sel);
     $view->assign('filters', $filters);
     $view->assign('willBeUseFilter', $willBeUseFilter);
     $view->assign('display_list_products', $display_list_products);
     $view->assign('shippinginfo', SEFLink($jshopConfig->shippinginfourl, 1));
     $dispatcher->trigger('onBeforeDisplayProductListView', array(&$view));
     $view->display();
 }
Exemplo n.º 9
0
 private function buildAdvQuery()
 {
     if ($this->buildAdvQuery == 1) {
         return 0;
     }
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     $db = JFactory::getDBO();
     $product = JSFactory::getTable('product', 'jshop');
     $orderbyq = getQuerySortDirection($this->order, $this->orderby);
     $adv_query = "";
     $adv_from = "";
     $adv_result = $product->getBuildQueryListProductDefaultResult();
     $product->getBuildQueryListProduct("search", "list", $this->filters, $adv_query, $adv_from, $adv_result);
     if ($this->date_to && checkMyDate($this->date_to)) {
         $adv_query .= " AND prod.product_date_added <= '" . $db->escape($this->date_to) . "'";
     }
     if ($this->date_from && checkMyDate($this->date_from)) {
         $adv_query .= " AND prod.product_date_added >= '" . $db->escape($this->date_from) . "'";
     }
     $where_search = "";
     if ($this->search_type == "exact") {
         $word = addcslashes($db->escape($this->search), "_%");
         $tmp = array();
         foreach ($jshopConfig->product_search_fields as $field) {
             $tmp[] = "LOWER(" . getDBFieldNameFromConfig($field) . ") LIKE '%" . $word . "%'";
         }
         $where_search = implode(' OR ', $tmp);
     } else {
         $words = explode(" ", $this->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 ($this->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[$this->order];
     $order_query = $product->getBuildQueryOrderListProduct($orderbyf, $orderbyq, $adv_from);
     $dispatcher->trigger('onBeforeQueryGetProductList', array("search", &$adv_result, &$adv_from, &$adv_query, &$order_query, &$this->filters));
     $this->adv_result = $adv_result;
     $this->adv_from = $adv_from;
     $this->adv_query = $adv_query;
     $this->order_query = $order_query;
     $this->buildAdvQuery == 1;
     return 1;
 }
 /**
  * отправляется запрос в базу локального сервера для окончательной проверки доступности для бронирования
  */
 public function chekBookingBeforeSave(&$order, &$cart)
 {
     $db_local = JDatabase::getInstance(VipLocalApi::getDbConnectOptions());
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $adv_user = JSFactory::getUser();
     $adv_user = JSFactory::getTable('usershop', 'jshop');
     $adv_user->load($user->id);
     $order->country = $adv_user->country;
     $order->f_name = $adv_user->f_name;
     $order->l_name = $adv_user->l_name;
     $order->email = $adv_user->email;
     $order->phone = $adv_user->phone;
     //		echo'<pre>';print_r($user);echo'</pre>';//die;
     //		echo'<pre>';print_r($adv_user);echo'</pre>';//die;
     //		echo'<pre>';print_r($order);echo'</pre>';die;
     $product_id_local = $cart->products[0]['ean'];
     $product_id = $cart->products[0]['product_id'];
     $category_id = $cart->products[0]['category_id'];
     $booking_date_info = $cart->products[0]['free_attributes_value'];
     //$date_from = '31-10-2015';
     $date_from = str_replace('/', '-', $booking_date_info[0]->value);
     $date_to = str_replace('/', '-', $booking_date_info[1]->value);
     //проверяем только локальный сервер, так как на WuBook-е установлена нотификация каждого нового бронирования.
     $object_is_free_on_local = $this->chekBookingOnLocal($db_local, $product_id_local, $date_from, $date_to);
     //$object_is_free_on_local = true;
     //повторно проверяем по базе сайта, чтобы никто не забронил номер пока пользователь "копается"
     $object_is_free_on_site = $this->chekBookingOnSite($db, $product_id, $date_from, $date_to);
     if ($object_is_free_on_local == true && $object_is_free_on_site == true) {
         //заменяем разделитеть даты
         $date_from = str_replace('/', '-', $date_from);
         $date_to = str_replace('/', '-', $date_to);
         //			echo'<pre>';print_r($product_id_local);echo'</pre>';//die;
         //			echo'<pre>';print_r($date_from);echo'</pre>';//die;
         //			echo'<pre>';print_r($date_to);echo'</pre>';//die;
         //			echo'<pre>';print_r($order);echo'</pre>';die;
         //			echo'<pre>';print_r($db_local);echo'</pre>';die;
         $k_zajav = VipLocalApi::addBookingOnLocalServer($db_local, $product_id_local, $date_from, $date_to, $order, VipLocalApi::ON_BOOKING_FROM_SITE_PRIM_PREFIX);
         //echo'<pre>';var_dump($k_zajav);echo'</pre>';die;
         $session = JFactory::getSession();
         $session->set("k_zajav", $k_zajav);
     } else {
         $cart->clear();
         $mainframe = JFactory::getApplication();
         JError::raiseNotice(100, _JSHOP_OBJECT_IS_ALREADY_BOOKED);
         $contextfilter = "jshoping.list.front.product.cat." . $category_id;
         $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);
         }
         $mainframe->redirect(SEFLink('index.php?option=com_jshopping&view=category&layout=category&task=view&category_id=' . $category_id . '&dfrom=' . $date_from_ . '&dto=' . $date_to_, 1, 1));
     }
 }
Exemplo n.º 11
0
 public function getAddonId()
 {
     if (!$this->addon_id) {
         $addon = JSFactory::getTable('addon', 'jshop');
         $addon->loadAlias($this->addon_alias);
         $this->addon_id = $addon->id;
     }
     return $this->addon_id;
 }
Exemplo n.º 12
0
 function getDescriptionMainPage($preparePluginContent = 1)
 {
     $statictext = JSFactory::getTable("statictext", "jshop");
     $rowstatictext = $statictext->loadData("manufacturer");
     $this->description = $rowstatictext->text;
     if ($preparePluginContent && JSFactory::getConfig()->use_plugin_content) {
         changeDataUsePluginContent($this, "manufacturer");
     }
     return $this->description;
 }
Exemplo n.º 13
0
 function delete($id, $check = 1)
 {
     if ($check) {
         if ($this->getCountProduct($id)) {
             return 0;
         }
     }
     $row = JSFactory::getTable('currency', 'jshop');
     return $row->delete($id);
 }
Exemplo n.º 14
0
 public function save()
 {
     $this->review->store();
     $product_id = $this->getProductId();
     JDispatcher::getInstance()->trigger('onAfterSaveReview', array(&$this->review));
     $product = JSFactory::getTable('product', 'jshop');
     $product->load($product_id);
     $product->loadAverageRating();
     $product->loadReviewsCount();
     $product->store();
 }
Exemplo n.º 15
0
 public static function getManufacturer($selected = null, $attribs = null, $name = 'manufacturer_id')
 {
     $first = JHTML::_('select.option', 0, _JSHOP_SEARCH_ALL_MANUFACTURERS, 'manufacturer_id', 'name');
     $_manufacturers = JSFactory::getTable('manufacturer', 'jshop');
     $options = $_manufacturers->getList();
     array_unshift($options, $first);
     if (is_null($attribs)) {
         $attribs = self::getDataultAttribs('');
     }
     return JHTML::_('select.genericlist', $options, $name, $attribs, 'manufacturer_id', 'name', $selected);
 }
Exemplo n.º 16
0
 function view()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $session = JFactory::getSession();
     $params = $mainframe->getParams();
     $ajax = JRequest::getInt('ajax');
     $cart = JSFactory::getModel('cart', 'jshop');
     $cart->load("wishlist");
     $cart->addLinkToProducts(1, "wishlist");
     $cart->setDisplayFreeAttributes();
     $seo = JSFactory::getTable("seo", "jshop");
     $seodata = $seo->loadData("wishlist");
     if (getThisURLMainPageShop()) {
         $document = JFactory::getDocument();
         appendPathWay(_JSHOP_WISHLIST);
         if ($seodata->title == "") {
             $seodata->title = _JSHOP_WISHLIST;
         }
         setMetaData($seodata->title, $seodata->keyword, $seodata->description);
     } else {
         setMetaData($seodata->title, $seodata->keyword, $seodata->description, $params);
     }
     $shopurl = SEFLink('index.php?option=com_jshopping&controller=category', 1);
     if ($jshopConfig->cart_back_to_shop == "product") {
         $endpagebuyproduct = xhtmlUrl($session->get('jshop_end_page_buy_product'));
     } elseif ($jshopConfig->cart_back_to_shop == "list") {
         $endpagebuyproduct = xhtmlUrl($session->get('jshop_end_page_list_product'));
     }
     if (isset($endpagebuyproduct) && $endpagebuyproduct) {
         $shopurl = $endpagebuyproduct;
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeDisplayWishlist', array(&$cart));
     $view_name = "cart";
     $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name);
     $view = $this->getView('wishlist', getDocumentType(), '', $view_config);
     $view->setLayout("wishlist");
     $view->assign('config', $jshopConfig);
     $view->assign('products', $cart->products);
     $view->assign('image_product_path', $jshopConfig->image_product_live_path);
     $view->assign('image_path', $jshopConfig->live_path);
     $view->assign('no_image', $jshopConfig->noimage);
     $view->assign('href_shop', $shopurl);
     $view->assign('href_checkout', SEFLink('index.php?option=com_jshopping&controller=cart&task=view', 1));
     $dispatcher->trigger('onBeforeDisplayWishlistView', array(&$view));
     $view->display();
     if ($ajax) {
         die;
     }
 }
Exemplo n.º 17
0
 function addUserToTableShop($user)
 {
     $this->u_name = $user->username;
     $this->email = $user->email;
     $this->user_id = $user->id;
     $number = $this->getNewUserNumber();
     $usergroup = JSFactory::getTable('usergroup', 'jshop');
     $default_usergroup = $usergroup->getDefaultUsergroup();
     $query = "INSERT INTO `#__jshopping_users` SET `usergroup_id`='" . $default_usergroup . "', `u_name` = '" . $this->_db->escape($user->username) . "', `email` = '" . $this->_db->escape($user->email) . "', `user_id`='" . $this->_db->escape($user->id) . "', f_name='" . $this->_db->escape($user->name) . "', `number`='" . $this->_db->escape($number) . "'";
     $this->_db->setQuery($query);
     $this->_db->query();
     JDispatcher::getInstance()->trigger('onAfterAddUserToTableShop', array(&$this));
 }
Exemplo n.º 18
0
 public function paymentComplete($order_id, $text = '')
 {
     $order = JSFactory::getTable('order', 'jshop');
     $order->load($order_id);
     $pm_method = $order->getPayment();
     $paymentsysdata = $pm_method->getPaymentSystemData();
     $payment_system = $paymentsysdata->paymentSystem;
     if ($payment_system) {
         $pmconfigs = $pm_method->getConfigs();
         $payment_system->complete($pmconfigs, $order, $pm_method);
     }
     JDispatcher::getInstance()->trigger('onAfterDisplayCheckoutFinish', array(&$text, &$order, &$pm_method));
 }
Exemplo n.º 19
0
 function filedelete()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $ie_id = JRequest::getInt("ie_id");
     $_importexport = JSFactory::getTable('ImportExport', 'jshop');
     $_importexport->load($ie_id);
     $alias = $_importexport->get('alias');
     $file = JRequest::getVar("file");
     $filename = $jshopConfig->importexport_path . $alias . "/" . $file;
     @unlink($filename);
     $mainframe->redirect("index.php?option=com_jshopping&controller=importexport&task=view&ie_id=" . $ie_id);
 }
Exemplo n.º 20
0
 function getReturnPolicyForProducts($products)
 {
     $productOption = JSFactory::getTable('productOption', 'jshop');
     $listrp = $productOption->getProductOptionList($products, 'return_policy');
     $listrp = array_unique($listrp);
     $tmp = $this->loadData('return_policy');
     $defidrp = intval($tmp->id);
     foreach ($listrp as $k => $v) {
         if (!$v) {
             $listrp[$k] = $defidrp;
         }
     }
     return $this->loadDataByIds($listrp);
 }
Exemplo n.º 21
0
 public function getMessageMail()
 {
     $product = JSFactory::getTable('product', 'jshop');
     $product->load($this->getProductId());
     $review = $this->getReview();
     $view = $this->getView("product");
     $view->setLayout("commentemail");
     $view->assign('product_name', $product->getName());
     $view->assign('user_name', $review->user_name);
     $view->assign('user_email', $review->user_email);
     $view->assign('mark', $review->mark);
     $view->assign('review', $review->review);
     extract(js_add_trigger(get_defined_vars(), "before"));
     return $view->loadTemplate();
 }
Exemplo n.º 22
0
 public static function getCountrys($option_select = 1)
 {
     $app = JFactory::getApplication();
     $option = array();
     $country = JSFactory::getTable('country', 'jshop');
     if ($option_select) {
         $option[] = JHTML::_('select.option', '0', _JSHOP_REG_SELECT, 'country_id', 'name');
     }
     if ($app->getName() != 'site') {
         $list = $country->getAllCountries(0);
     } else {
         $list = $country->getAllCountries();
     }
     $option = array_merge($option, $list);
     return $option;
 }
 public function addItemsFromOtherSection(&$view)
 {
     //echo'<pre>';print_r($view);echo'</pre>';
     $mainframe = JFactory::getApplication();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $jshopConfig = JSFactory::getConfig();
     $session = JFactory::getSession();
     $session->set("jshop_end_page_buy_product", $_SERVER['REQUEST_URI']);
     $session->set("jshop_end_page_list_product", $_SERVER['REQUEST_URI']);
     $category_id = JRequest::getInt('category_id');
     if ($category_id == 1) {
         $cat_id = 2;
     } elseif ($category_id == 2) {
         $cat_id = 1;
     }
     $category = JSFactory::getTable('category', 'jshop');
     $category->load($cat_id);
     $category->getDescription();
     $jshopConfig->count_products_to_page = $category->products_page;
     $context = "jshoping.list.front.product";
     $contextfilter = "jshoping.list.front.product.cat." . $category_id;
     $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', $category->products_page, 'int');
     if (!$limit) {
         $limit = $category->products_page;
     }
     $limitstart = JRequest::getInt('limitstart');
     $orderbyq = getQuerySortDirection($order, $orderby);
     $image_sort_dir = getImgSortDirection($order, $orderby);
     $field_order = $jshopConfig->sorting_products_field_select[$order];
     $filters = getBuildFilterListProduct($contextfilter, array("categorys"));
     $orderfield = $jshopConfig->category_sorting == 1 ? "ordering" : "name";
     $sub_categories = $category->getChildCategories($orderfield, 'asc', $publish = 1);
     //echo'<pre>';print_r($category);echo'</pre>';die;
     $total = $category->getCountProducts($filters);
     //echo'<pre>';print_r($total);echo'</pre>';die;
     if ($limitstart >= $total) {
         $limitstart = 0;
     }
     $products = $category->getProducts($filters, $field_order, $orderbyq, $limitstart, $limit);
     addLinkToProducts($products, $category_id);
     //echo'<pre>';print_r($products);echo'</pre>';
     $view->assign('another_products', $products);
     $view->assign('another_category', $category);
 }
Exemplo n.º 24
0
 function view()
 {
     $ie_id = JRequest::getInt("ie_id");
     $_importexport = JSFactory::getTable('ImportExport', 'jshop');
     $_importexport->load($ie_id);
     $alias = $_importexport->get('alias');
     if (!file_exists(JPATH_COMPONENT_ADMINISTRATOR . "/importexport/" . $alias . "/" . $alias . ".php")) {
         JError::raiseWarning("", sprintf(_JSHOP_ERROR_FILE_NOT_EXIST, "/importexport/" . $alias . "/" . $alias . ".php"));
         return 0;
     }
     include_once JPATH_COMPONENT_ADMINISTRATOR . "/importexport/" . $alias . "/" . $alias . ".php";
     $classname = 'Ie' . $alias;
     $controller = new $classname($ie_id);
     $controller->set('ie_id', $ie_id);
     $controller->set('alias', $alias);
     $controller->execute(JRequest::getVar('task'));
 }
Exemplo n.º 25
0
 function load()
 {
     $jshopConfig = JSFactory::getConfig();
     $session = JFactory::getSession();
     $objuser = $session->get('user_shop_guest');
     if (isset($objuser) && $objuser != '') {
         $tmp = unserialize($objuser);
         foreach ($tmp as $k => $v) {
             $this->{$k} = $v;
         }
     }
     $this->user_id = -1;
     $usergroup = JSFactory::getTable('usergroup', 'jshop');
     $this->usergroup_id = intval($jshopConfig->default_usergroup_id_guest);
     JDispatcher::getInstance()->trigger('onLoadJshopUserGust', array(&$this));
     return true;
 }
Exemplo n.º 26
0
 function save()
 {
     $addon = JSFactory::getTable('addon', 'jshop');
     $post = JRequest::get("post");
     if (!$addon->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping");
         return 0;
     }
     if (!$addon->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping");
         return 0;
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onAfterSaveLicenseKeyAddons', array(&$addon));
     $this->setRedirect(base64_decode($post['back']));
 }
Exemplo n.º 27
0
 function showEndForm($pmconfigs, $order)
 {
     $jshopConfig = JSFactory::getConfig();
     $pm_method = $this->getPmMethod();
     $item_name = sprintf(_JSHOP_PAYMENT_NUMBER, $order->order_number);
     $sandbox = $pmconfigs['testmode'] ? 'sandbox.' : '';
     $email = $pmconfigs['email_received'];
     $token = $pmconfigs[$sandbox ? 'test_token' : 'token'];
     $address_override = (int) $pmconfigs['address_override'];
     $_country = JSFactory::getTable('country', 'jshop');
     $_country->load($order->d_country);
     $country = $_country->country_code_2;
     $order->order_total = $this->fixOrderTotal($order);
     // Return links
     $uri = JURI::getInstance();
     $liveurlhost = $uri->toString(array('scheme', 'host', 'port'));
     if ($pmconfigs['notifyurlsef']) {
         $notify_url = $liveurlhost . SEFLink("index.php?option=com_jshopping&controller=checkout&task=step7&act=notify&js_paymentclass=" . $pm_method->payment_class . "&no_lang=1");
     } else {
         $notify_url = JURI::root() . "index.php?option=com_jshopping&controller=checkout&task=step7&act=notify&js_paymentclass=" . $pm_method->payment_class . "&no_lang=1";
     }
     $return = $liveurlhost . SEFLink("index.php?option=com_jshopping&controller=checkout&task=step7&act=return&js_paymentclass=" . $pm_method->payment_class);
     $cancel_return = $liveurlhost . SEFLink("index.php?option=com_jshopping&controller=checkout&task=step7&act=cancel&js_paymentclass=" . $pm_method->payment_class);
     // Build data for the request
     $vendor = JSFactory::getTable('vendor', 'jshop');
     $vendor->loadMain();
     $data = array('email' => $email, 'token' => $token, 'senderName' => $vendor->shop_name, 'senderAreaCode' => 11, 'senderEmail' => $order->email, 'currency' => $order->currency_code_iso, 'redirectURL' => $return, 'reference' => $order->order_id, 'itemId1' => $order->order_id, 'itemDescription1' => $item_name, 'itemAmount1' => number_format($order->order_subtotal, 2, '.', ''), 'itemQuantity1' => 1, 'shippingCost' => number_format($order->order_shipping, 2, '.', ''), 'shippingType' => 3, 'shippingAddressStreet' => $order->d_street, 'shippingAddressPostalCode' => $order->d_zip, 'shippingAddressCity' => $order->d_city, 'shippingAddressState' => $order->d_state, 'shippingAddressCountry' => 'BRA');
     // Post the order data to PagSeguro
     $options = array(CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_URL => "https://ws.{$sandbox}pagseguro.uol.com.br/v2/checkout/", CURLOPT_FRESH_CONNECT => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FORBID_REUSE => 1, CURLOPT_TIMEOUT => 4, CURLOPT_POSTFIELDS => http_build_query($data));
     $ch = curl_init();
     curl_setopt_array($ch, $options);
     if (!($result = curl_exec($ch))) {
         die('Error: ' . curl_error($ch));
     }
     curl_close($ch);
     // If we received a code (and it's not an error number), redirect the client to PagSeguro to complete the order
     $code = preg_match('|<code>(.+?)</code>|', $result, $m) ? $m[1] : false;
     if ($code && !is_numeric($code)) {
         header("Location: https://{$sandbox}pagseguro.uol.com.br/v2/checkout/payment.html?code={$code}");
     } else {
         die("Error: {$result}");
     }
 }
Exemplo n.º 28
0
 /**
  * обновление цен в корзине (в модели корзины)
  * @param mixed $cart_class
  */
 public function onAfterUpdateCartProductPrice(&$cart_class)
 {
     $jshopConfig = JSFactory::getConfig();
     foreach ($cart_class->products as $key => $value) {
         $product = JSFactory::getTable('product', 'jshop');
         $product->load($cart_class->products[$key]['product_id']);
         if (isset($value['product_price_wubook_av']) && $value['product_price_wubook_av'] > 0) {
             $product->product_price = $value['product_price_wubook_av'];
         }
         $attr_id = unserialize($value['attributes']);
         $freeattributes = unserialize($value['freeattributes']);
         $product->setAttributeActive($attr_id);
         $product->setFreeAttributeActive($freeattributes);
         $cart_class->products[$key]['price'] = $product->getPrice($cart_class->products[$key]['quantity'], 1, 1, 1, $cart_class->products[$key]);
         if ($jshopConfig->cart_basic_price_show) {
             $cart_class->products[$key]['basicprice'] = $product->getBasicPrice();
         }
     }
 }
Exemplo n.º 29
0
 public function prepateData(&$post)
 {
     $jshopConfig = JSFactory::getConfig();
     $usergroup = JSFactory::getTable('usergroup', 'jshop');
     $dispatcher = JDispatcher::getInstance();
     $this->default_usergroup = $usergroup->getDefaultUsergroup();
     $post['username'] = $post['u_name'];
     if ($post['password_2'] != '') {
         $post['password2'] = $post['password_2'];
     }
     if ($post['f_name'] == "") {
         $post['f_name'] = $post['email'];
     }
     $post['name'] = $post['f_name'] . ' ' . $post['l_name'];
     if ($post['birthday']) {
         $post['birthday'] = getJsDateDB($post['birthday'], $jshopConfig->field_birthday_format);
     }
     $post['lang'] = $jshopConfig->getLang();
     $dispatcher->trigger('onBeforeRegister', array(&$post, &$this->default_usergroup, &$this->userparams));
 }
Exemplo n.º 30
0
 public function load($page, $order_id = 0, $cartp = 0)
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     $statictext = JSFactory::getTable("statictext", "jshop");
     if ($jshopConfig->return_policy_for_product && $page == 'return_policy' && ($cartp || $order_id)) {
         if ($cartp) {
             $cart = JSFactory::getModel('cart', 'jshop');
             $cart->load();
             $list = $cart->getReturnPolicy();
         } else {
             $order = JSFactory::getTable('order', 'jshop');
             $order->load($order_id);
             $list = $order->getReturnPolicy();
         }
         $listtext = array();
         foreach ($list as $v) {
             $listtext[] = $v->text;
         }
         $row = new stdClass();
         $row->id = -1;
         $row->text = implode('<div class="return_policy_space"></div>', $listtext);
     } else {
         $row = $statictext->loadData($page);
     }
     if (!$row->id) {
         $this->setError(_JSHOP_PAGE_NOT_FOUND);
         return false;
     }
     if ($jshopConfig->use_plugin_content) {
         $obj = new stdClass();
         $params = JFactory::getApplication()->getParams('com_content');
         $obj->text = $row->text;
         $obj->title = $this->seodata->title;
         $dispatcher->trigger('onContentPrepare', array('com_content.article', &$obj, &$params, 0));
         $row->text = $obj->text;
     }
     $text = $row->text;
     $dispatcher->trigger('onBeforeDisplayContent', array($page, &$text));
     return $text;
 }