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/MCertificate.php

<?PHP
class Model_MCertificate
{
	
	function showCertificate()
	{
		$sql1="select * from teacher_table  order by teacher_icard ASC";
		$obj2=new Bin_Query();
		$obj2->executeQuery($sql1);
		return Display_DTeachers::showTeachers($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_DTeachers::showAddUser($obj->records,$verifycode,$errval);
	}
	
	function insert()
	{		
		$rollno=$_POST['txtusername'];
		$title=$_POST['txttitle'];
		$name=$_POST['txtname'];
		$of=$_POST['txtof'];
		$fname=$_POST['txtfname'];
		$center=$_POST['txtcenter'];
		$theory=$_POST['txttheory'];
		$drafting=$_POST['txtdrafting'];
		$practical=$_POST['txtpractical'];
		$marks=$_POST['txtmarks'];
		$grade=$_POST['txtgrade'];
		$teacher=$_POST['txtteacher'];
		$phone=$_POST['txtphone'];
		$doj=$_POST['txtdoj'];
		$cod=$_POST['txtcod'];
		$uploaded_path = '../uploads/certificate/';
		$saved_path = 'uploads/certificate';
		//$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 `certificate_table`(`certificate_rollno`, `certificate_title`, `certificate_name`, `certificate_of`, `certificate_oname`, `certificate_center`, `certificate_theory`, `certificate_drafting`, `certificate_practical`, `certificate_marks`, `certificate_grade`, `certificate_teacher`, `certificate_mobile`, `certificate_jod`, `certificate_cod`, `certificate_image`) VALUES ('$rollno','$title','$name','$of','$fname','$center','$theory','$drafting','$practical','$marks','$grade','$teacher','$phone','$doj','$cod','$savedpath')";
		if($obj->updateQuery($insertmember))
		{
			$_SESSION['message']="Certificate Added Sucessfully";
			header('Location:?do=certificate&action=add');
		}
	else
		{
			$_SESSION['error_message']="Process Failed";
			header('Location:?do=certificate&action=add');
			exit();
		}
	
	}
	
	

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

	

	function updateUser()
	{
		if(isset($_POST['update']))
		{
			//print_r($_POST);
			$usrid=(int)$_GET['usrid'];
			$rollno=$_POST['txtusername'];
			$title=$_POST['txttitle'];
			$name=$_POST['txtname'];
			$of=$_POST['txtof'];
			$fname=$_POST['txtfname'];
			$center=$_POST['txtcenter'];
			$theory=$_POST['txttheory'];
			$drafting=$_POST['txtdrafting'];
			$practical=$_POST['txtpractical'];
			$marks=$_POST['txtmarks'];
			$grade=$_POST['txtgrade'];
			$teacher=$_POST['txtteacher'];
			$phone=$_POST['txtphone'];
			$doj=$_POST['txtdoj'];
			$cod=$_POST['txtcod'];

			$usrid=$_POST['user_id'];
			$uploaded_path = '../uploads/certificate';
			$saved_path = 'uploads/certificate';
			$image=$_FILES['image']['name'];
			if($_FILES['image']['size']>0)
			{	
			////////////New Modification////////////
			$select="select * from certificate_table where certificate_rollno='$usrid'";
			$obj1= new Bin_Query();
			$obj1->executeQuery($select);
			$mphotoM=$obj1->records[0]['certificate_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 certificate_table where certificate_rollno='$usrid'";
				$obj1= new Bin_Query();
				$obj1->executeQuery($select);
				$savedpath=$obj1->records[0]['certificate_image'];

			}
			 $update="UPDATE `certificate_table` SET 
			 `certificate_rollno`='$rollno',
			 `certificate_title`='$title',
			 `certificate_name`='$name',
			 `certificate_of`='$of',
			 `certificate_oname`='$fname',
			 `certificate_center`='$center',
			 `certificate_theory`='$theory',
			 `certificate_drafting`='$drafting',
			 `certificate_practical`='$practical',
			 `certificate_marks`='$marks',
			 `certificate_grade`='$grade',
			 `certificate_teacher`='$teacher',
			 `certificate_mobile`='$phone',
			 `certificate_jod`='$doj',
			 `certificate_cod`='$cod',
			 `certificate_image`='$savedpath' WHERE `certificate_rollno`='$usrid'";
			
			$obj=new Bin_Query();
			if($obj->updateQuery($update))
			{
					$_SESSION['message']='Certificate Updated Sucessfully';
					header('Location:?do=certificate');				 
			}
			else
			{
					$_SESSION['message']='Certificate Updated Sucessfully';
					header('Location:?do=certificate');
			}
		
		}
		
		if(isset($_POST['del']))
		{
			$usrid=$_POST['user_id'];
			$obj=new Bin_Query();
			$sql1="delete from certificate_table  WHERE certificate_rollno='".$usrid."' ";
			
			////////////New Modification////////////
			$select="select * from certificate_table where certificate_rollno='$usrid'";
			$obj1= new Bin_Query();
			$obj1->executeQuery($select);
			$mphotoM=$obj1->records[0]['certificate_image'];
			$mphoto='../'.$mphotoM.'';
			unlink($mphoto);			
			////////////New Modification////////////
				
			if($obj->updateQuery($sql1))
				{
					$_SESSION['message']='certificate Deleted Sucessfully';
					header('Location:?do=certificate');
				}					
			else
				{
					$_SESSION['error_message']='Please select the User(s) to be Deleted';
					header('Location:?do=certificate');
				}	

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

		}
	}
}
?>