UTS PBKK

UTS PBKK

Jadi tugas dari UTS PBKK ini adalah membuat sebuah website untuk mencatat transaksi penjualan. Disini saya akan membuat website yang menjual rubicks cube dan akan mencatat semua transaksi penjualannya. Beberapa fitur pada website ini antara lain :
- Fitur login/logout (admin dan customer)
- Fitur untuk menambah produk rubicks (admin)
- Fitur untuk mengedit produk (admin)
- Fitur untuk menghapus produk (admin)
- Fitur untuk membeli produk (customer)
- Fitur untuk melihat semua transaksi customer (admin)
- Fitur untuk melihat transaksi customer tersebut (customer)
- Fitur search produk (admin dan customer)


Dokumentasi dari aplikasi :
1. Login/logout (admin dan customer)




Jadi di database nanti akan dibedakan apakah user tersebut merupakan admin atau customer. Jika user tersebut adalah admin, maka akan diarahkan ke halaman admin. Jika user tersebut adalah customer, maka akan diarahkan ke halaman customer.

Sedangkan untuk logout hanya seperti ini :


2. Fitur untuk menambah produk rubicks (admin)
Saat admin login, maka tampilan utamanya seperti ini :



Disana akan terdapat pilihan "+ add new" yang berarti menambah produk baru. Jika Add new ditekan maka akan menuju halaman ini :


Pada gambar di atas, saya akan menambah produk baru bernama Rubick 3x3 Siamese, maka jika di save produk ini akan muncul pada halaman list produk


3. Fitur untuk mengedit produk (admin)
Ini adalah halaman untuk mengedit produk, disana akan terdapat data produk yang lama, jika ada yang ingin diganti maka bisa langsung menggantinya.


4. Fitur untuk menghapus produk (admin)
Ini adalah validasi yang dilakukan ketika ingin menghapus sebuah produk :


Barang akan terdelete jika admin klik button delete.

5. Fitur untuk membeli produk (customer)

Jika pada halaman admin terdapat tombol untuk menambah produk, mengedit produk, dan menghapus produk, maka pada halaman customer hanya akan ada tombol untuk membeli seperti gambar di bawah ini :


Jika tombol Buy diklik maka akan direct ke halaman ini :


Customer akan diminta untuk input alamat customer, kode pos alamat customer, dan jumlah dari barang yang ingin dibeli. Misal saya ingin membeli rubicks 3x3 dengan alamat ITS, kode pos 60111, dan jumlahnya 6.


Maka data akan tersimpan sebagai data transaksi yang terdapat pada fitur selanjutnya.

6. Fitur untuk melihat semua transaksi customer (admin)
Pada halaman admin, maka akan terdapat fitur yang dapat digunakan untuk melihat semua transaksi yang ada dari semua customer. Kalau dibuka maka hasilnya akan seperti ini :


Pesanan yang saya buat pada penjelasan fitur nomor 5 tidak masuk pada gambar di atas karena gambar di atas diambil sebelum penjelasan fitur 5.

7. Fitur untuk melihat transaksi customer (customer)
Pada halaman customer, maka customer bisa melihat riwayat transaksinya seperti ini :


Pada gambar di atas sudah ada pemesanan yang saya lakukan pada fitur nomor 5. Untuk Total Price itu akan tergenerate sendiri berdasarkan harga barang dikali jumlah yang diinginkan customer.

8. Fitur search produk (admin dan customer)
Saya menambahkan fitur search untuk memudahkan admin dan customer yang ingin mencari barang spesifik. Misal saya ingin search rubick 5x5 :


Maka akan ditampilkan semua barang dengan nama 5x5 :



