0byt3m1n1
Path:
C:
/
GEOMATICS 23-01-2021
/
LAN
/
CPMS
/
model
/
[
Home
]
File: employee_mdl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; require_once "defaultValues_mdl.php"; require_once BASE_DIR."/Proposels/imagePath.php"; class Employee { public function staffNameCheck($staffname) { try { $u_id=@$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; //$sql="select `emp_name` from employe where user_id='$u_id' and project_id='$p_id' and emp_name='$staffname'"; $sql="select `emp_name` from employe where user_id='$u_id' and emp_name='$staffname'"; mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch( Exception $ex) { echo $ex-> getMessage(); return null; } } //---------------Register new staff---------------- public function addStaff($empName,$empAddress,$empPhone,$empMobile,$designation,$JD,$ED,$empEmail,$empSalary,$temp_fn) { try{ $u_id=@$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $table_id=Common::getTableID("employe","emp_id"); $table_id=$table_id+1; $sql="INSERT INTO `employe` ( `emp_id` , `user_id` , `project_id` , `emp_name` , `address` , `phone` , `mobile` , `designation`, `join_date`, `validupto_date`, `mail_id` , `salary`, `photo` ) VALUES ( '$table_id','$u_id','$p_id','$empName','$empAddress','$empPhone', '$empMobile','$designation','$JD','$ED', '$empEmail', '$empSalary','$temp_fn' ) "; mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } } //---------------------------------------- //---------------Register new student---------------- public function addStudent($empName,$empAddress,$empPhone,$empEmail,$course,$college,$category,$JD,$ED,$title,$temp_fn,$remarks) { try{ $u_id=@$_SESSION['user_id']; //$p_id=@$_SESSION['project_id']; $table_id=Common::getTableID("student","s_id"); $table_id=$table_id+1; $sql="INSERT INTO `student` ( `s_id` , `user_id` , `name` , `address` , `phone` , `email` , `course` , `college` , `category`, `start_date` , `end_date` , `title` , `file` , `remarks` ) VALUES ( '$table_id', '$u_id', '$empName', '$empAddress', '$empPhone', '$empEmail', '$course', '$college', '$category', '$JD', '$ED', '$title', '$temp_fn', '$remarks' )"; //echo $sql;exit(); mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } } //---------------------------------------- public function userNameCheck($username) { try { //$u_id=@$_SESSION['user_id']; //$p_id=@$_SESSION['project_id']; $sql="select `user_name` from user where user_name='$username'"; mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch( Exception $ex) { echo $ex-> getMessage(); return null; } } //-------------------------------------------Register new user-----// public function addUser($username,$password,$email) { try{ //$u_id=@$_SESSION['user_id']; // $p_id=@$_SESSION['project_id']; $sql="INSERT INTO `user` ( `user_id` , `user_name` , `passwd` , `email` ) VALUES ( NULL ,'$username', '$password', '$email' ) "; mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } } //------------------// public function updateuser($edituserid,$editusername,$editpasswd,$editemail,$verify_date) { try{ if ($verify_date != "" and $editpasswd != "") { $sql="update `user` set `user_name`='".$editusername."' , `passwd`='".$editpasswd."' ,`email`= '".$editemail."' , `verify_date`= '".$verify_date."' where `user_id`='".$edituserid."'"; } if ($verify_date != "" and $editpasswd == "") { $sql="update `user` set `user_name`='".$editusername."' , `email`= '".$editemail."' , `verify_date`= '".$verify_date."' where `user_id`='".$edituserid."'"; } if ($verify_date == "" and $editpasswd != "") { $sql="update `user` set `user_name`='".$editusername."' , `passwd`='".$editpasswd."' ,`email`= '".$editemail."' where `user_id`='".$edituserid."'"; } if ($verify_date == "" and $editpasswd == "") { $sql="update `user` set `user_name`='".$editusername."' , `email`= '".$editemail."' where `user_id`='".$edituserid."'"; } mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } } //------------------Update student details------------------ public function UpdateStudent($editempid,$editempName,$editempAddress,$editempPhone,$editempEmail,$editCourse,$editCollege,$editCategory,$editJD,$editED,$editTitle,$editRemarks,$temp_fn_restore,$old_photo_name) {//179 try{ $u_id=@$_SESSION['user_id']; if ($temp_fn_restore=="") // no photo selected { $sql="UPDATE `student` SET `name` = '".$editempName."', `address` = '".$editempAddress."', `phone` = '".$editempPhone."', `email` = '".$editempEmail."', `course` = '".$editCourse."', `college` = '".$editCollege."', `category` = '".$editCategory."', `start_date` = '".$editJD."', `end_date` = '".$editED."', `title` = '".$editTitle."', `remarks` = '".$editRemarks."' WHERE `s_id` ='".$editempid."'" ; } else { $sql="UPDATE `student` SET `name` = '".$editempName."', `address` = '".$editempAddress."', `phone` = '".$editempPhone."', `email` = '".$editempEmail."', `course` = '".$editCourse."', `college` = '".$editCollege."', `category` = '".$editCategory."', `start_date` = '".$editJD."', `end_date` = '".$editED."', `title` = '".$editTitle."', `file` = '".$temp_fn_restore."', `remarks` = '".$editRemarks."' WHERE `s_id` ='".$editempid."'" ; //delete old photo if($temp_fn_restore != $old_photo_name) { $DelFilePath = ROOT_DIR . $old_photo_name; if (file_exists($DelFilePath)) { unlink ($DelFilePath); } } } mysql_query($sql); if (mysql_affected_rows()>0) { //---------------------------------- return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } }//179 //-------------------------Update student details--------------------------- public function UpdateEmployee($editempid,$editempName,$editempAddress,$editempPhone,$editempMobile,$editdesignation,$editJD,$editED,$editempEmail,$editempSalary,$temp_fn_restore,$old_emp_name,$old_photo_name,$status) {//179 try{ $p_id=@$_SESSION['project_id']; $u_id=@$_SESSION['user_id']; if ($temp_fn_restore=="") // no photo selected { $sql="update `employe` set `emp_name`='".$editempName."' , `address`= '".$editempAddress."', `phone`= '".$editempPhone."', `mobile` ='".$editempMobile."', `designation`='".$editdesignation."', `join_date` ='".$editJD."', `validupto_date` ='".$editED."', `mail_id`='".$editempEmail."' , `salary`='".$editempSalary."' , `status`='".$status."' where `emp_id`='".$editempid."'"; } else { $sql="update `employe` set `emp_name`='".$editempName."' , `address`= '".$editempAddress."', `phone`= '".$editempPhone."', `mobile` ='".$editempMobile."', `designation`='".$editdesignation."', `join_date` ='".$editJD."', `validupto_date` ='".$editED."', `mail_id`='".$editempEmail."' , `salary`='".$editempSalary."', `photo`='".$temp_fn_restore."', `status`='".$status."' where `emp_id`='".$editempid."'"; //delete old photo if($temp_fn_restore != $old_photo_name) { $DelFilePath = ROOT_DIR . $old_photo_name; if (file_exists($DelFilePath)) { unlink ($DelFilePath); } } } mysql_query($sql); if (mysql_affected_rows()>0) { //update in other tables //account $sql="update `account` set `account_name`='".$editempName."' where user_id ='$u_id' and project_id = '$p_id' and `account_name`='".$old_emp_name."'"; mysql_query($sql); //advance_taken_entry $sql="update `advance_taken_entry` set `account_name`='".$editempName."' where user_id ='$u_id' and project_id = '$p_id' and `account_name`='".$old_emp_name."'"; mysql_query($sql); //custemaccount_cashentry $sql="update `custemaccount_cashentry` set `accountname`='".$editempName."' where user_id ='$u_id' and project_id = '$p_id' and `accountname`='".$old_emp_name."'"; mysql_query($sql); //custemaccount_cashentry $sql="update `custemaccount_cashentry` set `groupname`='".$editempName."' where user_id ='$u_id' and project_id = '$p_id' and `groupname`='".$old_emp_name."'"; mysql_query($sql); //ledger $sql="update `ledger` set `account_name`='".$editempName."' where user_id ='$u_id' and project_id = '$p_id' and `account_name`='".$old_emp_name."'"; mysql_query($sql); //payment $sql="update `payment` set `account_Name`='".$editempName."' where user_id ='$u_id' and project_id = '$p_id' and `account_Name`='".$old_emp_name."'"; mysql_query($sql); //reciept $sql="update `reciept` set `account_Name`='".$editempName."' where user_id ='$u_id' and project_id = '$p_id' and `account_Name`='".$old_emp_name."'"; mysql_query($sql); //---------------------------------- return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } }//179 public function addGroup($username) { try{ $table_id=Common::getTableID("accgroup","group_id"); $table_id=$table_id+1; $u_id=@$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="INSERT INTO `accgroup` ( `group_id`, `user_id`, `project_id`, `groupname` ) VALUES ('$table_id','$u_id','$p_id','$groupname_restore')"; mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } } //check PI name exists public function piNameCheck($username) { try { //$u_id=@$_SESSION['user_id']; //$p_id=@$_SESSION['project_id']; $sql="select `name` from pi where name='$username'"; mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch( Exception $ex) { echo $ex-> getMessage(); return null; } } //-------------------------------------------Register new PI-----// public function addPI($username) { try{ //$u_id=@$_SESSION['user_id']; // $p_id=@$_SESSION['project_id']; $sql="INSERT INTO `pi` (`pi_id` ,`name` ) VALUES (NULL ,'$username')"; mysql_query($sql); if (mysql_affected_rows()>0) { return "True"; } else { return "False"; } } catch(Exception $ex) { echo $ex-> getMessage(); return null; } } //------------------// } ?>