コード例 #1
0
ファイル: order.php プロジェクト: jaanusnurmoja/redjoomla
 public function business_gls_export($cid)
 {
     $app = JFactory::getApplication();
     $oids = implode(',', $cid);
     $where = "";
     $redhelper = new redhelper();
     $order_helper = new order_functions();
     $shipping = new shipping();
     $exportfilename = 'redshop_gls_order_export.csv';
     /* Start output to the browser */
     if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) {
         $UserBrowser = "Opera";
     } elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) {
         $UserBrowser = "IE";
     } else {
         $UserBrowser = '';
     }
     $mime_type = $UserBrowser == 'IE' || $UserBrowser == 'Opera' ? 'application/octetstream' : 'application/octet-stream';
     /* Clean the buffer */
     while (@ob_end_clean()) {
     }
     header('Content-Type: ' . $mime_type);
     header('Content-Encoding: UTF-8');
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     if ($UserBrowser == 'IE') {
         header('Content-Disposition: inline; filename="' . $exportfilename . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: attachment; filename="' . $exportfilename . '"');
         header('Pragma: no-cache');
     }
     if ($cid[0] != 0) {
         $where = " WHERE order_id IN (" . $oids . ")";
     }
     $db = JFactory::getDbo();
     $q = "SELECT * FROM #__redshop_orders " . $where . " ORDER BY order_id asc";
     $db->setQuery($q);
     $gls_arr = $db->loadObjectList();
     echo "Order_number,Quantity,Create_date,total_weight,reciever_firstName,reciever_lastname,Customer_note";
     echo "\r\n";
     for ($i = 0; $i < count($gls_arr); $i++) {
         $details = explode("|", $shipping->decryptShipping(str_replace(" ", "+", $gls_arr[$i]->ship_method_id)));
         if ($details[0] == 'shipper') {
             $orderproducts = $order_helper->getOrderItemDetail($gls_arr[$i]->order_id);
             $shippingDetails = $order_helper->getOrderShippingUserInfo($gls_arr[$i]->order_id);
             $billingDetails = $order_helper->getOrderBillingUserInfo($gls_arr[$i]->order_id);
             $totalWeight = "";
             $qty = "";
             for ($c = 0; $c < count($orderproducts); $c++) {
                 $product_id[] = $orderproducts[$c]->product_id;
                 $qty += $orderproducts[$c]->product_quantity;
                 $content_products[] = $orderproducts[$c]->order_item_name;
                 $sql = "SELECT weight FROM #__redshop_product WHERE product_id ='" . $orderproducts[$c]->product_id . "'";
                 $db->setQuery($sql);
                 $weight = $db->loadResult();
                 $totalWeight += $weight * $orderproducts[$c]->product_quantity;
             }
             $userDetail = ',"' . $shippingDetails->firstname . ' ' . $shippingDetails->lastname . '","' . $gls_arr[$i]->customer_note;
             echo '"' . $gls_arr[$i]->order_number . '","' . $qty . '","' . date("d-m-Y", $gls_arr[$i]->cdate) . '","' . $totalWeight . '","' . $userDetail . '"';
             echo "\r\n";
         }
     }
     exit;
 }
