FEAT_ENDORSEMENT_MODAL_AND_OTHER : RV

This commit is contained in:
VENKATESHWARAN 2024-04-04 15:22:02 +05:30
parent 443e9e1173
commit 34cd45b1c1
13 changed files with 782 additions and 117 deletions

View File

@ -207,6 +207,7 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){
$routes->get("policy-premium", "ClientController::getpolicyGridData/$1");
$routes->get("update-policy-status", "ClientController::updateClientPolicyStatus/$1");
$routes->get("download-excel/(:any)", "EmployeeController::downloadSampleExcelFile/$1");
$routes->get("get-emp-endorsement/(:any)", "EmployeeController::getEmpEndoresmentEntry/$1");
$routes->post("import-export", "EmployeeController::importExport");
});

View File

@ -1002,5 +1002,120 @@ class EmpDataServiceController extends BaseController
->where('client_policy.id', $client_policy_id)
->first();
}
public function convertRowTColumnForSIEnhancement($data){
$result = array();
foreach ($data as $obj) {
$pro_rata_premium = round(($obj->difference_premium * $obj->no_of_days / 365), 2);
$gst = round(($pro_rata_premium * 18 / 100), 2);
$total = round(($pro_rata_premium + $gst), 2);
$old_total = round(($obj->old_rata + $obj->old_gst), 2);
$result[] = array(
"field_name" => 'Basic Cover SI',
"old_value" => $obj->old_basic_cover_si,
"new_value" => $obj->new_basic_cover_si
);
$result[] = array(
"field_name" => 'Premium',
"old_value" => $obj->old_si_premium,
"new_value" => $obj->new_si_premium
);
$result[] = array(
"field_name" => 'SI Enhancement Date',
"old_value" => change_date_format($obj->old_date, 'Y-m-d', 'd-M-Y'),
"new_value" => change_date_format($obj->date_of_coverage, 'Y-m-d', 'd-M-Y')
);
$result[] = array(
"field_name" => 'Difference Premium',
"old_value" => ' --- ',
"new_value" => $obj->difference_premium
);
$result[] = array(
"field_name" => 'No of Days',
"old_value" => $obj->old_days,
"new_value" => $obj->no_of_days
);
$result[] = array(
"field_name" => 'Pro Rata Premium',
"old_value" => $obj->old_rata,
"new_value" => $pro_rata_premium
);
$result[] = array(
"field_name" => 'GST(18%)',
"old_value" => $obj->old_gst,
"new_value" => $gst
);
$result[] = array(
"field_name" => 'Total',
"old_value" => $old_total,
"new_value" => $total
);
}
return $result;
}
public function convertRowTColumnForDeletion($data){
$result = array();
foreach ($data as $obj) {
$old_total = round(($obj->old_rata + $obj->old_gst), 2);
$result[] = array(
"field_name" => 'Date of Leaving',
"old_value" => change_date_format($obj->end_date, 'Y-m-d', 'd-M-Y'),
"new_value" => change_date_format($obj->date_of_leaving, 'Y-m-d', 'd-M-Y')
);
$result[] = array(
"field_name" => 'Exit Reason',
"old_value" => ' --- ',
"new_value" => $obj->exist_reason
);
$result[] = array(
"field_name" => 'No of Days',
"old_value" => $obj->old_days,
"new_value" => $obj->no_of_days
);
$result[] = array(
"field_name" => 'Pro Rata Premium',
"old_value" => $obj->old_rata,
"new_value" => $obj->pro_rata_premium
);
$result[] = array(
"field_name" => 'GST(18%)',
"old_value" => $obj->old_gst,
"new_value" => $obj->gst
);
$result[] = array(
"field_name" => 'Total',
"old_value" => $old_total,
"new_value" => $obj->total
);
}
return $result;
}
// -----------------------------------------------------------------------------------
}

View File

