Are you a regular stikked user? Signup so you can keep track of your pastes!
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3.  * Product class
  4.  *
  5.  * @package default
  6.  * @author Ibnu Daqiqil Id
  7.  **/
  8.  
  9. class Product extends Shop_Controller
  10. {
  11.  
  12.         function __construct()
  13.         {
  14.                 parent::__construct();
  15.                 $this->load->model('product_model','product');
  16.         }
  17.        
  18.         /**
  19.          * Index function
  20.          *
  21.          * @return void
  22.          * @author Ibnu Daqiqil Id
  23.          **/   
  24.         function index()
  25.         {
  26.                 $this->browse();
  27.         }
  28.         function browse()
  29.         {
  30.                 $input_param =array('sortField','sortOrder','start','keyword','letter');
  31.                 $sort_field = array('code','name','price','featured','status');
  32.                 $sort_order = array('asc','desc');
  33.                
  34.                 $paging_uri=4;
  35.                 if ($this->uri->segment($paging_uri))
  36.                         $start=$this->uri->segment($paging_uri);
  37.                 else
  38.                         $start=0 ;
  39.                 $limit_per_page = 20;
  40.                 $filter ['name'] = $this->uri->asegment('sortOrder');
  41.                
  42.                 if (in_array($this->uri->asegment('sortField'),$sort_field))
  43.                 {
  44.                         if (in_array($this->uri->asegment('sortOrder'),$sort_order))
  45.                         {
  46.                                 $str_order = $this->uri->asegment('sortField').' '.$this->uri->asegment('sortOrder');
  47.                         }
  48.                         else
  49.                         {
  50.                                 $str_order = $this->uri->asegment('sortField').' ASC';
  51.                         }
  52.                 }
  53.                 else
  54.                 {
  55.                         $str_order = 'name asc';
  56.                 }
  57.                
  58.                 $data['products'] = $this->product->get_product(  array('product.shop_id'=>$this->shopid),$this->uri->asegment('keyword'),$this->uri->asegment('letter'),
  59.                                                                                                         "product.*, product_category.title as category, product_image.image",
  60.                                                                                                         $str_order,
  61.                                                                                                         $start,
  62.                                                                                                         $limit_per_page
  63.                                                                                                         );
  64.  
  65.                
  66.  
  67.        
  68.                 $data['title'] = "";
  69.                 $this->load->library('pagination');
  70.                 $this->load->helper('text');
  71.                 $config['base_url']     = site_url('manage/product/browse/');
  72.                 $config['total_rows']   = $this->product->find_count(array('shop_id'=>$this->shop_id));
  73.                 $config['per_page']     = $limit_per_page;
  74.                 $config['uri_segment']  = $paging_uri;
  75.        
  76.                 $this->pagination->initialize($config);
  77.  
  78.                 $data['page_links'] = $this->pagination->create_links();
  79.                 $data['product_status'] = array(1 => 'Available',
  80.                                                                 2 => 'On Request',
  81.                                                                 10 => 'Not Available');
  82.                 $data['title'] = 'Product management';
  83.                 $this->template->display('manage/product/list', $data);
  84.                
  85.         }
  86.         function test()
  87.         {
  88.                 $arr = array(
  89.                         'title' => 'Damien',
  90.                         'url' => 'aaa'
  91.                     );
  92.                 $uri = $this->uri->assoc_to_alt_uri($arr, 'controller/add');
  93.        
  94.                 $title = $this->uri->asegment('test');
  95.                 $url = $this->uri->asegment('url');
  96.                 echo $uri;
  97.         }
  98.         function save_order()
  99.         {
  100.                 $data = $this->input->post('listItem');
  101.                 //echo var_dump($data);
  102.                 $i=1;
  103.                 foreach ($data as $menu)
  104.                 {
  105.                         $this->db->where('id',$menu);
  106.                         $this->db->update('product',array('sort'=>$i));
  107.                         $i++;
  108.                 }
  109.         }
  110.        
  111.         function add()
  112.         {
  113.                 $data['title'] = 'Add New Product';
  114.                
  115.                
  116.                 $this->template->display('manage/product/add',$data);
  117.         }
  118.  
  119. }
  120.  
  121. // END  Product class
  122.  
  123. /* End of file product.php */
  124. /* Location: /Applications/XAMPP/xamppfiles/htdocs/multishop/application/controllers/manage/product.php  */

Reply to "product.php"

Here you can reply to the paste above

Create a snipurl

Make Private

Feeling clever? Set some advanced options.