diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index feca6fd..564fc92 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -761,36 +761,45 @@ class EmployeeController extends AdminController } - public function empby_client_clientbranch($client_id, $branch_id) - { - - $results = $this->clientModel->select('employees.id as employee_id, employees.name as employee_name, - employees.relationship, employees.emp_code, - employees.emp_status, auth_history.user_type') - ->join('employees', $client_id .'= employees.client_id AND ' . $branch_id . '= employees.client_branch_id', 'left') - ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') - ->where('employees.is_active', 1) - ->where('employees.emp_status !=', 'truncated') - ->groupBy('employees.id') - ->findAll(); - + public function empby_client_clientbranch($client_id, $branch_id, $client_policy_id) + { + + $results = $this->clientModel->select(' + employees.id as employee_id, + employees.name as employee_name, + employees.relationship, + employees.emp_code, + employees.emp_status, + auth_history.user_type + ') + ->join('employees', $client_id . '= employees.client_id AND ' . $branch_id . '= employees.client_branch_id', 'left') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') + ->where('employees.is_active', 1) + ->where('employees.emp_status !=', 'truncated') + ->where('employee_polices.client_policy_id', $client_policy_id) + ->where('employee_polices.is_active', 1) + ->where('employee_polices.status !=', 'truncated') + ->groupBy('employees.id') + ->findAll(); + $groupedData = []; $employeeId = ''; foreach ($results as $row) { - if($employeeId != $row['employee_id']){ + if ($employeeId != $row['employee_id']) { $employeeId = $row['employee_id']; - }else{ + } else { $employeeId = null; } - $employeeName = $row['employee_name'] ; - $employeeRelationship = $row['relationship'] ; - $employeeEmpCode = $row['emp_code'] ; + $employeeName = $row['employee_name']; + $employeeRelationship = $row['relationship']; + $employeeEmpCode = $row['emp_code']; $employeeEmpStatus = $row['emp_status']; $employeeUserType = $row['user_type']; - - + + // if ($employeeId !== null && $employeeRelationship == 'Self') { if ($employeeId !== null) { // Append employee info to the branch's employees list @@ -802,16 +811,16 @@ class EmployeeController extends AdminController 'emp_status' => $employeeEmpStatus, 'user_type' => $employeeUserType ]; - } $employeeId = $row['employee_id']; } - - - return json_encode($groupedData); - } - + // print_r($groupedData); die; + + return json_encode($groupedData); + } + + /** diff --git a/app/Views/enrollment_list.php b/app/Views/enrollment_list.php index d88a461..bc59899 100755 --- a/app/Views/enrollment_list.php +++ b/app/Views/enrollment_list.php @@ -314,17 +314,18 @@ var client_id = $('#clients').val(); var branch_id = $('#branch_id').val(); - if (client_id == '0' || branch_id == '0') { + var client_policy_id = $('#client_policy_id').val(); + if (client_id == '0' || branch_id == '0' || client_policy_id == '0') { Swal.fire({ title: "warning!", - text: 'Please select the Client and Client Branch.', + text: 'Please select the Client, Client Branch and Client Policy.', icon: "warning" }); return false; } $.ajax({ - url: '' + '/employee/empby_client_clientbranch/' + client_id + '/' + branch_id, + url: '' + '/employee/empby_client_clientbranch/' + client_id + '/' + branch_id + '/' + client_policy_id, method: 'GET', headers: { "Content-Type": "application/json", @@ -359,7 +360,7 @@ var loggedIn_count = 0; data.forEach(function(employee, index) { - if(employee.emp_status !== 'draft'){ + if(employee.emp_status === 'enrolled'){ var enrolled = 'Yes'; enrolled_count++; }else{ @@ -369,8 +370,13 @@ if(employee.user_type === 'employee'){ var loggedIn = 'Yes'; loggedIn_count++; - }else{ - var loggedIn = 'No'; + }else{ + + if (employee.relationship && employee.relationship.toLowerCase() === "self") { + var loggedIn = 'No'; + }else{ + var loggedIn = '-'; + } } table.row.add([ @@ -485,6 +491,8 @@ $('#emp_enrolled_view_click').on('click', function() { + + console.log($(this).hasClass('click_hover')); if ($(this).hasClass('click_hover')) { // $(this).removeClass('click_hover'); $('.click_hover').each(function() { @@ -496,7 +504,7 @@ $(this).removeClass('click_hover'); }); $('#emp_enrolled_view_click').addClass('click_hover'); - filterTable(3, 'Yes'); // Filter "Enrolled" column (4th column, index 3) + filterTable(4, 'Yes'); // Filter "Enrolled" column (4th column, index 3) } }); @@ -512,7 +520,7 @@ $(this).removeClass('click_hover'); }); $('#emp_not_enrolled_view_click').addClass('click_hover'); - filterTable(3, 'No'); // Filter "Enrolled" column (4th column, index 3) + filterTable(4, 'No'); // Filter "Enrolled" column (4th column, index 3) } }); @@ -528,7 +536,7 @@ $(this).removeClass('click_hover'); }); $('#emp_logged_in_view_click').addClass('click_hover'); - filterTable(4, 'Yes'); // Filter "Logged-In" column (5th column, index 4) + filterTable(5, 'Yes'); // Filter "Logged-In" column (5th column, index 4) } }); @@ -544,7 +552,7 @@ $(this).removeClass('click_hover'); }); $('#emp_not_logged_in_view_click').addClass('click_hover'); - filterTable(4, 'No'); // Filter "Logged-In" column (5th column, index 4) + filterTable(5, 'No'); // Filter "Logged-In" column (5th column, index 4) } }); @@ -738,7 +746,6 @@ }); }); - function sendManualReminder(input) { console.log('sendManualReminder function called'); @@ -779,44 +786,45 @@ return false; } - Swal.fire({ - title: "Do you want to send reminder mail?", - showDenyButton: true, - showCancelButton: false, - confirmButtonText: "Yes,Send", - denyButtonText: "Don't Send" - }).then((result) => { + Swal.fire({ + title: "Do you want to send reminder mail?", + showDenyButton: true, + showCancelButton: false, + confirmButtonText: "Yes,Send", + denyButtonText: "Don't Send" + }).then((result) => { - if (result.isConfirmed) { + if (result.isConfirmed) { - $.ajax({ - url: '' + client_id + '/' + client_branch_id + '/' + client_policy_id, - type: "GET", - dataType: 'json', - success: function(res) { + $.ajax({ + url: '' + client_id + '/' + client_branch_id + '/' + client_policy_id, + type: "GET", + dataType: 'json', + success: function(res) { - console.log('send_manual_reminder', res) + console.log('send_manual_reminder', res) - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); - if(res.status == false){ - toastr.info(res.message, 'INFO'); - }else{ - toastr.success(res.message, 'SUCCESS'); + if(res.status == false){ + toastr.info(res.message, 'INFO'); + }else{ + toastr.success(res.message, 'SUCCESS'); + } + + }, + error: function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); } - - }, - error: function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - } - }); - // Swal.fire("Saved!", "", "success"); - } - }); + }); + // Swal.fire("Saved!", "", "success"); + } + }); } +