CHANGE_EMP_FILTER_ADD_2_FIELDS_CHECK_HR_NO_DATATABLE_CSV : RV

This commit is contained in:
VENKATESHWARAN 2024-06-24 17:26:46 +05:30
parent 644a525976
commit b32e9f80ac
9 changed files with 158 additions and 43 deletions

View File

@ -248,6 +248,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1");
$routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1");
$routes->get("getPolicyTermsFormJson/(:any)", "ClientController::getPolicyTermsFormJson/$1");
$routes->get("checkHRNumber/(:any)", "ClientController::checkHRNumber/$1");
});
$routes->cli('cli/processjob', 'JobWorker::processJob');

View File

@ -2283,4 +2283,16 @@ class ClientController extends AdminController
}
public function checkHRNumber($mobileNumber)
{
try {
$mobileNumberCount = $this->levelContactModel->where('mobile', $mobileNumber)->countAllResults();
return $this->respond(['status' => true, 'data' => $mobileNumberCount], 200);
} catch (\Exception $e) {
log_message('error', 'Error checking mobile number: ' . $e->getMessage());
return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500);
}
}
}

View File

@ -79,13 +79,16 @@ class EmployeeController extends AdminController
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(
client_id: $filterData['client_id'],
policy_id: $filterData['policy_id'],
status: $filterData['status'],
branch_id: $filterData['branch_id']
branch_id: $filterData['branch_id'],
emp_code : $filterData['emp_code'],
emp_name : $filterData['emp_name'],
status : $filterData['status'],
);
$data['getData'] = $filterData;
}
// dd($this->request->getGet());
$this->myLogger->logme('error', 'list called');
$this->loadLayout('employee_list', $data);
}

View File