Dokumentasi Source Code
1. Model
- Product_model.php

 <?php defined('BASEPATH') OR exit('No direct script access allowed');  
 class Product_model extends CI_Model  
 {  
   private $_table = "products";  
   public $product_id;  
   public $name;  
   public $price;  
   public $image = "default.jpg";  
   public $description;  
   public function rules()  
   {  
     return [  
       ['field' => 'name',  
       'label' => 'Name',  
       'rules' => 'required'],  
       ['field' => 'price',  
       'label' => 'Price',  
       'rules' => 'numeric'],  
       ['field' => 'description',  
       'label' => 'Description',  
       'rules' => 'required']  
     ];  
   }  
   public function getAll()  
   {  
     return $this->db->get($this->_table)->result();  
   }  
   public function getById($id)  
   {  
     return $this->db->get_where($this->_table, ["product_id" => $id])->row();  
   }  
   public function save()  
   {  
     $post = $this->input->post();  
     $this->product_id = uniqid();  
     $this->name = $post["name"];  
     $this->price = $post["price"];  
     $this->image = $this->_uploadImage();  
     $this->description = $post["description"];  
     return $this->db->insert($this->_table, $this);  
   }  
   public function update()  
   {  
     $post = $this->input->post();  
     $this->product_id = $post["id"];  
     $this->name = $post["name"];  
     $this->price = $post["price"];  
     if (!empty($_FILES["image"]["name"])) {  
       $this->image = $this->_uploadImage();  
     } else {  
       $this->image = $post["old_image"];  
     }  
     $this->description = $post["description"];  
     return $this->db->update($this->_table, $this, array('product_id' => $post['id']));  
   }  
   public function delete($id)  
   {  
     $this->_deleteImage($id);  
     return $this->db->delete($this->_table, array("product_id" => $id));  
   }  
   private function _uploadImage()  
   {  
     $config['upload_path']     = './upload/product/';  
     $config['allowed_types']    = 'gif|jpg|png';  
     $config['file_name']      = $this->product_id;  
     $config['overwrite']               = true;  
     $config['max_size']       = 1024; // 1MB  
     // $config['max_width']      = 1024;  
     // $config['max_height']      = 768;  
     $this->load->library('upload', $config);  
     if ($this->upload->do_upload('image')) {  
       return $this->upload->data("file_name");  
     }  
   return "default.jpg";  
   }  
   private function _deleteImage($id)  
   {  
     $product = $this->getById($id);  
     if ($product->image != "default.jpg") {  
       $filename = explode(".", $product->image)[0];  
       return array_map('unlink', glob(FCPATH."upload/product/$filename.*"));  
     }  
   }  
   public function search($search)  
   {  
     $this->db->select('*');  
     $this->db->from('products');  
     $this->db->like('name',$search);  
     // $this->db->or_like('fname',$search);  
     // $this->db->or_like('lname',$search);  
     // $this->db->or_like('mname',$search);  
     $query = $this->db->get();  
     return $query->result();  
   }  
 }  

- User_model.php

 <?php  
 class User_model extends CI_Model  
 {  
   private $_table = "users";  
   public function doLogin(){  
           $post = $this->input->post();  
     // cari user berdasarkan email dan username  
     $this->db->where('email', $post["email"])  
         ->or_where('username', $post["email"]);  
     $user = $this->db->get($this->_table)->row();  
     // jika user terdaftar  
     if($user){  
       // periksa password-nya  
       $isPasswordTrue = password_verify($post["password"], $user->password);  
       // periksa role-nya  
       $isAdmin = $user->role == "admin";  
       $isUser = $user->role == "customer";  
       // jika password benar dan dia admin  
       if($isPasswordTrue && $isAdmin){   
         // login sukses yay!  
         $this->session->set_userdata(['user_logged' => $user]);  
         $this->session->set_userdata('username', $user->username);  
         $this->session->set_userdata('role', $user->role);  
         $this->_updateLastLogin($user->user_id);  
         return true;  
       }  
       if($isPasswordTrue && $isUser){  
         $this->session->set_userdata(['user_logged' => $user]);  
         $this->session->set_userdata('username', $user->username);  
         $this->session->set_userdata('role', $user->role);  
         $this->session->set_userdata('user_id', $user->user_id);  
         $this->_updateLastLogin($user->user_id);  
         return true;  
       }  
     }  
     // login gagal  
           return false;  
   }  
   public function isNotLogin(){  
     return $this->session->userdata('user_logged') === null;  
   }  
   private function _updateLastLogin($user_id){  
     $sql = "UPDATE {$this->_table} SET last_login=now() WHERE user_id={$user_id}";  
     $this->db->query($sql);  
   }  
 }  

