Beispiel #1
0
 /**
  * checkout function
  *
  * @access public
  * @return void
  */
 public function checkout()
 {
     $option = JRequest::getVar('option');
     $Itemid = JRequest::getVar('Itemid');
     $post = JRequest::get('post');
     $encr = JRequest::getVar('encr');
     $quotationHelper = new quotationHelper();
     $model = $this->getmodel();
     $session = JFactory::getSession();
     $redhelper = new redhelper();
     $cart = array();
     $cart['idx'] = 0;
     $session->set('cart', $cart);
     $quotationProducts = $quotationHelper->getQuotationProduct($post['quotation_id']);
     for ($q = 0; $q < count($quotationProducts); $q++) {
         $model->addtocart($quotationProducts[$q]);
     }
     $cart = $session->get('cart');
     $quotationDetail = $quotationHelper->getQuotationDetail($post['quotation_id']);
     $cart['customer_note'] = $quotationDetail->quotation_note;
     $cart['quotation_id'] = $quotationDetail->quotation_id;
     $cart['cart_discount'] = $quotationDetail->quotation_discount;
     $cart['quotation'] = 1;
     $session->set('cart', $cart);
     $model->modifyQuotation($quotationDetail->user_id);
     $Itemid = $redhelper->getCheckoutItemid();
     $this->setRedirect('index.php?option=' . $option . '&view=checkout&quotation=1&encr=' . $encr . '&Itemid=' . $Itemid);
 }
Beispiel #2
0
 public function makeAttributeQuotation($quotation_item_id = 0, $is_accessory = 0, $parent_section_id = 0, $quotation_status = 2, $stock = 0)
 {
     $quotationHelper = new quotationHelper();
     $displayattribute = "";
     $product_attribute = "";
     $quantity = 0;
     $stockroom_id = "0";
     $Itemdata = $quotationHelper->getQuotationProduct(0, $quotation_item_id);
     if (count($Itemdata) > 0 && $is_accessory != 1) {
         $product_attribute = $Itemdata[0]->product_attribute;
         $quantity = $Itemdata[0]->product_quantity;
     }
     $ItemAttdata = $quotationHelper->getQuotationItemAttributeDetail($quotation_item_id, $is_accessory, "attribute", $parent_section_id);
     if (count($ItemAttdata) > 0) {
         for ($i = 0; $i < count($ItemAttdata); $i++) {
             $displayattribute .= "<div class='checkout_attribute_title'>" . urldecode($ItemAttdata[$i]->section_name) . "</div>";
             $propdata = $quotationHelper->getQuotationItemAttributeDetail($quotation_item_id, $is_accessory, "property", $ItemAttdata[$i]->section_id);
             for ($p = 0; $p < count($propdata); $p++) {
                 $displayattribute .= "<div class='checkout_attribute_price'>" . urldecode($propdata[$p]->section_name) . " ";
                 if ($quotation_status != 1 || $quotation_status == 1 && SHOW_QUOTATION_PRICE == 1) {
                     $propertyOprand = $propdata[$p]->section_oprand;
                     $propertyPrice = $this->getProductFormattedPrice($propdata[$p]->section_price);
                     $propertyPriceWithVat = $this->getProductFormattedPrice($propdata[$p]->section_price + $propdata[$p]->section_vat);
                     $displayattribute .= "( {$propertyOprand} {$propertyPrice} excl. vat / {$propertyPriceWithVat})";
                 }
                 $displayattribute .= "</div>";
                 $subpropdata = $quotationHelper->getQuotationItemAttributeDetail($quotation_item_id, $is_accessory, "subproperty", $propdata[$p]->section_id);
                 for ($sp = 0; $sp < count($subpropdata); $sp++) {
                     $displayattribute .= "<div class='checkout_subattribute_price'>" . urldecode($subpropdata[$sp]->section_name) . " ";
                     if ($quotation_status != 1 || $quotation_status == 1 && SHOW_QUOTATION_PRICE == 1) {
                         $subpropertyOprand = $subpropdata[$sp]->section_oprand;
                         $subpropertyPrice = $this->getProductFormattedPrice($subpropdata[$sp]->section_price);
                         $subpropertyPriceWithVat = $this->getProductFormattedPrice($subpropdata[$sp]->section_price + $subpropdata[$sp]->section_vat);
                         $displayattribute .= "( {$subpropertyOprand} {$subpropertyPrice} excl. vat {$subpropertyPriceWithVat})";
                     }
                     $displayattribute .= "</div>";
                 }
             }
         }
     } else {
         $displayattribute = $product_attribute;
     }
     return $displayattribute;
 }
 public function delete($cid = array())
 {
     $producthelper = new producthelper();
     $order_functions = new order_functions();
     $quotationHelper = new quotationHelper();
     $stockroomhelper = new rsstockroomhelper();
     if (count($cid)) {
         if (ECONOMIC_INTEGRATION == 1) {
             $economic = new economic();
             for ($i = 0; $i < count($cid); $i++) {
                 $orderdata = $this->getTable('order_detail');
                 $orderdata->load($cid[$i]);
                 $invoiceHandle = $economic->deleteInvoiceInEconomic($orderdata);
             }
         }
         $cids = implode(',', $cid);
         $db = JFactory::getDbo();
         $order_item = $order_functions->getOrderItemDetail($cids);
         for ($i = 0; $i < count($order_item); $i++) {
             $quntity = $order_item[$i]->product_quantity;
             $order_id = $order_item[$i]->order_id;
             $order_detail = $order_functions->getOrderDetails($order_id);
             if ($order_detail->order_payment_status == "Unpaid") {
                 // Update stock roommanageStockAmount
                 $stockroomhelper->manageStockAmount($order_item[$i]->product_id, $quntity, $order_item[$i]->stockroom_id);
             }
             $producthelper->makeAttributeOrder($order_item[$i]->order_item_id, 0, $order_item[$i]->product_id, 1);
             $query = "DELETE FROM `" . $this->_table_prefix . "order_attribute_item` " . "WHERE `order_item_id` = " . $order_item[$i]->order_item_id;
             $this->_db->setQuery($query);
             $this->_db->query();
             $query = "DELETE FROM `" . $this->_table_prefix . "order_acc_item` " . "WHERE `order_item_id` = " . $order_item[$i]->order_item_id;
             $this->_db->setQuery($query);
             $this->_db->query();
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'orders WHERE order_id IN ( ' . $cids . ' )';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'order_item WHERE order_id IN ( ' . $cids . ' )';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'order_payment WHERE order_id IN ( ' . $cids . ' )';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'order_users_info WHERE order_id IN ( ' . $cids . ' )';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $quotation = $quotationHelper->getQuotationwithOrder($cids);
         for ($q = 0; $q < count($quotation); $q++) {
             $quotation_item = $quotationHelper->getQuotationProduct($quotation[$q]->quotation_id);
             for ($j = 0; $j < count($quotation_item); $j++) {
                 $query = 'DELETE FROM ' . $this->_table_prefix . 'quotation_fields_data ' . 'WHERE quotation_item_id=' . $quotation_item[$j]->quotation_item_id;
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
             }
             $query = 'DELETE FROM ' . $this->_table_prefix . 'quotation_item ' . 'WHERE quotation_id=' . $quotation[$q]->quotation_id;
             $this->_db->setQuery($query);
             if (!$this->_db->query()) {
                 $this->setError($this->_db->getErrorMsg());
                 return false;
             }
         }
         $query = 'DELETE FROM ' . $this->_table_prefix . 'quotation WHERE order_id IN ( ' . $cids . ' )';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     return true;
 }
Beispiel #4
0
$url = JURI::base();
$redconfig = new Redconfiguration();
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/quotation.php';
$quotationHelper = new quotationHelper();
$extra_field = new extra_field();
$extra_field_new = new extraField();
require_once JPATH_COMPONENT . '/helpers/product.php';
$producthelper = new producthelper();
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/order.php';
$order_functions = new order_functions();
$redTemplate = new Redtemplate();
$Itemid = JRequest::getInt('Itemid', 1);
$quoid = JRequest::getInt('quoid');
$encr = JRequest::getString('encr');
$quotationDetail = $quotationHelper->getQuotationDetail($quoid);
$quotationProducts = $quotationHelper->getQuotationProduct($quoid);
$fieldArray = $extra_field_new->getSectionFieldList(17, 0, 0);
$template = $redTemplate->getTemplate("quotation_detail");
if (count($template) > 0 && $template[0]->template_desc != "") {
    $quotation_template = $template[0]->template_desc;
} else {
    $quotation_template = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" width=\"100%\">\r\n<tbody>\r\n<tr>\r\n<td colspan=\"2\">\r\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">\r\n<tbody>\r\n<tr style=\"background-color: #cccccc\">\r\n<th align=\"left\">{quotation_information_lbl}{print}</th>\r\n</tr>\r\n<tr>\r\n</tr>\r\n<tr>\r\n<td>{quotation_id_lbl} : {quotation_id}</td>\r\n</tr>\r\n<tr>\r\n<td>{quotation_number_lbl} : {quotation_number}</td>\r\n</tr>\r\n<tr>\r\n<td>{quotation_date_lbl} : {quotation_date}</td>\r\n</tr>\r\n<tr>\r\n<td>{quotation_status_lbl} : {quotation_status}</td>\r\n</tr>\r\n<tr>\r\n<td>{quotation_note_lbl} : {quotation_note}</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n</td>\r\n</tr>\r\n<tr>\r\n<td colspan=\"2\">\r\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">\r\n<tbody>\r\n<tr style=\"background-color: #cccccc\">\r\n<th align=\"left\">{account_information_lbl}</th>\r\n</tr>\r\n<tr>\r\n<td>{account_information}{quotation_custom_field_list}</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n</td>\r\n</tr>\r\n<tr>\r\n<td colspan=\"2\">\r\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">\r\n<tbody>\r\n<tr style=\"background-color: #cccccc\">\r\n<th align=\"left\">{quotation_detail_lbl}</th>\r\n</tr>\r\n<tr>\r\n</tr>\r\n<tr>\r\n<td>\r\n<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\r\n<tbody>\r\n<tr>\r\n<td></td>\r\n<td>{product_name_lbl}</td>\r\n<td>{note_lbl}</td>\r\n<td>{price_lbl}</td>\r\n<td>{quantity_lbl}</td>\r\n<td align=\"right\">{total_price_lbl}</td>\r\n</tr>\r\n{product_loop_start}       \r\n<tr>\r\n<td>{product_thumb_image}</td>\r\n<td>{product_name}<br />({product_number_lbl} - {product_number})<br />{product_accessory}<br /> {product_attribute}<br />{product_userfields}</td>\r\n<td>{product_wrapper}</td>\r\n<td>{product_price}</td>\r\n<td>{product_quantity}</td>\r\n<td align=\"right\">{product_total_price}</td>\r\n</tr>\r\n{product_loop_end}\r\n</tbody>\r\n</table>\r\n</td>\r\n</tr>\r\n<tr>\r\n<td></td>\r\n</tr>\r\n<tr>\r\n<td>\r\n<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\r\n<tbody>\r\n<tr align=\"left\">\r\n<td align=\"left\"><strong>{quotation_subtotal_lbl} : </strong></td>\r\n<td align=\"right\">{quotation_subtotal}</td>\r\n</tr>\r\n<tr align=\"left\">\r\n<td align=\"left\"><strong>{quotation_vat_lbl} : </strong></td>\r\n<td align=\"right\">{quotation_vat}</td>\r\n</tr>\r\n<tr align=\"left\">\r\n<td align=\"left\"><strong>{quotation_discount_lbl} : </strong></td>\r\n<td align=\"right\">{quotation_discount}</td>\r\n</tr>\r\n<tr align=\"left\">\r\n<td colspan=\"2\" align=\"left\">\r\n<hr />\r\n</td>\r\n</tr>\r\n<tr align=\"left\">\r\n<td align=\"left\"><strong>{total_lbl} :</strong></td>\r\n<td align=\"right\">{quotation_total}</td>\r\n</tr>\r\n<tr align=\"left\">\r\n<td colspan=\"2\" align=\"left\">\r\n<hr />\r\n<br /> \r\n<hr />\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>";
}
$print = JRequest::getInt('print');
$p_url = @explode('?', $_SERVER['REQUEST_URI']);
$print_tag = '';
if ($print) {
    $print_tag = "<a onclick='window.print();' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' ><img src=" . JSYSTEM_IMAGES_PATH . "printButton.png  alt='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' /></a>";
} else {
    $print_url = $url . "index.php?tmpl=component&option=com_redshop&view=quotation_detail&quoid=" . $quoid . "&print=1";
    $print_tag = "<a href='#' onclick='window.open(\"{$print_url}\",\"mywindow\",\"scrollbars=1\",\"location=1\")' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' ><img src=" . JSYSTEM_IMAGES_PATH . "printButton.png  alt='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' /></a>";
Beispiel #5
0
 public function sendQuotationMail($quotation_id, $status = 0)
 {
     $uri = JURI::getInstance();
     $url = $uri->root();
     $redconfig = new Redconfiguration();
     $producthelper = new producthelper();
     $extra_field = new extra_field();
     $quotationHelper = new quotationHelper();
     $config = JFactory::getConfig();
     $mailinfo = $this->getMailtemplate(0, "quotation_mail");
     $mailbcc = array();
     if (count($mailinfo) > 0) {
         $message = $mailinfo[0]->mail_body;
         $subject = $mailinfo[0]->mail_subject;
         if (trim($mailinfo[0]->mail_bcc) != "") {
             $mailbcc = explode(",", $mailinfo[0]->mail_bcc);
         }
     } else {
         return false;
     }
     $template_start = "";
     $template_end = "";
     $template_middle = "";
     $cart = '';
     $template_sdata = explode('{product_loop_start}', $message);
     $extraField = new extraField();
     $fieldArray = $extraField->getSectionFieldList(17, 0, 0);
     if (count($template_sdata) > 0) {
         $template_start = $template_sdata[0];
         if (count($template_sdata) > 1) {
             $template_edata = explode('{product_loop_end}', $template_sdata[1]);
             if (count($template_edata) > 1) {
                 $template_end = $template_edata[1];
             }
             if (count($template_edata) > 0) {
                 $template_middle = $template_edata[0];
             }
         }
     }
     $row = $quotationHelper->getQuotationDetail($quotation_id);
     if (count($row) <= 0) {
         return false;
     }
     $rowitem = $quotationHelper->getQuotationProduct($quotation_id);
     for ($i = 0; $i < count($rowitem); $i++) {
         $product_id = $rowitem[$i]->product_id;
         $product = $producthelper->getProductById($product_id);
         $product_name = "<div class='product_name'>" . $rowitem[$i]->product_name . "</div>";
         $product_total_price = "<div class='product_price'>" . $producthelper->getProductFormattedPrice($rowitem[$i]->product_price * $rowitem[$i]->product_quantity) . "</div>";
         $product_price = "<div class='product_price'>" . $producthelper->getProductFormattedPrice($rowitem[$i]->product_price) . "</div>";
         $product_price_excl_vat = "<div class='product_price'>" . $producthelper->getProductFormattedPrice($rowitem[$i]->product_excl_price) . "</div>";
         $product_quantity = '<div class="update_cart">' . $rowitem[$i]->product_quantity . '</div>';
         $product_total_price_excl_vat = "<div class='product_price'>" . $producthelper->getProductFormattedPrice($rowitem[$i]->product_excl_price * $rowitem[$i]->product_quantity) . "</div>";
         $cart_mdata = $template_middle;
         $wrapper_name = "";
         if ($rowitem[$i]->product_wrapperid) {
             $wrapper = $producthelper->getWrapper($product_id, $rowitem[$i]->product_wrapperid);
             if (count($wrapper) > 0) {
                 $wrapper_name = $wrapper[0]->wrapper_name;
             }
             $wrapper_name = JText::_('COM_REDSHOP_WRAPPER') . ": " . $wrapper_name;
         }
         $product_image_path = '';
         if ($product->product_full_image) {
             if (is_file(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . $product->product_full_image)) {
                 $product_image_path = $product->product_full_image;
             } else {
                 if (is_file(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . PRODUCT_DEFAULT_IMAGE)) {
                     $product_image_path = PRODUCT_DEFAULT_IMAGE;
                 }
             }
         } else {
             if (is_file(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . PRODUCT_DEFAULT_IMAGE)) {
                 $product_image_path = PRODUCT_DEFAULT_IMAGE;
             }
         }
         if ($product_image_path) {
             $thumbUrl = RedShopHelperImages::getImagePath($product_image_path, '', 'thumb', 'product', CART_THUMB_WIDTH, CART_THUMB_HEIGHT, USE_IMAGE_SIZE_SWAPPING);
             $product_image = "<div  class='product_image'><img src='" . $thumbUrl . "'></div>";
         } else {
             $product_image = "<div  class='product_image'></div>";
         }
         $cart_mdata = str_replace("{product_name}", $product_name, $cart_mdata);
         $cart_mdata = str_replace("{product_s_desc}", $product->product_s_desc, $cart_mdata);
         $cart_mdata = str_replace("{product_thumb_image}", $product_image, $cart_mdata);
         $product_note = "<div class='product_note'>" . $wrapper_name . "</div>";
         $cart_mdata = str_replace("{product_wrapper}", $product_note, $cart_mdata);
         $product_userfields = $quotationHelper->displayQuotationUserfield($rowitem[$i]->quotation_item_id, 12);
         $cart_mdata = str_replace("{product_userfields}", $product_userfields, $cart_mdata);
         $cart_mdata = str_replace("{product_number_lbl}", JText::_('COM_REDSHOP_PRODUCT_NUMBER'), $cart_mdata);
         $cart_mdata = str_replace("{product_number}", $product->product_number, $cart_mdata);
         $cart_mdata = str_replace("{product_attribute}", $producthelper->makeAttributeQuotation($rowitem[$i]->quotation_item_id, 0, $rowitem[$i]->product_id, $row->quotation_status), $cart_mdata);
         $cart_mdata = str_replace("{product_accessory}", $producthelper->makeAccessoryQuotation($rowitem[$i]->quotation_item_id, $row->quotation_status), $cart_mdata);
         // ProductFinderDatepicker Extra Field Start
         $cart_mdata = $producthelper->getProductFinderDatepickerValue($cart_mdata, $product_id, $fieldArray);
         // ProductFinderDatepicker Extra Field End
         if ($row->quotation_status == 1 && !SHOW_QUOTATION_PRICE) {
             $cart_mdata = str_replace("{product_price_excl_vat}", "", $cart_mdata);
             $cart_mdata = str_replace("{product_price}", " ", $cart_mdata);
             $cart_mdata = str_replace("{product_total_price}", " ", $cart_mdata);
             $cart_mdata = str_replace("{product_subtotal_excl_vat}", " ", $cart_mdata);
         } else {
             $cart_mdata = str_replace("{product_price_excl_vat}", $product_price_excl_vat, $cart_mdata);
             $cart_mdata = str_replace("{product_price}", $product_price, $cart_mdata);
             $cart_mdata = str_replace("{product_total_price}", $product_total_price, $cart_mdata);
             $cart_mdata = str_replace("{product_subtotal_excl_vat}", $product_total_price_excl_vat, $cart_mdata);
         }
         $cart_mdata = str_replace("{product_quantity}", $product_quantity, $cart_mdata);
         $cart .= $cart_mdata;
     }
     $message = $template_start . $cart . $template_end;
     $search[] = "{quotation_note}";
     $replace[] = $row->quotation_note;
     $search[] = "{shopname}";
     $replace[] = SHOP_NAME;
     $search[] = "{quotation_id}";
     $replace[] = $row->quotation_id;
     $search[] = "{quotation_number}";
     $replace[] = $row->quotation_number;
     $search[] = "{quotation_date}";
     $replace[] = $redconfig->convertDateFormat($row->quotation_cdate);
     $search[] = "{quotation_status}";
     $replace[] = $quotationHelper->getQuotationStatusName($row->quotation_status);
     $billadd = '';
     if ($row->user_id != 0) {
         $message = $this->_carthelper->replaceBillingAddress($message, $row);
     } else {
         if ($row->quotation_email != "") {
             $billadd .= JText::_("COM_REDSHOP_EMAIL") . ' : ' . $row->quotation_email . '<br />';
         }
         $message = str_replace("{billing_address_information_lbl}", JText::_('COM_REDSHOP_BILLING_ADDRESS_INFORMATION_LBL'), $message);
         if (strstr($message, "{quotation_custom_field_list}")) {
             $billadd .= $extra_field->list_all_field_display(16, $row->user_info_id, 1, $row->quotation_email);
             $message = str_replace("{quotation_custom_field_list}", "", $message);
         } else {
             $message = $extra_field->list_all_field_display(16, $row->user_info_id, 1, $row->quotation_email, $message);
         }
     }
     $search[] = "{billing_address}";
     $replace[] = $billadd;
     $total_lbl = '';
     $subtotal_lbl = '';
     $vat_lbl = '';
     if ($row->quotation_status != 1 || $row->quotation_status == 1 && SHOW_QUOTATION_PRICE) {
         $total_lbl = JText::_('COM_REDSHOP_TOTAL_LBL');
         $subtotal_lbl = JText::_('COM_REDSHOP_QUOTATION_SUBTOTAL');
         $vat_lbl = JText::_('COM_REDSHOP_QUOTATION_VAT');
     }
     $message = str_replace('{total_lbl}', $total_lbl, $message);
     $message = str_replace('{quotation_subtotal_lbl}', $subtotal_lbl, $message);
     $message = str_replace('{quotation_vat_lbl}', $vat_lbl, $message);
     $message = $this->_carthelper->replaceLabel($message);
     $search[] = "{quotation_note}";
     $replace[] = $row->quotation_note;
     if ($row->quotation_status == 1 && !SHOW_QUOTATION_PRICE) {
         $quotation_subtotal = " ";
         $quotation_total = " ";
         $quotation_discount = " ";
         $quotation_vat = " ";
         $quotation_subtotal_excl_vat = "";
     } else {
         $tax = $row->quotation_tax;
         if (VAT_RATE_AFTER_DISCOUNT) {
             $Discountvat = VAT_RATE_AFTER_DISCOUNT * $row->quotation_discount / (1 + VAT_RATE_AFTER_DISCOUNT);
             $row->quotation_discount = $row->quotation_discount - $Discountvat;
             $tax = $tax - $Discountvat;
         }
         if (VAT_RATE_AFTER_DISCOUNT) {
             $sp_discount = $row->quotation_special_discount * ($row->quotation_subtotal + $row->quotation_tax) / 100;
             $Discountspvat = $sp_discount * VAT_RATE_AFTER_DISCOUNT / (1 + VAT_RATE_AFTER_DISCOUNT);
             $DiscountspWithotVat = $sp_discount - $Discountspvat;
             $row->quotation_discount = $row->quotation_discount + $DiscountspWithotVat;
             $tax = $tax - $Discountspvat;
         }
         $quotation_subtotal_excl_vat = $producthelper->getProductFormattedPrice($row->quotation_subtotal);
         $quotation_subtotal_minus_discount = $producthelper->getProductFormattedPrice($row->quotation_subtotal - $row->quotation_discount);
         $quotation_subtotal = $producthelper->getProductFormattedPrice($row->quotation_subtotal);
         $quotation_total = $producthelper->getProductFormattedPrice($row->quotation_total);
         $quotation_discount = $producthelper->getProductFormattedPrice($row->quotation_discount);
         $quotation_vat = $producthelper->getProductFormattedPrice($row->quotation_tax);
     }
     $search[] = "{quotation_subtotal}";
     $replace[] = $quotation_subtotal;
     $search[] = "{quotation_total}";
     $replace[] = $quotation_total;
     $search[] = "{quotation_subtotal_minus_discount}";
     $replace[] = $quotation_subtotal_minus_discount;
     $search[] = "{quotation_subtotal_excl_vat}";
     $replace[] = $quotation_subtotal_excl_vat;
     $search[] = "{quotation_discount}";
     $replace[] = $quotation_discount;
     $search[] = "{quotation_vat}";
     $replace[] = $quotation_vat;
     $quotationdetailurl = JURI::root() . 'index.php?option=com_redshop&view=quotation_detail&quoid=' . $quotation_id . '&encr=' . $row->quotation_encrkey;
     $search[] = "{quotation_detail_link}";
     $replace[] = "<a href='" . $quotationdetailurl . "'>" . JText::_("COM_REDSHOP_QUOTATION_DETAILS") . "</a>";
     $message = str_replace($search, $replace, $message);
     $message = $this->imginmail($message);
     $email = $row->quotation_email;
     // Set the e-mail parameters
     $from = $config->getValue('mailfrom');
     $fromname = $config->getValue('fromname');
     $body = $message;
     $subject = str_replace($search, $replace, $subject);
     // Send the e-mail
     if ($email != "") {
         $bcc = null;
         if (trim(ADMINISTRATOR_EMAIL) != '') {
             $bcc = explode(",", trim(ADMINISTRATOR_EMAIL));
         }
         $bcc = array_merge($bcc, $mailbcc);
         if (!JUtility::sendMail($from, $fromname, $email, $subject, $body, 1, null, $bcc)) {
             $this->setError('ERROR_SENDING_QUOTATION_MAIL');
         }
     }
     if ($status != 0) {
         $quotationHelper->updateQuotationStatus($quotation_id, $status);
     }
     return true;
 }
Beispiel #6
0
JHTML::_('behavior.tooltip');
JHTML::_('behavior.modal');
require_once JPATH_COMPONENT_SITE . '/helpers/product.php';
$producthelper = new producthelper();
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/quotation.php';
$quotationHelper = new quotationHelper();
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/order.php';
$order_functions = new order_functions();
$redconfig = new Redconfiguration();
$option = JRequest::getVar('option');
$model = $this->getModel('quotation_detail');
$extra_field = new extra_field();
$quotation = $this->quotation;
$uri = JURI::getInstance();
$url = $uri->root();
$quotation_item = $quotationHelper->getQuotationProduct($quotation->quotation_id);
?>
<script type="text/javascript">
	var rowCount = 1;
	var qrowCount = <?php 
echo count($quotation_item);
?>
;

	Joomla.submitbutton = function (pressbutton)
	{
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform(pressbutton);
			return;
		}
 public function newQuotationItem($data)
 {
     $quotationHelper = new quotationHelper();
     $rsCarthelper = new rsCarthelper();
     $producthelper = new producthelper();
     $stockroomhelper = new rsstockroomhelper();
     $item = $data['quotation_item'];
     // Get Order Info
     $quotationdata = $this->getTable('quotation_detail');
     $quotationdata->load($this->_id);
     $user_id = $quotationdata->user_id;
     // Set Order Item Info
     $qitemdata = $this->getTable('quotation_item_detail');
     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;
         $product = $producthelper->getProductById($product_id);
         $generateAttributeCart = $rsCarthelper->generateAttributeArray((array) $item[$i], $user_id);
         $retAttArr = $producthelper->makeAttributeCart($generateAttributeCart, $product_id, $user_id, 0, $quantity);
         $product_attribute = $retAttArr[0];
         $generateAccessoryCart = $rsCarthelper->generateAccessoryArray((array) $item[$i], $user_id);
         $retAccArr = $producthelper->makeAccessoryCart($generateAccessoryCart, $product_id, $user_id);
         $product_accessory = $retAccArr[0];
         $wrapper_price = 0;
         $wrapper_vat = 0;
         $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;
         }
         $qitemdata =& $this->getTable('quotation_item_detail');
         $qitemdata->quotation_item_id = 0;
         $qitemdata->quotation_id = $this->_id;
         $qitemdata->product_id = $product_id;
         $qitemdata->is_giftcard = 0;
         $qitemdata->product_name = $product->product_name;
         $qitemdata->actualitem_price = $product_price;
         $qitemdata->product_price = $product_price;
         $qitemdata->product_excl_price = $product_excl_price;
         $qitemdata->product_final_price = $product_price * $quantity;
         $qitemdata->product_attribute = $product_attribute;
         $qitemdata->product_accessory = $product_accessory;
         $qitemdata->product_wrapperid = $item[$i]->wrapper_data;
         $qitemdata->wrapper_price = $wrapper_price;
         $qitemdata->product_quantity = $quantity;
         if (!$qitemdata->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($qitemdata->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('quotation_attribute_item');
                     $rowattitem->quotation_att_item_id = 0;
                     $rowattitem->quotation_item_id = $qitemdata->quotation_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($qitemdata->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('quotation_attribute_item');
                         $rowattitem->quotation_att_item_id = 0;
                         $rowattitem->quotation_item_id = $qitemdata->quotation_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($qitemdata->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('quotation_attribute_item');
                             $rowattitem->quotation_att_item_id = 0;
                             $rowattitem->quotation_item_id = $qitemdata->quotation_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('quotation_accessory_item');
                 $rowaccitem->quotation_item_acc_id = 0;
                 $rowaccitem->quotation_item_id = $qitemdata->quotation_item_id;
                 $rowaccitem->accessory_id = $accessory_id;
                 $rowaccitem->accessory_item_sku = $accProductinfo->product_number;
                 $rowaccitem->accessory_item_name = $accessory_name;
                 $rowaccitem->accessory_price = $accessory_org_price;
                 $rowaccitem->accessory_vat = $accessory_vat_price;
                 $rowaccitem->accessory_quantity = $qitemdata->product_quantity;
                 $rowaccitem->accessory_item_price = $accessory_price;
                 $rowaccitem->accessory_final_price = $accessory_price * $qitemdata->product_quantity;
                 $rowaccitem->accessory_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('quotation_attribute_item');
                 $rowattitem->quotation_att_item_id = 0;
                 $rowattitem->quotation_item_id = $qitemdata->quotation_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $qitemdata->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($qitemdata->product_id, $propArr[$k]['property_price'], $user_id);
                     }
                     $property_id = $propArr[$k]['property_id'];
                     /** product property STOCKROOM update start */
                     $updatestock = $stockroomhelper->updateStockroomQuantity($property_id, $qitemdata->product_quantity, "property");
                     $rowattitem =& $this->getTable('quotation_attribute_item');
                     $rowattitem->quotation_att_item_id = 0;
                     $rowattitem->quotation_item_id = $qitemdata->quotation_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($qitemdata->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                         }
                         $subproperty_id = $subpropArr[$l]['subproperty_id'];
                         /** product subproperty STOCKROOM update start */
                         $updatestock = $stockroomhelper->updateStockroomQuantity($subproperty_id, $qitemdata->product_quantity, "subproperty");
                         $rowattitem =& $this->getTable('quotation_attribute_item');
                         $rowattitem->quotation_att_item_id = 0;
                         $rowattitem->quotation_item_id = $qitemdata->quotation_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;
                             }
                         }
                     }
                 }
             }
         }
         // Store userfields
         $userfields = JRequest::getVar('extrafields' . $qitemdata->product_id);
         $userfields_id = JRequest::getVar('extrafields_id_' . $qitemdata->product_id);
         for ($ui = 0; $ui < count($userfields); $ui++) {
             $quotationHelper->insertQuotationUserfield($userfields_id[$ui], $qitemdata->quotation_item_id, 12, $userfields[$ui]);
         }
     }
     // Update Quotation Record
     $QuotationData = $this->getTable('quotation_detail');
     $QuotationData->load($this->_id);
     $QuotationTotal = 0;
     $QuotationSubTotal = 0;
     $QuotationSpDiscount = 0;
     $QuotationDiscount = 0;
     $QuotationTotDiscount = 0;
     $QuotationTax = 0;
     $quotationItems = $quotationHelper->getQuotationProduct($QuotationData->quotation_id);
     for ($q = 0; $q < count($quotationItems); $q++) {
         $QuotationSubTotal += $quotationItems[$q]->product_excl_price * $quotationItems[$q]->product_quantity;
         $QuotationTax += ($quotationItems[$q]->product_final_price - $quotationItems[$q]->product_excl_price) * $quotationItems[$q]->product_quantity;
     }
     // Deduct normal Discount
     $QuotationDiscount = $QuotationData->quotation_discount;
     // Special Discount
     $QuotationSpDiscount = $QuotationData->quotation_special_discount * ($QuotationSubTotal + $QuotationTax) / 100;
     // Total Discount
     $QuotationTotDiscount = $QuotationDiscount + $QuotationSpDiscount;
     // Count final Total
     $QuotationTotal = $QuotationSubTotal + $QuotationTax - $QuotationTotDiscount;
     $QuotationData->quotation_tax = $QuotationTax;
     $QuotationData->quotation_total = $QuotationTotal;
     $QuotationData->quotation_subtotal = $QuotationSubTotal;
     $QuotationData->quotation_mdate = time();
     if (!$QuotationData->store()) {
         return false;
     } else {
         return true;
     }
     // End
     return true;
 }