first commit
This commit is contained in:
94
application/controllers/Cart.php
Normal file
94
application/controllers/Cart.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Cart extends CI_Controller {
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('Barang');
|
||||
$this->load->model('Kategori');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$hd['title'] = "Toko Dzaky Mulya";
|
||||
$data['active'] = "None";
|
||||
$data['kategori'] = $this->Kategori->kategori_all();
|
||||
|
||||
$this->load->view('front/header',$hd);
|
||||
$this->load->view('front/shopstep');
|
||||
$this->load->view('front/Cart',$data);
|
||||
$this->load->view('front/footer');
|
||||
}
|
||||
|
||||
public function tambah()
|
||||
{
|
||||
$data = array(
|
||||
'id' => $_POST['id'],
|
||||
'name' => $_POST['nama'],
|
||||
'price' => $_POST['harga'],
|
||||
'qty' => $_POST['qty'],
|
||||
);
|
||||
//print_r($data);
|
||||
$this->cart->insert($data);
|
||||
redirect('product');
|
||||
}
|
||||
public function update(){
|
||||
$i= 0;
|
||||
foreach ($_POST as $p){
|
||||
$i= $i+1;
|
||||
$data = array(
|
||||
'rowid' => $p['rowid'],
|
||||
'qty' => $p['qty']
|
||||
);
|
||||
$this->cart->update($data);
|
||||
}
|
||||
redirect('product');
|
||||
}
|
||||
public function check_out(){
|
||||
//print_r($this->cart->contents());
|
||||
$this->load->view('front/Checkout');
|
||||
}
|
||||
public function check_out_conv(){
|
||||
$data['profile'] = array(
|
||||
'nama' => $_POST['nama'],
|
||||
'email' => $_POST['email'],
|
||||
'alamat' => $_POST['alamat'],
|
||||
'kota_kab' => $_POST['kota'],
|
||||
'provinsi' => $_POST['prov'],
|
||||
'telp' => $_POST['telp']
|
||||
);
|
||||
$data['transaksi'] = array(
|
||||
'tanggal_order' => date('Y-m-d'),
|
||||
'total_harga' => $this->cart->total(),
|
||||
'cara_bayar' => $_POST['cara_bayar'],
|
||||
'type' => $_POST['tipe'],
|
||||
'status' => 'PENDING'
|
||||
);
|
||||
$data['belanjaan'] = $this->cart->contents();
|
||||
//echo JSON_encode($data);
|
||||
$this->load->model('User');
|
||||
$this->load->model('Transaction');
|
||||
$idProf = $this->User->tambah_profil($data['profile']);
|
||||
if( $idProf != 0){
|
||||
$idTrans = $this->Transaction->tambah_trans($data['transaksi']);
|
||||
if( $idProf != 0){
|
||||
foreach ($data['belanjaan'] as $belanja){
|
||||
$sal = array(
|
||||
'pembeli' => $idProf,
|
||||
'transaksi' => $idTrans,
|
||||
'barang' => $belanja['id'],
|
||||
'qty' => $belanja['qty'],
|
||||
'tanggal' => date('Y-m-d')
|
||||
);
|
||||
$this->Transaction->tambah_sales($sal);
|
||||
$this->Barang->barang_sold($sal['barang'],$sal['qty']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
16
application/controllers/Member.php
Normal file
16
application/controllers/Member.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Member extends CI_Controller {
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('Barang');
|
||||
$this->load->model('Kategori');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
}
|
99
application/controllers/Product.php
Normal file
99
application/controllers/Product.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Product extends CI_Controller {
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->library('Pagination');
|
||||
$this->load->model('Barang');
|
||||
$this->load->model('Kategori');
|
||||
|
||||
}
|
||||
|
||||
public function index($kate = '')
|
||||
{
|
||||
if (empty($kate)){
|
||||
//ambil data kategori
|
||||
//ambil data semua barang
|
||||
//pagination
|
||||
|
||||
//$hd['title'] = "Toko Dzaky Mulya";
|
||||
//$data['active'] = "Produk";
|
||||
//$data['barang'] = $this->Barang->barang_all();
|
||||
//$data['kategori'] = $this->Kategori->kategori_all();
|
||||
|
||||
//$this->load->view('front/header',$hd);
|
||||
//$this->load->view('front/shopstep');
|
||||
//$this->load->view('front/produk',$data);
|
||||
//$this->load->view('front/footer');
|
||||
$this->paging();
|
||||
}
|
||||
else{
|
||||
echo $kate;
|
||||
$this->paging($kate);
|
||||
}
|
||||
}
|
||||
|
||||
public function paging($kat="")
|
||||
{
|
||||
$barang = $this->Barang->barang_all();
|
||||
$config['base_url'] = base_url()."index.php/product/paging";
|
||||
$config['total_rows'] = count($barang);
|
||||
$config['per_page'] = "6";
|
||||
$config["uri_segment"] = 3;
|
||||
$choice = $config["total_rows"] / $config["per_page"];
|
||||
$config["num_links"] = floor($choice);
|
||||
|
||||
$config['full_tag_open'] = "<ul class='pagination'>";
|
||||
$config['full_tag_close'] ="</ul>";
|
||||
$config['num_tag_open'] = '<li>';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
|
||||
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
|
||||
$config['next_tag_open'] = "<li>";
|
||||
$config['next_tagl_close'] = "</li>";
|
||||
$config['prev_tag_open'] = "<li>";
|
||||
$config['prev_tagl_close'] = "</li>";
|
||||
$config['first_tag_open'] = "<li>";
|
||||
$config['first_tagl_close'] = "</li>";
|
||||
$config['last_tag_open'] = "<li>";
|
||||
$config['last_tagl_close'] = "</li>";
|
||||
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
$data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
|
||||
$data['barang'] = $this->Barang->barang_all2($config["per_page"],$data['page']);
|
||||
|
||||
$hd['title'] = "Toko Dzaky Mulya";
|
||||
$data['active'] = "Produk";
|
||||
$data['kategori'] = $this->Kategori->kategori_all();
|
||||
$data['pagination'] = $this->pagination->create_links();
|
||||
|
||||
$this->load->view('front/header',$hd);
|
||||
$this->load->view('front/shopstep');
|
||||
$this->load->view('front/produk',$data);
|
||||
$this->load->view('front/footer');
|
||||
}
|
||||
|
||||
public function top_prodct(){
|
||||
//ambil data produk dengan sales paling banyak
|
||||
//buat
|
||||
}
|
||||
|
||||
public function new_prodct(){
|
||||
//ambil data produk dengan sales paling banyak
|
||||
//buat
|
||||
}
|
||||
|
||||
public function kategori($kat){
|
||||
//ambil data dengan kategori tertentu
|
||||
$w = array(
|
||||
'kategori' => $kat
|
||||
);
|
||||
$data = $this->barang->barang_cust($w);
|
||||
//tampilkan
|
||||
//pagination
|
||||
}
|
||||
}
|
44
application/controllers/User.php
Normal file
44
application/controllers/User.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class User extends CI_Controller {
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('UserModel');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$location = site_url('welcome');
|
||||
header("Location: ".$location);
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
$data['username'] = $_POST['username'];
|
||||
$data['password'] = $_POST['password'];
|
||||
$result = $this->UserModel->login($data);
|
||||
if (isset($result)){
|
||||
$newdata = array(
|
||||
'username' => $result->username,
|
||||
'type' => $result->type,
|
||||
'logged_in' => TRUE
|
||||
);
|
||||
$this->session->set_userdata($newdata);
|
||||
$location = site_url('welcome');
|
||||
header("Location: ".$location);
|
||||
}else{
|
||||
$location = site_url('welcome');
|
||||
header("Location: ".$location);
|
||||
}
|
||||
}
|
||||
|
||||
public function logout(){
|
||||
$deldata = array('username','type','logged_in');
|
||||
$this->session->unset_userdata($deldata);
|
||||
$location = site_url('welcome');
|
||||
header("Location: ".$location);
|
||||
}
|
||||
}
|
||||
?>
|
35
application/controllers/Welcome.php
Normal file
35
application/controllers/Welcome.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Welcome extends CI_Controller {
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
$this->load->model('Barang');
|
||||
$this->load->model('Kategori');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
//$this->load->view('welcome_message');
|
||||
//ambil data slideshow
|
||||
//ambil data hot produk
|
||||
//ambil data new produk
|
||||
//load view home
|
||||
// $a = array(
|
||||
// 'id' => 1
|
||||
// );
|
||||
// $d = $this->Barang->caribarang('a');
|
||||
// echo JSON_ENCODE($d);
|
||||
$hd['title'] = "Toko Dzaky Mulya";
|
||||
$ss['active'] = "Home";
|
||||
$data['kategori'] = $this->Kategori->kategori_all();
|
||||
$this->load->view('front/header',$hd);
|
||||
$this->load->view('front/slideshow',$ss);
|
||||
$this->load->view('front/Home',$data);
|
||||
$this->load->view('front/footer');
|
||||
|
||||
}
|
||||
}
|
11
application/controllers/index.html
Normal file
11
application/controllers/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
93
application/controllers/su/BarangAdm.php
Normal file
93
application/controllers/su/BarangAdm.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class BarangAdm extends CI_Controller {
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
if($this->session->userdata('logged_in')==false){
|
||||
$location = site_url('welcome');
|
||||
header("Location: ".$location);
|
||||
}
|
||||
$this->load->model('Barang');
|
||||
$this->load->model('Transaction');
|
||||
$this->load->model('Kategori');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$hd['title'] = "Barang - Toko Dzaky Mulya";
|
||||
$hd['User'] = $this->session->userdata('username');
|
||||
$sb['aktif'] = "Barang";
|
||||
$sb['order'] = $this->Transaction->pending_order();
|
||||
$data['table'] = $this->Barang->barang_all();
|
||||
|
||||
$this->load->view('back/header',$hd);
|
||||
$this->load->view('back/sidebar',$sb);
|
||||
$this->load->view('back/barang',$data);
|
||||
$this->load->view('back/footer');
|
||||
}
|
||||
|
||||
public function tambah()
|
||||
{
|
||||
$hd['title'] = "Tambah Barang - Toko Dzaky Mulya";
|
||||
$hd['User'] = $this->session->userdata('username');
|
||||
$sb['aktif'] = "Barang";
|
||||
$sb['order'] = $this->Transaction->pending_order();
|
||||
$data['kategori'] = $this->Kategori->loadkategori();
|
||||
|
||||
$this->load->view('back/header');
|
||||
$this->load->view('back/sidebar',$sb);
|
||||
$this->load->view('back/tambahBarang',$data);
|
||||
$this->load->view('back/footer');
|
||||
}
|
||||
|
||||
public function tambah_conf()
|
||||
{
|
||||
$data = array(
|
||||
'nama' => $_POST['nama'],
|
||||
'kdbarang' => $_POST['kode'],
|
||||
'harga' => $_POST['harga'],
|
||||
'deskripsi' => $_POST['desc'],
|
||||
'kategori' => $_POST['kat'],
|
||||
'tags' => $_POST['tag'],
|
||||
'stok' => $_POST['stok'],
|
||||
'last_update' => date('Y-m-d G:i:s')
|
||||
);
|
||||
if($this->Barang->tambahbarang($data)){
|
||||
echo "sukses";
|
||||
}else{
|
||||
redirect('Produk/Tambah');
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$data['kategori'] = $this->Barang->loadkategori();
|
||||
$where = array('id'=>$id);
|
||||
$data['barang'] = $this->Barang->barang_cust($where);
|
||||
$this->load->view('back/updateBarang',$data);
|
||||
}
|
||||
|
||||
public function update_conf()
|
||||
{
|
||||
$data = array(
|
||||
'nama' => $_POST['nama'],
|
||||
'kdbarang' => $_POST['kode'],
|
||||
'harga' => $_POST['harga'],
|
||||
'deskripsi' => $_POST['desc'],
|
||||
'kategori' => $_POST['kat'],
|
||||
'tags' => $_POST['tag'],
|
||||
'stok' => $_POST['stok'],
|
||||
'last_update' => date('Y-m-d G:i:s')
|
||||
);
|
||||
print_r($data);
|
||||
if($this->Barang->updatebarang($_POST['id'],$data)){
|
||||
echo "sukses";
|
||||
}else{
|
||||
redirect('Produk/update/1');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
39
application/controllers/su/Dashboard.php
Normal file
39
application/controllers/su/Dashboard.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Dashboard extends CI_Controller {
|
||||
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
if($this->session->userdata('logged_in')==false){
|
||||
$location = site_url('welcome');
|
||||
header("Location: ".$location);
|
||||
}
|
||||
$this->load->model('Transaction');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// echo "<ul>";
|
||||
// echo "<li><a href='".site_url('su/user/tambah')."'>Tambah User(general)</a></li>";
|
||||
// echo "<li><a href=''>View User</a></li>";
|
||||
// echo "<li><a href=''>Delete User User</a></li>";
|
||||
// echo "<li><a href=''>Update User User</a></li>";
|
||||
|
||||
// echo "<li><a href='".site_url('su/barang')."'>Barang</a></li>";
|
||||
// echo "<li><a href='".site_url('su/barang/tambah')."'>Tambah Barang</a></li>";
|
||||
// echo "<li><a href=''>Update Barang</a></li>";
|
||||
// echo "<li><a href=''>Delete Barang</a></li>";
|
||||
// echo "</ul>";
|
||||
//$this->load->view('back/dashboard');
|
||||
$sb['aktif'] = "Home";
|
||||
$sb['order'] = $this->Transaction->pending_order();
|
||||
$hd['title'] = "Dashboard Admin - Toko Dzaky Mulya";
|
||||
$hd['User'] = $this->session->userdata('username');
|
||||
$this->load->view('back/header',$hd);
|
||||
$this->load->view('back/sidebar',$sb);
|
||||
$this->load->view('back/dashboard');
|
||||
$this->load->view('back/footer');
|
||||
}
|
||||
}
|
52
application/controllers/su/Order.php
Normal file
52
application/controllers/su/Order.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Order extends CI_Controller {
|
||||
function __Construct()
|
||||
{
|
||||
parent ::__construct();
|
||||
if($this->session->userdata('logged_in')==false){
|
||||
$location = site_url('welcome');
|
||||
header("Location: ".$location);
|
||||
}
|
||||
$this->load->model('Barang');
|
||||
$this->load->model('Transaction');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$hd['title'] = "View Order - Toko Dzaky Mulya";
|
||||
$hd['User'] = $this->session->userdata('username');
|
||||
$sb['aktif'] = "Order";
|
||||
$sb['order'] = $this->Transaction->pending_order();
|
||||
$data['table'] = $this->Transaction->get_order();
|
||||
|
||||
$this->load->view('back/header',$hd);
|
||||
$this->load->view('back/sidebar',$sb);
|
||||
$this->load->view('back/order',$data);
|
||||
$this->load->view('back/footer');
|
||||
}
|
||||
|
||||
public function order_view($id)
|
||||
{
|
||||
$hd['title'] = "Order - Toko Dzaky Mulya";
|
||||
$hd['User'] = $this->session->userdata('username');
|
||||
$sb['aktif'] = "Order";
|
||||
$sb['order'] = $this->Transaction->pending_order();
|
||||
$data['data'] = $this->Transaction->get_single_order($id);
|
||||
$this->load->view('back/header',$hd);
|
||||
$this->load->view('back/sidebar',$sb);
|
||||
$this->load->view('back/vieworder',$data);
|
||||
$this->load->view('back/footer');
|
||||
}
|
||||
|
||||
public function update_order($id)
|
||||
{
|
||||
$this->Transaction->update_order($id,$_POST['status']);
|
||||
$location = site_url('su/order');
|
||||
header("Location: ".$location);
|
||||
die();
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user