- Transaction_model.php

 <?php defined('BASEPATH') OR exit('No direct script access allowed');  
 class Transaction_model extends CI_Model  
 {  
   private $_table = "transactions";  
   public $id_transactions;  
   public $product_id;  
   public $user_id;  
   public $alamat;  
   public $kodepos;  
   public $jumlah;  
   public $total_harga;  
   public $transaction_made;  
   public function rules()  
   {  
     return [  
       ['field' => 'alamat',  
       'label' => 'Alamat',  
       'rules' => 'required'],  
       ['field' => 'kodepos',  
       'label' => 'Kodepos',  
       'rules' => 'required'],  
       ['field' => 'jumlah',  
       'label' => 'Jumlah',  
       'rules' => 'numeric'],  
     ];  
   }  
   public function getAll()  
   {  
     return $this->db->get($this->_table)->result();  
   }  
   public function getById($id)  
   {  
     return $this->db->get_where($this->_table, ["user_id" => $id])->result();  
   }  
   public function save($id, $harga)  
   {  
     $post = $this->input->post();  
     $this->id_transactions = uniqid();  
     $this->product_id = $id;  
     $this->user_id = $this->session->userdata('user_id');  
     $this->alamat = $post["alamat"];  
     $this->kodepos = $post["kodepos"];  
     $this->jumlah = $post["jumlah"];  
     $this->total_harga = ($post["jumlah"]) * $harga;  
     return $this->db->insert($this->_table, $this);  
   }  
 }  

2. Controller
- Login.php

 <?php  
 class Login extends CI_Controller  
 {  
   public function __construct()  
   {  
     parent::__construct();  
     $this->load->model("user_model");  
     $this->load->library('form_validation');  
   }  
   public function index()  
   {  
     // jika form login disubmit  
     if($this->input->post()){  
       if($this->user_model->doLogin()) redirect(site_url('admin'));  
     }  
     // tampilkan halaman login  
     $this->load->view("admin/login_page.php");  
   }  
   public function logout()  
   {  
     // hancurkan semua sesi  
     $this->session->sess_destroy();  
     redirect(site_url('admin/login'));  
   }  
 }  

- Overview.php

 <?php  
 class Overview extends CI_Controller {  
   public function __construct()  
   {  
           parent::__construct();  
           $this->load->model("user_model");  
           if($this->user_model->isNotLogin()) redirect(site_url('admin/login'));  
      }  
      public function index()  
      {  
     // load view admin/overview.php  
     $this->load->view("admin/overview");  
      }  
 }  

