public function save($send = 0) { $post = JRequest::get('post'); $adminproducthelper = new adminproducthelper(); $option = JRequest::getVar('option', '', 'request', 'string'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['quotation_id'] = $cid[0]; $model = $this->getModel('addquotation_detail'); if (!$post['users_info_id']) { $name = $post['firstname'] . ' ' . $post['lastname']; $post['usertype'] = "Registered"; $post['email'] = $post['user_email']; $post['username'] = JRequest::getVar('username', '', 'post', 'username'); $post['name'] = $name; JRequest::getVar('password1', $post['password']); $post['groups'] = array(0 => 2); $date = JFactory::getDate(); $post['registerDate'] = $date->toMySQL(); $post['block'] = 0; // Get Admin order detail Model Object $usermodel = JModel::getInstance('user_detail', 'user_detailModel'); // Call Admin order detail Model store function for Billing $user = $usermodel->storeUser($post); if (!$user) { $this->setError($this->_db->getErrorMsg()); return false; } $post['user_id'] = $user->user_id; $user_id = $user->user_id; $user_data = new stdClass(); $post['users_info_id'] = $user_data->users_info_id; if (count($user) <= 0) { $this->setRedirect('index.php?option=' . $option . '&view=quotaion_detail&user_id=' . $user_id); } } $orderItem = $adminproducthelper->redesignProductItem($post); $post['order_item'] = $orderItem; $post['user_info_id'] = $post['users_info_id']; $row = $model->store($post); if ($row) { $msg = JText::_('COM_REDSHOP_QUOTATION_DETAIL_SAVED'); if ($send == 1) { if ($model->sendQuotationMail($row->quotation_id)) { $msg = JText::_('COM_REDSHOP_QUOTATION_DETAIL_SENT'); } } } else { $msg = JText::_('COM_REDSHOP_ERROR_SAVING_QUOTATION_DETAIL'); } $this->setRedirect('index.php?option=' . $option . '&view=quotation', $msg); }
public function neworderitem() { $adminproducthelper = new adminproducthelper(); $stockroomhelper = new rsstockroomhelper(); $post = JRequest::get('post'); $tmpl = ""; if (isset($post['tmpl'])) { $tmpl = $post['tmpl']; } $option = JRequest::getVar('option', '', 'request', 'string'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $order_item_id = JRequest::getVar('order_item_id', 0, 'post', ''); $model = $this->getModel('order_detail'); $orderItem = $adminproducthelper->redesignProductItem($post); $post['order_item'] = $orderItem; $product_id = $orderItem[0]->product_id; $finalquantity = $quantity = $orderItem[0]->quantity; // Check product Quantity if (USE_STOCKROOM == 1) { $currentStock = $stockroomhelper->getStockroomTotalAmount($product_id); if ($currentStock >= $quantity) { $finalquantity = (int) $quantity; } else { $finalquantity = (int) $currentStock; } } if ($finalquantity > 0) { if ($model->neworderitem($post, $finalquantity, $order_item_id)) { if ($order_item_id == 0) { $msg = JText::_('COM_REDSHOP_ORDER_ITEM_ADDED'); } else { $msg = JText::_('COM_REDSHOP_QUANTITY_UPDATED'); } } else { if ($order_item_id == 0) { $msg = JText::_('COM_REDSHOP_ERROR_ADDING_ORDER_ITEM'); } else { $msg = JText::_('COM_REDSHOP_ERROR_UPDATING_QUANTITY'); } } } else { $msg = JText::_('COM_REDSHOP_PRODUCT_OUT_OF_STOCK'); } if ($tmpl) { $this->setRedirect('index.php?option=' . $option . '&view=order_detail&cid[]=' . $cid[0] . '&tmpl=' . $tmpl, $msg); } else { $this->setRedirect('index.php?option=' . $option . '&view=order_detail&cid[]=' . $cid[0], $msg); } }
public function save($apply = 0) { $post = JRequest::get('post'); $adminproducthelper = new adminproducthelper(); $order_functions = new order_functions(); $shippinghelper = new shipping(); $option = JRequest::getVar('option', '', 'request', 'string'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['order_id'] = $cid[0]; $model = $this->getModel('addorder_detail'); $post['order_number'] = $order_number = $order_functions->generateOrderNumber(); $orderItem = $adminproducthelper->redesignProductItem($post); $post['order_item'] = $orderItem; // Check product Quantity $stocknote = ''; if (USE_STOCKROOM == 1) { $stockroomhelper = new rsstockroomhelper(); $producthelper = new producthelper(); for ($i = 0; $i < count($orderItem); $i++) { $quantity = $orderItem[$i]->quantity; $productData = $producthelper->getProductById($orderItem[$i]->product_id); if ($productData->min_order_product_quantity > 0 && $productData->min_order_product_quantity > $quantity) { $msg = $productData->product_name . " " . JText::_('WARNING_MSG_MINIMUM_QUANTITY'); $stocknote .= sprintf($msg, $productData->min_order_product_quantity) . "<br/>"; $quantity = $productData->min_order_product_quantity; } $currentStock = $stockroomhelper->getStockroomTotalAmount($orderItem[$i]->product_id); $finalquantity = $currentStock >= $quantity ? (int) $quantity : (int) $currentStock; if ($finalquantity > 0) { if ($productData->max_order_product_quantity > 0 && $productData->max_order_product_quantity < $finalquantity) { $msg = $productData->product_name . " " . JText::_('WARNING_MSG_MAXIMUM_QUANTITY') . "<br/>"; $stocknote .= sprintf($msg, $productData->max_order_product_quantity); $finalquantity = $productData->max_order_product_quantity; } $orderItem[$i]->quantity = $finalquantity; } else { $stocknote .= $productData->product_name . " " . JText::_('PRODUCT_OUT_OF_STOCK') . "<br/>"; unset($orderItem[$i]); } } $orderItem = array_merge(array(), $orderItem); if (count($orderItem) <= 0) { $msg = JText::_('PRODUCT_OUT_OF_STOCK'); $this->setRedirect('index.php?option=' . $option . '&view=addorder_detail&user_id=' . $post['user_id'] . '&shipping_users_info_id=' . $post['shipp_users_info_id'], $msg); return; } } $order_total = $post['order_total']; $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $post['shipping_rate_id']))); if (count($order_shipping) > 4) { $post['order_shipping'] = $order_shipping[3]; $order_total = $order_total + $order_shipping[3]; $post['order_shipping_tax'] = $order_shipping[6]; } $tmporder_total = $order_total; if (array_key_exists("issplit", $post) && $post['issplit']) { $tmporder_total = $order_total / 2; } $paymentmethod = $order_functions->getPaymentMethodInfo($post['payment_method_class']); $paymentmethod = $paymentmethod[0]; $paymentparams = new JRegistry($paymentmethod->params); $paymentinfo = new stdclass(); $post['economic_payment_terms_id'] = $paymentparams->get('economic_payment_terms_id'); $post['economic_design_layout'] = $paymentparams->get('economic_design_layout'); $paymentinfo->payment_price = $paymentparams->get('payment_price', ''); $paymentinfo->is_creditcard = $post['economic_is_creditcard'] = $paymentparams->get('is_creditcard', ''); $paymentinfo->payment_oprand = $paymentparams->get('payment_oprand', ''); $paymentinfo->accepted_credict_card = $paymentparams->get("accepted_credict_card"); $paymentinfo->payment_discount_is_percent = $paymentparams->get('payment_discount_is_percent', ''); $cartHelper = new rsCartHelper(); $subtotal = $post['order_subtotal']; $update_discount = 0; if ($post['update_discount'] > 0) { $update_discount = $post['update_discount']; if ($update_discount > $subtotal) { $update_discount = $subtotal; } if ($update_discount != 0) { $order_total = $order_total - $update_discount; } } $special_discount = $post['special_discount']; $subtotal_excl_vat = 0; for ($i = 0; $i < count($orderItem); $i++) { $subtotal_excl_vat = $subtotal_excl_vat + $orderItem[$i]->prdexclprice * $orderItem[$i]->quantity; } if (APPLY_VAT_ON_DISCOUNT) { $amt = $subtotal; } else { $amt = $subtotal_excl_vat; } $discount_price = $amt * $special_discount / 100; $post['special_discount'] = $special_discount; $post['special_discount_amount'] = $discount_price; $order_total = $order_total - $discount_price; if (PAYMENT_CALCULATION_ON == 'subtotal') { $paymentAmount = $subtotal; } else { $paymentAmount = $order_total; } $paymentMethod = $cartHelper->calculatePayment($paymentAmount, $paymentinfo, $order_total); $post['ship_method_id'] = urldecode(urldecode($post['shipping_rate_id'])); $order_total = $paymentMethod[0]; $post['user_info_id'] = $post['users_info_id']; $post['payment_discount'] = $paymentMethod[1]; $post['payment_oprand'] = $paymentinfo->payment_oprand; $post['order_discount'] = $update_discount; $post['order_total'] = $order_total; $post['order_payment_amount'] = $tmporder_total; $post['order_payment_name'] = $paymentmethod->name; if ($apply == 1) { $post['order_payment_status'] = 'Unpaid'; $post['order_status'] = 'P'; } if ($row = $model->store($post)) { $msg = JText::_('COM_REDSHOP_ORDER_DETAIL_SAVED'); } else { $msg = JText::_('COM_REDSHOP_ERROR_SAVING_ORDER_DETAIL'); } if ($apply == 1) { $objorder = new order_functions(); $objorder->getpaymentinformation($row, $post); } else { $this->setRedirect('index.php?option=' . $option . '&view=order', $msg . $stocknote); } }
public function newQuotationItem() { $adminproducthelper = new adminproducthelper(); $post = JRequest::get('post'); $option = JRequest::getVar('option', '', 'request', 'string'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $model = $this->getModel('quotation_detail'); $quotationItem = $adminproducthelper->redesignProductItem($post); $post['quotation_item'] = $quotationItem; if ($model->newQuotationItem($post)) { $msg = JText::_('COM_REDSHOP_QUOTATION_ITEM_ADDED'); } else { $msg = JText::_('COM_REDSHOP_ERROR_ADDING_QUOTATION_ITEM'); } $this->setRedirect('index.php?option=' . $option . '&view=quotation_detail&cid[]=' . $cid[0], $msg); }