<?php

class HolidaySetup {

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

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


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


	public static function CheckHolidayAccount($date, $id) {
	
		global $db;
		$date = date("Y-m-d", strtotime($date));
		$query = "SELECT * from ".TABLE_HOLIDAYSETUP." WHERE ac_date ='$date' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Holiday
	
	/**********************************************************
	/ This function will return HolidaySetup
	**********************************************************/
		
	public static function GetHolidaySetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_HOLIDAYSETUP." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//HolidaySetup

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

?>