- Products.php

 <?php  
 defined('BASEPATH') OR exit('No direct script access allowed');  
 class Products extends CI_Controller  
 {  
   public function __construct()  
   {  
     parent::__construct();  
     $this->load->model("product_model");  
     $this->load->model("transaction_model");  
     $this->load->library('form_validation');  
     $this->load->model("user_model");  
     if($this->user_model->isNotLogin()) redirect(site_url('admin/login'));  
   }  
   public function index()  
   {  
     $data["products"] = $this->product_model->getAll();  
     $this->load->view("admin/product/list", $data);  
   }  
   public function add()  
   {  
     $product = $this->product_model;  
     $validation = $this->form_validation;  
     $validation->set_rules($product->rules());  
     if ($validation->run()) {  
       $product->save();  
       $this->session->set_flashdata('success', 'Berhasil disimpan!');  
     }  
     $this->load->view("admin/product/new_form");  
   }  
   public function addTransaction($id = null)  
   {  
     $transaction = $this->transaction_model;  
     $product = $this->product_model;  
     $validation = $this->form_validation;  
     $validation->set_rules($transaction->rules());  
     $data = $product->getById($id);  
     if($validation->run()) {  
       $transaction->save($id, $data->price);  
       $this->session->set_flashdata('success', 'Berhasil disimpan!');  
     }  
     $dataa["products"] = $this->product_model->getAll();  
     $this->load->view("admin/product/list", $dataa);  
   }  
   public function edit($id = null)  
   {  
     if (!isset($id)) redirect('admin/products');  
     $product = $this->product_model;  
     $validation = $this->form_validation;  
     $validation->set_rules($product->rules());  
     if ($validation->run()) {  
       $product->update();  
       $this->session->set_flashdata('success', 'Berhasil disimpan');  
     }  
     $data["product"] = $product->getById($id);  
     if (!$data["product"]) show_404();  
     $this->load->view("admin/product/edit_form", $data);  
   }  
   public function buy($id = null)  
   {  
     if (!isset($id)) redirect('admin/products');  
     $product = $this->product_model;  
     $data["product"] = $product->getById($id);  
     if (!$data["product"]) show_404();  
     $this->load->view("admin/product/new_transaction", $data);  
   }  
   public function delete($id=null)  
   {  
     if (!isset($id)) show_404();  
     if ($this->product_model->delete($id)) {  
       redirect(site_url('admin/products'));  
     }  
   }  
   public function search()  
   {  
     $this->load->model('product_model');  
     $search = $this->input->post('search');  
     $data['products'] = $this->product_model->search($search);  
     $this->load->view("admin/product/list", $data);  
   }  
   public function transactions()  
   {  
     $data["transactions"] = $this->transaction_model->getAll();  
     $this->load->view("admin/product/transaction", $data);  
   }  
   public function mytransactions()  
   {  
     $data["transactions"] = $this->transaction_model->getById($this->session->userdata('user_id'));  
     $this->load->view("admin/product/transaction", $data);  
   }  
 }  

3. View
- View Edit barang

 <!DOCTYPE html>  
 <html lang="en">  
 <head>  
      <?php $this->load->view("admin/_partials/head.php") ?>  
 </head>  
 <body id="page-top">  
      <?php $this->load->view("admin/_partials/navbar.php") ?>  
      <div id="wrapper">  
           <?php $this->load->view("admin/_partials/sidebar.php") ?>  
           <div id="content-wrapper">  
                <div class="container-fluid">  
                     <?php if ($this->session->flashdata('success')): ?>  
                     <div class="alert alert-success" role="alert">  
                          <?php echo $this->session->flashdata('success'); ?>  
                     </div>  
                     <?php endif; ?>  
                     <!-- Card -->  
                     <div class="card mb-3">  
                          <div class="card-header">  
                               <a href="<?php echo site_url('admin/products/') ?>"><i class="fas fa-arrow-left"></i>  
                                    Back</a>  
                          </div>  
                          <div class="card-body">  
                               <form action="" method="post" enctype="multipart/form-data">  
                               <!-- Note: atribut action dikosongkan, artinya action-nya akan diproses   
                                    oleh controller tempat vuew ini digunakan. Yakni index.php/admin/products/edit/ID --->  
                                    <input type="hidden" name="id" value="<?php echo $product->product_id?>" />  
                                    <div class="form-group">  
                                         <label for="name">Name*</label>  
                                         <input class="form-control <?php echo form_error('name') ? 'is-invalid':'' ?>"  
                                          type="text" name="name" placeholder="Product name" value="<?php echo $product->name ?>" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('name') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="price">Price</label>  
                                         <input class="form-control <?php echo form_error('price') ? 'is-invalid':'' ?>"  
                                          type="number" name="price" min="0" placeholder="Product price" value="<?php echo $product->price ?>" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('price') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="name">Photo</label>  
                                         <input class="form-control-file <?php echo form_error('image') ? 'is-invalid':'' ?>"  
                                          type="file" name="image" />  
                                         <input type="hidden" name="old_image" value="<?php echo $product->image ?>" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('image') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="name">Description*</label>  
                                         <textarea class="form-control <?php echo form_error('description') ? 'is-invalid':'' ?>"  
                                          name="description" placeholder="Product description..."><?php echo $product->description ?></textarea>  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('description') ?>  
                                         </div>  
                                    </div>  
                                    <input class="btn btn-success" type="submit" name="btn" value="Save" />  
                               </form>  
                          </div>  
                          <div class="card-footer small text-muted">  
                               * required fields  
                          </div>  
                     </div>  
                     <!-- /.container-fluid -->  
                     <!-- Sticky Footer -->  
                     <?php $this->load->view("admin/_partials/footer.php") ?>  
                </div>  
                <!-- /.content-wrapper -->  
           </div>  
           <!-- /#wrapper -->  
           <?php $this->load->view("admin/_partials/scrolltop.php") ?>  
           <?php $this->load->view("admin/_partials/js.php") ?>  
 </body>  
 </html>  

