Esempio n. 1
0
 public function setData($data, $load_data_config = 1)
 {
     $jshopConfig = JSFactory::getConfig();
     $this->data = $data;
     $review = $this->review;
     $review->bind($data);
     if ($load_data_config) {
         $review->user_id = JFactory::getUser()->id;
         $review->time = getJsDate();
         $review->ip = $_SERVER['REMOTE_ADDR'];
         if ($jshopConfig->display_reviews_without_confirm) {
             $review->publish = 1;
         }
     }
 }
Esempio n. 2
0
 function getEnableCode($code)
 {
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     if (!$jshopConfig->use_rabatt_code) {
         $this->error = _JSHOP_RABATT_NON_SUPPORT;
         return 0;
     }
     $date = getJsDate('now', 'Y-m-d');
     $query = "SELECT * FROM `#__jshopping_coupons` WHERE coupon_code = '" . $db->escape($code) . "' AND coupon_publish = '1'";
     extract(js_add_trigger(get_defined_vars(), "query"));
     $db->setQuery($query);
     $row = $db->loadObject();
     if (!isset($row->coupon_id)) {
         $this->error = _JSHOP_RABATT_NON_CORRECT;
         return 0;
     }
     if ($row->coupon_expire_date < $date && $row->coupon_expire_date != "0000-00-00") {
         $this->error = _JSHOP_RABATT_NON_CORRECT;
         return 0;
     }
     if ($row->coupon_start_date > $date) {
         $this->error = _JSHOP_RABATT_NON_CORRECT;
         return 0;
     }
     if ($row->used) {
         $this->error = _JSHOP_RABATT_USED;
         return 0;
     }
     if ($row->for_user_id) {
         $user = JFactory::getUser();
         if (!$user->id) {
             $this->error = _JSHOP_FOR_USE_COUPON_PLEASE_LOGIN;
             return 0;
         }
         if ($row->for_user_id != $user->id) {
             $this->error = _JSHOP_RABATT_NON_CORRECT;
             return 0;
         }
     }
     $this->load($row->coupon_id);
     return 1;
 }
Esempio n. 3
0
function getCalculateDeliveryDay($day, $date = null)
{
    if (!$date) {
        $date = getJsDate();
    }
    $time = intval(strtotime($date) + $day * 86400);
    return date('Y-m-d H:i:s', $time);
}
Esempio n. 4
0
 function copy()
 {
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $text = array();
     $cid = JRequest::getVar('cid');
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeCopyProduct', array(&$cid));
     $_lang = $this->getModel("languages");
     $languages = $_lang->getAllLanguages(1);
     $_products = $this->getModel("products");
     // Get all data about products
     $tables = array('attr', 'attr2', 'images', 'prices', 'relations', 'to_categories', 'videos', 'files');
     foreach ($cid as $key => $value) {
         $product = JTable::getInstance('product', 'jshop');
         $product->load($value);
         $product->product_id = null;
         foreach ($languages as $lang) {
             $name_alias = 'alias_' . $lang->language;
             if ($product->{$name_alias}) {
                 $product->{$name_alias} = $product->{$name_alias} . date('ymdHis');
             }
         }
         $product->product_date_added = getJsDate();
         $product->date_modify = "";
         $product->average_rating = 0;
         $product->reviews_count = 0;
         $product->hits = 0;
         $product->store();
         $array = array();
         foreach ($tables as $table) {
             $query = "SELECT * FROM `#__jshopping_products_" . $table . "` AS prod_table WHERE prod_table.product_id = '" . $db->escape($value) . "'";
             $db->setQuery($query);
             $array[] = $db->loadAssocList();
         }
         $i = 0;
         foreach ($array as $key2 => $value2) {
             if (count($value2)) {
                 foreach ($value2 as $key3 => $value3) {
                     $db->setQuery($_products->copyProductBuildQuery($tables[$i], $value3, $product->product_id));
                     $db->query();
                 }
             }
             $i++;
         }
         //change order in category
         $query = "select * from #__jshopping_products_to_categories where product_id='" . $product->product_id . "'";
         $db->setQuery($query);
         $list = $db->loadObjectList();
         foreach ($list as $val) {
             $query = "select max(product_ordering) as k from #__jshopping_products_to_categories where category_id='" . $val->category_id . "' ";
             $db->setQuery($query);
             $ordering = $db->loadResult() + 1;
             $query = "update #__jshopping_products_to_categories set product_ordering='" . $ordering . "' where category_id='" . $val->category_id . "' and product_id='" . $product->product_id . "' ";
             $db->setQuery($query);
             $db->query();
         }
         $query = "update #__jshopping_products_attr set ext_attribute_product_id=0 where product_id='" . $product->product_id . "'";
         $db->setQuery($query);
         $list = $db->loadObjectList();
         $text[] = sprintf(_JSHOP_PRODUCT_COPY_TO, $value, $product->product_id) . "<br>";
     }
     $dispatcher->trigger('onAfterCopyProduct', array(&$cid));
     $this->setRedirect("index.php?option=com_jshopping&controller=products", implode("</li><li>", $text));
 }
Esempio n. 5
0
 function changeStatusOrder($order_id, $status, $sendmessage = 1)
 {
     $mainframe = JFactory::getApplication();
     $lang = JSFactory::getLang();
     $jshopConfig = JSFactory::getConfig();
     $restext = '';
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeChangeOrderStatus', array(&$order_id, &$status, &$sendmessage, &$restext));
     $order = JSFactory::getTable('order', 'jshop');
     $order->load($order_id);
     $order->order_status = $status;
     $order->order_m_date = getJsDate();
     $order->store();
     $vendorinfo = $order->getVendorInfo();
     $order_status = JSFactory::getTable('orderStatus', 'jshop');
     $order_status->load($status);
     if ($jshopConfig->order_stock_removed_only_paid_status) {
         $product_stock_removed = in_array($status, $jshopConfig->payment_status_enable_download_sale_file);
     } else {
         $product_stock_removed = !in_array($status, $jshopConfig->payment_status_return_product_in_stock);
     }
     if ($order->order_created && !$product_stock_removed && $order->product_stock_removed == 1) {
         $order->changeProductQTYinStock("+");
     }
     if ($order->order_created && $product_stock_removed && $order->product_stock_removed == 0) {
         $order->changeProductQTYinStock("-");
     }
     $order_history = JSFactory::getTable('orderHistory', 'jshop');
     $order_history->order_id = $order->order_id;
     $order_history->order_status_id = $status;
     $order_history->status_date_added = getJsDate();
     $order_history->customer_notify = 1;
     $order_history->comments = $restext;
     $order_history->store();
     $name = $lang->get("name");
     $uri = JURI::getInstance();
     $liveurlhost = $uri->toString(array("scheme", 'host', 'port'));
     $order_details_url = $liveurlhost . SEFLink('index.php?option=com_jshopping&controller=user&task=order&order_id=' . $order_id, 1);
     if ($order->user_id == -1) {
         $order_details_url = '';
     }
     $message = $this->getMessageChangeStatusOrder($order, $order_status->{$name}, $vendorinfo, $order_details_url);
     if ($jshopConfig->admin_show_vendors) {
         $listVendors = $order->getVendors();
     } else {
         $listVendors = array();
     }
     $vendors_send_message = $jshopConfig->vendor_order_message_type == 1 || $order->vendor_type == 1 && $jshopConfig->vendor_order_message_type == 2;
     $vendor_send_order = $jshopConfig->vendor_order_message_type == 2 && $order->vendor_type == 0 && $order->vendor_id;
     if ($jshopConfig->vendor_order_message_type == 3) {
         $vendor_send_order = 1;
     }
     $admin_send_order = 1;
     if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order && count($listVendors)) {
         $admin_send_order = 0;
     }
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     if ($sendmessage) {
         //message client
         $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number);
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->addRecipient($order->email);
         $mailer->setSubject($subject);
         $mailer->setBody($message);
         $mailer->isHTML(false);
         $dispatcher->trigger('onBeforeSendMailChangeOrderStatusClient', array(&$mailer, &$order_id, &$status, &$sendmessage, &$order));
         $send = $mailer->Send();
         //message admin
         if ($admin_send_order) {
             $mailer = JFactory::getMailer();
             $mailer->setSender(array($mailfrom, $fromname));
             $mailer->addRecipient(explode(',', $jshopConfig->contact_email));
             $mailer->setSubject(_JSHOP_ORDER_STATUS_CHANGE_TITLE);
             $mailer->setBody($message);
             $mailer->isHTML(false);
             $dispatcher->trigger('onBeforeSendMailChangeOrderStatusAdmin', array(&$mailer, &$order_id, &$status, &$sendmessage, &$order));
             $send = $mailer->Send();
         }
         //message vendors
         if ($vendors_send_message || $vendor_send_order) {
             foreach ($listVendors as $k => $datavendor) {
                 $mailer = JFactory::getMailer();
                 $mailer->setSender(array($mailfrom, $fromname));
                 $mailer->addRecipient($datavendor->email);
                 $mailer->setSubject(_JSHOP_ORDER_STATUS_CHANGE_TITLE);
                 $mailer->setBody($message);
                 $mailer->isHTML(false);
                 $dispatcher->trigger('onBeforeSendMailChangeOrderStatusVendor', array(&$mailer, &$order_id, &$status, &$sendmessage, &$order));
                 $send = $mailer->Send();
             }
         }
     }
     $dispatcher->trigger('onAfterChangeOrderStatus', array(&$order_id, &$status, &$sendmessage));
     return 1;
 }
Esempio n. 6
0
 function reviewsave()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $post = JRequest::get('post');
     $backlink = JRequest::getVar('back_link');
     $product_id = JRequest::getInt('product_id');
     JRequest::checkToken() or jexit('Invalid Token');
     JPluginHelper::importPlugin('jshoppingproducts');
     $dispatcher = JDispatcher::getInstance();
     $review = JTable::getInstance('review', 'jshop');
     if ($review->getAllowReview() <= 0) {
         JError::raiseWarning('', jshopReview::getText());
         $this->setRedirect($backlink);
         return 0;
     }
     $review->bind($post);
     $review->time = getJsDate();
     $review->user_id = $user->id;
     $review->ip = $_SERVER['REMOTE_ADDR'];
     if ($jshopConfig->display_reviews_without_confirm) {
         $review->publish = 1;
     }
     $dispatcher->trigger('onBeforeSaveReview', array(&$review));
     if (!$review->check()) {
         JError::raiseWarning('', _JSHOP_ENTER_CORRECT_INFO_REVIEW);
         $this->setRedirect($backlink);
         return 0;
     }
     $review->store();
     $dispatcher->trigger('onAfterSaveReview', array(&$review));
     $product = JTable::getInstance('product', 'jshop');
     $product->load($product_id);
     $product->loadAverageRating();
     $product->loadReviewsCount();
     $product->store();
     $lang = JSFactory::getLang();
     $name = $lang->get("name");
     $view_name = "product";
     $view_config = array("template_path" => JPATH_COMPONENT . "/templates/" . $jshopConfig->template . "/" . $view_name);
     $view = $this->getView($view_name, 'html', '', $view_config);
     $view->setLayout("commentemail");
     $view->assign('product_name', $product->{$name});
     $view->assign('user_name', $review->user_name);
     $view->assign('user_email', $review->user_email);
     $view->assign('mark', $review->mark);
     $view->assign('review', $review->review);
     $message = $view->loadTemplate();
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     $mailer = JFactory::getMailer();
     $mailer->setSender(array($mailfrom, $fromname));
     $mailer->addRecipient(explode(',', $jshopConfig->contact_email));
     $mailer->setSubject(_JSHOP_NEW_COMMENT);
     $mailer->setBody($message);
     $mailer->isHTML(true);
     $send = $mailer->Send();
     if ($jshopConfig->display_reviews_without_confirm) {
         $this->setRedirect($backlink, _JSHOP_YOUR_REVIEW_SAVE_DISPLAY);
     } else {
         $this->setRedirect($backlink, _JSHOP_YOUR_REVIEW_SAVE);
     }
 }
Esempio n. 7
0
 public function createOrder(&$adv_user, &$post)
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     $cart = $this->getCart();
     $orderNumber = $jshopConfig->getNextOrderNumber();
     $jshopConfig->updateNextOrderNumber();
     $pm_method = $this->getPaymentMethod();
     if ($jshopConfig->without_payment) {
         $pm_method->payment_type = 1;
         $paymentSystemVerySimple = 1;
     } else {
         $paymentsysdata = $pm_method->getPaymentSystemData();
         $payment_system = $paymentsysdata->paymentSystem;
         if ($paymentsysdata->paymentSystemVerySimple) {
             $paymentSystemVerySimple = 1;
         }
     }
     $order = JSFactory::getTable('order', 'jshop');
     $arr_property = $order->getListFieldCopyUserToOrder();
     foreach ($adv_user as $key => $value) {
         if (in_array($key, $arr_property)) {
             $order->{$key} = $value;
         }
     }
     $sh_mt_pr = $this->getShippingMethodPrice();
     $order->order_date = $order->order_m_date = getJsDate();
     $order->order_tax = $cart->getTax(1, 1, 1);
     $order->setTaxExt($cart->getTaxExt(1, 1, 1));
     $order->order_subtotal = $cart->getPriceProducts();
     $order->order_shipping = $cart->getShippingPrice();
     $order->order_payment = $cart->getPaymentPrice();
     $order->order_discount = $cart->getDiscountShow();
     $order->shipping_tax = $cart->getShippingPriceTaxPercent();
     $order->setShippingTaxExt($cart->getShippingTaxList());
     $order->payment_tax = $cart->getPaymentTaxPercent();
     $order->setPaymentTaxExt($cart->getPaymentTaxList());
     $order->order_package = $cart->getPackagePrice();
     $order->setPackageTaxExt($cart->getPackageTaxList());
     $order->order_total = $cart->getSum(1, 1, 1);
     $order->currency_exchange = $jshopConfig->currency_value;
     $order->vendor_type = $cart->getVendorType();
     $order->vendor_id = $cart->getVendorId();
     $order->order_status = $jshopConfig->default_status_order;
     $order->shipping_method_id = $cart->getShippingId();
     $order->payment_method_id = $cart->getPaymentId();
     $order->delivery_times_id = $sh_mt_pr->delivery_times_id;
     if ($jshopConfig->delivery_order_depends_delivery_product) {
         $order->delivery_time = $cart->getDelivery();
     }
     if ($jshopConfig->show_delivery_date) {
         $order->delivery_date = $cart->getDeliveryDate();
     }
     $order->coupon_id = $cart->getCouponId();
     $pm_params = $cart->getPaymentParams();
     if (is_array($pm_params) && !$paymentSystemVerySimple) {
         $payment_system->setParams($pm_params);
         $payment_params_names = $payment_system->getDisplayNameParams();
         $order->payment_params = getTextNameArrayValue($payment_params_names, $pm_params);
         $order->setPaymentParamsData($pm_params);
     }
     $sh_params = $cart->getShippingParams();
     if (is_array($sh_params)) {
         $sh_method = $this->getShippingMethod();
         $shippingForm = $sh_method->getShippingForm();
         if ($shippingForm) {
             $shippingForm->setParams($sh_params);
             $shipping_params_names = $shippingForm->getDisplayNameParams();
             $order->shipping_params = getTextNameArrayValue($shipping_params_names, $sh_params);
         }
         $order->setShippingParamsData($sh_params);
     }
     $order->ip_address = $_SERVER['REMOTE_ADDR'];
     $order->order_add_info = $post['order_add_info'];
     $order->currency_code = $jshopConfig->currency_code;
     $order->currency_code_iso = $jshopConfig->currency_code_iso;
     $order->order_number = $order->formatOrderNumber($orderNumber);
     $order->order_hash = md5(time() . $order->order_total . $order->user_id);
     $order->file_hash = md5(time() . $order->order_total . $order->user_id . "hashfile");
     $order->display_price = $jshopConfig->display_price_front_current;
     $order->lang = $jshopConfig->getLang();
     if ($order->client_type) {
         $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type];
     } else {
         $order->client_type_name = "";
     }
     if ($order->order_total == 0) {
         $pm_method->payment_type = 1;
         $order->order_status = $jshopConfig->payment_status_paid;
     }
     if ($pm_method->payment_type == 1) {
         $order->order_created = 1;
     } else {
         $order->order_created = 0;
     }
     if (!$adv_user->delivery_adress) {
         $order->copyDeliveryData();
     }
     $dispatcher->trigger('onBeforeCreateOrder', array(&$order, &$cart, &$this));
     $order->store();
     return $order;
 }
Esempio n. 8
0
 function setInvoiceDate()
 {
     if (datenull($this->invoice_date)) {
         $db = JFactory::getDBO();
         $this->invoice_date = getJsDate();
         $query = "UPDATE `#__jshopping_orders` SET invoice_date='" . $db->escape($this->invoice_date) . "' WHERE order_id = '" . $db->escape($this->order_id) . "'";
         $db->setQuery($query);
         $db->query();
     }
 }