@ -61,10 +61,12 @@ class EmployeeController extends AdminController
{
// $model = new UserModel();
$data = [];
$data['status'] = ['draft' => 'Draft', 'active' => 'Active', 'inactive' => 'In-Active', 'expired' => 'Expired'];
if(count($this->request->getGet()))
{
$filterData = $this->request->getGet();
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(client_id: $filterData['client_id'],policy_id: $filterData['policy_id']);
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(client_id: $filterData['client_id'],policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['getData'] = $filterData;
}
$this->myLogger->logme('error','list called');
@ -453,15 +455,66 @@ class EmployeeController extends AdminController
// -------------------------------------------------------------------------------------------
public function endorsementList(){
// $empDataServiceController = new EmpDataServiceController();
// $group_key = $this->empEndorsementModel->select('group_key, actions')->where('id', 4)->first();
// $data = $this->empEndorsementModel->getDataForEnodrsementListinSIEnhancement($group_key['group_key']);
// $formatedData = $empDataServiceController->convertRowTColumnForSIEnhancement($data);
// $ee_entry = $this->empEndorsementModel->where('group_key', 107)->findAll();
// $ee_entry[0]['field_name'] = remove_underscore_capitalize_first_letter($ee_entry[0]['field_name']);
// echo "<pre>";
// print_r($formatedData); die;
$data = [];
$data['status'] = ['pending' => 'Pending', 'inprogress' => 'In-Progress', 'complete'=>'Complete'];
if(count($this->request->getGet()))
{
$filterData = $this->request->getGet();
$data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(client_id: $filterData['client_id'],policy_id: $filterData['policy_id']);
$data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(client_id: $filterData['client_id'],policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['getData'] = $filterData;
// echo "<pre>";
// print_r($data); die;
}
$this->myLogger->logme('error','list called');
$this->loadLayout('endorsement_list',$data);
}
public function getEmpEndoresmentEntry($id = null){
$empDataServiceController = new EmpDataServiceController();
if($id)
{
$group_key = $this->empEndorsementModel->select('group_key, actions')->where('id', $id)->first();
$nor_data = $this->empEndorsementModel->where('group_key', $group_key['group_key'])->findAll();
$ee_entry = '';
if($group_key['actions'] == 'si'){
$data = $this->empEndorsementModel->getDataForEnodrsementListinSIEnhancement($group_key['group_key']);
$formatedData = $empDataServiceController->convertRowTColumnForSIEnhancement($data);
$ee_entry = $formatedData;
}else if($group_key['actions'] == 'd'){
$data = $this->empEndorsementModel->getDataForEnodrsementListinDeletion($group_key['group_key']);
$formatedData = $empDataServiceController->convertRowTColumnForDeletion($data);
$ee_entry = $formatedData;
}else{
$ee_entry = $this->empEndorsementModel->where('group_key', $group_key['group_key'])->findAll();
$ee_entry[0]['field_name'] = remove_underscore_capitalize_first_letter($ee_entry[0]['field_name']);
$ee_entry[0]['old_value'] = formatDateOrReturn($ee_entry[0]['old_value']);
$ee_entry[0]['new_value'] = formatDateOrReturn($ee_entry[0]['new_value']);
}
return $this->respond(['dataStatus' => true,'code' => 200, 'data' => $ee_entry, 'data2' => $nor_data], 200);
}
else
{
return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'no data found'], 200);
}
}
}

View File

@ -397,4 +397,19 @@ if (!function_exists('remove_underscore_capitalize_first_letter')) {
$formattedEvent = ucwords(str_replace('_', ' ', $word));
return $formattedEvent;
}
}
if (!function_exists('formatDateOrReturn')) {
function formatDateOrReturn($value)
{
// Check if the value is a valid date
$timestamp = strtotime($value);
if ($timestamp !== false) {
// Format the date
return date('d-M-Y', $timestamp);
} else {
// Return the original value
return $value;
}
}
}

View File

@ -129,3 +129,5 @@ if(!function_exists('check_string_date'))

View File

