Backups Created:
/home/japatmex/public_html/wp-content/edit-wolf.php
Savvy
W
olf -
MANAGER
Edit File: Products.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Products extends MY_Controller { public function __construct(){ parent::__construct(); $this->load->model('Ecomm_model'); $this->load->helper('ecomm_helper'); } public function index($page = 1){ $this->data['page_title'] = 'Products'; $this->data['current_page'] = 'Products'; $category_id = (int)0; if($this->input->get('category_id')) { $category_id = $this->input->get('category_id'); } $row=$this->Ecomm_model->product_list('id','','','','',$category_id); $config = array(); $config["base_url"] = base_url($this->config->item('apanel_name').'/ecomm/products'); $config["total_rows"] = count($row); $config["per_page"] = 12; $config['num_links'] = 2; $config['use_page_numbers'] = TRUE; $config['reuse_query_string'] = TRUE; $config['enable_query_strings'] = TRUE; $config['page_query_string'] = FALSE; $config['full_tag_open'] = '<ul class="pagination">'; $config['full_tag_close'] = '</ul>'; $config['first_link'] = '<i class="fa fa-angle-double-left"></i>'; $config['first_tag_open'] = '<li>'; $config['first_tag_close'] = '</li>'; $config['last_link'] = '<i class="fa fa-angle-double-right"></i>'; $config['last_tag_open'] = '<li>'; $config['last_tag_close'] = '</li>'; $config['next_link'] = ''; $config['next_tag_open'] = '<span class="nextlink">'; $config['next_tag_close'] = '</span>'; $config['prev_link'] = ''; $config['prev_tag_open'] = '<span class="prevlink">'; $config['prev_tag_close'] = '</span>'; $config['cur_tag_open'] = '<li class="active"><a href="#">'; $config['cur_tag_close'] = '<span class="sr-only">(current)</span></a></li>'; $config['num_tag_open'] = '<li style="margin:3px">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $page=($page-1) * $config["per_page"]; if($this->input->post('search_value')!=''){ $keyword=addslashes(trim($this->input->post('search_value'))); $row=$this->Ecomm_model->product_list('id','DESC', '', '', $keyword, $category_id); } else{ $this->data["links"] = $this->pagination->create_links(); $row=$this->Ecomm_model->product_list('id','DESC', $config["per_page"], $page, '', $category_id); } $this->data['products'] = $row; $this->data['categories_dropdown'] = category_dropdown(); $this->data['view'] = 'admin/ecomm/products'; $this->load->view('admin/layouts/default1', $this->data); } public function relatedProduct(){ $message = ''; $this->data['sc'] = $type = $sc = $this->input->post_get('sc') ?: 0; $this->data['cldFrm'] = $cldFrm = $this->input->post_get('cldFrm') ?: 0; $this->data['fTypeId'] = $fTypeId = $this->input->post_get('fTypeId') ?: 0; $categoryId = $this->input->post_get('categoryId') ?: 0; if($this->input->post_get('btnSubmit')) { $relatedProductIds = $this->input->post('chkPacks'); $product_id = $this->input->get('product-id'); $this->db->where('ProductId',$product_id)->delete('tbl_gf_ecomm_related_products'); foreach($relatedProductIds as $relatedProductId){ $PostedData[] = array( 'RelatedProdId' => $relatedProductId, 'ProductId' => $product_id ); } $this->db->insert_batch('tbl_gf_ecomm_related_products', $PostedData); } $tblName = 'tbl_gf_ecomm_category'; $heading = 'Related Product'; $tblPivotName = 'tbl_gf_ecomm_product_categories'; $this->data['message'] = $message; $this->data['heading'] = $heading ; $this->data['tblName'] = $tblName; $this->data['categoryId'] = $categoryId; //$product_ids = $this->Ecomm_model->fetch_category_product($categoryId,$tblPivotName); $product_ids = $this->db->where('category_id', $categoryId)->get('tbl_gf_ecomm_product')->result(); foreach($product_ids as $id){ $p_ids[] = $id->id; } if($p_ids){ $this->data['rsPacks'] = $this->Ecomm_model->fetch_ecomm_product_list('id','DESC', $tblPivotName, $p_ids, $categoryId); } if($categoryId == 0){ $this->data['rsPacks'] = $this->Ecomm_model->fetch_ecomm_product_list('id','DESC', $tblPivotName, $p_ids, $categoryId); } $this->data['relatedPrducts'] = $this->Ecomm_model->fetch_ecomm_product_list('id','DESC', $tblPivotName, $p_ids, $categoryId); $this->data['count'] = count($this->data['rsPacks']); $this->data['sc'] = $sc ; $this->data['view'] = 'admin/ecomm/related_product_form' ; $this->load->view('admin/layouts/default1' , $this->data); } public function add() { $THEME = $this->data['rsStngs']->Theme; if($this->input->method() == 'post') { $data = $this->input->post(); if(!empty($data['is_duplicate']) && $data['is_duplicate'] == 1) { $redirect_back_url = base_url($this->config->item('apanel_name').'/ecomm/products/duplicate_product/'.$data['product_slug']).get_query_string(); }else{ $redirect_back_url = base_url($this->config->item('apanel_name').'/ecomm/products/add').get_query_string(); } $this->form_validation->set_rules('category_id', 'Select Category', 'required'); $this->form_validation->set_rules('title', 'Enter Product Title', 'trim|required'); $this->form_validation->set_rules('product_desc', 'Enter Product Description', 'trim|required'); $this->form_validation->set_rules('product_sku', 'Enter Product SKU.', 'trim|required'); $this->form_validation->set_rules('product_mrp', 'Enter Product MRP.', 'trim|required'); if($this->form_validation->run()) { $config['upload_path'] = FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'; $config['allowed_types'] = 'jpg|png|jpeg|gif'; $image1 = date('dmYhis').'_'.rand(0,99999).".".pathinfo($_FILES['file_name']['name'], PATHINFO_EXTENSION); $config['file_name'] = $image1; $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect($redirect_back_url); } else { $upload_data = $this->upload->data(); } $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name2')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect($redirect_back_url); } else { $upload_data = $this->upload->data(); $image2=$upload_data['file_name']; } if($_FILES['size_chart']['error']!=4){ if (!$this->upload->do_upload('size_chart')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect($redirect_back_url); } else { $upload_data = $this->upload->data(); $size_chart=$upload_data['file_name']; } } else{ $size_chart=''; } $this->load->helper("date"); $color=$this->input->post('product_color').'/'.$this->input->post('color_code'); $other_color_product=''; if($this->input->post('other_color_product')!=''){ $other_color_product=implode(',', $this->input->post('other_color_product')); } $slug = url_title($this->input->post('title'), 'dash', TRUE); $maximumSortOrder = $this->Ecomm_model->getMaximumSortValue(); $maximumSortOrder = $maximumSortOrder ?: 0; $selling_price = $this->input->post('selling_price') ? $this->input->post('selling_price') : $this->input->post('product_mrp'); $selling_price = $selling_price - $this->input->post('you_save'); $data = array( 'category_id' => $this->input->post('category_id'), 'sub_category_id' => $this->input->post('sub_cat_id'), 'brand_id' => $this->input->post('brand_id'), 'offer_id' => $this->input->post('offer_id'), 'product_title' => $this->input->post('title'), 'product_slug' => $slug, 'product_desc' => strip_tags($this->input->post('product_desc')), 'product_features' => addslashes($this->input->post('product_features_desc')), 'featured_image' => $image1, 'featured_image2' => $image2, 'size_chart' => $size_chart, 'product_sku' => $this->input->post('product_sku'), 'product_mrp' => $this->input->post('product_mrp'), 'selling_price' => $selling_price, 'you_save_amt' => $this->input->post('you_save') ? $this->input->post('you_save') : '0', 'you_save_per' => $this->input->post('you_save_per') ? $this->input->post('you_save_per') : '0', 'other_color_product' => $other_color_product, 'color' => $color, 'product_size' => $this->input->post('product_size'), 'product_quantity' => $this->input->post('product_quantity'), 'quantity' => $this->input->post('quantity'), 'original_qty' => $this->input->post('quantity'), 'low_quantity' => $this->input->post('low_quantity'), 'max_unit_buy' => $this->input->post('max_unit_buy'), 'delivery_charge' => $this->input->post('delivery_charge'), 'is_featured' => isset($_REQUEST['is_featured']) ? 1 : 0, 'new_arrival' => isset($_REQUEST['new_arrival']) ? 1 : 0, 'created_at' => strtotime(date('d-m-Y h:i:s A',now())), 'status' => (int) 0, 'sort_order' => (int)($maximumSortOrder+1) ); $data = $this->security->xss_clean($data); $last_id=$this->Ecomm_model->insert($data, 'tbl_gf_ecomm_product'); $this->active($last_id,true); if($last_id){ $files = $_FILES; $cpt = count($_FILES['product_images']['name']); for($i=0; $i<$cpt; $i++) { $_FILES['product_images']['name']= $files['product_images']['name'][$i]; $_FILES['product_images']['type']= $files['product_images']['type'][$i]; $_FILES['product_images']['tmp_name']= $files['product_images']['tmp_name'][$i]; $_FILES['product_images']['error']= $files['product_images']['error'][$i]; $_FILES['product_images']['size']= $files['product_images']['size'][$i]; // File upload configuration $uploadPath = FCPATH . 'uplds'.$THEME.'/ecomm/images/products/gallery/'; $config['upload_path'] = $uploadPath; $config['allowed_types'] = 'jpg|jpeg|png|gif'; // Load and initialize upload library $this->load->library('upload', $config); $this->upload->initialize($config); // Upload file to server if($this->upload->do_upload('product_images')){ // Uploaded file data $imageData = $this->upload->data(); $imageFile= $imageData['file_name']; $data = array( 'parent_id' => $last_id, 'image_file' => $imageFile, 'type' => 'product' ); $data = $this->security->xss_clean($data); $this->Ecomm_model->insert($data, 'tbl_gf_ecomm_product_images'); } } $messge = array('message' => 'Added successfully...','class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); $redirect_back_url = base_url($this->config->item('apanel_name').'/ecomm/products').get_query_string(); } else{ $messge = array('message' => 'Error in adding data !!','class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); } redirect($redirect_back_url); } else { $messge = array('message' => 'Enter all required fields !!','class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect($redirect_back_url); } } $this->data['page_title'] = 'Products'; $this->data['category_list'] = category_dropdown(); $this->data['brands'] = $this->Ecomm_model->get_brands_list(); $this->data['offer_list'] = $this->Ecomm_model->offers_list(); $this->data['current_page'] = 'Add Product'; $this->data['settings'] = $this->Ecomm_model->get_settings(); $this->data['view'] = 'admin/ecomm/add_product'; $this->load->view('admin/layouts/default1', $this->data); } public function active($id , $internal = false) { $data = array( 'status' => 1 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); if($internal == false){ echo 'Enable successfully...'; } } public function deactive($id,$internal = false) { $data = array( 'status' => 0 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); if($internal == false){ echo 'Disable successfully...'; } } public function edit($id, $category_id) { $THEME = $rowSettings->Theme; if($this->input->method() == 'post') { $data = $this->Ecomm_model->single_product($id,false); $config['upload_path'] = FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'; $config['allowed_types'] = 'jpg|png|jpeg|gif'; if($_FILES['file_name']['error']!=4){ if(file_exists(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'.$data[0]->featured_image)){ unlink(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'.$data[0]->featured_image); $mask = $data[0]->product_slug.'*_*'; array_map('unlink', glob(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/thumbs/'.$mask)); } $image = date('dmYhis').'_'.rand(0,99999).".".pathinfo($_FILES['file_name']['name'], PATHINFO_EXTENSION); $config['file_name'] = $image; $this->load->library('upload', $config); if (!$this->upload->do_upload('file_name')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/products/edit/'.$id.'/'.$category_id).get_query_string()); } } else{ $image=$data[0]->featured_image; } if($_FILES['file_name2']['error']!=4){ if(file_exists(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'.$data[0]->featured_image2)){ unlink(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'.$data[0]->featured_image2); $mask = $data[0]->id.'*_*'; array_map('unlink', glob(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/thumbs/'.$mask)); } $image2 = date('dmYhis').'_'.rand(0,99999)."_2_.".pathinfo($_FILES['file_name2']['name'], PATHINFO_EXTENSION); $config['file_name'] = $image2; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('file_name2')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/products/edit/'.$id.'/'.$category_id).get_query_string()); } } else{ $image2=$data[0]->featured_image2; } if($_FILES['size_chart']['error']!=4){ if(file_exists(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'.$data[0]->size_chart)){ unlink(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/'.$data[0]->size_chart); } $size_chart = date('dmYhis').'_'.rand(0,99999)."_3_.".pathinfo($_FILES['size_chart']['name'], PATHINFO_EXTENSION); $config['file_name'] = $size_chart; $this->load->library('upload', $config); if (!$this->upload->do_upload('size_chart')) { $messge = array('message' => $this->upload->display_errors(),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/products/edit/'.$id.'/'.$category_id).get_query_string()); } } else{ $size_chart=$data[0]->size_chart; } $this->load->helper("date"); $color=$this->input->post('product_color').'/'.$this->input->post('color_code'); $other_color_product=''; if($this->input->post('other_color_product')!=''){ $other_color_product=implode(',', $this->input->post('other_color_product')); } $slug = url_title($this->input->post('title'), 'dash', TRUE); $selling_price = $this->input->post('selling_price') ? $this->input->post('selling_price') : trim($this->input->post('product_mrp')); $selling_price = $selling_price; if($this->input->post('you_save') !== NULL && $this->input->post('you_save') != '') { //$selling_price = $selling_price - $this->input->post('you_save'); } $data = array( 'category_id' => $this->input->post('category_id'), 'sub_category_id' => $this->input->post('sub_cat_id'), 'brand_id' => $this->input->post('brand_id'), 'offer_id' => $this->input->post('offer_id'), 'product_title' => $this->input->post('title'), 'product_slug' => $slug, 'product_desc' => $this->input->post('product_desc'), 'product_features' => $this->input->post('product_features_desc'), 'featured_image' => $image, 'featured_image2' => $image2, 'size_chart' => $size_chart, 'product_sku' => $this->input->post('product_sku'), 'product_mrp' => trim($this->input->post('product_mrp')), 'quantity' => trim($this->input->post('quantity')), 'low_quantity' => trim($this->input->post('low_quantity')), 'selling_price' => $selling_price, 'you_save_amt' => $this->input->post('you_save') ? $this->input->post('you_save') : '0', 'you_save_per' => $this->input->post('you_save_per') ? $this->input->post('you_save_per') : '0', 'other_color_product' => $other_color_product, 'color' => $color, 'product_size' => $this->input->post('product_size'), 'product_quantity' => $this->input->post('product_quantity'), 'is_featured' => isset($_REQUEST['is_featured']) ? 1 : 0, 'new_arrival' => isset($_REQUEST['new_arrival']) ? 1 : 0, 'max_unit_buy' => $this->input->post('max_unit_buy'), 'delivery_charge' => $this->input->post('delivery_charge'), 'status' => $this->input->post('product_status') ); $data = $this->security->xss_clean($data); $last_id=$this->Ecomm_model->update($data, $id, 'tbl_gf_ecomm_product'); if($last_id){ $files = $_FILES; $cpt = count($_FILES['product_images']['name']); if($cpt > 0){ $row_img=$this->Ecomm_model->get_gallery($id); foreach ($row_img as $key1 => $val1) { $mask = $val1->id.'*_*'; array_map('unlink', glob(FCPATH . 'uplds'.$THEME.'/ecomm/images/products/thumbs/'.$mask)); } for($i=0; $i<$cpt; $i++) { $_FILES['product_images']['name']= $files['product_images']['name'][$i]; $_FILES['product_images']['type']= $files['product_images']['type'][$i]; $_FILES['product_images']['tmp_name']= $files['product_images']['tmp_name'][$i]; $_FILES['product_images']['error']= $files['product_images']['error'][$i]; $_FILES['product_images']['size']= $files['product_images']['size'][$i]; // File upload configuration $uploadPath = FCPATH . 'uplds'.$THEME.'/ecomm/images/products/gallery/'; $config['upload_path'] = $uploadPath; $config['allowed_types'] = 'jpg|jpeg|png|gif'; $imageFile = date('dmYhis').'_'.rand(0,99999)."_2_.".pathinfo($files['product_images']['name'][$i], PATHINFO_EXTENSION); $config['file_name'] = $imageFile; // Load and initialize upload library $this->load->library('upload', $config); $this->upload->initialize($config); // Upload file to server if($this->upload->do_upload('product_images')){ $data = array( 'parent_id' => $id, 'image_file' => $imageFile, 'type' => 'product' ); $data = $this->security->xss_clean($data); $this->Ecomm_model->insert($data, 'tbl_gf_ecomm_product_images'); } } } $messge = array('message' => $this->lang->line('update_msg'),'class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); } else{ $messge = array('message' => $this->lang->line('update_error'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); } } $this->data['page_title'] = 'Products'; $this->data['category_list'] = category_dropdown(); $this->data['brands'] = $this->Ecomm_model->get_brands_list(); $this->data['offer_list'] = $this->Ecomm_model->offers_list(); $this->data['product'] = $this->Ecomm_model->single_product($id,false); $this->data['product_info'] = $this->data['product'][0]; $this->data['product_photos'] = $this->Ecomm_model->get_gallery($id); $this->data['current_page'] = 'Edit Product'; $this->data['settings'] = $this->Ecomm_model->get_settings(); $this->data['view'] = 'admin/ecomm/edit_product'; $this->load->view('admin/layouts/default1', $this->data); } public function duplicate_product($product_slug) { $where=array('product_slug' => $product_slug); $id = $this->Ecomm_model->getIdBySlug($where, 'tbl_gf_ecomm_product'); $this->data['page_title'] = 'Products'; $this->data['category_list'] = category_dropdown(); $this->data['brands'] = $this->Ecomm_model->get_brands_list(); $this->data['offer_list'] = $this->Ecomm_model->offers_list(); $this->data['product'] = $this->Ecomm_model->single_product($id,false); $this->data['product_photos'] = $this->Ecomm_model->get_gallery($id); $this->data['current_page'] = 'Duplicate Product'; $this->data['settings'] = $this->Ecomm_model->get_settings(); $this->data['view'] = 'admin/ecomm/duplicate_product'; $this->load->view('admin/layouts/default1', $this->data); } public function inventory() { $this->data['page_title'] = 'Manage Inventory'; $this->data['current_page'] = 'Inventory'; $category_id = ''; $rowCategories = $this->Ecomm_model->category_list('id','DESC'); $this->data['categories'] = $rowCategories; $category_id = $this->input->get('category_id'); $this->data['product_list'] = $this->Ecomm_model->product_list_for_inventory($category_id,'','','','',''); $this->data['category_id'] = $category_id; $this->data['view'] = 'admin/ecomm/inventory'; $this->load->view('admin/layouts/default1', $this->data); } public function inventory_manage() { if($this->input->method() == 'post') { $data = array(); $products = array(); $quantities = array(); $quantity_olds = array(); $low_quantities = array(); $cat_id_hidden = ''; $note = ''; $products = $this->input->post('product_ids'); $variations = $this->input->post('variation_ids'); $variations = $this->input->post('variation_ids'); $quantity_olds = $this->input->post('quantity_old'); $quantities = $this->input->post('quantity'); $low_quantities = $this->input->post('lowQuantity'); $note = $this->input->post('note'); $cat_id_hidden = $this->input->post('cat_id_hidden'); $cat_id_hidden_concat = ($cat_id_hidden ? '?category_id='.$cat_id_hidden : ''); $z = 0; foreach($products as $productSingle){ if($variations[$z]!='') //update variations { $data = array( 'product_id' => $productSingle, 'variation_id'=> $variations[$z], 'quantity' => $quantities[$z] - $quantity_olds[$z], 'note' => $note ); $dataQuantity = array( 'quantity' => $quantities[$z], 'low_quantity' => $low_quantities[$z] ); if($this->data['quantity'] != 0) { $data = $this->security->xss_clean($data); $last_id = $this->Ecomm_model->insert($data, 'tbl_gf_ecomm_inventory_stock_logs'); //update inventory only if the quantity is not zero. } $last_id = $this->Ecomm_model->update($dataQuantity, $variations[$z], 'tbl_gf_ecomm_product_variations'); } else { $data = array( 'product_id' => $productSingle, 'quantity' => $quantities[$z] - $quantity_olds[$z], 'note' => $note ); $dataQuantity = array( 'quantity' => $quantities[$z], 'low_quantity' => $low_quantities[$z] ); if($this->data['quantity'] != 0) { $data = $this->security->xss_clean($data); $last_id = $this->Ecomm_model->insert($data, 'tbl_gf_ecomm_inventory_stock_logs'); //update inventory only if the quantity is not zero. } $last_id = $this->Ecomm_model->update($dataQuantity, $productSingle, 'tbl_gf_ecomm_product'); } $z++; } $messge = array('message' => 'Stock Updated','class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); redirect(base_url($this->config->item('apanel_name').'/ecomm/products/inventory_manage'.get_query_string())); } $this->data['page_title'] = 'Manage Inventory Products'; $this->data['current_page'] = 'Inventory'; $category_id = ''; $rowCategories = $this->Ecomm_model->category_list('id','DESC'); $this->data['categories'] = $rowCategories; $category_id = $this->input->get('category_id'); $this->data['product_list'] = $this->Ecomm_model->product_list_for_inventory($category_id,'','','','',''); $this->data['category_id'] = $category_id; $this->data['view'] = 'admin/ecomm/inventory_manage'; $this->load->view('admin/layouts/default1', $this->data); } public function get_sub_category($id='') { $data = $this->Ecomm_model->get_subcategories($id); $opt=''; foreach ($data as $key => $row) { $opt.='<option value="'.$row->id.'">'.$row->sub_category_name.'</option>'; } echo $opt; } public function get_brands($ids='') { $opt=''; if(!empty($ids)) { $data = $this->Ecomm_model->get_brands($ids); if(!empty($data)){ foreach ($data as $key => $row) { $opt.='<option value="'.$row->id.'">'.$row->brand_name.'</option>'; } echo $opt; exit(); } } $data = $this->Ecomm_model->get_brands_list(); foreach ($data as $key => $row) { $opt.='<option value="'.$row->id.'">'.$row->brand_name.'</option>'; } echo $opt; } public function get_featured($id='') { echo get_category_info($id,'product_features'); } public function calculate_offer($offer_id, $mrp) { echo calculate_offer($offer_id, $mrp); } public function get_color_products(){ $response=array(); $cat_id=$this->input->post('cat_id'); $brand_id=$this->input->post('brand_id'); $features=explode(',', get_category_info($cat_id,'product_features')); if(in_array('color', $features)){ if($this->input->post('curr_id')!=0) $ids=array('category_id'=>$cat_id, 'brand_id'=>$brand_id, 'id !='=>$this->input->post('curr_id')); else $ids=array('category_id'=>$cat_id, 'brand_id'=>$brand_id); $opt=''; if($row=$this->Ecomm_model->selectByids($ids, 'tbl_gf_ecomm_product')){ foreach ($row as $key => $value) { $opt.='<option value="'.$value->id.'">'.$value->product_title.'</option>'; } $response['status']=1; } else{ $response['status']=0; } $response['data']=$opt; } else{ $response['status']=0; } echo json_encode($response); } public function remove($id) { echo $this->Ecomm_model->remove_img($id); } public function newarrivalDeactive($id) { $data = array( 'new_arrival' => 0 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); echo 'New Arrival Disabled'; } public function newarrivalActive($id) { $data = array( 'new_arrival' => 1 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); echo 'New Arrival Enabled'; } public function showHomeDeactive($id) { $data = array( 'is_home' => 0 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); echo 'Removed From Home Page'; } public function showHomeActive($id) { $data = array( 'is_home' => 1 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); echo 'Show At Home Page'; } public function is_featured_deactive($id) { $data = array( 'is_featured' => 0 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); echo 'Removed From Featured'; } public function is_featured_active($id) { $data = array( 'is_featured' => 1 ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); echo 'Marked As Featured'; } public function check_sku(){ $sku = $this->input->post('sku'); $result = $this->Ecomm_model->check_sku($sku); $arr_result['status'] = $result; echo json_encode($arr_result); } public function delete($id) { echo $this->Ecomm_model->deleteProduct($id); } public function active_today($id) { $this->load->helper("date"); $data = array( 'today_deal' => 1, 'today_deal_date' => strtotime(date('d-m-Y',now())) ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); $messge = array('message' => $this->lang->line('today_enable_msg'),'class' => 'alert alert-success'); $this->session->set_flashdata('response_msg', $messge); } public function deactive_today($id,$direct=false) { $data = array( 'today_deal' => 0, 'today_deal_date' => 0, ); $data = $this->security->xss_clean($data); $this->Ecomm_model->update($data, $id,'tbl_gf_ecomm_product'); if(!$direct){ $messge = array('message' => $this->lang->line('today_disable_msg'),'class' => 'alert alert-danger'); $this->session->set_flashdata('response_msg', $messge); } } public function products_sellings() { $rowCategories = $this->Ecomm_model->category_list('id','DESC'); $this->data['page_title'] = 'Products Sale Report'; $this->data['current_page'] = 'Products Selling'; $this->data['categories'] = $rowCategories; $this->data['products'] = array(); $type_id = $this->input->get('type_id'); $category_id = $this->input->get('category_id'); $product_id = $this->input->get('product_id'); $start_date = $this->input->get('start_date'); $end_date = $this->input->get('end_date'); $this->data['product_id '] = $product_id; $this->data['category_id'] = $category_id; $this->data['type_id'] = $type_id; $this->data['start_date'] = $start_date; $this->data['end_date'] = $end_date; if($category_id){ $this->data['products'] = $this->Ecomm_model->product_filter($category_id,$product_id,$type_id,$start_date,$end_date); } $this->data['view'] = 'admin/ecomm/products_sellings'; $this->load->view('admin/layouts/default1', $this->data); } public function getCategoryProducts() { $html = ''; $category_id=$this->input->post('category_id'); if($category_id){ $products = $this->Ecomm_model->product_list_for_category($category_id); if($products){ $html .= '<option value="">Select product</option>'; foreach($products AS $singleProduct) { $selected = ''; $html.= '<option '.$selected.' value="'.$singleProduct->id.'">'.$singleProduct->product_title.'</option>'; } }else{ $html .= '<option value="">Not found any product</option>'; } }else{ $html .= '<option value="">Please select any category</option>'; } echo $html; } }