CHANGE_ENROLLMENT_STATUS_AND_REMINDER_MAIL : AADHAVAN

This commit is contained in:
aadhavan valli 2024-07-26 11:24:47 +05:30
parent 05132a2a9d
commit f6882f9b2f
11 changed files with 512 additions and 86 deletions

View File

@ -138,7 +138,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->post("upload", "EmployeeController::employeesUplodWithEvents"); $routes->post("upload", "EmployeeController::employeesUplodWithEvents");
$routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1"); $routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1");
$routes->get("endorsement-list", "EmployeeController::endorsementList"); $routes->get("endorsement-list", "EmployeeController::endorsementList");
$routes->get("enrollment-list", "EmployeeController::enrollmentClientList"); $routes->match(['get','post'],'enrollment-list','EmployeeController::enrollmentClientList');
$routes->get("empby_client_clientbranch/(:any)/(:any)", "EmployeeController::empby_client_clientbranch/$1/$2"); $routes->get("empby_client_clientbranch/(:any)/(:any)", "EmployeeController::empby_client_clientbranch/$1/$2");
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1"); $routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
}); });
@ -270,6 +270,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs'); $routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status');
$routes->get("processjob", "JobWorker::processJob"); $routes->get("processjob", "JobWorker::processJob");

View File

