FIX_MERGE_CONFLICT : RV

This commit is contained in:
VENKATESHWARAN 2024-07-30 14:11:31 +05:30
commit ae7c61767e
10 changed files with 763 additions and 195 deletions

View File

@ -146,6 +146,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
$routes->post("test-dependent", "EmployeeController::testCheckDependentConflict");
});

View File

@ -57,15 +57,6 @@ class DashboardController extends AdminController
$pendingActionsController = new PendingActionsController;
$pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
$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();
$groupedData = [];

View File

@ -1495,6 +1495,7 @@ class EmployeeController extends AdminController
public function testRackRate()
{
helper('excel_util_helper');
if ($this->request->getMethod() == 'get') {
$filterData = $this->request->getGet('client_policy_id');
//just load UI only
@ -1545,27 +1546,99 @@ class EmployeeController extends AdminController
}
// print_r($family_details);
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
//get file array or construnct dummy file array here
$file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception','client_branch_id' => 1,'created_by' => 1];
// return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
//get policy details
$policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
//get rack rates
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
$policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id);
$policy_details = (array)$policy_details[0];
// ~dd($policy_details[0]->policy_start_date);
//get rack rates
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($policy_id,$client_id);
//get file array or construnct dummy file array here
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $policy_id,'action' => 'inception','client_branch_id' => $branch_id,'created_by' => 1];
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $branch_id);
//get familiy details in inception file format array from post method
$family_details = [
[2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '5000000', NULL, '', '', 'G', '', '', '', '', '', '',''],
[1,'TEST001','Jane Doe', '01-Jan-1985', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', '0', '', '', ''],
// [3,'TEST001','Peter Doe', '01-Jan-1955', 'M', 'Father', '', NULL, '', '', '', '', '', '', '', '', '',''],
[4,'TEST001','Mary Doe', '01-Jan-1953', 'F', 'Mother', '', NULL, '', '', '', '', '', '', '', '', '',''],
[5,'TEST001','Grace Doe', '01-Jan-1954', 'F', 'Mother in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
//[6,'TEST001','George Doe', '01-Jan-1948', 'M', 'Father in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
[7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', '',''],
[6,'TEST001','Bob Doe', '01-Jan-1993', 'M', 'son', '50000', NULL, '', '', '', '', '', '', '', '', '',''],
];
// $data = calculate_premimum_new($family_details,$policy_details,$all_rack_rates,$file);
$data = calculate_premium_new(family_data: $family_details,policy_terms:$policy_details,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units);
foreach($data as $key => $member )
{
// ~dd($member);
$data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : '';
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
}
}
public function testCheckDependentConflict()
{
helper('excel_util_helper');
if ($this->request->getMethod() == 'get') {
$filterData = $this->request->getGet('client_policy_id');
//just load UI only
$this->loadLayout('rack_rate_test');
}
if ($this->request->getMethod() == 'post') {
$json = $this->request->getJSON();
// return $this->respond(['dataStatus' => false, 'code' => 200, 'data' => $data], 200);
// $data = (json_decode(json_encode($data),true));
$client_id = $json->client_id;
$policy_id = $json->policy_id;
$branch_id = $json->branch_id;
$tabledata = $json->data;
if(count($tabledata))
{
$family_details = [];
foreach($tabledata as $key => $row)
{
$row = (array)$row;
if(!$row['column12'])
{
$temp[0] = $row['column1'];//sno
$temp[1] = $row['column2'];//emp code
$temp[2] = $row['column3'];//name
$temp[3] = $row['column4'];//DOB
$temp[4] = strtoupper($row['column5']);//Gender
$temp[5] = $row['column6'];//relation
$temp[6] = $row['column7'];//SI
$temp[7] = $row['column8'];//DOC
$temp[8] = '';//DOJ
$temp[9] = $row['column9'];//BP
$temp[10] = $row['column10'];//band
$temp[11] = '';//designation
$temp[12] = '';//mobile
$temp[13] = '';//EMail
$temp[14] = '';//CE
$temp[15] = '';//RFE
$temp[16] = '';//DOE
$temp[17] = '';//Unit
$temp[18] = $row['column11'];//unit
$family_details[] = $temp;
}
}
}
// print_r($family_details);
// return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
//get policy details
$policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id);
$policy_terms = (array)$policy_details[0];
// dd($policy_terms);
$policy_terms = json_decode($policy_terms['policy_terms']);
$policy_terms = (array) $policy_terms;// convert obj to array
//get file array or construnct dummy file array here
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $policy_id,'action' => 'inception','client_branch_id' => $branch_id,'created_by' => 1];
//get familiy details in inception file format array from post method
$result = check_dependent_conflict($family_details, $policy_terms, $file['action']);
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['policy_terms' => $policy_terms['family_floaters'],'result' => $result] ], 200);
}
}