@ -11,6 +11,7 @@ class EmpEndorsementModel extends Model
protected $allowedFields = [
'id',
'pk',
'group_key',
'endorsement_id',
'emp_code',
'table_name',
@ -27,4 +28,170 @@ class EmpEndorsementModel extends Model
"remarks"
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
// protected function afterFind(array $data)
// {
// foreach ($data as &$row) {
// // Format date_of_coverage field to Indian date format
// if (isset($row['field_name'])) {
// $row['field_name'] = remove_underscore_capitalize_first_letter($row['field_name']);
// }
// }
// return $data;
// }
public function getDataForEnodrsementListinSIEnhancement($group_key){
$query = "
SELECT
employee_polices.days as old_days,
employee_polices.rata_premimum as old_rata,
employee_polices.gst as old_gst,
client_policy.policy_start_date as old_date,
MAX(CASE WHEN emp_endorsement.field_name = 'basic_cover_si' THEN emp_endorsement.new_value ELSE NULL END) AS new_basic_cover_si,
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) AS new_si_premium,
MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END) AS date_of_coverage,
MAX(CASE WHEN emp_endorsement.field_name = 'basic_cover_si' THEN emp_endorsement.old_value ELSE NULL END) AS old_basic_cover_si,
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END) AS old_si_premium,
(MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) AS difference_premium,
DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value END)) + 1 AS no_of_days,
ROUND(
(
(
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value END) -
MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value END)
) *
DATEDIFF(
employee_polices.policy_end_date,
MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value END)
) / 365
),
2
) AS pro_rata_premimum,
ROUND(((MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) * DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END)) / 365) * 0.18, 2) AS gst,
ROUND(((MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) * DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END)) / 365), 2) +
ROUND(((MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.new_value ELSE NULL END) - MAX(CASE WHEN emp_endorsement.field_name = 'premium' THEN emp_endorsement.old_value ELSE NULL END)) * DATEDIFF(employee_polices.policy_end_date, MAX(CASE WHEN emp_endorsement.field_name = 'si_enhancement_date' THEN emp_endorsement.new_value ELSE NULL END)) / 365) * 0.18, 2) AS total
FROM emp_endorsement
JOIN employee_polices ON employee_polices.id = emp_endorsement.pk
JOIN client_policy ON client_policy.id = employee_polices.client_policy_id
WHERE group_key = '{$group_key}'
";
$results = $this->db->query($query)->getResult();
return $results;
}
public function getDataForEnodrsementListinDeletion($group_key){
$query = "
SELECT
employee_polices.days as old_days,
employee_polices.rata_premimum as old_rata,
employee_polices.gst as old_gst,
employee_polices.policy_end_date as end_date,
MAX(CASE WHEN a.field_name = 'date_of_exit' THEN a.new_value ELSE NULL END) AS date_of_leaving,
MAX(CASE WHEN a.field_name = 'reason_for_exit' THEN a.new_value ELSE NULL END) AS exist_reason,
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) AS no_of_days,
ROUND((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365, 2) AS pro_rata_premium,
ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18, 2) AS gst,
ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) + (((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18), 2) AS total
FROM
emp_endorsement a
LEFT JOIN
employees ON a.emp_code = employees.emp_code
LEFT JOIN
employee_polices ON employees.id = employee_polices.employee_id
LEFT JOIN (
SELECT
aa.emp_code,
aa.new_value AS 'empstatus',
bb.new_value AS 'changeevent',
cc.new_value AS 'dateofexit',
dd.new_value AS 'reasonforexit',
ee.new_value AS 'status'
FROM
(
SELECT
a1.emp_code,
a1.field_name,
a1.new_value
FROM
emp_endorsement AS a1
WHERE
a1.field_name = 'emp_status'
) aa
LEFT JOIN
(
SELECT
b1.emp_code,
b1.field_name,
b1.new_value
FROM
emp_endorsement AS b1
WHERE
b1.field_name = 'change_event'
) bb ON aa.emp_code = bb.emp_code
LEFT JOIN
(
SELECT
c1.emp_code,
c1.field_name,
c1.new_value
FROM
emp_endorsement AS c1
WHERE
c1.field_name = 'date_of_exit'
) cc ON aa.emp_code = cc.emp_code
LEFT JOIN
(
SELECT
d1.emp_code,
d1.field_name,
d1.new_value
FROM
emp_endorsement AS d1
WHERE
d1.field_name = 'reason_for_exit'
) dd ON aa.emp_code = dd.emp_code
LEFT JOIN
(
SELECT
e1.emp_code,
e1.field_name,
e1.new_value
FROM
emp_endorsement AS e1
WHERE
e1.field_name = 'status'
) ee ON aa.emp_code = ee.emp_code
) AS deletiondata ON a.emp_code = deletiondata.emp_code
WHERE group_key = '{$group_key}';
";
$results = $this->db->query($query)->getResult();
return $results;
}
}

View File