@ -729,7 +729,7 @@ class ClientController extends AdminController
$base_policy = $this->request->getPost('base_policy'); $base_policy = $this->request->getPost('base_policy');
$insurerValue = (string) $this->request->getPost('insurer'); $insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue); list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
@ -814,8 +814,17 @@ class ClientController extends AdminController
$data['policy_no'] = $this->request->getPost('policy_no'); $data['policy_no'] = $this->request->getPost('policy_no');
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); if($data['inception_type'] == 2){
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'); $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['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['reminder_date'] = null;
}
$data['created_by'] = get_session_userid(); $data['created_by'] = get_session_userid();
$insert = $this->clientPolicyModel->insert($data); $insert = $this->clientPolicyModel->insert($data);
@ -851,8 +860,8 @@ class ClientController extends AdminController
$data['tpa_id'] = $tpaId; $data['tpa_id'] = $tpaId;
$data['policy_type_id'] = $this->request->getPost('policy_type_id'); $data['policy_type_id'] = $this->request->getPost('policy_type_id');
$data['policy_no'] = $this->request->getPost('policy_no'); $data['policy_no'] = $this->request->getPost('policy_no');
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'); // $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_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$data['insured'] = $this->request->getPost('insured'); $data['insured'] = $this->request->getPost('insured');
$data['no_of_lives'] = $this->request->getPost('no_of_lives'); $data['no_of_lives'] = $this->request->getPost('no_of_lives');
@ -874,6 +883,16 @@ class ClientController extends AdminController
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no'); $data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst'); $data['gst'] = $this->request->getPost('gst');
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['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['reminder_date'] = null;
}
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){ if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1; $data['is_addon'] = 1;

View File

@ -35,7 +35,6 @@ class DashboardController extends AdminController
{ {
$data = []; $data = [];
$results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, $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.id as client_branch_id, client_branch.branch_name,
client_branch.branch_code, employees.id as employee_id, client_branch.branch_code, employees.id as employee_id,

View File

@ -674,8 +674,15 @@ class EmployeeController extends AdminController
$branch_list = $this->clientBranchModel->findAll(); $branch_list = $this->clientBranchModel->findAll();
$data['client_list'] = $client_list; $data['client_list'] = $client_list;
$data['branch_list'] = $branch_list; $data['branch_list'] = $branch_list;
$this->myLogger->logme('error', 'list called');
$this->loadLayout('enrollment_list', $data); // Get session data if available
$data['selected_client_id'] = session()->get('client_id');
$data['selected_branch_id'] = session()->get('branch_id');
$data['selected_type'] = session()->get('type');
$this->myLogger->logme('error', 'list called');
return $this->loadLayout('enrollment_list', $data);
} }
public function empby_client_clientbranch($client_id, $branch_id) public function empby_client_clientbranch($client_id, $branch_id)

View File

@ -4,6 +4,13 @@ namespace App\Controllers;
use App\Models\JobModel; 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 class JobWorker extends AdminController
{ {
const STATUS_DONE = 'done'; const STATUS_DONE = 'done';
@ -228,6 +235,71 @@ 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

@ -12,7 +12,7 @@ class sendMailNotification
{ {
public static function sendMailNotification($action, $params) public static function sendMailNotification($action, $params)
{ {
print_r($params);die; $wholeData =[];
if ($action == 'member_welcome_mail') { if ($action == 'member_welcome_mail') {
$dataToInsert = $params['dataToInsert']; $dataToInsert = $params['dataToInsert'];
$notification = $params['notification']; $notification = $params['notification'];
@ -37,7 +37,6 @@ class sendMailNotification
} }
return $wholeData; return $wholeData;
} else if($action == 'member_reminder_mail'){ } else if($action == 'member_reminder_mail'){
$EmployeeModel = new EmployeeModel(); $EmployeeModel = new EmployeeModel();
$emp_data = $params['emp_data']; $emp_data = $params['emp_data'];
$notification_data = $params['notification_data']; $notification_data = $params['notification_data'];
@ -51,27 +50,46 @@ class sendMailNotification
$mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content);
$mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content); $mail_content = str_replace("[[nhance_logo]]", "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
$mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content); $mail_content = str_replace("[[app_link]]", "<a href='$app_link'>Review Details</a>", $mail_content);
if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) { if ($emp_data && (isset($notification_data) && $notification_data['enabled'] == 1)) {
if(isset($emp_data['relationship'])){
if ($emp_data['relationship'] == 'Self') {
if(count($emp_data) > 0){
$mail ='';
if ($emp_data['relationship'] == 'Self') {
$employee_name =$emp_data['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $emp_data['email_corporate'];
}
}
}else{
$mail ='';
}
}else{
$employee_name =$emp_data['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $emp_data['email_corporate'];
}
if (isset($mail) && !empty($mail)) {
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
}
}else{
foreach ($emp_data as $key => $value) { foreach ($emp_data as $key => $value) {
if ($value['relationship'] != 'Self') { if ($value['relationship'] != 'Self') {
$emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll(); $emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll();
if(count($emp_data) > 1){ if(count($emp_data) > 1){
$mail =''; $mail ='';
foreach ($emp_data as $key => $values) { foreach ($emp_data as $key => $values) {
if ($value['relationship'] == 'Self') { if ($value['relationship'] == 'Self') {
$employee_name =$values['name']; $employee_name =$values['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
$mail = $values['email_corporate']; $mail = $values['email_corporate'];
} }
} }
}else{ }else{
$mail =''; $mail ='';
} }
}else{ }else{
$employee_name =$value['name']; $employee_name =$value['name'];
$mail_content = str_replace("[[member_name]]", $employee_name, $mail_content); $mail_content = str_replace("[[member_name]]", $employee_name, $mail_content);
@ -81,13 +99,15 @@ class sendMailNotification
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
} }
} }
if (count($wholeData) < 1) {
$wholeData = [];
}
return $wholeData;
}else{
return "false";
} }
if (count($wholeData) < 1) {
$wholeData = [];
}
return $wholeData;
// }else{
// return "false";
// }
} else if($action == 'member_ecard_mail'){ } else if($action == 'member_ecard_mail'){
$notification = $params['notification']; $notification = $params['notification'];

View File

@ -19,6 +19,7 @@ class ClientPolicyModel extends Model
"policy_type_id", "policy_type_id",
"policy_start_date", "policy_start_date",
"policy_end_date", "policy_end_date",
"reminder_date",
"insured", "insured",
"no_of_employees", "no_of_employees",
"no_of_lives", "no_of_lives",

View File

@ -112,6 +112,10 @@
<label for="policy_end_date">Policy End Date<span class="text-danger">*</span></label> <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> <input value="" type="text" class="form-control" placeholder="Enter End Date " name="policy_end_date" id="end_date" required>
</div> </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"> <div class="form-group col-md-4" id="policy_status_field">
<label for="policy_status">Policy Status</label> <label for="policy_status">Policy Status</label>
<input value="" type="text" class="form-control" placeholder="Policy Status" id="policy_status" readonly> <input value="" type="text" class="form-control" placeholder="Policy Status" id="policy_status" readonly>
@ -174,6 +178,23 @@
<?php include('other_policy_terms.php'); ?> <?php include('other_policy_terms.php'); ?>
<script> <script>
$('#inception_type').change(function () {
var start_data = $('#start_date').parent();
var end_data = $('#end_date').parent();
var reminder_data = $('#reminder_date').parent();
if($(this).prop('checked')){
$(start_data).show();
$(end_data).show();
$(reminder_data).show();
}else{
$(start_data).hide();
$(end_data).hide();
$(reminder_data).hide();
}
})
var policy_PrimaryKey = $('#client_id_policy').val(); var policy_PrimaryKey = $('#client_id_policy').val();
var policy_client = $('#policy_PrimaryKey').val(); var policy_client = $('#policy_PrimaryKey').val();
@ -218,6 +239,13 @@
allowInput: false allowInput: false
}); });
var reminderDatePicker = flatpickr("#reminder_date", {
dateFormat: "d-m-Y",
defaultDate: endDate,
allowInput: false
});
$('#add_form').hide(); $('#add_form').hide();
$('.btnBack').hide(); $('.btnBack').hide();
@ -308,6 +336,8 @@
// ordering: false // ordering: false
}); });
}); });
$('.btnAdd').click(function() { $('.btnAdd').click(function() {
@ -711,6 +741,7 @@
$('#policy_no').val(res.data.policy_no); $('#policy_no').val(res.data.policy_no);
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_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_end_date));
$('#gst_no').val(gst); $('#gst_no').val(gst);
$('#policy_status_field').show(); $('#policy_status_field').show();
@ -1189,6 +1220,7 @@
$('#policy_no').val(''); $('#policy_no').val('');
$('#start_date').val(''); $('#start_date').val('');
$('#end_date').val(''); $('#end_date').val('');
$('#reminder_date').val('');
$('#base_policy').val('').change(); $('#base_policy').val('').change();
var client_id = $('#client_id_policy').val(); var client_id = $('#client_id_policy').val();
@ -1289,6 +1321,14 @@
$('#base_policy').prop('required', false); $('#base_policy').prop('required', false);
$('#base_danger').hide(); $('#base_danger').hide();
} }
if($('#inception_type').prop('checked')){
}else{
$('#start_date').parent().hide();
$('#end_date').parent().hide();
$('#reminder_date').parent().hide();
}
}) })
@ -1359,6 +1399,7 @@
var dataId = 0; var dataId = 0;
$(document).ready(function() { $(document).ready(function() {
$('#base_policy').change(function() { $('#base_policy').change(function() {
var client_policy_id = $(this).val() ? $(this).val() : 0; var client_policy_id = $(this).val() ? $(this).val() : 0;

View File

@ -1,115 +1,336 @@
<!-- Bootstrap CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.bundle.min.js"></script>
<!-- Bootstrap JS (ensure this is included) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
<style> <style>
/* Existing CSS ... */
.carousel-control-prev {
left: -38px;
}
.status-option { .status-option {
padding: 0.5rem !important; padding: 0.5rem !important;
background-color: darkgrey; background-color: darkgrey;
} }
.emp-count-view-click { .emp-count-view-click {
cursor: pointer; cursor: pointer;
} }
.emp-status .col-6 { .emp-status .col-6 {
/* padding-bottom: 1rem; */ padding-bottom: 0.3rem;
} }
.emp-status label { .emp-status label {
font-weight: bold; font-weight: bold;
} }
.client-branch-label { .client-branch-label {
padding: 0.2rem; padding: 0.2rem;
border-radius: 0.2rem; border-radius: 0.2rem;
display: inline-block; display: inline-block;
} }
.scroll-container { .scroll-container {
display: flex; display: flex;
overflow-x: auto; overflow-x: auto;
white-space: nowrap; white-space: nowrap;
} }
.scroll-item { .scroll-item {
flex: 0 0 auto; flex: 0 0 auto;
width: 25%; /* Adjust based on the number of items you want to show */ width: 33%; /* Adjust based on the number of items you want to show */
box-sizing: border-box; box-sizing: border-box;
padding: 0 10px; padding: 0 10px;
} }
.center_text{
text-align: center; @media (min-width: 1200px) {
} .col-xl-3 {
.card-body { max-width: 32% !important;
padding: 0rem ; }
} }
.number_css{ .center_text {
text-align: center;
}
.card-body {
padding: 1rem;
}
.number_css {
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
color: #343a40; color: #343a40;
text-align: center;
} }
.label_bottom_reduce{
.label_bottom_reduce {
margin-bottom: .0rem; margin-bottom: .0rem;
} }
.search-input {
margin-bottom: 1rem;
padding: 0.5rem;
border-radius: 0.25rem;
border: 1px solid #ced4da;
width: 100%;
}
.carousel-inner {
position: relative;
overflow: hidden;
}
.carousel-item {
height: auto; /* Adjust if needed */
/* margin-left: 80px; */
}
.card {
margin: 0 auto; /* Center card in carousel item */
}
.carousel-control-prev, .carousel-control-next {
width: 5%;
height: 100%;
}
.carousel-control-prev-icon, .carousel-control-next-icon {
background-color: rgba(0,0,0,0.5); /* Change color as needed */
}
.carousel-control-prev-icon {
background-image: url('data:image/svg+xml;charset=utf8,%3Csvg xmlns%3D"http://www.w3.org/2000/svg" fill%3D"%23000000" viewBox%3D"0 0 8 8"%3E%3Cpath d%3D"M2.5 0L4 1.5 1.5 4 4 6.5 2.5 8 0 4 2.5 0z"/%3E%3C/svg%3E');
}
.carousel-control-next-icon {
background-image: url('data:image/svg+xml;charset=utf8,%3Csvg xmlns%3D"http://www.w3.org/2000/svg" fill%3D"%23000000" viewBox%3D"0 0 8 8"%3E%3Cpath d%3D"M5.5 8L4 6.5 6.5 4 4 1.5 5.5 0l4 4-4 4z"/%3E%3C/svg%3E');
}
.show-item {
display: inline-block !important;
}
.hide-item {
display: none !important;
}
.content-page {
background-color: #e8eff5;
}
html {
background-color: #e8eff5;
}
</style> </style>
<div class="tab-pane fade" id="enrollment-dash-tab">
<div class="tab-pane fade" id="enrollment-dash-tab">
<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"> <div class="card" style="border: 0px;">
<div class="card-header"></div> <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: #edf1f5;"> <!-- Search Input Field -->
<div class="scroll-container"> <div class="row">
<?php foreach ($client_branch_emp_list as $clients) { ?> <div class="col-3">
<?php foreach ($clients['branches'] as $branches) { ?> <select class="form-control" name="" id="">
<div class="scroll-item"> <option value="">Open Enrollment</option>
<div class="card"> <option value="">Close Enrollment</option>
<div class="card-body emp-count-view-click"> </select>
<div class="d-flex justify-content-center"> </div>
<div class="col-12 center_text" style="background-color: #02a8b5;"> <div class="col-5"></div>
<label for="" class="client-branch-label"> <div class="col-4">
<?php echo isset($clients['short_name']) ? $clients['short_name'] : 'N/A'; ?> - <input type="text" id="searchInput" class="search-input" placeholder="Search by client or branch">
<?php echo isset($branches['branch_name']) ? $branches['branch_name'] : 'N/A'; ?> </div>
</label> </div>
<!-- Carousel Structure -->
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel" data-interval="false">
<div class="carousel-inner">
<?php
$itemsPerSlide = 3; // Number of items per slide
$currentItem = 0; // Counter for items
$isActive = true; // Variable to set the first item as active
foreach ($client_branch_emp_list as $clients) {
foreach ($clients['branches'] as $branches) {
// 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;
}
?>
<!-- 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> </div>
<div class="row emp-status"> <div class="card-body add_card_background_random" >
<div class="col-12 center_text">
<span class="number_css" style="font-size: x-large;"><?php echo isset($branches['employees']) ? count($branches['employees']) : '0'; ?></span><br> <input type="text" class="client_id" value="<?php echo $clients['client_id']; ?>" hidden>
<i class="fa fa-users" aria-hidden="true"></i> <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="col-6 center_text">
<span style="font-size: x-large;" class="number_css"><?php echo isset($branches['emp_login']) ? $branches['emp_login'] : '0'; ?></span><br>
<label class="label_bottom_reduce" for="" style="color: gray;font-family: var(--bs-body-font-family);font-size: var(--bs-body-font-size);">Logged-In</label>
</div>
<div class="col-6 center_text">
<span style="font-size: x-large;" class="number_css"><?php echo isset($branches['emp_enroll']) ? count($branches['employees']) - $branches['emp_enroll'] : '0'; ?></span><br>
<label class="label_bottom_reduce" for="" style="color: gray;font-family: var(--bs-body-font-family);font-size: var(--bs-body-font-size);">Draft</label>
</div> </div>
<div class="row emp-status" style="margin-top: -9px;">
<div class="col-6 center_text emp-count-view-click" >
<div class="col-6 center_text"> <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 style="font-size: x-large;" class="number_css"><?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;">Draft</span>
<label class="label_bottom_reduce" for="" style="color: gray;font-family: var(--bs-body-font-family);font-size: var(--bs-body-font-size);">Not Logged-In</label> </div>
</div> <div class="col-6 center_text emp-count-view-click" >
<div class="col-6 center_text"> <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 style="font-size: x-large;" class="number_css"><?php echo isset($branches['emp_enroll']) ? $branches['emp_enroll'] : '0'; ?></span><br> <span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
<label class="label_bottom_reduce" for="" style="color: gray;font-family: var(--bs-body-font-family);font-size: var(--bs-body-font-size);">Enrolled</label> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> <?php
<?php } ?> $currentItem++;
<?php } ?> }
}
if ($currentItem % $itemsPerSlide != 0) echo '</div>'; // Close the last carousel item
?>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<!-- <span class="carousel-control-prev-icon" aria-hidden="true"></span> -->
<!-- <span class="sr-only">Previous</span> -->
<i class="fas fa-angle-left"></i>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('.scroll-container').on('wheel', function(e) { // Scroll functionality
if (e.originalEvent.deltaY < 0) { $('.scroll-container').on('wheel', function(e) {
this.scrollLeft -= 100; // Adjust scroll speed if (e.originalEvent.deltaY < 0) {
} else { this.scrollLeft -= 100; // Adjust scroll speed
this.scrollLeft += 100; // Adjust scroll speed } else {
} this.scrollLeft += 100; // Adjust scroll speed
e.preventDefault(); }
}); e.preventDefault();
}); });
// Search functionality
$('#searchInput').on('input', function() {
var searchValue = $(this).val().toLowerCase();
var firstVisibleItem = null;
$('.scroll-item').each(function() {
var itemText = $(this).find('h5').text().toLowerCase();
if (itemText.indexOf(searchValue) > -1) {
$(this).removeClass('hide-item').addClass('show-item'); // Show item
if (!firstVisibleItem) {
firstVisibleItem = $(this);
}
} 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);
}
});
});
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()}`;
}
document.addEventListener('DOMContentLoaded', function() {
// Array of predefined colors
var colors = ['yellowgreen', 'indianred', 'cadetblue', 'burlywood', 'darkolivegreen'];
// Counter to keep track of the current color index
var colorIndex = 0;
// Apply a color from the array 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
});
});
</script> </script>

View File

@ -228,6 +228,7 @@
}, },
success: function(response) { success: function(response) {
var data = JSON.parse(response); var data = JSON.parse(response);
console.log(data);
var table = $('#tickets-table').DataTable(); var table = $('#tickets-table').DataTable();
table.clear(); table.clear();
@ -277,6 +278,12 @@
}); });
table.draw(); table.draw();
function getUrlParameter(name) {
var params = new URLSearchParams(window.location.search);
return params.get(name);
}
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
console.error('Error fetching data from API:', error); console.error('Error fetching data from API:', error);
@ -286,6 +293,43 @@
$(document).ready(function() { $(document).ready(function() {
function getUrlParameter(name) {
var params = new URLSearchParams(window.location.search);
return params.get(name);
}
// Check for URL parameters and set form values
var client_id = getUrlParameter('client_id');
var branch_id = getUrlParameter('branch_id');
var type = getUrlParameter('type');
if (client_id) {
$('#clients').val(client_id).trigger('change'); // Set client ID and trigger change event to populate branches
}
if (branch_id) {
setTimeout(function() { // Ensure branches are populated before setting branch ID
$('#branch_id').val(branch_id).trigger('change');
if($('#branch_id').val() != 0){
$('#get-emp-list').click().trigger();
}
}, 500);
}
if (history.pushState) {
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
window.history.pushState({path: newUrl}, '', newUrl);
}
setTimeout(() => {
// var type = getUrlParameter('type');
console.log("------------------------");
console.log(type);
$('#' + type).click().trigger();
}, 1000);
$('#clients').select2(); $('#clients').select2();
$('#branch_id').select2(); $('#branch_id').select2();
var table = $('#tickets-table').DataTable({ var table = $('#tickets-table').DataTable({

View File

@ -71,10 +71,11 @@
}); });
} }
</script> </script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css"/> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css"/> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css" />
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
<style> <style>