Membuat Toko Online Dengan Codeigniter

Membuat Toko Online Dengan Codeigniter




Project yang sudah jadi
https://drive.google.com/open?id=1QIanPyrunRCGCpvtrSX-s5yjmKmxtEKJ

Vidio dari 20 - 35
https://www.youtube.com/watch?v=r2ONZZrYk8c&list=PLce3Eyp7oY9_5lzhkUtrV6ygriYcttMlg

Template sb Admin2
https://drive.google.com/open?id=1y8xse40zYCjfclkQJym2GJ7js77S0zH8
=============================================================
Kata Kunci
CONFIG
- config/autoload
config/config
config/database
config/routes
CONTROLLER
- Controller/admin/dashboard_admin.php
Controller/admin/data_barang.php
Controller/admin/invoice.php
Controller/auth.php
Controller/dashboard.php
Controller/kategori.php
Controller/registrasi.php
Controller/welcome.php
MODEL
- Model/data_elektronik.php
Model/model_auth.php
Model/model_barang.php
Model/model_invoice.php
Model/model_kategori.php
VIEWS
- Views/admin/dashboard.php
Views/admin/data_barang.php
Views/admin/detail_invoice.php
View/admin/edit_barang.php
Views/admin/invoice.php
Views/template/footer.php
Views/template/header.php
Views/template/sidebar.php
Views/template_admin/footer.php
Views/template_admin/header.php
Views/template_admin/sidebar.php
Views/dashboard.php
Views/detail_barang.php
Views/elektronik.php
Views/form_login.php
Views/keranjang.php
Views/pakaian_anak_anak.php
Views/pakaian_pria.php
Views/pakaian_wanita.php
Views/pembayaran.php
Views/peralatan_olahraga.php
Views/proses_pesan.php
Views/registrasi.php
HTACCESS
- .htaccess.php

=============================================================
CONFIG
config/autoload

$autoload['libraries'] = array('database','cart','form_validation');
$autoload['helper'] = array('url');
$autoload['model'] = array('model_barang','model_invoice','model_kategori','model_auth');
config/config
$config['base_url'] = 'http://localhost/toko_online/';
config/database
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'toko_online',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
config/routes
$route['default_controller'] = 'welcome';
=============================================================
CONTROLLER
Controller/admin/dashboard_admin.php
<?php 

class Dashboard_admin extends CI_Controller{

public function __construct(){
parent :: __construct();
if($this->session->userdata('role_id') !=1 ){
$this->session->set_flashdata('pesan','<div class="alert alert-warning alert-dismissible fade show" role="alert">
  Anda Belum Login
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>');
redirect('auth/login');
}

}
public function index()
{
$this->load->view('template_admin/header');
$this->load->view('template_admin/sidebar');
$this->load->view('admin/dashboard');
$this->load->view('template_admin/footer');
}
}
?>
Controller/admin/data_barang.php
<?php 
class Data_barang extends CI_Controller{
public function __construct(){
parent :: __construct();
if($this->session->userdata('role_id') !=1 ){
$this->session->set_flashdata('pesan','<div class="alert alert-warning alert-dismissible fade show" role="alert">
  Anda Belum Login
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>');
redirect('auth/login');
}

}
public function index()
{
$data['barang'] = $this->model_barang->tampil_data()->result();

$this->load->view('template_admin/header');
$this->load->view('template_admin/sidebar');
$this->load->view('admin/data_barang',$data);
$this->load->view('template_admin/footer');
}
public function tambah_aksi()
{
$nama_brg = $this->input->post('nama_brg');
$keterangan = $this->input->post('keterangan');
$kategori = $this->input->post('kategori');
$harga = $this->input->post('harga');
$stok = $this->input->post('stok');
$gambar = $_FILES['gambar']['name'];
if($gambar=''){}else{
$config['upload_path'] = './uploads';
    $config['allowed_types'] = 'jpg|png|gif';

   $this->load->library('upload',$config);
   if(!$this->upload->do_upload('gambar')){//foto nama file pada view
    echo "upload gagal";die();
   }else{
    $gambarz = $this->upload->data('file_name');
   }
}

$data = array(
'nama_brg' => $nama_brg,
'keterangan' => $keterangan,
'kategori' =>$kategori,
'harga' => $harga,
'stok' =>$stok,
'gambar' => $gambarz
);
$this->model_barang->tambah_barang($data,'tb_barang');
redirect('admin/data_barang/index');
}
public function edit($id)
{
$where = array('id_brg' =>$id);
$data['barang'] = $this->model_barang->edit_barang($where,'tb_barang')->result();
$this->load->view('template_admin/header');
$this->load->view('template_admin/sidebar');
$this->load->view('admin/edit_barang',$data);
$this->load->view('template_admin/footer');

}
public function update()
{
$id = $this->input->post('id_brg');
$nama_brg = $this->input->post('nama_brg');
$keterangan = $this->input->post('keterangan');
$kategori = $this->input->post('kategori');
$harga = $this->input->post('harga');
$stok = $this->input->post('stok');

$data = array(
'nama_brg' => $nama_brg,
'keterangan' => $keterangan,
'kategori' => $kategori,
'harga' =>$harga,
'stok' =>$stok
);
$where = array('id_brg' => $id);
$this->model_barang->update_data($where,$data,'tb_barang');
redirect('admin/data_barang/index');
}
public function hapus($id)
{
$where = array('id_brg' =>$id);
$this->model_barang->hapus_data($where,'tb_barang');
redirect('admin/data_barang/index');
}
}

 ?>
Controller/admin/invoice.php
<?php 
class Invoice extends CI_Controller{
public function __construct(){
parent :: __construct();
if($this->session->userdata('role_id') !=1 ){
$this->session->set_flashdata('pesan','<div class="alert alert-warning alert-dismissible fade show" role="alert">
  Anda Belum Login
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>');
redirect('auth/login');
}

}
public function index()
{
$data['invoice'] = $this->model_invoice->tampil_data();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('admin/invoice',$data);
$this->load->view('template/footer');

}
public function detail($id_invoice)
{
$data['invoice'] = $this->model_invoice->ambil_id_invoice($id_invoice);
$data['pesanan'] = $this->model_invoice->ambil_id_pesanan($id_invoice);
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('admin/detail_invoice',$data);
$this->load->view('template/footer');
}
}
?>
===========
Controller/auth.php
<?php 
class Auth extends CI_Controller{
public function login()
{
$this->form_validation->set_rules('username','Username','required',[
'required' => 'Username wajib diisi'
]);
$this->form_validation->set_rules('password','Password','required',[
'required' => 'Password wajib diisi'
]);
if($this->form_validation->run() == False){
$this->load->view('template/header');
$this->load->view('form_login');
$this->load->view('template/footer');
}else{
$auth = $this->model_auth->cek_login(); 
if($auth == False){
$this->session->set_flashdata('pesan','<div class="alert alert-warning alert-dismissible fade show" role="alert">
  Username atau Password Anda Salah !
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>');
redirect('auth/login');
}else{
$this->session->set_userdata('username',$auth->username);
$this->session->set_userdata('role_id',$auth->role_id);
switch ($auth->role_id) {
case 1 : redirect('admin/dashboard_admin');
break;
case 2 : redirect('welcome');
break;
default:
break;
}

}
}
}
public function logout()
{
$this->session->sess_destroy();
redirect('auth/login');
}
}
?>
Controller/dashboard.php
<?php 
Class Dashboard extends CI_Controller{
public function __construct(){
parent :: __construct();
if($this->session->userdata('role_id') !='2' ){
$this->session->set_flashdata('pesan','<div class="alert alert-warning alert-dismissible fade show" role="alert">
  Anda Belum Login
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>');
redirect('auth/login');
}

}
public function tambah_ke_keranjang($id)
{
$barang = $this->model_barang->find($id);
$data = array(
        'id'      => $barang->id_brg,
        'qty'     => 1,
        'price'   => $barang->harga,
        'name'    => $barang->nama_brg
);

$this->cart->insert($data);
redirect('welcome');
}
public function detail_keranjang()
{
    $this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('keranjang');
$this->load->view('template/footer');
}
public function hapus_keranjang()
{
$this->cart->destroy();
redirect('welcome/index');
}
public function pembayaran()
{
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('pembayaran');
$this->load->view('template/footer');

}
public function proses_pesanan()
{
$is_processed = $this->model_invoice->index();
if($is_processed){
$this->cart->destroy();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('proses_pesanan');
$this->load->view('template/footer');
}else{
echo "Pesanan Anda Gagal DiProses";
}
}
public function detail($id_brg)
{
$data['barang'] = $this->model_barang->detail_brg($id_brg);
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('detail_barang',$data);
$this->load->view('template/footer');
}
}

?>

Controller/kategori.php
<?php 
class Kategori extends CI_Controller{
public function elektronik()
{
$data['elektronik'] = $this->model_kategori->data_elektronik()->result();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('elektronik',$data);
$this->load->view('template/footer');
}
public function pakaian_pria()
{
$data['pakaian_pria'] = $this->model_kategori->data_pakaian_pria()->result();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('pakaian_pria',$data);
$this->load->view('template/footer');
}
public function pakaian_wanita()
{
$data['pakaian_wanita'] = $this->model_kategori->data_pakaian_wanita()->result();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('pakaian_wanita',$data);
$this->load->view('template/footer');
}
public function pakaian_anak_anak()
{
$data['pakaian_anak_anak'] = $this->model_kategori->data_pakaian_anak_anak()->result();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('pakaian_anak_anak',$data);
$this->load->view('template/footer');
}
public function peralatan_olahraga()
{
$data['peralatan_olahraga'] = $this->model_kategori->data_peralatan_olahraga()->result();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('peralatan_olahraga',$data);
$this->load->view('template/footer');
}
}
?>
Controller/registrasi.php
<?php 
class Registrasi extends CI_Controller{
public function index()
{
$this->form_validation->set_rules('nama','Nama','required',[
'required' => 'Wajib Diisi'
]);
$this->form_validation->set_rules('username','username','required',[
'required' => 'Wajib Diisi'
]);
$this->form_validation->set_rules('password_1','password','required|matches[password_2]',[
'required' => 'Password Wajib Diisi',
'matches' => 'password tidak cocok'
]);
$this->form_validation->set_rules('password_2','password','required|matches[password_1]');
if($this->form_validation->run() == false){
$this->load->view('template/header');
$this->load->view('registrasi');
$this->load->view('template/footer');
}else{
$data = array(
'id' => '',
'nama' => $this->input->post('nama'),
'username' => $this->input->post('username'),
'password' => $this->input->post('password_1'),
'role_id' => 2,
);
$this->db->insert('tb_user',$data);
redirect('auth/login');
}
}
}
?>
Controller/welcome.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$data['barang'] = $this->model_barang->tampil_data()->result();
$this->load->view('template/header');
$this->load->view('template/sidebar');
$this->load->view('dashboard',$data);
$this->load->view('template/footer');
}
}

=============================================================
MODEL
Model/data_elektronik.php
<?php 
class Model_kategori extends CI_Model{
public function data_elektornik
}
?>
Model/model_auth.php
<?php 
class Model_auth extends CI_Model{
public function cek_login()
{
$username = set_value('username');
$password = set_value('password');

$result = $this->db->where('username',$username)
->where('password',$password)
->limit(1)
->get('tb_user');
if($result->num_rows() > 0 ){
return $result->row();
}else{
return array();
}

}
}
?>
Model/model_barang.php
<?php

class Model_barang extends CI_Model{

public function tampil_data()
{
//$this->db->limit(20);
//$this->db->where('nama_brg','sepatu');
return $this->db->get('tb_barang');
}
public function tambah_barang($data,$table)
{
$this->db->insert($table,$data);
public function edit_barang($where,$table)
{
return $this->db->get_where($table,$where);
}
public function update_data($where,$data,$table)
{

$this->db->where($where);
$this->db->update($table,$data);
}
public function hapus_data($where,$table)
{
$this->db->where($where);
$this->db->delete($table);
}
public function find($id)
{
$result = $this->db->where('id_brg',$id)
->limit(1)
->get('tb_barang');
if($result->num_rows()>0){
return $result->row();
}else{
return array();
}


}
public function detail_brg($id_brg)
{
$result = $this->db->where('id_brg',$id_brg)->get('tb_barang');
if($result->num_rows() > 0){
return $result->result();
}else{
return false;
}


}

}

