0ct/09 -vadivel j

This commit is contained in:
vadivel J 2024-10-09 17:50:09 +05:30
parent 22de98c308
commit 3d3000e0f6
4 changed files with 142 additions and 189 deletions

View File

@ -380,14 +380,14 @@ class Employeedetails extends BaseController
// $this->session->set_flashdata('Success', 'New Employee created successfully!'); // $this->session->set_flashdata('Success', 'New Employee created successfully!');
$this->session->setFlashdata('success', 'New Employee created successfully!'); $this->session->setFlashdata('success', 'New Employee created successfully!');
return json_encode('true'); // return json_encode('true');
// echo "<script>alert('New Employee Created successfully!');</script>"; echo "<script>alert('New Employee Created successfully!');</script>";
} else { } else {
// $this->session->set_flashdata('Error', 'New Employee details not saved'); // $this->session->set_flashdata('Error', 'New Employee details not saved');
$this->session->setFlashdata('error', 'Record Not Saved!'); $this->session->setFlashdata('error', 'Record Not Saved!');
return json_encode('false'); // return json_encode('false');
// echo "<script>alert('Record Not Saved!');</script>"; echo "<script>alert('Record Not Saved!');</script>";
// redirect('employeeListing', 'refresh'); // redirect('employeeListing', 'refresh');
} }
// return redirect()->route('employeeListing'); // return redirect()->route('employeeListing');
@ -449,34 +449,36 @@ class Employeedetails extends BaseController
* This function is used to check whether the Employee is existing in the database or not */ * This function is used to check whether the Employee is existing in the database or not */
function CheckEmail() function CheckEmail()
{ {
$id = $this->request->getPost('id'); $emailId = $this->request->getPost('emailId');
//print_r($id); //print_r($id);
$query = $this->employeedetails_model->checkMailExists($id); $response = $this->employeedetails_model->checkMailExists($emailId);
$response = ($query !== null && !empty($query)) ? $query[0]['EmailId'] : null;
return $this->response->setJSON($response); return $this->response->setJSON($response);
} }
function checkPAN() function checkPAN()
{ {
$id = $this->request->getPost('id'); $panNo = $this->request->getPost('panNo');
//print_r($id); //print_r($id);
$query = $this->employeedetails_model->checkPANExists($id); $response = $this->employeedetails_model->checkPANExists($panNo);
$response = ($query !== null && !empty($query)) ? $query[0]['PANNo'] : null;
return $this->response->setJSON($response); return $this->response->setJSON($response);
// print_r($query);
} }
function checkAadharNo() function checkAadharNo()
{ {
$id = $this->request->getPost('id'); $aadharNo = $this->request->getPost('aadharNo');
//print_r($id); //print_r($id);
$query = $this->employeedetails_model->checkAadharExists($id); $response = $this->employeedetails_model->checkAadharExists($aadharNo);
$response = ($query !== null && !empty($query)) ? $query[0]['AadharNo'] : null;
return $this->response->setJSON($response); return $this->response->setJSON($response);
} }

View File

@ -129,34 +129,40 @@ class Employeedetails_model extends Model
return $query->getResultArray(); return $query->getResultArray();
} }
function checkMailExists($email = '', $Empid = '') function checkMailExists($emailId = '', $Empid = '')
{ {
$builder = $this->db->table('t_employee_details')->select('EmailId') $builder = $this->db->table('t_employee_details')->select('EmailId')
->where('EmailId', $email); ->where('EmailId', $emailId);
if ($Empid != '') { if ($Empid != '') {
$builder->where('EmpID !=', $Empid); $builder->where('EmpID !=', $Empid);
} }
$query = $builder->get(); $query = $builder->get();
if ($query->getNumRows() > 0) { if ($query->getNumRows() > 0) {
return $query->getResultArray(); return true;
}else{
return false;
} }
} }
function checkAadharExists($AadharNo, $Empid = '') function checkAadharExists($aadharNo, $Empid = '')
{ {
$builder = $this->db->table('t_employee_details')->select('AadharNo') $builder = $this->db->table('t_employee_details')->select('AadharNo')
->where('AadharNo', $AadharNo); ->where('AadharNo', $aadharNo);
if ($Empid != '') { if ($Empid != '') {
$builder->where('EmpID !=', $Empid); $builder->where('EmpID !=', $Empid);
} }
$query = $builder->get(); $query = $builder->get();
if ($query->getNumRows() > 0) { if ($query->getNumRows() > 0) {
return $query->getResultArray(); return true;
}else{
return false;
} }
} }
function checkPANExists($PANNo, $Empid = '') function checkPANExists($PANNo, $Empid = '')
{ {
@ -166,10 +172,15 @@ class Employeedetails_model extends Model
if ($Empid != '') { if ($Empid != '') {
$builder->where('EmpID !=', $Empid); $builder->where('EmpID !=', $Empid);
} }
$query = $builder->get(); $query = $builder->get();
if ($query->getNumRows() > 0) { if ($query->getNumRows() > 0) {
return $query->getResultArray(); return true;
}else{
return false;
} }
} }

View File

@ -523,12 +523,12 @@
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-md-4 pad"> <div class="col-md-4 pad">
<label>Personal Email ID</label><span class="badge">*</span> <label>Official Email ID</label><span class="badge">*</span>
<input type="email" name="emailid" id="emailid" maxlength="100" <input type="email" name="emailid" id="emailid" maxlength="100"
class="form-control" required> class="form-control" required>
</div> </div>
<div class="col-md-4 pad"> <div class="col-md-4 pad">
<label>Official Email ID</label> <label>Personal Email ID</label>
<input type="email" name="comemailid" id="mail" maxlength="100" <input type="email" name="comemailid" id="mail" maxlength="100"
class="form-control"> class="form-control">
</div> </div>
@ -1010,46 +1010,14 @@
pattern="[aA-prPR-wyWY]{1}[1-9]{1}\d{1}\s\d{4}[1-9]{1}" title="The first digit or the last digit will never be 0 pattern="[aA-prPR-wyWY]{1}[1-9]{1}\d{1}\s\d{4}[1-9]{1}" title="The first digit or the last digit will never be 0
The first character cannot be Q, X or Z. (eg:A12 34567)" onkeypress="return alpha(event);"> The first character cannot be Q, X or Z. (eg:A12 34567)" onkeypress="return alpha(event);">
</div> </div>
<div class="col-md-3"><label>Passport Expiry Date</label>
<input id="ValidTill" name="ValidTill" onkeypress="return false;"
maxlength="10" class="form-control">
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-11">
<div class="row">
<div class="col-md-3"><label>Voter ID</label>
<input type="text" id="VoterID" name="voterID" maxlength="12"
class="form-control" style="text-transform: uppercase">
</div>
<div class="col-md-3"><label>Driving License</label>
<input type="text" id="Driverlicense"
onchange="validateDriverLicense();" style="text-transform:uppercase"
pattern="[a-zA-Z]{2}[0-9]{2}\s[0-9]{11}" title="EX:TN82 12345678900"
maxlength="16" name="driverlicense" class="form-control"
onkeypress="return alpha(event);">
</div>
<div class="col-md-3"><label>Driving License Expiry Date</label>
<input id="LicenseExpiryDate" name="licenseExpiryDate"
onkeypress="return false;" maxlength="10" class="form-control">
</div>
<div class="col-md-3"><label>Nominee reference</label>
<input type="text" id="nomineename" name="nomineename" maxlength="255"
class="form-control">
</div>
</div>
</div>
</div>
</form> </form>
<ul class="list-inline wizard mb-0"> <ul class="list-inline wizard mb-0">
<li class="previous list-inline-item"><a href="javascript: void(0);" class="btn btn-secondary">Previous</a> <li class="previous list-inline-item"><a href="javascript: void(0);" class="btn btn-secondary">Previous</a>
@ -1276,51 +1244,63 @@
} }
$("#emailid").change(function() { $("#emailid").change(function() {
var emailId = $('#emailid').val();
var id = $('#emailid').val(); // Validate email before proceeding
if (validateEmail()) { if (validateEmail()) {
$('#loader').show(); $('#loader').show(); // Show loader before sending AJAX request
$.ajax({
data: {
id: id
},
type: "POST", $.ajax({
url: "<?php echo base_url(); ?>employeeEmailExist", data: {
success: function(data) { emailId
if (data) { },
// alert(data+""+" Employee already exists in the database.Please Change the Email id") type: "POST",
// $('#emailid').val(''); url: "<?php echo base_url(); ?>employeeEmailExist",
// $('#emailid').focus();
var answer = confirm(data + "" + // Success callback for handling a successful response
" Employee already exists in the database.Do you want to change the Email id ?" success: function(data) {
) if (data) {
if (answer) { $('#loader').hide(); // Hide the loader after a successful response
$('#emailid').val('');
$('#emailid').focus();
} else {
alert('please edit the emailid in the edit employee screen');
window.location = 'employeedetails/employeeListing';
}
}
$('#loader').hide(); // Confirmation dialogue when email already exists
var answer = confirm("Employee mail Id already exists in the database. Kindly Provide us another Email id");
$('#emailid').val(''); // Clear email input if user wants to change
$('#emailid').focus(); // Set focus back to email input
} else {
$('#loader').hide(); // Hide loader if no data returned
} }
},
}); // Error callback to handle any errors in the request
} error: function(xhr, status, error) {
$('#loader').hide(); // Ensure the loader is hidden on error
console.log("AJAX Error: ", error); // Log the error for debugging
console.log("Response Status: ", status); // Log status
console.log("XHR Object: ", xhr); // Log full XHR object to see details
alert('An error occurred while checking the email. Please try again.'); // Alert user of the error
},
// Complete callback that always runs after the request (whether success or error)
complete: function() {
$('#loader').hide(); // Ensure the loader is always hidden after the request completes
}
});
}
});
});
$('#panno').change(function() { $('#panno').change(function() {
var id = $('#panno').val(); var panNo = $('#panno').val();
if (id != '') { if (panNo != '') {
$('#loader').show(); $('#loader').show();
$.ajax({ $.ajax({
data: { data: {
id: id panNo
}, },
type: "POST", type: "POST",
@ -1332,20 +1312,20 @@
// $('#panno').val(''); // $('#panno').val('');
// $('#panno').focus(); // $('#panno').focus();
var answer = confirm(data + " " + var answer = confirm(
" Employee details is already exists in the database.Do you want to change the Employee details?" " Pan Number details is already exists !!.Kindly Provide us another Pan Number"
) )
if (answer) {
$('#panno').val(''); $('#panno').val('');
$('#panno').focus(); $('#panno').focus();
return false; return false;
} else {
alert('please edit the PAN number in the Edit employee screen');
window.location = 'employeeListing';
}
} }
} },
complete: function() {
$('#loader').hide(); // Ensure the loader is always hidden after the request completes
}
}); });
} else { } else {
@ -1359,37 +1339,36 @@
// //
$('#aadharno').change(function() { $('#aadharno').change(function() {
var id = $('#aadharno').val(); var aadharNo = $('#aadharno').val();
if (id != '') { if (aadharNo) {
$('#loader').show(); $('#loader').show();
$.ajax({ $.ajax({
data: { data: {
id: id aadharNo
}, },
type: "POST", type: "POST",
url: "<?php echo base_url(); ?>employeecheckAadharNoExist", url: "<?php echo base_url(); ?>employeecheckAadharNoExist",
success: function(data) { success: function(data) {
$('#loader').hide(); $('#loader').hide();
console.log(data);
if (data) { if (data) {
// alert( data+""+" Employee already exists in the database.Please Change the Aadhar card Number");
// $('#aadharno').val('');
// $('#aadharno').focus();
var answer = confirm(data + " " +
" employee details is already exists in the database.Do you want to change the Employee details?" var answer = confirm(
" Aadhar details is already exists !!.Kindly Change Aadhar Details"
) )
if (answer) {
$('#aadharno').val(''); $('#aadharno').val('');
$('#aadharno').focus(); $('#aadharno').focus();
return false; return false;
} else {
alert('please edit the aadhar number in the edit employee screen');
window.location = 'employeeListing';
}
} }
} },
complete: function() {
$('#loader').hide(); // Ensure the loader is always hidden after the request completes
}
}); });
} else { } else {

View File

@ -353,14 +353,14 @@ if (!empty($EmpDetails)) {
<div class="row mb-3"> <div class="row mb-3">
<div class="col-md-4 pad"> <div class="col-md-4 pad">
<label>Personal Email ID</label> <label>Official Email ID</label>
<input type="mail" name="emailid" <input type="mail" name="emailid"
value="<?php echo $EmailId; ?>" id="email" value="<?php echo $EmailId; ?>" id="email"
placeholder="Email ID" maxlength="100" class="form-control"> placeholder="Email ID" maxlength="100" class="form-control">
</div> </div>
<div class="col-md-4 pad"> <div class="col-md-4 pad">
<label>Official Email ID</label> <label>Personal Email ID</label>
<input type="email" name="comemailid" id="mail" <input type="email" name="comemailid" id="mail"
placeholder="Official Email ID" placeholder="Official Email ID"
value="<?php echo $personalEmailId; ?>" maxlength="100" value="<?php echo $personalEmailId; ?>" maxlength="100"
@ -934,61 +934,13 @@ if (!empty($EmpDetails)) {
The first character cannot be Q, X or Z. (eg:A12 34567)" The first character cannot be Q, X or Z. (eg:A12 34567)"
style="text-transform: uppercase"> style="text-transform: uppercase">
</div> </div>
<div class="col-md-3">
<label>Passport Expiry Date</label>
<input id="ValidTill" name="ValidTill" maxlength="10"
placeholder="Passport Expiry Date" class="form-control"
value="<?php echo $DOPassport; ?>">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-11">
<div class="row">
<div class="col-md-3">
<label>Voter ID</label>
<input type="text" id="VoterID" name="voterID" maxlength="12"
value="<?php echo $VoterID; ?>" class="form-control"
placeholder="VoterID" onkeypress="return alpha(event);"
style="text-transform: uppercase">
</div>
<div class="col-md-3">
<label>Driving License</label>
<!-- <input type="text" id="Driverlicense" maxlength="16" onchange="validateDriverLicense();" pattern="[A-Z]{2}[0-9]{2}\s[0-9]{11}" value="<?php echo $DriverLicense; ?>"name="Driverlicense" title="EX:TN82 12345678900" class="form-control" value=""placeholder="Driverlicense"> -->
<input type="text" id="Driverlicense" maxlength="16"
onchange="validateDriverLicense();"
pattern="[a-zA-Z]{2}[0-9]{2}\s[0-9]{11}"
value="<?php echo $DriverLicense; ?>" name="driverlicense"
title="EX:TN82 12345678900" class="form-control"
placeholder="Driverlicense"
style="text-transform: uppercase"
onkeypress="return alpha(event);">
</div>
<div class="col-md-3">
<label>Driving License Expiry Date</label>
<input id="LicenseExpiryDate" name="LicenseExpiryDate"
value="<?php echo $LicenseValidtill; ?>"
onkeypress="return false;" class="form-control"
placeholder="License Expiry Date">
</div>
<div class="col-md-3">
<label>Nominee reference</label>
<input type="text" id="nomineename" name="nomineename"
maxlength="250" class="form-control"
placeholder="Nominee Name" value="<?php echo $nominee; ?>">
</div>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
<ul class="list-inline wizard mb-0"> <ul class="list-inline wizard mb-0">
<li class="previous list-inline-item"><a href="javascript: void(0);" <li class="previous list-inline-item"><a href="javascript: void(0);"
@ -1630,84 +1582,93 @@ if (!empty($EmpDetails)) {
$("#email").change(function() { $("#email").change(function() {
var id = $('#email').val(); var emailId = $('#email').val();
if (validateEmail()) { if (validateEmail()) {
$('#loader').show(); $('#loader').show();
$.ajax({ $.ajax({
data: { data: {
id: id emailId
}, },
type: "POST", type: "POST",
url: "<?php echo base_url(); ?>employeedetails/CheckEmail", url: "<?php echo base_url(); ?>employeeEmailExist",
success: function(data) { success: function(data) {
$('#loader').hide(); $('#loader').hide();
if (data) { if (data != emailId) {
alert(data + "" + alert(data + "" +
" Employee already exists in the database.Please Change the mail id"); "Another Employee already exists !!.Please Change the mail id");
return false; return false;
//window.location = 'Employeedetails/employeeListing';
} }
} },
complete: function() {
$('#loader').hide(); // Ensure the loader is always hidden after the request completes
}
}); });
} }
}); });
$('#panno').change(function() { $('#panno').change(function() {
var id = $('#panno').val(); var panNo = $('#panno').val();
if (id != '') { if (panNo != '') {
$('#loader').show(); $('#loader').show();
$.ajax({ $.ajax({
data: { data: {
id: id panNo
}, },
type: "POST", type: "POST",
url: "<?php echo base_url(); ?>employeedetails/checkPAN", url: "<?php echo base_url(); ?>employeePANExist",
success: function(data) { success: function(data) {
$('#loader').hide(); $('#loader').hide();
if (data) { if (data != panNo ) {
alert(data + "" + alert(
" Employee already exists in the database.Please Change the Pan Card Number" " Employee with this pan number already exists in the database.Please Change the Pan Card Number"
); );
$('#panno').val(''); $('#panno').val('');
$('#panno').focus(); $('#panno').focus();
//return false;
//window.location = 'Employeedetails/employeeListing';
} }
} }
,
complete: function() {
$('#loader').hide(); // Ensure the loader is always hidden after the request completes
}
}); });
} }
}); });
$('#aadharno').change(function() { $('#aadharno').change(function() {
var id = $('#aadharno').val(); var aadharNo = $('#aadharno').val();
if (id != '') { if (aadharNo != '') {
$('#loader').show(); $('#loader').show();
$.ajax({ $.ajax({
data: { data: {
id: id aadharNo
}, },
type: "POST", type: "POST",
url: "<?php echo base_url(); ?>employeedetails/checkAadharNo", url: "<?php echo base_url(); ?>employeecheckAadharNoExist",
success: function(data) { success: function(data) {
$('#loader').hide(); $('#loader').hide();
if (data) { if (data != aadharNo) {
alert(data + "" + alert(
" Employee already exists in the database.Please Change the Aadhar card Number" "Another Employee with this aadhar number already exists ..!!.Please Change the Aadhar card Number"
); );
$('#aadharno').val(''); $('#aadharno').val('');
$('#aadharno').focus(); $('#aadharno').focus();
//return false;
//window.location = 'Employeedetails/employeeListing';
} }
} }
,
complete: function() {
$('#loader').hide(); // Ensure the loader is always hidden after the request completes
}
}); });
} }