<?php

class LeaveSetup {

	/*************************************************
	/ This function add new Leave Setup
	*************************************************/
	
	public static function AddLeaveSetup($data) {
		global $db;
				
		$id = $db->query_insert(TABLE_LEAVE, $data);
		if($db->affected_rows > 0){
			//$db->query_insert("vrs_logs", $data);
			return $id;
		}else{
			return false;
		}
	
	} // AddLeave

	/*************************************************
	/ This function update Leave
	*************************************************/
	
	public static function UpdateLeaveSetup($pid,$data) {
		global $db;
		$id = $db->query_update(TABLE_LEAVE,$data,"id='$pid'");
		if($db->affected_rows > 0){
			//$db->query_insert("vrs_logs", $data);
			return $id;
		}else{
			return $id;
		}
	
	} // UpdateLeave


	public static function GetLeaveSetupById($id) {
		global $db;
		$query = "SELECT * from ".TABLE_LEAVE." WHERE id ='$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
                if($db->affected_rows > 0){
                        return $rows;
                }else{
                        return false;
                }
	}//LeaveSetup


	public static function CheckLeave($name, $id) {
		global $db;
		$query = "SELECT * from ".TABLE_LEAVE." WHERE name ='$name' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
                if($db->affected_rows > 0){
                        return $rows;
                }else{
                        return false;
                }
	}//LeaveSetupSetup
	
	/**********************************************************
	/ This function will return LeaveSetupSetup
	**********************************************************/

	public static function GetLeaveSetupList($filter="",$pageno="null",$pagesize="null") {

		global $db;
		$query = "SELECT * from ".TABLE_LEAVE." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);

		if($db->affected_rows > 0){

			return $rows;
		}else{

			return false;
		}
	}//LeaveSetupSetup

	public static function GetNumRows() { global $db; return $db->GetNumRows(); }
	public static function GetNumberOfPages() { global $db; return $db->GetNumberOfPages(); }
		
	
}

?>
