Beispiel #1
0
 /**
  * Get Billing Addresses
  *
  * @return  array
  */
 public function billingaddresses()
 {
     $app = JFactory::getApplication();
     $order_functions = new order_functions();
     $user = JFactory::getUser();
     $session = JFactory::getSession();
     $auth = $session->get('auth');
     $list = array();
     if ($user->id) {
         $list = $order_functions->getBillingAddress($user->id);
     } elseif ($auth['users_info_id']) {
         $uid = -$auth['users_info_id'];
         $list = $order_functions->getBillingAddress($uid);
     }
     return $list;
 }
Beispiel #2
0
 public function getuseraccountinfo($uid)
 {
     $order_functions = new order_functions();
     $user = JFactory::getUser();
     $session = JFactory::getSession();
     $auth = $session->get('auth');
     $list = array();
     if ($user->id) {
         $list = $order_functions->getBillingAddress($user->id);
     } elseif ($auth['users_info_id']) {
         $uid = -$auth['users_info_id'];
         $list = $order_functions->getBillingAddress($uid);
     }
     if (!empty($list)) {
         $list->email = $list->user_email;
     }
     return $list;
 }
Beispiel #3
0
 public function display($tpl = null)
 {
     $option = JRequest::getVar('option');
     $extra_field = new extra_field();
     $order_functions = new order_functions();
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_REDSHOP_QUOTATION_MANAGEMENT'));
     $document->addScript('components/' . $option . '/assets/js/json.js');
     $document->addScript('components/' . $option . '/assets/js/validation.js');
     $document->addScript('components/' . $option . '/assets/js/order.js');
     $document->addScript('components/' . $option . '/assets/js/common.js');
     $document->addScript('components/' . $option . '/assets/js/select_sort.js');
     $document->addStyleSheet('components/' . $option . '/assets/css/search.css');
     $document->addScript('components/' . $option . '/assets/js/search.js');
     $session = JFactory::getSession();
     $uri = JFactory::getURI();
     $lists = array();
     $model = $this->getModel();
     $detail = $this->get('Data');
     $Redconfiguration = new Redconfiguration();
     $user_id = JRequest::getVar('user_id', 0);
     if ($user_id != 0) {
         $billing = $order_functions->getBillingAddress($user_id);
     } else {
         $billing = $model->setBilling();
     }
     if (!is_object($detail)) {
         $detail = new stdClass();
     }
     $detail->user_id = $user_id;
     $session->set('offlineuser_id', $user_id);
     $userop = array();
     $userop[0] = new stdClass();
     $userop[0]->user_id = 0;
     $userop[0]->text = JText::_('COM_REDSHOP_SELECT');
     $userlists = $model->getUserData(0, "BT");
     $userlist = array_merge($userop, $userlists);
     $lists['userlist'] = JHTML::_('select.genericlist', $userlist, 'user_id', 'class="inputbox" onchange="showquotationUserDetail();" ', 'user_id', 'text');
     JToolBarHelper::title(JText::_('COM_REDSHOP_QUOTATION_MANAGEMENT') . ': <small><small>[ ' . JText::_('COM_REDSHOP_NEW') . ' ]</small></small>', 'redshop_order48');
     JToolBarHelper::save();
     JToolBarHelper::custom('send', 'send.png', 'send.png', JText::_('COM_REDSHOP_SEND'), false);
     JToolBarHelper::cancel();
     // PRODUCT/ATTRIBUTE STOCK ROOM QUANTITY CHECKING IS IMPLEMENTED
     $countryarray = $Redconfiguration->getCountryList((array) $billing);
     $billing->country_code = $countryarray['country_code'];
     $lists['country_code'] = $countryarray['country_dropdown'];
     $statearray = $Redconfiguration->getStateList((array) $billing);
     $lists['state_code'] = $statearray['state_dropdown'];
     $lists['quotation_extrafield'] = $extra_field->list_all_field(16, $billing->users_info_id);
     $this->lists = $lists;
     $this->detail = $detail;
     $this->billing = $billing;
     $this->userlist = $userlists;
     $this->request_url = $uri->toString();
     parent::display($tpl);
 }
Beispiel #4
0
 public function _loadData()
 {
     $order_functions = new order_functions();
     $user = JFactory::getUser();
     if ($user->id) {
         $this->_data = $order_functions->getBillingAddress($user->id);
         $this->_data->user_info_id = $this->_data->users_info_id;
         return true;
     }
     return false;
 }
