Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
aadhavan valli 2024-07-30 14:48:18 +05:30
commit 78815446c6
12 changed files with 544 additions and 102 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

@ -1816,7 +1816,6 @@ class EmpDataServiceController extends BaseController
//Endorsement Correction
public function importCorrectionValidation($params)
{
@ -2232,7 +2231,6 @@ class EmpDataServiceController extends BaseController
//Endorsement SIEnhancement
public function importSIEnhancementValidation($params)
{
$file_id = $params['file_id'];
@ -2844,12 +2842,14 @@ class EmpDataServiceController extends BaseController
//Endorsement Deletion
public function importDeletionValidation($params)
{
{
$file_id = $params['file_id'];
$file = $this->batchFileModel->where('id', $file_id)->first();
// dd($file);
$client_id = $file['client_id'];
$client_policy_id = $file['client_policy_id'];
$client_branch_id = $file['client_branch_id'];
@ -2954,6 +2954,7 @@ class EmpDataServiceController extends BaseController
$query = $db->query($sql);
$endorsement_data = $query->getResultArray();
// dd($endorsement_data);
if ($endorsement_data == null || empty($endorsement_data)) {
@ -3255,7 +3256,7 @@ class EmpDataServiceController extends BaseController
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
$excel_data = $this->readExcelFileToArray($file_name_with_path);
unset($excel_data[0]);
array_pop($excel_data);
// array_pop($excel_data);
$emp_count = count($excel_data); //excel file count
@ -3279,6 +3280,7 @@ class EmpDataServiceController extends BaseController
$fetch_data = [
'client_policy_id' => $client_policy_id,
'client_branch_id' => $client_branch_id,
'client_id' => $client_id,
'emp_name' => $emp_name,
'emp_code' => $emp_code
];
@ -3289,8 +3291,8 @@ class EmpDataServiceController extends BaseController
if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) {
$employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status'], 'is_active' => 0);
$employees_table_data[] = array('id' => $result['employees_primarykey'], 'emp_status' => $result['status'], 'is_active' => 0);
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status']);
$employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']);
$emp_endorsement_table_data[] = array('id' => $result['emp_endorsement_primarykey'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[15], 'status' => 'complete');
}
@ -3843,7 +3845,7 @@ class EmpDataServiceController extends BaseController
FROM employee_polices
JOIN employees ON employees.id = employee_polices.employee_id
WHERE employees.unit = '$unit'
AND id IN (" . implode(',', $arrayData['employeeIds']) . ")
AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
")->getRow();
if($amount){
@ -3903,7 +3905,7 @@ class EmpDataServiceController extends BaseController
FROM employee_polices
JOIN employees ON employees.id = employee_polices.employee_id
WHERE employees.unit = '$unit'
AND id IN (" . implode(',', $arrayData['employeeIds']) . ")
AND employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
")->getRow();
if($amount){

View File

@ -98,6 +98,7 @@ class EmployeeController extends AdminController
emp_name : $filterData['emp_name'],
status : $filterData['status'],
);
// dd($this->employeePolicyModel->getLastQuery());
$data['getData'] = $filterData;
}
@ -162,7 +163,7 @@ class EmployeeController extends AdminController
// dd($res);
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->excelFileDataValidation(['file_id' => '38']);
// $res = $empServiceController->employeeDisembark(['file_id' => '586']);
// dd($res);
// $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: '2');
// dd($existing_famility_details);
@ -1163,21 +1164,8 @@ class EmployeeController extends AdminController
// $this->loadLayout('ecard_template/default_ecard');
$data = [
'employeeIds' => [6,8,10],
'client_id' => 12,
'client_policy_id' => 12,
'client_branch_id' => 1,
'cd_ac_no' => '34567834567892',
'endorsement_no' => null,
'count' => 3,
'event_name' =>'inception',
'policy_name' => 'new policy',
'user_id' => 1,
];
$empDataServiceController = new EmpDataServiceController();
$empData= $empDataServiceController->cashDepositCalculationForInception($data);
$empDataServiceController = new EmpDataServiceController();
$return = $empDataServiceController->importDeletionValidation(['file_id' => 130]);
}
@ -1507,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
@ -1557,26 +1546,99 @@ class EmployeeController extends AdminController
}
// 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
$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
$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
$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
$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

@ -906,8 +906,8 @@ class EmployeeServiceController extends AdminController
}
//proceed next data level validation in JOB queue
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
// $jobWorker = new JobWorker();
// JobWorker::processJob($r);
@ -1024,7 +1024,7 @@ class EmployeeServiceController extends AdminController
}
}
if(($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0 && ($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment')) || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) // 3 is GMC parents dep addon)
if(($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon)
{
$res = check_self_available_in_family($family,$file['action']);
if(!$res['is_self_found'])
@ -1248,12 +1248,11 @@ class EmployeeServiceController extends AdminController
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']);
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
// $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid(),'client_branch_id' => $params['client_branch_id']];
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
// dd($this->employeeModel->getLastQuery());
// Kint::dump($existing_famility_details);die();
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
@ -1273,7 +1272,7 @@ class EmployeeServiceController extends AdminController
// die();
return (($employee_data_group_by_family));
return (count($employee_data_group_by_family));
}
@ -1500,14 +1499,14 @@ class EmployeeServiceController extends AdminController
//get applicable slab rate for current member relation
$pre_rack_rate_name = '';
$applicable_rack_rate_name = '';
$applicable_rack_rate_master = '';
$applicable_rack_rate_master = [];
foreach ($slab_details['slab_rates'] as $skey => $slab_value)
{
if($pre_rack_rate_name != $slab_value['rack_rate_name'])
{
$pre_rack_rate_name = $slab_value['rack_rate_name'];
$rack_rate_json = json_decode($slab_value['additional_relationship']);
if(in_array(strtolower($employee['relationship']), $rack_rate_json) && $rack_rate_json[ strtolower($employee['relationship']) ] != 0 && $rack_rate_json[ strtolower($employee['relationship']) ] != NA)
if(in_array(strtolower($employee['relationship']), $rack_rate_json) && $rack_rate_json[ strtolower($employee['relationship']) ] != 0 && $rack_rate_json[ strtolower($employee['relationship']) ] != 'NA')
{
$applicable_rack_rate_name = $slab_value['rack_rate_name'];
$applicable_rack_rate_master = $slab_value['grid_master'];

View File

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

View File

@ -227,11 +227,14 @@ if(!function_exists('check_si'))
{
function check_si($row,$policy_details,$slab_details)
{
// Kint::dump($policy_details);
$policy_details = (array)$policy_details[0];
// dd($policy_details);
$return_array = array('status' => true,'error' => '');
$is_si_found = false;
$is_age_slab_found = false;
if($policy_details[0]['policy_type_id'] == 1 && $slab_details[0]['policy_grid_id'] == 1 && $slab_details[0]['si_or_bp'] == 2) // GPA && grid type 1 for GPA && sub type is basic pay
if($policy_details['policy_type_id'] == 1 && $slab_details[0]['policy_grid_id'] == 1 && $slab_details[0]['si_or_bp'] == 2) // GPA && grid type 1 for GPA && sub type is basic pay
{
$is_si_found = true;
$is_age_slab_found = true;
@ -1008,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;
@ -1986,13 +1989,14 @@ if(!function_exists('check_unit'))
{
function check_unit($row,$existing_units)
{
$temp = $row[18];
$temp = empty($row[18]) ? $row[18] : trim($row[18]);
if(in_array($row['current_action'], ['I','A','MI']) )
{
if(count($existing_units) == 1)
{
if(empty(trim($row[18])))
if(empty($temp))
{
return array('status' => true);
}
@ -2000,11 +2004,11 @@ if(!function_exists('check_unit'))
if(strtolower($row[5]) == 'self')
{
if(in_array(trim($row[18]),$existing_units)) //18 is unit name
if(in_array($temp,$existing_units)) //18 is unit name
{
return array('status' => true);
}
else if(!empty(trim($row[18])))
else if(!empty($temp))
{
return array('status' => false,'error' => 'wrong unit name');
}
@ -2015,13 +2019,13 @@ if(!function_exists('check_unit'))
}
else
{
if(empty(trim($row[18])))
if(empty($temp))
{
return array('status' => true);
}
else
{
if(in_array(trim($row[18]),$existing_units)) //18 is unit name
if(in_array($temp,$existing_units)) //18 is unit name
{
return array('status' => true);
}

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

@ -109,7 +109,7 @@ class EmployeeModel extends Model
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policies.name as policy_name','client_policy.is_addon'])
->join('employee_polices', 'employee_polices.employee_id = employees.id')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policies', 'policies.id = client_policy.policy_id')
->join('policies', 'policies.id = client_policy.policy_id','left')
->where('employees.is_active',1)
->when($client_policy_id, function($query) use ($client_policy_id){
return $query->where('employee_polices.client_policy_id',$client_policy_id);

View File

@ -81,7 +81,7 @@ class EmployeePolicyModel extends Model
$result = $this->select([
'employee_polices.*',
'pm.name as policy_name',
'policy_type.policy_type as policy_name',
'im.short_name as insurer_short_name',
'ib.branch_name as insurer_branch_name',
'ib.branch_code as insurer_branch_code',
@ -109,8 +109,8 @@ class EmployeePolicyModel extends Model
])
->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
->join('policy_type', 'policy_type.id = pm.policy_type_id')
->join('policies pm', 'cp.policy_id = pm.id', 'left') //pm - policy master
->join('policy_type', 'policy_type.id = cp.policy_type_id')
->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master
->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch
->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master
@ -511,6 +511,7 @@ class EmployeePolicyModel extends Model
employees.relationship_code AS emp_relationship_code,
employees.emp_type as emp_type,
'D' as event_type_data,
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
employees.doj AS emp_doj,
employees.mobile AS emp_mobile,
@ -604,6 +605,7 @@ class EmployeePolicyModel extends Model
$client_policy_id = $fetch_data['client_policy_id'];
$client_branch_id = $fetch_data['client_branch_id'];
$client_id = $fetch_data['client_id'];
$emp_name = $fetch_data['emp_name'];
$emp_code = $fetch_data['emp_code'];
@ -614,6 +616,18 @@ class EmployeePolicyModel extends Model
ep.id as emp_policy_primarykey,
e.id as employees_primarykey,
ee.group_key,
(
SELECT employees.id
FROM employees
WHERE client_id = '$client_id'
AND client_branch_id = '$client_branch_id'
AND is_active = 1
AND emp_status = 'active'
AND emp_code = '$emp_code'
AND name = '$emp_name'
LIMIT 1
) AS employees_id,
MAX(
CASE
WHEN ee.field_name = 'date_of_exit' THEN ee.new_value

View File

@ -140,7 +140,7 @@
<script>
toastr.options = {
"timeOut": 2000,
"timeOut": 5000,
"closeButton": true,
};
</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">Dependent Conflict 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 -->
@ -151,6 +206,19 @@
<script>
let mouseX = 0;
let mouseY = 0;
document.addEventListener('mousemove', function(event) {
mouseX = event.clientX;
mouseY = event.clientY;
});
function getMouseCoordinates() {
return { x: mouseX, y: mouseY };
}
$(document).ready(function() {
// Initialize select2
$("#clients").select2();
@ -161,7 +229,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 +241,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 +376,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 +385,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 +461,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 +539,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 +554,7 @@
};
// $('#loader').show();
$('#loader').show();
var apiURL = '<?php echo base_url(); ?>' + 'employee/test-rack-rate';
console.log('calculatePremium');
// console.log(apiURL);
@ -406,17 +568,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 +586,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 +657,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) {
@ -541,6 +897,7 @@ const suggestionsList = document.getElementById("suggestions");
newCell.contentEditable = "true"; // Make the cell editable (if needed)
newCell.style.border = "1px solid";
newCell.addEventListener("input", handleInput);
newCell.addEventListener("blur", function(){ hideSuggestions(); });
newRow.appendChild(newCell);
// SI (assuming you want a date input field)
@ -640,10 +997,13 @@ const suggestionsList = document.getElementById("suggestions");
// Position the suggestion box near the input field (optional)
const cellRect = focusedCell.parentNode.getBoundingClientRect();
// console.log(cellRect.left);
// console.log(cellRect.right);
suggestionBox.style.left = 170 + "px";
suggestionBox.style.top = 50 + "px";
const coords = getMouseCoordinates();
console.log(coords.x);
console.log(coords.y);
suggestionBox.style.left = (coords.x - 100) + "px";
suggestionBox.style.top = (coords.y - 300) + "px";
}
}

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']);
}