 ?>
Model/model_invoice.php
<?php 
class Model_invoice extends CI_Model{
public function index()
{
date_default_timezone_set('asia/jakarta');
$nama = $this->input->post('nama');
$alamat = $this->input->post('alamat');

$invoice = array(
'nama' => $nama,
'alamat' => $alamat,
'tgl_pesan' => date('Y-m-d H:i:s'),
'batas_bayar' => date('Y-m-d H:i:s',mktime(date('H'),date('i'),date('s'),date('m'),date('d')+1,date('Y'))),

);
$this->db->insert('tb_invoice',$invoice);
$id_invoice = $this->db->insert_id();
foreach($this->cart->contents() as $item){
$data = array(
'id_invoice' => $id_invoice,
'id_brg' => $item['id'],
'nama_brg' => $item['name'],
'jumlah' => $item['qty'],
'harga' => $item['price'],
);
$this->db->insert('tb_pesanan',$data);
}
return TRUE;
}
public function tampil_data()
{
$result = $this->db->get('tb_invoice');
if($result->num_rows()>0){
return $result->result();
}else{
return false;
}
}
public function ambil_id_invoice($id_invoice)
{
$result = $this->db->where('id',$id_invoice)->limit(1)->get('tb_invoice');
if($result->num_rows()>0){
return $result->row();
}else{
return false;
}
}
public function ambil_id_pesanan($id_invoice)
{
$result = $this->db->where('id_invoice',$id_invoice)->limit(1)->get('tb_pesanan');
if($result->num_rows()>0){
return $result->result();
}else{
return false;
}
}
}
?>
Model/model_kategori.php
<?php 
class Model_kategori extends CI_Model{
public function data_elektronik()
{
return $this->db->get_where('tb_barang',array('kategori' => 'elektronik'));//nama bebase =>elektronik
}
public function data_pakaian_pria()
{
return $this->db->get_where('tb_barang',array('kategori' => 'pakaian pria'));
}
public function data_pakaian_wanita()
{
return $this->db->get_where('tb_barang',array('kategori' => 'pakaian wanita'));
}
public function data_pakaian_anak_anak()
{
return $this->db->get_where('tb_barang',array('kategori' => 'pakaian anak anak'));
}
public function data_peralatan_olahraga()
{
return $this->db->get_where('tb_barang',array('kategori' => 'peralatan olahraga'));
}
}
?>
=============================================================
VIEWS
Views/admin/dashboard.php
<div class="container-fluid">
<!-- Content Row -->
          <div class="row">

            <!-- Earnings (Monthly) Card Example -->
            <div class="col-xl-3 col-md-6 mb-4">
              <div class="card border-left-primary shadow h-100 py-2">
                <div class="card-body">
                  <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                      <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Earnings (Monthly)</div>
                      <div class="h5 mb-0 font-weight-bold text-gray-800">$40,000</div>
                    </div>
                    <div class="col-auto">
                      <i class="fas fa-calendar fa-2x text-gray-300"></i>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- Earnings (Monthly) Card Example -->
            <div class="col-xl-3 col-md-6 mb-4">
              <div class="card border-left-success shadow h-100 py-2">
                <div class="card-body">
                  <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                      <div class="text-xs font-weight-bold text-success text-uppercase mb-1">Earnings (Annual)</div>
                      <div class="h5 mb-0 font-weight-bold text-gray-800">$215,000</div>
                    </div>
                    <div class="col-auto">
                      <i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- Earnings (Monthly) Card Example -->
            <div class="col-xl-3 col-md-6 mb-4">
              <div class="card border-left-info shadow h-100 py-2">
                <div class="card-body">
                  <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                      <div class="text-xs font-weight-bold text-info text-uppercase mb-1">Tasks</div>
                      <div class="row no-gutters align-items-center">
                        <div class="col-auto">
                          <div class="h5 mb-0 mr-3 font-weight-bold text-gray-800">50%</div>
                        </div>
                        <div class="col">
                          <div class="progress progress-sm mr-2">
                            <div class="progress-bar bg-info" role="progressbar" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="col-auto">
                      <i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- Pending Requests Card Example -->
            <div class="col-xl-3 col-md-6 mb-4">
              <div class="card border-left-warning shadow h-100 py-2">
                <div class="card-body">
                  <div class="row no-gutters align-items-center">
                    <div class="col mr-2">
                      <div class="text-xs font-weight-bold text-warning text-uppercase mb-1">Pending Requests</div>
                      <div class="h5 mb-0 font-weight-bold text-gray-800">18</div>
                    </div>
                    <div class="col-auto">
                      <i class="fas fa-comments fa-2x text-gray-300"></i>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <!-- Content Row -->

</div>

Views/admin/data_barang.php
<div class="container-fluid">
<button class="btn btn-sm btn-primary mb-3" data-toggle="modal" data-target="#tambah_barang"><i class="fas fa-plus fa-sm"></i>Tambah Barang</button>
<table class="table table-bordered">
<tr>
<th>NO</th>
<th>NAMA BARANG</th>
<th>KETERANGAN</th>
<th>KATEGORI</th>
<th>HARGA</th>
<th>STOCK</th>
<th colspan="3">AKSI</th>
  </tr>
  <?php $no=1; foreach ($barang as $brg):  ?>
  <tr>
  <td><?php echo $no++?></td>
  <td><?php echo $brg->nama_brg?></td>
  <td><?php echo $brg->keterangan?></td>
  <td><?php echo $brg->kategori?></td>
  <td><?php echo $brg->harga?></td>
  <td><?php echo $brg->stok?></td>
  <td><div class="btn btn-success btn-sm"><i class="fas fa-search-plus"></i></div></td>
  <td><?php echo anchor('admin/data_barang/edit/'.$brg->id_brg,'<div class="btn btn-primary btn-sm"><i class="fas fa-edit"></i></div>') ?></td>
  <td><?php echo anchor('admin/data_barang/hapus/'.$brg->id_brg,'<div class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></div>') ?></td>
  </tr>
  <?php endforeach; ?>
</table>

</div>


<!-- Modal -->
<div class="modal fade" id="tambah_barang" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">FORM INPUT PRODUK</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form action="<?php echo base_url('admin/data_barang/tambah_aksi'); ?>" method="POST" enctype="multipart/form-data">
        <div class="form-group">
        <label>Nama Barang</label>
        <input type="text" name="nama_brg" class="form-control">
        </div>
        <div class="form-group">
        <label>Keterangan</label>
        <input type="text" name="keterangan" class="form-control">
        </div>
        <div class="form-group">
        <label>kategori</label>
        <select class="form-control" name="kategori">
              <option>elektronik</option>
              <option>pakaian pria</option>
              <option>pakaian wanita</option>
              <option>pakaian anak anak</option>
              <option>peralatan olahraga</option>
            </select>
        </div>
        <div class="form-group">
        <label>harga</label>
        <input type="text" name="harga" class="form-control">
        </div>
        <div class="form-group">
        <label>stok</label>
        <input type="text" name="stok" class="form-control">
        </div>
        <div class="form-group">
        <label>Gambar produk</label>
        <input type="file" name="gambar" class="form-control">
        </div>       
     
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Simpan</button>
      </div>
      </form>
    </div>
  </div>

</div>
Views/admin/detail_invoice.php
<div class="container-fluid">
<h4>Detai Pesanan <div class="btn btn-sm btn-success"> No.Invoice : <?php echo $invoice->id ?></div> </h4>
<table class="table table-bordered table-hover table-striped" >
<tr>
<th>No</th>
<th>Nama Produck</th>
<th>Jumlah Pesanan</th>
<th>Harga Satuan</th>
<th>SUB-TOTAL</th>
</tr>
<?php $total=0;
foreach($pesanan as $psn):
$subtotal = $psn->jumlah * $psn->harga;
$total += $subtotal;
?>
<tr>
<td><?php echo $psn->id_brg ?></td>
<td><?php echo $psn->nama_brg ?></td>
<td><?php echo $psn->jumlah ?></td>
<td><?php echo number_format($psn->harga,0,',','.') ?></td>
<td><?php echo number_format($subtotal,0,',','.') ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td></td>
<td  colspan="3" align="left">Grand Total</td>
<td  align="left"><?php echo number_format($total,0,',','.') ?></td>
</tr>
</table>
<a href="<?php echo base_url('admin/invoice/index') ?>"><div class="btn btn-sm btn-primary">Kembali</div></a>

</div>
View/admin/edit_barang.php
<div class="container-fluid">
<h3><i class="fas fa-edit mb-3">Edit Data Barang</i></h3>
<?php foreach($barang as $brg) : ?>
<form method="post" action="<?php echo base_url('admin/data_barang/update') ?>">
<div class="for-group">
<label>Nama barang</label>
<input type="text" name="nama_brg" class="form-control"
value="<?php echo $brg->nama_brg ?>">
</div>
<div class="for-group">
<label>Keterangan </label>
<input type="hidden" name="id_brg" class="form-control"
value="<?php echo $brg->id_brg ?>">
<input type="text" name="keterangan" class="form-control"
value="<?php echo $brg->keterangan ?>">
</div>

<div class="for-group">
<label>kategori</label>
<input type="text" name="kategori" class="form-control"
value="<?php echo $brg->kategori ?>">
</div>
<div class="for-group">
<label>harga</label>
<input type="text" name="harga" class="form-control"
value="<?php echo $brg->harga ?>">
</div>
<div class="for-group">
<label>stok</label>
<input type="text" name="stok" class="form-control"
value="<?php echo $brg->stok ?>">
</div>
<button type="submit" class="btn btn-primary btn-sm mt-3">Simpan</button>
<?php echo anchor('admin/data_barang','<button type="submit" class="btn btn-danger btn-sm mt-3">Cancel</button>') ?>

</form>
<?php endforeach; ?>

</div>
Views/admin/invoice.php
<div class="container-fluid">
<div class="alert alert-primary"> <h4>Invoice Pemesanan Produk</h4> </div>

<table class="table  table-bordered table-hover table-striped">
<tr>
<th>Id Invoice</th>
<th>Nama Pemesan</th>
<th>Alamat Pemesanan</th>
<th>Tanggal Pemesanan</th>
<th>Batas Pembayaran</th>
<th>Aksi</th>
</tr>
<?php foreach($invoice as $inv ): ?>
<tr>
<td><?php echo $inv->id ?></td>
<td><?php echo $inv->nama ?></td>
<td><?php echo $inv->alamat ?></td>
<td><?php echo $inv->tgl_pesan ?></td>
<td><?php echo $inv->batas_bayar ?></td>
<td><?php echo anchor('admin/invoice/Detail/'.$inv->id,'<div class="btn btn-sm btn-primary">Detail</div>') ?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
Views/template/footer.php
<!-- Footer
      <footer class="sticky-footer bg-white">
        <div class="container my-auto">
          <div class="copyright text-center my-auto">
            <span>Copyright &copy; Your Website 2019</span>
          </div>
        </div>
      </footer>

 End of Footer -->

    </div>
    <!-- End of Content Wrapper -->

  </div>
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
          <button class="close" type="button" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
        <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
          <a class="btn btn-primary" href="login.html">Logout</a>
        </div>
      </div>
    </div>
  </div>

  <!-- Bootstrap core JavaScript-->
  <script src="<?php echo base_url()?>assets/vendor/jquery/jquery.min.js"></script>
  <script src="<?php echo base_url()?>assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  <!-- Core plugin JavaScript-->
  <script src="<?php echo base_url()?>assets/vendor/jquery-easing/jquery.easing.min.js"></script>

  <!-- Custom scripts for all pages-->
  <script src="<?php echo base_url()?>assets/js/sb-admin-2.min.js"></script>

  <!-- Page level plugins -->
  <script src="<?php echo base_url()?>assets/vendor/chart.js/Chart.min.js"></script>

  <!-- Page level custom scripts -->
  <script src="<?php echo base_url()?>assets/js/demo/chart-area-demo.js"></script>
  <script src="<?php echo base_url()?>assets/js/demo/chart-pie-demo.js"></script>

</body>


</html>
Views/template/header.php

<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>SB Admin 2 - Dashboard</title>

  <!-- Custom fonts for this template-->
  <link href="<?php echo base_url()?>assets/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

  <!-- Custom styles for this template-->
  <link href="<?php echo base_url()?>assets/css/sb-admin-2.min.css" rel="stylesheet">

</head>
Views/template/sidebar.php
<body id="page-top">

  <!-- Page Wrapper -->
  <div id="wrapper">

    <!-- Sidebar -->
    <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

      <!-- Sidebar - Brand -->
      <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
        <div class="sidebar-brand-icon "><!--rotate-n-15-->
          <i class="fas fa-store-alt"></i>
          <!--<i class="fas fa-laugh-wink"></i>-->
        </div>
        <div class="sidebar-brand-text mx-3">Toko Online <!--<sup>2</sup>--></div>

      </a>

      <!-- Divider -->
      <hr class="sidebar-divider my-0">

      <!-- Nav Item - Dashboard -->
      <li class="nav-item active">
        <a class="nav-link" href="<?php echo base_url('dashboard')?>">
          <i class="fas fa-fw fa-tachometer-alt"></i>
          <span>Dashboard</span></a>
      </li>

      <!-- Divider -->
      <hr class="sidebar-divider">

      <!-- Heading -->
      <div class="sidebar-heading">
        Kategori
      </div>


