public function importeconomic() { // Add product to economic $cnt = JRequest::getInt('cnt', 0); $totalprd = 0; $msg = ''; if (ECONOMIC_INTEGRATION == 1) { $economic = new economic(); $db = JFactory::getDbo(); $incNo = $cnt; $query = 'SELECT p.* FROM #__redshop_product AS p ' . 'LIMIT ' . $cnt . ', 10 '; $db->setQuery($query); $prd = $db->loadObjectlist(); $totalprd = count($prd); $responcemsg = ''; for ($i = 0; $i < count($prd); $i++) { $incNo++; $ecoProductNumber = $economic->createProductInEconomic($prd[$i]); $responcemsg .= "<div>" . $incNo . ": " . JText::_('COM_REDSHOP_PRODUCT_NUMBER') . " " . $prd[$i]->product_number . " -> "; if (count($ecoProductNumber) > 0 && is_object($ecoProductNumber[0]) && isset($ecoProductNumber[0]->Number)) { $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_IMPORT_PRODUCTS_TO_ECONOMIC_SUCCESS') . "</span>"; } else { $errmsg = JText::_('COM_REDSHOP_ERROR_IN_IMPORT_PRODUCT_TO_ECONOMIC'); if (JError::isError(JError::getError())) { $error = JError::getError(); $errmsg = $error->message; } $responcemsg .= "<span style='color: #ff0000'>" . $errmsg . "</span>"; } $responcemsg .= "</div>"; } if ($totalprd > 0) { $msg = $responcemsg; } else { $msg = JText::_("COM_REDSHOP_IMPORT_PRODUCT_TO_ECONOMIC_IS_COMPLETED"); } } echo "<div id='sentresponse'>" . $totalprd . "`_`" . $msg . "</div>"; die; }
public function store($data) { $row =& $this->getTable(); if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } $giftcardfile = JRequest::getVar('giftcard_image', '', 'files', 'array'); $giftcardimg = ""; if ($giftcardfile['name'] != "") { $giftcardfile['name'] = str_replace(" ", "_", $giftcardfile['name']); $giftcardimg = JPath::clean(time() . '_' . $giftcardfile['name']); $src = $giftcardfile['tmp_name']; $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'giftcard/' . $giftcardimg; $row->giftcard_image = $giftcardimg; JFile::upload($src, $dest); } $giftcardbgfile = JRequest::getVar('giftcard_bgimage', '', 'files', 'array'); $giftcardbgimg = ""; if ($giftcardbgfile['name'] != "") { $giftcardbgfile['name'] = str_replace(" ", "_", $giftcardbgfile['name']); $giftcardbgimg = JPath::clean(time() . '_' . $giftcardbgfile['name']); $src = $giftcardbgfile['tmp_name']; $dest = REDSHOP_FRONT_IMAGES_RELPATH . 'giftcard/' . $giftcardbgimg; $row->giftcard_bgimage = $giftcardbgimg; JFile::upload($src, $dest); } if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } if (ECONOMIC_INTEGRATION == 1) { $economic = new economic(); $giftdata = new stdClass(); $giftdata->product_id = $row->giftcard_id; $giftdata->product_number = "gift_" . $row->giftcard_id . "_" . $row->giftcard_name; $giftdata->product_name = $row->giftcard_name; $giftdata->product_price = $row->giftcard_price; $giftdata->accountgroup_id = $row->accountgroup_id; $giftdata->product_volume = 0; $ecoProductNumber = $economic->createProductInEconomic($giftdata); } 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(); } }