system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
cmd: 

Direktori : /home/pfhr/public_html/admin/classes/Model/
Upload File :
Current File : /home/pfhr/public_html/admin/classes/Model/MStudents.php

<?PHP
class Model_MStudents
{
	
	function showStudents()
	{
		$sql1="select * from student_table  order by student_icard ASC";
		$obj2=new Bin_Query();
		$obj2->executeQuery($sql1);
		return Display_DStudents::showStudents($obj2->records);
	}

	function showAddUser($errval)
	{
		$country="SELECT * FROM country_master_table";
		$obj=new Bin_Query();
		$obj->executeQuery($country);

		srand();
		$verifycode=substr(md5(rand(0,100000)),0,5);
		return Display_DStudents::showAddUser($obj->records,$verifycode,$errval);
	}
	
	function insert()
	{		
		$username=$_POST['txtusername'];
		$title=$_POST['txttitle'];
		$name=$_POST['txtname'];
		$of=$_POST['txtof'];
		$fname=$_POST['txtfname'];
		$dob=$_POST['txtdob'];
		$address=$_POST['txtaddress'];
		$phone=$_POST['txtphone'];
		$designation=$_POST['txtdesignation'];
		$co=$_POST['txtco'];
		$doj=$_POST['txtdoj'];
		$due=$_POST['txtdue'];
		$blood=$_POST['txtblood'];
		

		$uploaded_path = '../uploads/students/';
		$saved_path = 'uploads/students';
		//$saved_path1 = 'uploads/members_thumb';
		//$uploaded_path1 = '../uploads/members_thumb';
		
		if($_FILES['image']['size']>0)
		{	
			$headerimage = $uploaded_path."/".$_FILES['image']['name'];
			$savedpath = $saved_path."/".$_FILES['image']['name'];
			move_uploaded_file($_FILES['image']['tmp_name'],$headerimage);
			//list($img_w,$img_h, $type, $attr) = getimagesize($uploaded_path);
			//new Lib_ThumbImage('thumb',$headerimage,$uploaded_path1,40);
			//$savedpath1 = $saved_path1."/".$_FILES['image']['name'];
		}


		$obj = new Bin_Query();
		$insertmember="INSERT INTO `student_table`(`student_icard`, `student_title`, `student_name`, `student_of`, `student_fname`, `student_address`, `student_designation`, `student_blood`, `student_phone`, `student_co`, `student_doj`, `student_due`, `student_image`) VALUES ('$username','$title','$name','$of','$fname','$address','$designation','$blood','$phone','$co','$doj','$due','$savedpath')";
		if($obj->updateQuery($insertmember))
		{
			$_SESSION['message']="Student Added Sucessfully";
			header('Location:?do=students&action=add');
		}
	else
		{
			$_SESSION['error_message']="Process Failed";
			header('Location:?do=students&action=add');
			exit();
		}
	
	}
	
	

		
	function showEditDetail()
	{
		$userid=$_GET['id'];
		$obj1=new Bin_Query();
		$select="select * from student_table where student_icard='$userid'";
		$obj1->executeQuery($select);
		return $obj1->records[0];
	}

	

	function updateUser()
	{
		if(isset($_POST['update']))
		{
			//print_r($_POST);
			$usrid=(int)$_GET['usrid'];
			$icard=$_POST['txtusername'];
			$name=$_POST['txtname'];
			$of=$_POST['txtof'];
			$fname=$_POST['txtfname'];
			$dob=$_POST['txtdob'];
			$address=$_POST['txtaddress'];
			$phone=$_POST['txtphone'];
			$designation=$_POST['txtdesignation'];
			$co=$_POST['txtco'];
			$doj=$_POST['txtdoj'];
			$due=$_POST['txtdue'];
			$blood=$_POST['txtblood'];
			$usrid=$_POST['user_id'];
			$uploaded_path = '../uploads/students';
			$saved_path = 'uploads/students';
			$image=$_FILES['image']['name'];
			if($_FILES['image']['size']>0)
			{	
			////////////New Modification////////////
			$select="select * from student_table where student_icard='$usrid'";
			$obj1= new Bin_Query();
			$obj1->executeQuery($select);
			$mphotoM=$obj1->records[0]['student_image'];
			$mphoto='../'.$mphotoM.'';
			unlink($mphoto);		
			////////////New Modification////////////
			$headerimage = $uploaded_path."/".$_FILES['image']['name'];
			$savedpath = $saved_path."/".$_FILES['image']['name'];
			move_uploaded_file($_FILES['image']['tmp_name'],$headerimage);
			
			}
			else
			{
				$select="select * from student_table where student_icard='$usrid'";
				$obj1= new Bin_Query();
				$obj1->executeQuery($select);
				$savedpath=$obj1->records[0]['student_image'];

			}
			 $update="UPDATE `student_table` SET 
			 `student_icard`='$icard',
			 `student_title`='$title',
			 `student_name`='$name',
			 `student_of`='$of',
			 `student_fname`='$fname',
			 `student_address`='$address',
			 `student_designation`='$designation',
			 `student_blood`='$blood',
			 `student_phone`='$phone',
			 `student_co`='$co',
			 `student_doj`='$doj',
			 `student_due`='$due',
			 `student_image`='$savedpath' WHERE  student_icard='$usrid'";
			
			$obj=new Bin_Query();
			if($obj->updateQuery($update))
			{
					$_SESSION['message']='Student Updated Sucessfully';
					header('Location:?do=students');				 
			}
			else
			{
					$_SESSION['message']='Student Updated Sucessfully';
					header('Location:?do=students');
			}
		
		}
		
		if(isset($_POST['del']))
		{
			$usrid=$_POST['user_id'];
			$obj=new Bin_Query();
			$sql1="delete from student_table  WHERE student_icard='".$usrid."' ";
			
			////////////New Modification////////////
			$select="select * from student_table where student_icard='$usrid'";
			$obj1= new Bin_Query();
			$obj1->executeQuery($select);
			$mphotoM=$obj1->records[0]['student_image'];
			$mphoto='../'.$mphotoM.'';
			unlink($mphoto);			
			////////////New Modification////////////
				
			if($obj->updateQuery($sql1))
				{
					$_SESSION['message']='User Deleted Sucessfully';
					header('Location:?do=students');
				}					
			else
				{
					$_SESSION['error_message']='Please select the User(s) to be Deleted';
					header('Location:?do=students');
				}	

		}
		
		if(isset($_POST['delPIC']))
		{
			$usrid=$_POST['user_id'];
			$select="select * from student_table where student_icard='$usrid' ";
			$obj1= new Bin_Query();
			if($obj1->updateQuery($select))
				{
					$mphotoM=$obj1->records[0]['student_image'];
					$mphoto='../'.$mphotoM.'';
					unlink($mphoto);
					
					$obj12=new Bin_Query();
					$update="update student_table set student_image='' where student_icard='$usrid'";
					$obj12->executeQuery($update);
					
					$_SESSION['message']='Picture Deleted Sucessfully';
					header('Location:?do=students&action=edit&id='.$usrid.'');
				}					
			else
				{
					$_SESSION['error_message']='Please select the User(s) to be Deleted';
					header('Location:?do=students&action=edit&id=$usrid');
				}	

		}
	}
}
?>