Esempio n. 9
0
 function changeStatusOrder($order_id, $status, $sendmessage = 1)
 {
     $mainframe = JFactory::getApplication();
     $lang = JSFactory::getLang();
     $jshopConfig = JSFactory::getConfig();
     $restext = '';
     JPluginHelper::importPlugin('jshoppingorder');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeChangeOrderStatus', array(&$order_id, &$status, &$sendmessage, &$restext));
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     $order->order_status = $status;
     $order->store();
     $vendorinfo = $order->getVendorInfo();
     $order_status = JTable::getInstance('orderStatus', 'jshop');
     $order_status->load($status);
     if ($order->order_created && in_array($status, $jshopConfig->payment_status_return_product_in_stock)) {
         $order->changeProductQTYinStock("+");
     }
     $order_history = JTable::getInstance('orderHistory', 'jshop');
     $order_history->order_id = $order->order_id;
     $order_history->order_status_id = $status;
     $order_history->status_date_added = getJsDate();
     $order_history->customer_notify = 1;
     $order_history->comments = $restext;
     $order_history->store();
     if (!$sendmessage) {
         return 1;
     }
     $name = $lang->get("name");
     $uri = JURI::getInstance();
     $liveurlhost = $uri->toString(array("scheme", 'host', 'port'));
     $order_details_url = $liveurlhost . SEFLink('index.php?option=com_jshopping&controller=user&task=order&order_id=' . $order_id, 1);
     if ($order->user_id == -1) {
         $order_details_url = '';
     }
     include_once JPATH_COMPONENT_SITE . "/views/checkout/view.html.php";
     $view_name = "order";
     $view_config = array("template_path" => JPATH_COMPONENT_SITE . "/templates/" . $jshopConfig->template . "/" . $view_name);
     $view = new JshoppingViewCheckout($view_config);
     $view->setLayout("statusorder");
     $view->assign('order', $order);
     $view->assign('order_status', $order_status->{$name});
     $view->assign('vendorinfo', $vendorinfo);
     $view->assign('order_detail', $order_details_url);
     $dispatcher->trigger('onBeforeCreateMailOrderStatusView', array(&$view));
     $message = $view->loadTemplate();
     if ($jshopConfig->admin_show_vendors) {
         $listVendors = $order->getVendors();
     } else {
         $listVendors = array();
     }
     $vendors_send_message = $jshopConfig->vendor_order_message_type == 1 || $order->vendor_type == 1 && $jshopConfig->vendor_order_message_type == 2;
     $vendor_send_order = $jshopConfig->vendor_order_message_type == 2 && $order->vendor_type == 0 && $order->vendor_id;
     if ($jshopConfig->vendor_order_message_type == 3) {
         $vendor_send_order = 1;
     }
     $admin_send_order = 1;
     if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order && count($listVendors)) {
         $admin_send_order = 0;
     }
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     //message client
     $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number);
     $mailer = JFactory::getMailer();
     $mailer->setSender(array($mailfrom, $fromname));
     $mailer->addRecipient($order->email);
     $mailer->setSubject($subject);
     $mailer->setBody($message);
     $mailer->isHTML(false);
     $send = $mailer->Send();
     //message admin
     if ($admin_send_order) {
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->addRecipient(explode(',', $jshopConfig->contact_email));
         $mailer->setSubject(_JSHOP_ORDER_STATUS_CHANGE_TITLE);
         $mailer->setBody($message);
         $mailer->isHTML(false);
         $send = $mailer->Send();
     }
     //message vendors
     if ($vendors_send_message || $vendor_send_order) {
         foreach ($listVendors as $k => $datavendor) {
             $mailer = JFactory::getMailer();
             $mailer->setSender(array($mailfrom, $fromname));
             $mailer->addRecipient($datavendor->email);
             $mailer->setSubject(_JSHOP_ORDER_STATUS_CHANGE_TITLE);
             $mailer->setBody($message);
             $mailer->isHTML(false);
             $send = $mailer->Send();
         }
     }
     $dispatcher->trigger('onAfterChangeOrderStatus', array(&$order_id, &$status, &$sendmessage));
     return 1;
 }
Esempio n. 10
0
 function save()
 {
     $db = JFactory::getDBO();
     $jshopConfig = JSFactory::getConfig();
     $post = JRequest::get('post');
     $client_id = JRequest::getInt('client_id', 0);
     $file_generete_pdf_order = $jshopConfig->file_generete_pdf_order;
     $dispatcher = JDispatcher::getInstance();
     $order_id = intval($post['order_id']);
     $orders = JSFactory::getModel("orders");
     $order = JSFactory::getTable('order', 'jshop');
     $order->load($order_id);
     if (!$order_id) {
         $order->user_id = -1;
         $order->order_date = getJsDate();
         $orderNumber = $jshopConfig->next_order_number;
         $jshopConfig->updateNextOrderNumber();
         $order->order_number = $order->formatOrderNumber($orderNumber);
         $order->order_hash = md5(time() . $order->order_total . $order->user_id);
         $order->file_hash = md5(time() . $order->order_total . $order->user_id . "hashfile");
         $order->ip_address = $_SERVER['REMOTE_ADDR'];
         $order->order_status = $jshopConfig->default_status_order;
     }
     $order->order_m_date = getJsDate();
     $order_created_prev = $order->order_created;
     if ($post['birthday']) {
         $post['birthday'] = getJsDateDB($post['birthday'], $jshopConfig->field_birthday_format);
     }
     if ($post['d_birthday']) {
         $post['d_birthday'] = getJsDateDB($post['d_birthday'], $jshopConfig->field_birthday_format);
     }
     if ($post['invoice_date']) {
         $post['invoice_date'] = getJsDateDB($post['invoice_date'], $jshopConfig->store_date_format);
     }
     if (!$jshopConfig->hide_tax) {
         $post['order_tax'] = 0;
         $order_tax_ext = array();
         if (isset($post['tax_percent'])) {
             foreach ($post['tax_percent'] as $k => $v) {
                 if ($post['tax_percent'][$k] != "" || $post['tax_value'][$k] != "") {
                     $order_tax_ext[number_format($post['tax_percent'][$k], 2)] = $post['tax_value'][$k];
                 }
             }
         }
         $post['order_tax_ext'] = serialize($order_tax_ext);
         $post['order_tax'] = number_format(array_sum($order_tax_ext), 2);
     }
     $currency = JSFactory::getTable('currency', 'jshop');
     $currency->load($post['currency_id']);
     $post['currency_code'] = $currency->currency_code;
     $post['currency_code_iso'] = $currency->currency_code_iso;
     $post['currency_exchange'] = $currency->currency_value;
     $dispatcher->trigger('onBeforeSaveOrder', array(&$post, &$file_generete_pdf_order, &$order));
     $order->bind($post);
     $order->delivery_times_id = $post['order_delivery_times_id'];
     $order->store();
     $order_id = $order->order_id;
     $order_items = $order->getAllItems();
     $orders->saveOrderItem($order_id, $post, $order_items);
     $order->items = null;
     $vendor_id = $order->getVendorIdForItems();
     $order->vendor_id = $vendor_id;
     $order->store();
     JSFactory::loadLanguageFile($order->getLang());
     $lang = JSFactory::getLang($order->getLang());
     $order->items = null;
     if ($order->order_created == 1 && $order_created_prev == 0) {
         $order->updateProductsInStock(1);
         $checkout = JSFactory::getModel('checkout', 'jshop');
         if ($jshopConfig->send_order_email) {
             $checkout->sendOrderEmail($order_id, 1);
         }
     } elseif ($order->order_created == 1 && $jshopConfig->generate_pdf) {
         $order->load($order_id);
         $order->prepareOrderPrint();
         $order->generatePdf($file_generete_pdf_order);
     }
     JSFactory::loadAdminLanguageFile();
     $dispatcher->trigger('onAfterSaveOrder', array(&$order, &$file_generete_pdf_order));
     $this->setRedirect("index.php?option=com_jshopping&controller=orders&client_id=" . $client_id);
 }
Esempio n. 11
0
 function saveOrderHistory($notify, $comments)
 {
     $history = JSFactory::getTable('orderHistory', 'jshop');
     $history->order_id = $this->order_id;
     $history->order_status_id = $this->order_status;
     $history->status_date_added = getJsDate();
     $history->customer_notify = $notify;
     $history->comments = $comments;
     JDispatcher::getInstance()->trigger('onBeforeJshopOrderSaveOrderHistory', array(&$history, &$notify, &$comments, &$this));
     return $history->store();
 }
Esempio n. 12
0
 public function storeStatDownloads()
 {
     $stat_download = $this->stat_download;
     $id = $this->id;
     $stat_download[$id]['download'] = intval($stat_download[$id]['download']) + 1;
     $stat_download[$id]['time'] = getJsDate();
     $this->order->setFilesStatDownloads($stat_download);
     $this->order->store();
 }
Esempio n. 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();
 }
 private function orderStatusStore()
 {
     $this->order->load($this->order_id);
     $prev_status = $this->order->order_status;
     $this->order->order_status = $this->status;
     $this->order->order_m_date = getJsDate();
     $this->order->store();
     return $prev_status;
 }
Esempio n. 15
0
 function saveTransactionData($rescode, $status_id, $data)
 {
     $row = JSFactory::getTable("PaymentTrx", "jshop");
     $row->order_id = $this->order_id;
     $row->rescode = $rescode;
     $row->status_id = $status_id;
     $row->transaction = $this->transaction;
     $row->date = getJsDate();
     $row->store();
     if (is_array($data)) {
         foreach ($data as $k => $v) {
             $rowdata = JSFactory::getTable("PaymentTrxData", "jshop");
             $rowdata->id = 0;
             $rowdata->trx_id = $row->id;
             $rowdata->order_id = $this->order_id;
             $rowdata->key = $k;
             $rowdata->value = $v;
             $rowdata->store();
         }
     }
 }
Esempio n. 16
0
 function save()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     require_once $jshopConfig->path . 'lib/image.lib.php';
     require_once $jshopConfig->path . 'lib/uploadfile.class.php';
     $dispatcher = JDispatcher::getInstance();
     $_alias = JSFactory::getModel("alias");
     $db = JFactory::getDBO();
     $_categories = JSFactory::getModel("categories");
     $category = JSFactory::getTable("category", "jshop");
     if (!$_POST["category_id"]) {
         $_POST['category_add_date'] = getJsDate();
     }
     if (!isset($_POST['category_publish'])) {
         $_POST['category_publish'] = 0;
     }
     $post = JRequest::get('post');
     $_lang = JSFactory::getModel("languages");
     $languages = $_lang->getAllLanguages(1);
     if ($post['category_parent_id'] == $post['category_id']) {
         $post['category_parent_id'] = 0;
     }
     $dispatcher->trigger('onBeforeSaveCategory', array(&$post));
     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->checkExistAlias1Group($post['alias_' . $lang->language], $lang->language, $post['category_id'], 0)) {
             $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);
     }
     if (!$category->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=categories");
         return 0;
     }
     $edit = $category->category_id;
     $upload_image = $_categories->uploadImage($post);
     if ($upload_image != '') {
         $category->category_image = $upload_image;
     }
     $this->_reorderCategory($category);
     if (!$category->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=categories");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveCategory', array(&$category));
     $success = $edit ? _JSHOP_CATEGORY_SUCC_UPDATE : _JSHOP_CATEGORY_SUCC_ADDED;
     if ($this->getTask() == 'apply') {
         $this->setRedirect('index.php?option=com_jshopping&controller=categories&task=edit&category_id=' . $category->category_id, $success);
     } else {
         $this->setRedirect('index.php?option=com_jshopping&controller=categories', $success);
     }
 }
Esempio n. 17
0
 function save()
 {
     $db = JFactory::getDBO();
     $jshopConfig = JSFactory::getConfig();
     $post = JRequest::get('post');
     $client_id = JRequest::getInt('client_id', 0);
     $file_generete_pdf_order = $jshopConfig->file_generete_pdf_order;
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $order_id = intval($post['order_id']);
     $orders = $this->getModel("orders");
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     if (!$order_id) {
         $order->user_id = -1;
         $order->order_date = getJsDate();
         $orderNumber = $jshopConfig->next_order_number;
         $jshopConfig->updateNextOrderNumber();
         $order->order_number = $order->formatOrderNumber($orderNumber);
         $order->order_hash = md5(time() . $order->order_total . $order->user_id);
         $order->file_hash = md5(time() . $order->order_total . $order->user_id . "hashfile");
         $order->ip_address = $_SERVER['REMOTE_ADDR'];
         $order->order_status = $jshopConfig->default_status_order;
     }
     $order->order_m_date = getJsDate();
     $order_created_prev = $order->order_created;
     if ($post['birthday']) {
         $post['birthday'] = getJsDateDB($post['birthday'], $jshopConfig->field_birthday_format);
     }
     if ($post['d_birthday']) {
         $post['d_birthday'] = getJsDateDB($post['d_birthday'], $jshopConfig->field_birthday_format);
     }
     if ($post['invoice_date']) {
         $post['invoice_date'] = getJsDateDB($post['invoice_date'], $jshopConfig->store_date_format);
     }
     if (!$jshopConfig->hide_tax) {
         $post['order_tax'] = 0;
         $order_tax_ext = array();
         if (isset($post['tax_percent'])) {
             foreach ($post['tax_percent'] as $k => $v) {
                 if ($post['tax_percent'][$k] != "" || $post['tax_value'][$k] != "") {
                     $order_tax_ext[number_format($post['tax_percent'][$k], 2)] = $post['tax_value'][$k];
                 }
             }
         }
         $post['order_tax_ext'] = serialize($order_tax_ext);
         $post['order_tax'] = number_format(array_sum($order_tax_ext), 2);
     }
     $currency = JTable::getInstance('currency', 'jshop');
     $currency->load($post['currency_id']);
     $post['currency_code'] = $currency->currency_code;
     $post['currency_code_iso'] = $currency->currency_code_iso;
     $post['currency_exchange'] = $currency->currency_value;
     $dispatcher->trigger('onBeforeSaveOrder', array(&$post, &$file_generete_pdf_order));
     $order->bind($post);
     $order->store();
     $order_id = $order->order_id;
     $order_items = $order->getAllItems();
     $orders->saveOrderItem($order_id, $post, $order_items);
     JSFactory::loadLanguageFile($order->getLang());
     if ($jshopConfig->order_send_pdf_client || $jshopConfig->order_send_pdf_admin) {
         $order->load($order_id);
         $order->items = null;
         $order->products = $order->getAllItems();
         JSFactory::loadLanguageFile($order->getLang());
         $lang = JSFactory::getLang($order->getLang());
         $order->order_date = strftime($jshopConfig->store_date_format, strtotime($order->order_date));
         $order->order_tax_list = $order->getTaxExt();
         $country = JTable::getInstance('country', 'jshop');
         $country->load($order->country);
         $field_country_name = $lang->get("name");
         $order->country = $country->{$field_country_name};
         $d_country = JTable::getInstance('country', 'jshop');
         $d_country->load($order->d_country);
         $field_country_name = $lang->get("name");
         $order->d_country = $d_country->{$field_country_name};
         $shippingMethod = JTable::getInstance('shippingMethod', 'jshop');
         $shippingMethod->load($order->shipping_method_id);
         $pm_method = JTable::getInstance('paymentMethod', 'jshop');
         $pm_method->load($order->payment_method_id);
         $name = $lang->get("name");
         $description = $lang->get("description");
         $order->shipping_information = $shippingMethod->{$name};
         $order->payment_name = $pm_method->{$name};
         $order->payment_information = $order->payment_params;
         if ($jshopConfig->order_send_pdf_client || $jshopConfig->order_send_pdf_admin) {
             include_once $file_generete_pdf_order;
             $order->pdf_file = generatePdf($order);
             $order->insertPDF();
         }
     }
     if ($order->order_created == 1 && $order_created_prev == 0) {
         $order->items = null;
         JSFactory::loadLanguageFile($order->getLang());
         JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jshopping/models');
         $checkout = JModelLegacy::getInstance('checkout', 'jshop');
         if ($jshopConfig->send_order_email) {
             $checkout->sendOrderEmail($order_id, 1);
         }
     }
     JSFactory::loadAdminLanguageFile();
     $dispatcher->trigger('onAfterSaveOrder', array(&$order, &$file_generete_pdf_order));
     $this->setRedirect("index.php?option=com_jshopping&controller=orders&client_id=" . $client_id);
 }
Esempio n. 18
0
 function save()
 {
     $review = JSFactory::getTable('review', 'jshop');
     $post = JRequest::get('post');
     if (intval($post['review_id']) == 0) {
         $post['time'] = getJsDate();
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSaveReview', array(&$post));
     if (!$post['product_id']) {
         JError::raiseWarning("", _JSHOP_ERROR_DATA);
         $this->setRedirect("index.php?option=com_jshopping&controller=reviews");
         return 0;
     }
     if (!$review->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=reviews");
         return 0;
     }
     if (!$review->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=reviews&task=edit&cid[]=" . $review->review_id);
         return 0;
     }
     $product = JSFactory::getTable('product', 'jshop');
     $product->load($review->product_id);
     $product->loadAverageRating();
     $product->loadReviewsCount();
     $product->store();
     $dispatcher->trigger('onAfterSaveReview', array(&$review));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=reviews&task=edit&cid[]=" . $review->review_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=reviews");
     }
 }
Esempio n. 19
0
 function step5save()
 {
     $session = JFactory::getSession();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $checkout = JModelLegacy::getInstance('checkout', 'jshop');
     $mainframe = JFactory::getApplication();
     $checkout->checkStep(5);
     $checkagb = JRequest::getVar('agb');
     JPluginHelper::importPlugin('jshoppingorder');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onLoadStep5save', array(&$checkagb));
     $lang = JSFactory::getLang();
     $user = JFactory::getUser();
     if ($user->id) {
         $adv_user = JSFactory::getUserShop();
     } else {
         $adv_user = JSFactory::getUserShopGuest();
     }
     $cart = JModelLegacy::getInstance('cart', 'jshop');
     $cart->load();
     $cart->setDisplayItem(1, 1);
     $cart->setDisplayFreeAttributes();
     if ($jshopConfig->check_php_agb && $checkagb != 'on') {
         JError::raiseWarning("", _JSHOP_ERROR_AGB);
         $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5', 0, 1, $jshopConfig->use_ssl));
         return 0;
     }
     if (!$cart->checkListProductsQtyInStore()) {
         $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=cart&task=view', 1, 1));
         return 0;
     }
     if (!$cart->checkCoupon()) {
         $cart->setRabatt(0, 0, 0);
         JError::raiseWarning("", _JSHOP_RABATT_NON_CORRECT);
         $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=cart&task=view', 1, 1));
         return 0;
     }
     $orderNumber = $jshopConfig->next_order_number;
     $jshopConfig->updateNextOrderNumber();
     $payment_method_id = $cart->getPaymentId();
     $pm_method = JTable::getInstance('paymentMethod', 'jshop');
     $pm_method->load($payment_method_id);
     $payment_method = $pm_method->payment_class;
     if ($jshopConfig->without_payment) {
         $pm_method->payment_type = 1;
         $paymentSystemVerySimple = 1;
     } else {
         $paymentsysdata = $pm_method->getPaymentSystemData();
         $payment_system = $paymentsysdata->paymentSystem;
         if ($paymentsysdata->paymentSystemVerySimple) {
             $paymentSystemVerySimple = 1;
         }
         if ($paymentsysdata->paymentSystemError) {
             $cart->setPaymentParams("");
             JError::raiseWarning("", _JSHOP_ERROR_PAYMENT);
             $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step3', 0, 1, $jshopConfig->use_ssl));
             return 0;
         }
     }
     $order = JTable::getInstance('order', 'jshop');
     $arr_property = $order->getListFieldCopyUserToOrder();
     foreach ($adv_user as $key => $value) {
         if (in_array($key, $arr_property)) {
             $order->{$key} = $value;
         }
     }
     $sh_mt_pr = JTable::getInstance('shippingMethodPrice', 'jshop');
     $sh_mt_pr->load($cart->getShippingPrId());
     $order->order_date = $order->order_m_date = getJsDate();
     $order->order_tax = $cart->getTax(1, 1, 1);
     $order->setTaxExt($cart->getTaxExt(1, 1, 1));
     $order->order_subtotal = $cart->getPriceProducts();
     $order->order_shipping = $cart->getShippingPrice();
     $order->order_payment = $cart->getPaymentPrice();
     $order->order_discount = $cart->getDiscountShow();
     $order->shipping_tax = $cart->getShippingPriceTaxPercent();
     $order->setShippingTaxExt($cart->getShippingTaxList());
     $order->payment_tax = $cart->getPaymentTaxPercent();
     $order->setPaymentTaxExt($cart->getPaymentTaxList());
     $order->order_package = $cart->getPackagePrice();
     $order->setPackageTaxExt($cart->getPackageTaxList());
     $order->order_total = $cart->getSum(1, 1, 1);
     $order->currency_exchange = $jshopConfig->currency_value;
     $order->vendor_type = $cart->getVendorType();
     $order->vendor_id = $cart->getVendorId();
     $order->order_status = $jshopConfig->default_status_order;
     $order->shipping_method_id = $cart->getShippingId();
     $order->payment_method_id = $cart->getPaymentId();
     $order->delivery_times_id = $sh_mt_pr->delivery_times_id;
     if ($jshopConfig->delivery_order_depends_delivery_product) {
         $order->delivery_time = $cart->getDelivery();
     }
     if ($jshopConfig->show_delivery_date) {
         $order->delivery_date = $cart->getDeliveryDate();
     }
     $order->coupon_id = $cart->getCouponId();
     $pm_params = $cart->getPaymentParams();
     if (is_array($pm_params) && !$paymentSystemVerySimple) {
         $payment_system->setParams($pm_params);
         $payment_params_names = $payment_system->getDisplayNameParams();
         $order->payment_params = getTextNameArrayValue($payment_params_names, $pm_params);
         $order->setPaymentParamsData($pm_params);
     }
     $name = $lang->get("name");
     $order->ip_address = $_SERVER['REMOTE_ADDR'];
     $order->order_add_info = JRequest::getVar('order_add_info', '');
     $order->currency_code = $jshopConfig->currency_code;
     $order->currency_code_iso = $jshopConfig->currency_code_iso;
     $order->order_number = $order->formatOrderNumber($orderNumber);
     $order->order_hash = md5(time() . $order->order_total . $order->user_id);
     $order->file_hash = md5(time() . $order->order_total . $order->user_id . "hashfile");
     $order->display_price = $jshopConfig->display_price_front_current;
     $order->lang = $jshopConfig->cur_lang;
     if ($order->client_type) {
         $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type];
     } else {
         $order->client_type_name = "";
     }
     if ($order->order_total == 0) {
         $pm_method->payment_type = 1;
         $jshopConfig->without_payment = 1;
         $order->order_status = $jshopConfig->payment_status_paid;
     }
     if ($pm_method->payment_type == 1) {
         $order->order_created = 1;
     } else {
         $order->order_created = 0;
     }
     if (!$adv_user->delivery_adress) {
         $order->copyDeliveryData();
     }
     $dispatcher->trigger('onBeforeCreateOrder', array(&$order));
     $order->store();
     $dispatcher->trigger('onAfterCreateOrder', array(&$order));
     if ($cart->getCouponId()) {
         $coupon = JTable::getInstance('coupon', 'jshop');
         $coupon->load($cart->getCouponId());
         if ($coupon->finished_after_used) {
             $free_discount = $cart->getFreeDiscount();
             if ($free_discount > 0) {
                 $coupon->coupon_value = $free_discount / $jshopConfig->currency_value;
             } else {
                 $coupon->used = $adv_user->user_id;
             }
             $coupon->store();
         }
     }
     $order->saveOrderItem($cart->products);
     $session->set("jshop_end_order_id", $order->order_id);
     $order_history = JTable::getInstance('orderHistory', 'jshop');
     $order_history->order_id = $order->order_id;
     $order_history->order_status_id = $order->order_status;
     $order_history->status_date_added = $order->order_date;
     $order_history->customer_notify = 1;
     $order_history->store();
     if ($pm_method->payment_type == 1) {
         $order->changeProductQTYinStock("-");
         if ($jshopConfig->send_order_email) {
             $checkout->sendOrderEmail($order->order_id);
         }
     }
     $dispatcher->trigger('onEndCheckoutStep5', array(&$order));
     $session->set("jshop_send_end_form", 0);
     if ($jshopConfig->without_payment) {
         $checkout->setMaxStep(10);
         $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         return 0;
     }
     $pmconfigs = $pm_method->getConfigs();
     $task = "step6";
     if (isset($pmconfigs['windowtype']) && $pmconfigs['windowtype'] == 2) {
         $task = "step6iframe";
         $session->set("jsps_iframe_width", $pmconfigs['iframe_width']);
         $session->set("jsps_iframe_height", $pmconfigs['iframe_height']);
     }
     $checkout->setMaxStep(6);
     $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=' . $task, 0, 1, $jshopConfig->use_ssl));
 }
