public function save($apply = 0) { $post = JRequest::get('post', JREQUEST_ALLOWRAW); $manufacturer_desc = JRequest::getVar('manufacturer_desc', '', 'post', 'string', JREQUEST_ALLOWRAW); $post["manufacturer_desc"] = $manufacturer_desc; $option = JRequest::getVar('option'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['manufacturer_id'] = $cid[0]; $model = $this->getModel('manufacturer_detail'); if ($row = $model->store($post)) { $field = new extra_field(); $field->extra_field_save($post, "10", $row->manufacturer_id); $msg = JText::_('COM_REDSHOP_MANUFACTURER_DETAIL_SAVED'); } else { $msg = JText::_('COM_REDSHOP_ERROR_SAVING_MANUFACTURER_DETAIL'); } if ($apply == 1) { $this->setRedirect('index.php?option=' . $option . '&view=manufacturer_detail&task=edit&cid[]=' . $row->manufacturer_id, $msg); } else { $this->setRedirect('index.php?option=' . $option . '&view=manufacturer', $msg); } }
/** * Method to send catalog sample * * @return void */ public function catalogsample_send() { $post = JRequest::get('post'); $Itemid = JRequest::getVar('Itemid'); $option = JRequest::getVar('option', '', 'request', 'string'); $model = $this->getModel('catalog'); if (isset($post["sample_code"])) { $colour_id = implode(",", $post["sample_code"]); $post['colour_id'] = $colour_id; } $post["registerdate"] = time(); $post["email"] = $post["email_address"]; $post["name"] = $post["name_2"]; if ($row = $model->catalogSampleStore($post)) { $extra_field = new extra_field(); $extra_field->extra_field_save($post, 9, $row->request_id); $msg = JText::_('COM_REDSHOP_SAMPLE_SEND_SUCCSEEFULLY'); } else { $msg = JText::_('COM_REDSHOP_ERROR_SAMPLE_SEND_SUCCSEEFULLY'); } $this->setRedirect('index.php?option=' . $option . '&view=catalog&layout=sample&Itemid=' . $Itemid, $msg); }
public function save($apply = 0) { $post = JRequest::get('post'); // Include extra field class require_once JPATH_COMPONENT . '/helpers/extra_field.php'; $option = JRequest::getVar('option'); $post['shipping_rate_on_product'] = $post['container_product']; $post["shipping_location_info"] = JRequest::getVar('shipping_location_info', '', 'post', 'string', JREQUEST_ALLOWRAW); $model = $this->getModel('shipping_rate_detail'); if ($row = $model->store($post)) { $field = new extra_field(); // Field_section 11 :Shipping $field->extra_field_save($post, "11", $row->shipping_rate_id); $msg = JText::_('COM_REDSHOP_SHIPPING_LOCATION_SAVED'); } else { $msg = JText::_('COM_REDSHOP_ERROR_SAVING_SHIPPING'); } if ($apply) { $this->setRedirect('index.php?option=' . $option . '&view=shipping_rate_detail&cid=' . $row->shipping_rate_id . '&id=' . $post['id'], $msg); } else { $this->setRedirect('index.php?option=' . $option . '&view=shipping_rate&id=' . $post['id'], $msg); } }
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; }
public function store($data) { $row =& $this->getTable(); if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } // Storing image name in the database $option = JRequest::getVar('option'); $filename = ""; // Get File name, tmp_name $file = JRequest::getVar('category_full_image', array(), 'files', 'array'); if (count($file) > 0) { // Make the filename unique $filename = JPath::clean(time() . '_' . $file['name']); $filename = str_replace(" ", "_", $filename); } if (isset($data['image_delete'])) { unlink(REDSHOP_FRONT_IMAGES_RELPATH . 'category/thumb/' . $data['old_image']); unlink(REDSHOP_FRONT_IMAGES_RELPATH . 'category/' . $data['old_image']); $query = "UPDATE " . $this->_table_prefix . "category set category_thumb_image = '',category_full_image = '' where category_id =" . $row->category_id; $this->_db->setQuery($query); $this->_db->query(); } if (count($_FILES) > 0 && $_FILES['category_full_image']['name'] != "") { $newwidth = THUMB_WIDTH; $newheight = THUMB_HEIGHT; $row->category_full_image = $filename; $row->category_thumb_image = $filename; // Get extension of the file $filetype = JFile::getExt($file['name']); $src = $file['tmp_name']; // Specific path of the file $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'category/' . $filename; JFile::upload($src, $dest); } else { if (isset($data['category_image']) && $data['category_image'] != null) { $image_split = explode('/', $data['category_image']); // Make the filename unique $filename = JPath::clean(time() . '_' . $image_split[count($image_split) - 1]); $row->category_full_image = $filename; $row->category_thumb_image = $filename; // Image Upload $newwidth = THUMB_WIDTH; $newheight = THUMB_HEIGHT; $src = JPATH_ROOT . '/' . $data['category_image']; $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'category/' . $filename; copy($src, $dest); } } // Get File name, tmp_name $backfile = JRequest::getVar('category_back_full_image', '', 'files', 'array'); if (isset($data['image_back_delete'])) { unlink(REDSHOP_FRONT_IMAGES_RELPATH . 'category/thumb/' . $data['old_back_image']); unlink(REDSHOP_FRONT_IMAGES_RELPATH . 'category/' . $data['old_back_image']); $query = "UPDATE " . $this->_table_prefix . "category set category_back_full_image = '' where category_id =" . $row->category_id; $this->_db->setQuery($query); $this->_db->query(); } if (count($backfile) > 0 && $backfile['name'] != "") { // Make the filename unique $filename = JPath::clean(time() . '_' . $backfile['name']); $row->category_back_full_image = $filename; // Get extension of the file $filetype = JFile::getExt($backfile['name']); $src = $backfile['tmp_name']; // Specific path of the file $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'category/' . $filename; JFile::upload($src, $dest); } // Upload back image end if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$data['category_id']) { $newcatid = $this->_db->insertid(); if (isset($_POST['category_parent_id'])) { $parentcat = $_POST['category_parent_id']; } else { $parentcat = $data['category_parent_id']; } $query = 'INSERT INTO ' . $this->_table_prefix . 'category_xref(category_parent_id,category_child_id) VALUES ("' . $parentcat . '","' . $newcatid . '");'; $this->_db->setQuery($query); $this->_db->query(); } else { $newcatid = $data['category_id']; if (isset($_POST['category_parent_id'])) { $parentcat = $_POST['category_parent_id']; } else { $parentcat = $data['category_parent_id']; } $query = 'UPDATE ' . $this->_table_prefix . 'category_xref SET category_parent_id= "' . $parentcat . '" WHERE category_child_id = "' . $newcatid . '" '; $this->_db->setQuery($query); $this->_db->query(); // Sheking for the image at the updation time if ($_FILES['category_full_image']['name'] != "") { @unlink(REDSHOP_FRONT_IMAGES_RELPATH . 'category/thumb/' . $_POST['old_image']); @unlink(REDSHOP_FRONT_IMAGES_RELPATH . 'category/' . $_POST['old_image']); } } // Extra Field Data Saved $field = new extra_field(); $field->extra_field_save($data, 2, $newcatid); // Start Accessory Product if (count($data['product_accessory']) > 0 && is_array($data['product_accessory'])) { $data['product_accessory'] = array_merge(array(), $data['product_accessory']); $product_category = new product_category(); $product_list = $product_category->getCategoryProductList($newcatid); for ($p = 0; $p < count($product_list); $p++) { $product_id = $product_list[$p]->id; for ($a = 0; $a < count($data['product_accessory']); $a++) { $acc = $data['product_accessory'][$a]; $accessory_id = $product_category->CheckAccessoryExists($product_id, $acc['child_product_id']); if ($product_id != $acc['child_product_id']) { $accdetail =& $this->getTable('accessory_detail'); $accdetail->accessory_id = $accessory_id; $accdetail->category_id = $newcatid; $accdetail->product_id = $product_id; $accdetail->child_product_id = $acc['child_product_id']; $accdetail->accessory_price = $acc['accessory_price']; $accdetail->oprand = $acc['oprand']; $accdetail->ordering = $acc['ordering']; $accdetail->setdefault_selected = isset($acc['setdefault_selected']) && $acc['setdefault_selected'] == 1 ? 1 : 0; if (!$accdetail->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } } } } // End Accessory Product insert return $row; }
public function updateBillingAdd($data) { $row = $this->getTable('order_user_detail'); $row->load($data['order_info_id']); $row->bind($data); if ($row->store()) { if ($row->is_company == 1) { // Saving users extra fields information $field = new extra_field(); // Field_section 8 :Company Address Section $list_field = $field->extra_field_save($data, 8, $row->users_info_id); } else { // Saving users extra fields information $field = new extra_field(); // Field_section 7 :Customer Address Section $list_field = @$field->extra_field_save($data, 7, $row->users_info_id); } return true; } else { return false; } }
public function storeRedshopUserShipping($data) { $extra_field = new extra_field(); $rowShip = JTable::getInstance('user_detail', 'Table'); if (!$rowShip->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } $rowShip->user_id = $data['user_id']; $rowShip->address_type = 'ST'; $rowShip->country_code = $data['country_code_ST']; $rowShip->state_code = isset($data['state_code_ST']) ? $data['state_code_ST'] : ""; $rowShip->firstname = $data['firstname_ST']; $rowShip->lastname = $data['lastname_ST']; $rowShip->address = $data['address_ST']; $rowShip->city = $data['city_ST']; $rowShip->zipcode = $data['zipcode_ST']; $rowShip->phone = $data['phone_ST']; $rowShip->user_email = $data['user_email']; $rowShip->tax_exempt = $data['tax_exempt']; $rowShip->requesting_tax_exempt = $data['requesting_tax_exempt']; $rowShip->shopper_group_id = $data['shopper_group_id']; $rowShip->tax_exempt_approved = $data['tax_exempt_approved']; $rowShip->is_company = $data['is_company']; if ($data['is_company'] == 1) { $rowShip->company_name = $data['company_name']; $rowShip->vat_number = $data['vat_number']; } if (!$rowShip->store()) { $this->setError($this->_db->getErrorMsg()); return false; } if ($data['is_company'] == 0) { // Info: field_section 14 :Customer shipping Address $list_field = $extra_field->extra_field_save($data, 14, $rowShip->users_info_id); } else { // Info: field_section 15 :Company shipping Address $list_field = $extra_field->extra_field_save($data, 15, $rowShip->users_info_id); } return $rowShip; }
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; }
/** * Save task. * * @param int $apply Task is apply or common save. * * @return void */ public function save($apply = 0) { // ToDo: This is potentially unsafe because $_POST elements are not sanitized. $post = $this->input->getArray($_POST); $cid = $this->input->post->get('cid', array(), 'array'); $post['product_id'] = $cid[0]; $stockroom_id = ''; if (is_array($post['product_category']) && !in_array($post['cat_in_sefurl'], $post['product_category'])) { $post['cat_in_sefurl'] = $post['product_category'][0]; } if (!$post['product_id']) { $post['publish_date'] = date("Y-m-d H:i:s"); } $post['discount_stratdate'] = strtotime($post['discount_stratdate']); if ($post['discount_enddate']) { $post['discount_enddate'] = strtotime($post['discount_enddate']) + 23 * 59 * 59; } $post["product_number"] = trim($this->input->getString('product_number', '')); $product_s_desc = $this->input->post->get('product_s_desc', array(), 'array'); $post["product_s_desc"] = stripslashes($product_s_desc[0]); $product_desc = $this->input->post->get('product_desc', array(), 'array'); $post["product_desc"] = stripslashes($product_desc[0]); if (!empty($post['product_availability_date'])) { $post['product_availability_date'] = strtotime($post['product_availability_date']); } if (trim($post["parent"]) == "") { $post["product_parent_id"] = 0; } $container_id = $this->input->getInt('container_id', null); if (USE_CONTAINER == 1) { $stockroom_id = $this->input->getInt('stockroom_id', null); } require_once JPATH_COMPONENT . '/helpers/extra_field.php'; $model = $this->getModel('product_detail'); if ($row = $model->store($post)) { // Save Association $model->SaveAssociations($row->product_id, $post); // Add product to economic if (ECONOMIC_INTEGRATION == 1) { $economic = new economic(); $economic->createProductInEconomic($row); } $field = new extra_field(); // Field_section 1 :Product $field->extra_field_save($post, 1, $row->product_id); // Field_section 12 :Product Userfield $field->extra_field_save($post, 12, $row->product_id); // Field_section 12 :Productfinder datepicker $field->extra_field_save($post, 17, $row->product_id); $this->attribute_save($post, $row); // Extra Field Data Saved $msg = JText::_('COM_REDSHOP_PRODUCT_DETAIL_SAVED'); $link = ''; if ($container_id != '' || $stockroom_id != '') { // ToDo: Fix this horror below! ?> <script language="javascript" type="text/javascript"> <?php if ($container_id) { $link = 'index.php?option=' . $this->option . '&view=container_detail&task=edit&cid[]=' . $container_id; } if ($stockroom_id && USE_CONTAINER == 1) { $link = 'index.php?option=' . $this->option . '&view=stockroom_detail&task=edit&cid[]=' . $stockroom_id; } ?> window.parent.document.location = '<?php echo $link; ?> '; </script> <?php exit; } if ($apply == 2) { $this->setRedirect('index.php?option=' . $this->option . '&view=product_detail&task=add', $msg); } elseif ($apply == 1) { $this->setRedirect('index.php?option=' . $this->option . '&view=product_detail&task=edit&cid[]=' . $row->product_id, $msg); } else { $this->setRedirect('index.php?option=' . $this->option . '&view=product', $msg); } } else { $row->product_id = $post['product_id']; $msg = $model->getError(); $this->app->enqueueMessage($msg, 'error'); $this->input->set('view', 'product_detail'); $this->input->set('layout', 'default'); $this->input->set('hidemainmenu', 1); parent::display(); } }