- View list barang

 <!DOCTYPE html>  
 <html lang="en">  
 <head>  
      <?php $this->load->view("admin/_partials/head.php") ?>  
 </head>  
 <body id="page-top">  
      <?php $this->load->view("admin/_partials/navbar.php") ?>  
      <div id="wrapper">  
      <?php $this->load->view("admin/_partials/sidebar.php") ?>  
           <div id="content-wrapper">  
                <div class="container-fluid">  
                     <!-- DataTables -->  
                     <div class="card mb-3">  
                     <?php if($this->session->userdata('role') == 'admin') { ?>  
                          <div class="card-header">  
                               <a href="<?php echo site_url('admin/products/add') ?>"><i class="fas fa-plus"></i> Add New</a>  
                          </div>  
                     <?php } ?>  
                          <div class="card-body">  
                               <div class="table-responsive">  
                                    <table class="table table-hover" id="dataTable" width="100%" cellspacing="0">  
                                         <thead>  
                                              <tr>  
                                                   <th>Name</th>  
                                                   <th>Price</th>  
                                                   <th>Photo</th>  
                                                   <th>Description</th>  
                                                   <th>Action</th>  
                                              </tr>  
                                         </thead>  
                                         <tbody>  
                                              <?php foreach ($products as $product): ?>  
                                              <tr>  
                                                   <td width="150">  
                                                        <?php echo $product->name ?>  
                                                   </td>  
                                                   <td>  
                                                        <?php echo $product->price ?>  
                                                   </td>  
                                                   <td>  
                                                        <img src="<?php echo base_url('upload/product/'.$product->image) ?>" width="64" />  
                                                   </td>  
                                                   <td class="small">  
                                                        <?php echo substr($product->description, 0, 120) ?>...</td>  
                                                   <?php if($this->session->userdata('role') == 'admin') { ?>  
                                                   <td width="250">  
                                                        <a href="<?php echo site_url('admin/products/edit/'.$product->product_id) ?>"  
                                                         class="btn btn-small"><i class="fas fa-edit"></i> Edit</a>  
                                                        <a onclick="deleteConfirm('<?php echo site_url('admin/products/delete/'.$product->product_id) ?>')"  
                                                         href="#!" class="btn btn-small text-danger"><i class="fas fa-trash"></i> Hapus</a>  
                                                   </td>  
                                                   <?php } ?>  
                                                   <?php if($this->session->userdata('role') == 'customer'){ ?>  
                                                   <td width="250">  
                                                        <a href="<?php echo site_url('admin/products/buy/'.$product->product_id) ?>"  
                                                         class="btn btn-small"><i class="fas fa-shopping-cart"></i>Buy</a>  
                                                   </td>  
                                                   <?php } ?>  
                                              </tr>  
                                              <?php endforeach; ?>  
                                         </tbody>  
                                    </table>  
                               </div>  
                          </div>  
                     </div>  
                </div>  
                <!-- /.container-fluid -->  
                <!-- Sticky Footer -->  
                <?php $this->load->view("admin/_partials/footer.php") ?>  
           </div>  
           <!-- /.content-wrapper -->  
      </div>  
      <!-- /#wrapper -->  
      <?php $this->load->view("admin/_partials/scrolltop.php") ?>  
      <?php $this->load->view("admin/_partials/modal.php") ?>  
      <?php $this->load->view("admin/_partials/js.php") ?>  
   <script>  
   function deleteConfirm(url){  
     $('#btn-delete').attr('href', url);  
     $('#deleteModal').modal();  
   }  
   </script>  
 </body>  
 </html>  

