<?php 
class Designation_model extends CI_Model
{
	public function __construct()
	{
		$this->load->database();
	}	
	
	
	
 //data is retrieve from this query  


	public   function insert($data)
{
	$this->db->insert('designationMaster ',$data);
	//echo $data;;
}
public function fetch()  
      { 
		$this->db->select('*');
		$this->db->from('designationMaster');
		$this->db->where('activeStatus', '1');
		$query= $this->db->get();
		//echo $c=$query ->num_rows();
		return $query;
      }
	  	
		
		function delete($designationMasterId){
          	
			$data=array(
	 		'activeStatus'=>0
			);
            $this->db->where('designationMasterId',$designationMasterId); 
			
			          
            $this->db->update('designationMaster',$data);
        }
	function select($designationMasterId)
	{
		$this->db->select('designationMasterId');
		$this->db->where('designationMasterId',$designationMasterId);
		$q = $this->db->get('designationMaster');
		return $data = $q->result_array(); 
	
	}
	/*public function fetch()  
      {  
          
		$this->db->select('*'); 
		$this->db->from('designationMaster');
		$this->db->where('activeStatus',1);  
		 $query = $this->db->get();
		// $query=$this->db->query("select * from bank where status='1'" );
		
         //$query = $this->db->get('banktb');  
         return $query;
	  }*/
	function do_edit($designationName,$designationMasterId,$description,$cgn,$cn,$dn)
	{
		$data=array('designationName'=>$designationName,
		
		'designationMasterId'=>$designationMasterId,
		'description'=>$description,
		'companyGroupMasterId'=>$cgn,
		'companyMasterId'=>$cn,
		'departmentMasterId'=>$dn);
		$this->db->where('designationMasterId',$designationMasterId);
		$this->db->update('designationMaster',$data);
		
		if($this->db->affected_rows()>0)
		{
			echo"<script> alert('Data Updated')</script>";
		}

	}
	 public function cgname()  
	{  
	 
	// $query = $this->db->query('select * from pl_companyGroupMaster');
       
	  $query = $this->db->get('companyGroupMaster');  
										 
										
	   return $query;  
	}
		
 	 public function cname()  
	{  
	 
	// $query = $this->db->query('select * from pl_companyGroupMaster');
       
	  $query = $this->db->get('companyMaster');  
										 
										
	   return $query;  
	}
	 public function dpname()  
	{  
	 
	// $query = $this->db->query('select * from pl_companyGroupMaster');
       
	  $query = $this->db->get('departmentMaster');  
										 
									
	   return $query;  
	   
	}
	function update($id,$name){
	  // echo $id;
            $data = array(
			
                      'designationName' => $name,
					 
            );
	
        $this->db->where('designationMasterId', $id);
        $this->db->update('designationMaster', $data);
        
  
        }
		function getDeactiveData(){
            
			$this->db->where('activeStatus',0);
			$this->db->order_by("designationName", "asc");
			$query = $this->db->get('designationMaster');
            return $query;
        }
		
		function activate($designationMasterId){
		
			 $data=array(
	 		'activeStatus'=>1
			);
            $this->db->where('designationMasterId',$designationMasterId);          
            $this->db->update('designationMaster',$data);
        
	}
	
}
?>
