tripsdoc

Kasir.php

Dec 12th, 2016
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <?php
  2.  
  3. class Kasir extends Admin_Controller
  4. {
  5. public function __construct(){
  6. parent::__construct();
  7. if(!$this->session->userdata('username'))
  8. {
  9. redirect('login');
  10. }
  11. $this->load->model('Kasir_Model');
  12. }
  13. public function index()
  14. {
  15. $data['listBarang'] = $this->Kasir_Model->getAllBarang();
  16. $this->load->view('login/index', $data);
  17. }
  18. public function dataBarang()
  19. {
  20. $this->halaman = 'Data Barang';
  21. $halaman = $this->halaman;
  22. $this->load->helper('url');
  23.  
  24. $data = $this->db->get('barang')->result_array();
  25. $jumlah = $this->db->get('barang')->num_rows();
  26. $main_view = 'barang/tampil';
  27. $this->load->view('template', compact('halaman', 'main_view', 'data', 'jumlah'));
  28. }
  29. public function tambahBarang()
  30. {
  31. $this->halaman = 'Tambah Data Barang';
  32. $halaman = $this->halaman;
  33. $this->load->helper('url');
  34.  
  35. $heading = 'Tambah Data Barang';
  36. $main_view = 'barang/tambah';
  37. $this->load->view('template', compact('halaman', 'main_view'));
  38. }
  39. public function detailBarang($kode)
  40. {
  41. $this->halaman = 'Informasi Data Barang';
  42. $halaman = $this->halaman;
  43. $this->load->helper('url');
  44.  
  45. $heading = 'Informasi Data Barang';
  46. $data = $this->db->where('kode',$kode)->get('barang');
  47. $main_view = 'barang/informasi';
  48. $this->load->view('template', compact('halaman', 'main_view', 'data'));
  49. }
  50. public function ubahBarang($kode)
  51. {
  52. $this->halaman = 'Ubah Data Barang';
  53. $halaman = $this->halaman;
  54. $this->load->helper('url');
  55. $this->load->database();
  56.  
  57. $data = $this->db->where('kode',$kode)->get('barang');
  58. $main_view = 'barang/ubah';
  59. $this->load->view('template', compact('halaman', 'main_view', 'data'));
  60. }
  61. public function addBarangDb()
  62. {
  63. $data = array(
  64. 'kode' => $this->input->post('kode'),
  65. 'nama' => $this->input->post('nama'),
  66. 'harga' => $this->input->post('harga'),
  67. 'stok' => $this->input->post('stok'),
  68. 'gambar' => $this->input->post('gambar')
  69. );
  70. $this->Kasir_Model->addBarang($data);
  71.  
  72. redirect('kasir/dataBarang');
  73. }
  74. public function updateBarangDb()
  75. {
  76. $data = array(
  77. 'nama' => $this->input->post('nama'),
  78. 'harga' => $this->input->post('harga'),
  79. 'stok' => $this->input->post('stok')
  80. );
  81. $condition['kode'] = $this->input->post('kode');
  82. $this->Kasir_Model->updateBarang($data, $condition);
  83.  
  84. redirect('kasir/dataBarang');
  85. }
  86. public function deleteBarangDb($kode)
  87. {
  88. $this->Kasir_Model->deleteBarang($kode);
  89. redirect('kasir/dataBarang');
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment