<?php

class EmployeeSetup {

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

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


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

	public static function GetEmployeeSetupByMachineUserId($id) {

		global $db;
		$query = "SELECT * from ".TABLE_EMPLOYEESETUP." WHERE machine_userid ='$id'";
		//print($query);exit;
		$rows = $db->query_first($query);

		if($db->affected_rows > 0){

			return $rows;
		}else{

			return false;
		}
	}//Employee


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

	public static function GetMaxMachineIdFromEmployee() {

		global $db;
		$query = "SELECT MAX(machine_userid) AS machineid from ".TABLE_EMPLOYEESETUP." ";
		//print($query);exit;
		$rows = $db->query_first($query);

		if($db->affected_rows > 0){

			return $rows;
		}else{

			return false;
		}
	}//Attendance
	
	/**********************************************************
	/ This function will return EmployeeSetup
	**********************************************************/
		
	public static function GetEmployeeSetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_EMPLOYEESETUP." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//EmployeeSetup

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

?>
