/** * Save the faq * * @access public * @return string */ public function save_faq() { $this->load->helper('html_output'); //search engine friendly urls $formatted_urls = array(); $urls = $this->input->post('faqs_url'); $faqs_question = $this->input->post('faqs_question'); if (is_array($urls) && count($urls) > 0) { foreach ($urls as $languages_id => $url) { $url = format_friendly_url($url); if (empty($url)) { $url = $faqs_question[$languages_id]; } $formatted_urls[$languages_id] = $url; } } $data = array('faqs_question' => $this->input->post('faqs_question'), 'faqs_url' => $formatted_urls, 'faqs_answer' => $this->input->post('faqs_answer'), 'faqs_order' => $this->input->post('faqs_order'), 'faqs_status' => $this->input->post('faqs_status')); if ($this->faqs_model->save($this->input->post('faqs_id'), $data)) { $response = array('success' => TRUE, 'feedback' => lang('ms_success_action_performed')); } else { $response = array('success' => FALSE, 'feedback' => lang('ms_error_action_not_performed')); } $this->output->set_output(json_encode($response)); }
/** * Save a category * * @access public * @return string */ public function save_category() { $this->load->helper('html_output'); $parent_id = $this->input->post('parent_category_id'); $flag = $this->input->post('product_flag'); $categories_id = $this->input->post('categories_id'); $categories_name = $this->input->post('categories_name'); $parent_id = !empty($parent_id) ? end(explode('_', $parent_id)) : 0; $flag = !empty($flag) ? $flag : 0; $categories_id = !empty($categories_id) && is_numeric($categories_id) ? $categories_id : NULL; //search engine friendly urls $formatted_urls = array(); $urls = $this->input->post('categories_url'); if (is_array($urls) && !empty($urls)) { foreach ($urls as $languages_id => $url) { $url = format_friendly_url($url); if (empty($url)) { $url = format_friendly_url($categories_name[$languages_id]); } $formatted_urls[$languages_id] = $url; } } $data = array('parent_id' => $parent_id, 'sort_order' => $this->input->post('sort_order'), 'image' => 'image', 'categories_status' => $this->input->post('categories_status'), 'name' => $this->input->post('categories_name'), 'url' => $formatted_urls, 'page_title' => $this->input->post('page_title'), 'meta_keywords' => $this->input->post('meta_keywords'), 'meta_description' => $this->input->post('meta_description'), 'flag' => $flag); $category_id = $this->categories_model->save($categories_id, $data); if ($category_id > 0) { $response = array('success' => TRUE, 'feedback' => lang('ms_success_action_performed'), 'categories_id' => $category_id, 'text' => $categories_name[lang_id()]); } else { $response = array('success' => FALSE, 'feedback' => lang('ms_error_action_not_performed')); } $this->output->set_header("Content-Type: text/html")->set_output(json_encode($response)); }
public function save_product() { $this->load->helper('html_output'); $this->load->helper('file'); $image_path = ROOTPATH . 'images/products/_upload/' . $this->session->userdata('session_id') . '/'; $config = array('directory' => $image_path, 'stats' => true); $this->load->library('directory_listing', $config); $this->directory_listing->setIncludeDirectories('false'); //search engine friendly urls $formatted_urls = array(); $urls = $this->input->post('products_friendly_url'); if (is_array($urls) && !empty($urls)) { foreach ($urls as $languages_id => $url) { $url = format_friendly_url($url); if (empty($url)) { $products_name = $this->input->post('products_name'); $url = format_friendly_url($products_name[$languages_id]); } $formatted_urls[$languages_id] = $url; } } $products_quantity = $this->input->post('products_quantity'); $products_max_order_quantity = $this->input->post('products_max_order_quantity'); $data = array('products_type' => $this->input->post('products_type'), 'quantity' => !empty($products_quantity) ? $products_quantity : 0, 'products_moq' => $this->input->post('products_moq'), 'products_max_order_quantity' => !empty($products_max_order_quantity) ? $products_max_order_quantity : -1, 'order_increment' => $this->input->post('order_increment'), 'quantity_unit_class' => $this->input->post('quantity_unit_class'), 'price' => $this->input->post('products_price'), 'weight' => $this->input->post('products_weight'), 'quantity_discount_groups_id' => $this->input->post('quantity_discount_groups_id'), 'weight_class' => $this->input->post('products_weight_class'), 'status' => $this->input->post('products_status'), 'tax_class_id' => $this->input->post('products_tax_class_id'), 'manufacturers_id' => $this->input->post('manufacturers_id'), 'date_available' => $this->input->post('products_date_available'), 'products_name' => $this->input->post('products_name'), 'products_short_description' => $this->input->post('products_short_description'), 'products_description' => $this->input->post('products_description'), 'products_sku' => $this->input->post('products_sku'), 'products_model' => $this->input->post('products_model'), 'products_tags' => $this->input->post('products_tags'), 'products_url' => $this->input->post('products_url'), 'products_friendly_url' => $formatted_urls, 'products_page_title' => $this->input->post('products_page_title'), 'products_meta_keywords' => $this->input->post('products_meta_keywords'), 'products_meta_description' => $this->input->post('products_meta_description'), 'products_attributes_groups_id' => $this->input->post('products_attributes_groups_id')); $xsell_ids = $this->input->post('xsell_ids'); if (!empty($xsell_ids)) { $xsell_ids = explode(';', $xsell_ids); $data['xsell_id_array'] = $xsell_ids; } $categories_id = $this->input->post('categories_id'); if (!empty($categories_id)) { $data['categories'] = explode(',', $categories_id); } $accessories_ids = $this->input->post('accessories_ids'); if (!empty($accessories_ids)) { $accessories_ids = explode(';', $accessories_ids); $data['accessories_ids'] = $accessories_ids; } $localimages = $this->input->post('localimages'); if (!empty($localimages)) { $localimages = explode(',', $localimages); $data['localimages'] = $localimages; } $products_variants = $this->input->post('products_variants'); if ($data['products_type'] != PRODUCT_TYPE_GIFT_CERTIFICATE && !empty($products_variants)) { $products_variants = explode(';', $products_variants); $data['variants'] = $products_variants; $data['variants_quantity'] = array(); $data['variants_status'] = array(); $data['variants_price'] = array(); $data['variants_sku'] = array(); $data['variants_model'] = array(); $data['variants_weight'] = array(); $data['variants_change'] = array(); foreach ($products_variants as $variant) { $variants = explode(':', $variant); $varaints_quantity = $this->input->post('variants_quantity'); $variants_net_price = $this->input->post('variants_net_price'); $variants_sku = $this->input->post('variants_sku'); $variants_model = $this->input->post('variants_model'); $variants_weight = $this->input->post('variants_weight'); $variants_status = $this->input->post('variants_status_' . $variants[0]); $data['products_variants_id'][$variants[0]] = $variants[1]; $data['variants_default'][$variants[0]] = $variants[2]; $data['variants_quantity'][$variants[0]] = $varaints_quantity[$variants[0]]; $data['variants_price'][$variants[0]] = $variants_net_price[$variants[0]]; $data['variants_sku'][$variants[0]] = $variants_sku[$variants[0]]; $data['variants_model'][$variants[0]] = $variants_model[$variants[0]]; $data['variants_weight'][$variants[0]] = $variants_weight[$variants[0]]; $data['variants_status'][$variants[0]] = $variants_status; $variants_image = $this->input->post('variants_image_' . $variants[0]); $data['variants_image'][$variants[0]] = !empty($variants_image) ? $variants_image : null; } } //search engine friendly urls $return_urls = array(); if (is_array($formatted_urls) && !empty($formatted_urls)) { foreach ($formatted_urls as $languages_id => $url) { $return_urls[] = array('languages_id' => $languages_id, 'url' => $url); } } $pid = $this->input->post('products_id'); $pid = !empty($pid) && (is_numeric($pid) && $pid != '-1') ? $pid : null; $products_id = $this->products_model->save($pid, $data); if ($products_id) { $response = array('success' => true, 'feedback' => lang('ms_success_action_performed'), 'productsId' => $products_id, 'urls' => $return_urls); } else { $response = array('success' => false, 'feedback' => lang('ms_error_action_not_performed')); } $this->output->set_header('Content-Type: text/html')->set_output(json_encode($response)); return NULL; }
/** * Save the manufacturer * * @access public * @return string */ public function save_manufacturer() { $this->load->helper('html_output'); //search engine friendly urls $formatted_urls = array(); $urls = $this->input->post('manufacturers_friendly_url'); if (is_array($urls) && count($urls) > 0) { foreach ($urls as $languages_id => $url) { $url = format_friendly_url($url); //if the friendly url is empty, set it with the manufacturer's name if (empty($url)) { $url = format_friendly_url($this->input->post('manufacturers_name')); } $formatted_urls[$languages_id] = $url; } } $data = array('name' => $this->input->post('manufacturers_name'), 'image' => 'manufacturers_image', 'friendly_url' => $formatted_urls, 'url' => $this->input->post('manufacturers_url'), 'page_title' => $this->input->post('page_title'), 'meta_keywords' => $this->input->post('meta_keywords'), 'meta_description' => $this->input->post('meta_description')); if ($this->manufacturers_model->save($this->input->post('manufacturers_id'), $data)) { $response = array('success' => TRUE, 'feedback' => lang('ms_success_action_performed')); } else { $response = array('success' => FALSE, 'feedback' => lang('ms_error_action_not_performed')); } $this->output->set_output(json_encode($response)); }
/** * Save an article * * @access public * @return string */ public function save_article() { $this->load->helper('html_output'); //search engine friendly urls $formatted_urls = array(); $urls = $this->input->post('articles_url'); $article_name = $this->input->post('articles_name'); if (is_array($urls) && count($urls) > 0) { foreach ($urls as $languages_id => $url) { $url = format_friendly_url($url); if (empty($url)) { $article_name = $this->input->post('articles_name'); $url = format_friendly_url($article_name[$languages_id]); } $formatted_urls[$languages_id] = $url; } } $data = array('articles_name' => $this->input->post('articles_name'), 'articles_url' => $formatted_urls, 'articles_image' => 'articles_image', 'articles_description' => $this->input->post('articles_description'), 'articles_order' => $this->input->post('articles_order'), 'articles_status' => $this->input->post('articles_status'), 'delimage' => $this->input->post('delimage') == 'on' ? 1 : 0, 'articles_categories' => $this->input->post('articles_categories_id') ? $this->input->post('articles_categories_id') : '1', 'page_title' => $this->input->post('page_title'), 'meta_keywords' => $this->input->post('meta_keywords'), 'meta_description' => $this->input->post('meta_description')); if ($this->articles_model->save($this->input->post('articles_id') != -1 ? $this->input->post('articles_id') : NULL, $data)) { $response = array('success' => TRUE, 'feedback' => lang('ms_success_action_performed')); } else { $response = array('success' => FALSE, 'feedback' => lang('ms_error_action_not_performed')); } $this->output->set_header('Content-Type: text/html')->set_output(json_encode($response)); }