- View Form menambah produk

 <!DOCTYPE html>  
 <html lang="en">  
 <head>  
      <?php $this->load->view("admin/_partials/head.php") ?>  
 </head>  
 <body id="page-top">  
      <?php $this->load->view("admin/_partials/navbar.php") ?>  
      <div id="wrapper">  
           <?php $this->load->view("admin/_partials/sidebar.php") ?>  
           <div id="content-wrapper">  
                <div class="container-fluid">  
                     <?php if ($this->session->flashdata('success')): ?>  
                     <div class="alert alert-success" role="alert">  
                          <?php echo $this->session->flashdata('success'); ?>  
                     </div>  
                     <?php endif; ?>  
                     <div class="card mb-3">  
                          <div class="card-header">  
                               <a href="<?php echo site_url('admin/products/') ?>"><i class="fas fa-arrow-left"></i> Back</a>  
                          </div>  
                          <div class="card-body">  
                               <form action="<?php echo site_url('admin/products/add') ?>" method="post" enctype="multipart/form-data" >  
                                    <div class="form-group">  
                                         <label for="name">Name*</label>  
                                         <input class="form-control <?php echo form_error('name') ? 'is-invalid':'' ?>"  
                                          type="text" name="name" placeholder="Product name" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('name') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="price">Price*</label>  
                                         <input class="form-control <?php echo form_error('price') ? 'is-invalid':'' ?>"  
                                          type="number" name="price" min="0" placeholder="Product price" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('price') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="name">Photo</label>  
                                         <input class="form-control-file <?php echo form_error('price') ? 'is-invalid':'' ?>"  
                                          type="file" name="image" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('image') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="name">Description*</label>  
                                         <textarea class="form-control <?php echo form_error('description') ? 'is-invalid':'' ?>"  
                                          name="description" placeholder="Product description..."></textarea>  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('description') ?>  
                                         </div>  
                                    </div>  
                                    <input class="btn btn-success" type="submit" name="btn" value="Save" />  
                               </form>  
                          </div>  
                          <div class="card-footer small text-muted">  
                               * required fields  
                          </div>  
                     </div>  
                     <!-- /.container-fluid -->  
                     <!-- Sticky Footer -->  
                     <?php $this->load->view("admin/_partials/footer.php") ?>  
                </div>  
                <!-- /.content-wrapper -->  
           </div>  
           <!-- /#wrapper -->  
           <?php $this->load->view("admin/_partials/scrolltop.php") ?>  
           <?php $this->load->view("admin/_partials/js.php") ?>  
 </body>  
 </html>  