      <!-- Nav Item - Tables -->
      <li class="nav-item">
        <a class="nav-link" href="<?php echo base_url('kategori/elektronik')?>">
          <i class="fas fa-fw fa-tv"></i>
          <span>Electronik</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo base_url('kategori/Pakaian_pria')?>">
          <i class="fas fa-fw fa-tshirt"></i>
          <span>Pakaian Pria</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo base_url('kategori/Pakaian_wanita')?>">
          <i class="fas fa-fw fa-tshirt"></i>
          <span>Pakaian Wanita</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo base_url('kategori/Pakaian_anak_anak')?>">
          <i class="fas fa-fw fa-tshirt"></i>
          <span>Pakaian Anak - Anak</spxan></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo base_url('kategori/Peralatan_olahraga')?>">
          <i class="fas fa-fw fa-futbol"></i>
          <span>Peralatan Olah Raga</span></a>
      </li>

      <!-- Divider -->
      <hr class="sidebar-divider d-none d-md-block">

      <!-- Sidebar Toggler (Sidebar) -->
      <div class="text-center d-none d-md-inline">
        <button class="rounded-circle border-0" id="sidebarToggle"></button>
      </div>

    </ul>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

      <!-- Main Content -->
      <div id="content">

        <!-- Topbar -->
        <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

          <!-- Sidebar Toggle (Topbar) -->
          <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
            <i class="fa fa-bars"></i>
          </button>

          <!-- Topbar Search -->
          <form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">
            <div class="input-group">
              <input type="text" class="form-control bg-light border-0 small" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2">
              <div class="input-group-append">
                <button class="btn btn-primary" type="button">
                  <i class="fas fa-search fa-sm"></i>
                </button>
              </div>
            </div>
          </form>

          <!-- Topbar Navbar -->
          <ul class="navbar-nav ml-auto">

            <!-- Nav Item - Search Dropdown (Visible Only XS) -->
            <li class="nav-item dropdown no-arrow d-sm-none">
              <a class="nav-link dropdown-toggle" href="#" id="searchDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="fas fa-search fa-fw"></i>
              </a>
              <!-- Dropdown - Messages -->
              <div class="dropdown-menu dropdown-menu-right p-3 shadow animated--grow-in" aria-labelledby="searchDropdown">
                <form class="form-inline mr-auto w-100 navbar-search">
                  <div class="input-group">
                    <input type="text" class="form-control bg-light border-0 small" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2">
                    <div class="input-group-append">
                      <button class="btn btn-primary" type="button">
                        <i class="fas fa-search fa-sm"></i>
                      </button>
                    </div>
                  </div>
                </form>
              </div>
            </li>

           <div class="navbar">
             <ul class="nav navbar-nav navbar-right">
               
               <li> <?php $keranjang = '  Keranjan Belanja = '.$this->cart->total_items().' items' ?>
                 <?php echo anchor('dashboard/detail_keranjang',$keranjang) ?>
               </li>
             </ul>
             <div class="topbar-divider d-none d-sm-block"></div>

                <ul class="na navbar-nav navbar-right">
                  <?php if($this->session->userdata('username')){  ?>
                    <li><div>Selamat Datang <?php echo $this->session->userdata('username') ?></div></li>
                    <li class="ml-2"><?php echo anchor('auth/logout','logout') ?></li>
                    <?php }else{ ?>
                      <li><?php echo anchor('auth/login','Login') ?></li>
                 <?php } ?>
                </ul>
                 
           </div>

            

            <!-- Nav Item - User Information -->
            <li class="nav-item dropdown no-arrow">
              <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="mr-2 d-none d-lg-inline text-gray-600 small">Valerie Lunas</span>
                <img class="img-profile rounded-circle" src="https://source.unsplash.com/QAB-WJcbgJk/60x60">
              </a>
              <!-- Dropdown - User Information -->
              <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
                <a class="dropdown-item" href="#">
                  <i class="fas fa-user fa-sm fa-fw mr-2 text-gray-400"></i>
                  Profile
                </a>
                <a class="dropdown-item" href="#">
                  <i class="fas fa-cogs fa-sm fa-fw mr-2 text-gray-400"></i>
                  Settings
                </a>
                <a class="dropdown-item" href="#">
                  <i class="fas fa-list fa-sm fa-fw mr-2 text-gray-400"></i>
                  Activity Log
                </a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
                  <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
                  Logout
                </a>
              </div>
            </li>

          </ul>

        </nav>
        <!-- End of Topbar -->
Views/template_admin/footer.php
<!-- Footer -->
      <footer class="sticky-footer bg-white">
        <div class="container my-auto">
          <div class="copyright text-center my-auto">
            <span>Copyright &copy; Your Website 2019</span>
          </div>
        </div>
      </footer>
      <!-- End of Footer -->

    </div>
    <!-- End of Content Wrapper -->

  </div>
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
          <button class="close" type="button" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
        <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
          <a class="btn btn-primary" href="login.html">Logout</a>
        </div>
      </div>
    </div>
  </div>

  <!-- Bootstrap core JavaScript-->
  <script src="<?php echo base_url()?>assets/vendor/jquery/jquery.min.js"></script>
  <script src="<?php echo base_url()?>assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  <!-- Core plugin JavaScript-->
  <script src="<?php echo base_url()?>assets/vendor/jquery-easing/jquery.easing.min.js"></script>

  <!-- Custom scripts for all pages-->
  <script src="<?php echo base_url()?>assets/js/sb-admin-2.min.js"></script>

  <!-- Page level plugins -->
  <script src="<?php echo base_url()?>assets/vendor/chart.js/Chart.min.js"></script>

  <!-- Page level custom scripts -->
  <script src="<?php echo base_url()?>assets/js/demo/chart-area-demo.js"></script>
  <script src="<?php echo base_url()?>assets/js/demo/chart-pie-demo.js"></script>

</body>

</html>
Views/template_admin/header.php

<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>admin</title>

  <!-- Custom fonts for this template-->
  <link href="<?php echo base_url()?>assets/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

  <!-- Custom styles for this template-->
  <link href="<?php echo base_url()?>assets/css/sb-admin-2.min.css" rel="stylesheet">

</head>
Views/template_admin/sidebar.php
<body id="page-top">

  <!-- Page Wrapper -->
  <div id="wrapper">

    <!-- Sidebar -->
    <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

      <!-- Sidebar - Brand -->
      <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
        <div class="sidebar-brand-icon "><!--rotate-n-15-->
          <i class="fas fa-store-alt"></i>
          <!--<i class="fas fa-laugh-wink"></i>-->
        </div>
        <div class="sidebar-brand-text mx-3">Admin <!--<sup>2</sup>--></div>

      </a>

      <!-- Divider -->
      <hr class="sidebar-divider my-0">

