CHANGE_ENROLLMENT_STATUS_AND_REMINDER_MAIL_CHANGE_THE_CODE : AADHAVAN

This commit is contained in:
aadhavan valli 2024-07-29 17:14:03 +05:30
parent 7875c1186a
commit bd4e51f144
13 changed files with 516 additions and 228 deletions

View File

@ -47,7 +47,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) {
$routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) {
$routes->get("view", "DashboardController::dashboard");
$routes->match(['get','post'],'view','DashboardController::dashboard');
$routes->get('get-notification', 'DashboardController::getDashboardNotifications');
$routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1');
$routes->get('get-pending-action', 'PendingActionsController::getPendingActions');
@ -272,7 +272,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status');
$routes->cli('cli/enrollment_status', 'DashboardController::enrollment_status');
$routes->get("processjob", "JobWorker::processJob");

View File

@ -405,7 +405,9 @@ class ClientController extends AdminController
foreach ($clientPoliceData as $key => $value) {
$clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
$clientPoliceData[$key]->open_date = date('d-M-Y', strtotime($value->open_date));
$clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date));
$clientPoliceData[$key]->close_date = date('d-M-Y', strtotime($value->close_date));
}
$editData['client_policy'] = $clientPoliceData;
@ -812,16 +814,17 @@ class ClientController extends AdminController
// }
// }
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$data['policy_no'] = $this->request->getPost('policy_no');
if($data['inception_type'] == 2){
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d');
$data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d');
$data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d');
}else{
$data['policy_start_date'] = null;
$data['policy_end_date'] = null;
$data['open_date'] = null;
$data['closedate'] = null;
$data['reminder_date'] = null;
}
@ -882,14 +885,16 @@ class ClientController extends AdminController
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
if($data['inception_type'] == 2){
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d');
$data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d');
$data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d');
}else{
$data['policy_start_date'] = null;
$data['policy_end_date'] = null;
$data['open_date'] = null;
$data['close_date'] = null;
$data['reminder_date'] = null;
}

View File