- View form transaksi

 <!DOCTYPE html>  
 <html lang="en">  
 <head>  
      <?php $this->load->view("admin/_partials/head.php") ?>  
 </head>  
 <body id="page-top">  
      <?php $this->load->view("admin/_partials/navbar.php") ?>  
      <div id="wrapper">  
           <?php $this->load->view("admin/_partials/sidebar.php") ?>  
           <div id="content-wrapper">  
                <div class="container-fluid">  
                     <?php if ($this->session->flashdata('success')): ?>  
                     <div class="alert alert-success" role="alert">  
                          <?php echo $this->session->flashdata('success'); ?>  
                     </div>  
                     <?php endif; ?>  
                     <div class="card mb-3">  
                          <div class="card-header">  
                               <a href="<?php echo site_url('admin/products/') ?>"><i class="fas fa-arrow-left"></i> Back</a>  
                          </div>  
                          <div class="card-body">  
                               <form action="<?php echo site_url('admin/products/addTransaction/'.$product->product_id) ?>" method="post" enctype="multipart/form-data" >  
                                    <div class="form-group">  
                                         <label for="alamat">Alamat*</label>  
                                         <input class="form-control <?php echo form_error('alamat') ? 'is-invalid':'' ?>"  
                                          type="text" name="alamat" placeholder="Enter Address" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('name') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="kodepos">Kode Pos*</label>  
                                         <input class="form-control <?php echo form_error('kodepos') ? 'is-invalid':'' ?>"  
                                          type="number" name="kodepos" min="0" placeholder="Enter Postal Code" />  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('kodepos') ?>  
                                         </div>  
                                    </div>  
                                    <div class="form-group">  
                                         <label for="jumlah">Jumlah*</label>  
                                         <textarea class="form-control <?php echo form_error('jumlah') ? 'is-invalid':'' ?>"  
                                          name="jumlah" placeholder="Product description..."></textarea>  
                                         <div class="invalid-feedback">  
                                              <?php echo form_error('jumlah') ?>  
                                         </div>  
                                    </div>  
                                    <input class="btn btn-success" type="submit" name="btn" value="Save" />  
                               </form>  
                          </div>  
                          <div class="card-footer small text-muted">  
                               * required fields  
                          </div>  
                     </div>  
                     <!-- /.container-fluid -->  
                     <!-- Sticky Footer -->  
                     <?php $this->load->view("admin/_partials/footer.php") ?>  
                </div>  
                <!-- /.content-wrapper -->  
           </div>  
           <!-- /#wrapper -->  
           <?php $this->load->view("admin/_partials/scrolltop.php") ?>  
           <?php $this->load->view("admin/_partials/js.php") ?>  
 </body>  
 </html>  

