FEAT_TEST_RACK_RATE_UI
This commit is contained in:
parent
b28a614980
commit
71bae2149c
@ -146,6 +146,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
|
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
|
||||||
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
|
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
|
||||||
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
|
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
|
||||||
|
$routes->post("test-dependent", "EmployeeController::testCheckDependentConflict");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1507,6 +1507,7 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
public function testRackRate()
|
public function testRackRate()
|
||||||
{
|
{
|
||||||
|
helper('excel_util_helper');
|
||||||
if ($this->request->getMethod() == 'get') {
|
if ($this->request->getMethod() == 'get') {
|
||||||
$filterData = $this->request->getGet('client_policy_id');
|
$filterData = $this->request->getGet('client_policy_id');
|
||||||
//just load UI only
|
//just load UI only
|
||||||
@ -1557,26 +1558,99 @@ class EmployeeController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// print_r($family_details);
|
// print_r($family_details);
|
||||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
|
// return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200);
|
||||||
//get policy details
|
//get policy details
|
||||||
$policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_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
|
//get rack rates
|
||||||
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
|
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($policy_id,$client_id);
|
||||||
//get file array or construnct dummy file array here
|
//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];
|
$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
|
//get familiy details in inception file format array from post method
|
||||||
$family_details = [
|
$data = calculate_premium_new(family_data: $family_details,policy_terms:$policy_details,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units);
|
||||||
[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, '', '', '', '', '', '', '', '', '',''],
|
foreach($data as $key => $member )
|
||||||
[4,'TEST001','Mary Doe', '01-Jan-1953', 'F', 'Mother', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
{
|
||||||
[5,'TEST001','Grace Doe', '01-Jan-1954', 'F', 'Mother in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
// ~dd($member);
|
||||||
//[6,'TEST001','George Doe', '01-Jan-1948', 'M', 'Father in law', '', NULL, '', '', '', '', '', '', '', '', '',''],
|
$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) : '';
|
||||||
[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, '', '', '', '', '', '', '', '', '',''],
|
|
||||||
];
|
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
|
||||||
$data = calculate_premimum_new($family_details,$policy_details,$all_rack_rates,$file);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1273,7 +1273,7 @@ class EmployeeServiceController extends AdminController
|
|||||||
|
|
||||||
|
|
||||||
// die();
|
// die();
|
||||||
return (($employee_data_group_by_family));
|
return (count($employee_data_group_by_family));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1008,7 +1008,7 @@ if (!function_exists('transform_excel_data_to_db'))
|
|||||||
// $policy['reason_for_exit'] = $memArr[17];
|
// $policy['reason_for_exit'] = $memArr[17];
|
||||||
|
|
||||||
$policy['client_policy_id'] = $actionArr['policy_id'];
|
$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['policy_end_date'] = null;
|
||||||
$policy['days'] = null;
|
$policy['days'] = null;
|
||||||
$policy['premium'] = null;
|
$policy['premium'] = null;
|
||||||
|
|||||||
@ -82,7 +82,7 @@ class ClientModel extends Model
|
|||||||
$client['policies'] = $clientPolicies;
|
$client['policies'] = $clientPolicies;
|
||||||
|
|
||||||
$clientBranchModel = new ClientBranchModel();
|
$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'])
|
->where('client_branch.client_id',$client['id'])
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<!-- <div class="text-center"> -->
|
<!-- <div class="text-center"> -->
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-3">
|
||||||
<label>Client</label> <br />
|
<label>Client</label> <br />
|
||||||
<select class="form-control" id="clients">
|
<select class="form-control" id="clients">
|
||||||
<option value="0">Select</option>
|
<option value="0">Select</option>
|
||||||
@ -54,14 +54,20 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-3">
|
||||||
<label>Branch</label> <br />
|
<label>Branch</label> <br />
|
||||||
<select name="branch_id" class="form-control" id="branch_id">
|
<select name="branch_id" class="form-control" id="branch_id">
|
||||||
<option value="0">Select</option>
|
<option value="0">Select</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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 />
|
<label>Policy</label> <br />
|
||||||
<select class="form-control" id="policies">
|
<select class="form-control" id="policies">
|
||||||
<option value="0">Select</option>
|
<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>
|
<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> -->
|
||||||
<div class="col-12" style="text-align: right;">
|
<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>
|
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="addRowToTable();">+</a>
|
||||||
</div>
|
</div>
|
||||||
<!-- <button onclick="addRowToTable()">Add Row</button> -->
|
<!-- <button onclick="addRowToTable()">Add Row</button> -->
|
||||||
@ -136,13 +143,61 @@
|
|||||||
<div class="modal-dialog modal-dialog-centered" style="max-width:80%;">
|
<div class="modal-dialog modal-dialog-centered" style="max-width:80%;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<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>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<h5>Overflowing text to show scroll behavior</h5>
|
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="restable">
|
||||||
<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>
|
<thead class="bg-light">
|
||||||
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
|
<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>
|
||||||
</div><!-- /.modal-content -->
|
</div><!-- /.modal-content -->
|
||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
@ -161,7 +216,8 @@
|
|||||||
// Declare a global variable to store API response data
|
// Declare a global variable to store API response data
|
||||||
var clientPolicies = [];
|
var clientPolicies = [];
|
||||||
var clientPoliciesWithBranch = {
|
var clientPoliciesWithBranch = {
|
||||||
policies: []
|
policies: [],
|
||||||
|
units:[]
|
||||||
};
|
};
|
||||||
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
|
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
|
||||||
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
|
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
|
||||||
@ -172,7 +228,11 @@
|
|||||||
fetchClientPolicies();
|
fetchClientPolicies();
|
||||||
|
|
||||||
addRowToTable(['Ram Kumar','01-Apr-1990','M','Self','500000','',450000,'A','unit1']);
|
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) {
|
$.each(data, function(index, item) {
|
||||||
var option = $('<option>', {
|
var option = $('<option>', {
|
||||||
value: item.client_policy_id,
|
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) {
|
if (PolicyID == item.client_policy_id) {
|
||||||
option.attr('selected', true);
|
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() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('#clients').on('change', function() {
|
$('#clients').on('change', function() {
|
||||||
@ -334,30 +448,64 @@
|
|||||||
appendBranch(foundPolicies.branchs);
|
appendBranch(foundPolicies.branchs);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#unit_id').on('change', function() {
|
||||||
|
|
||||||
|
var selectedUnit = $(this).val();
|
||||||
|
setUnitInFirstRow(selectedUnit);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('#branch_id').on('change', function() {
|
$('#branch_id').on('change', function() {
|
||||||
|
console.log(clientPolicies);
|
||||||
var selectedClient = $(this).val();
|
console.log(clientPoliciesWithBranch);
|
||||||
|
var selectedBranch = $(this).val();
|
||||||
|
var current_client_id = $('#clients').val();
|
||||||
|
|
||||||
// console.log('selectedBranch', selectedClient);
|
// console.log('selectedBranch', selectedClient);
|
||||||
// console.log('clientPolicies', clientPoliciesWithBranch);
|
// console.log('clientPolicies', clientPoliciesWithBranch);
|
||||||
|
|
||||||
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
|
||||||
// console.log('item', 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) {
|
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
|
||||||
|
|
||||||
appendPolicies(foundPolicies);
|
appendPolicies(foundPolicies);
|
||||||
toastr.warning('No policies found for the selected client branch.');
|
toastr.warning('No policies found for the selected client branch.');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// console.log('foundPolicies', foundPolicies);
|
// console.log('foundPolicies', foundPolicies);
|
||||||
appendPolicies(foundPolicies);
|
appendPolicies(foundPolicies);
|
||||||
}
|
}
|
||||||
@ -378,11 +526,12 @@
|
|||||||
var client_id = $('#clients').val();
|
var client_id = $('#clients').val();
|
||||||
var policy_id = $('#policies').val();
|
var policy_id = $('#policies').val();
|
||||||
var branch_id = $('#branch_id').val();
|
var branch_id = $('#branch_id').val();
|
||||||
// console.log(client_id + '-' + policy_id);
|
var unit_id = $('#unit_id').val();
|
||||||
// if (client_id == '0' || policy_id == '0') {
|
console.log(client_id + '-' + policy_id);
|
||||||
// alert('Please select values in both dropdowns.');
|
if (client_id == '0' || policy_id == '0') {
|
||||||
// return;
|
alert('Please select all values in dropdowns.');
|
||||||
// }
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var queryParams = {
|
var queryParams = {
|
||||||
client_id: client_id,
|
client_id: client_id,
|
||||||
@ -392,7 +541,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// $('#loader').show();
|
$('#loader').show();
|
||||||
var apiURL = '<?php echo base_url(); ?>' + 'employee/test-rack-rate';
|
var apiURL = '<?php echo base_url(); ?>' + 'employee/test-rack-rate';
|
||||||
console.log('calculatePremium');
|
console.log('calculatePremium');
|
||||||
// console.log(apiURL);
|
// console.log(apiURL);
|
||||||
@ -406,17 +555,13 @@
|
|||||||
data: JSON.stringify(queryParams),
|
data: JSON.stringify(queryParams),
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
console.log(response.dataStatus);
|
||||||
var myModal = new bootstrap.Modal(document.getElementById('centermodal'), { keyboard: true });
|
console.log(response.data);
|
||||||
|
|
||||||
// Show the modal
|
|
||||||
myModal.show();
|
|
||||||
// return;
|
|
||||||
// console.log(response.dataStatus);
|
|
||||||
// console.log(response.data);
|
|
||||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||||
// $("#centermodal").modal('show');
|
// $("#centermodal").modal('show');
|
||||||
console.log('success');
|
console.log('success');
|
||||||
|
|
||||||
|
displayData(response.data);
|
||||||
} else if (response.code === 404 && response.dataStatus === false) {
|
} else if (response.code === 404 && response.dataStatus === false) {
|
||||||
console.error('no data found', response);
|
console.error('no data found', response);
|
||||||
} else {
|
} 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');
|
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) {
|
function formatNumberToIndianLocale(value, field_name, action) {
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,7 @@ class PremiumCalculationTestNew extends CIUnitTestCase
|
|||||||
foreach ($value['slab_rates'] as $skey => $svalue) {
|
foreach ($value['slab_rates'] as $skey => $svalue) {
|
||||||
$svalue['rack_rate_name'] = $key;
|
$svalue['rack_rate_name'] = $key;
|
||||||
$svalue['grid_master'] = $value['grid_master'];
|
$svalue['grid_master'] = $value['grid_master'];
|
||||||
$all_rack_rates[] = $svalue;
|
$all_rack_rates['slab_rates'][] = $svalue;
|
||||||
}
|
}
|
||||||
// dd($value['slab_rates']);
|
// dd($value['slab_rates']);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user