@ -67,7 +67,7 @@ class EmployeePolicyModel extends Model
}
// -----------------------------------------------------------------------------------------------------
public function getEmployeePolicy($client_id,$policy_id)
public function getEmployeePolicy($client_id,$policy_id,$status)
{
$result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active'])
->join('employees emp', 'employee_polices.employee_id = emp.id')
@ -79,8 +79,13 @@ class EmployeePolicyModel extends Model
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
->where('employee_polices.client_policy_id',$policy_id)
->findAll();
->where('employee_polices.client_policy_id',$policy_id);
if($status != 0 && !empty($status)){
$result->where('employee_polices.status', $status);
}
$result = $result->findAll();
return ($result);
}
@ -561,22 +566,78 @@ class EmployeePolicyModel extends Model
}
public function getEmployeeEndorsementList($client_id,$policy_id)
{
$result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active'])
->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('insurers im', 'cp.insurer_id = im.id') //im - insurar master
->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch
->join('tpa tpam', 'cp.tpa_id = tpam.id') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
->where('employee_polices.client_policy_id',$policy_id)
->findAll();
return ($result);
}
//------------------------------------------------------------------
public function getEmployeeEndorsementList($client_id, $policy_id, $status)
{
$query1 = $this->db->table('emp_endorsement e');
$query1->select('
e.id,
e.pk,
e.emp_code,
e.name,
e.actions,
e.status,
e.remarks,
e.endorsement_id,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name
');
$query1->distinct();
$query1->join('employee_polices ep', 'ep.id = e.pk', 'left');
$query1->join('employees', 'employees.id = ep.employee_id', 'left');
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left');
$query1->join('policies', 'policies.id = client_policy.policy_id', 'left');
$query1->join('insurers', 'insurers.id = policies.insurer_id', 'left');
$query1->whereIn('e.actions', ['c']);
$query1->where('ep.client_policy_id', $client_id);
$query1->where('employees.client_id', $policy_id);
if($status != 0 && !empty($status)){
}
$query1->where('e.status', $status);
}
$query1->orderBy('e.id', 'desc');
$results1 = $query1->get()->getResultArray();
$query2 = $this->db->table('emp_endorsement e');
$query2->select('
e.id,
e.pk,
e.emp_code,
e.name,
e.actions,
e.status,
e.endorsement_id,
e.remarks,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name
');
$query2->join('employee_polices ep', 'ep.id = e.pk', 'left');
$query2->join('employees', 'employees.id = ep.employee_id', 'left');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left');
$query2->join('policies', 'policies.id = client_policy.policy_id', 'left');
$query2->join('insurers', 'insurers.id = policies.insurer_id', 'left');
$query2->whereIn('e.actions', ['si', 'd']);
$query2->where('ep.client_policy_id', $client_id);
$query2->where('employees.client_id', $policy_id);
if($status != 0 && !empty($status)){
$query2->where('e.status', $status);
}
$query2->groupBy('e.emp_code, e.name, e.actions');
$query2->orderBy('e.id', 'desc');
$results2 = $query2->get()->getResultArray();
$results = array_merge($results1, $results2);
return $results;
}
//----------------------------------------------------------------------------------------------
}

View File