      <!-- Nav Item - Dashboard -->
      <li class="nav-item active">
        <a class="nav-link" href="<?php echo base_url('admin/dashboard_admin') ?>">
          <i class="fas fa-fw fa-tachometer-alt"></i>
          <span>Dashboard</span></a>
      </li>

      <!-- Divider -->
      <hr class="sidebar-divider">

      

      <!-- Nav Item - Tables -->
      <li class="nav-item">
        <a class="nav-link" href="<?php echo base_url('admin/data_barang') ?>">
          <i class="fas fa-fw fa-database"></i>
          <span>Data Barang</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo base_url('admin/invoice') ?>">
          <i class="fas fa-fw fa-file-invoice"></i>
          <span>Invoice</span></a>
      </li>
      
      <!-- Divider -->
      <hr class="sidebar-divider d-none d-md-block">

      <!-- Sidebar Toggler (Sidebar) -->
      <div class="text-center d-none d-md-inline">
        <button class="rounded-circle border-0" id="sidebarToggle"></button>
      </div>

    </ul>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

      <!-- Main Content -->
      <div id="content">

        <!-- Topbar -->
        <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

          <!-- Sidebar Toggle (Topbar) -->
          <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
            <i class="fa fa-bars"></i>
          </button>

          <!-- Topbar Search -->
          <form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">
            <div class="input-group">
              <input type="text" class="form-control bg-light border-0 small" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2">
              <div class="input-group-append">
                <button class="btn btn-primary" type="button">
                  <i class="fas fa-search fa-sm"></i>
                </button>
              </div>
            </div>
          </form>

          <!-- Topbar Navbar -->
          <ul class="navbar-nav ml-auto">

            <!-- Nav Item - Search Dropdown (Visible Only XS) -->
            <li class="nav-item dropdown no-arrow d-sm-none">
              <a class="nav-link dropdown-toggle" href="#" id="searchDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="fas fa-search fa-fw"></i>
              </a>
              <!-- Dropdown - Messages -->
              <div class="dropdown-menu dropdown-menu-right p-3 shadow animated--grow-in" aria-labelledby="searchDropdown">
                <form class="form-inline mr-auto w-100 navbar-search">
                  <div class="input-group">
                    <input type="text" class="form-control bg-light border-0 small" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2">
                    <div class="input-group-append">
                      <button class="btn btn-primary" type="button">
                        <i class="fas fa-search fa-sm"></i>
                      </button>
                    </div>
                  </div>
                </form>
              </div>
            </li>

           

            <div class="topbar-divider d-none d-sm-block"></div>

            <ul class="na navbar-nav navbar-right">
                  <?php if($this->session->userdata('username')){  ?>
                    <li><div>Selamat Datang <?php echo $this->session->userdata('username') ?></div></li>
                    <li class="ml-2"><?php echo anchor('auth/logout','logout') ?></li>
                    <?php }else{ ?>
                      <li><?php echo anchor('auth/login','Login') ?></li>

                 <?php } ?>
                </ul>

          </ul>

        </nav>
        <!-- End of Topbar -->
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="<?php echo base_url()."assets/img/slider1.jpg" ?>" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="<?php echo base_url()."assets/img/slider2.jpg" ?>" class="d-block w-100" alt="...">
    </div>     
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<div class="row text-center mt-3">
<?php foreach($barang as $brg) : ?>
<div class="card ml-3" style="width: 16rem;">
  <img size="200px" height="170px" src="<?php echo base_url().'/uploads/'.$brg->gambar ?>"  class="card-img-top" alt="..." >
  <div class="card-body">
    <h5 class="card-title mb-1"><?php echo $brg->nama_brg; ?></h5>
    <small><?php echo $brg->keterangan ?></small><br>
    <span class="badge badge-success mb-3">Rp <?php echo number_format($brg->harga,0,',','.') ?></span>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/detail/'.$brg->id_brg,'<div class="btn btn-sm btn-success">Detail</div>') ?>
    <!--<a href="#" class="btn btn-sm btn-primary">Tambah Ke keranjang
    <a href="php" class="btn btn-sm btn-success">Detail</a></a> -->
  </div>
</div>
<?php endforeach ?>
</div>
</div>
Views/dashboard.php
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="<?php echo base_url()."assets/img/slider1.jpg" ?>" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="<?php echo base_url()."assets/img/slider2.jpg" ?>" class="d-block w-100" alt="...">
    </div>     
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<div class="row text-center mt-3">
<?php foreach($barang as $brg) : ?>
<div class="card ml-3" style="width: 16rem;">
  <img size="200px" height="170px" src="<?php echo base_url().'/uploads/'.$brg->gambar ?>"  class="card-img-top" alt="..." >
  <div class="card-body">
    <h5 class="card-title mb-1"><?php echo $brg->nama_brg; ?></h5>
    <small><?php echo $brg->keterangan ?></small><br>
    <span class="badge badge-success mb-3">Rp <?php echo number_format($brg->harga,0,',','.') ?></span>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/detail/'.$brg->id_brg,'<div class="btn btn-sm btn-success">Detail</div>') ?>
    <!--<a href="#" class="btn btn-sm btn-primary">Tambah Ke keranjang
    <a href="php" class="btn btn-sm btn-success">Detail</a></a> -->
  </div>
</div>
<?php endforeach ?>
</div>
</div>
Views/detail_barang.php
<div class="container-fluid">
<div class="card">
  <h5 class="card-header">Detail Produk</h5>
  <div class="card-body">
  <?php foreach ($barang as $brg): ?>  
 
    <div class="row">
    <div class="col-md-4">
    <img src="<?php echo base_url().'/uploads/'.$brg->gambar ?> " hight="200px" width="200px">
    </div>
    <div class="col-md-8">
    <table class="table">
    <tr>
    <td>Nama Produk</td>
    <td><strong><?php echo $brg->nama_brg ?></strong></td>
    </tr>
    <tr>
    <td>Keterangan</td>
    <td><strong><?php echo $brg->keterangan ?></strong></td>
    </tr>
    <tr>
    <td>Kategori</td>
    <td><strong><?php echo $brg->kategori ?></strong></td>
    </tr>
    <tr>
    <td>Stok</td>
    <td><strong><?php echo number_format($brg->stok,0,',','.') ?></div></strong></td>
    </tr>
    <tr>
    <td>harga</td>
    <td><strong><div class="btn btn-sm btn-success">Rp. <?php echo number_format($brg->harga,0,',','.') ?></div></strong></td>
    </tr>
   
    </table>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/index/','<div class="btn btn-sm btn-danger">Kembali</div>') ?>
    </div>
    </div>
    <?php endforeach; ?>
  </div>
</div>
</div>
Views/elektronik.php
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="<?php echo base_url()."assets/img/slider1.jpg" ?>" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="<?php echo base_url()."assets/img/slider2.jpg" ?>" class="d-block w-100" alt="...">
    </div>     
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<div class="row text-center mt-3">
<?php foreach($elektronik as $brg) : ?>
<div class="card ml-3" style="width: 16rem;">
  <img size="200px" height="170px" src="<?php echo base_url().'/uploads/'.$brg->gambar ?>"  class="card-img-top" alt="..." >
  <div class="card-body">
    <h5 class="card-title mb-1"><?php echo $brg->nama_brg; ?></h5>
    <small><?php echo $brg->keterangan ?></small><br>
    <span class="badge badge-success mb-3">Rp <?php echo number_format($brg->harga,0,',','.') ?></span>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/detail/'.$brg->id_brg,'<div class="btn btn-sm btn-success">Detail</div>') ?>
    <!--<a href="#" class="btn btn-sm btn-primary">Tambah Ke keranjang
    <a href="php" class="btn btn-sm btn-success">Detail</a></a> -->
  </div>
</div>
<?php endforeach ?>
</div>
</div>
Views/form_login.php

<body class="bg-gradient-primary">

  <div class="container">

    <!-- Outer Row -->
    <div class="row justify-content-center">

      <div class="col-xl-5 col-lg-12 col-md-9">

        <div class="card o-hidden border-0 shadow-lg my-5">
          <div class="card-body p-0">
            <!-- Nested Row within Card Body -->
            <div class="row">
              
              <div class="col-lg-12">
                <div class="p-5">
                  <div class="text-center">
                    <h1 class="h4 text-gray-900 mb-4">Form Login</h1>
                  </div>
                  <?php echo $this->session->flashdata('pesan') ?>
                  <form class="user" method="POST" action="<?php echo base_url('auth/login'); ?>">
                    <div class="form-group">
                      <input type="text" class="form-control form-control-user" id="exampleInputEmail" aria-describedby="emailHelp" placeholder="Masukan Username Anda" name="username">
                      <?php echo form_error('username','<div class="text-danger small ml-2">','</div');?><!--Kesalahan Form Validation-->
                    </div>
                    <div class="form-group">
                      <input type="password" class="form-control form-control-user" id="exampleInputPassword" placeholder="Masukan Password Anda" name="password">
                      <?php echo form_error('password','<div class="text-danger small ml-2">','</div');?><!--Kesalahan Form Validation-->
                    </div>
                    
                  <button type="submit" class="btn btn-primary form-control">Login</button>
                    
                  </form>
                  <hr>

                  <div class="text-center">
                    <a class="small" href="<?php echo base_url('registrasi/index') ?>">Belum Punya Akun ? Daftar !</a>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>

      </div>

    </div>