Beispiel #5
0
 /**
  * Method to edit billing Address
  *
  * @return  boolean  True if the ID is in the edit list.
  */
 public function edit()
 {
     $user = JFactory::getUser();
     $order_functions = new order_functions();
     $billingaddresses = $order_functions->getBillingAddress($user->id);
     $GLOBALS['billingaddresses'] = $billingaddresses;
     $task = JRequest::getVar('submit', 'post');
     if ($task == 'Cancel') {
         $this->registerTask('save', 'cancel');
     }
     parent::display();
 }
Beispiel #6
0
 public function _initData()
 {
     if (empty($GLOBALS['billingaddresses'])) {
         $session = JFactory::getSession();
         $auth = $session->get('auth');
         if (isset($auth['users_info_id']) && $auth['users_info_id']) {
             $order_functions = new order_functions();
             $detail = $order_functions->getBillingAddress(-$auth['users_info_id']);
             if (!isset($detail->user_id)) {
                 $detail->user_id = -$auth['users_info_id'];
             }
         } else {
             // Toggler settings
             $is_company = DEFAULT_CUSTOMER_REGISTER_TYPE == 2 ? 1 : 0;
             // Allow registration type settings
             if (ALLOW_CUSTOMER_REGISTER_TYPE == 1) {
                 $is_company = 0;
             } elseif (ALLOW_CUSTOMER_REGISTER_TYPE == 2) {
                 $is_company = 1;
             }
             $user = JFactory::getUser();
             $detail = new stdClass();
             $detail->users_info_id = 0;
             $detail->user_id = $user->id;
             $detail->id = $user->id;
             $detail->name = $user->name;
             $detail->username = $user->username;
             $detail->email = $user->email;
             $detail->user_email = $user->email;
             $detail->password = null;
             $detail->is_company = $is_company;
             $detail->firstname = null;
             $detail->lastname = null;
             $detail->address_type = 'BT';
             $detail->company_name = null;
             $detail->vat_number = null;
             $detail->tax_exempt = 0;
             $detail->country_code = null;
             $detail->state_code = null;
             $detail->shopper_group_id = null;
             $detail->published = 1;
             $detail->address = null;
             $detail->city = null;
             $detail->zipcode = null;
             $detail->phone = null;
             $detail->requesting_tax_exempt = 0;
             $detail->tax_exempt_approved = 0;
             $detail->approved = 1;
         }
         return $detail;
     }
 }
Beispiel #7
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $order_functions = new order_functions();
     // Extra_field;
     $extra_field = new extraField();
     $task = JRequest::getCmd('task');
     $user = JFactory::getUser();
     $uri = JFactory::getURI();
     // Preform security checks
     $session = JFactory::getSession();
     $auth = $session->get('auth');
     $params = $app->getParams('com_redshop');
     $lists = array();
     if ($user->id) {
         $billingaddresses = $order_functions->getBillingAddress($user->id);
     } elseif (isset($auth['users_info_id']) && $auth['users_info_id']) {
         $model = $this->getModel('account_shipto');
         $billingaddresses = $model->_loadData($auth['users_info_id']);
     } else {
         $app->Redirect('index.php?option=com_redshop&view=login&Itemid=' . JRequest::getInt('Itemid'));
         exit;
     }
     if ($task == 'addshipping') {
         JHTML::Script('jquery-1.4.2.min.js', 'components/com_redshop/assets/js/', false);
         JHTML::Script('jquery.validate.js', 'components/com_redshop/assets/js/', false);
         JHTML::Script('common.js', 'components/com_redshop/assets/js/', false);
         JHTML::Script('registration.js', 'components/com_redshop/assets/js/', false);
         JHTML::Stylesheet('validation.css', 'components/com_redshop/assets/css/');
         $shippingaddresses = $this->get('Data');
         if ($shippingaddresses->users_info_id > 0 && $shippingaddresses->user_id != $billingaddresses->user_id) {
             echo JText::_('COM_REDSHOP_ALERTNOTAUTH');
             return;
         }
         $lists['shipping_customer_field'] = $extra_field->list_all_field(14, $shippingaddresses->users_info_id);
         $lists['shipping_company_field'] = $extra_field->list_all_field(15, $shippingaddresses->users_info_id);
         $this->setLayout('form');
     } else {
         $shippingaddresses = $order_functions->getShippingAddress($user->id);
     }
     $this->lists = $lists;
     $this->shippingaddresses = $shippingaddresses;
     $this->billingaddresses = $billingaddresses;
     $this->request_url = $uri->toString();
     $this->params = $params;
     parent::display($tpl);
 }