@ -1,5 +1,4 @@
<style>
body {
.multiselect-native-select {
position: relative;
@ -25,7 +24,15 @@ body {
.multiselect-selected-text{
float: left !important;
}
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
</style>
<!-- End ADD and EDIT Page HTML -->

View File

@ -323,7 +323,7 @@
policyTable += `
<tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${item.policy_name}</td>
<td>${item.policy_name} (${item.policy_type_name})</td>
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
<td>${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)}</td>
<td>${checkDateStatus(item.policy_end_date, 1)}</td>

View File

@ -22,23 +22,34 @@ table.dataTable tbody td {
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<!-- <div class="text-center"> -->
<div class="row">
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Status</label> <br />
<select class="form-control" id="status2">
<option value="0">Select</option>
<?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>"
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
@ -98,7 +109,19 @@ table.dataTable tbody td {
<td><?php echo $employee['insurer_short_name']?></td>
<td><?php echo $employee['tpa_id']?></td>
<td><?php echo $employee['uhid']?></td>
<td><span class="badge badge-success">active</span></td>
<td>
<?php
if ($employee['status'] == 'draft') {
echo '<span class="badge badge-secondary">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'active') {
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inactive') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
}elseif ($employee['status'] == 'expired') {
echo '<span class="badge badge-danger">' . $employee['status'] . '</span>';
}
?>
</td>
<td><?php echo $employee['premium']?></td>
<td>
<div class="btn-group dropdown">
@ -134,6 +157,8 @@ table.dataTable tbody td {
<script>
// Declare a global variable to store API response data
var clientPolicies = [];
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
$(document).ready(function() {
console.log("document loaded");
@ -144,7 +169,6 @@ $(document).ready(function() {
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
@ -167,8 +191,21 @@ function fetchClientPolicies() {
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
// console.log(clientPolicies);
console.log('1',clientPolicies);
appendClients(clientPolicies);
//this function for reselect the policy
setTimeout(function() {
if (client_id != 0 ) {
var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id)
return item.id == client_id;
});
appendPolicies(foundPolicies.policies);
}
}, 500);
//end
} catch (error) {
console.error('Error parsing API response data:', error);
}
@ -188,29 +225,43 @@ function fetchClientPolicies() {
function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
$('#clients').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.client_name
}));
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0'?>;
console.log(PolicyID)
$.each(data, function(index, item) {
$('#policies').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.name
}));
});
if (PolicyID == item.id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
$('#clients').on('change', function() {
var selectedClient = $(this).val();
console.log(selectedClient);
@ -224,16 +275,20 @@ $('#clients').on('change', function() {
appendPolicies(foundPolicies.policies);
});
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function fetchEmpolyeeList(event) {
event.preventDefault(); // Prevent default action
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status2').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
@ -241,8 +296,10 @@ function fetchEmpolyeeList(event) {
}
var queryParams = {
client_id: client_id,
policy_id: policy_id
policy_id: policy_id,
status : status,
};
const queryString = objectToQueryString(queryParams);
@ -268,9 +325,11 @@ function fetchEmpolyeeList(event) {
// });
}
document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
</script>

View File

@ -1,12 +1,12 @@
<style>
.table th,
.table td {
padding: 8px;
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
</style>
<div class="row">
@ -22,23 +22,34 @@
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<!-- <div class="text-center"> -->
<div class="row">
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
</select>
</div>
<div class="col-md-6 col-xl-3">
<div class="form-group mb-3">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
<select class="form-control" id="policies">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Status</label> <br />
<select class="form-control" id="status1">
<option value="0">Select</option>
<?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>"
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
@ -74,11 +85,11 @@
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">Name/code</th>
<th class="font-weight-medium">Policy name</th>
<th class="font-weight-medium">Insurar name</th>
<th class="font-weight-medium">TPA ID</th>
<th class="font-weight-medium">UHID ID</th>
<th class="font-weight-medium">Policy status</th>
<th class="font-weight-medium">Premium</th>
<th class="font-weight-medium">Endorsement ID</th>
<th class="font-weight-medium">Insurer name</th>
<th class="font-weight-medium">Remarks</th>
<th class="font-weight-medium">Endorsement Type</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
@ -91,32 +102,37 @@
<tr>
<td><b><?php echo ($key + 1)?></b></td>
<!-- <td><?php echo $employee['emp_code']?></td> -->
<td><?php echo $employee['name']?>( <?php echo $employee['emp_code']?> )</td>
<td><?php echo $employee['policy_name']?></td>
<td><?php echo $employee['insurer_short_name']?></td>
<td><?php echo $employee['tpa_id']?></td>
<td><?php echo $employee['uhid']?></td>
<td><span class="badge badge-success">active</span></td>
<td><?php echo $employee['premium']?></td>
<td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?></td>
<td><?php echo $employee['endorsement_id']?></td>
<td><?php echo isset($employee['insurer_short_name']) ? $employee['insurer_short_name'] : '' ?>
</td>
<td><?php echo $employee['remarks']?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#"><i
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
Ticket</a>
<a class="dropdown-item" href="#"><i
class="mdi mdi-check-all mr-2 text-muted font-18 vertical-middle"></i>Close</a>
<a class="dropdown-item" href="#"><i
class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Remove</a>
<a class="dropdown-item" href="#"><i
class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>Mark as
Unread</a>
</div>
</div>
<?php
if ($employee['actions'] == 'c') {
echo 'Correction';
} elseif ($employee['actions'] == 'si') {
echo 'SI Enhancement';
} elseif ($employee['actions'] == 'd') {
echo 'Deletion';
}
?>
</td>
<td>
<?php
if ($employee['status'] == 'pending') {
echo '<span class="badge badge-danger">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inprogress') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'complete') {
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
}
?>
</td>
<td class="text-center"><a href="#" data-id="<?php echo $employee['id']?>"
class="fa fa-eye emp_data_model" aria-hidden="true" data-toggle="modal"
data-target="#centermodal"></a>
</td>
</tr>
<?php }}?>
@ -127,27 +143,52 @@
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<div id="loader" class="loader" style="display:none;">SPINNER</div>
<!-- Center modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">Endorsement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th class="font-weight-medium"></th>
<th class="font-weight-medium">Old Value</th>
<th class="font-weight-medium">New Value</th>
</tr>
</thead>
<tbody id="table_data">
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
// Declare a global variable to store API response data
var clientPolicies = [];
$(document).ready(function() {
console.log("document loaded");
//fetchClientPolicies();
});
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
function fetchClientPolicies() {
$('#loader').show();
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies');
@ -166,8 +207,21 @@ function fetchClientPolicies() {
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
// console.log(clientPolicies);
console.log(clientPolicies);
appendClients(clientPolicies);
//this function for reselect policy
setTimeout(function() {
if (client_id) {
var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id)
return item.id == client_id;
});
appendPolicies(foundPolicies.policies);
}
}, 500);
//end
} catch (error) {
console.error('Error parsing API response data:', error);
}
@ -187,26 +241,40 @@ function fetchClientPolicies() {
function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
$('#clients').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.client_name
}));
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0'?>;
console.log(PolicyID)
$.each(data, function(index, item) {
$('#policies').append($('<option>', {
var option = $('<option>', {
value: item.id,
text: item.name
}));
});
if (PolicyID == item.id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
@ -233,6 +301,7 @@ function fetchEmpolyeeList(event) {
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status1').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
@ -241,7 +310,8 @@ function fetchEmpolyeeList(event) {
var queryParams = {
client_id: client_id,
policy_id: policy_id
policy_id: policy_id,
status: status,
};
const queryString = objectToQueryString(queryParams);
@ -256,4 +326,117 @@ document.getElementById('toggleIcon').addEventListener('click', function() {
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
$('.emp_data_model').click(function() {
var myVal = $(this).data('id');
console.log(myVal);
fetchEmpEndorsementData(myVal)
});
function fetchEmpEndorsementData(id) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = '<?php echo base_url();?>' + 'util/get-emp-endorsement/' + id;
console.log('fetchEmpEndorsementData');
console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
if (response.code === 200 && response.dataStatus === true) {
try {
endorsementData = (response.data);
endorsementData2 = (response.data2);
e_actions = endorsementData2[0]['actions'];
var heading = "";
if (endorsementData2[0]['actions'] == 'si') {
heading = ' - ' + 'SI Enhancement';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'd') {
heading = ' - ' + 'Deletion';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'c') {
heading = ' - ' + 'Correction';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
}
$('#heading').html(heading);
$('#table_data').empty();
$.each(endorsementData, function(index, item) {
var tableHtml = `
<tr>
<td>${item.field_name}</td>
<td>${formatNumberToIndianLocale(item.old_value, item.field_name)}</td>
<td>${formatNumberToIndianLocale(item.new_value, item.field_name, e_actions)}</td>
</tr>
`;
$('#table_data').append(tableHtml);
});
} catch (error) {
console.error('Error parsing API response data:', error);
}
} 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);
}
});
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 200);
}
function formatNumberToIndianLocale(value, field_name, action) {
console.log(action)
// Check if the value is a valid number (either as a number or as a string)
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
// Convert the value to a number and format it using Indian English locale
var return_val = parseFloat(value).toLocaleString('en-IN');
if(field_name == 'Total'){
if(action == 'd'){
return '₹ ' + return_val + ' ( Refund )';
}else if(action == 'si'){
return '₹ ' + return_val + ' ( To be paid )';
}
}
return '₹ ' + return_val;
} else {
// Return the original value if it's not a valid number
return value;
}
}
$('.close').click(function(){
$('#table_data').empty();
})
</script>

View File

@ -14,6 +14,7 @@
<th class="font-weight-medium">File name</th>
<th class="font-weight-medium">Client</th>
<th class="font-weight-medium">policy</th>
<th class="font-weight-medium">Event</th>
<th class="font-weight-medium">User/Time</th>
<th class="font-weight-medium">Status</th>
</tr>
@ -34,6 +35,7 @@
<td><?php echo $file['file_name']?></td>
<td><?php echo $file['short_name']?></td>
<td><?php echo $file['policy_name']?></td>
<td><?php echo $file['action']?></td>
<td><?php echo fancy_date_time_format($file['created_at']).' by <strong>'.$file['first_name'].'</strong>'?></td>
<td><?php echo $file['status']; if($file['status'] == 'failed')
{

View File

@ -5,8 +5,8 @@
<meta charset="utf-8" />
<title>nHANCE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
<meta content="A fully featured CRM" name="description" />
<meta content="Venba info tech" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?= base_url()."public"; ?>/assets/images/favicon.ico">