コード例 #2
0
 public function store($postdata)
 {
     $redshopMail = new redshopMail();
     $order_functions = new order_functions();
     $helper = new redhelper();
     $producthelper = new producthelper();
     $rsCarthelper = new rsCarthelper();
     $shippinghelper = new shipping();
     $adminproducthelper = new adminproducthelper();
     $stockroomhelper = new rsstockroomhelper();
     // For barcode generation
     $barcode_code = $order_functions->barcode_randon_number(12, 0);
     $postdata['barcode'] = $barcode_code;
     $row = $this->getTable('order_detail');
     if (!$row->bind($postdata)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $iscrm = $helper->isredCRM();
     if ($iscrm) {
         $postdata['order_id'] = $row->order_id;
         $postdata['debitor_id'] = $postdata['user_info_id'];
         JTable::addIncludePath(REDCRM_ADMIN . '/tables');
         $crmorder =& $this->getTable('crm_order');
         if (!$crmorder->bind($postdata)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         if (!$crmorder->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // Update rma table entry
         if (ENABLE_RMA && isset($postdata['rmanotes'])) {
             $rmaInfo = $this->getTable('rma_orders');
             $rmaInfo->rma_number = $postdata['rma_number'];
             $rmaInfo->original_order_id = $postdata['main_order_id'];
             $rmaInfo->credit_note_order_id = $row->order_id;
             $rmaInfo->rma_note = $postdata['rmanotes'];
             $rmaInfo->store();
         }
         JTable::addIncludePath(REDSHOP_ADMIN . '/tables');
     }
     $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $row->ship_method_id)));
     $rowOrderStatus =& $this->getTable('order_status_log');
     $rowOrderStatus->order_id = $row->order_id;
     $rowOrderStatus->order_status = $row->order_status;
     $rowOrderStatus->date_changed = time();
     $rowOrderStatus->customer_note = $row->customer_note;
     $rowOrderStatus->store();
     $billingaddresses = $order_functions->getBillingAddress($row->user_id);
     if (isset($postdata['billisship']) && $postdata['billisship'] == 1) {
         $shippingaddresses = $billingaddresses;
     } else {
         $key = 0;
         $shippingaddresses = $order_functions->getShippingAddress($row->user_id);
         $shipp_users_info_id = isset($postdata['shipp_users_info_id']) && $postdata['shipp_users_info_id'] != 0 ? $postdata['shipp_users_info_id'] : 0;
         if ($shipp_users_info_id != 0) {
             for ($o = 0; $o < count($shippingaddresses); $o++) {
                 if ($shippingaddresses[$o]->users_info_id == $shipp_users_info_id) {
                     $key = $o;
                     break;
                 }
             }
         }
         $shippingaddresses = $shippingaddresses[$key];
     }
     // ORDER DELIVERY TIME IS REMAINING
     $user_id = $row->user_id;
     $item = $postdata['order_item'];
     for ($i = 0; $i < count($item); $i++) {
         $product_id = $item[$i]->product_id;
         $quantity = $item[$i]->quantity;
         $product_excl_price = $item[$i]->prdexclprice;
         $product_price = $item[$i]->productprice;
         // Attribute price added
         $generateAttributeCart = $rsCarthelper->generateAttributeArray((array) $item[$i], $user_id);
         $retAttArr = $producthelper->makeAttributeCart($generateAttributeCart, $product_id, $user_id, 0, $quantity);
         $product_attribute = $retAttArr[0];
         // Accessory price
         $generateAccessoryCart = $rsCarthelper->generateAccessoryArray((array) $item[$i], $user_id);
         $retAccArr = $producthelper->makeAccessoryCart($generateAccessoryCart, $product_id, $user_id);
         $product_accessory = $retAccArr[0];
         $accessory_total_price = $retAccArr[1];
         $accessory_vat_price = $retAccArr[2];
         $wrapper_price = 0;
         $wrapper_vat = 0;
         if ($item[$i]->wrapper_data != 0 && $item[$i]->wrapper_data != '') {
             $wrapper = $producthelper->getWrapper($product_id, $item[$i]->wrapper_data);
             if (count($wrapper) > 0) {
                 if ($wrapper[0]->wrapper_price > 0) {
                     $wrapper_vat = $producthelper->getProducttax($product_id, $wrapper[0]->wrapper_price, $user_id);
                 }
                 $wrapper_price = $wrapper[0]->wrapper_price + $wrapper_vat;
             }
         }
         $product = $producthelper->getProductById($product_id);
         $rowitem =& $this->getTable('order_item_detail');
         if (!$rowitem->bind($postdata)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // STOCKROOM update
         $updatestock = $stockroomhelper->updateStockroomQuantity($product_id, $quantity);
         $stockroom_id_list = $updatestock['stockroom_list'];
         $stockroom_quantity_list = $updatestock['stockroom_quantity_list'];
         $rowitem->stockroom_id = $stockroom_id_list;
         $rowitem->stockroom_quantity = $stockroom_quantity_list;
         $rowitem->order_item_id = 0;
         $rowitem->order_id = $row->order_id;
         $rowitem->user_info_id = $row->user_info_id;
         $rowitem->supplier_id = $product->manufacturer_id;
         $rowitem->product_id = $product_id;
         $rowitem->order_item_sku = $product->product_number;
         $rowitem->order_item_name = $product->product_name;
         $rowitem->product_quantity = $quantity;
         $rowitem->product_item_price = $product_price;
         $rowitem->product_item_price_excl_vat = $product_excl_price;
         $rowitem->product_final_price = $product_price * $quantity;
         $rowitem->order_item_currency = REDCURRENCY_SYMBOL;
         $rowitem->order_status = $row->order_status;
         $rowitem->cdate = $row->cdate;
         $rowitem->mdate = $row->cdate;
         $rowitem->product_attribute = $product_attribute;
         $rowitem->product_accessory = $product_accessory;
         $rowitem->wrapper_id = $item[$i]->wrapper_data;
         $rowitem->wrapper_price = $wrapper_price;
         $rowitem->is_giftcard = 0;
         // RedCRM product purchase price
         if ($iscrm) {
             $crmProductHelper = new crmProductHelper();
             $crmproduct = $crmProductHelper->getProductById($product_id);
             $rowitem->product_purchase_price = $crmproduct->product_purchase_price > 0 ? $crmproduct->product_purchase_price : $crmproduct->product_price;
         }
         if ($producthelper->checkProductDownload($product_id)) {
             $medianame = $producthelper->getProductMediaName($product_id);
             for ($j = 0; $j < count($medianame); $j++) {
                 $product_serial_number = $producthelper->getProdcutSerialNumber($product_id);
                 $producthelper->insertProductDownload($product_id, $user_id, $rowitem->order_id, $medianame[$j]->media_name, $product_serial_number->serial_number);
             }
         }
         if (!$rowitem->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         /** my accessory save in table start */
         if (count($generateAccessoryCart) > 0) {
             $attArr = $generateAccessoryCart;
             for ($a = 0; $a < count($attArr); $a++) {
                 $accessory_vat_price = 0;
                 $accessory_attribute = "";
                 $accessory_id = $attArr[$a]['accessory_id'];
                 $accessory_name = $attArr[$a]['accessory_name'];
                 $accessory_price = $attArr[$a]['accessory_price'];
                 $accessory_org_price = $accessory_price;
                 if ($accessory_price > 0) {
                     $accessory_vat_price = $producthelper->getProductTax($product_id, $accessory_price, $user_id);
                 }
                 $attchildArr = $attArr[$a]['accessory_childs'];
                 for ($j = 0; $j < count($attchildArr); $j++) {
                     $attribute_id = $attchildArr[$j]['attribute_id'];
                     $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>";
                     $rowattitem =& $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $attribute_id;
                     $rowattitem->section = "attribute";
                     $rowattitem->parent_section_id = $accessory_id;
                     $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                     $rowattitem->is_accessory_att = 1;
                     if ($attribute_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $propArr = $attchildArr[$j]['attribute_childs'];
                     for ($k = 0; $k < count($propArr); $k++) {
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($product_id, $propArr[$k]['property_price'], $user_id);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>";
                         $subpropArr = $propArr[$k]['property_childs'];
                         $rowattitem =& $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 1;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>";
                             $rowattitem =& $this->getTable('order_attribute_item');
                             $rowattitem->order_att_item_id = 0;
                             $rowattitem->order_item_id = $rowitem->order_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 1;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                 }
                 $accdata =& $this->getTable('accessory_detail');
                 if ($accessory_id > 0) {
                     $accdata->load($accessory_id);
                 }
                 $accProductinfo = $producthelper->getProductById($accdata->child_product_id);
                 $rowaccitem =& $this->getTable('order_acc_item');
                 $rowaccitem->order_item_acc_id = 0;
                 $rowaccitem->order_item_id = $rowitem->order_item_id;
                 $rowaccitem->product_id = $accessory_id;
                 $rowaccitem->order_acc_item_sku = $accProductinfo->product_number;
                 $rowaccitem->order_acc_item_name = $accessory_name;
                 $rowaccitem->order_acc_price = $accessory_org_price;
                 $rowaccitem->order_acc_vat = $accessory_vat_price;
                 $rowaccitem->product_quantity = $quantity;
                 $rowaccitem->product_acc_item_price = $accessory_price;
                 $rowaccitem->product_acc_final_price = $accessory_price * $quantity;
                 $rowaccitem->product_attribute = $accessory_attribute;
                 if ($accessory_id > 0) {
                     if (!$rowaccitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
             }
         }
         /** my attribute save in table start */
         if (count($generateAttributeCart) > 0) {
             $attArr = $generateAttributeCart;
             for ($j = 0; $j < count($attArr); $j++) {
                 $attribute_id = $attArr[$j]['attribute_id'];
                 $rowattitem =& $this->getTable('order_attribute_item');
                 $rowattitem->order_att_item_id = 0;
                 $rowattitem->order_item_id = $rowitem->order_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $rowitem->product_id;
                 $rowattitem->section_name = $attArr[$j]['attribute_name'];
                 $rowattitem->is_accessory_att = 0;
                 if ($attribute_id > 0) {
                     if (!$rowattitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
                 $propArr = $attArr[$j]['attribute_childs'];
                 for ($k = 0; $k < count($propArr); $k++) {
                     $section_vat = 0;
                     if ($propArr[$k]['property_price'] > 0) {
                         $section_vat = $producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price'], $user_id);
                     }
                     $property_id = $propArr[$k]['property_id'];
                     /** product property STOCKROOM update start */
                     $updatestock = $stockroomhelper->updateStockroomQuantity($property_id, $quantity, "property");
                     $rowattitem =& $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $property_id;
                     $rowattitem->section = "property";
                     $rowattitem->parent_section_id = $attribute_id;
                     $rowattitem->section_name = $propArr[$k]['property_name'];
                     $rowattitem->section_price = $propArr[$k]['property_price'];
                     $rowattitem->section_vat = $section_vat;
                     $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                     $rowattitem->is_accessory_att = 0;
                     if ($property_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $subpropArr = $propArr[$k]['property_childs'];
                     for ($l = 0; $l < count($subpropArr); $l++) {
                         $section_vat = 0;
                         if ($subpropArr[$l]['subproperty_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                         }
                         $subproperty_id = $subpropArr[$l]['subproperty_id'];
                         /** product subproperty STOCKROOM update start */
                         $updatestock = $stockroomhelper->updateStockroomQuantity($subproperty_id, $quantity, "subproperty");
                         $rowattitem =& $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $subproperty_id;
                         $rowattitem->section = "subproperty";
                         $rowattitem->parent_section_id = $property_id;
                         $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                         $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                         $rowattitem->is_accessory_att = 0;
                         if ($subproperty_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
         //			$producthelper->insertProdcutUserfield($i,$item,$rowitem->order_item_id,12);
         if (USE_CONTAINER) {
             $producthelper->updateContainerStock($product_id, $quantity, $rowitem->container_id);
         }
         // Store userfields
         $userfields = $item[$i]->extrafieldname;
         $userfields_id = $item[$i]->extrafieldId;
         for ($ui = 0; $ui < count($userfields); $ui++) {
             $adminproducthelper->admin_insertProdcutUserfield($userfields_id[$ui], $rowitem->order_item_id, 12, $userfields[$ui]);
         }
         // redCRM RMA Transaction Entry
         if ($iscrm) {
             if (ENABLE_RMA && $rowitem->product_final_price < 0) {
                 // RMA transation log
                 if (isset($item[$i]->reason)) {
                     $rmaTrans =& $this->getTable('rma_transaction');
                     $rmaTrans->rma_transaction_id = 0;
                     $rmaTrans->rma_number = $postdata['rma_number'];
                     $rmaTrans->order_item_return_id = $rowitem->order_item_id;
                     $rmaTrans->order_item_return_reason = $item[$i]->reason;
                     $rmaTrans->order_item_return_status = $item[$i]->deposition;
                     $rmaTrans->order_item_return_action = $item[$i]->action;
                     $rmaTrans->cdate = time();
                     $rmaTrans->store();
                     if (ENABLE_ITEM_TRACKING_SYSTEM) {
                         // Manage supplier order stock
                         $crmSupplierOrderHelper = new crmSupplierOrderHelper();
                         $senddata['main_order_number'] = $postdata['main_order_number'];
                         $senddata['order_status'] = $row->order_status;
                         $senddata['product_id'] = $rowitem->product_id;
                         $senddata['property_id'] = $property_id;
                         $senddata['subproperty_id'] = $subproperty_id;
                         $senddata['deposition'] = $item[$i]->deposition;
                         $itemqty = $rowitem->product_quantity;
                         for ($r = 0; $r < $itemqty; $r++) {
                             $crmSupplierOrderHelper->manageStockAffectedRMA($senddata);
                         }
                     }
                 }
             }
         }
     }
     $rowpayment =& $this->getTable('order_payment');
     if (!$rowpayment->bind($postdata)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $rowpayment->order_id = $row->order_id;
     $rowpayment->payment_method_id = $postdata['payment_method_class'];
     $rowpayment->order_payment_amount = $row->order_total;
     $rowpayment->order_payment_name = $postdata['order_payment_name'];
     $rowpayment->payment_method_class = $postdata['payment_method_class'];
     if (!$rowpayment->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add billing Info
     $userrow =& $this->getTable('user_detail');
     $userrow->load($billingaddresses->users_info_id);
     $orderuserrow =& $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $row->order_id;
     $orderuserrow->address_type = 'BT';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add shipping Info
     $userrow =& $this->getTable('user_detail');
     if (isset($shippingaddresses->users_info_id)) {
         $userrow->load($shippingaddresses->users_info_id);
     }
     $orderuserrow =& $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $row->order_id;
     $orderuserrow->address_type = 'ST';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if ($row->order_status == CLICKATELL_ORDER_STATUS) {
         $helper->clickatellSMS($row->order_id);
     }
     // Maintan supplier order stck when item tracking system is enabled
     if ($helper->isredCRM()) {
         if (ENABLE_ITEM_TRACKING_SYSTEM) {
             // Supplier order helper object
             $crmSupplierOrderHelper = new crmSupplierOrderHelper();
             $getStatus = array();
             $getStatus['orderstatus'] = $row->order_status;
             $getStatus['paymentstatus'] = $row->order_payment_status;
             $crmSupplierOrderHelper->redSHOPOrderUpdate($row->order_id, $getStatus);
             unset($getStatus);
         }
     }
     $checkOrderStatus = 1;
     if ($postdata['payment_method_class'] == "rs_payment_banktransfer" || $postdata['payment_method_class'] == "rs_payment_banktransfer_discount" || $postdata['payment_method_class'] == "rs_payment_banktransfer2" || $postdata['payment_method_class'] == "rs_payment_banktransfer3" || $postdata['payment_method_class'] == "rs_payment_banktransfer4" || $postdata['payment_method_class'] == "rs_payment_banktransfer5") {
         $checkOrderStatus = 0;
     }
     // Economic Integration start for invoice generate and book current invoice
     if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) {
         $issplit = 0;
         $economic = new economic();
         if (isset($postdata['issplit']) && $postdata['issplit'] == 1) {
             $issplit = 1;
         }
         $economicdata['split_payment'] = $issplit;
         $economicdata['economic_payment_terms_id'] = $postdata['economic_payment_terms_id'];
         $economicdata['economic_design_layout'] = $postdata['economic_design_layout'];
         $economicdata['economic_is_creditcard'] = $postdata['economic_is_creditcard'];
         $payment_name = $postdata['payment_method_class'];
         $paymentArr = explode("rs_payment_", $postdata['payment_method_class']);
         if (count($paymentArr) > 0) {
             $payment_name = $paymentArr[1];
         }
         $economicdata['economic_payment_method'] = $payment_name;
         $invoiceHandle = $economic->createInvoiceInEconomic($row->order_id, $economicdata);
         if (ECONOMIC_INVOICE_DRAFT == 0) {
             $bookinvoicepdf = $economic->bookInvoiceInEconomic($row->order_id, $checkOrderStatus);
             if (is_file($bookinvoicepdf)) {
                 $ret = $redshopMail->sendEconomicBookInvoiceMail($row->order_id, $bookinvoicepdf);
             }
         }
     }
     // ORDER MAIL SEND
     if ($postdata['task'] != "save_without_sendmail") {
         $redshopMail->sendOrderMail($row->order_id);
     }
     return $row;
 }
コード例 #3
0
    ?>
"><?php 
    echo $row->order_id;
    ?>
</a>
					</td>
					<td align="center"><?php 
    echo $row->order_number;
    ?>
</td>
					<td align="center"><?php 
    echo $row->cdate;
    ?>
</td>
					<td align="center"><?php 
    $details = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $row->ship_method_id)));
    if (strstr($details[0], 'default_shipping')) {
        if (file_exists(JPATH_SITE . '/administrator/components/com_redshop/assets/lables/label_' . $row->order_id . '.pdf')) {
            ?>
								<a href="<?php 
            echo $dlink;
            ?>
"><?php 
            echo JText::_('COM_REDSHOP_DOWNLOAD');
            ?>
</a>
								<a href="<?php 
            echo $plink;
            ?>
"
								   target="_blank"><?php 
コード例 #4
0
 public function getShippingRate()
 {
     $shippinghelper = new shipping();
     $get = JRequest::get('get');
     $shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $get['shipping_rate_id'])));
     $order_shipping = 0;
     $order_shipping_class = '';
     if (count($shipping) > 4) {
         $order_shipping = $shipping[3] - $shipping[6];
         $order_shipping_tax = $shipping[6];
         $order_shipping_class = $shipping[0];
     }
     echo "<div id='resultShippingClass'>" . $order_shipping_class . "</div>";
     echo "<div id='resultShipping'>" . $order_shipping . "</div>";
     echo "<div id='resultShippingVat'>" . $order_shipping_tax . "</div>";
     die;
 }
コード例 #5
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $shippinghelper = new shipping();
     $order_functions = new order_functions();
     $params = $app->getParams('com_redshop');
     $option = JRequest::getVar('option');
     $Itemid = JRequest::getInt('Itemid');
     $issplit = JRequest::getBool('issplit');
     $ccinfo = JRequest::getInt('ccinfo');
     $task = JRequest::getCmd('task');
     $model = $this->getModel('checkout');
     $session = JFactory::getSession();
     if ($issplit != '') {
         $session->set('issplit', $issplit);
     }
     $payment_method_id = JRequest::getCmd('payment_method_id');
     $users_info_id = JRequest::getInt('users_info_id');
     $auth = $session->get('auth');
     if (empty($users_info_id)) {
         $users_info_id = $auth['users_info_id'];
     }
     $shipping_rate_id = JRequest::getString('shipping_rate_id');
     $shippingdetail = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $shipping_rate_id)));
     if (count($shippingdetail) < 4) {
         $shipping_rate_id = "";
     }
     $cart = $session->get('cart');
     if ($cart['idx'] < 1) {
         $msg = JText::_('COM_REDSHOP_EMPTY_CART');
         $app->Redirect('index.php?option=' . $option . '&Itemid=' . $Itemid, $msg);
     }
     if (SHIPPING_METHOD_ENABLE) {
         if ($users_info_id < 1) {
             $msg = JText::_('COM_REDSHOP_SELECT_SHIP_ADDRESS');
             $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id;
             $app->Redirect($link, $msg);
         }
         if ($shipping_rate_id == '' && $cart['free_shipping'] != 1) {
             $msg = JText::_('COM_REDSHOP_SELECT_SHIP_METHOD');
             $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id;
             $app->Redirect($link, $msg);
         }
     }
     if ($payment_method_id == '') {
         $msg = JText::_('COM_REDSHOP_SELECT_PAYMENT_METHOD');
         $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id;
         $app->Redirect($link, $msg);
     }
     $paymentinfo = $order_functions->getPaymentMethodInfo($payment_method_id);
     $paymentinfo = $paymentinfo[0];
     $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentinfo->element . '/' . $paymentinfo->element . '.xml';
     $paymentparams = new JRegistry($paymentinfo->params);
     $is_creditcard = $paymentparams->get('is_creditcard', '');
     $is_subscription = $paymentparams->get('is_subscription', 0);
     if (@$is_creditcard == 1) {
         $document = JFactory::getDocument();
         JHTML::Script('credit_card.js', 'components/com_redshop/assets/js/', false);
     }
     if ($is_subscription) {
         $subscription_id = $session->set('subscription_id', $subscription_id);
     }
     $this->cart = $cart;
     $this->users_info_id = $users_info_id;
     $this->shipping_rate_id = $shipping_rate_id;
     $this->payment_method_id = $payment_method_id;
     $this->is_creditcard = $is_creditcard;
     if ($task != '') {
         $tpl = $task;
     }
     parent::display($tpl);
 }
コード例 #6
0
 public function update_shippingrates($data)
 {
     $redhelper = new redhelper();
     $shippinghelper = new shipping();
     // Get Order Info
     $orderdata = $this->getTable('order_detail');
     $orderdata->load($this->_id);
     if ($data['shipping_rate_id'] != "") {
         // Get Shipping rate info Info
         $decry = $shippinghelper->decryptShipping(str_replace(" ", "+", $data['shipping_rate_id']));
         $neworder_shipping = explode("|", $decry);
         if ($data['shipping_rate_id'] != $orderdata->ship_method_id || $neworder_shipping[0] == 'plgredshop_shippingdefault_shipping_GLS') {
             if (count($neworder_shipping) > 4) {
                 // Shipping_rate_value
                 $orderdata->order_total = $orderdata->order_total - $orderdata->order_shipping + $neworder_shipping[3];
                 $orderdata->order_shipping = $neworder_shipping[3];
                 $orderdata->ship_method_id = $data['shipping_rate_id'];
                 $orderdata->order_shipping_tax = isset($neworder_shipping[6]) && $neworder_shipping[6] ? $neworder_shipping[6] : 0;
                 $orderdata->mdate = time();
                 $orderdata->shop_id = $data['shop_id'] . "###" . $data['gls_mobile'];
                 if (!$orderdata->store()) {
                     return false;
                 }
                 // Economic Integration start for invoice generate
                 if (ECONOMIC_INTEGRATION == 1) {
                     $economic = new economic();
                     $invoiceHandle = $economic->renewInvoiceInEconomic($orderdata);
                 }
             }
         }
     }
     return true;
 }
コード例 #7
0
 public function replaceMessage($message, $orderData, $paymentName)
 {
     $shippinghelper = new shipping();
     $shipping_method = '';
     $details = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $orderData->ship_method_id)));
     if (count($details) > 1) {
         $ext = "";
         if (array_key_exists(2, $details)) {
             $ext = " (" . $details[2] . ")";
         }
         $shipping_method = $details[1] . $ext;
     }
     $producthelper = new producthelper();
     $userData = $producthelper->getUserInformation($orderData->user_id);
     $message = str_replace('{order_id}', $orderData->order_id, $message);
     $message = str_replace('{order_status}', $orderData->order_status, $message);
     $message = str_replace('{customer_name}', $userData->firstname, $message);
     $message = str_replace('{payment_status}', $orderData->order_payment_status, $message);
     $message = str_replace('{order_comment}', $orderData->customer_note, $message);
     $message = str_replace('{shipping_method}', $shipping_method, $message);
     $message = str_replace('{payment_method}', $paymentName, $message);
     return $message;
 }
コード例 #8
0
 public function orderplace()
 {
     $app = JFactory::getApplication();
     $redconfig = new Redconfiguration();
     $quotationHelper = new quotationHelper();
     $stockroomhelper = new rsstockroomhelper();
     $helper = new redhelper();
     $shippinghelper = new shipping();
     $order_functions = new order_functions();
     $post = JRequest::get('post');
     $option = JRequest::getVar('option', 'com_redshop');
     $Itemid = JRequest::getVar('Itemid');
     $shop_id = JRequest::getVar('shop_id');
     $gls_mobile = JRequest::getVar('gls_mobile');
     $customer_message = JRequest::getVar('rs_customer_message_ta');
     $referral_code = JRequest::getVar('txt_referral_code');
     if ($gls_mobile) {
         $shop_id = $shop_id . '###' . $gls_mobile;
     }
     $user = JFactory::getUser();
     $session = JFactory::getSession();
     $auth = $session->get('auth');
     if (!$user->id && $auth['users_info_id']) {
         $user->id = -$auth['users_info_id'];
     }
     $db = JFactory::getDbo();
     $issplit = $session->get('issplit');
     $url = JURI::root();
     // If user subscribe for the newsletter
     if (isset($post['newsletter_signup']) && $post['newsletter_signup'] == 1) {
         $this->_userhelper->newsletterSubscribe();
     }
     // If user unsubscribe for the newsletter
     if (isset($post['newsletter_signoff']) && $post['newsletter_signoff'] == 1) {
         $this->_userhelper->newsletterUnsubscribe();
     }
     $order_paymentstatus = 'Unpaid';
     $objshipping = new shipping();
     $users_info_id = JRequest::getInt('users_info_id');
     $thirdparty_email = JRequest::getVar('thirdparty_email');
     $shippingaddresses = $this->shipaddress($users_info_id);
     $billingaddresses = $this->billingaddresses();
     if (isset($shippingaddresses)) {
         $d["shippingaddress"] = $shippingaddresses;
         $d["shippingaddress"]->country_2_code = $redconfig->getCountryCode2($d["shippingaddress"]->country_code);
         $d["shippingaddress"]->state_2_code = $redconfig->getStateCode2($d["shippingaddress"]->state_code);
         $shippingaddresses->country_2_code = $d["shippingaddress"]->country_2_code;
         $shippingaddresses->state_2_code = $d["shippingaddress"]->state_2_code;
     }
     if (isset($billingaddresses)) {
         $d["billingaddress"] = $billingaddresses;
         if (isset($billingaddresses->country_code)) {
             $d["billingaddress"]->country_2_code = $redconfig->getCountryCode2($billingaddresses->country_code);
             $billingaddresses->country_2_code = $d["billingaddress"]->country_2_code;
         }
         if (isset($billingaddresses->state_code)) {
             $d["billingaddress"]->state_2_code = $redconfig->getStateCode2($billingaddresses->state_code);
             $billingaddresses->state_2_code = $d["billingaddress"]->state_2_code;
         }
     }
     $cart = $session->get('cart');
     if ($cart['idx'] < 1) {
         $msg = JText::_('COM_REDSHOP_EMPTY_CART');
         $app->Redirect('index.php?option=' . $option . '&Itemid=' . $Itemid, $msg);
     }
     $ccdata = $session->get('ccdata');
     $shipping_rate_id = '';
     if ($cart['free_shipping'] != 1) {
         $shipping_rate_id = JRequest::getVar('shipping_rate_id');
     }
     $payment_method_id = JRequest::getVar('payment_method_id');
     $ccinfo = JRequest::getVar('ccinfo');
     if ($shipping_rate_id && $cart['free_shipping'] != 1) {
         $shipArr = $this->calculateShipping($shipping_rate_id);
         $cart['shipping'] = $shipArr['order_shipping_rate'];
         $cart['shipping_vat'] = $shipArr['shipping_vat'];
     }
     $cart = $this->_carthelper->modifyDiscount($cart);
     $paymentinfo = $this->_order_functions->getPaymentMethodInfo($payment_method_id);
     $paymentinfo = $paymentinfo[0];
     $paymentparams = new JRegistry($paymentinfo->params);
     $paymentinfo = new stdclass();
     $paymentinfo->payment_price = $paymentparams->get('payment_price', '');
     $paymentinfo->payment_oprand = $paymentparams->get('payment_oprand', '');
     $paymentinfo->payment_discount_is_percent = $paymentparams->get('payment_discount_is_percent', '');
     if (PAYMENT_CALCULATION_ON == 'subtotal') {
         $paymentAmount = $cart['product_subtotal'];
     } else {
         $paymentAmount = $cart['total'];
     }
     $paymentArray = $this->_carthelper->calculatePayment($paymentAmount, $paymentinfo, $cart['total']);
     $cart['total'] = $paymentArray[0];
     $cart = $session->set('cart', $cart);
     $cart = $session->get('cart');
     $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $shipping_rate_id)));
     $order_status = 'P';
     $order_status_full = $this->_order_functions->getOrderStatusTitle('P');
     // Start code to track duplicate order number checking by parth
     $order_number = $this->getOrdernumber();
     // End code to track duplicate order number checking by parth
     $order_subtotal = $cart['product_subtotal'];
     $cdiscount = $cart['coupon_discount'];
     $order_tax = $cart['tax'];
     $d['order_tax'] = $order_tax;
     $tax_after_discount = 0;
     if (isset($cart['tax_after_discount'])) {
         $tax_after_discount = $cart['tax_after_discount'];
     }
     $odiscount = $cart['coupon_discount'] + $cart['voucher_discount'] + $cart['cart_discount'];
     $odiscount_vat = $cart['discount_vat'];
     $d["order_payment_trans_id"] = '';
     $d['discount'] = $odiscount;
     $order_total = $cart['total'];
     if ($issplit) {
         $order_total = $order_total / 2;
     }
     JRequest::setVar('order_ship', $order_shipping[3]);
     $paymentmethod = $this->_order_functions->getPaymentMethodInfo($payment_method_id);
     $paymentmethod = $paymentmethod[0];
     $mainelement = $paymentmethod->element;
     if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_banktransfer2" || $paymentmethod->element == "rs_payment_banktransfer3" || $paymentmethod->element == "rs_payment_banktransfer4" || $paymentmethod->element == "rs_payment_banktransfer5" || $paymentmethod->element == "rs_payment_cashtransfer" || $paymentmethod->element == "rs_payment_cashsale" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_eantransfer") {
         $paymentmethod = $order_functions->getPaymentMethodInfo($paymentmethod->element);
         $paymentmethod = $paymentmethod[0];
         $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml';
         $paymentparams = new JRegistry($paymentmethod->params);
         $order_main_status = $paymentparams->get('verify_status', '');
         if ($paymentmethod->element != "rs_payment_banktransfer" && $paymentmethod->element != "rs_payment_cashtransfer" && $paymentmethod->element != "rs_payment_cashsale" && $paymentmethod->element != "rs_payment_banktransfer_discount" && $paymentmethod->element != "rs_payment_eantransfer") {
             $paymentmethod->element = substr($paymentmethod->element, 0, -1);
         }
     }
     if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_cashtransfer" || $paymentmethod->element == "rs_payment_cashsale" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_eantransfer") {
         $order_status = $order_main_status;
         if ($issplit) {
             $order_paymentstatus = trim("Partial Paid");
         } else {
             $order_paymentstatus = trim("Unpaid");
         }
         $order_status_full = $this->_order_functions->getOrderStatusTitle($order_main_status);
     }
     $paymentmethod->element = $mainelement;
     $payment_amount = 0;
     if (isset($cart['payment_amount'])) {
         $payment_amount = $cart['payment_amount'];
     }
     $payment_oprand = "";
     if (isset($cart['payment_oprand'])) {
         $payment_oprand = $cart['payment_oprand'];
     }
     $xmlpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml';
     $params = new JRegistry($paymentmethod->params, $xmlpath);
     $economic_payment_terms_id = $params->get('economic_payment_terms_id');
     $economic_design_layout = $params->get('economic_design_layout');
     $is_creditcard = $params->get('is_creditcard', '');
     $is_redirected = $params->get('is_redirected', 0);
     JRequest::setVar('payment_status', $order_paymentstatus);
     $d['order_shipping'] = $order_shipping[3];
     $GLOBALS['billingaddresses'] = $billingaddresses;
     $timestamp = time();
     // Get the IP Address
     if (!empty($_SERVER['REMOTE_ADDR'])) {
         $ip = $_SERVER['REMOTE_ADDR'];
     } else {
         $ip = 'unknown';
     }
     $row = $this->getTable('order_detail');
     if (!$row->bind($post)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $shippingVatRate = 0;
     if (array_key_exists(6, $order_shipping)) {
         $shippingVatRate = $order_shipping[6];
     }
     $random_gen_enc_key = $this->_order_functions->random_gen_enc_key(35);
     $users_info_id = $billingaddresses->users_info_id;
     $row->user_id = $user->id;
     $row->order_number = $order_number;
     $row->user_info_id = $users_info_id;
     $row->order_total = $order_total;
     $row->order_subtotal = $order_subtotal;
     $row->order_tax = $order_tax;
     $row->tax_after_discount = $tax_after_discount;
     $row->order_tax_details = '';
     $row->analytics_status = 0;
     $row->order_shipping = $order_shipping[3];
     $row->order_shipping_tax = $shippingVatRate;
     $row->coupon_discount = $cdiscount;
     $row->shop_id = $shop_id;
     $row->customer_message = $customer_message;
     $row->referral_code = $referral_code;
     $db = JFactory::getDbo();
     $dispatcher = JDispatcher::getInstance();
     $order_status_log = '';
     // For credit card payment gateway page will redirect to order detail page from plugin
     if ($is_creditcard == 1 && $is_redirected == 1) {
         $redirect_ccdata = $session->set('redirect_ccdata', $ccdata);
     }
     if ($is_creditcard == 1 && $is_redirected == 0 && $cart['total'] > 0) {
         JPluginHelper::importPlugin('redshop_payment');
         $values['order_shipping'] = $d['order_shipping'];
         $values['order_number'] = $order_number;
         $values['order_tax'] = $d['order_tax'];
         $values['shippinginfo'] = $d['shippingaddress'];
         $values['billinginfo'] = $d['billingaddress'];
         $values['order_total'] = $order_total;
         $values['order_subtotal'] = $order_subtotal;
         $values["order_id"] = $order_id;
         $values['payment_plugin'] = $paymentmethod->element;
         $values['odiscount'] = $odiscount;
         $paymentResponses = $dispatcher->trigger('onPrePayment_' . $values['payment_plugin'], array($values['payment_plugin'], $values));
         $paymentResponse = $paymentResponses[0];
         if ($paymentResponse->responsestatus == "Success") {
             $d["order_payment_trans_id"] = $paymentResponse->transaction_id;
             $order_status_log = $paymentResponse->message;
             $order_status = 'C';
             $order_paymentstatus = 'Paid';
         } else {
             if ($values['payment_plugin'] != 'rs_payment_localcreditcard') {
                 $errorMsg = $paymentResponse->message;
                 $this->setError($errorMsg);
                 return false;
             }
         }
     }
     if ($order_total <= 0) {
         $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml';
         $paymentparams = new JRegistry($paymentmethod->params);
         $order_main_status = $paymentparams->get('verify_status', '');
         $order_status = $order_main_status;
         $order_paymentstatus = 'Paid';
     }
     if (USE_AS_CATALOG) {
         $order_status = 'P';
         $order_paymentstatus = 'Unpaid';
     }
     // For barcode generation
     $barcode_code = $order_functions->barcode_randon_number(12, 0);
     // End
     $row->order_discount = $odiscount;
     $row->order_discount_vat = $odiscount_vat;
     $row->payment_discount = $payment_amount;
     $row->payment_oprand = $payment_oprand;
     $row->order_status = $order_status;
     $row->order_payment_status = $order_paymentstatus;
     $row->cdate = $timestamp;
     $row->mdate = $timestamp;
     $row->ship_method_id = $shipping_rate_id;
     $row->customer_note = $post['customer_note'];
     $row->requisition_number = $post['requisition_number'];
     $row->ip_address = $ip;
     $row->encr_key = $random_gen_enc_key;
     $row->split_payment = $issplit;
     $row->discount_type = $this->discount_type;
     $row->order_id = JRequest::getVar('order_id', $row->order_id);
     $row->barcode = $barcode_code;
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         // Start code to track duplicate order number checking by parth
         $this->deleteOrdernumberTrack();
         // End code to track duplicate order number checking by parth
         return false;
     }
     // Start code to track duplicate order number checking by parth
     $this->deleteOrdernumberTrack();
     // End code to track duplicate order number checking by parth
     $order_id = $row->order_id;
     $this->coupon($cart, $order_id);
     $this->voucher($cart, $order_id);
     $query = "UPDATE `#__redshop_orders` SET discount_type = " . $db->quote($this->discount_type) . " where order_id = " . (int) $order_id;
     $db->setQuery($query);
     $db->query();
     if (SHOW_TERMS_AND_CONDITIONS == 1 && isset($post['termscondition']) && $post['termscondition'] == 1) {
         $this->_userhelper->updateUserTermsCondition($users_info_id, 1);
     }
     // Place order id in quotation table if it Quotation
     if (array_key_exists("quotation_id", $cart) && $cart['quotation_id']) {
         $quotationHelper->updateQuotationwithOrder($cart['quotation_id'], $row->order_id);
     }
     if ($row->order_status == CLICKATELL_ORDER_STATUS) {
         $helper->clickatellSMS($order_id);
     }
     $session->set('order_id', $order_id);
     // Add order status log
     $rowOrderStatus = $this->getTable('order_status_log');
     $rowOrderStatus->order_id = $order_id;
     $rowOrderStatus->order_status = $order_status;
     $rowOrderStatus->date_changed = time();
     $rowOrderStatus->customer_note = $order_status_log;
     $rowOrderStatus->store();
     $country_name = $this->_order_functions->getCountryName($billingaddresses->country_code);
     $state_name = $this->_order_functions->getStateName($billingaddresses->state_code, $billingaddresses->country_code);
     JRequest::setVar('order_id', $row->order_id);
     JRequest::setVar('order_number', $row->order_number);
     if (!isset($order_shipping[5])) {
         $order_shipping[5] = "";
     }
     if ($order_shipping[5] == 'regular') {
         $regDel = $objshipping->getRegularDelivery();
         JRequest::setVar('order_delivery', "Delivered in one instance � DELIVERY TIME: " . current($regDel) . " weeks</td>");
     } elseif ($order_shipping[5] == 'split') {
         $delArray = $objshipping->getProductDeliveryArray($shipping_rate_id);
         $splitdel = $objshipping->getSplitDelivery();
         if (count($splitdel) > 1) {
             $split1 = $splitdel[0];
             $split2 = $splitdel[1];
             $prods1 = '';
             $prods2 = '';
             for ($i = 0; $i < count($split1); $i++) {
                 $value = current($split1);
                 $deltime1 = $value;
                 $key = key($split1);
                 $product = $this->_producthelper->getProductById($key, "product_name");
                 $prods1 .= $product->product_name . ',';
                 next($split1);
             }
             for ($i = 0; $i < count($split2); $i++) {
                 $value = current($split2);
                 $deltime2 = $value;
                 $key = key($split2);
                 $product = $this->_producthelper->getProductById($key, "product_name");
                 $prods2 .= $product->product_name . ',';
                 next($split2);
             }
             $prods1 = trim($prods1, ",");
             $prods2 = trim($prods2, ",");
         }
         JRequest::setVar('order_delivery', "Delivered over two instances for " . SPLIT_DELIVERY_COST . "kr extra    DELIVERY TIME: " . $deltime1 . " Weeks for " . $prods1 . "   AND   " . $deltime2 . " Weeks for " . $prods2 . " ");
     } else {
         $delArray = $objshipping->getProductDeliveryArray($shipping_rate_id);
         $splitdel = $objshipping->getSplitDelivery();
         $split1 = $splitdel[0];
         $value = current($split1);
         $product_delivery_time = $this->_producthelper->getProductMinDeliveryTime($cart[0]['product_id']);
         JRequest::setVar('order_delivery', $product_delivery_time);
     }
     $idx = $cart['idx'];
     $product_name = "";
     $product_note = "";
     $product_price = "";
     $product_quantity = "";
     $product_total_price = "";
     for ($i = 0; $i < $idx; $i++) {
         // GiftCARD start
         $is_giftcard = 0;
         $giftcard_price = 0;
         $giftcard_name = 0;
         // GiftCARD end
         $product_id = $cart[$i]['product_id'];
         $product = $this->_producthelper->getProductById($product_id);
         $rowitem = $this->getTable('order_item_detail');
         // The redCRM product purchase price
         if ($helper->isredCRM()) {
             $crmProductHelper = new crmProductHelper();
             $crmproduct = $crmProductHelper->getProductById($product_id);
             $rowitem->product_purchase_price = $crmproduct->product_purchase_price > 0 ? $crmproduct->product_purchase_price : $crmproduct->product_price;
             $crmdata = array();
             $crmDebitorHelper = new crmDebitorHelper();
             $crmDebitorHelper_values = $crmDebitorHelper->getShippingDestination(0, 0, $shippingaddresses->users_info_id);
             if ($session->get('isredcrmuser')) {
                 $crmDebitorHelper_contact_values = $crmDebitorHelper->getContactPersons(0, 0, 0, $user->id, 0);
             } else {
                 $crmDebitorHelper_contact_values = $crmDebitorHelper->getContactPersons(0, 0, 0, 0, $crmDebitorHelper_values[0]->shipping_id);
             }
             $crmdata['order_id'] = JRequest::getVar('order_id', $row->order_id);
             $crmdata['debitor_id'] = $shippingaddresses->users_info_id;
             $crmdata['custom_status'] = '';
             $crmdata['rma_number'] = '';
             if (count($crmDebitorHelper_values) > 0) {
                 $crmdata['shipping_id'] = $crmDebitorHelper_values[0]->shipping_id;
             } else {
                 $crmdata['shipping_id'] = 0;
             }
             if (count($crmDebitorHelper_contact_values) > 0 && count($crmDebitorHelper_values) > 0) {
                 $crmdata['person_id'] = $crmDebitorHelper_contact_values[0]->person_id;
             } else {
                 $crmdata['person_id'] = 0;
             }
             $crmOrderHelper = new crmOrderHelper();
             $crmOrderHelper->storeCRMOrder($crmdata);
         }
         // End
         if (!$rowitem->bind($post)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         if ($order_shipping[5] == 'regular') {
             $rowitem->delivery_time = $regDel;
         } elseif ($order_shipping[5] == 'split') {
             $rowitem->delivery_time = $delArray[$product_id];
         } else {
             $rowitem->delivery_time = '';
         }
         if (isset($cart[$i]['giftcard_id']) && $cart[$i]['giftcard_id']) {
             $is_giftcard = 1;
         }
         // Product stockroom update
         if (!$is_giftcard) {
             $updatestock = $stockroomhelper->updateStockroomQuantity($product_id, $cart[$i]['quantity']);
             $stockroom_id_list = $updatestock['stockroom_list'];
             $stockroom_quantity_list = $updatestock['stockroom_quantity_list'];
             $rowitem->stockroom_id = $stockroom_id_list;
             $rowitem->stockroom_quantity = $stockroom_quantity_list;
         }
         // End product stockroom update
         $vals = explode('product_attributes/', $cart[$i]['hidden_attribute_cartimage']);
         if (!empty($cart[$i]['attributeImage']) && file_exists(JPATH_ROOT . '/components/com_redshop/assets/images/mergeImages/' . $cart[$i]['attributeImage'])) {
             $rowitem->attribute_image = $order_id . $cart[$i]['attributeImage'];
             $old_media = JPATH_ROOT . '/components/com_redshop/assets/images/mergeImages/' . $cart[$i]['attributeImage'];
             $new_media = JPATH_ROOT . '/components/com_redshop/assets/images/orderMergeImages' . $rowitem->attribute_image;
             copy($old_media, $new_media);
         } elseif (!empty($vals[1])) {
             $rowitem->attribute_image = $vals[1];
         }
         $wrapper_price = 0;
         if (@$cart[$i]['wrapper_id']) {
             $wrapper_price = $cart[$i]['wrapper_price'];
         }
         if ($is_giftcard == 1) {
             $giftcardData = $this->_producthelper->getGiftcardData($cart[$i]['giftcard_id']);
             $rowitem->product_id = $cart[$i]['giftcard_id'];
             $rowitem->order_item_name = $giftcardData->giftcard_name;
             $rowitem->product_item_old_price = $cart[$i]['product_price'];
         } else {
             $rowitem->product_id = $product_id;
             $rowitem->product_item_old_price = $cart[$i]['product_old_price'];
             $rowitem->supplier_id = $product->manufacturer_id;
             $rowitem->order_item_sku = $product->product_number;
             $rowitem->order_item_name = $product->product_name;
         }
         $rowitem->product_item_price = $cart[$i]['product_price'];
         $rowitem->product_quantity = $cart[$i]['quantity'];
         $rowitem->product_item_price_excl_vat = $cart[$i]['product_price_excl_vat'];
         $rowitem->product_final_price = $cart[$i]['product_price'] * $cart[$i]['quantity'];
         $rowitem->is_giftcard = $is_giftcard;
         $retAttArr = $this->_producthelper->makeAttributeCart($cart[$i]['cart_attribute'], $product_id, 0, 0, $cart[$i]['quantity']);
         $cart_attribute = $retAttArr[0];
         // For discount calc data
         $cart_calc_data = "";
         if (isset($cart[$i]['discount_calc_output'])) {
             $cart_calc_data = $cart[$i]['discount_calc_output'];
         }
         // End
         $retAccArr = $this->_producthelper->makeAccessoryCart($cart[$i]['cart_accessory'], $product_id);
         $cart_accessory = $retAccArr[0];
         $rowitem->order_id = $order_id;
         $rowitem->user_info_id = $users_info_id;
         $rowitem->order_item_currency = REDCURRENCY_SYMBOL;
         $rowitem->order_status = $order_status;
         $rowitem->cdate = $timestamp;
         $rowitem->mdate = $timestamp;
         $rowitem->product_attribute = $cart_attribute;
         $rowitem->discount_calc_data = $cart_calc_data;
         $rowitem->product_accessory = $cart_accessory;
         $rowitem->container_id = $objshipping->getProductContainerId($cart[$i]['product_id']);
         $rowitem->wrapper_price = $wrapper_price;
         if (!empty($cart[$i]['wrapper_id'])) {
             $rowitem->wrapper_id = $cart[$i]['wrapper_id'];
         }
         if (!empty($cart[$i]['reciver_email'])) {
             $rowitem->giftcard_user_email = $cart[$i]['reciver_email'];
         }
         if (!empty($cart[$i]['reciver_name'])) {
             $rowitem->giftcard_user_name = $cart[$i]['reciver_name'];
         }
         if ($this->_producthelper->checkProductDownload($rowitem->product_id)) {
             $medianame = $this->_producthelper->getProductMediaName($rowitem->product_id);
             for ($j = 0; $j < count($medianame); $j++) {
                 $product_serial_number = $this->_producthelper->getProdcutSerialNumber($rowitem->product_id);
                 $this->_producthelper->insertProductDownload($rowitem->product_id, $user->id, $rowitem->order_id, $medianame[$j]->media_name, $product_serial_number->serial_number);
             }
         }
         // Import files for plugin
         JPluginHelper::importPlugin('redshop_product');
         if (!$rowitem->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // Add plugin support
         $dispatcher->trigger('afterOrderItemSave', array($cart, $rowitem, $i));
         // End
         if (isset($cart[$i]['giftcard_id']) && $cart[$i]['giftcard_id']) {
             $section_id = 13;
         } else {
             $section_id = 12;
         }
         $this->_producthelper->insertProdcutUserfield($i, $cart, $rowitem->order_item_id, $section_id);
         // My accessory save in table start
         if (count($cart[$i]['cart_accessory']) > 0) {
             $setPropEqual = true;
             $setSubpropEqual = true;
             $attArr = $cart[$i]['cart_accessory'];
             for ($a = 0; $a < count($attArr); $a++) {
                 $accessory_vat_price = 0;
                 $accessory_attribute = "";
                 $accessory_id = $attArr[$a]['accessory_id'];
                 $accessory_name = $attArr[$a]['accessory_name'];
                 $accessory_price = $attArr[$a]['accessory_price'];
                 $accessory_quantity = $attArr[$a]['accessory_quantity'];
                 $accessory_org_price = $accessory_price;
                 if ($accessory_price > 0) {
                     $accessory_vat_price = $this->_producthelper->getProductTax($rowitem->product_id, $accessory_price);
                 }
                 $attchildArr = $attArr[$a]['accessory_childs'];
                 for ($j = 0; $j < count($attchildArr); $j++) {
                     $prooprand = array();
                     $proprice = array();
                     $attribute_id = $attchildArr[$j]['attribute_id'];
                     $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>";
                     $rowattitem = $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $attribute_id;
                     $rowattitem->section = "attribute";
                     $rowattitem->parent_section_id = $accessory_id;
                     $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                     $rowattitem->is_accessory_att = 1;
                     if ($attribute_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $propArr = $attchildArr[$j]['attribute_childs'];
                     for ($k = 0; $k < count($propArr); $k++) {
                         $prooprand[$k] = $propArr[$k]['property_oprand'];
                         $proprice[$k] = $propArr[$k]['property_price'];
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $this->_producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>";
                         $subpropArr = $propArr[$k]['property_childs'];
                         $rowattitem = $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 1;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $this->_producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>";
                             $rowattitem = $this->getTable('order_attribute_item');
                             $rowattitem->order_att_item_id = 0;
                             $rowattitem->order_item_id = $rowitem->order_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 1;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                     // FOR ACCESSORY PROPERTY AND SUBPROPERTY PRICE CALCULATION
                     if ($setPropEqual && $setSubpropEqual) {
                         $accessory_priceArr = $this->_producthelper->makeTotalPriceByOprand($accessory_price, $prooprand, $proprice);
                         $setPropEqual = $accessory_priceArr[0];
                         $accessory_price = $accessory_priceArr[1];
                     }
                     for ($t = 0; $t < count($propArr); $t++) {
                         $subprooprand = array();
                         $subproprice = array();
                         $subElementArr = $propArr[$t]['property_childs'];
                         for ($tp = 0; $tp < count($subElementArr); $tp++) {
                             $subprooprand[$tp] = $subElementArr[$tp]['subproperty_oprand'];
                             $subproprice[$tp] = $subElementArr[$tp]['subproperty_price'];
                         }
                         if ($setPropEqual && $setSubpropEqual) {
                             $accessory_priceArr = $this->_producthelper->makeTotalPriceByOprand($accessory_price, $subprooprand, $subproprice);
                             $setSubpropEqual = $accessory_priceArr[0];
                             $accessory_price = $accessory_priceArr[1];
                         }
                     }
                     // FOR ACCESSORY PROPERTY AND SUBPROPERTY PRICE CALCULATION
                 }
                 $accdata = $this->getTable('accessory_detail');
                 if ($accessory_id > 0) {
                     $accdata->load($accessory_id);
                 }
                 $accProductinfo = $this->_producthelper->getProductById($accdata->child_product_id);
                 $rowaccitem = $this->getTable('order_acc_item');
                 $rowaccitem->order_item_acc_id = 0;
                 $rowaccitem->order_item_id = $rowitem->order_item_id;
                 $rowaccitem->product_id = $accessory_id;
                 $rowaccitem->order_acc_item_sku = $accProductinfo->product_number;
                 $rowaccitem->order_acc_item_name = $accessory_name;
                 $rowaccitem->order_acc_price = $accessory_org_price;
                 $rowaccitem->order_acc_vat = $accessory_vat_price;
                 $rowaccitem->product_quantity = $accessory_quantity;
                 $rowaccitem->product_acc_item_price = $accessory_price;
                 $rowaccitem->product_acc_final_price = $accessory_price * $accessory_quantity;
                 $rowaccitem->product_attribute = $accessory_attribute;
                 if ($accessory_id > 0) {
                     if (!$rowaccitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
             }
         }
         // My attribute save in table start
         if (count($cart[$i]['cart_attribute']) > 0) {
             $attchildArr = $cart[$i]['cart_attribute'];
             for ($j = 0; $j < count($attchildArr); $j++) {
                 $attribute_id = $attchildArr[$j]['attribute_id'];
                 $rowattitem = $this->getTable('order_attribute_item');
                 $rowattitem->order_att_item_id = 0;
                 $rowattitem->order_item_id = $rowitem->order_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $rowitem->product_id;
                 $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                 $rowattitem->is_accessory_att = 0;
                 if ($attribute_id > 0) {
                     if (!$rowattitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
                 $propArr = $attchildArr[$j]['attribute_childs'];
                 if (count($propArr) > 0) {
                     for ($k = 0; $k < count($propArr); $k++) {
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         //  Product property STOCKROOM update start
                         $updatestock_att = $stockroomhelper->updateStockroomQuantity($property_id, $cart[$i]['quantity'], "property", $product_id);
                         $stockroom_att_id_list = $updatestock_att['stockroom_list'];
                         $stockroom_att_quantity_list = $updatestock_att['stockroom_quantity_list'];
                         $rowattitem = $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 0;
                         $rowattitem->stockroom_id = $stockroom_att_id_list;
                         $rowattitem->stockroom_quantity = $stockroom_att_quantity_list;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         $subpropArr = $propArr[$k]['property_childs'];
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             // Product subproperty STOCKROOM update start
                             $updatestock_subatt = $stockroomhelper->updateStockroomQuantity($subproperty_id, $cart[$i]['quantity'], "subproperty", $product_id);
                             $stockroom_subatt_id_list = $updatestock_subatt['stockroom_list'];
                             $stockroom_subatt_quantity_list = $updatestock_subatt['stockroom_quantity_list'];
                             $rowattitem = $this->getTable('order_attribute_item');
                             $rowattitem->order_att_item_id = 0;
                             $rowattitem->order_item_id = $rowitem->order_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 0;
                             $rowattitem->stockroom_id = $stockroom_subatt_id_list;
                             $rowattitem->stockroom_quantity = $stockroom_subatt_quantity_list;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Subtracting the products from the container. means decreasing stock
         if (USE_CONTAINER) {
             $this->_producthelper->updateContainerStock($product_id, $cart[$i]['quantity'], $rowitem->container_id);
         }
         // Subtracting the products from the container. means decreasing stock end
         // Store user product subscription detail
         if ($product->product_type == 'subscription') {
             $subscribe = $this->getTable('product_subscribe_detail');
             $subscription_detail = $this->_producthelper->getProductSubscriptionDetail($product_id, $cart[$i]['subscription_id']);
             $add_day = $subscription_detail->period_type == 'days' ? $subscription_detail->subscription_period : 0;
             $add_month = $subscription_detail->period_type == 'month' ? $subscription_detail->subscription_period : 0;
             $add_year = $subscription_detail->period_type == 'year' ? $subscription_detail->subscription_period : 0;
             $subscribe->order_id = $order_id;
             $subscribe->order_item_id = $rowitem->order_item_id;
             $subscribe->product_id = $product_id;
             $subscribe->subscription_id = $cart[$i]['subscription_id'];
             $subscribe->user_id = $user->id;
             $subscribe->start_date = time();
             $subscribe->end_date = mktime(0, 0, 0, date('m') + $add_month, date('d') + $add_day, date('Y') + $add_year);
             if (!$subscribe->store()) {
                 $this->setError($this->_db->getErrorMsg());
                 return false;
             }
         }
     }
     $rowpayment = $this->getTable('order_payment');
     if (!$rowpayment->bind($post)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $rowpayment->order_id = $order_id;
     $rowpayment->payment_method_id = $payment_method_id;
     if (!isset($ccdata['creditcard_code'])) {
         $ccdata['creditcard_code'] = 0;
     }
     if (!isset($ccdata['order_payment_number'])) {
         $ccdata['order_payment_number'] = 0;
     }
     if (!isset($ccdata['order_payment_expire_month'])) {
         $ccdata['order_payment_expire_month'] = 0;
     }
     if (!isset($ccdata['order_payment_expire_year'])) {
         $ccdata['order_payment_expire_year'] = 0;
     }
     $rowpayment->order_payment_code = $ccdata['creditcard_code'];
     $rowpayment->order_payment_cardname = base64_encode($ccdata['order_payment_name']);
     $rowpayment->order_payment_number = base64_encode($ccdata['order_payment_number']);
     // This is ccv code
     $rowpayment->order_payment_ccv = base64_encode($ccdata['credit_card_code']);
     $rowpayment->order_payment_amount = $order_total;
     $rowpayment->order_payment_expire = $ccdata['order_payment_expire_month'] . $ccdata['order_payment_expire_year'];
     $rowpayment->order_payment_name = $paymentmethod->name;
     $rowpayment->payment_method_class = $paymentmethod->element;
     $rowpayment->order_payment_trans_id = $d["order_payment_trans_id"];
     $rowpayment->authorize_status = "";
     if (!$rowpayment->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // For authorize status
     JPluginHelper::importPlugin('redshop_payment');
     $dispatcher = JDispatcher::getInstance();
     $data = $dispatcher->trigger('onAuthorizeStatus_' . $paymentmethod->element, array($paymentmethod->element, $order_id));
     $GLOBALS['shippingaddresses'] = $shippingaddresses;
     // Add billing Info
     $userrow = $this->getTable('user_detail');
     $userrow->load($billingaddresses->users_info_id);
     $userrow->thirdparty_email = $post['thirdparty_email'];
     $orderuserrow = $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $order_id;
     $orderuserrow->address_type = 'BT';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add shipping Info
     $userrow = $this->getTable('user_detail');
     if (isset($shippingaddresses->users_info_id)) {
         $userrow->load($shippingaddresses->users_info_id);
     }
     $orderuserrow = $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $order_id;
     $orderuserrow->address_type = 'ST';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $checkOrderStatus = 1;
     if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_banktransfer2" || $paymentmethod->element == "rs_payment_banktransfer3" || $paymentmethod->element == "rs_payment_banktransfer4" || $paymentmethod->element == "rs_payment_banktransfer5") {
         $checkOrderStatus = 0;
     }
     if (isset($cart['extrafields_values'])) {
         if (count($cart['extrafields_values']) > 0) {
             $this->_producthelper->insertPaymentShippingField($cart, $order_id, 18);
             $this->_producthelper->insertPaymentShippingField($cart, $order_id, 19);
         }
     }
     // Economic Integration start for invoice generate and book current invoice
     if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) {
         $economic = new economic();
         $economicdata['split_payment'] = $issplit;
         $economicdata['economic_payment_terms_id'] = $economic_payment_terms_id;
         $economicdata['economic_design_layout'] = $economic_design_layout;
         $economicdata['economic_is_creditcard'] = $is_creditcard;
         $payment_name = $paymentmethod->element;
         $paymentArr = explode("rs_payment_", $paymentmethod->element);
         if (count($paymentArr) > 0) {
             $payment_name = $paymentArr[1];
         }
         $economicdata['economic_payment_method'] = $payment_name;
         $invoiceHandle = $economic->createInvoiceInEconomic($row->order_id, $economicdata);
         if (ECONOMIC_INVOICE_DRAFT == 0) {
             $bookinvoicepdf = $economic->bookInvoiceInEconomic($row->order_id, $checkOrderStatus);
             if (is_file($bookinvoicepdf)) {
                 $ret = $this->_redshopMail->sendEconomicBookInvoiceMail($row->order_id, $bookinvoicepdf);
             }
         }
     }
     // End Economic
     // Send the Order mail before payment
     if (!ORDER_MAIL_AFTER || ORDER_MAIL_AFTER && $row->order_payment_status == "Paid") {
         $this->_redshopMail->sendOrderMail($row->order_id);
     } else {
         // If Order mail set to send after payment then send mail to administrator only.
         $this->_redshopMail->sendOrderMail($row->order_id, true);
     }
     if ($row->order_status == "C") {
         $this->_order_functions->SendDownload($row->order_id);
     }
     // RedCRM includes
     if ($helper->isredCRM()) {
         if (ENABLE_ITEM_TRACKING_SYSTEM) {
             // Supplier order helper object
             $crmSupplierOrderHelper = new crmSupplierOrderHelper();
             $getStatus = array();
             $getStatus['orderstatus'] = $row->order_status;
             $getStatus['paymentstatus'] = $row->order_payment_status;
             $crmSupplierOrderHelper->redSHOPOrderUpdate($row->order_id, $getStatus);
             unset($getStatus);
         }
     }
     return $row;
 }
コード例 #9
0
ファイル: order.php プロジェクト: jaanusnurmoja/redjoomla
 public function export_fullorder_data()
 {
     $extrafile = JPATH_SITE . '/administrator/components/com_redshop/extras/order_export.php';
     if (file_exists($extrafile)) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . '/extras/order_export.php';
         $orderExport = new orderExport();
         $orderExport->createOrderExport();
         exit;
     }
     $producthelper = new producthelper();
     $order_function = new order_functions();
     $model = $this->getModel('order');
     $data = $model->export_data();
     $product_count = array();
     $db = JFactory::getDbo();
     $cid = JRequest::getVar('cid', array(0), 'method', 'array');
     $order_id = implode(',', $cid);
     $where = "";
     $sql = "SELECT order_id,count(order_item_id) as noproduct FROM `#__redshop_order_item`  " . $where . " GROUP BY order_id";
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Content-type: text/x-csv");
     header("Content-type: text/csv");
     header("Content-type: application/csv");
     header('Content-Disposition: attachment; filename=Order.csv');
     $db->setQuery($sql);
     $no_products = $db->loadObjectList();
     for ($i = 0; $i < count($data); $i++) {
         $product_count[] = $no_products[$i]->noproduct;
     }
     $no_products = max($product_count);
     $shipping_helper = new shipping();
     ob_clean();
     echo "Order number, Order status, Order date , Shipping method , Shipping user, Shipping address, Shipping postalcode,\n\t\tShipping city, Shipping country, Company name, Email ,Billing address, Billing postalcode, Billing city, Billing country,\n\t\tBilling User ,";
     for ($i = 1; $i <= $no_products; $i++) {
         echo JText::_('COM_REDSHOP_PRODUCT_NAME') . $i . ' ,';
         echo JText::_('COM_REDSHOP_PRODUCT') . ' ' . JText::_('COM_REDSHOP_PRODUCT_PRICE') . $i . ' ,';
         echo JText::_('COM_REDSHOP_PRODUCT_ATTRIBUTE') . $i . ' ,';
     }
     echo "Order Total\n";
     for ($i = 0; $i < count($data); $i++) {
         $billing_info = $order_function->getOrderBillingUserInfo($data[$i]->order_id);
         $details = explode("|", $shipping_helper->decryptShipping(str_replace(" ", "+", $data[$i]->ship_method_id)));
         echo $data[$i]->order_id . ",";
         echo utf8_decode($order_function->getOrderStatusTitle($data[$i]->order_status)) . " ,";
         echo date('d-m-Y H:i', $data[$i]->cdate) . " ,";
         echo str_replace(",", " ", $details[1]) . "(" . str_replace(",", " ", $details[2]) . ") ,";
         $shipping_info = $order_function->getOrderShippingUserInfo($data[$i]->order_id);
         echo str_replace(",", " ", $shipping_info->firstname) . " " . str_replace(",", " ", $shipping_info->lastname) . " ,";
         echo str_replace(",", " ", utf8_decode($shipping_info->address)) . " ,";
         echo $shipping_info->zipcode . " ,";
         echo str_replace(",", " ", utf8_decode($shipping_info->city)) . " ,";
         echo $shipping_info->country_code . " ,";
         echo str_replace(",", " ", $shipping_info->company_name) . " ,";
         echo $shipping_info->user_email . " ,";
         echo str_replace(",", " ", utf8_decode($billing_info->address)) . " ,";
         echo $billing_info->zipcode . " ,";
         echo str_replace(",", " ", utf8_decode($billing_info->city)) . " ,";
         echo $billing_info->country_code . " ,";
         echo str_replace(",", " ", $billing_info->firstname) . " " . str_replace(",", " ", $billing_info->lastname) . " ,";
         $no_items = $order_function->getOrderItemDetail($data[$i]->order_id);
         for ($it = 0; $it < count($no_items); $it++) {
             echo str_replace(",", " ", utf8_decode($no_items[$it]->order_item_name)) . " ,";
             echo "\"" . REDCURRENCY_SYMBOL . "\"" . $no_items[$it]->product_final_price;
             $product_attribute = $producthelper->makeAttributeOrder($no_items[$it]->order_item_id, 0, $no_items[$it]->product_id, 0, 1);
             $product_attribute = strip_tags(str_replace(",", " ", $product_attribute->product_attribute));
             echo trim(utf8_decode($product_attribute)) . " ,";
         }
         $temp = $no_products - count($no_items);
         if ($temp >= 0) {
             echo str_repeat(' ,', $temp * 3);
         }
         echo "\"" . REDCURRENCY_SYMBOL . "\"" . $data[$i]->order_total . "\n";
     }
     exit;
 }
コード例 #10
0
 }
 $replace[] = $statustext . " - " . $orderPaymentStatus;
 $search[] = "{order_status_order_only}";
 $replace[] = $statustext;
 $search[] = "{order_status_payment_only}";
 $replace[] = $orderPaymentStatus;
 $search[] = "{customer_note_lbl}";
 $replace[] = JText::_('COM_REDSHOP_COMMENT');
 $search[] = "{customer_note}";
 $replace[] = $OrdersDetail->customer_note;
 $search[] = "{shipping_method_lbl}";
 $replace[] = JText::_('COM_REDSHOP_SHIPPING_METHOD_LBL');
 $shipping_method = '';
 $shipping_rate_name = '';
 if ($OrdersDetail[0]->ship_method_id != '') {
     $ship_method = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $OrdersDetail[0]->ship_method_id)));
     if (count($ship_method) <= 1) {
         $ship_method = explode("|", $OrdersDetail[0]->ship_method_id);
     }
     $shipping_method = "";
     $shipping_rate_name = "";
     if (count($ship_method) > 0) {
         if (array_key_exists(1, $ship_method)) {
             $shipping_method = $ship_method[1];
         }
         if (array_key_exists(2, $ship_method)) {
             $shipping_rate_name = $ship_method[2];
         }
     }
 }
 $search[] = "{shipping_method}";
コード例 #11
0
ファイル: mail.php プロジェクト: jaanusnurmoja/redjoomla
    public function createMultiprintInvoicePdf($oid)
    {
        require_once JPATH_SITE . '/components/com_redshop/helpers/tcpdf/config/lang/eng.php';
        require_once JPATH_SITE . '/components/com_redshop/helpers/tcpdf/tcpdf.php';
        $order_functions = new order_functions();
        $shippinghelper = new shipping();
        $carthelper = new rsCarthelper();
        $extra_field = new extra_field();
        $redconfig = new Redconfiguration();
        $redTemplate = new Redtemplate();
        $producthelper = new producthelper();
        $message = "";
        $pdfObj = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A5', true, 'UTF-8', false);
        $pdfObj->SetTitle('Shipped');
        $pdfObj->SetAuthor('redSHOP');
        $pdfObj->SetCreator('redSHOP');
        $pdfObj->SetMargins(8, 8, 8);
        // Changed font to support Unicode Characters - Specially Polish Characters
        $font = 'freeserif';
        $pdfObj->setImageScale(PDF_IMAGE_SCALE_RATIO);
        $pdfObj->setHeaderFont(array($font, '', 8));
        // Set font
        $pdfObj->SetFont($font, "", 6);
        $order_id = "";
        for ($o = 0; $o < count($oid); $o++) {
            $body = "";
            $message = "";
            $order_id = $oid[$o];
            $OrderProducts = $order_functions->getOrderItemDetail($order_id);
            $OrdersDetail = $order_functions->getmultiOrderDetails($order_id);
            $billing = $order_functions->getOrderBillingUserInfo($OrdersDetail[0]->order_id);
            $shipping = $order_functions->getOrderShippingUserInfo($OrdersDetail[0]->order_id);
            $is_company = $billing->is_company;
            if (!$shipping) {
                $shipping = $billing;
            }
            $paymentmethod = $order_functions->getOrderPaymentDetail($order_id);
            $paymentmethod = $paymentmethod[0];
            $order_print_template = $redTemplate->getTemplate("order_print");
            if (count($order_print_template) > 0 && $order_print_template[0]->template_desc != "") {
                $ordersprint_template = $order_print_template[0]->template_desc;
            } else {
                $ordersprint_template = '<table style="width: 100%;" border="0" cellpadding="5" cellspacing="0">
				<tbody><tr><td colspan="2"><table style="width: 100%;" border="0" cellpadding="2" cellspacing="0"><tbody>
				<tr style="background-color: #cccccc;"><th align="left">{order_information_lbl}{print}</th></tr><tr></tr
				><tr><td>{order_id_lbl} : {order_id}</td></tr><tr><td>{order_number_lbl} : {order_number}</td></tr><tr>
				<td>{order_date_lbl} : {order_date}</td></tr><tr><td>{order_status_lbl} : {order_status}</td></tr><tr>
				<td>{shipping_method_lbl} : {shipping_method} : {shipping_rate_name}</td></tr><tr><td>{payment_lbl} : {payment_method}</td>
				</tr></tbody></table></td></tr><tr><td colspan="2"><table style="width: 100%;" border="0" cellpadding="2" cellspacing="0">
				<tbody><tr style="background-color: #cccccc;"><th align="left">{billing_address_information_lbl}</th>
				</tr><tr></tr><tr><td>{billing_address}</td></tr></tbody></table></td></tr><tr><td colspan="2">
				<table style="width: 100%;" border="0" cellpadding="2" cellspacing="0"><tbody><tr style="background-color: #cccccc;">
				<th align="left">{shipping_address_info_lbl}</th></tr><tr></tr><tr><td>{shipping_address}</td></tr></tbody>
				</table></td></tr><tr><td colspan="2"><table style="width: 100%;" border="0" cellpadding="2" cellspacing="0">
				<tbody><tr style="background-color: #cccccc;"><th align="left">{order_detail_lbl}</th></tr><tr></tr><tr><td>
				<table style="width: 100%;" border="0" cellpadding="2" cellspacing="2"><tbody><tr><td>{product_name_lbl}</td><td>{note_lbl}</td>
				<td>{price_lbl}</td><td>{quantity_lbl}</td><td align="right">Total Price</td></tr>{product_loop_start}<tr>
				<td><p>{product_name}<br />{product_attribute}{product_accessory}{product_userfields}</p></td>
				<td>{product_wrapper}{product_thumb_image}</td><td>{product_price}</td><td>{product_quantity}</td>
				<td align="right">{product_total_price}</td></tr>{product_loop_end}</tbody></table></td></tr><tr>
				<td></td></tr><tr><td><table style="width: 100%;" border="0" cellpadding="2" cellspacing="2"><tbody>
				<tr align="left"><td align="left"><strong>{order_subtotal_lbl} : </strong></td><td align="right">{order_subtotal}</td>
				</tr>{if vat}<tr align="left"><td align="left"><strong>{vat_lbl} : </strong></td><td align="right">{order_tax}</td>
				</tr>{vat end if}{if discount}<tr align="left"><td align="left"><strong>{discount_lbl} : </strong></td>
				<td align="right">{order_discount}</td></tr>{discount end if}<tr align="left"><td align="left">
				<strong>{shipping_lbl} : </strong></td><td align="right">{order_shipping}</td></tr><tr align="left">
				<td colspan="2" align="left"><hr /></td></tr><tr align="left"><td align="left"><strong>{total_lbl} :</strong>
				</td><td align="right">{order_total}</td></tr><tr align="left"><td colspan="2" align="left"><hr /><br />
				 <hr /></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>';
            }
            $print_tag = "<a onclick='window.print();' title='" . JText::_('COM_REDSHOP_PRINT') . "'>" . "<img src=" . JSYSTEM_IMAGES_PATH . "printButton.png  alt='" . JText::_('COM_REDSHOP_PRINT') . "' title='" . JText::_('COM_REDSHOP_PRINT') . "' /></a>";
            $search[] = "{print}";
            $replace[] = $print_tag;
            $search[] = "{order_id}";
            $replace[] = $OrdersDetail[0]->order_id;
            $search[] = "{order_number}";
            $replace[] = $OrdersDetail[0]->order_number;
            $search[] = "{order_date}";
            $replace[] = $redconfig->convertDateFormat($OrdersDetail[0]->cdate);
            $search[] = "{customer_note}";
            $replace[] = $OrdersDetail[0]->customer_note;
            // Set order paymethod name
            $search[] = "{payment_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_PAYMENT_METHOD');
            $search[] = "{payment_method}";
            $replace[] = $paymentmethod->order_payment_name;
            $statustext = $order_functions->getOrderStatusTitle($OrdersDetail[0]->order_status);
            $issplit = $OrdersDetail[0]->split_payment;
            $search[] = "{order_status}";
            if (trim($OrdersDetail[0]->order_payment_status) == 'Paid') {
                $orderPaymentStatus = JText::_('COM_REDSHOP_PAYMENT_STA_PAID');
            } elseif (trim($OrdersDetail[0]->order_payment_status) == 'Unpaid') {
                $orderPaymentStatus = JText::_('COM_REDSHOP_PAYMENT_STA_UNPAID');
            } elseif (trim($OrdersDetail[0]->order_payment_status) == 'Partial Paid') {
                $orderPaymentStatus = JText::_('COM_REDSHOP_PAYMENT_STA_PARTIAL_PAID');
            } else {
                $orderPaymentStatus = $OrdersDetail[0]->order_payment_status;
            }
            $replace[] = $statustext . " - " . $orderPaymentStatus;
            $search[] = "{order_status_order_only}";
            $replace[] = $statustext;
            $search[] = "{order_status_payment_only}";
            $replace[] = $orderPaymentStatus;
            $search[] = "{customer_note_lbl}";
            $replace[] = JText::_('COM_REDSHOP_COMMENT');
            $search[] = "{customer_note}";
            $replace[] = $OrdersDetail->customer_note;
            $search[] = "{shipping_method_lbl}";
            $replace[] = JText::_('COM_REDSHOP_SHIPPING_METHOD_LBL');
            $shipping_method = '';
            $shipping_rate_name = '';
            if ($OrdersDetail[0]->ship_method_id != '') {
                $ship_method = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $OrdersDetail[0]->ship_method_id)));
                if (count($ship_method) <= 1) {
                    $ship_method = explode("|", $OrdersDetail[0]->ship_method_id);
                }
                $shipping_method = "";
                $shipping_rate_name = "";
                if (count($ship_method) > 0) {
                    if (array_key_exists(1, $ship_method)) {
                        $shipping_method = $ship_method[1];
                    }
                    if (array_key_exists(2, $ship_method)) {
                        $shipping_rate_name = $ship_method[2];
                    }
                }
            }
            $search[] = "{shipping_method}";
            $replace[] = $shipping_method;
            $search[] = "{shipping}";
            $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_shipping);
            $search[] = "{shipping_rate_name}";
            $replace[] = $shipping_rate_name;
            $ordersprint_template = $carthelper->replaceBillingAddress($ordersprint_template, $billing);
            $ordersprint_template = $carthelper->replaceShippingAddress($ordersprint_template, $shipping);
            $product_name = "";
            $product_note = "";
            $product_price = "";
            $product_quantity = "";
            $product_total_price = "";
            $template_start = "";
            $template_middle = "";
            $template_end = "";
            if (strstr($ordersprint_template, "{product_loop_start}")) {
                $template_sdata = explode('{product_loop_start}', $ordersprint_template);
                $template_start = $template_sdata[0];
                $template_edata = explode('{product_loop_end}', $template_sdata[1]);
                $template_end = $template_edata[1];
                $template_middle = $template_edata[0];
            }
            $cart_tr = '';
            for ($i = 0; $i < count($OrderProducts); $i++) {
                $wrapper_name = "";
                if ($OrderProducts[$i]->wrapper_id) {
                    $wrapper = $producthelper->getWrapper($OrderProducts[$i]->product_id, $OrderProducts[$i]->wrapper_id);
                    if (count($wrapper) > 0) {
                        $wrapper_name = JText::_('COM_REDSHOP_WRAPPER') . ":<br/>" . $wrapper[0]->wrapper_name . "(" . $producthelper->getProductFormattedPrice($OrderProducts[$i]->wrapper_price) . ")";
                    }
                }
                if ($OrderProducts[$i]->is_giftcard == 1) {
                    $product_userfields = $producthelper->getuserfield($OrderProducts[$i]->order_item_id, 13);
                } else {
                    $product_userfields = $producthelper->getuserfield($OrderProducts[$i]->order_item_id);
                }
                $product_name = "<div  class='product_name'>" . $OrderProducts[$i]->order_item_name . "</div>";
                $product = $producthelper->getProductById($OrderProducts[$i]->product_id);
                $product_number = $OrderProducts[$i]->order_item_sku;
                $product_note = "<div  class='product_note'>" . $wrapper_name . "</div>";
                $product_total_price = "<div class='product_total_price'>" . $producthelper->getProductFormattedPrice($OrderProducts[$i]->product_final_price) . "</div>";
                $product_price = "<div class='product_price'>" . $producthelper->getProductFormattedPrice($OrderProducts[$i]->product_item_price) . "</div>";
                $product_quantity = '<div class="product_quantity">' . $OrderProducts[$i]->product_quantity . '</div>';
                $cart_mdata = '';
                $uri = JURI::getInstance();
                $url = $uri->root();
                if ($product->product_full_image) {
                    if (is_file(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . $product->product_full_image)) {
                        $product_image_path = $product->product_full_image;
                    } else {
                        if (is_file(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . PRODUCT_DEFAULT_IMAGE)) {
                            $product_image_path = PRODUCT_DEFAULT_IMAGE;
                        } else {
                            $product_image_path = "";
                        }
                    }
                } else {
                    if (is_file(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . PRODUCT_DEFAULT_IMAGE)) {
                        $product_image_path = PRODUCT_DEFAULT_IMAGE;
                    } else {
                        $product_image_path = "";
                    }
                }
                if ($product_image_path) {
                    $thumbUrl = RedShopHelperImages::getImagePath($product_image_path, '', 'thumb', 'product', CART_THUMB_WIDTH, CART_THUMB_HEIGHT, USE_IMAGE_SIZE_SWAPPING);
                    $product_image = '<div  class="product_image"><img src="' . $thumbUrl . '"></div>';
                } else {
                    $product_image = "<div  class='product_image'></div>";
                }
                $cart_mdata = str_replace("{product_name}", $product_name, $template_middle);
                $cart_mdata = str_replace("{product_thumb_image}", $product_image, $cart_mdata);
                $cart_mdata = str_replace("{product_attribute}", $OrderProducts[$i]->product_attribute, $cart_mdata);
                $cart_mdata = str_replace("{product_accessory}", $OrderProducts[$i]->product_accessory, $cart_mdata);
                $cart_mdata = str_replace("{product_wrapper}", '', $cart_mdata);
                $cart_mdata = str_replace("{product_number}", $product_number, $cart_mdata);
                $cart_mdata = str_replace("{product_number_lbl}", JText::_('COM_REDSHOP_PRODUCT_NUMBER'), $cart_mdata);
                $user_subscribe_detail = $producthelper->getUserProductSubscriptionDetail($OrderProducts[$i]->order_item_id);
                if (count($user_subscribe_detail) > 0 && $user_subscribe_detail->subscription_id) {
                    $subscription_detail = $producthelper->getProductSubscriptionDetail($OrderProducts[$i]->product_id, $user_subscribe_detail->subscription_id);
                    $selected_subscription = $subscription_detail->subscription_period . " " . $subscription_detail->period_type;
                    $cart_mdata = str_replace("{product_subscription_lbl}", JText::_('COM_REDSHOP_SUBSCRIPTION'), $cart_mdata);
                    $cart_mdata = str_replace("{product_subscription}", $selected_subscription, $cart_mdata);
                } else {
                    $cart_mdata = str_replace("{product_subscription_lbl}", "", $cart_mdata);
                    $cart_mdata = str_replace("{product_subscription}", "", $cart_mdata);
                }
                $cart_mdata = str_replace("{product_userfields}", $product_userfields, $cart_mdata);
                $cart_mdata = str_replace("{product_wrapper}", $product_note, $cart_mdata);
                $cart_mdata = str_replace("{product_price}", $product_price, $cart_mdata);
                $cart_mdata = str_replace("{product_quantity}", $product_quantity, $cart_mdata);
                $cart_mdata = str_replace("{product_total_price}", $product_total_price, $cart_mdata);
                $cart_tr .= $cart_mdata;
            }
            $ordersprint_template = $template_start . $cart_tr . $template_end;
            $search[] = "{order_subtotal}";
            $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_subtotal);
            if ($OrdersDetail[0]->order_tax <= 0) {
                $template_vat_sdata = explode('{if vat}', $ordersprint_template);
                $template_vat_start = $template_vat_sdata[0];
                $template_vat_edata = explode('{vat end if}', $template_vat_sdata[1]);
                $template_vat_end = $template_vat_edata[1];
                $template_vat_middle = $template_vat_edata[0];
                $ordersprint_template = $template_vat_start . $template_vat_end;
            } else {
                $search[] = "{if vat}";
                $replace[] = '';
                $search[] = "{order_tax}";
                $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_tax);
                $search[] = "{tax}";
                $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_tax);
                $search[] = "{vat_lbl}";
                $replace[] = JText::_('COM_REDSHOP_ORDER_TAX');
                $search[] = "{vat end if}";
                $replace[] = '';
            }
            if ($OrdersDetail[0]->payment_discount <= 0) {
                if (strstr($ordersprint_template, "{if payment_discount}")) {
                    $template_pd_sdata = explode('{if payment_discount}', $ordersprint_template);
                    $template_pd_start = $template_pd_sdata[0];
                    $template_pd_edata = explode('{payment_discount end if}', $template_pd_sdata[1]);
                    $template_pd_end = $template_pd_edata[1];
                    $template_pd_middle = $template_pd_edata[0];
                    $ordersprint_template = $template_pd_start . $template_pd_end;
                }
            } else {
                $OrdersDetail->order_discount = $OrdersDetail[0]->order_discount - $OrdersDetail[0]->payment_discount;
                $search[] = "{if payment_discount}";
                $replace[] = '';
                $search[] = "{payment_order_discount}";
                $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->payment_discount);
                $search[] = "{payment_discount_lbl}";
                $replace[] = JText::_('COM_REDSHOP_PAYMENT_DISCOUNT_LBL');
                $search[] = "{payment_discount end if}";
                $replace[] = '';
            }
            if ($OrdersDetail->order_discount <= 0) {
                if (strstr($ordersprint_template, "{if discount}")) {
                    $template_discount_sdata = explode('{if discount}', $ordersprint_template);
                    $template_discount_start = $template_discount_sdata[0];
                    $template_discount_edata = explode('{discount end if}', $template_discount_sdata[1]);
                    $template_discount_end = $template_discount_edata[1];
                    $template_discount_middle = $template_discount_edata[0];
                    $ordersprint_template = $template_discount_start . $template_discount_end;
                }
            } else {
                $search[] = "{if discount}";
                $replace[] = '';
                $search[] = "{order_discount}";
                $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_discount);
                $search[] = "{discount_lbl}";
                $replace[] = JText::_('COM_REDSHOP_ORDER_DISCOUNT');
                $search[] = "{discount end if}";
                $replace[] = '';
            }
            $search[] = "{order_id_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_ID');
            $search[] = "{order_number_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_NUMBER');
            $search[] = "{order_date_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_DATE');
            $search[] = "{order_status_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_STATUS');
            $search[] = "{shipping_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_SHIPPING');
            $search[] = "{order_information_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_INFORMATION');
            $search[] = "{billing_address_information_lbl}";
            $replace[] = JText::_('COM_REDSHOP_BILLING_ADDRESS_INFORMATION');
            $search[] = "{shipping_address_info_lbl}";
            $replace[] = JText::_('COM_REDSHOP_SHIPPING_ADDRESS_INFORMATION');
            $search[] = "{order_detail_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_DETAILS');
            $search[] = "{product_name_lbl}";
            $replace[] = JText::_('COM_REDSHOP_PRODUCT_NAME');
            $search[] = "{note_lbl}";
            $replace[] = JText::_('COM_REDSHOP_NOTE');
            $search[] = "{price_lbl}";
            $replace[] = JText::_('COM_REDSHOP_PRICE');
            $search[] = "{quantity_lbl}";
            $replace[] = JText::_('COM_REDSHOP_QUANTITY');
            $search[] = "{total_price_lbl}";
            $replace[] = JText::_('COM_REDSHOP_TOTAL_PRICE');
            $search[] = "{order_subtotal_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_SUBTOTAL');
            $search[] = "{product_number_lbl}";
            $replace[] = JText::_('COM_REDSHOP_PRODUCT_NUMBER');
            $search[] = "{total_lbl}";
            $replace[] = JText::_('COM_REDSHOP_ORDER_TOTAL');
            $search[] = "{order_shipping}";
            $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_shipping);
            $search[] = "{shipping}";
            $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_shipping);
            $search[] = "{order_total}";
            $replace[] = $producthelper->getProductFormattedPrice($OrdersDetail[0]->order_total);
            $message = str_replace($search, $replace, $ordersprint_template);
            $search = "";
            $replace = "";
            $body = $message;
            $pdfObj->AddPage();
            $pdfObj->WriteHTML($body, true, false, true, false, '');
        }
        $invoice_pdfName = "multiprintorder";
        $pdfObj->Output(JPATH_SITE . '/components/com_redshop/assets/document/invoice/' . $invoice_pdfName . ".pdf", "F");
        return $invoice_pdfName;
    }
コード例 #12
0
ファイル: order.php プロジェクト: jaanusnurmoja/redjoomla
 public function createWebPacklabel($order_id, $specifiedSendDate, $order_status, $paymentstatus)
 {
     if (POSTDK_INTEGRATION && ($order_status == "S" && $paymentstatus == "Paid")) {
         $shippinghelper = new shipping();
         $order_details = $this->getOrderDetails($order_id);
         $details = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $order_details->ship_method_id)));
         if ($details[0] === 'plgredshop_shippingdefault_shipping' && !$order_details->order_label_create) {
             $generate_label = $this->generateParcel($order_id, $specifiedSendDate);
             if ($generate_label != "success") {
                 JError::raiseWarning(21, $generate_label);
             }
         }
     }
 }