View File

@ -1272,7 +1272,7 @@ class EmployeeServiceController extends AdminController
// die();
return (($employee_data_group_by_family));
return (count($employee_data_group_by_family));
}

View File

@ -5,7 +5,7 @@ namespace App\Controllers;
use App\Models\JobModel;
class JobWorker extends AdminController
{
const STATUS_DONE = 'done';

View File

@ -1011,7 +1011,7 @@ if (!function_exists('transform_excel_data_to_db'))
// $policy['reason_for_exit'] = $memArr[17];
$policy['client_policy_id'] = $actionArr['policy_id'];
$policy['date_coverage'] = isset($memArr[7]) ? convert_string_to_date($memArr[7],'Y-m-d') : NULL;
$policy['date_coverage'] = isset($memArr[7]) && $memArr[7] != '' ? convert_string_to_date($memArr[7],'Y-m-d') : NULL;
$policy['policy_end_date'] = null;
$policy['days'] = null;
$policy['premium'] = null;

View File

@ -82,7 +82,7 @@ class ClientModel extends Model
$client['policies'] = $clientPolicies;
$clientBranchModel = new ClientBranchModel();
$clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id'])
$clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id','client_branch.units'])
->where('client_branch.client_id',$client['id'])
->findAll();

View File

@ -9,6 +9,8 @@
<!-- Bootstrap JS (ensure this is included) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
<!-- Remove one of these -->
<style>
.carousel-control-next {
@ -339,10 +341,20 @@ $(document).ready(function() {
// 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() {
navigateCarousel('prev');
$('.carousel-item').each(function(index, element) {
if ($.trim($(element).html()) === '') {
$(element).remove();
}
});
});
// Check the carousel item when the slide changes
@ -373,9 +385,286 @@ function enrollment_list(current_element, type) {
}
$('#enrollment_status_open_close').change(function () {
if ($(this).val() === 'open') {
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
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
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, 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);
updateCarouselWithData(data, 2);
}
} else {
console.error('Parsed data is not an object:', data);
}
} catch (e) {
console.error('Error parsing JSON:', e);
}
}
});
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.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
}
// 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.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() {
// Array of predefined colors
var colors = ['#EBE8FF', '#FFECE5', '#FFE8F5'];
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 = [
@ -399,135 +688,6 @@ document.addEventListener('DOMContentLoaded', function() {
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>

View File

@ -46,7 +46,7 @@
<div class="card-body">
<!-- <div class="text-center"> -->
<div class="form-row">
<div class="form-group col-md-4">
<div class="form-group col-md-3">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
@ -54,14 +54,20 @@
</div>
<div class="form-group col-md-4">
<div class="form-group col-md-3">
<label>Branch</label> <br />
<select name="branch_id" class="form-control" id="branch_id">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-3">
<label>Unit</label> <br />
<select name="branch_id" class="form-control" id="unit_id">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<div class="form-group col-md-3">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
@ -76,7 +82,8 @@
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
</div> -->
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="calculatePremium(event);" >calc</a>
<a href="<?= base_url("#"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="checkDependentConflict(event);" >Check Dependent conflict</a>
<a href="<?= base_url("#"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="calculatePremium(event);" >calc premium</a>
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="addRowToTable();">+</a>
</div>
<!-- <button onclick="addRowToTable()">Add Row</button> -->
@ -136,13 +143,61 @@
<div class="modal-dialog modal-dialog-centered" style="max-width:80%;">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Center modal</h4>
<h4 class="modal-title" id="myCenterModalLabel">Premium Calculation Test Data</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<h5>Overflowing text to show scroll behavior</h5>
<p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="restable">
<thead class="bg-light">
<tr>
<th class="small-width">SNO</th>
<th class="small-width">Emp code</th>
<th class="large-width">Name</th>
<th class="medium-width">DOB</th>
<th class="medium-width">Relation</th>
<th class="large-width">Rack rate name</th>
<th class="small-width">Grid ID</th>
<th class="small-width">Is Self</th>
<th class="small-width">Premium type</th>
<th class="large-width">SI</th>
<th class="medium-width">premium</th>
<th class="small-width">Policy days</th>
<th class="small-width">no of days</th>
<th class="medium-width">Rata premium</th>
<th class="medium-width">GST</th>
</tr>
</thead>
<tbody id='restablebody'>
</tbody>
</table>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="modal fade" id="centermodal2" tabindex="-1" role="dialog" aria-hidden="true" >
<div class="modal-dialog modal-dialog-centered" style="max-width:80%;">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Premium Calculation Test Data</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="restable">
<thead class="bg-light">
<tr>
<th class="small-width">Column</th>
<th class="large-width">Error</th>
</tr>
</thead>
<tbody id='dependenttablebody'>
</tbody>
</table>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
@ -161,7 +216,8 @@
// Declare a global variable to store API response data
var clientPolicies = [];
var clientPoliciesWithBranch = {
policies: []
policies: [],
units:[]
};
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
@ -172,7 +228,11 @@
fetchClientPolicies();
addRowToTable(['Ram Kumar','01-Apr-1990','M','Self','500000','',450000,'A','unit1']);
addRowToTable(['Sita','01-Apr-1993','F','Spouse','500000','','','A','unit1']);
addRowToTable(['Sita','01-Apr-1993','F','Spouse','','','','','']);
addRowToTable(['Gugan','01-Apr-2005','M','Son','','','','','']);
addRowToTable(['Selvi','01-Apr-2010','F','Daughter','','','','','']);
addRowToTable(['Suresh','01-Apr-1960','M','Father','','','','','']);
addRowToTable(['Jamuna','01-Apr-1965','F','Mother','','','','','']);
});
@ -303,7 +363,7 @@
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.client_policy_id,
text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
text: `${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
});
if (PolicyID == item.client_policy_id) {
option.attr('selected', true);
@ -312,6 +372,60 @@
});
}
function appendUnits(data) {
$('#unit_id').empty();
$('#unit_id').append($('<option>', {
value: '0',
text: 'Select'
}));
// var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0' ?>;
// console.log(PolicyID)
$.each(data, function(index, item) {
var option = $('<option>', {
value: item,
text: item
});
if (index == 0) {
option.attr('selected', true);
setUnitInFirstRow(item);
}
$('#unit_id').append(option);
});
}
function setUnitInFirstRow(text) {
var cellIndex = 10;
// Get the tbody element by its ID
var tbody = document.getElementById('emptablebody');
// Check if the tbody exists
if (!tbody) {
console.error('Tbody element not found with id:', tbodyId);
return;
}
// Get the first row of the tbody
var firstRow = tbody.rows[0];
// Check if the first row exists
if (!firstRow) {
console.error('No rows found in tbody with id:', tbodyId);
return;
}
// Check if the specified cell index exists in the first row
if (cellIndex >= firstRow.cells.length) {
console.error('Cell index', cellIndex, 'out of bounds for the first row');
return;
}
// Set the text content of the specified cell in the first row
firstRow.cells[cellIndex].textContent = text;
}
$(document).ready(function() {
$('#clients').on('change', function() {
@ -334,30 +448,64 @@
appendBranch(foundPolicies.branchs);
});
$('#unit_id').on('change', function() {
var selectedUnit = $(this).val();
setUnitInFirstRow(selectedUnit);
});
});
$(document).ready(function() {
$('#branch_id').on('change', function() {
var selectedClient = $(this).val();
console.log(clientPolicies);
console.log(clientPoliciesWithBranch);
var selectedBranch = $(this).val();
var current_client_id = $('#clients').val();
// console.log('selectedBranch', selectedClient);
// console.log('clientPolicies', clientPoliciesWithBranch);
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
// console.log('item', item);
return item.branch_id === selectedClient;
return item.branch_id === selectedBranch;
});
var foundUnits = [];
clientPolicies.forEach(function(client) {
if (client.id == current_client_id) {
console.log('inside ' + current_client_id);
console.log(client.client_name + ' first if');
var branches = client.branchs;
branches.forEach(function(branch) {
if (branch.id == selectedBranch) {
console.log('inside branch check');
console.log(branch.branch_name);
console.log(branch.units);
foundUnits = (JSON.parse(branch.units));
}
});
}
});
console.log('final');
console.log(foundUnits);
if (Array.isArray(foundUnits) && foundUnits.length === 0) {
// appendPolicies(foundPolicies);
toastr.warning('No Units found for the selected client branch.');
} else {
// console.log('foundPolicies', foundPolicies);
appendUnits(foundUnits);
}
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
appendPolicies(foundPolicies);
toastr.warning('No policies found for the selected client branch.');
} else {
// console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
}
@ -378,11 +526,12 @@
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var branch_id = $('#branch_id').val();
// console.log(client_id + '-' + policy_id);
// if (client_id == '0' || policy_id == '0') {
// alert('Please select values in both dropdowns.');
// return;
// }
var unit_id = $('#unit_id').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select all values in dropdowns.');
return;
}
var queryParams = {
client_id: client_id,
@ -392,7 +541,7 @@
};
// $('#loader').show();
$('#loader').show();
var apiURL = '<?php echo base_url(); ?>' + 'employee/test-rack-rate';
console.log('calculatePremium');
// console.log(apiURL);
@ -406,17 +555,13 @@
data: JSON.stringify(queryParams),
success: function(response) {
console.log(response);
var myModal = new bootstrap.Modal(document.getElementById('centermodal'), { keyboard: true });
// Show the modal
myModal.show();
// return;
// console.log(response.dataStatus);
// console.log(response.data);
console.log(response.dataStatus);
console.log(response.data);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
// $("#centermodal").modal('show');
console.log('success');
displayData(response.data);
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
@ -428,7 +573,67 @@
}
});
// $('#loader').hide();
$('#loader').hide();
}
function checkDependentConflict() {
event.preventDefault(); // Prevent default action
let table = document.getElementById('emptable');
let tabledata = getTableDataAsJson(table);
// return;
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var branch_id = $('#branch_id').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0' || branch_id == '0') {
alert('Please select all values');
return;
}
var queryParams = {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
data: tabledata,
};
$('#loader').show();
var apiURL = '<?php echo base_url(); ?>' + 'employee/test-dependent';
console.log('calculatePremium');
// console.log(apiURL);
$.ajax({
url: apiURL,
method: 'POST',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
data: JSON.stringify(queryParams),
success: function(response) {
console.log(response);
console.log(response.dataStatus);
console.log(response.data);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
// $("#centermodal").modal('show');
console.log('success');
displayDependentData(response.data);
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
}
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
});
$('#loader').hide();
}
@ -439,6 +644,144 @@
icon.classList.toggle('mdi-chevron-up');
});
function displayData(data)
{
const tableBody = document.getElementById("restablebody");
$("#restablebody").empty();
const existingRowCount = tableBody.rows.length;
for(i = 0; i < data.length; i++)
{
const newRow = document.createElement("tr");
let newCell;
// SNO with auto-increment
newCell = document.createElement("td");
newCell.textContent = i + 1;
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
// Emp code (assuming you want an input field)
newCell = document.createElement("td");
newCell.innerHTML = data[i]['emp_code'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
// newCell.innerHTML = data[i]['name'] ;
newCell.innerHTML = data[i]['name'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = data[i]['dob'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = data[i]['relationship'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = data[i]['temp']['grid_name'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = data[i]['temp']['grid_id'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = (data[i]['temp']['acting_self'] ? 'Yes' : 'No');
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = (data[i]['temp']['premium_type'] == 1 ? 'S' : 'I');
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = (data[i]['policy_details']['basic_cover_si']);
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = (data[i]['policy_details']['premium']);
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = data[i]['policy_details']['days'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = data[i]['policy_details']['no_of_days'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = (data[i]['policy_details']['rata_premimum']);
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
newCell = document.createElement("td");
newCell.innerHTML = (data[i]['policy_details']['gst']);
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
tableBody.appendChild(newRow);
}
var myModal = new bootstrap.Modal(document.getElementById('centermodal'), { keyboard: true });
// Show the modal
myModal.show();
}
function displayDependentData(data)
{
const tableBody = document.getElementById("dependenttablebody");
$("#dependenttablebody").empty();
if(!data['result']['status'])
{
for(i = 0; i < data['result']['error_data'].length; i++)
{
const newRow = document.createElement("tr");
let newCell;
// SNO with auto-increment
newCell = document.createElement("td");
newCell.textContent = data['result']['error_data'][i]['col_name'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
// Emp code (assuming you want an input field)
newCell = document.createElement("td");
newCell.innerHTML = data['result']['error_data'][i]['msg'];
newCell.style.border = "1px solid";
newRow.appendChild(newCell);
tableBody.appendChild(newRow);
}
}
else
{
const newRow = document.createElement("div");
newRow.innerHTML = '<h2>All Good...!</h2>';
tableBody.appendChild(newRow);
}
var myModal = new bootstrap.Modal(document.getElementById('centermodal2'), { keyboard: true });
// Show the modal
myModal.show();
}
function formatNumberToIndianLocale(value, field_name, action) {

View File

@ -146,7 +146,7 @@ class PremiumCalculationTestNew extends CIUnitTestCase
foreach ($value['slab_rates'] as $skey => $svalue) {
$svalue['rack_rate_name'] = $key;
$svalue['grid_master'] = $value['grid_master'];
$all_rack_rates[] = $svalue;
$all_rack_rates['slab_rates'][] = $svalue;
}
// dd($value['slab_rates']);
}