561 lines
21 KiB
PHP
561 lines
21 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : Employee (Employee Controller)
|
|
* User Class to control all user related operations.
|
|
* @author : Gandhimathi
|
|
* @version : 1.1
|
|
* @since : 07 Apr 2017
|
|
*/
|
|
class employeedetails extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('employeedetails_model');
|
|
$this->isLoggedIn();
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : Employee Details';
|
|
|
|
$this->loadViews("employeeListing", $this->global, NULL , NULL);
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the Employee details
|
|
*/
|
|
function employeeListing()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
|
|
$this->load->model('employeedetails_model');
|
|
|
|
$searchText = $this->input->post('searchText');
|
|
$data['searchText'] = $searchText;
|
|
|
|
$this->load->library('pagination');
|
|
|
|
$count = $this->employeedetails_model->employeeListingCount($searchText);
|
|
|
|
|
|
$returns = $this->paginationCompress ( "employeeListing/", $count[0]['Count'], 10 );
|
|
|
|
$data['userRecords'] = $this->employeedetails_model->employeeListing($searchText, $returns["page"], $returns["segment"]);
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Employee Listing';
|
|
|
|
$this->loadViews("employeeListing", $this->global, $data, NULL);
|
|
}
|
|
}
|
|
/*
|
|
Validation for Gender status Dropdown
|
|
*/
|
|
function Gender_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Gender_validate', 'Please Select Gender.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/*
|
|
Validation for Martial status Dropdown
|
|
*/
|
|
function Martial_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Martial_validate', 'Please Select Martial status.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/*
|
|
Validation for BloodGroup Dropdown
|
|
*/
|
|
function Blood_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Blood_validate', 'Please Select Blood Group.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/*
|
|
Validation for Qualification Dropdown
|
|
*/
|
|
function select_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('select_validate', 'Please Select Educational Qualification.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/*
|
|
Validation for Department Dropdown
|
|
*/
|
|
function Dep_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Dep_validate', 'Please Select Department.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/*
|
|
Validation for Desigination Dropdown
|
|
*/
|
|
function Des_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Des_validate', 'Please Select Desigination.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/**
|
|
* This function is used to save the new Employee form in the database
|
|
*/
|
|
|
|
function AddNewEmployee()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
$this->load->library('form_validation');
|
|
|
|
$this->form_validation->set_rules('ContactNumber', 'ContactNumber', 'trim|required|min_length[10]|max_length[10]');
|
|
$this->form_validation->set_rules('emailid', 'emailid', 'trim|required|valid_email');
|
|
$this->form_validation->set_rules('gender', 'gender', 'callback_Gender_validate');
|
|
$this->form_validation->set_rules('MartialStatus', 'MartialStatus', 'callback_Martial_validate');
|
|
|
|
$this->form_validation->set_rules('bloodgroup', 'bloodgroup', 'callback_Blood_validate');
|
|
|
|
$this->form_validation->set_rules('emergencycontactnumber', 'emergencycontactnumber', 'trim|required|min_length[10]|max_length[10]');
|
|
|
|
$this->form_validation->set_rules('desigination', 'Desigination', 'callback_Des_validate');
|
|
$this->form_validation->set_rules('departmentname', 'departmentname', 'callback_Dep_validate');
|
|
$this->form_validation->set_rules('eduqualifaction', 'eduqualifaction', 'callback_select_validate');
|
|
$this->form_validation->set_rules('referrercontno', 'referrercontno', 'trim|min_length[10]|max_length[10]');
|
|
$this->form_validation->set_rules('aadharno', 'aadharno', 'trim|min_length[12]|max_length[12]');
|
|
$this->form_validation->set_rules('panno', 'panno', 'trim|min_length[10]|max_length[10]');
|
|
$this->form_validation->set_rules('passportno', 'passportno', 'trim|min_length[8]|max_length[8]');
|
|
$this->form_validation->set_rules('accountno', 'accountno', 'trim|min_length[10]|max_length[20]');
|
|
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
$this->addemployee();
|
|
//echo 'Validate method called';
|
|
}
|
|
else
|
|
{
|
|
//echo 'Validate not method called';
|
|
$Picture = $this->add();
|
|
|
|
$FirstName = $this->input->post('FirstName');
|
|
$LastName = $this->input->post('LastName');
|
|
$FatherName = $this->input->post('FatherName');
|
|
$DateofBirth = $this->input->post('DateofBirth');
|
|
$ContactNumber = $this->input->post('ContactNumber');
|
|
$EmailId = $this->input->post('emailid');
|
|
$Gender = $this->input->post('gender');
|
|
$MartialStatus = $this->input->post('MartialStatus');
|
|
|
|
$BloodGroup = $this->input->post('bloodgroup');
|
|
$CurrentAddress = $this->input->post('currentaddress');
|
|
$permanentaddress = $this->input->post('permanentaddress');
|
|
$emergencycontactname = $this->input->post('emergencycontactname');
|
|
$emergencycontactnumber = $this->input->post('emergencycontactnumber');
|
|
$desigination = $this->input->post('desigination');
|
|
$departmentCode = $this->input->post('departmentname');
|
|
$dateofjoining = $this->input->post('dateofjoining');
|
|
$Previousexperience = $this->input->post('Previousexperience');
|
|
$eduqualifaction = $this->input->post('eduqualifaction');
|
|
$addqualification = $this->input->post('addqualification');
|
|
$referredby = $this->input->post('referredby');
|
|
$referrercontno = $this->input->post('referrercontno');
|
|
$accountno = $this->input->post('accountno');
|
|
$ifsccode = $this->input->post('ifsccode');
|
|
$bankbranchname = $this->input->post('bankbranchname');
|
|
$bankaddress = $this->input->post('bankaddress');
|
|
$aadharno = $this->input->post('aadharno');
|
|
$panno = $this->input->post('panno');
|
|
$passportno = $this->input->post('passportno');
|
|
$ValidTill = $this->input->post('ValidTill');
|
|
$addinfo = $this->input->post('addinfo');
|
|
$IsActive = '1';
|
|
$createdby = $this->session->userdata ( 'userId' );
|
|
|
|
|
|
$DOB = $this->getDateformat($DateofBirth);
|
|
$DOJ = $this->getDateformat($dateofjoining);
|
|
if($ValidTill != '')
|
|
{
|
|
$Valid = $this->getDateformat($ValidTill);
|
|
}
|
|
else
|
|
{
|
|
$Valid = null;
|
|
}
|
|
|
|
//echo $DOB;
|
|
$Employee = array('FirstName'=>$FirstName, 'LastName'=>$LastName,'FatherName'=>$FatherName,'Gender'=>$Gender,'DateofBirth'=>$DOB,'ContactNumber'=>$ContactNumber,'EmailId'=>$EmailId,'BloodGroup'=>$BloodGroup,'MartialStatus'=>$MartialStatus,'DateofJoining'=>$DOJ,'PreviousYearsOfExp'=>$Previousexperience,'Designation'=>$desigination,'Departmentcode'=>$departmentCode,'PresentAddress'=>$CurrentAddress,'PermanentAddress'=>$permanentaddress,'EmergencyContactName'=>$emergencycontactname,'EmergencyContactNumber'=>$emergencycontactnumber,'Edu_Qualification'=>$eduqualifaction,'Additional_Qualification'=>$addqualification,'AadharNo'=>$aadharno,'PANNo'=>$panno,'BankAccountNo'=>$accountno,'IFSCCode'=>$ifsccode,'BankBranchName'=>$bankbranchname,'BankAddress'=>$bankaddress,'PassportNo'=>$passportno,'Passport_Valid_till'=>$Valid,'IsActive'=>$IsActive,'ProfilePic'=>$Picture,'Reference_Name'=>$referredby,'Reference_ContactNumber'=>$referrercontno,'Remarks'=>$addinfo,'CreatedBy'=>$createdby);
|
|
|
|
$this->load->model('employeedetails_model');
|
|
$result = $this->employeedetails_model->addNewemployee($Employee);
|
|
|
|
if($result > 0)
|
|
{
|
|
|
|
// $this->session->set_flashdata('Success', 'New Employee created successfully!');
|
|
redirect('employeeListing','refresh');
|
|
echo "<script>alert('New Employee Created successfully!');</script>";
|
|
}
|
|
else
|
|
{
|
|
|
|
$this->session->set_flashdata('Error', 'New Employee details not saved');
|
|
redirect('employeeListing','refresh');
|
|
echo "<script>alert('Record Not Saved!');</script>";
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val);
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
return $retDate;
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the add new Employee form with dropdown values */
|
|
function addemployee()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
$this->load->model('employeedetails_model');
|
|
$GenderConfigID = 'C013';
|
|
$MartialConfigID = 'C012';
|
|
$QualificationConfigID = 'C014';
|
|
$DesignationConfigID = 'C010';
|
|
$BloodGroupConfigID = 'C011';
|
|
|
|
$data['Gender'] = $this->employeedetails_model->getConfigValue($GenderConfigID);
|
|
$data['Martial'] = $this->employeedetails_model->getConfigValue($MartialConfigID);
|
|
$data['Qualification'] = $this->employeedetails_model->getConfigValue($QualificationConfigID);
|
|
$data['Designation'] = $this->employeedetails_model->getConfigValue($DesignationConfigID);
|
|
$data['BloodGroup'] = $this->employeedetails_model->getConfigValue($BloodGroupConfigID);
|
|
|
|
$data['Department'] = $this->employeedetails_model->getDepartment();
|
|
$this->global['pageTitle'] = 'Siddharth : Add New Employee';
|
|
$this->loadViews("addemployee", $this->global, $data, NULL);
|
|
}
|
|
}
|
|
/**
|
|
* This function is used to check whether the Employee is existing in the database or not */
|
|
function CheckEmail()
|
|
{
|
|
$id = $this->input->post('id');
|
|
$this->load->model('employeedetails_model');
|
|
$query = $this->employeedetails_model->checkMailExists($id );
|
|
|
|
$query = $query[0]['EmailId'];
|
|
print_r($query);
|
|
|
|
}
|
|
function pageNotFound()
|
|
{
|
|
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
|
|
function add(){
|
|
|
|
|
|
$picture = '';
|
|
//Check whether user upload picture
|
|
if(!empty($_FILES['photo']['name']))
|
|
{
|
|
|
|
$config['upload_path'] = 'uploads/images/';
|
|
$config['allowed_types'] = 'jpg|jpeg|png|gif';
|
|
$config['file_name'] = $_FILES['photo']['name'];
|
|
|
|
//Load upload library and initialize configuration
|
|
$this->load->library('upload',$config);
|
|
$this->upload->initialize($config);
|
|
|
|
if($this->upload->do_upload('photo'))
|
|
{
|
|
$uploadData = $this->upload->data();
|
|
$picture = $uploadData['file_name'];
|
|
}
|
|
else
|
|
{
|
|
$error = array('error' => $this->upload->display_errors());
|
|
$picture = '';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$picture = '';
|
|
}
|
|
|
|
return $picture ;
|
|
}
|
|
|
|
function ViewEmployee($EmpNO='')
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
if($EmpNO == '')
|
|
{
|
|
$EmpID = $_GET['EmpID'];
|
|
}
|
|
else
|
|
{
|
|
|
|
$EmpID = $EmpNO; }
|
|
|
|
$GenderConfigID = 'C013';
|
|
$MartialConfigID = 'C012';
|
|
$QualificationConfigID = 'C014';
|
|
$DesignationConfigID = 'C010';
|
|
$BloodGroupConfigID = 'C011';
|
|
$this->load->model('employeedetails_model');
|
|
$data['GenderList'] = $this->employeedetails_model->getConfigValue($GenderConfigID);
|
|
$data['MartialList'] = $this->employeedetails_model->getConfigValue($MartialConfigID);
|
|
$data['QualificationList'] = $this->employeedetails_model->getConfigValue($QualificationConfigID);
|
|
$data['DesignationList'] = $this->employeedetails_model->getConfigValue($DesignationConfigID);
|
|
$data['BloodGroupList'] = $this->employeedetails_model->getConfigValue($BloodGroupConfigID);
|
|
|
|
$data['DepartmentList'] = $this->employeedetails_model->getDepartment();
|
|
$data['EmpDetails'] = $this->employeedetails_model->viewemployee($EmpID);
|
|
$this->global['pageTitle'] = 'Siddharth : View Employee';
|
|
|
|
$this->loadViews("editEmployee", $this->global, $data, NULL);
|
|
|
|
}
|
|
}
|
|
/* To Check the email exists in the database or not for the employee*/
|
|
function checkMailEmp()
|
|
{
|
|
$Empid = $this->input->post('employeeid');
|
|
$EmailId = $this->input->post('emailid');
|
|
|
|
$this->load->model('employeedetails_model');
|
|
$query = $this->employeedetails_model->checkMailExists($EmailId, $Empid);
|
|
if (count($query)> 0)
|
|
{
|
|
$this->form_validation->set_message('checkMailEmp', 'The Entered Email id is exists in the Database.');
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/* To Update the employee details*/
|
|
function UpdateEmployee()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
$EmpId = $this->input->post('employeeid');
|
|
$this->load->library('form_validation');
|
|
|
|
$this->form_validation->set_rules('ContactNumber', 'ContactNumber', 'trim|required|min_length[10]|max_length[10]');
|
|
$this->form_validation->set_rules('emailid', 'emailid', 'trim|required|valid_email|callback_checkMailEmp');
|
|
$this->form_validation->set_rules('gender', 'gender', 'callback_Gender_validate');
|
|
$this->form_validation->set_rules('MartialStatus', 'MartialStatus', 'callback_Martial_validate');
|
|
|
|
$this->form_validation->set_rules('bloodgroup', 'bloodgroup', 'callback_Blood_validate');
|
|
|
|
$this->form_validation->set_rules('emergencycontactnumber', 'emergencycontactnumber', 'trim|required|min_length[10]|max_length[10]');
|
|
|
|
$this->form_validation->set_rules('desigination', 'Desigination', 'callback_Des_validate');
|
|
$this->form_validation->set_rules('departmentname', 'departmentname', 'callback_Dep_validate');
|
|
$this->form_validation->set_rules('eduqualifaction', 'eduqualifaction', 'callback_select_validate');
|
|
$this->form_validation->set_rules('referrercontno', 'referrercontno', 'trim|min_length[10]|max_length[10]');
|
|
$this->form_validation->set_rules('aadharno', 'aadharno', 'trim|min_length[12]|max_length[12]');
|
|
$this->form_validation->set_rules('panno', 'panno', 'trim|min_length[10]|max_length[10]');
|
|
$this->form_validation->set_rules('passportno', 'passportno', 'trim|min_length[8]|max_length[8]');
|
|
$this->form_validation->set_rules('accountno', 'accountno', 'trim|min_length[10]|max_length[20]');
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
$this->ViewEmployee($EmpId);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$this->load->model('employeedetails_model');
|
|
$EmpId = $this->input->post('employeeid');
|
|
$PictureName = $this->input->post('Image');
|
|
|
|
if ($PictureName != '')
|
|
{
|
|
//echo 'Exists';
|
|
$Picture = $PictureName;
|
|
}
|
|
else
|
|
{
|
|
//echo 'Not Exists';
|
|
$Picture = $this->add();
|
|
}
|
|
//echo $Picture;
|
|
|
|
$FirstName = $this->input->post('FirstName');
|
|
$LastName = $this->input->post('LastName');
|
|
$FatherName = $this->input->post('FatherName');
|
|
$DateofBirth = $this->input->post('DateofBirth');
|
|
$ContactNumber = $this->input->post('ContactNumber');
|
|
$EmailId = $this->input->post('emailid');
|
|
$Gender = $this->input->post('gender');
|
|
$MartialStatus = $this->input->post('MartialStatus');
|
|
$BloodGroup = $this->input->post('bloodgroup');
|
|
$CurrentAddress = $this->input->post('currentaddress');
|
|
$permanentaddress = $this->input->post('permanentaddress');
|
|
$emergencycontactname = $this->input->post('emergencycontactname');
|
|
$emergencycontactnumber = $this->input->post('emergencycontactnumber');
|
|
$desigination = $this->input->post('desigination');
|
|
$departmentCode = $this->input->post('departmentname');
|
|
$dateofjoining = $this->input->post('dateofjoining');
|
|
$Previousexperience = $this->input->post('Previousexperience');
|
|
$eduqualifaction = $this->input->post('eduqualifaction');
|
|
$addqualification = $this->input->post('addqualification');
|
|
$referredby = $this->input->post('referredby');
|
|
$referrercontno = $this->input->post('referrercontno');
|
|
$accountno = $this->input->post('accountno');
|
|
$ifsccode = $this->input->post('ifsccode');
|
|
$bankbranchname = $this->input->post('bankbranchname');
|
|
$bankaddress = $this->input->post('bankaddress');
|
|
$aadharno = $this->input->post('aadharno');
|
|
$panno = $this->input->post('panno');
|
|
$passportno = $this->input->post('passportno');
|
|
$ValidTill = $this->input->post('ValidTill');
|
|
$addinfo = $this->input->post('addinfo');
|
|
|
|
$chked = $this->input->post('isactive');
|
|
// echo 'chkvalue'. $chked ;
|
|
if( $chked != '')
|
|
{
|
|
$IsActive = '1';
|
|
}
|
|
else
|
|
{
|
|
$IsActive = '0';
|
|
}
|
|
// echo 'chkvalue'. $IsActive ;
|
|
$UpdatedBY = $this->session->userdata ( 'userId' );
|
|
|
|
|
|
$DOB = $this->getDateformat($DateofBirth);
|
|
$DOJ = $this->getDateformat($dateofjoining);
|
|
if($ValidTill != '')
|
|
{
|
|
$Valid = $this->getDateformat($ValidTill);
|
|
}
|
|
else
|
|
{
|
|
$Valid = null;
|
|
}
|
|
|
|
//echo $DOB;
|
|
$Employee = array('FirstName'=>$FirstName, 'LastName'=>$LastName,'FatherName'=>$FatherName,'Gender'=>$Gender,'DateofBirth'=>$DOB,'ContactNumber'=>$ContactNumber,'EmailId'=>$EmailId,'BloodGroup'=>$BloodGroup,'MartialStatus'=>$MartialStatus,'DateofJoining'=>$DOJ,'PreviousYearsOfExp'=>$Previousexperience,'Designation'=>$desigination,'Departmentcode'=>$departmentCode,'PresentAddress'=>$CurrentAddress,'PermanentAddress'=>$permanentaddress,'EmergencyContactName'=>$emergencycontactname,'EmergencyContactNumber'=>$emergencycontactnumber,'Edu_Qualification'=>$eduqualifaction,'Additional_Qualification'=>$addqualification,'AadharNo'=>$aadharno,'PANNo'=>$panno,'BankAccountNo'=>$accountno,'IFSCCode'=>$ifsccode,'BankBranchName'=>$bankbranchname,'BankAddress'=>$bankaddress,'PassportNo'=>$passportno,'Passport_Valid_till'=>$Valid,'IsActive'=>$IsActive,'ProfilePic'=>$Picture,'Reference_Name'=>$referredby,'Reference_ContactNumber'=>$referrercontno,'Remarks'=>$addinfo,'UpdatedBY'=>$UpdatedBY);
|
|
|
|
|
|
$result = $this->employeedetails_model->UpdateEmployee($Employee,$EmpId);
|
|
|
|
if($result > 0)
|
|
{
|
|
|
|
// $this->session->set_flashdata('Success', $EmpId.'Employee Updated successfully!');
|
|
redirect('employeeListing','refresh');
|
|
echo "<script>alert('You Have Successfully updated the Employee Record!');</script>";
|
|
}
|
|
else
|
|
{
|
|
|
|
$this->session->set_flashdata('Error', $EmpId.'Employee details not saved');
|
|
redirect('employeeListing','refresh');
|
|
echo "<script>alert('Record Not Updated!');</script>";
|
|
}
|
|
|
|
// redirect('employeeListing');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|