RommyRIsyandi

input pesanan

Aug 28th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.24 KB | None | 0 0
  1. // controller
  2. public function opesan()
  3.     {
  4.  
  5.         $data = array('id_pesanan' => $this->input->post('id_pesanan'),
  6.                       'no_meja' => $this->input->post('no_meja'),
  7.                       'tgl_pesan' => $this->input->post('tgl_pesan'),
  8.                       'total' => $this->input->post('total'));
  9.         $query = $this->kuale->insert('tb_pesanan', $data);
  10.         $this->kuale->selesai();
  11.         redirect('admin/pelayan');
  12.     }
  13. //view tpesan2.php
  14. <form>
  15.   <div class="col-xs-12 col-sm-12">
  16.     <table id="example2" class="table table-bordered table-hover table-striped" style="width: 100%">
  17.       <thead>
  18.     <th>Nomor Meja</th>
  19.     <th>Tanggal Order</th>
  20.     <th>Total Order</th>
  21.     <th>Aksi</th>
  22.   </thead>
  23.   <tbody>
  24.     <tr>
  25.       <?php
  26. $total=0;
  27. foreach ($detail->result() as $row => $r) {
  28. $total +=$r->subtotal;
  29. }
  30. ?>
  31. <?php echo form_open('admin/opesan'); ?>
  32. <td><select name="no_meja" class="form-control">
  33.   <option>Pilih No.Meja</option>
  34.   <option value="1">1</option>
  35.   <option value="2">2</option>
  36.   <option value="3">3</option>
  37.   <option value="4">4</option>
  38.   <option value="5">5</option>
  39.   <option value="6">6</option>
  40.   <option value="7">7</option>
  41.   <option value="8">8</option>
  42.   <option value="9">9</option>
  43.   <option value="10">10</option>
  44. </select></td>
  45.  
  46. <td><input type="date" name="tgl_order" id="tgl_order" required></td>
  47. <td><input type="text" name="total" class="subtotal_val" value="<?=$total ;?>" readonly></td>
  48. <td><button type="submit" onClick="return confirm('apakah anda sudah selesai menginput menu?')">Selesai</button></td></tr>
  49. <?php echo form_close(); ?>
  50.  
  51. <h4></h4>
  52. </tbody></table><br/>
  53. </div>
  54. </form>
  55.  
  56. //model
  57. <?php
  58. defined('BASEPATH') OR exit('No direct script access allowed');
  59.  
  60. class Kuale extends CI_Model {
  61.  
  62.     public function select($tabel,$where)
  63.     {
  64.         return $query = $this->db->get_where($tabel, $where);
  65.     }
  66.  
  67.     public function selectAll($tabel)
  68.     {
  69.         return $query = $this->db->get($tabel);
  70.     }
  71.  
  72.     public function update($tabel,$data,$where)
  73.     {
  74.         return $query = $this->db->update($tabel, $data, $where);
  75.     }
  76.  
  77.     public function delete($tabel,$where)
  78.     {
  79.         return $query = $this->db->delete($tabel, $where);
  80.     }
  81.     public function insert($tabel,$data)
  82.     {
  83.        
  84.         return $query =$this->db->insert($tabel, $data);
  85.     }
  86.  
  87.     public function proseslogin($username,$password)
  88.     {
  89.         $this->db->where('username', $username);
  90.         $this->db->where('password', $password);
  91.         return $this->db->get('user')->row();
  92.     }
  93.     public function getmenu()
  94.     {
  95.         $sql = "SELECT id_menu, nama_pesanan, harga_satuan, jml_porsi, (harga_satuan * jml_porsi) as subtotal FROM tb_detail_pesanan ORDER BY id_detail_pesanan ";
  96.         return $this->db->query($sql);
  97.     }
  98.     public function getsum()
  99.     {
  100.         $this->db->select_sum('subtotal', 'total');
  101.         $this->db->from('tb_detail_pesanan');
  102.         return $this->db->get('')->row();
  103.     }
  104.     public function selesai($data)
  105.     {
  106.         $this->db->insert('tb_pesanan', $data);
  107.         $last_id = $this->db->query("select id_pesanan from tb_pesanan order by id_pesanan desc")->row_array();
  108.         $this->db->query("update tb_detail_pesanan set id_pesanan='".$last_id['id_pesanan']."' where status='0'");
  109.         $this->db->query("update tb_detail_pesanan set status='1' where status='0'");  
  110.     }
  111. }
  112.  
  113. /* End of file kuale.php */
  114. /* Location: ./application/models/kuale.php */
Advertisement
Add Comment
Please, Sign In to add comment