예제 #1
0
 public function importeconomic()
 {
     $db = JFactory::getDbo();
     // Add product to economic
     if (ECONOMIC_INTEGRATION == 1) {
         $economic = new economic();
         $query = "SELECT s.*, r.* FROM #__redshop_shipping_rate r " . "LEFT JOIN #__extensions s ON r.shipping_class = s.element " . "WHERE s.enabled=1 and s.folder='redshop_shipping'";
         $db->setQuery($query);
         $shipping = $db->loadObjectList();
         for ($i = 0; $i < count($shipping); $i++) {
             $shipping_nshortname = strlen($shipping[$i]->name) > 15 ? substr($shipping[$i]->name, 0, 15) : $shipping[$i]->name;
             $shipping_number = $shipping_nshortname . ' ' . $shipping[$i]->shipping_rate_id;
             $shipping_name = $shipping[$i]->shipping_rate_name;
             $shipping_rate = $shipping[$i]->shipping_rate_value;
             if ($shipping[$i]->economic_displayname) {
                 $shipping_number = $shipping[$i]->economic_displayname;
             }
             $economic->createShippingRateInEconomic($shipping_number, $shipping_name, $shipping_rate, $shipping[$i]->apply_vat);
         }
     }
     $msg = JText::_("COM_REDSHOP_IMPORT_RATES_TO_ECONOMIC_SUCCESS");
     $this->setRedirect('index.php?option=com_redshop&view=shipping', $msg);
 }
예제 #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
 public function store($data)
 {
     $row =& $this->getTable();
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $giftcardfile = JRequest::getVar('giftcard_image', '', 'files', 'array');
     $giftcardimg = "";
     if ($giftcardfile['name'] != "") {
         $giftcardfile['name'] = str_replace(" ", "_", $giftcardfile['name']);
         $giftcardimg = JPath::clean(time() . '_' . $giftcardfile['name']);
         $src = $giftcardfile['tmp_name'];
         $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'giftcard/' . $giftcardimg;
         $row->giftcard_image = $giftcardimg;
         JFile::upload($src, $dest);
     }
     $giftcardbgfile = JRequest::getVar('giftcard_bgimage', '', 'files', 'array');
     $giftcardbgimg = "";
     if ($giftcardbgfile['name'] != "") {
         $giftcardbgfile['name'] = str_replace(" ", "_", $giftcardbgfile['name']);
         $giftcardbgimg = JPath::clean(time() . '_' . $giftcardbgfile['name']);
         $src = $giftcardbgfile['tmp_name'];
         $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'giftcard/' . $giftcardbgimg;
         $row->giftcard_bgimage = $giftcardbgimg;
         JFile::upload($src, $dest);
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (ECONOMIC_INTEGRATION == 1) {
         $economic = new economic();
         $giftdata = new stdClass();
         $giftdata->product_id = $row->giftcard_id;
         $giftdata->product_number = "gift_" . $row->giftcard_id . "_" . $row->giftcard_name;
         $giftdata->product_name = $row->giftcard_name;
         $giftdata->product_price = $row->giftcard_price;
         $giftdata->accountgroup_id = $row->accountgroup_id;
         $giftdata->product_volume = 0;
         $ecoProductNumber = $economic->createProductInEconomic($giftdata);
     }
     return $row;
 }
예제 #4
0
 public function importStockFromEconomic()
 {
     // Add product stock from economic
     $cnt = JRequest::getInt('cnt', 0);
     $stockroom_id = JRequest::getInt('stockroom_id', 0);
     $totalprd = 0;
     $msg = '';
     if (ECONOMIC_INTEGRATION == 1) {
         $economic = new economic();
         $db = JFactory::getDbo();
         $incNo = $cnt;
         $query = 'SELECT p.* FROM #__redshop_product AS p ' . 'LIMIT ' . $cnt . ', 10 ';
         $db->setQuery($query);
         $prd = $db->loadObjectlist();
         $totalprd = count($prd);
         $responcemsg = '';
         for ($i = 0; $i < count($prd); $i++) {
             $incNo++;
             $ecoProductNumber = $economic->importStockFromEconomic($prd[$i]);
             $responcemsg .= "<div>" . $incNo . ": " . JText::_('COM_REDSHOP_PRODUCT_NUMBER') . " " . $prd[$i]->product_number . " -> ";
             if (count($ecoProductNumber) > 0 && isset($ecoProductNumber[0])) {
                 $query = "UPDATE #__redshop_product_stockroom_xref " . "SET quantity='" . $ecoProductNumber[0] . "' " . "WHERE product_id='" . $prd[$i]->product_id . "' " . "AND stockroom_id='" . $stockroom_id . "' ";
                 $db->setQuery($query);
                 $db->Query();
                 $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_IMPORT_STOCK_FROM_ECONOMIC_SUCCESS') . "</span>";
             } else {
                 $errmsg = JText::_('COM_REDSHOP_ERROR_IN_IMPORT_STOCK_FROM_ECONOMIC');
                 if (JError::isError(JError::getError())) {
                     $error = JError::getError();
                     $errmsg = $error->message;
                 }
                 $responcemsg .= "<span style='color: #ff0000'>" . $errmsg . "</span>";
             }
             $responcemsg .= "</div>";
         }
         if ($totalprd > 0) {
             $msg = $responcemsg;
         } else {
             $msg = JText::_("COM_REDSHOP_IMPORT_STOCK_FROM_ECONOMIC_IS_COMPLETED");
         }
     }
     echo "<div id='sentresponse'>" . $totalprd . "`_`" . $msg . "</div>";
     die;
 }
예제 #5
0
 /**
  * Check validation
  *
  * @param   string  $users_info_id  not used
  *
  * @return bool
  */
 public function chkvalidation($users_info_id)
 {
     $model = $this->getModel('checkout');
     $billingaddresses = $model->billingaddresses();
     $shippingaddresses = $model->shipaddress($users_info_id);
     $extra_field = new extra_field();
     $extrafield_name = '';
     $return = 0;
     if (!$billingaddresses->is_company) {
         if ($billingaddresses->firstname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_FIRST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         } elseif ($billingaddresses->lastname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_LAST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         }
     } else {
         if ($billingaddresses->company_name == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_COMPANY_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         }
         if ($billingaddresses->firstname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_FIRST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         } elseif ($billingaddresses->lastname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_LAST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         } elseif (ECONOMIC_INTEGRATION == 1 && trim($billingaddresses->ean_number) != '') {
             $economic = new economic();
             $debtorHandle = $economic->createUserInEconomic($billingaddresses);
             if (JError::isError(JError::getError())) {
                 $return = 1;
                 $error = JError::getError();
                 $msg = $error->message;
                 JError::raiseWarning('', $msg);
                 return $return;
             }
         }
     }
     if (!trim($billingaddresses->address)) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_ADDRESS');
         JError::raiseWarning('', $msg);
         return $return;
     } elseif (!$billingaddresses->country_code) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_SELECT_COUNTRY');
         JError::raiseWarning('', $msg);
         return $return;
     } elseif (!$billingaddresses->zipcode) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_ZIPCODE');
         JError::raiseWarning('', $msg);
         return $return;
     } elseif (!$billingaddresses->phone) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_PHONE');
         JError::raiseWarning('', $msg);
         return $return;
     }
     if ($billingaddresses->is_company == 1) {
         $extrafield_name = $extra_field->chk_extrafieldValidation(8, $billingaddresses->users_info_id);
         if (!empty($extrafield_name)) {
             $return = 1;
             $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
             JError::raiseWarning('', $msg);
             return $return;
         }
     } else {
         $extrafield_name = $extra_field->chk_extrafieldValidation(7, $billingaddresses->users_info_id);
         if (!empty($extrafield_name)) {
             $return = 1;
             $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
             JError::raiseWarning('', $msg);
             return $return;
         }
     }
     if (SHIPPING_METHOD_ENABLE && $users_info_id != $billingaddresses->users_info_id) {
         if ($billingaddresses->is_company == 1) {
             $extrafield_name = $extra_field->chk_extrafieldValidation(15, $users_info_id);
             if (!empty($extrafield_name)) {
                 $return = 2;
                 $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
                 JError::raiseWarning('', $msg);
                 return $return;
             }
         } else {
             $extrafield_name = $extra_field->chk_extrafieldValidation(14, $users_info_id);
             if (!empty($extrafield_name)) {
                 $return = 2;
                 $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
                 JError::raiseWarning('', $msg);
                 return $return;
             }
         }
     }
     return $return;
 }
예제 #6
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;
 }
예제 #7
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;
 }
예제 #8
0
 public function createInvoice()
 {
     if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) {
         $order_id = JRequest::getCmd('order_id');
         $order_function = new order_functions();
         $paymentInfo = $order_function->getOrderPaymentDetail($order_id);
         if (count($paymentInfo) > 0) {
             $payment_name = $paymentInfo[0]->payment_method_class;
             $paymentArr = explode("rs_payment_", $paymentInfo[0]->payment_method_class);
             if (count($paymentArr) > 0) {
                 $payment_name = $paymentArr[1];
             }
             $economicdata['economic_payment_method'] = $payment_name;
             $paymentmethod = $order_function->getPaymentMethodInfo($paymentInfo[0]->payment_method_class);
             if (count($paymentmethod) > 0) {
                 $paymentparams = new JRegistry($paymentmethod[0]->params);
                 $economicdata['economic_payment_terms_id'] = $paymentparams->get('economic_payment_terms_id');
                 $economicdata['economic_design_layout'] = $paymentparams->get('economic_design_layout');
                 $economicdata['economic_is_creditcard'] = $paymentparams->get('is_creditcard');
             }
         }
         $economic = new economic();
         $economicdata['split_payment'] = 0;
         $invoiceHandle = $economic->createInvoiceInEconomic($order_id, $economicdata);
         if (ECONOMIC_INVOICE_DRAFT == 0) {
             $bookinvoicepdf = $economic->bookInvoiceInEconomic($order_id, 1);
             if (is_file($bookinvoicepdf)) {
                 $redshopMail = new redshopMail();
                 $ret = $redshopMail->sendEconomicBookInvoiceMail($order_id, $bookinvoicepdf);
             }
         }
     }
     $this->setRedirect('index.php?option=com_redshop&view=order');
 }
예제 #9
0
 public function storeRedshopUser($data, $user_id = 0, $admin = 0)
 {
     $redshopMail = new redshopMail();
     $extra_field = new extra_field();
     $helper = new redhelper();
     $data['user_email'] = $data['email'] = $data['email1'];
     $data['name'] = $name = $data['firstname'];
     $data['address_type'] = 'BT';
     $row = JTable::getInstance('user_detail', 'Table');
     if (isset($data['users_info_id']) && $data['users_info_id'] != 0) {
         $isNew = false;
         $row->load($data['users_info_id']);
         $data["old_tax_exempt_approved"] = $row->tax_exempt_approved;
         $user_id = $row->user_id;
     } else {
         $isNew = true;
         $data['password'] = JRequest::getVar('password1', '', 'post', 'string', JREQUEST_ALLOWRAW);
         $app = JFactory::getApplication();
         $is_admin = $app->isAdmin();
         if ($data['is_company'] == 1) {
             if ($is_admin && $data['shopper_group_id'] != 0) {
                 $data['shopper_group_id'] = $data['shopper_group_id'];
             } else {
                 $data['shopper_group_id'] = SHOPPER_GROUP_DEFAULT_COMPANY != 0 ? SHOPPER_GROUP_DEFAULT_COMPANY : 2;
             }
         } else {
             if ($is_admin && isset($data['shopper_group_id']) && $data['shopper_group_id'] != 0) {
                 $data['shopper_group_id'] = $data['shopper_group_id'];
             } else {
                 $data['shopper_group_id'] = SHOPPER_GROUP_DEFAULT_PRIVATE != 0 ? SHOPPER_GROUP_DEFAULT_PRIVATE : 1;
             }
         }
     }
     if ($user_id > 0) {
         $joomlauser = new JUser($user_id);
         $data['username'] = $joomlauser->username;
         $data['name'] = $joomlauser->name;
         $data['email'] = $joomlauser->email;
     }
     if (SHOW_TERMS_AND_CONDITIONS == 1 && isset($data['termscondition']) && $data['termscondition'] == 1) {
         $data['accept_terms_conditions'] = 1;
     }
     $row->user_id = $data['user_id'] = $user_id;
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (USE_TAX_EXEMPT) {
         if (!$admin && $row->is_company == 1) {
             $row->requesting_tax_exempt = $data['tax_exempt'];
             if ($row->requesting_tax_exempt == 1) {
                 $redshopMail->sendRequestTaxExemptMail($row, $data['username']);
             }
         }
         // Sending tax exempted mails (tax_exempt_approval_mail)
         if (!$isNew && $admin && isset($data["tax_exempt_approved"]) && $data["old_tax_exempt_approved"] != $data["tax_exempt_approved"]) {
             if ($data["tax_exempt_approved"] == 1) {
                 $redshopMail->sendTaxExemptMail("tax_exempt_approval_mail", $data, $row->user_email);
             } else {
                 $redshopMail->sendTaxExemptMail("tax_exempt_disapproval_mail", $data, $row->user_email);
             }
         }
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Update user info id
     if (ECONOMIC_INTEGRATION) {
         $economic = new economic();
         $original_info_id = $row->users_info_id;
         if ($isNew) {
             $maxDebtor = $economic->getMaxDebtorInEconomic();
             if (count($maxDebtor) > 0) {
                 $maxDebtor = $maxDebtor[0];
                 if ($row->users_info_id <= $maxDebtor) {
                     $nextId = $maxDebtor + 1;
                     $sql = "UPDATE " . $this->_table_prefix . "users_info " . "SET users_info_id = " . (int) $nextId . " " . "WHERE users_info_id = " . (int) $row->users_info_id;
                     $this->_db->setQuery($sql);
                     $this->_db->Query();
                     $row->users_info_id = $nextId;
                 }
             }
         }
         $debtorHandle = $economic->createUserInEconomic($row);
         if ($row->is_company && trim($row->ean_number) != '' && JError::isError(JError::getError())) {
             $msg = JText::_('PLEASE_ENTER_EAN_NUMBER');
             JError::raiseWarning('', $msg);
             return false;
         }
     }
     $auth['users_info_id'] = $row->users_info_id;
     $this->_session->set('auth', $auth);
     // For non-registered customers
     if (!$row->user_id) {
         $row->user_id = 0 - $row->users_info_id;
         $row->store();
         $u = JFactory::getUser();
         $u->set('username', $row->user_email);
         $u->set('email', $row->user_email);
         $u->set('usertype', 'Registered');
         $date = JFactory::getDate();
         $u->set('registerDate', $date->toMySQL());
         $data['user_id'] = $row->user_id;
         $data['username'] = $row->user_email;
         $data['email'] = $row->user_email;
     }
     if (isset($data['newsletter_signup']) && $data['newsletter_signup'] == 1) {
         $this->newsletterSubscribe($row->user_id, $data);
     }
     $billisship = 1;
     if (!isset($data['billisship'])) {
         $billisship = 0;
     }
     // Info: field_section 6 :Userinformations
     $list_field = $extra_field->extra_field_save($data, 6, $row->users_info_id);
     if ($row->is_company == 0) {
         // Info: field_section 7 :Userinformations
         $list_field = $extra_field->extra_field_save($data, 7, $row->users_info_id);
     } else {
         // Info: field_section 8 :Userinformations
         $list_field = $extra_field->extra_field_save($data, 8, $row->users_info_id);
     }
     if ($billisship != 1) {
         $rowShip = $this->storeRedshopUserShipping($data);
     }
     if (REGISTER_METHOD != 1 && $isNew && $admin == 0) {
         if (REGISTER_METHOD == 2) {
             if (isset($data['createaccount']) && $data['createaccount'] == 1) {
                 $redshopMail->sendRegistrationMail($data);
             }
         } else {
             $redshopMail->sendRegistrationMail($data);
         }
     }
     if ($isNew) {
         JPluginHelper::importPlugin('highrise');
         $dispatcher = JDispatcher::getInstance();
         $hResponses = $dispatcher->trigger('oncreateHighriseUser', array());
     }
     /**
      * redCRM includes
      */
     if ($helper->isredCRM()) {
         $this->setoreredCRMDebtor($row);
     }
     return $row;
 }
예제 #10
0
 public function importatteco()
 {
     // Add product attribute to economic
     $cnt = JRequest::getInt('cnt', 0);
     $totalprd = 0;
     $msg = '';
     if (ECONOMIC_INTEGRATION == 1 && ATTRIBUTE_AS_PRODUCT_IN_ECONOMIC == 1) {
         $economic = new economic();
         $db = JFactory::getDbo();
         $incNo = $cnt;
         $query = "SELECT ap.*, a.attribute_name, p.product_id, p.accountgroup_id " . "FROM #__redshop_product_attribute_property AS ap " . "LEFT JOIN #__redshop_product_attribute AS a ON a.attribute_id=ap.attribute_id " . "LEFT JOIN #__redshop_product AS p ON p.product_id=a.product_id " . "WHERE p.published=1 " . "AND p.product_id!='' " . "AND ap.property_number!='' " . "LIMIT " . $cnt . ", 10 ";
         $db->setQuery($query);
         $list = $db->loadObjectlist();
         $totalprd = count($list);
         $responcemsg = '';
         for ($i = 0; $i < count($list); $i++) {
             $incNo++;
             $prdrow = new stdClass();
             $prdrow->product_id = $list[$i]->product_id;
             $prdrow->accountgroup_id = $list[$i]->accountgroup_id;
             $ecoProductNumber = $economic->createPropertyInEconomic($prdrow, $list[$i]);
             $responcemsg .= "<div>" . $incNo . ": " . JText::_('COM_REDSHOP_PROPERTY_NUMBER') . " " . $list[$i]->property_number . " -> ";
             if (count($ecoProductNumber) > 0 && is_object($ecoProductNumber[0]) && isset($ecoProductNumber[0]->Number)) {
                 $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_IMPORT_ATTRIBUTES_TO_ECONOMIC_SUCCESS') . "</span>";
             } else {
                 $errmsg = JText::_('COM_REDSHOP_ERROR_IN_IMPORT_ATTRIBUTES_TO_ECONOMIC');
                 if (JError::isError(JError::getError())) {
                     $error = JError::getError();
                     $errmsg = $error->message;
                 }
                 $responcemsg .= "<span style='color: #ff0000'>" . $errmsg . "</span>";
             }
             $responcemsg .= "</div>";
         }
         $query = "SELECT sp.*, ap.property_id, ap.property_name, p.product_id, p.accountgroup_id  FROM #__redshop_product_subattribute_color AS sp " . "LEFT JOIN #__redshop_product_attribute_property AS ap ON ap.property_id=sp.subattribute_id " . "LEFT JOIN #__redshop_product_attribute AS a ON a.attribute_id=ap.attribute_id " . "LEFT JOIN #__redshop_product AS p ON p.product_id=a.product_id " . "WHERE p.published=1 " . "AND p.product_id!='' " . "AND sp.subattribute_color_number!='' " . "LIMIT " . $cnt . ", 10 ";
         $db->setQuery($query);
         $list = $db->loadObjectlist();
         $totalprd = $totalprd + count($list);
         for ($i = 0; $i < count($list); $i++) {
             $incNo++;
             $prdrow = new stdClass();
             $prdrow->product_id = $list[$i]->product_id;
             $prdrow->accountgroup_id = $list[$i]->accountgroup_id;
             $ecoProductNumber = $economic->createSubpropertyInEconomic($prdrow, $list[$i]);
             $responcemsg .= "<div>" . $incNo . ": " . JText::_('COM_REDSHOP_SUBPROPERTY_NUMBER') . " " . $list[$i]->subattribute_color_number . " -> ";
             if (count($ecoProductNumber) > 0 && is_object($ecoProductNumber[0]) && isset($ecoProductNumber[0]->Number)) {
                 $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_IMPORT_ATTRIBUTES_TO_ECONOMIC_SUCCESS') . "</span>";
             } else {
                 $errmsg = JText::_('COM_REDSHOP_ERROR_IN_IMPORT_ATTRIBUTES_TO_ECONOMIC');
                 if (JError::isError(JError::getError())) {
                     $error = JError::getError();
                     $errmsg = $error->message;
                 }
                 $responcemsg .= "<span style='color: #ff0000'>" . $errmsg . "</span>";
             }
             $responcemsg .= "</div>";
         }
         if ($totalprd > 0) {
             $msg = $responcemsg;
         } else {
             $msg = JText::_("COM_REDSHOP_IMPORT_ATTRIBUTES_TO_ECONOMIC_IS_COMPLETED");
         }
     }
     echo "<div id='sentresponse'>" . $totalprd . "`_`" . $msg . "</div>";
     die;
 }
예제 #11
0
 /**
  * Function attribute_save.
  *
  * @param   array   $post  Array of input data.
  * @param   object  $row   Array of row data.
  *
  * @return void
  */
 public function attribute_save($post, $row)
 {
     $economic = null;
     if (ECONOMIC_INTEGRATION == 1 && ATTRIBUTE_AS_PRODUCT_IN_ECONOMIC != 0) {
         $economic = new economic();
     }
     $model = $this->getModel('product_detail');
     $attribute_save = array();
     $property_save = array();
     $subproperty_save = array();
     if (!is_array($post['attribute'])) {
         return;
     }
     $attribute = array_merge(array(), $post['attribute']);
     for ($a = 0; $a < count($attribute); $a++) {
         $attribute_save['attribute_id'] = $attribute[$a]['id'];
         $tmpordering = $attribute[$a]['tmpordering'] ? $attribute[$a]['tmpordering'] : $a;
         $attribute_save['product_id'] = $row->product_id;
         $attribute_save['attribute_name'] = urldecode($attribute[$a]['name']);
         $attribute_save['ordering'] = $attribute[$a]['ordering'];
         $attribute_save['attribute_published'] = $attribute[$a]['published'] == 'on' || $attribute[$a]['published'] == '1' ? '1' : '0';
         $attribute_save['attribute_required'] = $attribute[$a]['required'] == 'on' || $attribute[$a]['required'] == '1' ? '1' : '0';
         $attribute_save['allow_multiple_selection'] = $attribute[$a]['allow_multiple_selection'] == 'on' || $attribute[$a]['allow_multiple_selection'] == '1' ? '1' : '0';
         $attribute_save['hide_attribute_price'] = $attribute[$a]['hide_attribute_price'] == 'on' || $attribute[$a]['hide_attribute_price'] == '1' ? '1' : '0';
         $attribute_save['display_type'] = $attribute[$a]['display_type'];
         $attribute_array = $model->store_attr($attribute_save);
         $property = array_merge(array(), $attribute[$a]['property']);
         $propertyImage = array_keys($attribute[$a]['property']);
         $tmpproptyimagename = array_merge(array(), $propertyImage);
         for ($p = 0; $p < count($property); $p++) {
             $property_save['property_id'] = $property[$p]['property_id'];
             $property_save['attribute_id'] = $attribute_array->attribute_id;
             $property_save['property_name'] = urldecode($property[$p]['name']);
             $property_save['property_price'] = $property[$p]['price'];
             $property_save['oprand'] = $property[$p]['oprand'];
             $property_save['property_number'] = $property[$p]['number'];
             $property_save['property_image'] = $property[$p]['image'];
             $property_save['ordering'] = $property[$p]['order'];
             $property_save['setrequire_selected'] = $property[$p]['req_sub_att'] == 'on' || $property[$p]['req_sub_att'] == '1' ? '1' : '0';
             $property_save['setmulti_selected'] = $property[$p]['multi_sub_att'] == 'on' || $property[$p]['multi_sub_att'] == '1' ? '1' : '0';
             $property_save['setdefault_selected'] = $property[$p]['default_sel'] == 'on' || $property[$p]['default_sel'] == '1' ? '1' : '0';
             $property_save['setdisplay_type'] = $property[$p]['setdisplay_type'];
             $property_save['property_published'] = $property[$p]['published'] == 'on' || $property[$p]['published'] == '1' ? '1' : '0';
             $property_save['extra_field'] = $property[$p]['extra_field'];
             $property_array = $model->store_pro($property_save);
             $property_id = $property_array->property_id;
             $property_image = $this->input->files->get('attribute_' . $tmpordering . '_property_' . $tmpproptyimagename[$p] . '_image', array(), 'array');
             if (empty($property[$p]['mainImage'])) {
                 if (!empty($property_image['name'])) {
                     $property_save['property_image'] = $model->copy_image($property_image, 'product_attributes', $property_id);
                     $property_save['property_id'] = $property_id;
                     $property_array = $model->store_pro($property_save);
                     $this->DeleteMergeImages();
                 }
             }
             if (!empty($property[$p]['mainImage'])) {
                 $property_save['property_image'] = $model->copy_image_from_path($property[$p]['mainImage'], 'product_attributes');
                 $property_save['property_id'] = $property_id;
                 $property_array = $model->store_pro($property_save);
                 $this->DeleteMergeImages();
             }
             if (empty($property[$p]['property_id'])) {
                 $listImages = $model->GetimageInfo($property_id, 'property');
                 for ($li = 0; $li < count($listImages); $li++) {
                     $mImages = array();
                     $mImages['media_name'] = $listImages[$li]->media_name;
                     $mImages['media_alternate_text'] = $listImages[$li]->media_alternate_text;
                     $mImages['media_section'] = 'property';
                     $mImages['section_id'] = $property_id;
                     $mImages['media_type'] = 'images';
                     $mImages['media_mimetype'] = $listImages[$li]->media_mimetype;
                     $mImages['published'] = $listImages[$li]->published;
                     $model->copyadditionalImage($mImages);
                 }
             }
             if (ECONOMIC_INTEGRATION == 1 && ATTRIBUTE_AS_PRODUCT_IN_ECONOMIC != 0) {
                 $economic->createPropertyInEconomic($row, $property_array);
             }
             // Set trigger to save Attribute Property Plugin Data
             if ((int) $property_id) {
                 $dispatcher = JDispatcher::getInstance();
                 JPluginHelper::importPlugin('redshop_product_type');
                 // Trigger the data preparation event.
                 $dispatcher->trigger('onAttributePropertySaveLoop', array($row, &$property[$p], &$property_array));
             }
             $subproperty = array_merge(array(), $property[$p]['subproperty']);
             $subproperty_title = $property[$p]['subproperty']['title'];
             $subpropertyImage = array_keys($property[$p]['subproperty']);
             unset($subpropertyImage[0]);
             $tmpimagename = array_merge(array(), $subpropertyImage);
             for ($sp = 0; $sp < count($subproperty) - 1; $sp++) {
                 $subproperty_save['subattribute_color_id'] = $subproperty[$sp]['subproperty_id'];
                 $subproperty_save['subattribute_color_name'] = $subproperty[$sp]['name'];
                 $subproperty_save['subattribute_color_title'] = $subproperty_title;
                 $subproperty_save['subattribute_color_price'] = $subproperty[$sp]['price'];
                 $subproperty_save['oprand'] = $subproperty[$sp]['oprand'];
                 $subproperty_save['subattribute_color_image'] = $subproperty[$sp]['image'];
                 $subproperty_save['subattribute_id'] = $property_id;
                 $subproperty_save['ordering'] = $subproperty[$sp]['order'];
                 $subproperty_save['subattribute_color_number'] = $subproperty[$sp]['number'];
                 $subproperty_save['setdefault_selected'] = $subproperty[$sp]['chk_propdselected'] == 'on' || $subproperty[$sp]['chk_propdselected'] == '1' ? '1' : '0';
                 $subproperty_save['subattribute_published'] = $subproperty[$sp]['published'] == 'on' || $subproperty[$sp]['published'] == '1' ? '1' : '0';
                 $subproperty_save['extra_field'] = $subproperty[$sp]['extra_field'];
                 $subproperty_array = $model->store_sub($subproperty_save);
                 $subproperty_image = $this->input->files->get('attribute_' . $tmpordering . '_property_' . $p . '_subproperty_' . $tmpimagename[$sp] . '_image', array(), 'array');
                 $subproperty_id = $subproperty_array->subattribute_color_id;
                 if (empty($subproperty[$sp]['mainImage'])) {
                     if (!empty($subproperty_image['name'])) {
                         $subproperty_save['subattribute_color_image'] = $model->copy_image($subproperty_image, 'subcolor', $subproperty_id);
                         $subproperty_save['subattribute_color_id'] = $subproperty_id;
                         $subproperty_array = $model->store_sub($subproperty_save);
                         $this->DeleteMergeImages();
                     }
                 }
                 if (!empty($subproperty[$sp]['mainImage'])) {
                     $subproperty_save['subattribute_color_image'] = $model->copy_image_from_path($subproperty[$sp]['mainImage'], 'subcolor');
                     $subproperty_save['subattribute_color_id'] = $subproperty_id;
                     $subproperty_array = $model->store_sub($subproperty_save);
                     $this->DeleteMergeImages();
                 }
                 if (empty($subproperty[$sp]['subproperty_id'])) {
                     $listsubpropImages = $model->GetimageInfo($subproperty_id, 'subproperty');
                     for ($lsi = 0; $lsi < count($listsubpropImages); $lsi++) {
                         $smImages = array();
                         $smImages['media_name'] = $listsubpropImages[$lsi]->media_name;
                         $smImages['media_alternate_text'] = $listsubpropImages[$lsi]->media_alternate_text;
                         $smImages['media_section'] = 'subproperty';
                         $smImages['section_id'] = $subproperty_id;
                         $smImages['media_type'] = 'images';
                         $smImages['media_mimetype'] = $listsubpropImages[$lsi]->media_mimetype;
                         $smImages['published'] = $listsubpropImages[$lsi]->published;
                         $model->copyadditionalImage($smImages);
                     }
                 }
                 if (ECONOMIC_INTEGRATION == 1 && ATTRIBUTE_AS_PRODUCT_IN_ECONOMIC != 0) {
                     $economic->createSubpropertyInEconomic($row, $subproperty_array);
                 }
             }
         }
     }
     return;
 }
예제 #12
0
 public function createBookInvoice($order_id, $order_status)
 {
     // Economic Integration start for invoice generate and book current invoice
     if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 1) {
         $economic = new economic();
         if (ECONOMIC_INVOICE_DRAFT == 2 && $order_status == BOOKING_ORDER_STATUS) {
             $paymentInfo = $this->getOrderPaymentDetail($order_id);
             if (count($paymentInfo) > 0) {
                 $payment_name = $paymentInfo[0]->payment_method_class;
                 $paymentArr = explode("rs_payment_", $paymentInfo[0]->payment_method_class);
                 if (count($paymentArr) > 0) {
                     $payment_name = $paymentArr[1];
                 }
                 $economicdata['economic_payment_method'] = $payment_name;
                 $paymentmethod = $this->getPaymentMethodInfo($paymentInfo[0]->payment_method_class);
                 if (count($paymentmethod) > 0) {
                     $paymentparams = new JRegistry($paymentmethod[0]->params);
                     $economicdata['economic_payment_terms_id'] = $paymentparams->get('economic_payment_terms_id');
                     $economicdata['economic_design_layout'] = $paymentparams->get('economic_design_layout');
                     $economicdata['economic_is_creditcard'] = $paymentparams->get('is_creditcard');
                 }
             }
             $economicdata['split_payment'] = 0;
             $invoiceHandle = $economic->createInvoiceInEconomic($order_id, $economicdata);
         }
         $bookinvoicepdf = $economic->bookInvoiceInEconomic($order_id, ECONOMIC_INVOICE_DRAFT);
         if (is_file($bookinvoicepdf)) {
             $redshopMail = new redshopMail();
             $ret = $redshopMail->sendEconomicBookInvoiceMail($order_id, $bookinvoicepdf);
         }
     }
 }