Esempio n. 20
0
 function save()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     require_once $jshopConfig->path . 'lib/image.lib.php';
     require_once $jshopConfig->path . 'lib/uploadfile.class.php';
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $_alias = $this->getModel("alias");
     $db = JFactory::getDBO();
     $category = JTable::getInstance("category", "jshop");
     if (!$_POST["category_id"]) {
         $_POST['category_add_date'] = getJsDate();
     }
     if (!isset($_POST['category_publish'])) {
         $_POST['category_publish'] = 0;
     }
     $post = JRequest::get('post');
     $_lang = $this->getModel("languages");
     $languages = $_lang->getAllLanguages(1);
     if ($post['category_parent_id'] == $post['category_id']) {
         $post['category_parent_id'] = 0;
     }
     $dispatcher->trigger('onBeforeSaveCategory', array(&$post));
     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->checkExistAlias1Group($post['alias_' . $lang->language], $lang->language, $post['category_id'], 0)) {
             $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);
     }
     if (!$category->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=categories");
         return 0;
     }
     $edit = $category->category_id;
     $upload = new UploadFile($_FILES['category_image']);
     $upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
     $upload->setDir($jshopConfig->image_category_path);
     $upload->setFileNameMd5(0);
     $upload->setFilterName(1);
     if ($upload->upload()) {
         $name = $upload->getName();
         if ($post['old_image'] && $name != $post['old_image']) {
             @unlink($jshopConfig->image_category_path . "/" . $post['old_image']);
         }
         @chmod($jshopConfig->image_category_path . "/" . $name, 0777);
         if ($post['size_im_category'] < 3) {
             if ($post['size_im_category'] == 1) {
                 $category_width_image = $jshopConfig->image_category_width;
                 $category_height_image = $jshopConfig->image_category_height;
             } else {
                 $category_width_image = JRequest::getInt('category_width_image');
                 $category_height_image = JRequest::getInt('category_height_image');
             }
             $path_full = $jshopConfig->image_category_path . "/" . $name;
             $path_thumb = $jshopConfig->image_category_path . "/" . $name;
             if (!ImageLib::resizeImageMagic($path_full, $category_width_image, $category_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
                 JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
                 saveToLog("error.log", "SaveCategory - Error create thumbail");
             }
             @chmod($jshopConfig->image_category_path . "/" . $name, 0777);
             unset($img);
         }
         $category->category_image = $name;
     } else {
         if ($upload->getError() != 4) {
             JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
             saveToLog("error.log", "SaveCategory - Error upload image. code: " . $upload->getError());
         }
     }
     $this->_reorderCategory($category);
     if (!$category->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=categories");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveCategory', array(&$category));
     $success = $edit ? _JSHOP_CATEGORY_SUCC_UPDATE : _JSHOP_CATEGORY_SUCC_ADDED;
     if ($this->getTask() == 'apply') {
         $this->setRedirect('index.php?option=com_jshopping&controller=categories&task=edit&category_id=' . $category->category_id, $success);
     } else {
         $this->setRedirect('index.php?option=com_jshopping&controller=categories', $success);
     }
 }