<?php 
		
	class admin
	{//Class 'admin' Opens Here
		private $pageSize = 5;
		//Version(1.1) public function checkLoginId($loginId,$con)
		public function checkLoginId($loginId,$con)
		{//Function 'checkLoginId' Opens Here
		
			$sql1 = "select count(*) from admindetails where loginid = '".$loginId."'";	
			$recordSet1 = mysql_query($sql1,$con);
			$count1 = 0;
			while($row1 = mysql_fetch_array($recordSet1))
			{
				$count1 = $row1[0];
				if($count1 > 0)
				{
					return true;
				}
				else
				{
					return false;
				}
				
			}					
	
		}//Function 'checkLoginId' Closes Here
	
		//Declaring Variavles
	    //(1.0)public function getAdminId($loginId,$con)--Returns Integer
		public function getAdminId($loginId,$con)
		{//Function 'getAdminId' Opens Here
			$sql2 = "select adminid from admindetails where loginid = '".$loginId."'";
			$recordSet2 = mysql_query($sql2,$con);
			$adminId2 = 0;
			while($row2 = mysql_fetch_array($recordSet2))
			{
				$adminId2 = $row2["adminid"];
			}
			return $adminId2;
		}//Function 'getAdminId' Closes Here

		//(1.0)public function validateLogin($loginId,$password,$con)--Returns string
		public function validateLogin($loginId,$password,$con)
		{//Function 'validateLogin' Opens Here
			$loginIdExistence = $this->checkLoginId($loginId,$con);
			if($loginIdExistence)
			{
				$sql4 = "select password from admindetails where loginid = '".$loginId."'";
				$recordSet4 = mysql_query($sql4,$con);
				$dbPassword4;
				while($row4 = mysql_fetch_array($recordSet4))
				{
					$dbPassword4 = $row4["password"];
				}
				if($dbPassword4 == $password)
				{
					return "Correct";
				}
				else
				{
					return "Incorect%20Password";
				}
			}
			else
			{
				return "LoginId%20DoesNot%20Exits";
			}
		}//Function 'validateLogin' Closes Here
		//(1.0)public function setSignOutTime($adminId,$con)--Returns True/False
		public function setSignOutTime($adminId,$con)
		{//Function 'setSignOutTime' Opens Here
			$sql5 = "update admindetails set dols = now() where adminid = $adminId";
			$rowsAffected5 = 0;
			mysql_query($sql5,$con);
			$rowsAffected5 = mysql_affected_rows();
			if($rowsAffected5 > 0)
			{
				return true;
			}
			else
			{
			return false;
			}
		}//Function 'setSignOutTime' Closes Here
		//(1.0)public function getAdminDetails($adminId,$con)--Returns Recordset
		public function getAdminDetails($adminId,$con)
		{//Function 'getAdminDetails' Opens Here
			$sql3 = "select * from admindetails where adminid = $adminId";
			$recordSet3 = mysql_query($sql3,$con);
			return $recordSet3;
		}//Function 'getAdminDetails' Closes Here

		//(1.0)public function getAllAdminDetails($con)--Returns Recordset
		public function getAllAdminDetails($con)
		{//Function 'getAdminDetails' Opens Here
			$sql16 = "select * from admindetails";
			echo $sql16;
			$recordSet16 = mysql_query($sql16,$con);
			return $recordSet16;
		}//Function 'getAdminDetails' Closes Here

		//(1.1)public function insertNewUser($category,$name,$userName,$password,$con)
		public function insertNewUser($category,$name,$userName,$password,$con)
		{//Function 'insertNewUser' Opens Here
			$sql11 = "insert into admindetails(category,name,loginid,password) values('".$category."','".$name."','".$userName."','".$password."')";
			//echo $sql11;
			$rowsAffected11 = 0;
			mysql_query($sql11,$con);
			$rowsAffected11 = mysql_affected_rows();
			if($rowsAffected11 > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}//Function 'insertNewUser' Closes Here

		//(1.0)public function insertAdminDetails($adminId,$name,$gender,$email,$mobile,$con)
		public function insertAdminDetails($adminId,$name,$gender,$email,$mobile,$con)
		{//Function 'insertAdminDetails' Opens Here
			$sql6 = "update admindetails set name = '".$name."',gender = '".$gender."',email = '".$email."',mobile = $mobile,doc = now(),dom = now() where adminid = $adminId ";
			//echo $sql6;
			 $rowsAffected6 = 0;
			mysql_query($sql6,$con);
			$rowsAffected6 = mysql_affected_rows();
			if($rowsAffected6 > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}//Function 'insertAdminDetails' Closes Here

		//(1.0)public function setAdminDetails($adminId,$name,$gender,$email,$mobile,$con)
		public function setAdminDetails($adminId,$name,$gender,$email,$mobile,$con)
		{//Function 'setAdminDetails' Opens Here
			$sql7 = "update admindetails set name = '".$name."',gender = '".$gender."',email = '".$email."',mobile = $mobile,doc = now(),dom = now() where adminid = $adminId ";
			//echo $sql7;
			$rowsAffected7 = 0;
			mysql_query($sql7,$con);
			$rowsAffected7 = mysql_affected_rows();
			if($rowsAffected7 > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}//Function 'setAdminDetails' Closes Here

		//(1.0)public function setPassword($adminId,$newPassword,$con)--Returns True/False
		public function setPassword($adminId,$newPassword,$con)
		{//Function 'setPassword' Opens Here
			$sql8 = "update admindetails set password = '".$newPassword."' where adminid = $adminId";
			$rowsAffected8 = 0;
			mysql_query($sql8,$con);
			$rowsAffected8 = mysql_affected_rows();
			if($rowsAffected8 > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}//Function 'setPassword' Closes Here

		public function insertFileDetails($admin_id,$uImage1,$cur_date,$con)
		{
			$sql9 = "insert into add_files(admin_id,file_name,cur_date,last_updated) values(".$admin_id.",'".mysql_real_escape_string($uImage1)."','".mysql_real_escape_string($cur_date)."',now())";
			$recordSet = mysql_query($sql9,$con);
			return $recordSet;
		}
		public function getAllAlerts1($search,$con)
		{//Function 'getAllAlerts' Opens Here
			//echo $search;
			$sql30 = "select id,file_name,DAY(last_updated) as day,MONTHNAME(last_updated) as month_name,year(last_updated) as date,cur_date from add_files";
			if($search != "")
			{
				$sql30 = $sql30." where cur_date = '$search' order by cur_date desc";
			}else
			{
				$sql30 = $sql30." order by cur_date desc";
			}
			//echo $sql30;
			$recordSet30 = mysql_query($sql30,$con);
			return $recordSet30;		
		}	
		public function getMaxRecord($con)
		{
			$sql31 = "SELECT * FROM add_files ORDER BY id DESC LIMIT 1";
			//echo $sql31;
			$recordSet31 = mysql_query($sql31,$con);
			return $recordSet31;
		}	
	}

?>