add and Edit screen issue fixed

This commit is contained in:
gandhimathi Bharathirajan 2017-04-09 16:15:47 +05:30
parent 838c37af9f
commit 642711980a

View File

@ -49,8 +49,9 @@ class Employeedetails extends BaseController
$this->load->library('pagination');
$count = $this->Employeedetails_model->employeeListingCount();
$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"]);
@ -60,7 +61,108 @@ class Employeedetails extends BaseController
$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
*/
@ -72,16 +174,36 @@ class Employeedetails extends BaseController
$this->loadThis();
}
else
{
$this->load->library('form_validation');
$this->form_validation->set_rules('eduqualifaction','Enter Qualification','trim|required');
{
$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[15]|max_length[15]');
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');
@ -137,16 +259,17 @@ class Employeedetails extends BaseController
if($result > 0)
{
echo "<script>alert('New Employee created successfully!');</script>";
$this->session->set_flashdata('Success', 'New Employee created successfully!');
echo "<script>alert('New Employee Created successfully!');</script>";
// $this->session->set_flashdata('Success', 'New Employee created successfully!');
redirect('employeeListing','refresh');
}
else
{
echo "<script>alert('New Employee details not saved!');</script>";
echo "<script>alert('Record Not Saved!');</script>";
$this->session->set_flashdata('Error', 'New Employee details not saved');
redirect('employeeListing','refresh');
}
redirect('employeeListing');
}
}
}
@ -240,7 +363,7 @@ class Employeedetails extends BaseController
return $picture ;
}
function ViewEmployee()
function ViewEmployee($EmpNO='')
{
if($this->isAdmin() == TRUE)
{
@ -248,7 +371,14 @@ class Employeedetails extends BaseController
}
else
{
if($EmpNO == '')
{
$EmpID = $_GET['EmpID'];
}
else
{
$EmpID = $EmpNO; }
$GenderConfigID = 'C013';
$MartialConfigID = 'C012';
@ -270,6 +400,25 @@ class Employeedetails extends BaseController
}
}
/* 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)
@ -278,6 +427,35 @@ class Employeedetails extends BaseController
}
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[15]|max_length[15]');
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');
@ -358,17 +536,19 @@ class Employeedetails extends BaseController
if($result > 0)
{
echo "<script>alert('Employee Updated successfully!');</script>";
$this->session->set_flashdata('Success', $EmpId.'Employee Updated successfully!');
echo "<script>alert('You Have Successfully updated the Employee Record!');</script>";
// $this->session->set_flashdata('Success', $EmpId.'Employee Updated successfully!');
redirect('employeeListing','refresh');
}
else
{
echo "<script>alert('Employee details not saved');</script>";
echo "<script>alert('Record Not Updated!');</script>";
$this->session->set_flashdata('Error', $EmpId.'Employee details not saved');
redirect('employeeListing','refresh');
}
redirect('employeeListing');
// redirect('employeeListing');
}
}
}
}