<?php
class classUser
{
	private $staffID;
	private $staffType;
	private $firstName;
	private $lastName;
	private $email;
	private $phone;
	private $locationID;
	private $department=NULL;
	private $salary=NULL;
	private $joinDate=NULL;
	private $resignDate=NULL;
	private $active=NULL;
	
	
	######################################### SET FUNCTION ###################################################
	
	public function setStaffID($staffID)
	{
		if($staffID!="")
		{
			$this->staffID=$staffID;	
		}
		else
		{
			throw new MyException('Please select staff person.');
			
		}
	}
	
	public function setLocationID($locationID)
	{
		if($locationID!="")
		{
			$this->locationID=$locationID;	
		}
		else
		{
			throw new MyException('Please select location.');
			
		}
	}
	
	public function setfirstName($firstName)
	{
		if($firstName!="")
		{
			$this->firstName=$firstName;	
		}
		else
		{
			throw new MyException('Please select location.');
			
		}
	}
	
	public function setLocationID($locationID)
	{
		if($locationID!="")
		{
			$this->locationID=$locationID;	
		}
		else
		{
			throw new MyException('Please select location.');
			
		}
	}
	public function setLocationID($locationID)
	{
		if($locationID!="")
		{
			$this->locationID=$locationID;	
		}
		else
		{
			throw new MyException('Please select location.');
			
		}
	}
	public function setLocationID($locationID)
	{
		if($locationID!="")
		{
			$this->locationID=$locationID;	
		}
		else
		{
			throw new MyException('Please select location.');
			
		}
	}
	
	######################################### GET FUNCTION ###################################################
	
	
	public function getFirstName()
	{
		return $this->firstName;
	}
	
	public function getLastName()
	{
		return $this->lastName;
	}
	
	public function getEmail()
	{
		return $this->email;
	}
	
	public function getPhone()
	{
		return $this->phone;
	}
	
	
	public function getDiagnostic()
	{
		return $this->diagnostic;	
	}
	public function getOPD()
	{
		return $this->opd ;	
	}
	public function getIPD()
	{
		return $this->ipd;	
	}
	public function getPharmacy()
	{
		return $this->pharmacy;	
	}
	public function getOT()
	{
		return $this->ot;	
	}
	public function getEmergency()
	{
		return $this->emergency;	
	}
	public function getAdmin()
	{
		return $this->admin;	
	}
	
	public function getPatientRegFee()
	{
		if($this->patientRegFee!='')
		{
			return $this->patientRegFee;	
		}
		else
		{
			throw new MyException(103114);
		}
	}
	
	public function getNoOfLocations()
	{
		if($this->noOfLocations!='')
		{
			return $this->noOfLocations ;	
		}
		else
		{
			throw new MyException(103117);
		}
	}
	
	
	public function getLocCity()
	{
		return $this->locCity;	
	}
	public function getLocAddress()
	{
		return $this->locAddress;	
	}
	public function getLocPhone()
	{
		return $this->locPhone;	
	}
	public function getLocContactPerson()
	{
		return $this->locContactPerson;	
	}
	
	######################################### RETRIEVE FUNCTION ###################################################
	
	function retrieveUserAllDataByUserName($user_name)
	{
		$query="SELECT * FROM users WHERE user_name = '$user_name'";
		$queryOb = new classQueryGlobal;
		$row = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($row[0]))
		{
			$this->userID=$row[0]['user_id'];
			
			$this->userName=$row[0]['user_name']; 
			$this->password=$row[0]['password'];
			$this->userRoleID=$row[0]['userrole_id'];
			
			$this->firstName=$row[0]['fname'];
			$this->lastName=$row[0]['lname'];
			$this->email=$row[0]['email'];
			$this->phone=$row[0]['phone'];
			$this->organizationID=$row[0]['org_id'];
			$this->locationID=$row[0]['location_id'];
			
		}
	}
	
	function retrieveUserAllDataByUserID($user_id)
	{
		$query="SELECT * FROM users WHERE user_id = '$user_id'";
		$queryOb = new classQueryGlobal;
		$row = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($row[0]))
		{
			$this->userID=$row[0]['user_id'];
			
			$this->userName=$row[0]['user_name']; 
			$this->password=$row[0]['password'];
			$this->userRoleID=$row[0]['userrole_id'];
			
			$this->firstName=$row[0]['fname'];
			$this->lastName=$row[0]['lname'];
			$this->email=$row[0]['email'];
			$this->phone=$row[0]['phone'];
			$this->organizationID=$row[0]['org_id'];
			$this->locationID=$row[0]['location_id'];
		}
	}
	
	function searchUser($by_id=NULL,$by_name=NULL,$by_phone=NULL)
	{
		if($by_id!="")
		{
			$query = "SELECT * FROM users WHERE  user_id = '$by_id' order by time_stamp DESC";
		}
		elseif($by_name!="")
		{
			$query = "SELECT * FROM users WHERE (fname LIKE '%".$by_name."%') OR (lname LIKE '%".$by_name."%') order by time_stamp DESC"; 
		}
		elseif($by_phone!="")
		{
			$query = "SELECT * FROM users WHERE  phone LIKE '%".$by_phone."%' order by time_stamp DESC"; 
		}
		
		$queryOb = new classQueryGlobal;
		$user_details = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($user_details[0]['user_id'])&&$user_details[0]['user_id']!='')
		{
			return $user_details;
		}
	}
	  
	######################################### INSERT FUNCTION ###################################################
	
	
	######################################### UPDATE FUNCTION ###################################################
	
	
	######################################### DELETE FUNCTION ###################################################
	
}
?>