public function _loadData() { $order_functions = new order_functions(); if (empty($this->_data)) { $this->_data = $order_functions->getOrderDetails($this->_id); return (bool) $this->_data; } return true; }
function display($tpl = null) { $app = JFactory::getApplication(); $order_functions = new order_functions(); $print = JRequest::getInt('print'); if ($print) { ?> <script type="text/javascript" language="javascript"> window.print(); </script> <?php } $params = $app->getParams('com_redshop'); $prodhelperobj = new producthelper(); $prodhelperobj->generateBreadcrumb(); $user = JFactory::getUser(); $session = JFactory::getSession(); $order_id = $session->get('order_id'); $oid = JRequest::getInt('oid', $order_id); $encr = JRequest::getString('encr'); $layout = JRequest::getCmd('layout'); $model = $this->getModel('order_detail'); $OrdersDetail = $order_functions->getOrderDetails($oid); if ($user->id) { if ($OrdersDetail->user_id != $user->id) { $app->Redirect('index.php?option=com_redshop&view=login&Itemid=' . JRequest::getInt('Itemid')); return; } } else { if (isset($encr)) { $authorization = $model->checkauthorization($oid, $encr); if (!$authorization) { JError::raiseWarning(404, JText::_('COM_REDSHOP_ORDER_ENCKEY_FAILURE')); echo JText::_('COM_REDSHOP_ORDER_ENCKEY_FAILURE'); return false; } } elseif (!$user->id) { $app->Redirect('index.php?option=com_redshop&view=login&Itemid=' . JRequest::getInt('Itemid')); return; } } $this->OrdersDetail = $OrdersDetail; $this->user = $user; $this->params = $params; parent::display($tpl); }
* @package RedSHOP.Frontend * @subpackage Template * * @copyright Copyright (C) 2005 - 2013 redCOMPONENT.com. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('_JEXEC') or die; require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/order.php'; include_once JPATH_COMPONENT . '/helpers/helper.php'; $configobj = new Redconfiguration(); $order_functions = new order_functions(); $redhelper = new redhelper(); $url = JURI::base(); $Itemid = $redhelper->getCheckoutItemid(); $order_id = JRequest::getInt('oid'); $order = $order_functions->getOrderDetails($order_id); $orderitem = $order_functions->getOrderItemDetail($order_id); if ($order->order_total > 0 && !USE_AS_CATALOG) { $paymentmethod = $order_functions->getOrderPaymentDetail($order_id); $paymentmethod = $order_functions->getPaymentMethodInfo($paymentmethod[0]->payment_method_class); $paymentmethod = $paymentmethod[0]; $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '/' . $paymentmethod->element . '.xml'; $paymentparams = new JRegistry($paymentmethod->params); echo '<div>'; $is_creditcard = $paymentparams->get('is_creditcard', ''); $is_redirected = $paymentparams->get('is_redirected', 0); if (!$is_creditcard || $is_redirected == 1) { $adminpath = JPATH_ADMINISTRATOR . '/components/com_redshop'; $invalid_elements = $paymentparams->get('invalid_elements', ''); // Send the order_id and orderpayment_id to the payment plugin so it knows which DB record to update upon successful payment $billingaddresses = $order_functions->getBillingAddress($order->user_id);
$session = JFactory::getSession(); $user_id = $user->id; // get redshop helper $Itemid = $redhelper->getCheckoutItemid(); if ($Itemid == 0) { $Itemid = JRequest::getVar('Itemid'); } $option = JRequest::getVar('option'); $model = $this->getModel('checkout'); $ccinfo = JRequest::getVar('ccinfo'); /*$paymentinfo = $order_functions->getPaymentMethodInfo($this->payment_method_id); $paymentinfo = $paymentinfo[0]; */ //$cart = $this->cart; $getparameters = $order_functions->getparameters($request['plugin']); $order = $order_functions->getOrderDetails($request['order_id']); $paymentinfo = $getparameters[0]; $paymentparams = new JRegistry($paymentinfo->params); $is_creditcard = $paymentparams->get('is_creditcard', ''); $payment_oprand = $paymentparams->get('payment_oprand', ''); $payment_discount_is_percent = $paymentparams->get('payment_discount_is_percent', ''); $payment_price = $paymentparams->get('payment_price', ''); $accepted_credict_card = $paymentparams->get("accepted_credict_card"); $paymentinfo = new stdclass(); $paymentinfo->payment_price = $payment_price; $paymentinfo->is_creditcard = $is_creditcard; $paymentinfo->payment_oprand = $payment_oprand; $paymentinfo->payment_discount_is_percent = $payment_discount_is_percent; $paymentinfo->accepted_credict_card = $accepted_credict_card; $order_shipping_rate = $cart['shipping']; $shopperGroupId = $userhelper->getShopperGroup($user_id);
public function delete($cid = array()) { $producthelper = new producthelper(); $order_functions = new order_functions(); $quotationHelper = new quotationHelper(); $stockroomhelper = new rsstockroomhelper(); if (count($cid)) { if (ECONOMIC_INTEGRATION == 1) { $economic = new economic(); for ($i = 0; $i < count($cid); $i++) { $orderdata = $this->getTable('order_detail'); $orderdata->load($cid[$i]); $invoiceHandle = $economic->deleteInvoiceInEconomic($orderdata); } } $cids = implode(',', $cid); $db = JFactory::getDbo(); $order_item = $order_functions->getOrderItemDetail($cids); for ($i = 0; $i < count($order_item); $i++) { $quntity = $order_item[$i]->product_quantity; $order_id = $order_item[$i]->order_id; $order_detail = $order_functions->getOrderDetails($order_id); if ($order_detail->order_payment_status == "Unpaid") { // Update stock roommanageStockAmount $stockroomhelper->manageStockAmount($order_item[$i]->product_id, $quntity, $order_item[$i]->stockroom_id); } $producthelper->makeAttributeOrder($order_item[$i]->order_item_id, 0, $order_item[$i]->product_id, 1); $query = "DELETE FROM `" . $this->_table_prefix . "order_attribute_item` " . "WHERE `order_item_id` = " . $order_item[$i]->order_item_id; $this->_db->setQuery($query); $this->_db->query(); $query = "DELETE FROM `" . $this->_table_prefix . "order_acc_item` " . "WHERE `order_item_id` = " . $order_item[$i]->order_item_id; $this->_db->setQuery($query); $this->_db->query(); } $query = 'DELETE FROM ' . $this->_table_prefix . 'orders WHERE order_id IN ( ' . $cids . ' )'; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } $query = 'DELETE FROM ' . $this->_table_prefix . 'order_item WHERE order_id IN ( ' . $cids . ' )'; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } $query = 'DELETE FROM ' . $this->_table_prefix . 'order_payment WHERE order_id IN ( ' . $cids . ' )'; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } $query = 'DELETE FROM ' . $this->_table_prefix . 'order_users_info WHERE order_id IN ( ' . $cids . ' )'; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } $quotation = $quotationHelper->getQuotationwithOrder($cids); for ($q = 0; $q < count($quotation); $q++) { $quotation_item = $quotationHelper->getQuotationProduct($quotation[$q]->quotation_id); for ($j = 0; $j < count($quotation_item); $j++) { $query = 'DELETE FROM ' . $this->_table_prefix . 'quotation_fields_data ' . 'WHERE quotation_item_id=' . $quotation_item[$j]->quotation_item_id; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } $query = 'DELETE FROM ' . $this->_table_prefix . 'quotation_item ' . 'WHERE quotation_id=' . $quotation[$q]->quotation_id; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } $query = 'DELETE FROM ' . $this->_table_prefix . 'quotation WHERE order_id IN ( ' . $cids . ' )'; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } return true; }
public function checkoutnext() { $app = JFactory::getApplication(); $session = JFactory::getSession(); require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/order.php'; require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/configuration.php'; $redconfig = new Redconfiguration(); $model = $this->getModel(); $order_functions = new order_functions(); $request = JRequest::get('request'); if ($request['ccinfo'] == 0) { $redirect_url = JRoute::_(JURI::base() . "index.php?option=com_redshop&view=order_detail&task=edit&cid[]=" . $request['order_id']); } $order = $order_functions->getOrderDetails($request['order_id']); // Send the order_id and orderpayment_id to the payment plugin so it knows which DB record to update upon successful payment $userbillinginfo = $order_functions->getOrderBillingUserInfo($request['order_id']); $shippingaddresses = $order_functions->getOrderShippingUserInfo($request['order_id']); if (isset($shippingaddresses)) { $shippingaddress = $shippingaddresses; $shippingaddress->country_2_code = $redconfig->getCountryCode2($shippingaddress->country_code); $shippingaddress->state_2_code = $redconfig->getCountryCode2($shippingaddress->state_code); } if (isset($shippingaddresses)) { $d["shippingaddress"] = $shippingaddresses; $d["shippingaddress"]->country_2_code = $redconfig->getCountryCode2($d["shippingaddress"]->country_code); $d["shippingaddress"]->state_2_code = $redconfig->getCountryCode2($d["shippingaddress"]->state_code); $shippingaddresses->country_2_code = $redconfig->getCountryCode2($d["shippingaddress"]->country_code); $shippingaddresses->state_2_code = $redconfig->getCountryCode2($d["shippingaddress"]->state_code); } if (isset($userbillinginfo)) { $d["billingaddress"] = $userbillinginfo; if (isset($userbillinginfo->country_code)) { $d["billingaddress"]->country_2_code = $redconfig->getCountryCode2($userbillinginfo->country_code); $userbillinginfo->country_2_code = $redconfig->getCountryCode2($userbillinginfo->country_code); } if (isset($userbillinginfo->state_code)) { $d["billingaddress"]->state_2_code = $redconfig->getCountryCode2($userbillinginfo->state_code); $userbillinginfo->state_2_code = $redconfig->getCountryCode2($userbillinginfo->state_code); } } $ccdata['order_payment_name'] = $request['order_payment_name']; $ccdata['creditcard_code'] = $request['creditcard_code']; $ccdata['order_payment_number'] = $request['order_payment_number']; $ccdata['order_payment_expire_month'] = $request['order_payment_expire_month']; $ccdata['order_payment_expire_year'] = $request['order_payment_expire_year']; $ccdata['credit_card_code'] = $request['credit_card_code']; $session->set('ccdata', $ccdata); $values['order_shipping'] = $order->order_shipping; $values['order_number'] = $request['order_id']; $values['order_tax'] = $order->order_tax; $values['shippinginfo'] = $d["shippingaddress"]; $values['billinginfo'] = $d["billingaddress"]; $values['order_total'] = $order->order_total; $values['order_subtotal'] = $order->order_subtotal; $values["order_id"] = $request['order_id']; $values['payment_plugin'] = $request['payment_plugin']; $values['order'] = $order; JPluginHelper::importPlugin('redshop_payment'); $dispatcher = JDispatcher::getInstance(); $results = $dispatcher->trigger('onPrePayment_' . $values['payment_plugin'], array($values['payment_plugin'], $values)); $paymentResponse = $results[0]; if ($paymentResponse->responsestatus == "Success" || $values['payment_plugin'] == "") { $paymentResponse->log = $paymentResponse->message; $paymentResponse->msg = $paymentResponse->message; $paymentResponse->order_status_code = 'C'; $paymentResponse->order_payment_status_code = 'Paid'; $paymentResponse->order_id = $request['order_id']; $order_functions->changeorderstatus($paymentResponse); } // Update order payment table with credit card details $model->update_ccdata($request['order_id'], $paymentResponse->transaction_id); $redirect_url = JRoute::_(JURI::base() . "index.php?option=com_redshop&view=order_detail&task=edit&cid[]=" . $request['order_id']); $app->redirect($redirect_url, $paymentResponse->message); }
public function changeOrderStatusMail($order_id, $newstatus, $order_comment = '') { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $config = new Redconfiguration(); $carthelper = new rsCarthelper(); $order_functions = new order_functions(); $redshopMail = new redshopMail(); $shippinghelper = new shipping(); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $mailbcc = null; $mailtemplate = $redshopMail->getMailtemplate(0, '', 'mail_section LIKE "order_status" AND mail_order_status LIKE ' . $db->quote($newstatus) . ' '); if (count($mailtemplate) > 0) { $maildata = $mailtemplate[0]->mail_body; $mailsubject = $mailtemplate[0]->mail_subject; if (trim($mailtemplate[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailtemplate[0]->mail_bcc); } // Getting the order details $orderdetail = $this->getOrderDetails($order_id); $barcode_code = $orderdetail->barcode; // Changes to parse all tags same as order mail start $row = $order_functions->getOrderDetails($order_id); $maildata = str_replace("{order_mail_intro_text_title}", JText::_('COM_REDSHOP_ORDER_MAIL_INTRO_TEXT_TITLE'), $maildata); $maildata = str_replace("{order_mail_intro_text}", JText::_('COM_REDSHOP_ORDER_MAIL_INTRO_TEXT'), $maildata); $maildata = $carthelper->replaceOrderTemplate($row, $maildata); $arr_discount_type = array(); $arr_discount = explode('@', $row->discount_type); $discount_type = ''; for ($d = 0; $d < count($arr_discount); $d++) { if ($arr_discount[$d]) { $arr_discount_type = explode(':', $arr_discount[$d]); if ($arr_discount_type[0] == 'c') { $discount_type .= JText::_('COM_REDSHOP_COUPON_CODE') . ' : ' . $arr_discount_type[1] . '<br>'; } if ($arr_discount_type[0] == 'v') { $discount_type .= JText::_('COM_REDSHOP_VOUCHER_CODE') . ' : ' . $arr_discount_type[1] . '<br>'; } } } if (!$discount_type) { $discount_type = JText::_('COM_REDSHOP_NO_DISCOUNT_AVAILABLE'); } $search[] = "{discount_type}"; $replace[] = $discount_type; $maildata = str_replace($search_sub, $replace_sub, $maildata); // Changes to parse all tags same as order mail end $userdetail = $this->getOrderBillingUserInfo($order_id); // For barcode if (strstr($maildata, "{barcode}")) { if ($barcode_code != "" && file_exists(REDSHOP_FRONT_IMAGES_RELPATH . "barcode/" . $barcode_code . ".png")) { $barcode_code = $barcode_code; } else { $barcode_code = $this->barcode_randon_number(12, 1); $this->updatebarcode($order_id, $barcode_code); } $img_url = REDSHOP_FRONT_IMAGES_ABSPATH . "barcode/" . $barcode_code . ".png"; $bar_replace = '<img alt="" src="' . $img_url . '">'; $search[] = "{barcode}"; $replace[] = $bar_replace; } // Getting the order status changed template from mail center end $maildata = $carthelper->replaceBillingAddress($maildata, $userdetail); // Get ShippingAddress From order Users info $shippingaddresses = $this->getOrderShippingUserInfo($order_id); if (count($shippingaddresses) <= 0) { $shippingaddresses = $userdetail; } $maildata = $carthelper->replaceShippingAddress($maildata, $shippingaddresses); $search[] = "{shopname}"; $replace[] = SHOP_NAME; $search[] = "{fullname}"; $replace[] = $userdetail->firstname . " " . $userdetail->lastname; $search[] = "{customer_id}"; $replace[] = $userdetail->users_info_id; $search[] = "{order_id}"; $replace[] = $order_id; $search[] = "{order_number}"; $replace[] = $orderdetail->order_number; $search[] = "{order_date}"; $replace[] = $config->convertDateFormat($orderdetail->cdate); $search[] = "{customer_note_lbl}"; $replace[] = JText::_('COM_REDSHOP_COMMENT'); $search[] = "{customer_note}"; $replace[] = $order_comment; $search[] = "{order_detail_link_lbl}"; $replace[] = JText::_('COM_REDSHOP_ORDER_DETAIL_LBL'); $orderdetailurl = JURI::root() . 'index.php?option=com_redshop&view=order_detail&oid=' . $order_id . '&encr=' . $orderdetail->encr_key; $search[] = "{order_detail_link}"; $replace[] = "<a href='" . $orderdetailurl . "'>" . JText::_("COM_REDSHOP_ORDER_DETAIL_LINK_LBL") . "</a>"; $details = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $orderdetail->ship_method_id))); if (count($details) <= 1) { $details = explode("|", $orderdetail->ship_method_id); } $shopLocation = $orderdetail->shop_id; if ($details[0] != 'plgredshop_shippingdefault_shipping_GLS') { $shopLocation = ''; } $arrLocationDetails = explode('|', $shopLocation); $orderdetail->track_no = $arrLocationDetails[0]; $search[] = "{order_track_no}"; $replace[] = trim($orderdetail->track_no); $order_trackURL = 'http://www.pacsoftonline.com/ext.po.dk.dk.track?key=' . POSTDK_CUSTOMER_NO . '&order=' . $order_id; $search[] = "{order_track_url}"; $replace[] = "<a href='" . $order_trackURL . "'>" . JText::_("COM_REDSHOP_TRACK_LINK_LBL") . "</a>"; $mailbody = str_replace($search, $replace, $maildata); $mailsubject = str_replace($search, $replace, $mailsubject); if ($userdetail->user_email != '' && $mailbody) { JUtility::sendMail($MailFrom, $FromName, $userdetail->user_email, $mailsubject, $mailbody, 1, null, $mailbcc); } } }