function display($tpl = null) { $app = JFactory::getApplication(); $producthelper = new producthelper(); $pathway = $app->getPathway(); $document = JFactory::getDocument(); $user = JFactory::getUser(); // Preform security checks if ($user->id == 0) { echo JText::_('COM_REDSHOP_ALERTNOTAUTH_REVIEW'); return; } $model = $this->getModel('product_rating'); $userinfo = $model->getuserfullname($user->id); $params = $app->getParams('com_redshop'); $Itemid = JRequest::getInt('Itemid'); $product_id = JRequest::getInt('product_id'); $category_id = JRequest::getInt('category_id'); $user = JFactory::getUser(); $model = $this->getModel('product_rating'); $rate = JRequest::getInt('rate'); $already_rated = $model->checkRatedProduct($product_id, $user->id); if ($already_rated == 1) { if ($rate == 1) { $msg = JText::_('COM_REDSHOP_YOU_CAN_NOT_REVIEW_SAME_PRODUCT_AGAIN'); $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $product_id . '&cid=' . $category_id . '&Itemid=' . $Itemid); $app->redirect($link, $msg); } else { echo JText::_('COM_REDSHOP_YOU_CAN_NOT_REVIEW_SAME_PRODUCT_AGAIN'); ?> <span id="closewindow"><input type="button" value="Close Window" onclick="window.parent.redBOX.close();"/></span> <script> setTimeout("window.parent.redBOX.close();", 2000); </script> <?php return; } } $productinfo = $producthelper->getProductById($product_id); $this->user = $user; $this->userinfo = $userinfo; $this->product_id = $product_id; $this->rate = $rate; $this->category_id = $category_id; $this->productinfo = $productinfo; $this->params = $params; parent::display($tpl); }
public function sendMailForReview($data) { $this->store($data); $producthelper = new producthelper(); $redshopMail = new redshopMail(); $user = JFactory::getUser(); $url = JURI::base(); $option = JRequest::getVar('option'); $Itemid = JRequest::getVar('Itemid'); $mailbcc = null; $fromname = $data['username']; $from = $user->email; $subject = ""; $message = $data['title']; $comment = $data['comment']; $username = $data['username']; $product_id = $data['product_id']; $mailbody = $redshopMail->getMailtemplate(0, "review_mail"); $data_add = $message; if (count($mailbody) > 0) { $data_add = $mailbody[0]->mail_body; $subject = $mailbody[0]->mail_subject; if (trim($mailbody[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailbody[0]->mail_bcc); } } $product = $producthelper->getProductById($product_id); $link = JRoute::_($url . "index.php?option=" . $option . "&view=product&pid=" . $product_id . '&Itemid=' . $Itemid); $product_url = "<a href=" . $link . ">" . $product->product_name . "</a>"; $data_add = str_replace("{product_link}", $product_url, $data_add); $data_add = str_replace("{product_name}", $product->product_name, $data_add); $data_add = str_replace("{title}", $message, $data_add); $data_add = str_replace("{comment}", $comment, $data_add); $data_add = str_replace("{username}", $username, $data_add); if (ADMINISTRATOR_EMAIL != "") { $sendto = explode(",", ADMINISTRATOR_EMAIL); if (JFactory::getMailer()->sendMail($from, $fromname, $sendto, $subject, $data_add, $mode = 1, null, $mailbcc)) { return true; } else { return false; } } }
public function sendProductMailToFriend($your_name, $friend_name, $product_id, $email) { $producthelper = new producthelper(); $redshopMail = new redshopMail(); $url = JURI::base(); $option = JRequest::getVar('option'); $mailinfo = $redshopMail->getMailtemplate(0, "product"); $data_add = ""; $subject = ""; $mailbcc = null; if (count($mailinfo) > 0) { $data_add = $mailinfo[0]->mail_body; $subject = $mailinfo[0]->mail_subject; if (trim($mailinfo[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailinfo[0]->mail_bcc); } } else { $data_add = "<p>Hi {friend_name} ,</p>\r\n<p>New Product : {product_name}</p>\r\n<p>{product_desc} Please check this link : {product_url}</p>\r\n<p> </p>\r\n<p> </p>"; $subject = "Send to friend"; } $data_add = str_replace("{friend_name}", $friend_name, $data_add); $data_add = str_replace("{your_name}", $your_name, $data_add); $product = $producthelper->getProductById($product_id); $data_add = str_replace("{product_name}", $product->product_name, $data_add); $data_add = str_replace("{product_desc}", $product->product_desc, $data_add); $rlink = JRoute::_($url . "index.php?option=" . $option . "&view=product&pid=" . $product_id); $product_url = "<a href=" . $rlink . ">" . $rlink . "</a>"; $data_add = str_replace("{product_url}", $product_url, $data_add); $config = JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $subject = str_replace("{product_name}", $product->product_name, $subject); $subject = str_replace("{shopname}", SHOP_NAME, $subject); if ($email != "") { if (JFactory::getMailer()->sendMail($from, $fromname, $email, $subject, $data_add, 1, null, $mailbcc)) { echo "<div class='' align='center'>" . JText::_('COM_REDSHOP_EMAIL_HAS_BEEN_SENT_SUCCESSFULLY') . "</div>"; } else { echo "<div class='' align='center'>" . JText::_('COM_REDSHOP_EMAIL_HAS_NOT_BEEN_SENT_SUCCESSFULLY') . "</div>"; } } exit; }
private static function getProductDetail($id) { $component = JComponentHelper::getComponent("com_redshop"); if (!isset($component->id)) { JError::raiseError('500', 'redShop Component is not installed'); } if (!defined('TABLE_PREFIX')) { require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/redshop.cfg.php'; } require_once JPATH_SITE . '/components/com_redshop/helpers/helper.php'; $objhelper = new redhelper(); $producthelper = new producthelper(); $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $id); if (count($ItemData) > 0) { $pItemid = $ItemData->id; } else { $pItemid = $objhelper->getItemid($id); } $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $id . '&Itemid=' . $pItemid); $product = $producthelper->getProductById($id); $product->product_price = $producthelper->getProductPrice($id); $product->link = $link; return $product; }
} else { $print_url = $url . "index.php?option=com_redshop&view=product&layout=compare&print=1&tmpl=component"; $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>"; } $template = str_replace("{print}", $print_tag, $template); $template = str_replace('{compare_product_heading}', $pagetitle, $template); $template = str_replace('{returntocategory_name}', JText::_("COM_REDSHOP_GO_BACK"), $template); $template = str_replace('{returntocategory_link}', $returnlink, $template); // Make extrafield object.. $field = new extraField(); $product_tag = array(); if (count($compare_template) > 0) { $product_tag = $producthelper->product_tag($compare_template[0]->template_id, "1", $template); } for ($i = 0; $i < $compare['idx']; $i++) { $product = $producthelper->getProductById($compare[$i]["product_id"]); if ($i == $compare['idx'] - 1) { $td_start = ""; $td_end = ""; } else { $td_start = "<td>"; $td_end = "</td>"; } $exp_div = "<div name='exp_" . $product->product_id . "'>"; $div_end = "</div>"; $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $product->product_id . '&Itemid=' . $this->itemId); $link_remove = JRoute::_('index.php?option=com_redshop&view=product&task=removecompare&layout=compare&pid=' . $product->product_id . '&Itemid=' . $this->itemId); $remove = "<a href='" . $link_remove . "'>" . JText::_('TPL_REDGADGETS_REMOVE_PRODUCT_FROM_COMPARE_LIST') . "</a>"; $thumbUrl = RedShopHelperImages::getImagePath($product->product_full_image, '', 'thumb', 'product', COMPARE_PRODUCT_THUMB_WIDTH, COMPARE_PRODUCT_THUMB_HEIGHT, USE_IMAGE_SIZE_SWAPPING); $img = "<div style='width:" . COMPARE_PRODUCT_THUMB_WIDTH . "px;height:" . COMPARE_PRODUCT_THUMB_HEIGHT . "px;float: left;' ><a href='" . $link . "' title='" . $product->product_name . "'><img src='" . $thumbUrl . "'></a></div>"; $expand = "<a href='javascript:void(0)' onClick='expand_collapse(this," . $product->product_id . ")' style='font-size:18px;text-decoration:none;' >-</a>";
public function sendAskQuestionMail($ansid) { $producthelper = new producthelper(); $uri = JURI::getInstance(); $url = $uri->root(); $option = JRequest::getVar('option'); $subject = ""; $data_add = ""; $mailbcc = null; $mailinfo = $this->getMailtemplate(0, "ask_question_mail"); $ans = $producthelper->getQuestionAnswer($ansid); if (count($mailinfo) > 0) { $data_add = $mailinfo[0]->mail_body; $subject = $mailinfo[0]->mail_subject; $mailbcc = explode(",", $mailinfo[0]->mail_bcc); } if (count($ans) > 0) { $ans = $ans[0]; $fromname = $ans->user_name; $from = $ans->user_email; $email = explode(",", trim(ADMINISTRATOR_EMAIL)); $question = $ans->question; $answer = ""; $telephone = ""; $address = ""; $product_id = $ans->product_id; if ($ans->parent_id) { $answer = $ans->question; $qdetail = $producthelper->getQuestionAnswer($ans->parent_id); if (count($qdetail) > 0) { $config = JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $qdetail = $qdetail[0]; $question = $qdetail->question; $email = $qdetail->user_email; $product_id = $qdetail->product_id; $address = $qdetail->address; $telephone = $qdetail->telephone; } } $product = $producthelper->getProductById($product_id); $link = JRoute::_($url . "index.php?option=" . $option . "&view=product&pid=" . $product_id); $data_add = str_replace("{product_name}", $product->product_name, $data_add); $data_add = str_replace("{product_desc}", $product->product_desc, $data_add); $product_url = "<a href=" . $link . ">" . $product->product_name . "</a>"; $data_add = str_replace("{product_link}", $product_url, $data_add); $data_add = str_replace("{user_question}", $question, $data_add); $data_add = str_replace("{answer}", $answer, $data_add); $data_add = str_replace("{user_address}", $address, $data_add); $data_add = str_replace("{user_telephone}", $telephone, $data_add); $subject = str_replace("{user_question}", $question, $subject); $subject = str_replace("{shopname}", SHOP_NAME, $subject); $subject = str_replace("{product_name}", $product->product_name, $subject); if ($email) { if (JUtility::sendMail($from, $fromname, $email, $subject, $data_add, $mode = 1, null, $mailbcc)) { return true; } } } return false; }
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 store($data) { $extra_field = new extra_field(); $quotationHelper = new quotationHelper(); $producthelper = new producthelper(); $rsCarthelper = new rsCarthelper(); $stockroomhelper = new rsstockroomhelper(); $extra_field->extra_field_save($data, 16, $data['user_info_id'], $data['user_email']); $row = $this->getTable('quotation_detail'); if ($data['quotation_discount'] > 0) { $data['order_total'] = $data['order_total'] - $data['quotation_discount'] - $data['order_total'] * $data['quotation_special_discount'] / 100; } $data['quotation_number'] = $quotationHelper->generateQuotationNumber(); $data['quotation_encrkey'] = $quotationHelper->randomQuotationEncrkey(); $data['quotation_cdate'] = time(); $data['quotation_mdate'] = time(); $data['quotation_total'] = $data['order_total']; $data['quotation_subtotal'] = $data['order_subtotal']; $data['quotation_tax'] = $data['order_tax']; $data['quotation_ipaddress'] = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown'; if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } $row->quotation_status = 2; if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } $quotation_item = array(); $user_id = $row->user_id; $item = $data['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]; $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; } $rowitem =& $this->getTable('quotation_item_detail'); $product = $producthelper->getProductById($product_id); $quotation_item[$i]->quotation_id = $row->quotation_id; $quotation_item[$i]->product_id = $product_id; $quotation_item[$i]->is_giftcard = 0; $quotation_item[$i]->product_name = $product->product_name; $quotation_item[$i]->actualitem_price = $product_price; $quotation_item[$i]->product_price = $product_price; $quotation_item[$i]->product_excl_price = $product_excl_price; $quotation_item[$i]->product_final_price = $product_price * $quantity; $quotation_item[$i]->product_attribute = $product_attribute; $quotation_item[$i]->product_accessory = $product_accessory; $quotation_item[$i]->product_wrapperid = $item[$i]->wrapper_data; $quotation_item[$i]->wrapper_price = $wrapper_price; $quotation_item[$i]->product_quantity = $quantity; if (!$rowitem->bind($quotation_item[$i])) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$rowitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } // Store userfields $userfields = JRequest::getVar('extrafields' . $product_id); $userfields_id = JRequest::getVar('extrafields_id_' . $product_id); for ($ui = 0; $ui < count($userfields); $ui++) { $quotationHelper->insertQuotationUserfield($userfields_id[$ui], $rowitem->quotation_item_id, 12, $userfields[$ui]); } /** 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($rowitem->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 = $rowitem->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($rowitem->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 = $rowitem->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($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('quotation_attribute_item'); $rowattitem->quotation_att_item_id = 0; $rowattitem->quotation_item_id = $rowitem->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 = $rowitem->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 = $rowitem->product_quantity; $rowaccitem->accessory_item_price = $accessory_price; $rowaccitem->accessory_final_price = $accessory_price * $rowitem->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 = $rowitem->quotation_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 */ $stockroomhelper->updateStockroomQuantity($property_id, $rowitem->product_quantity, "property"); $rowattitem =& $this->getTable('quotation_attribute_item'); $rowattitem->quotation_att_item_id = 0; $rowattitem->quotation_item_id = $rowitem->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($rowitem->product_id, $subpropArr[$l]['subproperty_price'], $user_id); } $subproperty_id = $subpropArr[$l]['subproperty_id']; /** product subproperty STOCKROOM update start */ $stockroomhelper->updateStockroomQuantity($subproperty_id, $rowitem->product_quantity, "subproperty"); $rowattitem = $this->getTable('quotation_attribute_item'); $rowattitem->quotation_att_item_id = 0; $rowattitem->quotation_item_id = $rowitem->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; } } } } } } } return $row; }
function display($tpl = null) { $config = new Redconfiguration(); $redTemplate = new Redtemplate(); $order_functions = new order_functions(); $producthelper = new producthelper(); $model = $this->getModel(); $redTemplate = new Redtemplate(); $detail = $this->get('data'); $carthelper = new rsCarthelper(); $shippinghelper = new shipping(); $products = $order_functions->getOrderItemDetail($detail->order_id); $template = $model->getStockNoteTemplate(); if (count($template) > 0 && $template->template_desc != "") { $html_template = $template->template_desc; } else { $html_template = '<table border="0" cellspacing="2" cellpadding="2" width="100%"><tr><td>{order_id_lbl} : {order_id}</td><td> {order_date_lbl} : {order_date}</td></tr></table> <table border="1" cellspacing="0" cellpadding="0" width="100%"><tbody><tr style="background-color: #d7d7d4"><th align="center">{product_name_lbl}</th> <th align="center">{product_number_lbl}</th> <th align="center">{product_quantity_lbl}</th></tr> {product_loop_start} <tr> <td align="center"> <table> <tr><td>{product_name}</td></tr> <tr><td>{product_attribute}</td></tr> </table> </td> <td align="center">{product_number}</td> <td align="center">{product_quantity}</td> </tr> {product_loop_end} </tbody> </table>'; } ob_start(); if (strstr($html_template, "{product_loop_start}") && strstr($html_template, "{product_loop_end}")) { $template_sdata = explode('{product_loop_start}', $html_template); $template_start = $template_sdata[0]; $template_edata = explode('{product_loop_end}', $template_sdata[1]); $template_end = $template_edata[1]; $template_middle = $template_edata[0]; $middle_data = ''; for ($p = 0; $p < count($products); $p++) { $middle_data .= $template_middle; $product_detail = $producthelper->getProductById($products[$p]->product_id); $middle_data = str_replace("{product_number}", $product_detail->product_number, $middle_data); $middle_data = str_replace("{product_name}", $products[$p]->order_item_name, $middle_data); $middle_data = str_replace("{product_attribute}", $products[$p]->product_attribute, $middle_data); $middle_data = str_replace("{product_quantity}", $products[$p]->product_quantity, $middle_data); } $html_template = $template_start . $middle_data . $template_end; } $html_template = str_replace("{order_id_lbl}", JText::_('COM_REDSHOP_ORDER_ID'), $html_template); $html_template = str_replace("{order_id}", $detail->order_id, $html_template); $html_template = str_replace("{order_date_lbl}", JText::_('COM_REDSHOP_ORDER_DATE'), $html_template); $html_template = str_replace("{order_date}", $config->convertDateFormat($detail->cdate), $html_template); $html_template = str_replace("{product_name_lbl}", JText::_('COM_REDSHOP_PRODUCT_NAME'), $html_template); $html_template = str_replace("{product_number_lbl}", JText::_('COM_REDSHOP_PRODUCT_NUMBER'), $html_template); $html_template = str_replace("{product_quantity_lbl}", JText::_('COM_REDSHOP_QUANTITY'), $html_template); $billing = $order_functions->getOrderBillingUserInfo($detail->order_id); $html_template = $carthelper->replaceBillingAddress($html_template, $billing); $shipping = $order_functions->getOrderShippingUserInfo($detail->order_id); $html_template = $carthelper->replaceShippingAddress($html_template, $shipping); $html_template = str_replace("{requisition_number}", $detail->requisition_number, $html_template); $html_template = str_replace("{requisition_number_lbl}", JText::_('COM_REDSHOP_REQUISITION_NUMBER'), $html_template); // start pdf code $pdfObj = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A5', true, 'UTF-8', false); $pdfObj->SetTitle("Order StockNote: " . $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, "", 10); //$pdfObj->AliasNbPages(); $pdfObj->AddPage(); $pdfObj->WriteHTML($html_template); $pdfObj->Output("StocNoteOrder_" . $detail->order_id . ".pdf", "D"); exit; }
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; }
public function getProductItemInfo($product_id = 0, $quantity = 1, $unique_id = "", $user_id = 0, $newproduct_price = 0) { $producthelper = new producthelper(); $wrapperlist = ""; $accessorylist = ""; $attributelist = ""; $productuserfield = ""; $product_price = 0; $product_price_excl_vat = 0; $producttax = 0; if ($product_id) { $productInfo = $producthelper->getProductById($product_id); if ($newproduct_price != 0) { $product_price_excl_vat = $newproduct_price; $producttax = $producthelper->getProductTax($product_id, $newproduct_price, $user_id); } else { $productArr = $producthelper->getProductNetPrice($product_id, $user_id, $quantity); $product_price_excl_vat = $productArr['productPrice']; $producttax = $productArr['productVat']; // Attribute start $attributes_set = array(); if ($productInfo->attribute_set_id > 0) { $attributes_set = $producthelper->getProductAttribute(0, $productInfo->attribute_set_id, 0, 1); } $attributes = $producthelper->getProductAttribute($product_id); $attributes = array_merge($attributes, $attributes_set); $attributelist = $this->replaceAttributeData($product_id, 0, $attributes, $user_id, $unique_id); // Accessory start $accessory = $producthelper->getProductAccessory(0, $product_id); $accessorylist = $this->replaceAccessoryData($product_id, $accessory, $user_id, $unique_id); // Wrapper selection box generate $wrapperlist = $this->replaceWrapperData($product_id, $user_id, $unique_id); $productuserfield = $this->replaceUserfield($product_id, $productInfo->product_template, $unique_id); } } $product_price = $product_price_excl_vat + $producttax; $total_price = $product_price * $quantity; $totaltax = $producttax * $quantity; $displayrespoce = ""; $displayrespoce .= "<div id='product_price_excl_vat'>" . $product_price_excl_vat . "</div>"; $displayrespoce .= "<div id='product_tax'>" . $producttax . "</div>"; $displayrespoce .= "<div id='product_price'>" . $product_price . "</div>"; $displayrespoce .= "<div id='total_price'>" . $total_price . "</div>"; $displayrespoce .= "<div id='total_tax'>" . $totaltax . "</div>"; $displayrespoce .= "<div id='attblock'><table>" . $attributelist . "</table></div>"; $displayrespoce .= "<div id='productuserfield'><table>" . $productuserfield . "</table></div>"; $displayrespoce .= "<div id='accessoryblock'><table>" . $accessorylist . "</table></div>"; $displayrespoce .= "<div id='noteblock'>" . $wrapperlist . "</div>"; return $displayrespoce; }
$producthelper = new producthelper(); $uri = JURI::getInstance(); $url = $uri->root(); // For Add Media Detail $showbuttons = JRequest::getCmd('showbuttons'); $media_section = JRequest::getCmd('media_section'); $section_id = JRequest::getCmd('section_id'); $model = $this->getModel('media'); $sectionadata = array(); $sectiona_primary_image = ""; $section_name = ""; $directory = $media_section; if ($showbuttons == 1) { switch ($media_section) { case "product": $sectionadata = $producthelper->getProductById($section_id); $section_name = $sectionadata->product_name; $sectiona_primary_image = $sectionadata->product_full_image; $directory = $media_section; break; case "property": $sectionadata = $producthelper->getAttibuteProperty($section_id); $section_name = $sectionadata[0]->property_name; $sectiona_primary_image = $sectionadata[0]->property_main_image; $directory = 'property'; break; case "subproperty": $sectionadata = $producthelper->getAttibuteSubProperty($section_id); $section_name = $sectionadata[0]->subattribute_color_name; $sectiona_primary_image = $sectionadata[0]->subattribute_color_main_image; $directory = 'subproperty';
$output = '<div class="mod_cart_extend_total_pro_value" id="mod_cart_total_txt_product" >'; $output .= JText::_('COM_REDSHOP_TOTAL_PRODUCT') . ':' . ' ' . $cartTotalProduct . ' ' . JText::_('COM_REDSHOP_PRODUCTS_IN_CART'); $output .= '</div>'; } break; case 'extended': $output = '<div class="mod_cart_products" id="mod_cart_products">'; if ($count) { $cartTotalProduct = $idx; for ($i = 0; $i < $idx; $i++) { $carthelper = new rsCarthelper(); if ($carthelper->rs_multi_array_key_exists('giftcard_id', $cart[$i]) && $cart[$i]['giftcard_id']) { $giftcardData = $producthelper->getGiftcardData($cart[$i]['giftcard_id']); $name = $giftcardData->giftcard_name; } else { $product_detail = $producthelper->getProductById($cart[$i]['product_id']); $name = $product_detail->product_name; } $output .= '<div class="mod_cart_product">'; $output .= '<div class="mod_cart_product_name">' . $name . ' x ' . $cart[$i]['quantity'] . '</div>'; if (!DEFAULT_QUOTATION_MODE || DEFAULT_QUOTATION_MODE && SHOW_QUOTATION_PRICE) { $output .= '<div class="mod_cart_product_price">'; if ($show_with_vat) { $output .= $producthelper->getProductFormattedPrice($cart[$i]['product_price'], true); } else { $output .= $producthelper->getProductFormattedPrice($cart[$i]['product_price_excl_vat'], true); } $output .= '</div>'; } $output .= '</div>'; }
public function neworderitem($data, $quantity, $order_item_id) { $adminproducthelper = new adminproducthelper(); $producthelper = new producthelper(); $rsCarthelper = new rsCarthelper(); $stockroomhelper = new rsstockroomhelper(); // Get Order Info $orderdata = $this->getTable('order_detail'); $orderdata->load($this->_id); $item = $data['order_item']; // Get product Info // Set Order Item Info $orderitemdata = $this->getTable('order_item_detail'); $orderitemdata->load($order_item_id); $user_id = $orderdata->user_id; for ($i = 0; $i < count($item); $i++) { $product_id = $item[$i]->product_id; $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]; $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); $updatestock = $stockroomhelper->updateStockroomQuantity($product_id, $quantity); $stockroom_id_list = $updatestock['stockroom_list']; $stockroom_quantity_list = $updatestock['stockroom_quantity_list']; $orderitemdata->stockroom_id = $stockroom_id_list; $orderitemdata->stockroom_quantity = $stockroom_quantity_list; $orderitemdata->order_item_id = 0; $orderitemdata->order_id = $this->_id; $orderitemdata->user_info_id = $orderdata->user_info_id; $orderitemdata->supplier_id = $product->manufacturer_id; $orderitemdata->product_id = $product_id; $orderitemdata->order_item_sku = $product->product_number; $orderitemdata->order_item_name = $product->product_name; $orderitemdata->product_quantity = $quantity; $orderitemdata->product_item_price = $product_price; $orderitemdata->product_item_price_excl_vat = $product_excl_price; $orderitemdata->product_final_price = $product_price * $quantity; $orderitemdata->order_item_currency = REDCURRENCY_SYMBOL; $orderitemdata->order_status = "P"; $orderitemdata->cdate = time(); $orderitemdata->mdate = time(); $orderitemdata->product_attribute = $product_attribute; $orderitemdata->product_accessory = $product_accessory; $orderitemdata->wrapper_id = $item[$i]->wrapper_data; $orderitemdata->wrapper_price = $wrapper_price; if ($producthelper->checkProductDownload($product_id)) { $medianame = $producthelper->getProductMediaName($product_id); for ($j = 0; $j < count($medianame); $j++) { $sql = "INSERT INTO " . $this->_table_prefix . "product_download " . "(product_id, user_id, order_id, end_date, download_max, download_id, file_name) " . "VALUES('" . $product_id . "', '" . $user_id . "', '" . $this->_id . "', " . "'" . (time() + PRODUCT_DOWNLOAD_DAYS * 23 * 59 * 59) . "', '" . PRODUCT_DOWNLOAD_LIMIT . "', " . "'" . md5(uniqid(mt_rand(), true)) . "', '" . $medianame[$j]->media_name . "')"; $this->_db->setQuery($sql); $this->_db->query(); } } if (!$orderitemdata->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 = $orderitemdata->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 = $orderitemdata->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 = $orderitemdata->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); } $accessoryproduct = $producthelper->getProductById($accdata->child_product_id); $rowaccitem =& $this->getTable('order_acc_item'); $rowaccitem->order_item_acc_id = 0; $rowaccitem->order_item_id = $orderitemdata->order_item_id; $rowaccitem->product_id = $accessory_id; $rowaccitem->order_acc_item_sku = $accessoryproduct->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 = $orderitemdata->order_item_id; $rowattitem->section_id = $attribute_id; $rowattitem->section = "attribute"; $rowattitem->parent_section_id = $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($product_id, $propArr[$k]['property_price'], $usre_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 = $orderitemdata->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 = $orderitemdata->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; } } } } } } if (USE_CONTAINER) { $producthelper->updateContainerStock($product_id, $quantity, $orderitemdata->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], $orderitemdata->order_item_id, 12, $userfields[$ui]); } } if ($orderitemdata->order_item_id > 0) { $totalItemVat = $orderitemdata->product_item_price - $orderitemdata->product_item_price_excl_vat; $orderdata->order_tax = $orderdata->order_tax + $totalItemVat * $orderitemdata->product_quantity; $orderdata->order_total = $orderdata->order_total + $orderitemdata->product_final_price; $orderdata->order_subtotal = $orderdata->order_subtotal + $orderitemdata->product_final_price; $orderdata->mdate = time(); // Update order detail if (!$orderdata->store()) { return false; } if (ECONOMIC_INTEGRATION == 1) { $economic = new economic(); $invoiceHandle = $economic->renewInvoiceInEconomic($orderdata); } // Send mail from template $redshopMail = new redshopMail(); $redshopMail->sendOrderSpecialDiscountMail($this->_id); } else { return false; } return true; }
* @subpackage View * * @copyright Copyright (C) 2005 - 2013 redCOMPONENT.com. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('_JEXEC') or die; JHTML::_('behavior.tooltip'); JHTML::_('behavior.modal'); require_once JPATH_COMPONENT_SITE . '/helpers/product.php'; $producthelper = new producthelper(); $option = JRequest::getVar('option'); $model = $this->getModel('answer_detail'); $editor = JFactory::getEditor(); $uri = JURI::getInstance(); $url = $uri->root(); $product = $producthelper->getProductById($this->qdetail->product_id); ?> <script language="javascript" type="text/javascript"> Joomla.submitbutton = function (pressbutton) { submitbutton(pressbutton); } submitbutton = function (pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform(pressbutton); return; } submitform(pressbutton);
for ($i = 0; $i < count($quotationProducts); $i++) { $cart_mdata .= $template_middle; $wrapper_name = ""; if ($quotationProducts[$i]->product_wrapperid) { $wrapper = $producthelper->getWrapper($quotationProducts[$i]->product_id, $quotationProducts[$i]->product_wrapperid); if (count($wrapper) > 0) { $wrapper_name = JText::_('COM_REDSHOP_WRAPPER') . ":<br/>" . $wrapper[0]->wrapper_name . "(" . $producthelper->getProductFormattedPrice($quotationProducts[$i]->wrapper_price) . ")"; } } if ($quotationProducts[$i]->is_giftcard == 1) { $product_userfields = $quotationHelper->displayQuotationUserfield($quotationProducts[$i]->quotation_item_id, 13); $giftcardData = $producthelper->getGiftcardData($quotationProducts[$i]->product_id); $product_number = ""; } else { $product_userfields = $quotationHelper->displayQuotationUserfield($quotationProducts[$i]->quotation_item_id, 12); $product = $producthelper->getProductById($quotationProducts[$i]->product_id); $product_number = $product->product_number; $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; } }
$cart_tr = ''; for ($i = 0; $i < count($OrderProducts); $i++) { $wrapper_name = ""; if ($OrderProducts[$i]->wrapper_id) { $wrapper = $producthelper->getWrapper($OrderProducts[$i]->product_id, $OrderProducts[$i]->wrapper_id); if (count($wrapper) > 0) { $wrapper_name = JText::_('COM_REDSHOP_WRAPPER') . ":<br/>" . $wrapper[0]->wrapper_name . "(" . $producthelper->getProductFormattedPrice($OrderProducts[$i]->wrapper_price) . ")"; } } if ($OrderProducts[$i]->is_giftcard == 1) { $product_userfields = $producthelper->getuserfield($OrderProducts[$i]->order_item_id, 13); } else { $product_userfields = $producthelper->getuserfield($OrderProducts[$i]->order_item_id); } $product_name = "<div class='product_name'>" . $OrderProducts[$i]->order_item_name . "</div>"; $product = $producthelper->getProductById($OrderProducts[$i]->product_id); $product_number = $OrderProducts[$i]->order_item_sku; $product_note = "<div class='product_note'>" . $wrapper_name . "</div>"; $product_total_price = "<div class='product_total_price'>" . $producthelper->getProductFormattedPrice($OrderProducts[$i]->product_final_price) . "</div>"; $product_price = "<div class='product_price'>" . $producthelper->getProductFormattedPrice($OrderProducts[$i]->product_item_price) . "</div>"; $product_quantity = '<div class="product_quantity">' . $OrderProducts[$i]->product_quantity . '</div>'; $cart_mdata = ''; $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; } }
} $category_id = $producthelper->getCategoryProduct($row->product_id); $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $row->product_id); if (count($ItemData) > 0) { $Itemid = $ItemData->id; } else { $Itemid = $redhelper->getItemid($row->product_id, $category_id); } $link = JRoute::_('index.php?option=' . $option . '&view=product&pid=' . $row->product_id . '&cid=' . $category_id . '&Itemid=' . $Itemid); if ($vertical_product) { echo "<div class='mod_redshop_products'>"; } else { echo "<div class='mod_redshop_products_horizontal'>"; } echo "<div class='mod_redshop_products_outer'><div class='mod_redshop_products_inner'>"; $productInfo = $producthelper->getProductById($row->product_id); if ($image) { $thumb = $productInfo->product_full_image; if (WATERMARK_PRODUCT_IMAGE) { $thum_image = $redhelper->watermark('product', $thumb, $thumbwidth, $thumbheight, WATERMARK_PRODUCT_THUMB_IMAGE, '0'); echo "<div class='mod_redshop_products_image'><img src=" . $thum_image . "></div>"; } else { $thum_image = RedShopHelperImages::getImagePath($thumb, '', 'thumb', 'product', $thumbwidth, $thumbheight, USE_IMAGE_SIZE_SWAPPING); echo "<div class='mod_redshop_products_image'><a href='" . $link . "' title='{$row->product_name}'><img src=" . $thum_image . "></a></div>"; } } if (!empty($stock_status)) { echo $stock_status; } if (!$row->not_for_sale && $show_price) { $productArr = $producthelper->getProductNetPrice($row->product_id);
<?php if ($totalDownloadProduct > 0) { echo '<td>' . JText::_('COM_REDSHOP_DOWNLOAD_SETTING') . '</td>'; } ?> </tr> <?php $ordervolume = 0; $cart = array(); $subtotal_excl_vat = 0; for ($i = 0; $i < count($products); $i++) { $cart[$i]['product_id'] = $products[$i]->product_id; $cart[$i]['quantity'] = $products[$i]->product_quantity; $quantity = $products[$i]->product_quantity; $product_id = $products[$i]->product_id; $productdetail = $producthelper->getProductById($product_id); $ordervolume = $ordervolume + $productdetail->product_volume; $order_item_id = $products[$i]->order_item_id; $order_item_name = $products[$i]->order_item_name; $order_item_sku = $products[$i]->order_item_sku; $wrapper_id = $products[$i]->wrapper_id; $p_userfield = $producthelper->getuserfield($order_item_id); $subscribe_detail = $model->getUserProductSubscriptionDetail($order_item_id); $catId = $producthelper->getCategoryProduct($product_id); $res = $producthelper->getSection("category", $catId); if (count($res) > 0) { $cname = $res->category_name; $clink = JRoute::_($url . 'index.php?option=com_redshop&view=category&layout=detail&cid=' . $catId); } $cname = "<a href='" . $clink . "'>" . $cname . "</a>"; $Product_name = $order_item_name . '<br>' . $order_item_sku . '<br>' . $p_userfield . '<br>' . $cname;
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a JError object. * * @see fetch() * @since 11.1 */ public function display($tpl = null) { // Request variables $prodhelperobj = new producthelper(); $this->redTemplate = new Redtemplate(); $this->redHelper = new redhelper(); $this->textHelper = new text_library(); $this->app = JFactory::getApplication(); $this->input = $this->app->input; $this->model = $this->getModel('product'); $this->document = JFactory::getDocument(); $this->session = JFactory::getSession(); $pageheadingtag = ''; $params = $this->app->getParams('com_redshop'); $menu_meta_keywords = $params->get('menu-meta_keywords'); $menu_meta_description = $params->get('menu-meta_description'); $menu_robots = $params->get('robots'); $this->data = $this->get('data'); $productTemplate = null; $this->itemId = $this->input->getInt('Itemid', null); $this->pid = $this->input->getInt('pid', 0); $layout = $this->input->getString('layout', 'default'); $template = $this->input->getString('r_template', ''); JPluginHelper::importPlugin('redshop_product'); $this->dispatcher = JDispatcher::getInstance(); if (!$this->pid) { $this->pid = $params->get('productid'); } /* * Include JavaScript. * But, first check if a plugin wants to use its own jQuery. */ $stopJQuery = $this->dispatcher->trigger('stopProductRedshopJQuery', array($this->data, $layout)); if (in_array(true, $stopJQuery, true)) { $stopJQuery = true; } else { $stopJQuery = false; } if (!$stopJQuery) { JHtml::Script('jquery.js', 'components/com_redshop/assets/js/', false); } JHtml::Script('redBOX.js', 'components/com_redshop/assets/js/', false); JHtml::Script('json.js', 'components/com_redshop/assets/js/', false); JHtml::Script('attribute.js', 'components/com_redshop/assets/js/', false); JHtml::Script('common.js', 'components/com_redshop/assets/js/', false); // Lightbox Javascript JHtml::Stylesheet('style.css', 'components/com_redshop/assets/css/'); JHtml::Stylesheet('scrollable-navig.css', 'components/com_redshop/assets/css/'); if ($layout == "downloadproduct") { $this->setLayout('downloadproduct'); } elseif ($layout == "compare") { $this->setLayout('compare'); } elseif ($layout == "viewajaxdetail") { $this->setLayout('viewajaxdetail'); } elseif ($layout == "searchletter") { $this->setLayout('searchletter'); } else { // Ajax box if ($template == 'cartbox' && AJAX_CART_BOX == 1) { $this->loadTemplate('cartbox'); exit; } else { $this->setLayout('default'); } $prodhelperobj_array_main = $prodhelperobj->getProductNetPrice($this->data->product_id); if ($this->data->published == 0) { JError::raiseError(404, sprintf(JText::_('COM_REDSHOP_PRODUCT_IS_NOT_PUBLISHED'), $this->data->product_name, $this->data->product_number)); } if ($this->data->canonical_url != "") { $main_url = JURI::root() . $this->data->canonical_url; $canonical = '<link rel="canonical" href="' . $main_url . '" />'; $this->document->addCustomTag($canonical); } elseif ($this->data->product_parent_id != 0 && $this->data->product_parent_id != "") { $product_parent_data = $prodhelperobj->getProductById($this->data->product_parent_id); if ($product_parent_data->canonical_url != "") { $main_url = JURI::root() . $product_parent_data->canonical_url; $canonical = '<link rel="canonical" href="' . $main_url . '" />'; $this->document->addCustomTag($canonical); } else { $main_url = substr_replace(JURI::root(), "", -1); $main_url .= JRoute::_('index.php?option=com_redshop&view=product&layout=detail&Itemid=' . $this->itemId . '&pid=' . $this->data->product_parent_id, false); $canonical = '<link rel="canonical" href="' . $main_url . '" />'; $this->document->addCustomTag($canonical); } } $productTemplate = $this->model->getProductTemplate(); /* * Process the prepare Product plugins */ $this->dispatcher->trigger('onPrepareProduct', array(&$productTemplate->template_desc, &$params, $this->data)); $pagetitletag = ''; // For page title if (AUTOGENERATED_SEO && SEO_PAGE_TITLE != '') { $pagetitletag = SEO_PAGE_TITLE; $pagetitletag = str_replace("{productname}", $this->data->product_name, $pagetitletag); $pagetitletag = str_replace("{categoryname}", $this->data->category_name, $pagetitletag); $pagetitletag = str_replace("{manufacturer}", $this->data->manufacturer_name, $pagetitletag); $pagetitletag = str_replace("{productsku}", $this->data->product_number, $pagetitletag); $pagetitletag = str_replace("{productnumber}", $this->data->product_number, $pagetitletag); $pagetitletag = str_replace("{shopname}", SHOP_NAME, $pagetitletag); $pagetitletag = str_replace("{productshortdesc}", strip_tags($this->data->product_s_desc), $pagetitletag); $pagetitletag = str_replace("{saleprice}", $prodhelperobj_array_main['product_price'], $pagetitletag); $parentcat = ""; $parentid = $prodhelperobj->getParentCategory($this->data->category_id); while ($parentid != 0) { $parentdetail = $prodhelperobj->getSection("category", $parentid); $parentcat = $parentdetail->category_name . " " . $parentcat; $parentid = $prodhelperobj->getParentCategory($parentdetail->category_id); } $pagetitletag = str_replace("{parentcategoryloop}", $parentcat, $pagetitletag); $pagetitletag = $prodhelperobj->getProductNotForSaleComment($this->data, $pagetitletag); } if ($this->data->pagetitle != '' && AUTOGENERATED_SEO && SEO_PAGE_TITLE != '') { if ($this->data->append_to_global_seo == 'append') { $pagetitletag .= " " . $this->data->pagetitle; $this->document->setTitle($pagetitletag); $this->document->setMetaData("og:title", $pagetitletag); } elseif ($this->data->append_to_global_seo == 'prepend') { $pagetitletag = $this->data->pagetitle . " " . $pagetitletag; $this->document->setTitle($pagetitletag); $this->document->setMetaData("og:title", $pagetitletag); } elseif ($this->data->append_to_global_seo == 'replace') { $this->document->setTitle($this->data->pagetitle); $this->document->setMetaData("og:title", $this->data->pagetitle); } } else { if ($this->data->pagetitle != '') { $this->document->setTitle($this->data->pagetitle); $this->document->setMetaData("og:title", $this->data->pagetitle); } elseif (AUTOGENERATED_SEO && SEO_PAGE_TITLE != '') { $this->document->setTitle($pagetitletag); $this->document->setMetaData("og:title", $pagetitletag); } else { $this->document->setTitle($this->data->product_name . " | " . $this->data->category_name . " | " . $this->app->getCfg('sitename') . " | " . $this->data->product_number); $this->document->setMetaData("og:title", $this->data->product_name . " | " . $this->data->category_name . " | " . $this->app->getCfg('sitename') . " | " . $this->data->product_number); } } $uri = JFactory::getURI(); $scheme = $uri->getScheme(); $host = $uri->getHost(); if ($this->data->product_thumb_image && file_exists(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . $this->data->product_thumb_image)) { $this->document->setMetaData("og:image", $scheme . "://" . $host . "/components/com_redshop/assets/images/product/" . $this->data->product_thumb_image); } elseif ($this->data->product_full_image && file_exists(REDSHOP_FRONT_IMAGES_RELPATH . "product/" . $this->data->product_full_image)) { $this->document->setMetaData("og:image", $scheme . "://" . $host . "/components/com_redshop/assets/images/product/" . $this->data->product_full_image); } $pagekeywordstag = ''; if (AUTOGENERATED_SEO && SEO_PAGE_KEYWORDS != '') { $pagekeywordstag = SEO_PAGE_KEYWORDS; $pagekeywordstag = str_replace("{productname}", $this->data->product_name, $pagekeywordstag); $pagekeywordstag = str_replace("{categoryname}", $this->data->category_name, $pagekeywordstag); $pagekeywordstag = str_replace("{manufacturer}", $this->data->manufacturer_name, $pagekeywordstag); $pagekeywordstag = str_replace("{productsku}", $this->data->product_number, $pagekeywordstag); $pagekeywordstag = str_replace("{productnumber}", $this->data->product_number, $pagekeywordstag); $pagekeywordstag = str_replace("{shopname}", SHOP_NAME, $pagekeywordstag); $pagekeywordstag = str_replace("{productshortdesc}", strip_tags($this->data->product_s_desc), $pagekeywordstag); $pagekeywordstag = str_replace("{saleprice}", $prodhelperobj_array_main['product_price'], $pagekeywordstag); $pagekeywordstag = $prodhelperobj->getProductNotForSaleComment($this->data, $pagekeywordstag); $this->document->setMetaData('keywords', $pagekeywordstag); } if (trim($this->data->metakey) != '' && AUTOGENERATED_SEO && SEO_PAGE_KEYWORDS != '') { if ($this->data->append_to_global_seo == 'append') { $pagekeywordstag .= "," . trim($this->data->metakey); $this->document->setMetaData('keywords', $pagekeywordstag); } elseif ($this->data->append_to_global_seo == 'prepend') { $this->document->setMetaData('keywords', $pagekeywordstag); } elseif ($this->data->append_to_global_seo == 'replace') { $this->document->setMetaData('keywords', $this->data->metakey); } } else { if (trim($this->data->metakey) != '') { $this->document->setMetaData('keywords', $this->data->metakey); } else { if (AUTOGENERATED_SEO && SEO_PAGE_KEYWORDS != '') { $this->document->setMetaData('keywords', $pagekeywordstag); } elseif ($menu_meta_keywords != "") { $this->document->setMetaData('keywords', $menu_meta_keywords); } else { $this->document->setMetaData('keywords', $this->data->product_name . ", " . $this->data->category_name . ", " . SHOP_NAME . ", " . $this->data->product_number); } } } if (trim($this->data->metarobot_info) != '') { $this->document->setMetaData('robots', $this->data->metarobot_info); } else { if (AUTOGENERATED_SEO && SEO_PAGE_ROBOTS != '') { $pagerobotstag = SEO_PAGE_ROBOTS; $this->document->setMetaData('robots', $pagerobotstag); } elseif ($menu_robots != "") { $this->document->setMetaData('robots', $menu_robots); } else { $this->document->setMetaData('robots', "INDEX,FOLLOW"); } } $pagedesctag = ''; // For meta description if (AUTOGENERATED_SEO && SEO_PAGE_DESCRIPTION != '') { if ($prodhelperobj_array_main['product_price_saving'] != "") { $product_price_saving_main = $prodhelperobj_array_main['product_price_saving']; } else { $product_price_saving_main = 0; } $pagedesctag = SEO_PAGE_DESCRIPTION; $pagedesctag = str_replace("{productname}", $this->data->product_name, $pagedesctag); $pagedesctag = str_replace("{categoryname}", $this->data->category_name, $pagedesctag); $pagedesctag = str_replace("{manufacturer}", $this->data->manufacturer_name, $pagedesctag); $pagedesctag = str_replace("{productsku}", $this->data->product_number, $pagedesctag); $pagedesctag = str_replace("{productnumber}", $this->data->product_number, $pagedesctag); $pagedesctag = str_replace("{shopname}", SHOP_NAME, $pagedesctag); $pagedesctag = str_replace("{productshortdesc}", strip_tags($this->data->product_s_desc), $pagedesctag); $pagedesctag = str_replace("{productdesc}", strip_tags($this->data->product_desc), $pagedesctag); $pagedesctag = str_replace("{saleprice}", $prodhelperobj_array_main['product_price'], $pagedesctag); $pagedesctag = str_replace("{saving}", $product_price_saving_main, $pagedesctag); $pagedesctag = $prodhelperobj->getProductNotForSaleComment($this->data, $pagedesctag); } if (trim($this->data->metadesc) != '' && AUTOGENERATED_SEO && SEO_PAGE_DESCRIPTION != '') { if ($this->data->append_to_global_seo == 'append') { $pagedesctag .= " " . $this->data->metadesc; $this->document->setMetaData('description', $pagedesctag); $this->document->setMetaData("og:description", $pagedesctag); } elseif ($this->data->append_to_global_seo == 'prepend') { $this->document->setMetaData('description', $pagedesctag); $this->document->setMetaData("og:description", $pagedesctag); } elseif ($this->data->append_to_global_seo == 'replace') { $this->document->setMetaData('description', $this->data->metadesc); $this->document->setMetaData("og:description", $this->data->metadesc); } } else { if (trim($this->data->metadesc) != '') { $this->document->setMetaData('description', $this->data->metadesc); $this->document->setMetaData("og:description", $pagedesctag); } elseif (AUTOGENERATED_SEO && SEO_PAGE_DESCRIPTION != '') { $this->document->setMetaData('description', $pagedesctag); $this->document->setMetaData("og:description", $pagedesctag); } elseif ($menu_meta_description != "") { $this->document->setMetaData('description', $menu_meta_description); $this->document->setMetaData("og:description", $menu_meta_description); } else { $prodhelperobj_array = $prodhelperobj->getProductNetPrice($this->data->product_id); if ($prodhelperobj_array['product_price_saving'] != '') { $product_price_saving_main = $prodhelperobj_array['product_price_saving']; } else { $product_price_saving_main = 0; } $this->document->setMetaData('description', JText::_('COM_REDSHOP_META_BUY') . ' ' . $this->data->product_name . ' ' . JText::_('COM_REDSHOP_META_AT_ONLY') . ' ' . $prodhelperobj_array['product_price'] . ' ' . JText::_('COM_REDSHOP_META_SAVE') . ' ' . $product_price_saving_main); $this->document->setMetaData('og:description', JText::_('COM_REDSHOP_META_BUY') . ' ' . $this->data->product_name . ' ' . JText::_('COM_REDSHOP_META_AT_ONLY') . ' ' . $prodhelperobj_array['product_price'] . ' ' . JText::_('COM_REDSHOP_META_SAVE') . ' ' . $product_price_saving_main); } } /** * @var $this->data * Trigger event onAfterDisplayProduct * Show content return by plugin directly into product page after display product title */ $this->data->event = new stdClass(); $results = $this->dispatcher->trigger('onAfterDisplayProductTitle', array(&$productTemplate->template_desc, $params, $this->data)); $this->data->event->afterDisplayTitle = trim(implode("\n", $results)); /** * @var $this->data * * Trigger event onBeforeDisplayProduct will display content before product display */ $results = $this->dispatcher->trigger('onBeforeDisplayProduct', array(&$productTemplate->template_desc, $params, $this->data)); $this->data->event->beforeDisplayProduct = trim(implode("\n", $results)); // For page heading if (AUTOGENERATED_SEO && SEO_PAGE_HEADING != '') { $pageheadingtag = SEO_PAGE_HEADING; $pageheadingtag = str_replace("{productname}", $this->data->product_name, $pageheadingtag); $pageheadingtag = str_replace("{categoryname}", $this->data->category_name, $pageheadingtag); $pageheadingtag = str_replace("{manufacturer}", $this->data->manufacturer_name, $pageheadingtag); $pageheadingtag = str_replace("{productsku}", $this->data->product_number, $pageheadingtag); $pageheadingtag = str_replace("{productnumber}", $this->data->product_number, $pageheadingtag); $pageheadingtag = str_replace("{productshortdesc}", strip_tags($this->data->product_s_desc), $pageheadingtag); } if (trim($this->data->pageheading) != '' && AUTOGENERATED_SEO && SEO_PAGE_HEADING != '') { $pageheadingtag = $pageheadingtag . " " . $this->data->pageheading; } else { if (trim($this->data->pageheading) != '') { $pageheadingtag = $this->data->pageheading; } } $visited = array(); $visited = $this->session->get('visited', $visited); if ($this->pid && !in_array($this->pid, $visited)) { $this->model->updateVisited($this->pid); $visited[] = $this->pid; $this->session->set('visited', $visited); } // End } // Breadcrumb if ($this->pid) { $prodhelperobj->generateBreadcrumb($this->pid); } $this->template = $productTemplate; $this->pageheadingtag = $pageheadingtag; $this->params = $params; $for = $this->input->getBool("for", false); if ($for) { parent::display('related'); return; } parent::display($tpl); }
return false; } else { document.frmchngAttribute.submit(); } } </script> <?php $cart_attribute = $redTemplate->getTemplate("change_cart_attribute"); if (count($cart_attribute) > 0 && $cart_attribute[0]->template_desc) { $template_desc = $cart_attribute[0]->template_desc; } else { $template_desc = '<table border="0">\\r\\n<tbody>\\r\\n<tr>\\r\\n<th>Change Attribute</th>\\r\\n</tr>\\r\\n<tr>\\r\\n<td>{attribute_template:attributes}</td>\\r\\n</tr>\\r\\n<tr>\\r\\n<td>{apply_button} {cancel_button}</td>\\r\\n</tr>\\r\\n</tbody>\\r\\n</table>'; } $product = $producthelper->getProductById($product_id); // Checking for child products $childproduct = $producthelper->getChildProduct($product_id); if (count($childproduct) > 0) { $isChilds = true; } else { $isChilds = false; } // Product attribute Start if ($isChilds) { $attributes = array(); $selectAtt = array(array(), array()); } else { $attributes_set = array(); if ($product->attribute_set_id > 0) { $attributes_set = $producthelper->getProductAttribute(0, $product->attribute_set_id, 0, 1);
public function store($data, $post) { $this->_loadData(); $quotationHelper = new quotationHelper(); $producthelper = new producthelper(); $extra_field = new extra_field(); $user = JFactory::getUser(); $user_id = 0; $user_info_id = 0; $user_email = $post['user_email']; if ($user->id) { $user_id = $user->id; $user_info_id = $this->_data->user_info_id; $user_email = $user->email; } $res = $this->getUserIdByEmail($user_email); if (count($res) > 0) { $user_id = $res->user_id; $user_info_id = $res->users_info_id; } $list_field = $extra_field->extra_field_save($post, 16, $user_info_id, $user_email); $data['quotation_number'] = $quotationHelper->generateQuotationNumber(); $data['user_id'] = $user_id; $data['user_info_id'] = $user_info_id; $data['user_email'] = $user_email; $data['quotation_total'] = $data['total']; $data['quotation_subtotal'] = $data['subtotal']; $data['quotation_tax'] = $data['tax']; $data['quotation_status'] = 1; $data['quotation_cdate'] = time(); $data['quotation_mdate'] = time(); $data['quotation_note'] = $data['quotation_note']; $data['quotation_ipaddress'] = $_SERVER['REMOTE_ADDR']; $data['quotation_encrkey'] = $quotationHelper->randomQuotationEncrkey(); $data['quotation_discount'] = isset($data['discount2']) ? $data['discount2'] : 0; $totalitem = $data['idx']; $quotation_item = array(); $row = $this->getTable('quotation_detail'); if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } for ($i = 0; $i < $totalitem; $i++) { $rowitem = $this->getTable('quotation_item_detail'); $quotation_item[$i] = new stdClass(); $quotation_item[$i]->quotation_id = $row->quotation_id; if (isset($data[$i]['giftcard_id']) && $data[$i]['giftcard_id'] != 0) { $quotation_item[$i]->product_id = $data[$i]['giftcard_id']; $giftcardData = $producthelper->getGiftcardData($data[$i]['giftcard_id']); $quotation_item[$i]->is_giftcard = 1; $quotation_item[$i]->product_name = $giftcardData->giftcard_name; $section = 13; } else { $product = $producthelper->getProductById($data[$i]['product_id']); $retAttArr = $producthelper->makeAttributeCart($data[$i]['cart_attribute'], $data[$i]['product_id'], 0, 0, $data[$i]['quantity']); $cart_attribute = $retAttArr[0]; $retAccArr = $producthelper->makeAccessoryCart($data[$i]['cart_accessory'], $data[$i]['product_id']); $cart_accessory = $retAccArr[0]; $quotation_item[$i]->product_id = $data[$i]['product_id']; $quotation_item[$i]->is_giftcard = 0; $quotation_item[$i]->product_name = $product->product_name; $quotation_item[$i]->actualitem_price = $data[$i]['product_price']; $quotation_item[$i]->product_price = $data[$i]['product_price']; $quotation_item[$i]->product_excl_price = $data[$i]['product_price_excl_vat']; $quotation_item[$i]->product_final_price = $data[$i]['product_price'] * $data[$i]['quantity']; $quotation_item[$i]->product_attribute = $cart_attribute; $quotation_item[$i]->product_accessory = $cart_accessory; $quotation_item[$i]->product_wrapperid = $data[$i]['wrapper_id']; $quotation_item[$i]->wrapper_price = $data[$i]['wrapper_price']; $section = 12; } $quotation_item[$i]->product_quantity = $data[$i]['quantity']; if (!$rowitem->bind($quotation_item[$i])) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$rowitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } /** my accessory save in table start */ if (count($data[$i]['cart_accessory']) > 0) { $attArr = $data[$i]['cart_accessory']; for ($a = 0; $a < count($attArr); $a++) { $accessory_vat_price = 0; $accessory_attribute = ""; $accessory_id = $attArr[$a]['accessory_id']; $accessory_name = $attArr[$a]['accessory_name']; $accessory_price = $attArr[$a]['accessory_price']; $accessory_org_price = $accessory_price; if ($accessory_price > 0) { $accessory_vat_price = $producthelper->getProductTax($rowitem->product_id, $accessory_price); } $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 = $rowitem->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 = $producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']); $property_id = $propArr[$k]['property_id']; $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $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 = $rowitem->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 = $producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']); $subproperty_id = $subpropArr[$l]['subproperty_id']; $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $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 = $rowitem->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 = $rowitem->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 = $rowitem->product_quantity; $rowaccitem->accessory_item_price = $accessory_price; $rowaccitem->accessory_final_price = $accessory_price * $rowitem->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($data[$i]['cart_attribute']) > 0) { $attArr = $data[$i]['cart_attribute']; 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 = $rowitem->quotation_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 = $producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']); $property_id = $propArr[$k]['property_id']; $rowattitem = $this->getTable('quotation_attribute_item'); $rowattitem->quotation_att_item_id = 0; $rowattitem->quotation_item_id = $rowitem->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 = $producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']); $subproperty_id = $subpropArr[$l]['subproperty_id']; $rowattitem = $this->getTable('quotation_attribute_item'); $rowattitem->quotation_att_item_id = 0; $rowattitem->quotation_item_id = $rowitem->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; } } } } } } $quotationHelper->manageQuotationUserfield($data[$i], $rowitem->quotation_item_id, $section); } return $row; }
public function sendMailForAskQuestion($data) { $this->store($data); $producthelper = new producthelper(); $redshopMail = new redshopMail(); $url = JURI::base(); $option = JRequest::getVar('option'); $Itemid = JRequest::getVar('Itemid'); $mailbcc = null; $fromname = $data['your_name']; $from = $data['your_email']; $subject = ""; $message = $data['your_question']; $product_id = $data['pid']; $mailbody = $redshopMail->getMailtemplate(0, "ask_question_mail"); $data_add = $message; if (count($mailbody) > 0) { $data_add = $mailbody[0]->mail_body; $subject = $mailbody[0]->mail_subject; if (trim($mailbody[0]->mail_bcc) != "") { $mailbcc = explode(",", $mailbody[0]->mail_bcc); } } $product = $producthelper->getProductById($product_id); $data_add = str_replace("{product_name}", $product->product_name, $data_add); $data_add = str_replace("{product_desc}", $product->product_desc, $data_add); // Init required properties $data['address'] = isset($data['address']) ? $data['address'] : null; $data['telephone'] = isset($data['telephone']) ? $data['telephone'] : null; $link = JRoute::_($url . "index.php?option=" . $option . "&view=product&pid=" . $product_id . '&Itemid=' . $Itemid); $product_url = "<a href=" . $link . ">" . $product->product_name . "</a>"; $data_add = str_replace("{product_link}", $product_url, $data_add); $data_add = str_replace("{user_question}", $message, $data_add); $data_add = str_replace("{answer}", "", $data_add); $subject = str_replace("{user_question}", $message, $subject); $subject = str_replace("{shopname}", SHOP_NAME, $subject); $data_add = str_replace("{user_address}", $data['address'], $data_add); $data_add = str_replace("{user_telephone}", $data['telephone'], $data_add); $data_add = str_replace("{user_telephone_lbl}", JText::_('COM_REDSHOP_USER_PHONE_LBL'), $data_add); $data_add = str_replace("{user_address_lbl}", JText::_('COM_REDSHOP_USER_ADDRESS_LBL'), $data_add); if (ADMINISTRATOR_EMAIL != "") { $sendto = explode(",", ADMINISTRATOR_EMAIL); if (JFactory::getMailer()->sendMail($from, $fromname, $sendto, $subject, $data_add, $mode = 1, null, $mailbcc)) { return true; } else { return false; } } }
/*if($product_price > $product_price_discount) { $wishlist_data = str_replace('{product_price}', $producthelper->getProductFormattedPrice($product_price_discount) , $wishlist_data); }else{ $wishlist_data = str_replace('{product_price}', $producthelper->getProductFormattedPrice($product_price) , $wishlist_data); }*/ $wishlist_data = str_replace('{product_s_desc}', $row->product_s_desc, $wishlist_data); // Checking for child products start if (strstr($wishlist_data, "{child_products}")) { $parentproductid = $row->product_id; if ($this->data->product_parent_id != 0) { $parentproductid = $producthelper->getMainParentProduct($row->product_id); } $frmChild = ""; if ($parentproductid != 0) { $productInfo = $producthelper->getProductById($parentproductid); // Get child products $childproducts = $model->getAllChildProductArrayList(0, $parentproductid); if (count($childproducts) > 0) { $childproducts = array_merge(array($productInfo), $childproducts); $cld_name = array(); if (count($childproducts) > 0) { $parentid = 0; for ($c = 0; $c < count($childproducts); $c++) { if ($childproducts[$c]->product_parent_id == 0) { $level = ""; } else { if ($parentid != $childproducts[$c]->product_parent_id) { $level = $level; } }
/** * Load the fields for export * * @return void */ private function loadFields() { $extra_field = new extra_field(); $producthelper = new producthelper(); $db = JFactory::getDbo(); $query = "SELECT * FROM `#__redshop_fields` ORDER BY field_id asc "; $this->_db->setQuery($query); $cur = $this->_db->loadObjectList(); $ret = null; for ($i = 0; $i < count($cur); $i++) { if ($i == 0) { echo "field_id,field_title,field_name_field,field_type,field_desc,field_class,field_section,field_maxlength,field_cols,field_rows,field_size,field_show_in_front,required,published,data_id,data_txt,itemid,section,value_id,field_value,field_name,data_number"; echo "\r\n"; } $query = 'SELECT data_id,`data_txt`,`itemid`,`section` FROM `#__redshop_fields_data` WHERE `fieldid` = ' . $cur[$i]->field_id . ' and section!=""'; $this->_db->setQuery($query); $data = $this->_db->loadObjectList(); $attr = array(); $datavalue = $extra_field->getFieldValue($cur[$i]->field_id); $attrvalue = array(); echo $cur[$i]->field_id . "," . $cur[$i]->field_title . "," . $cur[$i]->field_name . "," . $cur[$i]->field_type . "," . $cur[$i]->field_desc . "," . $cur[$i]->field_class . "," . $cur[$i]->field_section . "," . $cur[$i]->field_maxlength . "," . $cur[$i]->field_cols . "," . $cur[$i]->field_rows . "," . $cur[$i]->field_size . "," . $cur[$i]->field_show_in_front . "," . $cur[$i]->required . "," . $cur[$i]->published . "\n"; for ($att = 0; $att < count($data); $att++) { $product_details = $producthelper->getProductById($data[$att]->itemid); echo $cur[$i]->field_id . ",,,,,,,,,,,,,," . $data[$att]->data_id . ",\"" . $data[$att]->data_txt . "\"," . $data[$att]->itemid . "," . $data[$att]->section . ",,,," . $product_details->product_number . ",\n"; } for ($attrvalue = 0; $attrvalue < count($datavalue); $attrvalue++) { echo $cur[$i]->field_id . ",,,,,,,,,,,,,,,,,," . $datavalue[$attrvalue]->value_id . "," . $datavalue[$attrvalue]->field_value . "," . $datavalue[$attrvalue]->field_name . ",\n"; } } }
function getProductData($userData) { $producthelper = new producthelper(); if ($userData->product_id) { $productDetail = ""; $product_data = $producthelper->getProductById($userData->product_id); if ($userData->subproperty_id) { $subproperty_data = $producthelper->getAttibuteSubProperty($userData->subproperty_id); $property_data = $producthelper->getAttibuteProperty($userData->property_id); } else { if ($userData->property_id) { $property_data = $producthelper->getAttibuteProperty($userData->property_id); } } $productData = array(); $productDetail = $product_data->product_name; if (count($property_data) > 0) { $productDetail .= "<br/>" . $property_data['property_name']; } if (count($subproperty_data) > 0) { $productDetail .= "<br/>" . $subproperty_data['subproperty_name']; } $productData['product_name'] = $product_data->product_name; $productData['product_detail'] = $productDetail; return $productData; } }
function renderLayout() { if ($this->config['module_mode'] !== 'normal') { $this->render_portal_mode($this->config['module_mode']); } else { $renderer = new NSP_GK4_Layout_Parts(); // detecting mode - com_content or K2 $k2_mode = false; $rs_mode = false; $vm_mode = false; $producthelper = ''; $redhelper = ''; //check the source if ($this->config["data_source"] == 'k2_categories' || $this->config["data_source"] == 'k2_articles' || $this->config["data_source"] == 'all_k2_articles' || $this->config["data_source"] == 'k2_tags') { if ($this->config['k2_categories'] != -1) { $k2_mode = true; } else { // exception when K2 is not installed $this->content = array("ID" => array(), "alias" => array(), "CID" => array(), "title" => array(), "text" => array(), "date" => array(), "date_publish" => array(), "author" => array(), "cat_name" => array(), "cat_alias" => array(), "hits" => array(), "news_amount" => 0, "rating_sum" => 0, "rating_count" => 0, "plugins" => ''); } } else { if ($this->config["data_source"] == 'redshop_categories' || $this->config["data_source"] == 'redshop_products' || $this->config["data_source"] == 'all_redshop_products') { if ($this->config['redshop_categories'] != -1 && file_exists(JPATH_ROOT . DS . 'components' . DS . 'com_redshop')) { $rs_mode = true; $producthelper = new producthelper(); $redhelper = new redhelper(); } else { // exception when RedSHOP is not installed $this->content = array("ID" => array(), "CID" => array(), "title" => array(), "text" => array(), "date" => array(), "date_publish" => array(), "price" => array(), "discount_price" => array(), "discount_start" => array(), "discount_end" => array(), "tax" => array(), "cat_name" => array(), "manufacturer" => array(), "manufacturer_id" => array(), "product_image" => array(), "news_amount" => array()); } } elseif ($this->config["data_source"] == 'vm_categories' || $this->config["data_source"] == 'vm_products') { if ($this->config['vm_categories'] != -1) { $vm_mode = true; } else { // exception when VirtueMart is not installed $this->content = array("ID" => array(), "CID" => array(), "title" => array(), "text" => array(), "date" => array(), "date_publish" => array(), "price" => array(), "price_currency" => array(), "discount_amount" => array(), "discount_is_percent" => array(), "discount_start" => array(), "discount_end" => array(), "tax" => array(), "cat_name" => array(), "manufacturer" => array(), "manufacturer_id" => array(), "product_image" => array(), "news_amount" => 0); } } } // tables which will be used in generated content $news_list_tab = array(); $news_html_tab = array(); // Generating content $uri =& JURI::getInstance(); $li_counter = 0; $news_k2_store = ''; $news_header = ''; $news_image = ''; $news_readmore = ''; $news_textt = ''; $news_infoo = ''; $news_infoo2 = ''; // for ($i = 0; $i < count($this->content["ID"]); $i++) { if ($i < $this->config['news_column'] * $this->config['news_rows'] * $this->config['news_full_pages']) { // GENERATING NEWS CONTENT if ($k2_mode == FALSE && $rs_mode == FALSE && $vm_mode == FALSE) { // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i]); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image($this->config, $uri, $this->content['ID'][$i], $this->content['IID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $this->content['title'][$i], $this->content['images'][$i]); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore($this->config, $this->content['ID'][$i], $this->content['CID'][$i]); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $news_readmore); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info($this->config, $this->content['catname'][$i], $this->content['CID'][$i], $this->content['author'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['rating_count'][$i], $this->content['rating_sum'][$i]); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info($this->config, $this->content['catname'][$i], $this->content['CID'][$i], $this->content['author'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['rating_count'][$i], $this->content['rating_sum'][$i], 2); } } else { if ($rs_mode == FALSE && $vm_mode == FALSE && $k2_mode == TRUE) { // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['title'][$i]); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image_k2($this->config, $uri, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['text'][$i], $this->content['title'][$i]); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i]); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['text'][$i], $news_readmore); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info_k2($this->config, $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['author'][$i], $this->content['author_id'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['alias'][$i], $this->content['comments'], $this->content['rating_count'][$i], $this->content['rating_sum'][$i]); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info_k2($this->config, $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['author'][$i], $this->content['author_id'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['alias'][$i], $this->content['comments'], $this->content['rating_count'][$i], $this->content['rating_sum'][$i], 2); } // GENERATE STORE BLOCK $news_k2_store = $renderer->store_k2($this->config, $this->content['ID'][$i], $this->content['plugins'][$i], $this->k2store_params); } else { if ($rs_mode == TRUE && $vm_mode == FALSE && $k2_mode == FALSE) { $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $this->content['ID'][$i]); $id = $this->content['ID'][$i]; $cid = $producthelper->getCategoryProduct($this->content['ID'][$i]); $Itemid = $redhelper->getItemid($this->content['ID'][$i]); $product = $producthelper->getProductById($this->content['ID'][$i]); // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i], $Itemid); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['product_image'][$i], $this->content['title'][$i], $Itemid); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $Itemid); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $news_readmore, $Itemid); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info_rs($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $Itemid, $this->content['manufacturer_id'][$i], 1); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info_rs($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $Itemid, $this->content['manufacturer_id'][$i], 2); } // COMPUTE PRICE DEPENDS OF USER ID $user =& JFactory::getUser(); $price = $producthelper->getProductPrice($this->content['ID'][$i], $this->config['rs_price_with_vat'], $user->id); $price = $producthelper->getProductFormattedPrice($price, true); if ($this->config['rs_add_to_cart'] == 1) { $addToCart = $producthelper->replaceCartTemplate($this->content['ID'][$i], 0, 0, 0, "", false, array(), 0, 0, 0); $addToCart = str_replace('&', '&', $addToCart); if ($this->config['rs_show_default_cart_button'] == 0) { $btnCode = '<a class=\'nspAddToCart\' onclick="if(displayAddtocartForm(\'addtocart_prd_' . $this->content['ID'][$i]; $btnCode .= '\',\'' . $id . '\',\'0\',\'0\', \'user_fields_form\'))'; $btnCode .= '{checkAddtocartValidation(\'addtocart_prd_' . $id . '\',\'' . $id . '\',\'0\',\'0\', \'user_fields_form\',\'0\',\'0\',\'0\');}"><span style=\'cursor: pointer;\' id=\'pdaddtocartprd' . $id . '\' title=\'\' class=\'\'>' . JText::_('MOD_NEWS_PRO_GK4_ADD_TO_CART') . '</span></a>'; $addToCart = preg_replace('/\\<img.*?\\>/i', $btnCode, $addToCart); } } // GET THE CURRENCY $bool = preg_match('/[^0-9]/u', $price, $currency); $currency = $currency[0]; $bool = preg_match('/[0-9]+/u', $price, $price); $price = $price[0]; // GENERATE RedSHOP STORE INFO $news_rs_store = $renderer->store_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $price, $this->content['discount_start'][$i], $this->content['discount_end'][$i], $this->content['tax'][$i], $this->content['discount_price'][$i], $currency, $Itemid, $addToCart); } else { if ($vm_mode == TRUE) { // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i]); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['product_image'][$i], $this->content['title'][$i]); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i]); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $news_readmore); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info_vm($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['comments']); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info_vm($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['comments'], 2); } $news_vm_store = $renderer->store_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['price'][$i], $this->content['price_currency'][$i], $this->content['discount_amount'][$i], true, $this->content['discount_start'][$i], $this->content['discount_end'][$i], $this->content['tax'][$i], $this->content['manufacturer_id'][$i]); } } } } // PARSING PLUGINS if ($this->config['parse_plugins'] == TRUE) { $news_textt = JHtml::_('content.prepare', $news_textt); } // CLEANING PLUGINS if ($this->config['clean_plugins'] == TRUE) { $news_textt = preg_replace("/(\\{.+?\\}.+?\\{.+?})|(\\{.+?\\})/", "", $news_textt); } // GENERATE CONTENT FOR TAB $news_generated_content = ''; // initialize variable // for ($j = 1; $j < 7; $j++) { if ($this->config['wrapContent'] == 1 && $this->config['news_image_order'] == 1) { if ($j == 2) { $news_generated_content .= '<div class="gkArtContentWrap">'; } } if ($this->config['news_header_order'] == $j) { $news_generated_content .= $news_header; } if ($this->config['news_image_order'] == $j) { $news_generated_content .= $news_image; } if ($this->config['news_text_order'] == $j) { $news_generated_content .= $news_textt; } if ($this->config['news_info_order'] == $j) { $news_generated_content .= $news_infoo; } if ($this->config['news_info2_order'] == $j) { $news_generated_content .= $news_infoo2; } if ($this->config['news_rs_store_enabled'] != 'disabled') { if ($rs_mode != FALSE && $this->config['news_rs_store_order'] == $j) { $news_generated_content .= $news_rs_store; } if ($vm_mode != FALSE && $this->config['news_rs_store_order'] == $j) { $news_generated_content .= $news_vm_store; } if ($k2_mode != FALSE && $this->config['news_rs_store_order'] == $j) { $news_generated_content .= $news_k2_store; } } } // if ($this->config['news_content_readmore_pos'] != 'after') { $news_generated_content .= $news_readmore; } if ($this->config['wrapContent'] == 1 && $this->config['news_image_order'] == 1) { $news_generated_content .= '</div>'; } // creating table with news content array_push($news_html_tab, $news_generated_content); } else { if ($k2_mode == FALSE && $vm_mode == FALSE) { array_push($news_list_tab, $renderer->lists($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i], $this->content['text'][$i], $li_counter % 2, $li_counter)); } elseif ($k2_mode == TRUE) { array_push($news_list_tab, $renderer->lists_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['title'][$i], $this->content['text'][$i], $li_counter % 2, $li_counter)); } else { array_push($news_list_tab, $renderer->lists_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i], $this->content['text'][$i], $li_counter % 2, $li_counter)); } // $li_counter++; } } /** GENERATING FINAL XHTML CODE START **/ // create instances of basic Joomla! classes $document = JFactory::getDocument(); $uri = JURI::getInstance(); // add stylesheets to document header if ($this->config["useCSS"] == 1) { $document->addStyleSheet($uri->root() . 'modules/mod_news_pro_gk4/interface/css/style.css', 'text/css'); } // add script to the document header if ($this->config['useScript'] == 1) { $document->addScript($uri->root() . 'modules/mod_news_pro_gk4/interface/scripts/engine.js'); } // init $headData variable $headData = false; // add scripts with automatic mode to document header if ($this->config['useScript'] == 2) { // getting module head section datas unset($headData); $headData = $document->getHeadData(); // generate keys of script section $headData_keys = array_keys($headData["scripts"]); // set variable for false $engine_founded = false; // searching phrase mootools in scripts paths if (array_search($uri->root() . 'modules/mod_news_pro_gk4/interface/scripts/engine.js', $headData_keys) > 0) { $engine_founded = true; } // if engine doesn't exists in the head section if (!$engine_founded) { // add new script tag connected with mootools from module $document->addScript($uri->root() . 'modules/mod_news_pro_gk4/interface/scripts/engine.js'); } } // require JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'content'); require JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'default'); } }
public function store($data) { $producthelper = new producthelper(); $row =& $this->getTable('mass_discount_detail'); if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } $row->category_id = @implode(",", $data['category_id']); $row->manufacturer_id = @implode(",", $data['manufacturer_id']); $row->discount_product = @implode(",", $data['discount_product']); $change_product = false; $newchange_product = false; $this->setId($row->mass_discount_id); $dataDiscount =& $this->getData(); $discount_product = explode(',', $dataDiscount->discount_product); $tmp = new stdClass(); $tmp = @array_merge($tmp, $discount_product); $newdiscount_product = explode(',', $row->discount_product); $tmp = new stdClass(); $tmp = @array_merge($tmp, $newdiscount_product); $arr_diff = array_diff($discount_product, $newdiscount_product); if (count($arr_diff) > 0) { sort($arr_diff); } else { $change_product = true; } for ($i = 0; $i < count($arr_diff); $i++) { $query = 'UPDATE ' . $this->_table_prefix . 'product SET product_on_sale="0" WHERE product_id="' . $arr_diff[$i] . '" '; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } $arr_diff = array_diff($newdiscount_product, $discount_product); if (count($arr_diff) > 0) { sort($arr_diff); } else { $newchange_product = true; } if ($change_product && $newchange_product) { $arr_diff = $discount_product; } for ($i = 0; $i < count($arr_diff); $i++) { $productData = $producthelper->getProductById($arr_diff[$i]); if ($productData->product_on_sale != 1) { $p_price = $data['discount_type'] == 1 ? $productData->product_price - $productData->product_price * $data['discount_amount'] / 100 : $productData->product_price - $data['discount_amount']; $p_price = $producthelper->productPriceRound($p_price); $query = 'UPDATE ' . $this->_table_prefix . 'product SET product_on_sale="1" , discount_price="' . $p_price . '" , discount_stratdate="' . $data['discount_startdate'] . '" , discount_enddate="' . $data['discount_enddate'] . '" WHERE product_id="' . $arr_diff[$i] . '" '; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } } $category_id = explode(',', $dataDiscount->category_id); $tmp = new stdClass(); $tmp = @array_merge($tmp, $category_id); $newcategory_id = explode(',', $row->category_id); $tmp = new stdClass(); $tmp = @array_merge($tmp, $newcategory_id); $change_category = false; $newchange_category = false; $arr_diff = array_diff($category_id, $newcategory_id); if (count($arr_diff) > 0) { sort($arr_diff); } else { $change_category = true; } for ($i = 0; $i < count($arr_diff); $i++) { $product_Ids = $producthelper->getProductCategory($arr_diff[$i]); for ($p = 0; $p < count($product_Ids); $p++) { $query = 'UPDATE ' . $this->_table_prefix . 'product SET product_on_sale="0" WHERE product_id="' . $product_Ids[$p]->product_id . '" '; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } } $arr_diff = array_diff($newcategory_id, $category_id); if (count($arr_diff) > 0) { sort($arr_diff); } else { $newchange_category = true; } if ($change_category && $newchange_category) { $arr_diff = $category_id; } for ($i = 0; $i < count($arr_diff); $i++) { $product_Ids = $producthelper->getProductCategory($arr_diff[$i]); for ($p = 0; $p < count($product_Ids); $p++) { $productData = $producthelper->getProductById($product_Ids[$p]->product_id); if ($productData->product_on_sale != 1) { $p_price = $data['discount_type'] == 1 ? $productData->product_price - $productData->product_price * $data['discount_amount'] / 100 : $data['discount_amount']; $p_price = $producthelper->productPriceRound($p_price); $query = 'UPDATE ' . $this->_table_prefix . 'product SET product_on_sale="1" , discount_price="' . $p_price . '" , discount_stratdate="' . $data['discount_startdate'] . '" , discount_enddate="' . $data['discount_enddate'] . '" WHERE product_id="' . $product_Ids[$p]->product_id . '" '; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } } } $manufacturer_id = explode(',', $dataDiscount->manufacturer_id); $tmp = new stdClass(); $tmp = @array_merge($tmp, $manufacturer_id); $change_manufacturer = false; $newchange_manufacturer = false; $newmanufacturer_id = explode(',', $row->manufacturer_id); $tmp = new stdClass(); $tmp = @array_merge($tmp, $newmanufacturer_id); $manu_arr_diff = array_diff($manufacturer_id, $newmanufacturer_id); if (count($manu_arr_diff) > 0) { sort($manu_arr_diff); } else { $change_manufacturer = true; } for ($i = 0; $i < count($manu_arr_diff); $i++) { if ($manu_arr_diff[$i] > 0) { $product_Ids = $this->GetProductmanufacturer($manu_arr_diff[$i]); for ($p = 0; $p < count($product_Ids); $p++) { $query = 'UPDATE ' . $this->_table_prefix . 'product SET product_on_sale="0" WHERE product_id="' . $product_Ids[$p]->product_id . '" '; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } } } $manu_arr_diff = array_diff($newmanufacturer_id, $manufacturer_id); if (count($manu_arr_diff) > 0) { sort($manu_arr_diff); } else { $newchange_manufacturer = true; } if ($newchange_manufacturer && $change_manufacturer) { $manu_arr_diff = $manufacturer_id; } for ($i = 0; $i < count($manu_arr_diff); $i++) { if ($manu_arr_diff[$i] > 0) { $product_Ids = $this->GetProductmanufacturer($manu_arr_diff[$i]); for ($p = 0; $p < count($product_Ids); $p++) { $productData = $producthelper->getProductById($product_Ids[$p]->product_id); $p_price = $data['discount_type'] == 1 ? $productData->product_price - $productData->product_price * $data['discount_amount'] / 100 : $data['discount_amount']; if ($productData->product_on_sale != 1) { $p_price = $producthelper->productPriceRound($p_price); $query = 'UPDATE ' . $this->_table_prefix . 'product SET product_on_sale="1" , discount_price="' . $p_price . '" , discount_stratdate="' . $data['discount_startdate'] . '" , discount_enddate="' . $data['discount_enddate'] . '" WHERE product_id="' . $product_Ids[$p]->product_id . '" '; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } } } } $row->manufacturer_id = $row->manufacturer_id ? $row->manufacturer_id : ''; $row->category_id = $row->category_id ? $row->category_id : ''; $row->discount_product = $row->discount_product ? $row->discount_product : ''; if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } return $row; }
public function displayQuotationUserfield($quotation_item_id = 0, $section_id = 12) { $redTemplate = new Redtemplate(); $producthelper = new producthelper(); $resultArr = array(); $db = JFactory::getDbo(); $sql = "SELECT fd.*,f.field_title,f.field_type,f.field_name " . "FROM " . $this->_table_prefix . "quotation_fields_data AS fd " . "LEFT JOIN " . $this->_table_prefix . "fields AS f ON f.field_id=fd.fieldid " . "WHERE fd.quotation_item_id= " . (int) $quotation_item_id . " AND fd.section = " . $db->quote($section_id); $db->setQuery($sql); $userfield = $db->loadObjectlist(); if (count($userfield) > 0) { $quotationItem = $this->getQuotationProduct(0, $quotation_item_id); $product_id = $quotationItem[0]->product_id; $productdetail = $producthelper->getProductById($product_id); $productTemplate = $redTemplate->getTemplate("product", $productdetail->product_template); $returnArr = $producthelper->getProductUserfieldFromTemplate($productTemplate[0]->template_desc); $userFieldTag = $returnArr[1]; for ($i = 0; $i < count($userFieldTag); $i++) { for ($j = 0; $j < count($userfield); $j++) { if ($userfield[$j]->field_name == $userFieldTag[$i]) { if ($userfield[$j]->field_type == 10) { $files = explode(",", $userfield[$j]->data_txt); $data_txt = ""; for ($f = 0; $f < count($files); $f++) { $u_link = REDSHOP_FRONT_DOCUMENT_ABSPATH . "product/" . $files[$f]; $data_txt .= "<a href='" . $u_link . "'>" . $files[$f] . "</a> "; } $resultArr[] = $userfield[$j]->field_title . " : " . $data_txt; } else { $resultArr[] = $userfield[$j]->field_title . " : " . $userfield[$j]->data_txt; } } } } } $resultstr = ""; if (count($resultArr) > 0) { $resultstr .= "<br/>" . implode("<br/>", $resultArr); } return $resultstr; }
/** * Add to wishlist function * * @access public * @return void */ public function addtowishlist() { ob_clean(); $app = JFactory::getApplication(); $extraField = new extraField(); $section = 12; $row_data = $extraField->getSectionFieldList($section); // GetVariables $producthelper = new producthelper(); $cid = JRequest::getInt('cid'); $user = JFactory::getUser(); $Itemid = JRequest::getVar('Itemid'); $option = JRequest::getVar('option'); $ajaxvar = JRequest::getVar('ajaxon'); $mywid = JRequest::getVar('wid'); if ($ajaxvar == 1 && ($mywid == 1 || $mywid == 2)) { $post = JRequest::get('post'); $post['product_id'] = JRequest::getVar('product_id'); $proname = $producthelper->getProductById($post['product_id']); $post['view'] = JRequest::getVar('view'); $post['task'] = JRequest::getVar('task'); for ($i = 0; $i < count($row_data); $i++) { $field_name = $row_data[$i]->field_name; $type = $row_data[$i]->field_type; if (isset($post[$row_data[$i]->field_name])) { $data_txt = $post[$row_data[$i]->field_name]; } else { $data_txt = ''; } $tmpstr = strpbrk($data_txt, '`'); if ($tmpstr) { $tmparray = explode('`', $data_txt); $tmp = new stdClass(); $tmp = @array_merge($tmp, $tmparray); if (is_array($tmparray)) { $data_txt = implode(",", $tmparray); } } $post['productuserfield_' . $i] = $data_txt; } } else { $post = JRequest::get('post'); $proname = $producthelper->getProductById($post['product_id']); for ($i = 0; $i < count($row_data); $i++) { $field_name = $row_data[$i]->field_name; $type = $row_data[$i]->field_type; if (isset($post[$row_data[$i]->field_name])) { $data_txt = $post[$row_data[$i]->field_name]; } else { $data_txt = ''; } $tmpstr = strpbrk($data_txt, '`'); if ($tmpstr) { $tmparray = explode('`', $data_txt); $tmp = new stdClass(); $tmp = @array_merge($tmp, $tmparray); if (is_array($tmparray)) { $data_txt = implode(",", $tmparray); } } $post['productuserfield_' . $i] = $data_txt; } } $rurl = ""; if (isset($post['rurl'])) { $rurl = base64_decode($post['rurl']); } // Initiallize variable $post['user_id'] = $user->id; $post['cdate'] = time(); $model = $this->getModel('product'); if ($user->id && $ajaxvar != '1') { if ($model->checkWishlist($post['product_id']) == null) { if ($model->addToWishlist($post)) { $app->enqueueMessage(JText::_('COM_REDSHOP_WISHLIST_SAVE_SUCCESSFULLY')); } else { $app->enqueueMessage(JText::_('COM_REDSHOP_ERROR_SAVING_WISHLIST')); } } else { $app->enqueueMessage(JText::_('COM_REDSHOP_ALLREADY_ADDED_TO_WISHLIST')); } } else { // User can store wishlist in session if ($model->addtowishlist2session($post)) { $app->enqueueMessage(JText::_('COM_REDSHOP_WISHLIST_SAVE_SUCCESSFULLY')); } else { $app->enqueueMessage(JText::_('COM_REDSHOP_ALLREADY_ADDED_TO_WISHLIST')); } } if ($ajaxvar == 1) { sleep(2); $getproductimage = $producthelper->getProductById($post['product_id']); $finalproductimgname = $getproductimage->product_full_image; if ($finalproductimgname != '') { $mainimg = "product/" . $finalproductimgname; } else { $mainimg = 'noimage.jpg'; } echo "<span id='basketWrap' ><a href='index.php?view=wishlist&task=viewwishlist&option=com_redshop&Itemid=" . JRequest::getVar('Itemid') . "&pid=" . $post['product_id'] . "'><img src='" . REDSHOP_FRONT_IMAGES_ABSPATH . $mainimg . "' height='30' width='30'/></a></span>:-:" . $proname->product_name . ""; exit; } elseif ($mywid == 1) { $this->setRedirect('index.php?option=' . $option . 'wishlist=1&view=login&Itemid=' . $Itemid); } if ($rurl != "") { $this->setRedirect($rurl); } else { $this->setRedirect('index.php?option=' . $option . '&view=product&pid=' . $post['product_id'] . '&cid=' . $cid . '&Itemid=' . $Itemid); } }