Beispiel #8
0
$order = $order_functions->getOrderDetails($order_id);
$orderitem = $order_functions->getOrderItemDetail($order_id);
if ($order->order_total > 0 && !USE_AS_CATALOG) {
    $paymentmethod = $order_functions->getOrderPaymentDetail($order_id);
    $paymentmethod = $order_functions->getPaymentMethodInfo($paymentmethod[0]->payment_method_class);
    $paymentmethod = $paymentmethod[0];
    $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '/' . $paymentmethod->element . '.xml';
    $paymentparams = new JRegistry($paymentmethod->params);
    echo '<div>';
    $is_creditcard = $paymentparams->get('is_creditcard', '');
    $is_redirected = $paymentparams->get('is_redirected', 0);
    if (!$is_creditcard || $is_redirected == 1) {
        $adminpath = JPATH_ADMINISTRATOR . '/components/com_redshop';
        $invalid_elements = $paymentparams->get('invalid_elements', '');
        // Send the order_id and orderpayment_id to the payment plugin so it knows which DB record to update upon successful payment
        $billingaddresses = $order_functions->getBillingAddress($order->user_id);
        if (isset($billingaddresses)) {
            if (isset($billingaddresses->country_code)) {
                $billingaddresses->country_2_code = $configobj->getCountryCode2($billingaddresses->country_code);
            }
            if (isset($billingaddresses->state_code)) {
                $billingaddresses->state_2_code = $billingaddresses->state_code;
            }
        }
        $shippingaddresses = $order_functions->getOrderShippingUserInfo($order->order_id);
        if (isset($shippingaddresses)) {
            if (isset($shippingaddresses->country_code)) {
                $shippingaddresses->country_2_code = $configobj->getCountryCode2($shippingaddresses->country_code);
            }
            if (isset($shippingaddresses->state_code)) {
                $shippingaddresses->state_2_code = $shippingaddresses->state_code;
 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;
 }
Beispiel #10
0
 public function display($tpl = null)
 {
     $option = JRequest::getVar('option');
     $extra_field = new extra_field();
     $order_functions = new order_functions();
     $Redconfiguration = new Redconfiguration();
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_REDSHOP_ORDER'));
     $document->addScript('components/' . $option . '/assets/js/select_sort.js');
     $document->addStyleSheet('components/' . $option . '/assets/css/search.css');
     $document->addScript('components/' . $option . '/assets/js/search.js');
     $document->addScript('components/' . $option . '/assets/js/json.js');
     $document->addScript('components/' . $option . '/assets/js/validation.js');
     $document->addScript('components/' . $option . '/assets/js/order.js');
     $document->addScript('components/' . $option . '/assets/js/common.js');
     $uri = JFactory::getURI();
     $lists = array();
     $billing = array();
     $shippinginfo = array();
     $model = $this->getModel();
     $detail = $this->get('data');
     $redhelper = new redhelper();
     $payment_lang_list = $redhelper->getPlugins("redshop_payment");
     $language = JFactory::getLanguage();
     $base_dir = JPATH_ADMINISTRATOR;
     $language_tag = $language->getTag();
     for ($l = 0; $l < count($payment_lang_list); $l++) {
         $extension = 'plg_redshop_payment_' . $payment_lang_list[$l]->element;
         $language->load($extension, $base_dir, $language_tag, true);
     }
     $err = JRequest::getVar('err', '');
     $shipping_rate_id = JRequest::getVar('shipping_rate_id');
     $user_id = JRequest::getVar('user_id', 0);
     if ($user_id != 0) {
         $billing = $order_functions->getBillingAddress($user_id);
         $shippinginfo = $order_functions->getShippingAddress($user_id);
     } else {
         $billing = $model->setBilling();
     }
     $shipping_country = 0;
     $shipping_state = 0;
     $key = 0;
     $shippingop = array();
     $shippingop[0] = new stdClass();
     $shippingop[0]->users_info_id = 0;
     $shippingop[0]->text = JText::_('COM_REDSHOP_SELECT');
     if (count($shippinginfo) > 0) {
         $shipping_users_info_id = JRequest::getVar('shipping_users_info_id', 0);
         if ($shipping_users_info_id != 0) {
             for ($o = 0; $o < count($shippinginfo); $o++) {
                 if ($shippinginfo[$o]->users_info_id == $shipping_users_info_id) {
                     $key = $o;
                     break;
                 }
             }
             $shipping_country = $shippinginfo[$key]->country_code;
             $shipping_state = $shippinginfo[$key]->state_code;
         }
         $shippingop = array_merge($shippingop, $shippinginfo);
         $billisship = $shippinginfo[$key]->billisship = $shipping_users_info_id ? 0 : 1;
     } else {
         $shippinginfo[0] = $model->setShipping();
         $shipping_users_info_id = $shippinginfo[0]->users_info_id = 0;
         $billisship = $shippinginfo[0]->billisship;
     }
     $shdisable = $billisship ? "disabled" : "";
     $detail->user_id = $user_id;
     $lists['shippinginfo_list'] = JHTML::_('select.genericlist', $shippingop, 'shipp_users_info_id', 'class="inputbox" ' . $shdisable . ' onchange="getShippinginfo(this.value, ' . $billing->is_company . ');" ', 'users_info_id', 'text', $shipping_users_info_id);
     $payment_detail = $this->get('payment');
     JToolBarHelper::title(JText::_('COM_REDSHOP_ORDER') . ': <small><small>[ ' . JText::_('COM_REDSHOP_NEW') . ' ]</small></small>', 'redshop_order48');
     if ($err == "" && array_key_exists("users_info_id", $billing) && $billing->users_info_id) {
         JToolBarHelper::custom('savepay', 'save.png', 'save_f2.png', 'Save + Pay', false);
         JToolBarHelper::custom('save_without_sendmail', 'save.png', 'save_f2.png', JText::_('COM_REDSHOP_SAVE_WITHOUT_SEND_ORDERMAIL_LBL'), false);
         JToolBarHelper::save();
     }
     JToolBarHelper::cancel();
     $countryarray = $Redconfiguration->getCountryList((array) $billing, "country_code", "BT");
     $billing->country_code = $countryarray['country_code'];
     $lists['country_code'] = $countryarray['country_dropdown'];
     $statearray = $Redconfiguration->getStateList((array) $billing, "state_code", "country_code", "BT", 1);
     $lists['state_code'] = $statearray['state_dropdown'];
     $shipping['country_code_ST'] = $shippinginfo[$key]->country_code;
     $countryarray = $Redconfiguration->getCountryList((array) $shipping, "country_code_ST", "ST");
     $shipping['country_code_ST'] = $shippinginfo[$key]->country_code = $countryarray['country_code_ST'];
     $lists['country_code_ST'] = $countryarray['country_dropdown'];
     $statearray = $Redconfiguration->getStateList((array) $shipping, "state_code_ST", "country_code_ST", "ST", 1);
     $lists['state_code_ST'] = $statearray['state_dropdown'];
     $lists['is_company'] = JHTML::_('select.booleanlist', 'is_company', 'class="inputbox" onchange="showOfflineCompanyOrCustomer(this.value);" ', $billing->is_company, JText::_('COM_REDSHOP_USER_COMPANY'), JText::_('COM_REDSHOP_USER_CUSTOMER'));
     $lists['customer_field'] = $extra_field->list_all_field(7, $billing->users_info_id);
     $lists['company_field'] = $extra_field->list_all_field(8, $billing->users_info_id);
     $lists['shipping_customer_field'] = $extra_field->list_all_field(14, $shippinginfo[0]->users_info_id);
     $lists['shipping_company_field'] = $extra_field->list_all_field(15, $shippinginfo[0]->users_info_id);
     $this->lists = $lists;
     $this->detail = $detail;
     $this->billing = $billing;
     $this->shipping = $shippinginfo[$key];
     $this->shipping_users_info_id = $shipping_users_info_id;
     $this->payment_detail = $payment_detail;
     $this->shipping_rate_id = $shipping_rate_id;
     $this->request_url = $uri->toString();
     parent::display($tpl);
 }
Beispiel #11
0
 function display($tpl = null)
 {
     $config = new Redconfiguration();
     $redTemplate = new Redtemplate();
     $order_functions = new order_functions();
     $model = $this->getModel();
     $detail = $this->get('data');
     $billing = $order_functions->getBillingAddress($detail->user_id);
     $shipping = $order_functions->getOrderShippingUserInfo($detail->order_id);
     if (!$shipping) {
         $shipping = $billing;
     }
     $template = $redTemplate->getTemplate("shipping_pdf");
     $html_template = $template[0]->template_desc;
     ob_start();
     $order_status = $order_functions->getOrderStatusTitle($detail->order_status);
     $html_template = str_replace("{order_information_lbl}", JText::_('COM_REDSHOP_ORDER_INFORMATION'), $html_template);
     $html_template = str_replace("{order_id_lbl}", JText::_('COM_REDSHOP_ORDER_ID'), $html_template);
     $html_template = str_replace("{order_number_lbl}", JText::_('COM_REDSHOP_ORDER_NUMBER'), $html_template);
     $html_template = str_replace("{order_date_lbl}", JText::_('COM_REDSHOP_ORDER_DATE'), $html_template);
     $html_template = str_replace("{order_status_lbl}", JText::_('COM_REDSHOP_ORDER_STATUS'), $html_template);
     $html_template = str_replace("{shipping_address_info_lbl}", JText::_('COM_REDSHOP_SHIPPING_ADDRESS_INFORMATION'), $html_template);
     $html_template = str_replace("{shipping_firstname_lbl}", JText::_('COM_REDSHOP_FIRSTNAME'), $html_template);
     $html_template = str_replace("{shipping_lastname_lbl}", JText::_('COM_REDSHOP_LASTNAME'), $html_template);
     $html_template = str_replace("{shipping_address_lbl}", JText::_('COM_REDSHOP_ADDRESS'), $html_template);
     $html_template = str_replace("{shipping_zip_lbl}", JText::_('COM_REDSHOP_ZIP'), $html_template);
     $html_template = str_replace("{shipping_city_lbl}", JText::_('COM_REDSHOP_CITY'), $html_template);
     $html_template = str_replace("{shipping_country_lbl}", JText::_('COM_REDSHOP_COUNTRY'), $html_template);
     $html_template = str_replace("{shipping_state_lbl}", JText::_('COM_REDSHOP_STATE'), $html_template);
     $html_template = str_replace("{shipping_phone_lbl}", JText::_('COM_REDSHOP_PHONE'), $html_template);
     $html_template = str_replace("{order_id}", $detail->order_id, $html_template);
     $html_template = str_replace("{order_number}", $detail->order_number, $html_template);
     $html_template = str_replace("{order_date}", $config->convertDateFormat($detail->cdate), $html_template);
     $html_template = str_replace("{order_status}", $order_status, $html_template);
     $html_template = str_replace("{shipping_firstname}", $shipping->firstname, $html_template);
     $html_template = str_replace("{shipping_lastname}", $shipping->lastname, $html_template);
     $html_template = str_replace("{shipping_address}", $shipping->address, $html_template);
     $html_template = str_replace("{shipping_zip}", $shipping->zipcode, $html_template);
     $html_template = str_replace("{shipping_city}", $shipping->city, $html_template);
     $html_template = str_replace("{shipping_country}", JTEXT::_($order_functions->getCountryName($shipping->country_code)), $html_template);
     $html_template = str_replace("{shipping_state}", $order_functions->getStateName($shipping->state_code, $shipping->country_code), $html_template);
     $html_template = str_replace("{shipping_phone}", $shipping->zipcode, $html_template);
     // if user is company than
     if ($billing->is_company && $billing->company_name != "") {
         $html_template = str_replace("{company_name}", $billing->company_name, $html_template);
         $html_template = str_replace("{company_name_lbl}", JText::_('COM_REDSHOP_COMPANY_NAME'), $html_template);
     } else {
         $html_template = str_replace("{company_name}", "", $html_template);
         $html_template = str_replace("{company_name_lbl}", "", $html_template);
     }
     $pdfObj = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A5', true, 'UTF-8', false);
     $pdfObj->SetTitle("Order :" . $detail->order_id);
     $pdfObj->SetAuthor('redSHOP');
     $pdfObj->SetCreator('redSHOP');
     $pdfObj->SetMargins(15, 15, 15);
     $font = 'times';
     $pdfObj->SetHeaderData('', '', '', "Order " . $detail->order_id);
     $pdfObj->setHeaderFont(array($font, '', 10));
     //$pdfObj->setFooterFont(array($font, '', 8));
     $pdfObj->SetFont($font, "", 12);
     //$pdfObj->AliasNbPages();
     $pdfObj->AddPage();
     $pdfObj->WriteHTML($html_template);
     $pdfObj->Output("Order_" . $detail->order_id . ".pdf", "D");
     exit;
 }
Beispiel #12
0
    /**
     *  function ******** To get Shipping rate for cart
     */
    public function getDefaultShipping($d)
    {
        $userhelper = new rsUserhelper();
        $session = JFactory::getSession();
        $order_subtotal = $d['order_subtotal'];
        $user = JFactory::getUser();
        $user_id = $user->id;
        $db = JFactory::getDbo();
        $totaldimention = $this->getCartItemDimention();
        $weighttotal = $totaldimention['totalweight'];
        $volume = $totaldimention['totalvolume'];
        $order_functions = new order_functions();
        $userInfo = $order_functions->getBillingAddress($user_id);
        $country = '';
        $state = '';
        $is_company = '';
        $newpwhere = '';
        $newcwhere = '';
        $wherestate = '';
        $whereshopper = '';
        if ($userInfo) {
            $country = $userInfo->country_code;
            $is_company = $userInfo->is_company;
            $user_id = $userInfo->user_id;
            $state = $userInfo->state_code;
        }
        $shoppergroup = $userhelper->getShoppergroupData($user_id);
        if (count($shoppergroup) > 0) {
            $shopper_group_id = $shoppergroup->shopper_group_id;
            $whereshopper = ' AND (FIND_IN_SET(' . (int) $shopper_group_id . ', shipping_rate_on_shopper_group ) OR shipping_rate_on_shopper_group="") ';
        }
        if ($country) {
            $wherecountry = '(FIND_IN_SET(' . $db->quote($country) . ', shipping_rate_country ) OR shipping_rate_country="0" OR shipping_rate_country="")';
        } else {
            $wherecountry = '(FIND_IN_SET(' . $db->quote(DEFAULT_SHIPPING_COUNTRY) . ', shipping_rate_country ) OR shipping_rate_country="0"
			OR shipping_rate_country="")';
        }
        if ($state) {
            $wherestate = ' AND (FIND_IN_SET(' . $db->quote($state) . ', shipping_rate_state ) OR shipping_rate_state="0" OR shipping_rate_state="")';
        }
        if (!$is_company) {
            $iswhere = " AND ( company_only = 2 or company_only = 0) ";
        } else {
            $iswhere = " AND ( company_only = 1 or company_only = 0) ";
        }
        $shippingArr = $this->getShopperGroupDefaultShipping();
        $shopper_shipping = 0;
        if (empty($shippingArr)) {
            $cart = $session->get('cart');
            $idx = (int) $cart['idx'];
            $totalVolume = 0;
            $shippingrate = array();
            if ($idx) {
                $pwhere = 'AND ( ';
                for ($i = 0; $i < $idx; $i++) {
                    $product_id = $cart[$i]['product_id'];
                    $pwhere .= 'FIND_IN_SET(' . (int) $product_id . ', shipping_rate_on_product)';
                    if ($i != $idx - 1) {
                        $pwhere .= " or ";
                    }
                }
                $pwhere .= ")";
                $newpwhere = str_replace("AND (", "OR (", $pwhere);
                $sql = "SELECT * FROM " . $this->_table_prefix . "shipping_rate as sr " . "LEFT JOIN #__extensions AS s ON sr.shipping_class = s.element\n\t\t \t     \t\t\t\t WHERE s.folder='redshop_shipping' and s.enabled =1  and  {$wherecountry}\n\t\t\t\t\t\t\t\t {$iswhere}\n\t\t\t\t\t\t\t\t AND ((shipping_rate_volume_start <= " . $db->quote($volume) . " AND  shipping_rate_volume_end >= " . $db->quote($volume) . ") OR (shipping_rate_volume_end = 0) )\n\t\t\t\t\t\t\t\t AND ((shipping_rate_ordertotal_start <= " . $db->quote($order_subtotal) . " AND  shipping_rate_ordertotal_end >= " . $db->quote($order_subtotal) . ")  OR (shipping_rate_ordertotal_end = 0))\n\t\t\t\t\t\t\t\t AND ((shipping_rate_weight_start <= " . $db->quote($weighttotal) . " AND  shipping_rate_weight_end >= " . $db->quote($weighttotal) . ")  OR (shipping_rate_weight_end = 0))\n\t\t\t\t\t\t\t\t {$pwhere} {$wherestate} {$whereshopper}\n\t\t\t\t\t\t\t\t   ORDER BY s.ordering, sr.shipping_rate_priority  LIMIT 0,1";
                $db->setQuery($sql);
                $shippingrate = $db->loadObject();
            }
            if (!$shippingrate) {
                for ($i = 0; $i < $idx; $i++) {
                    $product_id = $cart[$i]['product_id'];
                    $sel = 'SELECT category_id FROM ' . $this->_table_prefix . 'product_category_xref WHERE product_id = ' . (int) $product_id;
                    $db->setQuery($sel);
                    $categorydata = $db->loadObjectList();
                    $where = ' ';
                    if ($categorydata) {
                        $where = 'AND ( ';
                        for ($c = 0; $c < count($categorydata); $c++) {
                            $where .= " FIND_IN_SET(" . (int) $categorydata[$c]->category_id . ", shipping_rate_on_category) ";
                            if ($c != count($categorydata) - 1) {
                                $where .= " or ";
                            }
                        }
                        $where .= ")";
                        $newcwhere = str_replace("AND (", "OR (", $where);
                        $sql = "SELECT * FROM " . $this->_table_prefix . "shipping_rate as sr\n\t\t\t\t\t\t\t\t\t LEFT JOIN #__extensions AS s\n\t\t\t\t\t\t\t\t\t ON\n\t\t\t\t\t\t\t\t\t sr.shipping_class = s.element\n\t\t\t \t     \t\t\t\t WHERE  s.folder='redshop_shipping' and s.enabled =1 and {$wherecountry} {$whereshopper}\n\t\t\t\t\t\t\t\t\t {$iswhere}\n\t\t\t\t\t\t\t\t\t AND ((shipping_rate_volume_start <= " . $db->quote($volume) . " AND  shipping_rate_volume_end >= " . $db->quote($volume) . ") OR (shipping_rate_volume_end = 0) )\n\t\t\t\t\t\t\t\t\t AND ((shipping_rate_ordertotal_start <= " . $db->quote($order_subtotal) . " AND  shipping_rate_ordertotal_end >= " . $db->quote($order_subtotal) . ")  OR (shipping_rate_ordertotal_end = 0))\n\t\t\t\t\t\t\t\t\t AND ((shipping_rate_weight_start <= " . $db->quote($weighttotal) . " AND  shipping_rate_weight_end >= " . $db->quote($weighttotal) . ")  OR (shipping_rate_weight_end = 0))\n\t\t\t\t\t\t\t\t\t {$where} {$wherestate}\n\t\t\t\t\t\t\t\t\tORDER BY s.ordering, sr.shipping_rate_priority  LIMIT 0,1";
                        $db->setQuery($sql);
                        $shippingrate = $db->loadObject();
                    }
                }
            }
            if (!$shippingrate) {
                $sql = "SELECT * FROM " . $this->_table_prefix . "shipping_rate as sr\n\t\t\t\t\t\t\t\t LEFT JOIN #__extensions AS s\n\t\t\t\t\t\t\t\t ON\n\t\t\t\t\t\t\t\t sr.shipping_class = s.element\n\t\t \t     \t\tWHERE s.folder='redshop_shipping' and s.enabled =1  and {$wherecountry} {$whereshopper}\n\t\t\t\t\t\t{$iswhere} {$wherestate}\n\t\t\t\t\t\tAND ((shipping_rate_volume_start <= " . $db->quote($volume) . " AND  shipping_rate_volume_end >= " . $db->quote($volume) . ") OR (shipping_rate_volume_end = 0) )\n\t\t\t\t\t\tAND ((shipping_rate_ordertotal_start <= " . $db->quote($order_subtotal) . " AND  shipping_rate_ordertotal_end >= " . $db->quote($order_subtotal) . ")  OR (shipping_rate_ordertotal_end = 0))\n\t\t\t\t\t\tAND ((shipping_rate_weight_start <= " . $db->quote($weighttotal) . " AND  shipping_rate_weight_end >= " . $db->quote($weighttotal) . ")  OR (shipping_rate_weight_end = 0))\n\t\t\t\t\t\tAND (shipping_rate_on_product = '' {$newpwhere}) AND (shipping_rate_on_category = '' {$newcwhere} )\n\t\t\t\t\t\tORDER BY s.ordering, sr.shipping_rate_priority  LIMIT 0,1";
                $db->setQuery($sql);
                $shippingrate = $db->loadObject();
            }
            $total = 0;
            $shipping_vat = 0;
            if ($shippingrate) {
                $total = $shippingrate->shipping_rate_value;
                if ($shippingrate->apply_vat == 1) {
                    $result = $this->getShippingVatRates($shippingrate->shipping_tax_group_id, $user_id);
                    $chk = $this->producthelper->taxexempt_addtocart($user_id);
                    if (!empty($result) && !empty($chk)) {
                        if ($result->tax_rate > 0) {
                            $shipping_vat = $total * $result->tax_rate;
                            $total = $shipping_vat + $total;
                        }
                    }
                }
            }
            $shipArr['shipping_rate'] = $total;
            $shipArr['shipping_vat'] = $shipping_vat;
            return $shipArr;
        } else {
            return $shippingArr;
        }
    }
Beispiel #13
0
 public function customerInformation()
 {
     $order_functions = new order_functions();
     $query = "SELECT vmui.* , vmsvx.shopper_group_id FROM `#__vm_user_info` AS vmui " . "LEFT JOIN #__vm_shopper_vendor_xref AS vmsvx ON vmui.user_id = vmsvx.user_id ";
     $this->_db->setQuery($query);
     $data = $this->_db->loadObjectList();
     $k = 0;
     for ($i = 0; $i < count($data); $i++) {
         if ($data[$i]->address_type == "BT") {
             $redshopUser = $order_functions->getBillingAddress($data[$i]->user_id);
             if (count($redshopUser) > 0) {
                 $redUserId = $redshopUser->users_info_id;
                 $row = $this->getTable('user_detail');
                 $row->load($redUserId);
                 $row->user_email = $data[$i]->user_email;
                 $row->shopper_group_id = $data[$i]->shopper_group_id;
                 $row->firstname = $data[$i]->first_name;
                 $row->lastname = $data[$i]->last_name;
                 $row->company_name = $data[$i]->company;
                 $row->address = $data[$i]->address_1;
                 $row->city = $data[$i]->city;
                 $row->country_code = $data[$i]->country;
                 $row->state_code = $data[$i]->state;
                 $row->zipcode = $data[$i]->zip;
                 $row->phone = $data[$i]->phone_1;
                 if ($row->store()) {
                     $k++;
                 }
             } else {
                 $rows = $this->getTable('user_detail');
                 $rows->load();
                 $rows->user_id = $data[$i]->user_id;
                 $rows->user_email = $data[$i]->user_email;
                 $rows->shopper_group_id = $data[$i]->shopper_group_id;
                 $rows->firstname = $data[$i]->first_name;
                 $rows->address_type = $data[$i]->address_type;
                 $rows->lastname = $data[$i]->last_name;
                 $rows->company_name = $data[$i]->company;
                 $rows->address = $data[$i]->address_1;
                 $rows->city = $data[$i]->city;
                 $rows->country_code = $data[$i]->country;
                 $rows->state_code = $data[$i]->state;
                 $rows->zipcode = $data[$i]->zip;
                 $rows->phone = $data[$i]->phone_1;
                 if ($rows->store()) {
                     $k++;
                 }
             }
         } else {
             $rows = $this->getTable('user_detail');
             $rows->load();
             $rows->user_id = $data[$i]->user_id;
             $rows->user_email = $data[$i]->user_email;
             $rows->shopper_group_id = $data[$i]->shopper_group_id;
             $rows->firstname = $data[$i]->first_name;
             $rows->address_type = $data[$i]->address_type;
             $rows->lastname = $data[$i]->last_name;
             $rows->company_name = $data[$i]->company;
             $rows->address = $data[$i]->address_1;
             $rows->city = $data[$i]->city;
             $rows->country_code = $data[$i]->country;
             $rows->state_code = $data[$i]->state;
             $rows->zipcode = $data[$i]->zip;
             $rows->phone = $data[$i]->phone_1;
             if ($rows->store()) {
                 $k++;
             }
         }
     }
     return $k;
 }