Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Kasir extends Admin_Controller
- {
- public function __construct(){
- parent::__construct();
- if(!$this->session->userdata('username'))
- {
- redirect('login');
- }
- $this->load->model('Kasir_Model');
- }
- public function index()
- {
- $data['listBarang'] = $this->Kasir_Model->getAllBarang();
- $this->load->view('login/index', $data);
- }
- public function dataBarang()
- {
- $this->halaman = 'Data Barang';
- $halaman = $this->halaman;
- $this->load->helper('url');
- $data = $this->db->get('barang')->result_array();
- $jumlah = $this->db->get('barang')->num_rows();
- $main_view = 'barang/tampil';
- $this->load->view('template', compact('halaman', 'main_view', 'data', 'jumlah'));
- }
- public function tambahBarang()
- {
- $this->halaman = 'Tambah Data Barang';
- $halaman = $this->halaman;
- $this->load->helper('url');
- $heading = 'Tambah Data Barang';
- $main_view = 'barang/tambah';
- $this->load->view('template', compact('halaman', 'main_view'));
- }
- public function detailBarang($kode)
- {
- $this->halaman = 'Informasi Data Barang';
- $halaman = $this->halaman;
- $this->load->helper('url');
- $heading = 'Informasi Data Barang';
- $data = $this->db->where('kode',$kode)->get('barang');
- $main_view = 'barang/informasi';
- $this->load->view('template', compact('halaman', 'main_view', 'data'));
- }
- public function ubahBarang($kode)
- {
- $this->halaman = 'Ubah Data Barang';
- $halaman = $this->halaman;
- $this->load->helper('url');
- $this->load->database();
- $data = $this->db->where('kode',$kode)->get('barang');
- $main_view = 'barang/ubah';
- $this->load->view('template', compact('halaman', 'main_view', 'data'));
- }
- public function addBarangDb()
- {
- $data = array(
- 'kode' => $this->input->post('kode'),
- 'nama' => $this->input->post('nama'),
- 'harga' => $this->input->post('harga'),
- 'stok' => $this->input->post('stok'),
- 'gambar' => $this->input->post('gambar')
- );
- $this->Kasir_Model->addBarang($data);
- redirect('kasir/dataBarang');
- }
- public function updateBarangDb()
- {
- $data = array(
- 'nama' => $this->input->post('nama'),
- 'harga' => $this->input->post('harga'),
- 'stok' => $this->input->post('stok')
- );
- $condition['kode'] = $this->input->post('kode');
- $this->Kasir_Model->updateBarang($data, $condition);
- redirect('kasir/dataBarang');
- }
- public function deleteBarangDb($kode)
- {
- $this->Kasir_Model->deleteBarang($kode);
- redirect('kasir/dataBarang');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment