<?php

 

class Manual_Query_With_Grn_Model extends CI_Model {

  

  

  function __construct() 

  {

    /* Call the Model constructor */

    parent::__construct();

  }


	function get_all_data() {
		$this->db->select('t.*');
		$this->db->from('upload t');
		
		//$this->db->order_by("t.id", "desc");
		//$this->db->where("t.category",$val);//("id !=",$id);
		$query = $this->db->get();
		//echo $this->db->last_query();
		return $query->result_array();
	}
	function get_updated_data() {
		$this->db->select('t.*');
		$this->db->from('updated t');
		
		//$this->db->order_by("t.id", "desc");
		//$this->db->where("t.category",$val);//("id !=",$id);
		$query = $this->db->get();
		//echo $this->db->last_query();
		return $query->result_array();
	}

	function save_data($supplier_data)
	{

			$this->db->insert('product',$supplier_data);
			//echo $this->db->last_query();

	}
	
	function update_product($product_id,$data)
   {
      $this->db->where('product_id', $product_id);
      $this->db->update('product', $data); 
      return $product_id;
   }
   
   function get_product_by_name($name='',$product_id='')
   {
     $this->db->select('p.*');
     $this->db->from('product p');
    
     $this->db->where('p.product_name',$name);
	 if($product_id){
	 $this->db->where_not_in("p.product_id",$product_id);
	 }
	  $this->db->order_by("p.product_name", "asc");
     $query = $this->db->get();  
     if($query->num_rows() >0)
     {
       return $query->row();
     }
     else
     {
       return false;
     }
   }
   function get_product_by_id($product_id)
   {
     $this->db->select('p.*');
     $this->db->from('product p');
     $this->db->where("p.product_id",$product_id);
	 $query = $this->db->get();  
     if($query->num_rows() >0)
     {
       return $query->row();
     }
     else
     {
       return false;
     }
   }

    function get_empty_coded_products()
   {
     $this->db->select('p.*');
     $this->db->from('product p');
     $this->db->where('p.product_code',"");
	  $this->db->order_by("p.product_name", "asc");
     $query = $this->db->get();  
     if($query->num_rows() >0)
     {
       return $query->result_array();
     }
     else
     {
       return false;
     }
   }

}