@ -6,6 +6,7 @@ use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Helpers\sendMailNotification;
use CodeIgniter\API\ResponseTrait;
@ -13,6 +14,11 @@ use App\Models\MessageModel;
use App\Models\UserMessageModel;
use App\Models\ClientModel;
use App\Models\JobModel;
use App\Models\ClientPolicyModel;
use App\Models\NotificationModel;
use App\Models\EmployeePolicyModel;
class DashboardController extends AdminController
{
@ -33,20 +39,22 @@ class DashboardController extends AdminController
public function dashboard()
{
$data = [];
$data = [];
$results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name,
client_branch.id as client_branch_id, client_branch.branch_name,
client_branch.branch_code, employees.id as employee_id,
employees.name as employee_name, employees.relationship,
employees.emp_code, employees.emp_status, auth_history.user_type')
->join('client_branch','clients.id = client_branch.client_id', 'left')
->join('employees','client_branch.id = employees.client_branch_id', 'left')
->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
->findAll();
client_branch.id as client_branch_id, client_branch.branch_name,
client_branch.branch_code, employees.id as employee_id,
employees.name as employee_name, employees.relationship,
employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id')
->join('client_branch', 'clients.id = client_branch.client_id', 'left')
->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left')
->join('employees', 'client_branch.id = employees.client_branch_id', 'left')
->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
->findAll();
$groupedData = [];
$employeeId = '';
foreach ($results as $row) {
$clientId = $row['client_id'];
$clientName = $row['client_name'];
@ -54,16 +62,14 @@ class DashboardController extends AdminController
$branchId = $row['client_branch_id'];
$branchName = $row['branch_name'];
$branchCode = $row['branch_code'];
if($employeeId != $row['employee_id']){
$employeeId = $row['employee_id'];
}else{
$employeeId = null;
}
$employeeName = $row['employee_name'] ;
$employeeRelationship = $row['relationship'] ;
$employeeEmpCode = $row['emp_code'] ;
$employeeId = $row['employee_id'];
$employeeName = $row['employee_name'];
$employeeRelationship = $row['relationship'];
$employeeEmpCode = $row['emp_code'];
$employeeEmpStatus = $row['emp_status'];
$employeeUserType = $row['user_type'];
$clientPolicyId = $row['client_policy_id'];
$policyTypeId = $row['policy_type_id'];
// Initialize the client entry if it doesn't exist
if (!isset($groupedData[$clientId])) {
@ -83,12 +89,23 @@ class DashboardController extends AdminController
'branch_code' => $branchCode,
'emp_login' => 0,
'emp_enroll' => 0,
'client_policies' => [],
'employees' => []
];
}
if ($employeeId !== null && $employeeRelationship == 'Self') {
// Append employee info to the branch's employees list
$groupedData[$clientId]['branches'][$branchId]['employees'][] = [
// Add the client policy to the branch's policies list if it exists, not already added, and policyTypeId is not equal to 1
if ($clientPolicyId !== null && $policyTypeId != 1 && !in_array(['client_policy_id' => $clientPolicyId, 'policy_type_id' => $policyTypeId], $groupedData[$clientId]['branches'][$branchId]['client_policies'])) {
$groupedData[$clientId]['branches'][$branchId]['client_policies'][] = [
'client_policy_id' => $clientPolicyId,
'policy_type_id' => $policyTypeId
];
}
// Append employee info to the branch's employees list if relationship is 'Self' and not already added
$employeeKey = $employeeId . '-' . $employeeName; // unique key to identify an employee
if ($employeeId !== null && $employeeRelationship == 'Self' && !isset($groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey])) {
$groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey] = [
'employee_id' => $employeeId,
'employee_name' => $employeeName,
'relationship' => $employeeRelationship,
@ -105,21 +122,31 @@ class DashboardController extends AdminController
$groupedData[$clientId]['branches'][$branchId]['emp_enroll']++;
}
}
$employeeId = $row['employee_id'];
}
// Re-index the arrays to match the expected structure
foreach ($groupedData as &$client) {
foreach ($client['branches'] as &$branch) {
$branch['employees'] = array_values($branch['employees']);
}
$client['branches'] = array_values($client['branches']);
}
// echo "<pre>";
$data['client_branch_emp_list'] = $groupedData;
$session = \Config\Services::session();
$session->set('enrollment_data', json_encode($data));
// echo "<pre>";
// print_r($data);die;
echo view('layout/header');
echo view('DashBoard', $data);
echo view('layout/footer');
}
public function getDashboardNotifications()
{
@ -148,4 +175,87 @@ class DashboardController extends AdminController
}
public static function enrollment_status() {
$clientModel = new ClientModel();
$clientPolicyModel = new ClientPolicyModel();
$notificationModel = new NotificationModel();
$employeePolicyModel = new EmployeePolicyModel();
$myLogger = \Config\Services::mylogger();
$client_policy_data = $clientPolicyModel
->where('id', 21)
->findAll();
$currentDate = date('Y-m-d');
// Update policy status based on start and end dates
foreach ($client_policy_data as $client_policy) {
$id = $client_policy['id'];
if ($currentDate == $client_policy['open_date']) {
$clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
}
if ($client_policy['close_date'] < $currentDate) {
$clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
}
}
$reminder_whole_mail = [];
foreach ($client_policy_data as $client_policy) {
// Fetch client data
$client_data = $clientModel->find($client_policy['client_id']);
// Fetch notification settings
$notification_data = $notificationModel->where('client_id', $client_policy['client_id'])
->where('template_name', 'member_reminder_mail')
->first();
// Check if notification should be sent
if ($notification_data && $notification_data['enabled'] == 1 && $currentDate == $client_policy['reminder_date']) {
// Fetch all employees related to the client policy
$employees = $employeePolicyModel->select('employees.*')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->findAll();
// Process each employee
foreach ($employees as $employee) {
if($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self'){
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
// Send the mail notification
$reminder_whole_mail[] = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
}
}
}
}
// Process and queue bulk emails
$temp_whole_data = [];
$count = 0;
foreach ($reminder_whole_mail as $whole_index => $values) {
foreach ($values as $index => $value) {
$temp_whole_data[] = $value;
$count++;
if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) {
if (!empty($temp_whole_data)) {
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
$temp_whole_data = [];
$count = 0;
}
}
}
}
if(count($temp_whole_data) > 0){
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
}
return json_encode(true);
}
}

View File

@ -3,13 +3,8 @@
namespace App\Controllers;
use App\Models\JobModel;
use App\Models\ClientModel;
use App\Models\ClientPolicyModel;
use App\Models\NotificationModel;
use App\Models\EmployeePolicyModel;
use App\Helpers\sendMailNotification;
class JobWorker extends AdminController
{
@ -330,70 +325,7 @@ class JobWorker extends AdminController
}
public static function enrollment_status() {
$clientModel = new ClientModel();
$clientPolicyModel = new ClientPolicyModel();
$notificationModel = new NotificationModel();
$employeePolicyModel = new EmployeePolicyModel();
$myLogger = \Config\Services::mylogger();
$client_policy_data = $clientPolicyModel->where('is_active', 1)
->where('policy_status', 1)
->where('inception_type', 2)
->findAll();
$currentDate = date('Y-m-d');
// Update policy status based on start and end dates
foreach ($client_policy_data as $client_policy) {
$id = $client_policy['id'];
if ($currentDate == $client_policy['policy_start_date']) {
$clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
}
if ($client_policy['policy_end_date'] < $currentDate) {
$clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
}
}
$reminder_whole_mail = [];
foreach ($client_policy_data as $client_policy) {
$employee = $employeePolicyModel->select('employees.*')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->first();
$client_data = $clientModel->find($client_policy['client_id']);
$notification_data = $notificationModel->where('client_id', $client_policy['client_id'])
->where('template_name', 'member_reminder_mail')
->first();
if ($notification_data && $notification_data['enabled'] == 1 && $currentDate == $client_policy['reminder_date']) {
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
$reminder_whole_mail[] = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
}
}
// Process and queue bulk emails
$temp_whole_data = [];
$count = 0;
foreach ($reminder_whole_mail as $whole_index => $values) {
foreach ($values as $index => $value) {
$temp_whole_data[] = $value;
$count++;
if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) {
if (!empty($temp_whole_data)) {
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
$temp_whole_data = [];
$count = 0;
}
}
}
}
return json_encode(true);
}

View File

@ -20,6 +20,9 @@ class ClientPolicyModel extends Model
"policy_start_date",
"policy_end_date",
"reminder_date",
"open_date",
"close_date",
"close_date",
"insured",
"no_of_employees",
"no_of_lives",

View File

@ -112,10 +112,7 @@
<label for="policy_end_date">Policy End Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter End Date " name="policy_end_date" id="end_date" required>
</div>
<div class="form-group col-md-4">
<label for="reminder_date">Reminder Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Reminder Date " name="reminder_date" id="reminder_date" required>
</div>
<div class="form-group col-md-4" id="policy_status_field">
<label for="policy_status">Policy Status</label>
<input value="" type="text" class="form-control" placeholder="Policy Status" id="policy_status" readonly>
@ -146,7 +143,18 @@
<label for="inception_type" style="position: relative;bottom: 5px;left: 85px;">Enable
Employee Enrolment Process</label>
</div>
<div class="form-group col-md-4">
<label for="open_date">Open Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter OpenS Date " name="open_date" id="open_date" >
</div>
<div class="form-group col-md-4">
<label for="close_date">Close Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Close Date " name="close_date" id="close_date" >
</div>
<div class="form-group col-md-4">
<label for="reminder_date">Reminder Date<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Reminder Date " name="reminder_date" id="reminder_date" >
</div>
<div class="form-group col-md-4">
<label class="switch" style="position: relative;top: 43px;left: 20px;">
<input id="policy_visibility" type="checkbox" name="enrolment_visibility" checked>
@ -180,16 +188,16 @@
<script>
$('#inception_type').change(function () {
var start_data = $('#start_date').parent();
var end_data = $('#end_date').parent();
var open_data = $('#open_date').parent();
var close_data = $('#close_date').parent();
var reminder_data = $('#reminder_date').parent();
if($(this).prop('checked')){
$(start_data).show();
$(end_data).show();
$(open_data).show();
$(close_data).show();
$(reminder_data).show();
}else{
$(start_data).hide();
$(end_data).hide();
$(open_data).hide();
$(close_data).hide();
$(reminder_data).hide();
}
})
@ -214,7 +222,6 @@
// Get today's date
var today = new Date();
// Initialize Flatpickr for the start date with today's date
var startDatePicker = flatpickr("#start_date", {
dateFormat: "d-m-Y",
defaultDate: today,
@ -227,21 +234,42 @@
}
});
// Calculate the end date (today + 1 year)
var endDate = new Date(today);
endDate.setFullYear(endDate.getFullYear() + 1);
endDate.setDate(endDate.getDate() - 1); // Set end date to last day of next year
// Initialize Flatpickr for the end date with the calculated end date
// Initialize Flatpickr for the start date with today's date
var openDatePicker = flatpickr("#open_date", {
dateFormat: "d-m-Y",
defaultDate: today,
allowInput: false,
onChange: function(selectedDates, dateStr, instance) {
var closeDate = new Date(selectedDates[0]);
closeDate.setFullYear(closeDate.getFullYear() + 1);
closeDate.setDate(closeDate.getDate() - 1); // Set end date to last day of selected year
closeDatePicker.setDate(closeDate);
}
});
// Calculate the end date (today + 1 year)
var closeDate = new Date(today);
closeDate.setFullYear(closeDate.getFullYear() + 1);
closeDate.setDate(closeDate.getDate() - 1); // Set end date to last day of next year
var endDatePicker = flatpickr("#end_date", {
dateFormat: "d-m-Y",
defaultDate: endDate,
defaultDate: closeDate,
allowInput: false
});
// Initialize Flatpickr for the end date with the calculated end date
var closeDatePicker = flatpickr("#close_date", {
dateFormat: "d-m-Y",
defaultDate: closeDate,
allowInput: false
});
var reminderDatePicker = flatpickr("#reminder_date", {
dateFormat: "d-m-Y",
defaultDate: endDate,
defaultDate: closeDate,
allowInput: false
});
@ -308,9 +336,9 @@
<td>${policy_name_data}</td>
<td>${item.branch_name ? item.branch_name : ' - '}</td>
<td>${tpaValue}</td>
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
<td>${(item.open_date)} / ${(item.close_date)}</td>
<td style="text-align: center;">${(enrollmentStatus)}</td>
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>${checkDateStatus(item.close_date, 1)}</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
@ -352,8 +380,10 @@
$('#insurer').val('').change();
$('#tpa').val('').change();
$('#policy_no').val('').change();
$('#policy_no').val('').change();
$('#start_date').val('').change();
$('#end_date').val('').change();
$('#close_date').val('').change();
// $('#policy').html('<option value="" selected>Select Policy</option>').change();
$('#policy_form_action').val('<?= base_url("client/policy/create"); ?>');
$('#policy_status_field').hide()
@ -382,8 +412,10 @@
$('#insurer').val('').change();
$('#tpa').val('').change();
$('#policy_no').val('').change();
$('#start_date').val('').change();
$('#start_no').val('').change();
$('#end_date').val('').change();
$('#open_date').val('').change();
$('#close_date').val('').change();
$('#policy').html('<option value="" selected>Select Policy</option>');
$('#base_policy_id').hide();
$('#client_branch').val('').change();
@ -532,9 +564,9 @@
<td>${policy_name_data}</td>
<td>${item.branch_name}</td>
<td>${tpaValue}</td>
<td>${rearrangeDateFormat(item.policy_start_date)} / ${rearrangeDateFormat(item.policy_end_date)}</td>
<td>${rearrangeDateFormat(item.open_date)} / ${rearrangeDateFormat(item.close_date)}</td>
<td style="text-align: center;">${(enrollmentStatus)}</td>
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>${checkDateStatus(item.close_date, 1)}</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
@ -555,8 +587,8 @@
$('#insurer').val('');
$('#tpa').val('');
$('#policy_no').val('');
$('#start_date').val('');
$('#end_date').val('');
$('#open_date').val('');
$('#close_date').val('');
$('#policy').html('<option value="" selected>Select Policy</option>');
},
error: function(xhr, status, error) {
@ -689,6 +721,7 @@
// get the client policy data for edit
$('body').on('click', '.btnPolicyEdit', function() {
var policy_form_action = '';
var policy_id = $(this).attr('data-id');
@ -739,18 +772,26 @@
$('#policy_PrimaryKey').val(res.data.id);
$('#insurer_policy_id').val(res.data.policy_id);
$('#policy_no').val(res.data.policy_no);
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
// $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
$('#open_date').val(rearrangeDateFormat(res.data.open_date));
// $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
$('#close_date').val(rearrangeDateFormat(res.data.close_date));
$('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date));
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#policy_status').val(checkDateStatus(res.data.policy_close_date));
$('#gst_no').val(gst);
$('#policy_status_field').show();
if (res.data.inception_type == 2) {
$('#inception_type').prop('checked', true);
$('#open_date').parent().show();
$('#close_date').parent().show();
$('#reminder_date').parent().show();
} else {
$('#inception_type').prop('checked', false);
$('#open_date').parent().hide();
$('#close_date').parent().hide();
$('#reminder_date').parent().hide();
}
@ -1218,8 +1259,8 @@
$('#insurer').val('').change();
$('#tpa').val('').change();
$('#policy_no').val('');
$('#start_date').val('');
$('#end_date').val('');
$('#open_date').val('');
$('#close_date').val('');
$('#reminder_date').val('');
$('#base_policy').val('').change();
@ -1325,8 +1366,8 @@
if($('#inception_type').prop('checked')){
}else{
$('#start_date').parent().hide();
$('#end_date').parent().hide();
$('#open_date').parent().hide();
$('#close_date').parent().hide();
$('#reminder_date').parent().hide();
}
})
@ -1437,8 +1478,8 @@
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change();
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
$('#policy_no').val(res.data.policy_no).change();
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)).change();
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)).change();
$('#open_date').val(rearrangeDateFormat(res.data.open_date)).change();
$('#close_date').val(rearrangeDateFormat(res.data.close_date)).change();
}
},

View File

@ -11,10 +11,11 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
<style>
/* Existing CSS ... */
.carousel-control-next {
right: -18px;
}
.carousel-control-prev {
left: -38px;
left: -24px;
}
.status-option {
@ -48,14 +49,14 @@
.scroll-item {
flex: 0 0 auto;
width: 33%; /* Adjust based on the number of items you want to show */
width: 30%; /* Adjust based on the number of items you want to show */
box-sizing: border-box;
padding: 0 10px;
}
@media (min-width: 1200px) {
.col-xl-3 {
max-width: 32% !important;
max-width: 30% !important;
}
}
@ -92,7 +93,7 @@
.carousel-item {
height: auto; /* Adjust if needed */
/* margin-left: 80px; */
margin-left: 57px;
}
.card {
@ -105,7 +106,7 @@
}
.carousel-control-prev-icon, .carousel-control-next-icon {
background-color: rgba(0,0,0,0.5); /* Change color as needed */
/* background-color: rgba(0,0,0,0.5); Change color as needed */
}
.carousel-control-prev-icon {
@ -139,14 +140,14 @@
<div class="tab-pane fade" id="enrollment-dash-tab">
<div class="row visa_status_count_view">
<div class="col-12">
<div class="card" style="border: 0px;">
<div class="card" style="border: 0px;height: 470px;">
<div class="card-body status-option" id="statusContent" style="padding: 0.5rem !important;background-color: white;">
<!-- Search Input Field -->
<div class="row">
<div class="col-3">
<select class="form-control" name="" id="">
<option value="">Open Enrollment</option>
<option value="">Close Enrollment</option>
<select class="form-control" name="" id="enrollment_status_open_close">
<option value="open">Open Enrollment</option>
<option value="close">Close Enrollment</option>
</select>
</div>
<div class="col-5"></div>
@ -166,86 +167,86 @@
// Start a new carousel item if needed
if ($currentItem % $itemsPerSlide == 0) {
if (!$isActive) echo '</div>'; // Close previous carousel item
echo '<div class="carousel-item' . ($isActive ? ' active' : '') . '">';
$isActive = false;
echo '<div class="carousel-item' . ($isActive ? ' active' : '') . '">';
$isActive = false;
}
if(count($branches['client_policies']) != 0){ ?>
<!-- New Card Layout for each item -->
<div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="<?php echo $clients['short_name']; ?>" data-branch="<?php echo $branches['branch_name']; ?>">
<div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<div class="card-header add_card_background_random" >
<div class="row">
<div class="col-8 emp-count-view-click" >
<div class="d-flex justify-content-between">
<div class="w-100 " >
<h3 class="my-2 py-1" ><span data-plugin="counterup" style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;" onclick="enrollment_list(this, 'emp_count_view_click')"><?php echo isset($branches['employees']) ? count($branches['employees']) : '0'; ?></span></h3>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 emp-count-view-click" >
<div class="d-flex justify-content-between">
<div class="w-100" >
<h5 class="mt-0 text-truncate" title="Branch Info" style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;"><?php echo isset($clients['short_name']) ? $clients['short_name'] : 'N/A'; ?> - <?php echo isset($branches['branch_name']) ? $branches['branch_name'] : 'N/A'; ?></h5>
</div>
</div>
</div>
<!-- <div class="col-3 center_text emp-count-view-click" >
<div class="d-flex justify-content-between">
<div class="w-100 text-center" >
<p class="mb-0 text-muted">
<span class="text-success mr-2"></span>
<span class="text-nowrap">Emp Count</span>
</p>
</div>
</div>
</div> -->
</div>
</div>
<div class="card-body" >
<input type="text" class="client_id" value="<?php echo $clients['client_id']; ?>" hidden>
<input type="text" class="client_branch_id" value="<?php echo $branches['client_branch_id'] ?>" hidden>
<div class="row emp-status" style="margin-top: -9px;">
<div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_logged_in_view_click')"><?php echo isset($branches['emp_login']) ? $branches['emp_login'] : '0'; ?></span><br>
<span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span>
</div>
<div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"><?php echo isset($branches['emp_login']) ? count($branches['employees']) - $branches['emp_login'] : '0'; ?></span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;margin-left: -13px;">Not Logged-In</span>
</div>
</div>
<div class="row emp-status" style="margin-top: 5px;">
<div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_enrolled_view_click')"><?php echo isset($branches['emp_enroll']) ? count($branches['employees']) - $branches['emp_enroll'] : '0'; ?></span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span>
</div>
<div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_enrolled_view_click')"><?php echo isset($branches['emp_enroll']) ? $branches['emp_enroll'] : '0'; ?></span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div>
</div>
</div>
</div>
</div>
<?php
$currentItem++;
}
}
?>
<!-- New Card Layout for each item -->
<div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="<?php echo $clients['short_name']; ?>" data-branch="<?php echo $branches['branch_name']; ?>">
<div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<div class="card-header" >
<div class="row">
<div class="col-8 center_text emp-count-view-click" >
<div class="d-flex justify-content-between">
<div class="w-100 text-center" >
<h3 class="my-2 py-1 number_css" ><span data-plugin="counterup" style="margin-left: 113px;font-size: 2.0rem;" onclick="enrollment_list(this, 'emp_count_view_click')"><?php echo isset($branches['employees']) ? count($branches['employees']) : '0'; ?></span></h3>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 center_text emp-count-view-click" >
<div class="d-flex justify-content-between">
<div class="w-100 text-center" >
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Branch Info" style="text-align: center;"><?php echo isset($clients['short_name']) ? $clients['short_name'] : 'N/A'; ?> - <?php echo isset($branches['branch_name']) ? $branches['branch_name'] : 'N/A'; ?></h5>
</div>
</div>
</div>
<!-- <div class="col-3 center_text emp-count-view-click" >
<div class="d-flex justify-content-between">
<div class="w-100 text-center" >
<p class="mb-0 text-muted">
<span class="text-success mr-2"></span>
<span class="text-nowrap">Emp Count</span>
</p>
</div>
</div>
</div> -->
</div>
</div>
<div class="card-body add_card_background_random" >
<input type="text" class="client_id" value="<?php echo $clients['client_id']; ?>" hidden>
<input type="text" class="client_branch_id" value="<?php echo $branches['client_branch_id'] ?>" hidden>
<div class="row emp-status" style="margin-top: -9px;">
<div class="col-6 center_text emp-count-view-click" >
<span style="font-size: large;color: white !important;" class="number_css" onclick="enrollment_list(this, 'emp_logged_in_view_click')"><?php echo isset($branches['emp_login']) ? $branches['emp_login'] : '0'; ?></span><br>
<span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span>
</div>
<div class="col-6 center_text emp-count-view-click" >
<span style="font-size: large;color: white !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"><?php echo isset($branches['emp_login']) ? count($branches['employees']) - $branches['emp_login'] : '0'; ?></span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;margin-left: -13px;">Not Logged-In</span>
</div>
</div>
<div class="row emp-status" style="margin-top: -9px;">
<div class="col-6 center_text emp-count-view-click" >
<span style="font-size: large;color: white !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_enrolled_view_click')"><?php echo isset($branches['emp_enroll']) ? count($branches['employees']) - $branches['emp_enroll'] : '0'; ?></span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span>
</div>
<div class="col-6 center_text emp-count-view-click" >
<span style="font-size: large;color: white !important;" class="number_css" onclick="enrollment_list(this, 'emp_enrolled_view_click')"><?php echo isset($branches['emp_enroll']) ? $branches['emp_enroll'] : '0'; ?></span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div>
</div>
</div>
</div>
</div>
<?php
$currentItem++;
}
}
if ($currentItem % $itemsPerSlide != 0) echo '</div>'; // Close the last carousel item
?>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" style="width: 28px;"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg> <!-- <img src="<?php echo base_url()?>public/assets/images/left_arrow.png" alt="<"> -->
<!-- <span class="carousel-control-prev-icon" aria-hidden="true"></span> -->
<!-- <span class="sr-only">Previous</span> -->
<i class="fas fa-angle-left"></i>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" style="width: 28px;"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z"/></svg>
<!-- <span class="carousel-control-next-icon" aria-hidden="true"></span> -->
<span class="sr-only">Next</span>
</a>
</div>
@ -257,6 +258,8 @@
<script>
$(document).ready(function() {
var lastDirection = ''; // Variable to keep track of the last direction
// Scroll functionality
$('.scroll-container').on('wheel', function(e) {
if (e.originalEvent.deltaY < 0) {
@ -300,9 +303,58 @@ $(document).ready(function() {
}
});
function navigateCarousel(direction) {
lastDirection = direction; // Track the direction
var $carousel = $('#carouselExampleControls');
var $activeItem = $carousel.find('.carousel-item.active');
if (direction === 'next') {
if ($activeItem.find('.scroll-item').length === 0) {
$carousel.carousel('next');
setTimeout(checkEmptyCarouselItem, 100); // Check after slide transition
} else {
$carousel.carousel('next');
}
} else if (direction === 'prev') {
if ($activeItem.find('.scroll-item').length === 0) {
$carousel.carousel('prev');
setTimeout(checkEmptyCarouselItem, 100); // Check after slide transition
} else {
$carousel.carousel('prev');
}
}
}
function checkEmptyCarouselItem() {
var $carousel = $('#carouselExampleControls');
var $activeItem = $carousel.find('.carousel-item.active');
// Check if the active item is empty
if ($activeItem.find('.scroll-item').length === 0) {
// If empty, move to the next item
$carousel.carousel(lastDirection === 'next' ? 'next' : 'prev');
}
}
// Attach click handlers to carousel controls
$('.carousel-control-next').on('click', function() {
navigateCarousel('next');
});
$('.carousel-control-prev').on('click', function() {
navigateCarousel('prev');
});
// Check the carousel item when the slide changes
$('#carouselExampleControls').on('slid.bs.carousel', function() {
checkEmptyCarouselItem();
});
// Initial check for empty carousel items
checkEmptyCarouselItem();
});
function enrollment_list(current_element, type) {
var clientId = $(current_element).closest('.carousel-slide-item').find('.client_id').val();
var branchId = $(current_element).closest('.carousel-slide-item').find('.client_branch_id').val();
@ -320,17 +372,162 @@ function enrollment_list(current_element, type) {
window.location.href = `${url}?${params.toString()}`;
}
document.addEventListener('DOMContentLoaded', function() {
// Array of predefined colors
var colors = ['yellowgreen', 'indianred', 'cadetblue', 'burlywood', 'darkolivegreen'];
var colors = ['#EBE8FF', '#FFECE5', '#FFE8F5'];
// '#6ADBE3'
// Array of predefined background images
var images = [
'/public/assets/images/mask_group.png',
'/public/assets/images/mask_group_orange.png',
'/public/assets/images/mask_group_pink.png',
];
// '/public/assets/images/mask_group_blue.png'
// Counter to keep track of the current color index
var colorIndex = 0;
// Counter to keep track of the current index
var index = 0;
// Apply a color from the array to each card-header in sequence
// Base URL for the images
var baseUrl = '<?php echo base_url() ?>';
// Apply a color and image from the arrays to each card-header in sequence
document.querySelectorAll('.add_card_background_random').forEach(function(header) {
header.style.backgroundColor = colors[colorIndex];
colorIndex = (colorIndex + 1) % colors.length; // Move to the next color, cycling back to 0 if needed
header.style.backgroundColor = colors[index % colors.length];
header.style.backgroundImage = `url(${baseUrl + images[index % images.length]})`;
header.style.backgroundSize = 'cover'; // Ensure the image covers the entire div
header.style.backgroundPosition = 'center'; // Center the image within the div
index++;
});
});
$('#enrollment_status_open_close').change(function () {
if ($(this).val() == 'open') {
console.log("open");
} else {
console.log("close");
// Fetch the session data from PHP
var enrollment_data = '<?php echo $_SESSION['enrollment_data']; ?>';
try {
// Parse JSON data
var data = JSON.parse(enrollment_data);
console.log('Parsed data:', data);
// Ensure data is an object and client_branch_emp_list is treated as an array
if (data && typeof data === 'object') {
if (Array.isArray(data.client_branch_emp_list)) {
console.log('client_branch_emp_list:', data.client_branch_emp_list);
updateCarouselWithData(data);
} else {
// Convert client_branch_emp_list to an array if it's not already
if (data.client_branch_emp_list && typeof data.client_branch_emp_list === 'object') {
// If it's an object but not an array, wrap it in an array
data.client_branch_emp_list = [data.client_branch_emp_list];
} else {
// Handle the case where it's neither an array nor an object
console.error('client_branch_emp_list is not an array or object:', data.client_branch_emp_list);
data.client_branch_emp_list = []; // Ensure it is at least an empty array
}
console.log('Converted client_branch_emp_list:', data.client_branch_emp_list);
updateCarouselWithData(data);
}
} else {
console.error('Parsed data is not an object:', data);
}
} catch (e) {
console.error('Error parsing JSON:', e);
}
}
});
function updateCarouselWithData(data) {
console.log(data);
var itemsPerSlide = 3; // Number of items per slide
var currentItem = 0; // Counter for items
var isActive = true; // Variable to set the first item as active
var carouselInner = $('.carousel-inner');
// Clear existing carousel items
carouselInner.empty();
// Check if data.client_branch_emp_list is valid
if (Array.isArray(data.client_branch_emp_list) && data.client_branch_emp_list.length > 0) {
console.log("Processing array...");
// Handle the case where data.client_branch_emp_list is an array
var items = data.client_branch_emp_list[0];
console.log("Items data:", items);
array.forEach(element => {
});
// Validate if items is an array
if (Array.isArray(items)) {
for (var i = 0; i < items.length; i++) {
var item = items[i];
console.log("--------------");
console.log(item);
// Create a new carousel item every `itemsPerSlide` items
if (currentItem % itemsPerSlide === 0) {
if (!isActive) carouselInner.append('</div>'); // Close previous carousel item
carouselInner.append('<div class="carousel-item' + (isActive ? ' active' : '') + '">');
isActive = false;
}
// Generate HTML for each item
var itemHtml = `
<div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="${item.client_name}" data-branch="${item.branch_name}">
<div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<div class="card-header add_card_background_random">
<div class="row">
<div class="col-8 emp-count-view-click">
<div class="d-flex justify-content-between">
<div class="w-100">
<h3 class="my-2 py-1">
<span data-plugin="counterup" style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;">${item.employee_count}</span>
</h3>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 emp-count-view-click">
<div class="d-flex justify-content-between">
<div class="w-100">
<h5 class="mt-0 text-truncate" title="Branch Info" style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;">${item.client_name} - ${item.branch_name}</h5>
</div>
</div>
</div>
</div>
</div>
<div class="card-body">
<!-- Add more details based on the item data -->
</div>
</div>
</div>
`;
carouselInner.find('.carousel-item.active').append(itemHtml);
currentItem++;
}
// Close the last carousel item if it was opened
if (currentItem % itemsPerSlide !== 0) carouselInner.append('</div>');
} else {
console.error('Expected an array for items, but got:', items);
}
} else if (typeof data.client_branch_emp_list === 'object') {
console.error('client_branch_emp_list is an object, not an array:', data.client_branch_emp_list);
} else {
console.error('client_branch_emp_list is missing or not in the expected format:', data.client_branch_emp_list);
}
// Initialize or refresh carousel if needed
$('#carouselExampleControls').carousel('dispose').carousel();
}
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B