93 lines
2.3 KiB
PHP
93 lines
2.3 KiB
PHP
|
<?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');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
?>
|