<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Product class
*
* @package default
* @author Ibnu Daqiqil Id
**/
class Product extends Shop_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('product_model','product');
}
/**
* Index function
*
* @return void
* @author Ibnu Daqiqil Id
**/
function index()
{
$this->browse();
}
function browse()
{
$input_param =array('sortField','sortOrder','start','keyword','letter');
$sort_field = array('code','name','price','featured','status');
$sort_order = array('asc','desc');
$paging_uri=4;
if ($this->uri->segment($paging_uri))
$start=$this->uri->segment($paging_uri);
else
$start=0 ;
$limit_per_page = 20;
$filter ['name'] = $this->uri->asegment('sortOrder');
if (in_array($this->uri->asegment('sortField'),$sort_field))
{
if (in_array($this->uri->asegment('sortOrder'),$sort_order))
{
$str_order = $this->uri->asegment('sortField').' '.$this->uri->asegment('sortOrder');
}
else
{
$str_order = $this->uri->asegment('sortField').' ASC';
}
}
else
{
$str_order = 'name asc';
}
$data['products'] = $this->product->get_product( array('product.shop_id'=>$this->shopid),$this->uri->asegment('keyword'),$this->uri->asegment('letter'),
"product.*, product_category.title as category, product_image.image",
$str_order,
$start,
$limit_per_page
);
$data['title'] = "";
$this->load->library('pagination');
$this->load->helper('text');
$config['base_url'] = site_url('manage/product/browse/');
$config['total_rows'] = $this->product->find_count(array('shop_id'=>$this->shop_id));
$config['per_page'] = $limit_per_page;
$config['uri_segment'] = $paging_uri;
$this->pagination->initialize($config);
$data['page_links'] = $this->pagination->create_links();
$data['product_status'] = array(1 => 'Available',
2 => 'On Request',
10 => 'Not Available');
$data['title'] = 'Product management';
$this->template->display('manage/product/list', $data);
}
function test()
{
$arr = array(
'title' => 'Damien',
'url' => 'aaa'
);
$uri = $this->uri->assoc_to_alt_uri($arr, 'controller/add');
$title = $this->uri->asegment('test');
$url = $this->uri->asegment('url');
echo $uri;
}
function save_order()
{
$data = $this->input->post('listItem');
//echo var_dump($data);
$i=1;
foreach ($data as $menu)
{
$this->db->where('id',$menu);
$this->db->update('product',array('sort'=>$i));
$i++;
}
}
function add()
{
$data['title'] = 'Add New Product';
$this->template->display('manage/product/add',$data);
}
}
// END Product class
/* End of file product.php */
/* Location: /Applications/XAMPP/xamppfiles/htdocs/multishop/application/controllers/manage/product.php */