Advertisement
timonte

controller_transaksi

May 15th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Transaksi extends CI_Controller {
  5.  
  6. function __construct()
  7. {
  8. parent::__construct();
  9. $this->load->library('template');
  10. $this->load->model('app_admin');
  11. }
  12.  
  13. public function index()
  14. {
  15. $this->cek_login();
  16. $select = ['id_order', 'tgl_pesan', 'bts_bayar', 'fullname', 'o.status AS status'];
  17. $table = "t_order o JOIN t_users u ON (o.id_user = u.id_user)";
  18. $data['data'] = $this->app_admin->select_all($select, $table);
  19.  
  20. $this->template->admin('admin/transaksi', $data);
  21. }
  22.  
  23. public function konfirmasi()
  24. {
  25. $this->cek_login();
  26.  
  27. if (!is_numeric($this->uri->segment(3)))
  28. {
  29. redirect('transaksi');
  30. }
  31.  
  32. $this->app_admin->update('t_order', ['status' => 'proses'], ['id_order' =>$this->uri->segment(3)]);
  33.  
  34. redirect('transaksi');
  35. }
  36.  
  37. public function delete()
  38. {
  39. $this->cek_login();
  40.  
  41. if (!is_numeric($this->uri->segment(3)))
  42. {
  43. redirect('transaksi');
  44. }
  45.  
  46. $this->app_admin->delete(['t_order', 't_detail_order'], ['id_order' =>$this->uri->segment(3)]);
  47.  
  48. redirect('transaksi');
  49. }
  50.  
  51. public function detail()
  52. {
  53. $this->cek_login();
  54.  
  55. if (!is_numeric($this->uri->segment(3)))
  56. {
  57. redirect('transaksi');
  58. }
  59. $select = ['o.id_order AS id_order', 'tgl_pesan', 'bts_bayar', 'fullname', 'o.status AS status', 'pos', 'service', 'kota', 'tujuan', 'total', 'biaya', 'kurir', 'nama_item', 'qty'];
  60.  
  61. $table = "t_order o JOIN t_detail_order do ON (o.id_order = do.id_order) JOIN t_users u ON (o.id_user = u.id_user) JOIN t_items i ON (do.id_item = i.id_item)";
  62. $data['data'] = $this->app_admin->select_where($select, $table, ['o.id_order' =>$this->uri->segment(3)]);
  63.  
  64. $this->template->admin('admin/detail_transaksi', $data);
  65. }
  66.  
  67. public function report()
  68. {
  69. $this->load->library('form_validation');
  70. $this->cek_login();
  71.  
  72. if ($this->input->post('submit', TRUE) == 'Submit')
  73. {
  74. $this->form_validation->set_rules('bln', 'Bulan', 'required|numeric');
  75. $this->form_validation->set_rules('thn', 'Tahun', 'required|numeric');
  76.  
  77. if ($this->form_validation->run() == TRUE)
  78. {
  79. $bln = $this->input->post('bln', TRUE);
  80. $thn = $this->input->post('thn', TRUE);
  81. }
  82.  
  83. } else {
  84. $bln = date('m');
  85. $thn = date('Y');
  86. }
  87. //YYYY-mm-dd
  88. $awal = $thn.'-'.$bln. '-01';
  89. $akhir = $thn.'-'.$bln. '-31';
  90. $where = ['tgl_pesan >=' => $awal, 'tgl_pesan <=' => $akhir, 'o.status' => 'proses'];
  91. $data['data'] = $this->app_admin->report($where);
  92. $data['bln'] = $bln;
  93. $data['thn'] = $thn;
  94.  
  95.  
  96. $this->template->admin('admin/laporan', $data);
  97. }
  98.  
  99. function cek_login()
  100. {
  101. if (!$this->session->userdata('admin'))
  102. {
  103. redirect('login');
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement