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
<?PHP
class Model_MTeachers
{
function showTeachers()
{
$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()
{
$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/teachers/';
$saved_path = 'uploads/teachers';
//$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 `teacher_table`(`teacher_icard`, `teacher_title`, `teacher_name`, `teacher_of`, `teacher_fname`, `teacher_address`, `teacher_designation`, `teacher_blood`, `teacher_phone`, `teacher_co`, `teacher_doj`, `teacher_due`, `teacher_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=teachers&action=add');
}
else
{
$_SESSION['error_message']="Process Failed";
header('Location:?do=teachers&action=add');
exit();
}
}
function showEditDetail()
{
$userid=$_GET['id'];
$obj1=new Bin_Query();
$select="select * from teacher_table where teacher_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/teachers';
$saved_path = 'uploads/teachers';
$image=$_FILES['image']['name'];
if($_FILES['image']['size']>0)
{
////////////New Modification////////////
$select="select * from teacher_table where teacher_icard='$usrid'";
$obj1= new Bin_Query();
$obj1->executeQuery($select);
$mphotoM=$obj1->records[0]['teacher_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 teacher_table where teacher_icard='$usrid'";
$obj1= new Bin_Query();
$obj1->executeQuery($select);
$savedpath=$obj1->records[0]['teacher_image'];
}
$update="UPDATE `teacher_table` SET
`teacher_icard`='$icard',
`teacher_title`='$title',
`teacher_name`='$name',
`teacher_of`='$of',
`teacher_fname`='$fname',
`teacher_address`='$address',
`teacher_designation`='$designation',
`teacher_blood`='$blood',
`teacher_phone`='$phone',
`teacher_co`='$co',
`teacher_doj`='$doj',
`teacher_due`='$due',
`teacher_image`='$savedpath' WHERE teacher_icard='$usrid'";
$obj=new Bin_Query();
if($obj->updateQuery($update))
{
$_SESSION['message']='Student Updated Sucessfully';
header('Location:?do=teachers');
}
else
{
$_SESSION['message']='Student Updated Sucessfully';
header('Location:?do=teachers');
}
}
if(isset($_POST['del']))
{
$usrid=$_POST['user_id'];
$obj=new Bin_Query();
$sql1="delete from teacher_table WHERE teacher_icard='".$usrid."' ";
////////////New Modification////////////
$select="select * from teacher_table where teacher_icard='$usrid'";
$obj1= new Bin_Query();
$obj1->executeQuery($select);
$mphotoM=$obj1->records[0]['teacher_image'];
$mphoto='../'.$mphotoM.'';
unlink($mphoto);
////////////New Modification////////////
if($obj->updateQuery($sql1))
{
$_SESSION['message']='User Deleted Sucessfully';
header('Location:?do=teachers');
}
else
{
$_SESSION['error_message']='Please select the User(s) to be Deleted';
header('Location:?do=teachers');
}
}
if(isset($_POST['delPIC']))
{
$usrid=$_POST['user_id'];
$select="select * from teacher_table where teacher_icard='$usrid' ";
$obj1= new Bin_Query();
if($obj1->updateQuery($select))
{
$mphotoM=$obj1->records[0]['teacher_image'];
$mphoto='../'.$mphotoM.'';
unlink($mphoto);
$obj12=new Bin_Query();
$update="update teacher_table set teacher_image='' where teacher_icard='$usrid'";
$obj12->executeQuery($update);
$_SESSION['message']='Picture Deleted Sucessfully';
header('Location:?do=teachers&action=edit&id='.$usrid.'');
}
else
{
$_SESSION['error_message']='Please select the User(s) to be Deleted';
header('Location:?do=teachers&action=edit&id=$usrid');
}
}
}
}
?>