- View list transaksi

 <!DOCTYPE html>  
 <html lang="en">  
 <head>  
      <?php $this->load->view("admin/_partials/head.php") ?>  
 </head>  
 <body id="page-top">  
      <?php $this->load->view("admin/_partials/navbar.php") ?>  
      <div id="wrapper">  
           <?php $this->load->view("admin/_partials/sidebar.php") ?>  
           <div id="content-wrapper">  
                <div class="container-fluid">  
                     <!-- DataTables -->  
                     <div class="card mb-3">  
                          <div class="card-header">  
                               Daftar Transaksi  
                          </div>  
                          <div class="card-body">  
                               <div class="table-responsive">  
                                    <table class="table table-hover" id="dataTable" width="100%" cellspacing="0">  
                                         <thead>  
                                              <tr>  
                                                   <th>Product</th>  
                                                   <th>User ID</th>  
                                                   <th>Address</th>  
                                                   <th>Postal Code</th>  
                                                   <th>Amount</th>  
                                                   <th>Total Price</th>  
                                                   <th>Action</th>  
                                              </tr>  
                                         </thead>  
                                         <tbody>  
                                              <?php foreach ($transactions as $transaction): ?>  
                                              <tr>  
                                                   <td width="150">  
                                                        <?php       
                                                             $product = $this->product_model;   
                                                             $data = $product->getById($transaction->product_id);  
                                                             echo $data->name  
                                                        ?>  
                                                   </td>  
                                                   <td>  
                                                        <?php echo $transaction->user_id ?>  
                                                   </td>  
                                                   <td>  
                                                        <?php echo $transaction->alamat ?>  
                                                   </td>  
                                                   <td>  
                                                        <?php echo $transaction->kodepos ?>  
                                                   </td>  
                                                   <td>  
                                                        <?php echo $transaction->jumlah ?>  
                                                   </td>  
                                                   <td>  
                                                        <?php echo $transaction->total_harga ?>  
                                                   </td>  
                                                   <td>  
                                                        <?php echo $transaction->transaction_made ?>  
                                                   </td>  
                                              </tr>  
                                              <?php endforeach; ?>  
                                         </tbody>  
                                    </table>  
                               </div>  
                          </div>  
                     </div>  
                </div>  
                <!-- /.container-fluid -->  
                <!-- Sticky Footer -->  
                <?php $this->load->view("admin/_partials/footer.php") ?>  
           </div>  
           <!-- /.content-wrapper -->  
      </div>  
      <!-- /#wrapper -->  
      <?php $this->load->view("admin/_partials/scrolltop.php") ?>  
      <?php $this->load->view("admin/_partials/modal.php") ?>  
      <?php $this->load->view("admin/_partials/js.php") ?>  
   <script>  
   function deleteConfirm(url){  
     $('#btn-delete').attr('href', url);  
     $('#deleteModal').modal();  
   }  
   </script>  
 </body>  
 </html>  

- View login

 <!DOCTYPE html>  
 <html lang="en">  
 <head>  
   <meta charset="UTF-8">  
   <meta name="viewport" content="width=device-width, initial-scale=1.0">  
   <meta http-equiv="X-UA-Compatible" content="ie=edge">  
   <title>Login Admin</title>  
   <!-- Bootstrap core CSS-->  
   <link href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css') ?>" rel="stylesheet">  
 </head>  
 <body>  
   <div class="container">  
     <div class="row">  
       <div class="col-12 col-md-6 text-center mt-5 mx-auto p-4">  
         <h1 class="h2">Login</h1>  
         <!-- <p class="lead">Silahkan masuk ke Panel Admin</p> -->  
       </div>  
     </div>  
     <div class="row">  
       <div class="col-12 col-md-5 mx-auto mt-5">  
         <form action="<?= site_url('admin/login') ?>" method="POST">  
           <div class="form-group">  
             <label for="email">Email</label>  
             <input type="text" class="form-control" name="email" placeholder="Pakai username juga bisa.." required />  
           </div>  
           <div class="form-group">  
             <label for="password">Password</label>  
             <input type="password" class="form-control" name="password" placeholder="Password.." required />  
           </div>  
           <div class="form-group">  
             <div class="d-flex justify-content-between">  
               <div class="custom-control custom-checkbox">  
                 <input type="checkbox" class="custom-control-input" name="rememberme" id="rememberme" />  
                 <label class="custom-control-label" for="rememberme"> Ingat Saya</label>  
               </div>  
               <a href="<?= site_url('reset_password') ?>">Lupa Password?</a>  
             </div>  
           </div>  
           <div class="form-group">  
             <input type="submit" class="btn btn-success w-100" value="Login" />  
           </div>  
         </form>  
       </div>  
     </div>  
   </div>  
 </body>  
 </html>  

Sedangkan untuk code partial nya bisa dilihat disini : Full Source Code


Database 
- Product


- Transaction


- Users



Hosting

Untuk website ini sudah saya hosting dan bisa langsung login disini : Toko Rubick
Untuk username dan password :

Admin :
username : samuelmarcell21
password : petanikode

Customer :
username : samuelmarcell
password : 123

atau

username : samsammarcell
password : kopi



Comments

Popular posts from this blog

APSI 1 - Analisa Sistem Informasi Lazada

Tugas 3 PBKK