<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class ConsignorModel extends CI_Model{

	function __construct(){
		parent::__construct();
	}





		function selectCatInfo($type, $where){

    	if($where){
			$this->db->where($where);
		}

 	$query = $this->db->get($type);

		if($query){
			return $query->result();
		}else{
			return false;
		}
	}


	function selectInfo(){



$sql ="SELECT 	id,NAME,address,mobile_no,opening_date,creator_id_fk,current_datetime, gst_no, STATUS FROM consignor_tb ";


$query = $this->db->query($sql);
if($query){

//	print_r($query->result()); die;

return $query->result();

}else{
return false;
}


}


function selectInfoActive(){



	$sql ="SELECT 	id,NAME,address,mobile_no,opening_date,creator_id_fk,current_datetime, gst_no, STATUS FROM consignor_tb 
	 WHERE STATUS='active';";
	
	
	$query = $this->db->query($sql);
	if($query){
	
	//	print_r($query->result()); die;
	
	return $query->result();
	
	}else{
	return false;
	}
	
	
	}

function selectInfoBYID($id){



	$sql ="SELECT 	id, NAME, address, mobile_no, opening_date, creator_id_fk, current_datetime, gst_no, STATUS
	FROM consignor_tb WHERE NAME='".$id."' ";
	

	$query = $this->db->query($sql);
		
	
	if($query){
		
	
	return $query->result();
	
	}
	else{
	return false;
	}
	
	
	}



          // insert Query For Insert Data

	public function insertInfo($table, $data) {
		if ($this->db->insert($table, $data)) {
            $insert_id = $this->db->insert_id();
			return $insert_id;
		}else{
			return false;
		}
	}



    	function getInfoById($id){

    	 $sql ='SELECT 	id,NAME,address,mobile_no,opening_date,creator_id_fk,current_datetime, gst_no, STATUS FROM consignor_tb 
	   WHERE id ="'.$id.'" ';

      $query = $this->db->query($sql);

     //	print_r($query->result()); die;

          $result = $query->result();
    return $result;
}



// Update Query For Selected Student
function updateInfoById($id,$data){
$this->db->where('id', $id);
$this->db->update('consignor_tb', $data);
}


function deleteInfo($id)
{

 $sql ='DELETE FROM consignor_tb WHERE id= "'.$id.'"; ';  

$this->db->query($sql);
}


}



?>
