FIX_DASHBOARD_ISSUE : RV

This commit is contained in:
VENKATESHWARAN 2025-03-01 17:45:26 +05:30
parent b878550c5d
commit 47970b7d98
4 changed files with 542 additions and 561 deletions

View File

@ -98,18 +98,59 @@ class DashboardController extends AdminController
public function dashboard() public function dashboard()
{ {
$data = []; $data['page_name'] = 'Dashboard';
$results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, $db = db_connect();
client_branch.id as client_branch_id, client_branch.branch_name, $sql = "SELECT
client_branch.branch_code, employees.id as employee_id, clients.id AS client_id,
employees.name as employee_name, employees.relationship, clients.client_name,
employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id') clients.short_name,
->join('client_branch', 'clients.id = client_branch.client_id', 'left') client_branch.id AS client_branch_id,
->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left') client_branch.branch_name,
->join('employees', 'client_branch.id = employees.client_branch_id', 'left') client_branch.branch_code,
->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
->findAll(); COUNT(employees.id) AS total_employees,
SUM(CASE WHEN employees.emp_status = 'draft' THEN 1 ELSE 0 END) AS draft_count,
SUM(CASE WHEN employees.emp_status IN ('enrolled', 'active') THEN 1 ELSE 0 END) AS enrolled_count,
SUM(CASE WHEN auth_history.user_id IS NOT NULL THEN 1 ELSE 0 END) AS logged_in_count,
SUM(CASE WHEN auth_history.user_id IS NULL THEN 1 ELSE 0 END) AS not_logged_in_count,
CASE
WHEN EXISTS (
SELECT 1 FROM client_policy
WHERE client_policy.client_branch_id = client_branch.id
AND client_policy.is_active = 1
AND client_policy.open_for_enrollment = 1
) THEN 1
ELSE 0
END AS open_or_close_enrollment
FROM clients
LEFT JOIN client_branch ON clients.id = client_branch.client_id
LEFT JOIN employees ON client_branch.id = employees.client_branch_id
LEFT JOIN (
SELECT user_id, user_type
FROM auth_history
WHERE user_type = 'employee'
GROUP BY user_id
) AS auth_history ON employees.id = auth_history.user_id
WHERE employees.relationship = 'Self'
AND employees.emp_status IN ('draft', 'enrolled', 'active')
AND employees.is_active = 1
AND clients.is_active = 1
AND client_branch.is_active = 1
GROUP BY clients.id, client_branch.id";
$query = $db->query($sql);
$results = $query->getResultArray();
$data['client_branch_emp_list'] = $results;
$session = \Config\Services::session();
$session->set('enrollment_data', json_encode($data));
// $pendingActionsController = new PendingActionsController; // $pendingActionsController = new PendingActionsController;
// $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); // $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
@ -118,95 +159,6 @@ class DashboardController extends AdminController
// $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData); // $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
// $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData); // $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
$groupedData = [];
foreach ($results as $row) {
$clientId = $row['client_id'];
$clientName = $row['client_name'];
$shortName = $row['short_name'];
$branchId = $row['client_branch_id'];
$branchName = $row['branch_name'];
$branchCode = $row['branch_code'];
$clientPolicyId = $row['client_policy_id'];
$policyTypeId = $row['policy_type_id'];
$employeeId = '';
if ($employeeId != $row['employee_id']) {
$employeeId = $row['employee_id'];
} else {
$employeeId = null;
}
$employeeName = $row['employee_name'];
$employeeRelationship = $row['relationship'];
$employeeEmpCode = $row['emp_code'];
$employeeEmpStatus = $row['emp_status'];
$employeeUserType = $row['user_type'];
// Initialize the client entry if it doesn't exist
if (!isset($groupedData[$clientId])) {
$groupedData[$clientId] = [
'client_id' => $clientId,
'client_name' => $clientName,
'short_name' => $shortName,
'branches' => []
];
}
// Initialize the branch entry if it doesn't exist
if (!isset($groupedData[$clientId]['branches'][$branchId])) {
$groupedData[$clientId]['branches'][$branchId] = [
'client_branch_id' => $branchId,
'branch_name' => $branchName,
'branch_code' => $branchCode,
'emp_login' => 0,
'emp_enroll' => 0,
'client_policies' => [],
'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 error 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,
'emp_code' => $employeeEmpCode,
'emp_status' => $employeeEmpStatus,
'user_type' => $employeeUserType
];
if (!empty($employeeUserType)) {
$groupedData[$clientId]['branches'][$branchId]['emp_login']++;
}
// Increment emp_enroll if emp_status is not 'draft'
if ($employeeEmpStatus !== 'draft') {
$groupedData[$clientId]['branches'][$branchId]['emp_enroll']++;
}
}
}
// 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']);
}
$data['client_branch_emp_list'] = $groupedData;
$session = \Config\Services::session();
$session->set('enrollment_data', json_encode($data));
// echo "<pre>";
// $data['pendingActionsData'] = $pendingActionsData; // $data['pendingActionsData'] = $pendingActionsData;
// $data['businessTeamCount'] = count($businessTeamData) ?? 0; // $data['businessTeamCount'] = count($businessTeamData) ?? 0;
// $data['financeTeamCount'] = count($financeTeamData) ?? 0; // $data['financeTeamCount'] = count($financeTeamData) ?? 0;
@ -214,9 +166,8 @@ class DashboardController extends AdminController
// $data['financeTeamStatusData'] = $financeTeamStatusData; // $data['financeTeamStatusData'] = $financeTeamStatusData;
// $data['policyStatus'] = $this->policyStatus; // $data['policyStatus'] = $this->policyStatus;
// $data['colorShades'] = $this->colorShades; // $data['colorShades'] = $this->colorShades;
// dd($data);die;
$data['page_name'] = 'Dashboard'; // dd($data);
echo view('layout/header', $data); echo view('layout/header', $data);
echo view('DashBoard', $data); echo view('DashBoard', $data);

View File

@ -2199,12 +2199,15 @@ class EmployeeController extends AdminController
} }
} }
//UPDATE EMPLOYEE
public function update_emp_data() public function update_emp_data()
{ {
$data = $this->request->getPost(); $data = $this->request->getPost();
// print_rr($data);die(); // print_rr($data);die();
// $data['dob'] = date('Y-m-d', strtotime($data['dob'])); // $data['dob'] = date('Y-m-d', strtotime($data['dob']));
$data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d'); if (isset($data['dob'])) {
$data['dob'] = change_date_format($data['dob'], null, 'Y-m-d');
}
// print_rr($data); die; // print_rr($data); die;
// Fetch current employee data // Fetch current employee data
@ -2212,14 +2215,17 @@ class EmployeeController extends AdminController
if ($employee_data['relationship'] == 'Self') { if ($employee_data['relationship'] == 'Self') {
if ($employee_data['gender'] != $data['gender']) { if (isset($data['gender'])) {
$spouse_gender = ($data['gender'] == 'M') ? 'F' : 'M'; if ($employee_data['gender'] != $data['gender']) {
$this->employeeModel
->where('emp_code', $employee_data['emp_code']) $spouse_gender = ($data['gender'] == 'M') ? 'F' : 'M';
->where('relationship', 'Spouse') $this->employeeModel
->set(['gender' => $spouse_gender]) ->where('emp_code', $employee_data['emp_code'])
->update(); ->where('relationship', 'Spouse')
->set(['gender' => $spouse_gender])
->update();
}
} }
} }

View File

@ -544,6 +544,10 @@ if (!function_exists('change_date_format')) {
'Y/m/d', // 2024/12/01 'Y/m/d', // 2024/12/01
'Y.m.d', // 2024.12.01 'Y.m.d', // 2024.12.01
'Y,m,d', // 2024,12,01 'Y,m,d', // 2024,12,01
'd/m/Y', // 01/01/2025
'd-m-Y', // 01-01-2025
]; ];
try { try {

View File

@ -1,9 +1,9 @@
<div class="tab-pane active show" id="pending-actions-dash-tab" style="/*padding-left: 35px;*/padding-right: 35px;"> <div class="tab-pane active show" id="pending-actions-dash-tab" style="/*padding-left: 35px;*/padding-right: 35px;">
<div class="row visa_status_count_view"> <div class="row visa_status_count_view">
<div class="col-12"> <div class="col-12">
<div class="card" style="border: 0px;height: 470px;"> <div class="card" style="border: 0px;height: 470px;">
<div class="card-body status-option" id="statusContent" style="padding: 0.5rem !important;background-color: white;"> <div class="card-body status-option" id="statusContent"
style="padding: 0.5rem !important;background-color: white;">
<!-- Search Input Field --> <!-- Search Input Field -->
<div class="row"> <div class="row">
<div class="col-3"> <div class="col-3">
@ -14,7 +14,8 @@
</div> </div>
<div class="col-5"></div> <div class="col-5"></div>
<div class="col-4"> <div class="col-4">
<input type="text" id="searchInput" class="search-input" placeholder="Search by client or branch"> <input type="text" id="searchInput" class="search-input"
placeholder="Search by client or branch">
</div> </div>
</div> </div>
<!-- Carousel Structure --> <!-- Carousel Structure -->
@ -25,36 +26,46 @@
$currentItem = 0; // Counter for items $currentItem = 0; // Counter for items
$isActive = true; // Variable to set the first item as active $isActive = true; // Variable to set the first item as active
foreach ($client_branch_emp_list as $clients) { foreach ($client_branch_emp_list as $clients) {
foreach ($clients['branches'] as $branches) {
// Start a new carousel item if needed // Start a new carousel item if needed
if ($currentItem % $itemsPerSlide == 0) { if ($currentItem % $itemsPerSlide == 0) {
if (!$isActive) echo '</div>'; // Close previous carousel item if (!$isActive) echo '</div>'; // Close previous carousel item
echo '<div class="carousel-item' . ($isActive ? ' active' : '') . '">'; echo '<div class="carousel-item' . ($isActive ? ' active' : '') . '">';
$isActive = false; $isActive = false;
} }
if(count($branches['client_policies']) != 0){ ?> ?>
<!-- New Card Layout for each item --> <!-- 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="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item"
<div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);"> data-client="<?php echo $clients['short_name']; ?>"
<div class="card-header add_card_background_random" > data-branch="<?php echo $clients['branch_name']; ?>">
<div class="row"> <div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<div class="col-8 emp-count-view-click" > <div class="card-header add_card_background_random">
<div class="d-flex justify-content-between"> <div class="row">
<div class="w-100 " > <div class="col-8 emp-count-view-click">
<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 class="d-flex justify-content-between">
</div> <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($clients['total_employees']) ? $clients['total_employees'] : '0'; ?></span>
</h3>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col-12 emp-count-view-click" > <div class="row">
<div class="d-flex justify-content-between"> <div class="col-12 emp-count-view-click">
<div class="w-100" > <div class="d-flex justify-content-between">
<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 class="w-100">
</div> <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($clients['branch_name']) ? $clients['branch_name'] : 'N/A'; ?>
</h5>
</div> </div>
</div> </div>
<!-- <div class="col-3 center_text emp-count-view-click" > </div>
<!-- <div class="col-3 center_text emp-count-view-click" >
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="w-100 text-center" > <div class="w-100 text-center" >
<p class="mb-0 text-muted"> <p class="mb-0 text-muted">
@ -64,50 +75,76 @@
</div> </div>
</div> </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 $clients['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($clients['logged_in_count']) ? $clients['logged_in_count'] : '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($clients['not_logged_in_count']) ? $clients['not_logged_in_count'] : '0'; ?></span><br>
<span class="text-nowrap"
style="color: currentColor;font-size: 15px;margin-left: -13px;">Not
Logged-In</span>
</div> </div>
</div> </div>
<div class="card-body" > <div class="row emp-status" style="margin-top: 5px;">
<input type="text" class="client_id" value="<?php echo $clients['client_id']; ?>" hidden> <div class="col-6 emp-count-view-click">
<input type="text" class="client_branch_id" value="<?php echo $branches['client_branch_id'] ?>" hidden> <span style="font-size: large;color: black !important;"
<div class="row emp-status" style="margin-top: -9px;"> class="number_css"
<div class="col-6 emp-count-view-click" > onclick="enrollment_list(this, 'emp_not_enrolled_view_click')"><?php echo isset($clients['draft_count']) ? $clients['draft_count'] : '0'; ?></span><br>
<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"
<span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span> 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_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>
<div class="row emp-status" style="margin-top: 5px;"> <div class="col-6 emp-count-view-click">
<div class="col-6 emp-count-view-click" > <span style="font-size: large;color: black !important;"
<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> class="number_css"
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span> onclick="enrollment_list(this, 'emp_enrolled_view_click')"><?php echo isset($clients['enrolled_count']) ? $clients['enrolled_count'] : '0'; ?></span><br>
</div> <span class="text-nowrap"
<div class="col-6 emp-count-view-click" > style="color: currentColor;font-size: 15px;">Enrolled</span>
<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>
</div> </div>
</div> </div>
<?php </div>
<?php
$currentItem++; $currentItem++;
}
}
} }
if ($currentItem % $itemsPerSlide != 0) echo '</div>'; // Close the last carousel item if ($currentItem % $itemsPerSlide != 0) echo '</div>'; // Close the last carousel item
?> ?>
</div> </div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev"> <a class="carousel-control-prev" href="#carouselExampleControls" role="button"
<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="<"> --> 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="carousel-control-prev-icon" aria-hidden="true"></span> -->
<span class="sr-only">Previous</span> <span class="sr-only">Previous</span>
</a> </a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next"> <a class="carousel-control-next" href="#carouselExampleControls" role="button"
<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> data-slide="next">
<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="carousel-control-next-icon" aria-hidden="true"></span> -->
<span class="sr-only">Next</span> <span class="sr-only">Next</span>
</a> </a>
@ -119,435 +156,418 @@
</div> </div>
<script> <script>
$(document).ready(function() {
var lastDirection = ''; // Variable to keep track of the last direction
// Scroll functionality $(document).ready(function() {
$('.scroll-container').on('wheel', function(e) { var lastDirection = ''; // Variable to keep track of the last direction
if (e.originalEvent.deltaY < 0) {
this.scrollLeft -= 100; // Adjust scroll speed
} else {
this.scrollLeft += 100; // Adjust scroll speed
}
e.preventDefault();
});
// Search functionality // Scroll functionality
$('#searchInput').on('input', function() { $('.scroll-container').on('wheel', function(e) {
var searchValue = $(this).val().toLowerCase(); if (e.originalEvent.deltaY < 0) {
var firstVisibleItem = null; this.scrollLeft -= 100; // Adjust scroll speed
} else {
this.scrollLeft += 100; // Adjust scroll speed
}
e.preventDefault();
});
$('.scroll-item').each(function() { // Search functionality
var itemText = $(this).find('h5').text().toLowerCase(); $('#searchInput').on('input', function() {
var searchValue = $(this).val().toLowerCase();
var firstVisibleItem = null;
if (itemText.indexOf(searchValue) > -1) { $('.scroll-item').each(function() {
$(this).removeClass('hide-item').addClass('show-item'); // Show item var itemText = $(this).find('h5').text().toLowerCase();
if (!firstVisibleItem) { if (itemText.indexOf(searchValue) > -1) {
firstVisibleItem = $(this); $(this).removeClass('hide-item').addClass('show-item'); // Show item
if (!firstVisibleItem) {
firstVisibleItem = $(this);
}
} else {
$(this).removeClass('show-item').addClass('hide-item'); // Hide item
} }
} else { });
$(this).removeClass('show-item').addClass('hide-item'); // Hide item
if (firstVisibleItem) {
// Remove active class from all carousel items
$('.carousel-item').removeClass('active');
// Add active class to the parent carousel item of the first visible item
firstVisibleItem.closest('.carousel-item').addClass('active');
// Scroll to the first visible item
$('html, body').animate({
scrollTop: firstVisibleItem.offset().top
}, 500);
} }
}); });
if (firstVisibleItem) { function navigateCarousel(direction) {
// Remove active class from all carousel items lastDirection = direction; // Track the direction
$('.carousel-item').removeClass('active'); var $carousel = $('#carouselExampleControls');
var $activeItem = $carousel.find('.carousel-item.active');
// Add active class to the parent carousel item of the first visible item if (direction === 'next') {
firstVisibleItem.closest('.carousel-item').addClass('active'); if ($activeItem.find('.scroll-item').length === 0) {
$carousel.carousel('next');
// Scroll to the first visible item setTimeout(checkEmptyCarouselItem, 100); // Check after slide transition
$('html, body').animate({ } else {
scrollTop: firstVisibleItem.offset().top $carousel.carousel('next');
}, 500); }
} 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 navigateCarousel(direction) { function checkEmptyCarouselItem() {
lastDirection = direction; // Track the direction var $carousel = $('#carouselExampleControls');
var $carousel = $('#carouselExampleControls'); var $activeItem = $carousel.find('.carousel-item.active');
var $activeItem = $carousel.find('.carousel-item.active');
if (direction === 'next') { // Check if the active item is empty
if ($activeItem.find('.scroll-item').length === 0) { if ($activeItem.find('.scroll-item').length === 0) {
$carousel.carousel('next'); // If empty, move to the next item
setTimeout(checkEmptyCarouselItem, 100); // Check after slide transition $carousel.carousel(lastDirection === 'next' ? 'next' : 'prev');
} 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() { // Attach click handlers to carousel controls
var $carousel = $('#carouselExampleControls'); $('.carousel-control-next').on('click', function() {
var $activeItem = $carousel.find('.carousel-item.active'); navigateCarousel('next');
$('.carousel-item').each(function(index, element) {
// Check if the active item is empty if ($.trim($(element).html()) === '') {
if ($activeItem.find('.scroll-item').length === 0) { $(element).remove();
// 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-item').each(function(index, element) {
if ($.trim($(element).html()) === '') {
$(element).remove();
}
}); });
});
$('.carousel-control-prev').on('click', function() { $('.carousel-control-prev').on('click', function() {
navigateCarousel('prev'); navigateCarousel('prev');
$('.carousel-item').each(function(index, element) { $('.carousel-item').each(function(index, element) {
if ($.trim($(element).html()) === '') { if ($.trim($(element).html()) === '') {
$(element).remove(); $(element).remove();
} }
});
}); });
});
// Check the carousel item when the slide changes // Check the carousel item when the slide changes
$('#carouselExampleControls').on('slid.bs.carousel', function() { $('#carouselExampleControls').on('slid.bs.carousel', function() {
checkEmptyCarouselItem();
});
// Initial check for empty carousel items
checkEmptyCarouselItem(); checkEmptyCarouselItem();
}); });
// Initial check for empty carousel items document.addEventListener('DOMContentLoaded', function() {
checkEmptyCarouselItem(); random_color_set();
});
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();
var baseUrl = '<?php echo base_url(); ?>'; // Adjust this to your actual base URL if needed
var url = baseUrl + 'employee/enrollment-list'; // Change this to the actual URL of your enroller_list page
var params = new URLSearchParams({
client_id: clientId,
branch_id: branchId,
type: type
}); });
// Redirect to the constructed URL with parameters $('#enrollment_status_open_close').change(function() {
window.location.href = `${url}?${params.toString()}`;
}
if ($(this).val() === 'open') {
var enrollment_data = '<?php echo addslashes(json_encode($client_branch_emp_list, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT)); ?>';
console.log('Raw enrollment_data:', enrollment_data);
try {
$('#enrollment_status_open_close').change(function () { // Ensure enrollment_data is not empty or invalid
if ($(this).val() === 'open') { if (!enrollment_data || enrollment_data === 'null' || enrollment_data === '""') {
var enrollment_data = '<?php echo addslashes($_SESSION['enrollment_data']); ?>'; throw new Error('Invalid JSON data received.');
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, 1);
} 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, 1);
} }
} else {
console.error('Parsed data is not an object:', data);
}
} catch (e) {
console.error('Error parsing JSON:', e);
}
} else {
// Fetch the session data from PHP
var enrollment_data = '<?php echo addslashes($_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 // Parse JSON data
if (data && typeof data === 'object') { var data = JSON.parse(enrollment_data);
if (Array.isArray(data.client_branch_emp_list)) { console.log('Parsed data:', data);
console.log('client_branch_emp_list:', data.client_branch_emp_list);
updateCarouselWithData(data, 2);
} 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); // Ensure parsed data is always treated as an array
updateCarouselWithData(data, 2); if (!Array.isArray(data)) {
data = data && typeof data === 'object' ? [data] : [];
} }
} else {
console.error('Parsed data is not an object:', data);
}
} catch (e) {
console.error('Error parsing JSON:', e);
}
}
});
function updateCarouselWithData(data, open_close) { console.log('Final client_branch_emp_list:', data);
var itemsPerSlide = 3; // Number of items per slide updateCarouselWithData(data, 1);
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);
// Convert items object to an array
var client_list = Object.values(items);
// Validate if client_list is an array
if (Array.isArray(client_list)) {
console.log(client_list);
for (var i = 0; i < client_list.length; i++) {
var client = client_list[i];
// console.log(item.branches);
var branch_list = client.branches;
for (var j = 0; j < branch_list.length; j++) {
var branch = branch_list[j];
console.log(branch);
if(open_close == 1){
if(branch.client_policies.length > 0){
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="${client.short_name}" data-branch="${branch.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')">${branch.employees.length}</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;">${client.short_name} - ${branch.branch_name} </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="${client.client_id}" hidden>
<input type="text" class="client_branch_id" value="${branch.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')">${branch.emp_login}</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')"> ${branch.employees.length - (branch.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')">${branch.employees.length - (branch.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')">${(branch.emp_enroll || 0)}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div>
</div>
</div>
</div>
</div>
`;
carouselInner.find('.carousel-item').last().append(itemHtml);
currentItem++;
}
}else{
if(branch.client_policies.length == 0){
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="${client.short_name}" data-branch="${branch.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')">${branch.employees.length}</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;">${client.short_name} - ${branch.branch_name} </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="${client.client_id}" hidden>
<input type="text" class="client_branch_id" value="${branch.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')">${branch.emp_login}</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')"> ${branch.employees.length - (branch.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')">${branch.employees.length - (branch.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')">${(branch.emp_enroll || 0)}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div>
</div>
</div>
</div>
</div>
`;
carouselInner.find('.carousel-item').last().append(itemHtml);
currentItem++;
}
}
}
// Create a new carousel item every `itemsPerSlide` items
} catch (error) {
console.error('Error parsing JSON:', error.message, error);
} }
// Close the last carousel item if it was opened
if (currentItem % itemsPerSlide !== 0) carouselInner.append('</div>');
} else { } else {
console.error('Expected an array for items, but got:', client_list);
// Fetch the session data from PHP
var enrollment_data = '<?php echo addslashes(json_encode($client_branch_emp_list, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT)); ?>';
console.log('Raw enrollment_data:', enrollment_data);
try {
// Ensure enrollment_data is valid before parsing
if (!enrollment_data || enrollment_data === 'null' || enrollment_data === '""') {
throw new Error('Invalid JSON data received.');
}
// Parse JSON data
var data = JSON.parse(enrollment_data);
console.log('Parsed data:', data);
// Ensure `data` is always an array
data = Array.isArray(data) ? data : (data && typeof data === 'object' ? [data] : []);
console.log('Final client_branch_emp_list:', data);
updateCarouselWithData(data, 2);
} catch (error) {
console.error('Error parsing JSON:', error.message, error);
}
} }
} 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);
}
random_color_set();
// Initialize or refresh carousel if needed
$('#carouselExampleControls').carousel('dispose').carousel();
}
document.addEventListener('DOMContentLoaded', function() {
random_color_set();
});
function remove_empty_carousel() {
}
function random_color_set() {
// Array of predefined colors
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 index
var index = 0;
// 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[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++;
}); });
}
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();
var baseUrl = '<?php echo base_url(); ?>'; // Adjust this to your actual base URL if needed
var url = baseUrl + 'employee/enrollment-list'; // Change this to the actual URL of your enroller_list page
var params = new URLSearchParams({
client_id: clientId,
branch_id: branchId,
type: type
});
// Redirect to the constructed URL with parameters
window.location.href = `${url}?${params.toString()}`;
}
function updateCarouselWithData(data, open_close) {
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) && data.length > 0) {
console.log("Processing array........................................");
// Handle the case where data.client_branch_emp_list is an array
var items = data[0];
console.log("Items data:", items);
// Convert items object to an array
var client_list = Object.values(items);
// Validate if client_list is an array
if (Array.isArray(client_list)) {
console.log(client_list);
for (var i = 0; i < data.length; i++) {
let client = data[i];
if (open_close == 1 && client.open_or_close_enrollment == 1) {
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="${client.short_name}" data-branch="${client.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')">${client.total_employees}</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;">${client.short_name} - ${client.branch_name} </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="${client.client_id}" hidden>
<input type="text" class="client_branch_id" value="${client.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')">${client.logged_in_count ?? 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')"> ${client.not_logged_in_count ?? 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')">${client.draft_count ?? 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')">${(client.enrolled_count ?? 0)}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div>
</div>
</div>
</div>
</div>
`;
carouselInner.find('.carousel-item').last().append(itemHtml);
currentItem++;
} else {
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="${client.short_name}" data-branch="${client.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')">${client.total_employees}</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;">${client.short_name} - ${client.branch_name} </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="${client.client_id}" hidden>
<input type="text" class="client_branch_id" value="${client.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')">${client.logged_in_count}</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')"> ${client.not_logged_in_count ?? 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')">${client.draft_count ?? 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')">${(client.enrolled_count ?? 0)}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div>
</div>
</div>
</div>
</div>
`;
carouselInner.find('.carousel-item').last().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:', client_list);
}
} else if (typeof data === 'object') {
console.error('client_branch_emp_list is an object, not an array:', data);
} else {
console.error('client_branch_emp_list is missing or not in the expected format:', data);
}
random_color_set();
// Initialize or refresh carousel if needed
$('#carouselExampleControls').carousel('dispose'); // Properly dispose of the instance
$('#carouselExampleControls').carousel(); // Reinitialize it
}
function random_color_set() {
// Array of predefined colors
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 index
var index = 0;
// 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[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++;
});
}
</script> </script>