@@ -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
The first character cannot be Q, X or Z. (eg:A12 34567)" onkeypress="return alpha(event);">
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Previous
@@ -1276,51 +1244,63 @@
}
$("#emailid").change(function() {
+ var emailId = $('#emailid').val();
- var id = $('#emailid').val();
- if (validateEmail()) {
- $('#loader').show();
- $.ajax({
- data: {
- id: id
- },
+ // Validate email before proceeding
+ if (validateEmail()) {
+ $('#loader').show(); // Show loader before sending AJAX request
- type: "POST",
- url: "employeeEmailExist",
- success: function(data) {
- if (data) {
- // alert(data+""+" Employee already exists in the database.Please Change the Email id")
- // $('#emailid').val('');
- // $('#emailid').focus();
+ $.ajax({
+ data: {
+ emailId
+ },
+ type: "POST",
+ url: "employeeEmailExist",
+
+ // Success callback for handling a successful response
+ success: function(data) {
+ if (data) {
+ $('#loader').hide(); // Hide the loader after a successful response
- var answer = confirm(data + "" +
- " Employee already exists in the database.Do you want to change the Email id ?"
- )
- if (answer) {
- $('#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() {
- var id = $('#panno').val();
- if (id != '') {
+ var panNo = $('#panno').val();
+ if (panNo != '') {
$('#loader').show();
$.ajax({
data: {
- id: id
+ panNo
},
type: "POST",
@@ -1332,20 +1312,20 @@
// $('#panno').val('');
// $('#panno').focus();
- var answer = confirm(data + " " +
- " Employee details is already exists in the database.Do you want to change the Employee details?"
+ var answer = confirm(
+ " Pan Number details is already exists !!.Kindly Provide us another Pan Number"
)
- if (answer) {
+
$('#panno').val('');
$('#panno').focus();
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 {
@@ -1359,37 +1339,36 @@
//
$('#aadharno').change(function() {
- var id = $('#aadharno').val();
- if (id != '') {
+ var aadharNo = $('#aadharno').val();
+ if (aadharNo) {
$('#loader').show();
$.ajax({
data: {
- id: id
+ aadharNo
},
type: "POST",
url: "employeecheckAadharNoExist",
success: function(data) {
$('#loader').hide();
+ console.log(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').focus();
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 {
diff --git a/app/Views/editEmployeenew.php b/app/Views/editEmployeenew.php
index cb4907e2..973f5357 100755
--- a/app/Views/editEmployeenew.php
+++ b/app/Views/editEmployeenew.php
@@ -353,14 +353,14 @@ if (!empty($EmpDetails)) {
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1630,84 +1582,93 @@ if (!empty($EmpDetails)) {
$("#email").change(function() {
- var id = $('#email').val();
+ var emailId = $('#email').val();
if (validateEmail()) {
$('#loader').show();
$.ajax({
data: {
- id: id
+ emailId
},
type: "POST",
- url: "employeedetails/CheckEmail",
+ url: "employeeEmailExist",
success: function(data) {
$('#loader').hide();
- if (data) {
+ if (data != emailId) {
alert(data + "" +
- " Employee already exists in the database.Please Change the mail id");
+ "Another Employee already exists !!.Please Change the mail id");
return false;
- //window.location = 'Employeedetails/employeeListing';
+
}
- }
+ },
+ complete: function() {
+ $('#loader').hide(); // Ensure the loader is always hidden after the request completes
+ }
});
}
});
$('#panno').change(function() {
- var id = $('#panno').val();
- if (id != '') {
+ var panNo = $('#panno').val();
+ if (panNo != '') {
$('#loader').show();
$.ajax({
data: {
- id: id
+ panNo
},
type: "POST",
- url: "employeedetails/checkPAN",
+ url: "employeePANExist",
success: function(data) {
$('#loader').hide();
- if (data) {
- alert(data + "" +
- " Employee already exists in the database.Please Change the Pan Card Number"
+ if (data != panNo ) {
+ alert(
+ " Employee with this pan number already exists in the database.Please Change the Pan Card Number"
);
$('#panno').val('');
$('#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() {
- var id = $('#aadharno').val();
- if (id != '') {
+ var aadharNo = $('#aadharno').val();
+ if (aadharNo != '') {
$('#loader').show();
$.ajax({
data: {
- id: id
+ aadharNo
},
type: "POST",
- url: "employeedetails/checkAadharNo",
+ url: "employeecheckAadharNoExist",
success: function(data) {
$('#loader').hide();
- if (data) {
- alert(data + "" +
- " Employee already exists in the database.Please Change the Aadhar card Number"
+ if (data != aadharNo) {
+ alert(
+ "Another Employee with this aadhar number already exists ..!!.Please Change the Aadhar card Number"
);
$('#aadharno').val('');
$('#aadharno').focus();
- //return false;
- //window.location = 'Employeedetails/employeeListing';
+
}
}
+ ,
+ complete: function() {
+ $('#loader').hide(); // Ensure the loader is always hidden after the request completes
+ }
});
}