  </div>


</body>

</html>
Views/keranjang.php
<div class="container-fluid">
<h4>Keranjang Belanjan</h4>
<table class="table table-bordered table-striped table-hover">
<tr>
<th>No</th>
<th>Nama Produk</th>
<th>Jumlah</th>
<th>harga</th>
<th>sub Total</th>
</tr>
<?php $no=1; foreach($this->cart->contents() as $items): ?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $items['name'] ?></td>
<td><?php echo $items['qty'] ?></td>
<td align="right">Rp. <?php echo number_format( $items['price'],0,',','.')  ?></td>
<td align="right">Rp.<?php echo number_format($items['subtotal'],0,',','.') ?></td>

</tr>
<?php endforeach; ?>
<tr>
<td></td>
<td>Total Pembayaran</td>
<td align="right" colspan="3">Rp. <?php echo number_format($this->cart->total(),0,',','.')?></td>
</tr>
</table>
<div align="right">
<a href="<?php echo base_url('dashboard/hapus_keranjang') ?>"><div class="btn btn-sm btn-danger">Hapus Keranjang</div></a>
<a href="<?php echo base_url('dashboard/index') ?>"><div class="btn btn-sm btn-primary">Lanjutkan Belanja</div></a>
<a href="<?php echo base_url('dashboard/pembayaran') ?>"><div class="btn btn-sm btn-success">Pembayaran</div></a>
</div>
</div>
Views/pakaian_anak_anak.php
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="<?php echo base_url()."assets/img/slider1.jpg" ?>" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="<?php echo base_url()."assets/img/slider2.jpg" ?>" class="d-block w-100" alt="...">
    </div>     
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<div class="row text-center mt-3">
<?php foreach($pakaian_anak_anak as $brg) : ?>
<div class="card ml-3" style="width: 16rem;">
  <img size="200px" height="170px" src="<?php echo base_url().'/uploads/'.$brg->gambar ?>"  class="card-img-top" alt="..." >
  <div class="card-body">
    <h5 class="card-title mb-1"><?php echo $brg->nama_brg; ?></h5>
    <small><?php echo $brg->keterangan ?></small><br>
    <span class="badge badge-success mb-3">Rp <?php echo number_format($brg->harga,0,',','.') ?></span>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/detail/'.$brg->id_brg,'<div class="btn btn-sm btn-success">Detail</div>') ?>
    <!--<a href="#" class="btn btn-sm btn-primary">Tambah Ke keranjang
    <a href="php" class="btn btn-sm btn-success">Detail</a></a> -->
  </div>
</div>
<?php endforeach ?>
</div>
</div>
Views/pakaian_pria.php
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="<?php echo base_url()."assets/img/slider1.jpg" ?>" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="<?php echo base_url()."assets/img/slider2.jpg" ?>" class="d-block w-100" alt="...">
    </div>     
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<div class="row text-center mt-3">
<?php foreach($pakaian_pria as $brg) : ?>
<div class="card ml-3" style="width: 16rem;">
  <img size="200px" height="170px" src="<?php echo base_url().'/uploads/'.$brg->gambar ?>"  class="card-img-top" alt="..." >
  <div class="card-body">
    <h5 class="card-title mb-1"><?php echo $brg->nama_brg; ?></h5>
    <small><?php echo $brg->keterangan ?></small><br>
    <span class="badge badge-success mb-3">Rp <?php echo number_format($brg->harga,0,',','.') ?></span>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/detail/'.$brg->id_brg,'<div class="btn btn-sm btn-success">Detail</div>') ?>
    <!--<a href="#" class="btn btn-sm btn-primary">Tambah Ke keranjang
    <a href="php" class="btn btn-sm btn-success">Detail</a></a> -->
  </div>
</div>
<?php endforeach ?>
</div>
</div>

Views/pakaian_wanita.php
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="<?php echo base_url()."assets/img/slider1.jpg" ?>" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="<?php echo base_url()."assets/img/slider2.jpg" ?>" class="d-block w-100" alt="...">
    </div>     
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<div class="row text-center mt-3">
<?php foreach($pakaian_wanita as $brg) : ?>
<div class="card ml-3" style="width: 16rem;">
  <img size="200px" height="170px" src="<?php echo base_url().'/uploads/'.$brg->gambar ?>"  class="card-img-top" alt="..." >
  <div class="card-body">
    <h5 class="card-title mb-1"><?php echo $brg->nama_brg; ?></h5>
    <small><?php echo $brg->keterangan ?></small><br>
    <span class="badge badge-success mb-3">Rp <?php echo number_format($brg->harga,0,',','.') ?></span>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/detail/'.$brg->id_brg,'<div class="btn btn-sm btn-success">Detail</div>') ?>
    <!--<a href="#" class="btn btn-sm btn-primary">Tambah Ke keranjang
    <a href="php" class="btn btn-sm btn-success">Detail</a></a> -->
  </div>
</div>
<?php endforeach ?>
</div>
</div>
Views/pembayaran.php
<div class="container-fluid">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="btn btn-sm btn-success">
<?php 
$grand_total=0;
if($keranjang = $this->cart->contents()){
foreach($keranjang as $item)
{
$grand_total = $grand_total + $item['subtotal'];
}
echo "<h4>Total Belanja Anda = Rp. ".number_format($grand_total,0,',','.');
?>
</div> <br><br>
<h3>Input Alamat Pengiriman dan Pembayaran</h3>
<form method="post" action="<?php echo base_url('dashboard/proses_pesanan') ?>">
<div class="form-group">
<label>Nama Lengkap</label>
<input type="text" name="nama" placeholder="Nama Lengkap" class="form-control">
</div>
<div class="form-group">
<label>Alamat Lengkap</label>
<input type="text" class="form-control" name="alamat" placeholder="Alamat Lengkap Anda">
</div>
<div class="form-group">
<label>No. Telepon</label>
<input type="text" class="form-control" name="no_telp" placeholder="No Telepon Anda">
</div>
<div class="form-group">
<label>Jasa Pengiriman </label>
<select class="form-control">
<option>JNE</option>
<option>TIKI</option>
<option>POST INDONESIA</option>
<option>GOJEK</option>
<option>GRAB</option>
</select>
</div>
<div class="form-group">
<label>Pilih Bank</label>
<select  class="form-control">
<option>BRI - xxxxxx</option>
<option>BNI - xxxxxx</option>
<option>MANDIRI - xxxxxx</option>
<option>BCA - xxxxxx</option>
</select>
</div>
<button type="submit" class="btn btn-sm btn-primary mb-3" >PESAN</button>
</form>
<?php }else{ echo "<h4>Keranjang Belanja Anda Masih Kosong" ; } ?>
</div>
<div class="col-md-2"></div>
</div>
</div>
Views/peralatan_olahraga.php
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="<?php echo base_url()."assets/img/slider1.jpg" ?>" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="<?php echo base_url()."assets/img/slider2.jpg" ?>" class="d-block w-100" alt="...">
    </div>     
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<div class="row text-center mt-3">
<?php foreach($peralatan_olahraga as $brg) : ?>
<div class="card ml-3" style="width: 16rem;">
  <img size="200px" height="170px" src="<?php echo base_url().'/uploads/'.$brg->gambar ?>"  class="card-img-top" alt="..." >
  <div class="card-body">
    <h5 class="card-title mb-1"><?php echo $brg->nama_brg; ?></h5>
    <small><?php echo $brg->keterangan ?></small><br>
    <span class="badge badge-success mb-3">Rp <?php echo number_format($brg->harga,0,',','.') ?></span>
    <?php echo anchor('dashboard/tambah_ke_keranjang/'.$brg->id_brg,'<div class="btn btn-sm btn-primary">Tambah Ke keranjang</div>') ?>
    <?php echo anchor('dashboard/detail/'.$brg->id_brg,'<div class="btn btn-sm btn-success">Detail</div>') ?>
    <!--<a href="#" class="btn btn-sm btn-primary">Tambah Ke keranjang
    <a href="php" class="btn btn-sm btn-success">Detail</a></a> -->
  </div>
</div>
<?php endforeach ?>
</div>
</div>
Views/proses_pesan.php
<div class="container-fluid">
<div class="alert alert-success">
<p class="text-center align-middle">SELAMAT PESANAN ANDA TELAH BERHASIL DIPROESES</p>
</div>
</div>
Views/registrasi.php

<body class="bg-gradient-primary">

  <div class="container">

    <div class="card o-hidden border-0 shadow-lg my-5 col-lg-6 mx-auto">
      <div class="card-body p-0">
        <!-- Nested Row within Card Body -->
        <div class="row">
          <div class="col-lg">
            <div class="p-5">
              <div class="text-center">
                <h1 class="h4 text-gray-900 mb-4">Daftar akun!</h1>
              </div>
              <form class="user" method="post" action="<?php echo base_url('registrasi/index') ?>">
                <div class="form-group">
                  <input type="text" class="form-control form-control-user" id="exampleInputEmail" placeholder="Nama Anda" name="nama">
                  <?php echo form_error('nama','<div class="text-danger small ml-2">','</div>') ?>
                </div>
                <div class="form-group">
                  <input type="text" class="form-control form-control-user" id="exampleInputEmail" placeholder="Username Anda" name="username">
                  <?php echo form_error('username','<div class="text-danger small ml-2">','</div>') ?>
                </div>
                <div class="form-group row">
                  <div class="col-sm-6 mb-3 mb-sm-0">
                    <input type="password" class="form-control form-control-user" id="exampleInputPassword" placeholder="Password" name="password_1">
                    <?php echo form_error('password_1','<div class="text-danger small ml-2">','</div>') ?>
                  </div>
                  <div class="col-sm-6">
                    <input type="password" class="form-control form-control-user" id="exampleRepeatPassword" placeholder="Ulangi Password" name="password_2">

                  </div>
                </div>

                <button type="submit" class="btn btn-primary btn-user btn-block">Daftar</button>

              </form>
              <hr>
              
              <div class="text-center">
                <a class="small" href="<?php echo base_url('auth/login') ?>">Sudah punya akun? Silahkan Login!</a>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>
=============================================================
HTACCESS
.htaccess.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

=============================================================


Membuat Toko Online Dengan Codeigniter Membuat Toko Online Dengan Codeigniter Reviewed by Leo on 20:39 Rating: 5

No comments