Advertisement
cahyadsn

query CI get_Report_Penjualan

Jan 26th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. function get_Report_Penjualan() {
  2.     // VARIABEL
  3.     $faktur=$this->input->get('nofaktur');
  4.     $nota=$this->input->get('notaref');
  5.     $unit=$this->input->get('unit');
  6.     $customer=$this->input->get('customer');
  7.     $status=$this->input->get('status');
  8.     $operator=$this->input->get('operator');
  9.     $typebayar=$this->input->get('typebayar');
  10.     $fromdate=$this->input->get('fromdate');
  11.     $todate=$this->input->get('todate');
  12.     // QUERY REPORT
  13.     $this->db->select('a.*,b.customer_name,c.location_name,d.operator_name');
  14.     $this->db->from('TRANSACTION_HISTORY a');
  15.     $this->db->join('CUSTOMER b','a.customer_id=b.customer_id');
  16.     $this->db->join('LOCATION c','a.location_id=c.location_id');
  17.     $this->db->join('OPERATOR d','a.operator_id=d.operator_id');
  18.     //$this->db->or_where('transaction_type','Sell');
  19.     if(!empty($fromdate) && !empty($todate)){
  20.         $this->db->where("CONVERT(VARCHAR(10),transaction_date,120) >='$fromdate'
  21.                           AND CONVERT(VARCHAR(10),transaction_date,120) <='$todate'");
  22.     }
  23.     if(!empty($unit)){
  24.         $this->db->where('a.location_id',$unit);
  25.     }
  26.     if(!empty($customer)){
  27.         $this->db->where('a.customer_id',$customer);
  28.     }
  29.     if(!empty($status)) {
  30.         $this->db->where('transaction_status',$status);
  31.     }
  32.     if(!empty($operator)) {
  33.         $this->db->where('a.operator_id',$operator);
  34.     }
  35.     if(!empty($typebayar)) {
  36.         $this->db->where('transaction_payment_type',$typebayar);
  37.     }
  38.     if(!empty($nota)) {
  39.         $this->db->where('transaction_ref_note',$nota);
  40.     }
  41.     if(!empty($faktur)) {
  42.         $this->db->where('transaction_number',$faktur);
  43.     }
  44.     $this->db->order_by('transaction_date','DESC');
  45.     $query = $this->db->get();
  46.     return $query->result();
  47.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement