Do_a_sale

Download Raw Clone


  1. public function search_purchase(){
  2. $q = $this->input->get('q');
  3. if(strlen($q)>=2){
  4. $json = [];
  5. // $table = ['name'=>'products_purchase','type'=>'result'];
  6. // $where = ['available_quantity >'=>0];
  7. // $like = ['challan_no'=>$q];
  8. // $or_like['do_no']=$q;
  9. // 'product_type'=>$q,'date'=>$q];
  10. // $data = ['table'=>$table,'where'=>$where,'like'=>$like,'or_like'=>$or_like];
  11. // $products = $this->extract->retrieve($data);
  12. $array = array('challan_no' => $q, 'do_no' => $q, 'product_type' => $q, 'date' => $q);
  13. // $query = $this->db->where('available_quantity >',0)->like('challan_no',$q)->or_like('date',$q)->or_like('do_no',$q)->get('products_purchase');
  14. $query = $this->db->query("select * from products_purchase where available_quantity>0 and challan_no LIKE '%".$q."%' OR do_no LIKE '%".$q."%' OR date LIKE '%".$q."%' OR product_type LIKE '%".$q."%' ");
  15. foreach ($query->result() as $product):
  16. $text = $product->product_type. ' - '.$product->challan_no. ' - '.$product->date;
  17. $json[] = ['id'=>$product->id, 'text'=>$text];
  18. endforeach;
  19. echo json_encode($json);
  20. }
  21. exit;
  22. }

Raw paste data: