olshop/application/controllers/Product.php
2020-01-02 23:12:35 +07:00

100 lines
2.7 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Product extends CI_Controller {
function __Construct()
{
parent ::__construct();
$this->load->library('Pagination');
$this->load->model('Barang');
$this->load->model('Kategori');
}
public function index($kate = '')
{
if (empty($kate)){
//ambil data kategori
//ambil data semua barang
//pagination
//$hd['title'] = "Toko Dzaky Mulya";
//$data['active'] = "Produk";
//$data['barang'] = $this->Barang->barang_all();
//$data['kategori'] = $this->Kategori->kategori_all();
//$this->load->view('front/header',$hd);
//$this->load->view('front/shopstep');
//$this->load->view('front/produk',$data);
//$this->load->view('front/footer');
$this->paging();
}
else{
echo $kate;
$this->paging($kate);
}
}
public function paging($kat="")
{
$barang = $this->Barang->barang_all();
$config['base_url'] = base_url()."index.php/product/paging";
$config['total_rows'] = count($barang);
$config['per_page'] = "6";
$config["uri_segment"] = 3;
$choice = $config["total_rows"] / $config["per_page"];
$config["num_links"] = floor($choice);
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['barang'] = $this->Barang->barang_all2($config["per_page"],$data['page']);
$hd['title'] = "Toko Dzaky Mulya";
$data['active'] = "Produk";
$data['kategori'] = $this->Kategori->kategori_all();
$data['pagination'] = $this->pagination->create_links();
$this->load->view('front/header',$hd);
$this->load->view('front/shopstep');
$this->load->view('front/produk',$data);
$this->load->view('front/footer');
}
public function top_prodct(){
//ambil data produk dengan sales paling banyak
//buat
}
public function new_prodct(){
//ambil data produk dengan sales paling banyak
//buat
}
public function kategori($kat){
//ambil data dengan kategori tertentu
$w = array(
'kategori' => $kat
);
$data = $this->barang->barang_cust($w);
//tampilkan
//pagination
}
}