@ -76,31 +76,68 @@ class EmployeePolicyModel extends Model
}
// -----------------------------------------------------------------------------------------------------
public function getEmployeePolicy($client_id,$policy_id,$status,$branch_id)
public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="")
{
$result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile'])
->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master
->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch
->join('tpa tpam', 'cp.tpa_id = tpam.id','left') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id','left') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
->where('emp.client_branch_id',$branch_id)
->where('employee_polices.is_active',1)
->where('emp.is_active',1)
->where('employee_polices.client_policy_id',$policy_id)
->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC');
if($status != 0 && !empty($status)){
$result = $this->select([
'employee_polices.*',
'pm.name as policy_name',
'im.short_name as insurer_short_name',
'ib.branch_name as insurer_branch_name',
'ib.branch_code as insurer_branch_code',
'tpam.name as tpa_name',
'tpam.short_name as tpa_short_name',
'tpab.branch_code as tpa_branch_code',
'cm.client_name',
'cm.short_name as client_short_name',
'emp.relationship',
'emp.relationship_code',
'emp.change_event',
'emp.emp_code',
'emp.name',
'emp.email_corporate',
'emp.dob',
'emp.gender',
'emp.emp_status',
'emp.is_active as emp_is_active',
'emp.mobile as mobile'
])
->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master
->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch
->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->orderBy('emp.emp_code', 'ASC')
->orderBy('employee_polices.employee_id', 'ASC');
// Conditionally add where clauses
if ($client_id !=0 && !empty($client_id)) {
$result->where('emp.client_id', $client_id);
}
if ($branch_id !=0 && !empty($branch_id)) {
$result->where('emp.client_branch_id', $branch_id);
}
if ($policy_id !=0 && !empty($policy_id)) {
$result->where('employee_polices.client_policy_id', $policy_id);
}
if ($status !=0 && !empty($status)) {
$result->where('employee_polices.status', $status);
}
if (!empty($emp_code)) {
$result->where('emp.emp_code', $emp_code);
}
if (!empty($emp_name)) {
$result->like('emp.name', $emp_name);
}
$result = $result->findAll();
return ($result);
// Always check these conditions
$result->where('employee_polices.is_active', 1)
->where('emp.is_active', 1);
return $result->findAll();
}

View File

@ -89,7 +89,7 @@
<div class="form-row">
<div class="form-group col-md-6">
<label for="mobile">Mobile<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
<input value="" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="mobile" onchange="checkMobileNumber(this)" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
</div>
<div class="form-group col-md-6">
<label for="designation">Designation<span class="text-danger">*</span></label>
@ -423,7 +423,7 @@ $(document).ready(function () {
<div class="form-row">
<div class="form-group col-md-6">
<label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" min="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
<input value="${contact !== undefined && contact !== false ? contact.mobile : ''}" type="text" class="form-control" placeholder="Enter Contact Mobile" name="mobile[]" id="${uniqueId}_mobile" onchange="checkMobileNumber(this)" onkeypress = "return onlyNumbers(event)" maxlength="10" min="10" data-parsley-type-message="Please enter a valid 10-digit mobile number." data-parsley-required-message="Please enter a valid 10-digit mobile number." required>
</div>
<div class="form-group col-md-6">
<label for="${uniqueId}_designation">Designation<span class="text-danger">*</span></label>
@ -563,6 +563,33 @@ $(document).ready(function () {
function checkMobileNumber(input){
console.log('function called')
console.log(input);
console.log('Input Value', input.value);
var mobileNumber = input.value;
var url = '<?php echo base_url('util/checkHRNumber/') ?>' + mobileNumber;
$.get(url, function(response){
console.log(response)
console.log(response.data)
if(response.data > 0){
toastr.warning('The Mobile Number Already Exist.', 'Warning');
input.value = "";
return;
}
}).fail(function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
});
}
</script>

View File

@ -59,6 +59,16 @@ table.dataTable tbody td {
</select>
</div>
<div class="form-group col-md-4">
<label>Employee Code</label> <br />
<input type="text" class="form-control" id="emp_code" name="emp_code" value="<?= isset($getData['emp_code']) && !empty($getData['emp_code']) ? $getData['emp_code'] : '' ?>">
</div>
<div class="form-group col-md-4">
<label>Employee Name</label> <br />
<input type="text" class="form-control" id="emp_name" name="emp_name" value="<?= isset($getData['emp_name']) && !empty($getData['emp_name']) ? $getData['emp_name'] : '' ?>">
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
@ -318,18 +328,22 @@ function fetchEmpolyeeList(event) {
var policy_id = $('#policies').val();
var status = $('#status2').val();
var branch_id = $('#branch_id').val();
var emp_code = $('#emp_code').val();
var emp_name = $('#emp_name').val();
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
}
// if (client_id == '0' || policy_id == '0') {
// alert('Please select values in both dropdowns.');
// return;
// }
var queryParams = {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
emp_code : emp_code,
emp_name : emp_name,
status : status,
};

View File

@ -587,16 +587,25 @@
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"buttons": [{
"extend": 'csv',
"text": 'CSV',
"title": 'Endorsement-List',
"className": 'my_class',
"exportOptions": {
"columns": ':not(:last-child)'
},
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'Endorsement-List',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)',
format: {
body: function (data, row, column, node) {
// Convert data to string to avoid scientific notation in CSV
if (!isNaN(data) && parseFloat(data) > 1e20) {
return `'${data}`;
}
return data.toString();// Ensures all data is treated as strings
}
}
}
}],
"initComplete": function(settings, json) {
initComplete: function(settings, json) {
$('.my_class').css({
"position": "relative",
"left": "79px"
@ -608,7 +617,12 @@
},
paging: true,
// pagingType: 'full_numbers'
columnDefs: [
{ type: 'scientific', targets: 0 } // Apply custom sorting type to the first column
],
});
});
</script>

View File

@ -136,6 +136,7 @@
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="https://cdn.datatables.net/plug-ins/2.0.8/sorting/scientific.js"></script>
<script>
toastr.options = {

View File

@ -377,13 +377,18 @@ function generateTable(rack_rate_type) {
$('#excel_table').html(table);
}
if ($('.duplicate').length > 0) {
//console.log('test');
toastr.warning("Duplicates found!", "warning");
$('.excel_table_class').empty();
$('.excel_textarea').val('');
if(secondKey != 2){
console.log(secondKey)
if ($('.duplicate').length > 0) {
//console.log('test');
toastr.warning("Duplicates found!", "warning");
$('.excel_table_class').empty();
$('.excel_textarea').val('');
}
}
if (emptyCellCount > 0) {
toastr.warning('Number of empty cells: ' + emptyCellCount);
$('.excel_table_class').empty();
@ -566,4 +571,5 @@ function submitData(rack_rate_type) {
}
</script>