Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
velz 2024-09-24 14:06:56 +05:30
commit 578c0713f0
8 changed files with 263 additions and 175 deletions

View File

@ -362,15 +362,18 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase"); $routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
$routes->post("saveMpin", "RestAuthenticationController::saveMpin"); $routes->post("saveMpin", "RestAuthenticationController::saveMpin");
$routes->post("updateMpin", "RestAuthenticationController::updateMpin"); $routes->post("updateMpin", "RestAuthenticationController::updateMpin");
$routes->post("getChatResponse", "ChatBotController::getChatResponse"); $routes->post("getChatResponse", "ChatBotController::getChatResponse");
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile"); $routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
$routes->get("relationshipList", "EmployeeRestController::relationshipList"); $routes->get("relationshipList", "EmployeeRestController::relationshipList");
$routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence");
$routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence"); $routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence");
$routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); $routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence");

View File

@ -147,16 +147,27 @@ class ChatBotController extends AdminController
$text = $this->request->getVar('text'); $text = $this->request->getVar('text');
$value = $this->request->getVar('value'); $value = $this->request->getVar('value');
$Data = $this->ChatBotModel->where('options', $text)->where('is_active', 1 )->first(); $Data = $this->ChatBotModel->where('options', $text)->where('is_active', 1 )->first();
if($Data){ if($Data){
if($Data['options'] == 'Please Enter Your Mobile Number To View Your Policies') if($Data['options'] == 'Please Enter Your Mobile Number To View Your Policies')
{ {
$result = $this->getAllPolicyByMobileNumber($value,'text'); $result = $this->getAllPolicyByMobileNumber($value,'text');
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200); return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}else if($Data['options'] == 'Please Enter Your Mobile Number To Raise Claim'){ }else if($Data['options'] == 'Please Enter Your Mobile Number To Raise Claim'){
$result = $this->getAllPolicyByMobileNumber($value,'options'); $result = $this->getAllPolicyByMobileNumber($value,'options');
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200); return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}else if( $Data['options'] == 'Enter Your Claim Number'){
$result = $this->getTicket($value,$emp_code,$client_id);
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
} }
}else{ }else{
@ -192,6 +203,7 @@ class ChatBotController extends AdminController
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200); return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
}else{ }else{
$result = $this->sendDefaultMessage(); $result = $this->sendDefaultMessage();
@ -396,6 +408,40 @@ class ChatBotController extends AdminController
} }
} }
public function getTicket($value, $emp_code, $client_id)
{
// Construct the URL with query parameters
$url = 'https://venbait.in/nhance/helpdesk/dev/api/tickets/show/' . $value;
$token = 'uncp8FvG310bEyYdV9MmStlo7KDRZ65fLWTeXCI2JzwPrNHjBqQhUiAgxsaO';
$headers = [
'Token: ' . $token,
];
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute cURL request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
return ['status' => 'failed', 'response' => $error];
} else {
// Close cURL session
curl_close($ch);
return ['status' => 'success', 'response' => $response];
}
}

View File

@ -1411,10 +1411,7 @@ class EmployeeRestController extends AdminController
} }
} }
public function getGTLIPolicy($empData,$emp_code,$client_id,$client_branch_id)
{
}
public function FloterConvertion($array){ public function FloterConvertion($array){
@ -1948,7 +1945,7 @@ class EmployeeRestController extends AdminController
$client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId; $client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
$emp_code = $this->request->getVar('emp_code') ?? $empCode; $emp_code = $this->request->getVar('emp_code') ?? $empCode;
$default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy $default_si = $this->request->getVar('si') ?? $default_si;// si amt which choosed in add on policy
$client_branch_id = $this->request->getVar('client_branch_id') ?? $client_branch_id;
// dd($client_policy_id); // dd($client_policy_id);
@ -2219,7 +2216,6 @@ class EmployeeRestController extends AdminController
{ {
if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; } if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; }
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name') $ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name')
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left') ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
@ -2227,9 +2223,10 @@ class EmployeeRestController extends AdminController
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
->where('client_policy.is_active', 1 ) ->where('client_policy.is_active', 1 )
->where('client_policy.policy_status', $policy_status) ->where('client_policy.policy_status', $policy_status)
->where('client_policy.enrolment_visibility', 1 )
->orderby('client_policy.id' , 'ASC') ->orderby('client_policy.id' , 'ASC')
->findAll(); ->findAll();
// dd($ClientPolicyData);
// Retrieve employee and dependents data by passing the employee code // Retrieve employee and dependents data by passing the employee code
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) $employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
->where('client_id',$this->request->getGet('client_id')) ->where('client_id',$this->request->getGet('client_id'))
@ -2278,9 +2275,10 @@ class EmployeeRestController extends AdminController
if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else
if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; } if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; }
if($ClientPolicyValue['policy_type_id'] == 1){ $data['floter_text_heading'] = 'Sum Insured'; } if($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 6 || $ClientPolicyValue['policy_type_id'] == 7)
else
{ {
$data['floter_text_heading'] = 'Sum Insured';
}else{
if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; } if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; }
} }

View File

@ -88,7 +88,6 @@ class PolicyTransactionController extends BaseController
'generated' => 'Generated', 'generated' => 'Generated',
'sent' => 'Sent', 'sent' => 'Sent',
'payment_received' => 'Payment Received', 'payment_received' => 'Payment Received',
]; ];
} }
@ -147,6 +146,7 @@ class PolicyTransactionController extends BaseController
clients.client_name, clients.client_name,
client_branch.branch_name AS client_branch_name, client_branch.branch_name AS client_branch_name,
insurers.name AS insurer_name, insurers.name AS insurer_name,
insurers.short_name AS insurer_short_name,
policy_type.policy_type, policy_type.policy_type,
pt_co_share_details.agreed_amt AS amount, pt_co_share_details.agreed_amt AS amount,
pt_co_share_details.bp_amt AS bp, pt_co_share_details.bp_amt AS bp,
@ -155,7 +155,7 @@ class PolicyTransactionController extends BaseController
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left') ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left') ->join('clients', 'clients.id = policy_transaction.client_id', 'left')
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left') ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left') ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left') ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
@ -321,7 +321,6 @@ class PolicyTransactionController extends BaseController
return $this->respondError("Failed to update policy transaction"); return $this->respondError("Failed to update policy transaction");
} }
private function insertOrUpdateCoShareDetails($data, $pt_id) private function insertOrUpdateCoShareDetails($data, $pt_id)
{ {
// Prepare data for insertion and updating // Prepare data for insertion and updating
@ -671,12 +670,14 @@ class PolicyTransactionController extends BaseController
clients.short_name as client_short_name, clients.short_name as client_short_name,
clients.client_code, clients.client_code,
client_branch.branch_name as client_branch_name, client_branch.branch_name as client_branch_name,
insurers.name as insurer_name, insurers.name AS insurer_name,
insurers.short_name AS insurer_short_name,
policy_type.policy_type policy_type.policy_type
') ')
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'policy_transaction.client_id = clients.id', 'left') ->join('clients', 'policy_transaction.client_id = clients.id', 'left')
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left') ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
->join('insurers', 'policy_transaction.insurer_id = insurers.id','left') ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id','left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left') ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
@ -696,7 +697,6 @@ class PolicyTransactionController extends BaseController
$this->loadLayout('policy_transaction_endorsement_list', $data); $this->loadLayout('policy_transaction_endorsement_list', $data);
} }
public function createEndorsementPolicy() public function createEndorsementPolicy()
{ {
$id = $this->request->getPost('id'); $id = $this->request->getPost('id');
@ -712,7 +712,7 @@ class PolicyTransactionController extends BaseController
private function preparePolicyTransactionData() private function preparePolicyTransactionData()
{ {
$data = $this->request->getPost(); $data = $this->request->getPost();
// print_r($data); // print_r($data); die;
$data_received_date = (string)$this->request->getPost('data_received_date'); $data_received_date = (string)$this->request->getPost('data_received_date');
$closure_date = (string)$this->request->getPost('closure_date'); $closure_date = (string)$this->request->getPost('closure_date');
@ -730,11 +730,57 @@ class PolicyTransactionController extends BaseController
$issue_type = $this->policyTransactionModel $issue_type = $this->policyTransactionModel
->where('action_type', 'inception') ->where('action_type', 'inception')
->where('client_id', $this->request->getPost('client_id')) ->where('client_id', $this->request->getPost('client_id'))
->where('client_branch_id', $this->request->getPost('client_branch_id')) ->where('client_policy_id', $this->request->getPost('client_policy_id'))
->first(); ->first();
$data['tsi'] = generate_tsi_code($issue_type['issue_type'] ?? 1); $data['tsi'] = generate_tsi_code($issue_type['issue_type'] ?? 1);
// print_r($data); die; $client_branch_id = $data['client_branch_id'];
if($data['client_branch_id'] == ""){
$client_branch_id = $issue_type['client_branch_id'];
}
if(!$data['id']){
$data += [
'issuer' => $issue_type['issuer'] ?? null,
'client_type' => $data['client_type'] ?? $issue_type['client_type'] ?? null,
'policy_type_id' => $issue_type['policy_type_id'] ?? null,
'policy_type_id' => $issue_type['policy_type_id'] ?? null,
'issue_type' => $issue_type['issue_type'] ?? null,
'source_client_policy_id' => $issue_type['source_client_policy_id'] ?? null,
'cd_ac_no' => $issue_type['issue_type'] ?? null,
'policy_issue_date' => $issue_type['policy_issue_date'] ?? null,
'policy_start_date' => $issue_type['policy_start_date'] ?? null,
'policy_end_date' => $issue_type['policy_end_date'] ?? null,
'revenue_type' => $issue_type['revenue_type'] ?? null,
'co_share' => $issue_type['co_share'] ?? 0,
'bro_payable_by' => $issue_type['bro_payable_by'] ?? 0,
'installment' => $issue_type['installment'] ?? null,
'installment_data' => $issue_type['installment_data'] ?? null,
'location' => $issue_type['location'] ?? null,
'links' => $issue_type['links'] ??null,
'stage' => $issue_type['stage'] ?? null,
'etat' => $issue_type['etat'] ?? null,
'etat_band' => $issue_type['etat_band'] ?? null,
'edate' => $issue_type['edate'] ?? null,
'renewal_date' => $issue_type['renewal_date'] ?? null,
'rollover_date' => $issue_type['rollover_date'] ?? null,
'policy_holder_name' => $issue_type['policy_holder_name'] ?? null,
'same_as_proposer' => $issue_type['same_as_proposer'] ?? 1,
'ref' => $issue_type['ref'] ?? null,
'spl' => $issue_type['spl'] ?? null,
'fund_received' => $issue_type['fund_received'] ?? null,
'listed_insurers' => $issue_type['listed_insurers'] ?? null,
'ppteam' => $issue_type['ppteam'] ?? null,
'sales_generated_by' => $issue_type['sales_generated_by'] ?? null,
'serviced_by' => $issue_type['serviced_by'] ?? null
];
$data['client_branch_id'] = $client_branch_id;
}
// print_r($issue_type);
// print_r($data);
// die;
return $data; return $data;
} }
@ -744,11 +790,11 @@ class PolicyTransactionController extends BaseController
$insert = $this->policyTransactionModel->insert($data); $insert = $this->policyTransactionModel->insert($data);
if ($insert) { if ($insert) {
$this->insertTransactionStatus($insert, $data['status'], 1); $this->insertTransactionStatus($insert, $data['status'], 1);
$this->handleCompletedStatus($data, $insert); $this->handleCompletedStatus($data, $insert);
$this->insertOrUpdateCoShareDetails($data, $insert); $this->insertOrUpdateCoShareDetails($data, $insert);
return $this->respond(['status' => true, 'message' => 'Endorsement transaction created successfully'], 200); return $this->respond(['status' => true, 'message' => 'Endorsement transaction created successfully'], 200);
} }
@ -799,7 +845,6 @@ class PolicyTransactionController extends BaseController
} }
} }
public function getEndorsementDataForEdit($id) public function getEndorsementDataForEdit($id)
{ {
$data = $this->policyTransactionModel $data = $this->policyTransactionModel
@ -908,6 +953,7 @@ class PolicyTransactionController extends BaseController
->join('policy_transaction', 'policy_transaction.id = pt_co_share_details.pt_id') ->join('policy_transaction', 'policy_transaction.id = pt_co_share_details.pt_id')
->where('policy_transaction.client_id', $client_id) ->where('policy_transaction.client_id', $client_id)
->where('policy_transaction.client_policy_id', $client_policy_id) ->where('policy_transaction.client_policy_id', $client_policy_id)
->where('policy_transaction.action_type', 'inception')
->findAll(); ->findAll();
if ($totalCount) { if ($totalCount) {

View File

@ -284,13 +284,15 @@
<thead> <thead>
<tr> <tr>
<th>Premium Details</th> <th>Premium Details</th>
<!-- Add additional header columns if needed for insurers -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr style="display: none;"> <tr>
<td>Insurer</td> <td>Insurer</td>
<!-- Columns for dynamic insurers will be added here -->
</tr> </tr>
<tr id="is_leader_tr" style="display: none;"> <tr>
<td>Is Leader?</td> <td>Is Leader?</td>
</tr> </tr>
<tr id="co_share_per_tr" style="display: none;"> <tr id="co_share_per_tr" style="display: none;">
@ -630,6 +632,7 @@ $("#endorsement_form_id").submit(function(event) {
if (res.status == true) { if (res.status == true) {
toastr.success(res.message, 'Success'); toastr.success(res.message, 'Success');
$('#policy_tranction_primarykey').val(res.pt_id); $('#policy_tranction_primarykey').val(res.pt_id);
window.location.reload(true);
} else { } else {
toastr.error(res.message, 'Error'); toastr.error(res.message, 'Error');
} }
@ -845,7 +848,7 @@ function addInsurerColumn() {
case 1: // Is Leader? case 1: // Is Leader?
newCell = `<td> newCell = `<td>
<label class="switch" style="position: relative; top: 5px; left: 35px;"> <label class="switch" style="position: relative; top: 5px; left: 35px;">
<input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="checkbox" name="co_share_type[]"> <input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="checkbox" name="co_share_type[]" disabled>
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
</label> </label>
<label for="inception_type" style="position: relative; top: 5px; left: 40px;">Leader Yes</label> <label for="inception_type" style="position: relative; top: 5px; left: 40px;">Leader Yes</label>
@ -860,7 +863,7 @@ function addInsurerColumn() {
case 4: // TP / Ter Premium case 4: // TP / Ter Premium
newCell = `<td><input type="text" id="tp_ter_premium_${insurerCount}" name="tp_ter_premium[]" oninput="amountCalculation('${insurerCount}')"></td>`; newCell = `<td><input type="text" id="tp_ter_premium_${insurerCount}" name="tp_ter_premium[]" oninput="amountCalculation('${insurerCount}')"></td>`;
break; break;
case 5: // co Premium case 5: // Co Premium
newCell = `<td><input type="text" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')"></td>`; newCell = `<td><input type="text" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')"></td>`;
break; break;
case 6: // CGST case 6: // CGST
@ -873,7 +876,7 @@ function addInsurerColumn() {
newCell = `<td><input type="text" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')"></td>`; newCell = `<td><input type="text" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')"></td>`;
break; break;
case 9: // GST Amount case 9: // GST Amount
newCell = `<td><input type="text" class="readonly-color" id="gst_amount_${insurerCount}" name="gst_amount[]" oninput="amountCalculation('${insurerCount}')" readonly></td>`; newCell = `<td><input type="text" class="readonly-color" id="gst_amount_${insurerCount}" name="gst_amount[]" readonly></td>`;
break; break;
case 10: // Stamp Duty case 10: // Stamp Duty
newCell = `<td><input type="text" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')"></td>`; newCell = `<td><input type="text" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')"></td>`;
@ -891,66 +894,65 @@ function addInsurerColumn() {
newCell = `<td><input type="text" name="agreed_amount[]" onkeypress="return onlyNumbers(event)"></td>`; newCell = `<td><input type="text" name="agreed_amount[]" onkeypress="return onlyNumbers(event)"></td>`;
break; break;
case 15: // Standard BP % case 15: // Standard BP %
newCell = `<td><input type="text" class="readonly-color" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`; newCell = `<td><input type="text" class="readonly-color" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
break; break;
case 16: // Standard TP % case 16: // Standard TP %
newCell = `<td class="std_tp_td"><input type="text" class="readonly-color" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly></td>`; newCell = `<td class="std_tp_td"><input type="text" class="readonly-color" name="standard_tp[]" readonly></td>`;
newCell += `<td class="std_ter_td" style="dispaly: none;"><input type="text" class="readonly-color" name="standard_tep[]" onkeypress="return onlyNumbers(event)" readonly></td>`; newCell += `<td class="std_ter_td" style="display: none;"><input type="text" class="readonly-color" name="standard_tep[]" readonly></td>`;
break; break;
case 17: // id case 17: // id
newCell = `<td><input type="hidden" name="co_share_id[]"></td>`; newCell = `<td><input type="hidden" name="co_share_id[]"></td>`;
break; break;
} }
// Append new cell to the current row
$(this).append(newCell); $(this).append(newCell);
$('#follow_insurer_id_' + insurerCount).select2() // Initialize select2 for newly added insurer select dropdown
$('#follow_insurer_id_' + insurerCount).select2();
var selectedOption = $('#policy_type_id').find('option:selected'); // Get selected policy type data
const selectedOption = $('#policy_type_id').find('option:selected');
const bap = selectedOption.data('bap');
var ebp = selectedOption.data('ebp'); // Update column headers and visibility based on policy type
var etp = selectedOption.data('etp'); if (bap === 'Fire' || bap === 'Marine Cargo' || bap === 'Marine Hull') {
var etep = selectedOption.data('etep'); $('#tp_premium_td').text('Ter Premium');
var iep = selectedOption.data('iep'); $('#agree_tp_td').text('Agreed Ter %');
var itp = selectedOption.data('itp'); $('#std_head').text('Standard Ter %');
var itep = selectedOption.data('itep'); $('.std_ter_td').show();
var bap = selectedOption.data('bap');
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
$('#tp_premium_td').text('Ter Premium')
$('#agree_tp_td').text('Agreed Ter %')
$('#std_head').text('Standard Ter %')
$('.std_ter_td').show()
$('.std_tp_td').hide(); $('.std_tp_td').hide();
}else{ } else {
$('#tp_premium_td').text('TP Premium') $('#tp_premium_td').text('TP Premium');
$('#agree_tp_td').text('Agreed TP %') $('#agree_tp_td').text('Agreed TP %');
$('#std_head').text('Standard TP %') $('#std_head').text('Standard TP %');
$('.std_ter_td').hide() $('.std_ter_td').hide();
$('.std_tp_td').show() $('.std_tp_td').show();
} }
if(bap == 'Motor'){ // Hide TP premium row for Motor policy type
if (bap === 'Motor') {
$('#tp_premium_tr').hide(); $('#tp_premium_tr').hide();
}else{ } else {
$('#tp_premium_tr').show(); $('#tp_premium_tr').show();
} }
$('[name="standard_bp[]"]').val(ebp); // Set standard values
$('[name="standard_tp[]"]').val(etp); $('#standard_bp_' + insurerCount).val(selectedOption.data('ebp'));
$('[name="standard_tep[]"]').val(etep); // $('[name="standard_bp[]"]').val(selectedOption.data('ebp'));
$('[name="standard_tp[]"]').val(selectedOption.data('etp'));
$('[name="standard_tep[]"]').val(selectedOption.data('etep'));
if(insurerCount > 1){ // Set 'follow_insurer' to required if more than 1 column exists
if (insurerCount > 1) {
$('.follow_insurer').prop('required', true); $('.follow_insurer').prop('required', true);
}else{ } else {
$('.follow_insurer').prop('required', false); $('.follow_insurer').prop('required', false);
} }
}); });
// Add click event for delete button // Add click event for delete button
$('.delete-insurer').off('click').on('click', function() { $('.delete-insurer').off('click').on('click', function() {
const index = $(this).closest('th').index(); const index = $(this).closest('th').index();
@ -994,16 +996,18 @@ function removeAllColumnsExceptFirst(tableId) {
function populateTable(dataArray, status = false) { function populateTable(dataArray, status = false) {
dataArray.forEach((data, index) => { dataArray.forEach((data, index) => {
// Add a new insurer column for each entry in the data array // Add a new insurer column for each entry in the data array
addInsurerColumn(); // This will add a new column dynamically addInsurerColumn(); // Assuming this function adds a new column dynamically
// Populate the fields with the provided data // Populate the fields with the provided data
$('#insurerTable tbody tr').each(function(rowIndex, row) { $('#insurerTable tbody tr').each(function(rowIndex, row) {
const cell = $(row).find('td').eq(insurerCount); // Get the newly added column by `insurerCount` const cell = $(row).find('td').eq(insurerCount); // Ensure insurerCount is correctly set or incremented
// Split insurer id and branch id properly
let insurer = data.insurer_branch_id + '-' + data.insurer_id;
let insurer = data.insurer_branch_id + '-' + data.insurer_id
switch (rowIndex) { switch (rowIndex) {
case 0: // Insurer selection case 0: // Insurer selection
cell.find('select').val(insurer).change(); cell.find('select').val(insurer).prop('disabled', true).select2();
break; break;
case 1: // Is Leader? case 1: // Is Leader?
cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1'); cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1');
@ -1058,11 +1062,12 @@ function populateTable(dataArray, status = false) {
} }
break; break;
case 17: // id case 17: // id
cell.find('input').val(data.id); cell.find('input').val(status ? data.id : '');
break; break;
} }
}); });
}); });
} }
</script> </script>

View File

@ -68,6 +68,7 @@ table.dataTable thead th {
<th>Issuer</th> <th>Issuer</th>
<th>Client</th> <th>Client</th>
<th>Branch</th> <th>Branch</th>
<th>Insurer</th>
<th>Policy</th> <th>Policy</th>
<th>Endorsement Type</th> <th>Endorsement Type</th>
<th>Endorsement No</th> <th>Endorsement No</th>
@ -83,11 +84,12 @@ table.dataTable thead th {
<?php foreach($endorsement_data_list as $row){ ?> <?php foreach($endorsement_data_list as $row){ ?>
<tr> <tr>
<td><input type="checkbox" class="row-select" data-id="<?= $row['id']; ?>"></td> <td><input type="checkbox" class="row-select" data-id="<?= $row['id']; ?>"></td>
<td><?php $issuer[$row['issuer']] ?? ''; ?></td> <td><?php echo $issuer[$row['issuer']] ?? ''; ?></td>
<td><?php echo $row['client_short_name']; ?></td> <td><?php echo $row['client_short_name']; ?></td>
<td><?php echo $row['client_branch_name']; ?></td> <td><?php echo $row['client_branch_name']; ?></td>
<td><?php echo $row['insurer_short_name']; ?></td>
<td><?php echo $row['policy_type']; ?></td> <td><?php echo $row['policy_type']; ?></td>
<td><?php echo $row['action_type']; ?></td> <td><?php echo $action_type[$row['action_type']]; ?></td>
<td><?php echo $row['endorsement_no']; ?></td> <td><?php echo $row['endorsement_no']; ?></td>
<td><?php echo date('d-m-Y', strtotime($row['data_received_date'])); ?></td> <td><?php echo date('d-m-Y', strtotime($row['data_received_date'])); ?></td>
<td><?php echo $row['emp_count']; ?></td> <td><?php echo $row['emp_count']; ?></td>

View File

@ -1123,54 +1123,57 @@ $(document).ready(function() {
//edit function //edit function
function getPolicyTransactionDataForEdit(input) { function getPolicyTransactionDataForEdit(input) {
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
$('#inception_form_id')[0].reset(); $('#inception_form_id')[0].reset();
var id = $(input).attr('data-id'); var id = $(input).attr('data-id');
console.log('Selected policy transaction ID:', id);
$.ajax({ $.ajax({
url: '<?= base_url("/policy_tranction/inception/list/") ?>' + id, url: '<?= base_url("/policy_tranction/inception/list/") ?>' + id,
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
success: function(res) { success: function(res) {
console.log('getPolicyTransactionDataForEdit', res); console.log('getPolicyTransactionDataForEdit', res);
if (res.status == true) { if (res.status == true) {
hide_list_show_add() hide_list_show_add();
var page_title = 'Edit Policy' + (res.data.client_short_name || res.data.policy_type || res var page_title = 'Edit Policy' + (res.data.client_short_name || res.data.policy_type || res.data.policy_no ?
.data.policy_no ? ' - ' + [res.data.client_short_name, res.data.policy_type, res ' - ' + [res.data.client_short_name, res.data.policy_type, res.data.policy_no]
.data.policy_no .filter(Boolean).join('-') : '');
].filter(Boolean).join('-') : '');
$('#page_title').text(page_title) $('#page_title').text(page_title);
// Setting values to correct fields
$('#policy_tranction_primarykey').val(res.data.id); $('#policy_tranction_primarykey').val(res.data.id);
$('#client_policy_id').val(res.data.client_policy_id); $('#client_policy_id').val(res.data.client_policy_id);
$('#client_id_for_edit').val(res.data.client_id); $('#client_id_for_edit').val(res.data.client_id);
$('#issuer').val(res.data.issuer); $('#issuer').val(res.data.issuer);
$('#issue_type').val(res.data.issue_type).change(); $('#issue_type').val(res.data.issue_type);
setTimeout(function() {
$('#client_id').val(res.data.client_id).change(); $('#client_id').val(res.data.client_id).change();
$('#client_type').val(res.data.client_type); $('#client_type').val(res.data.client_type);
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change(); $('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
$('#vehicle_no').val(res.data.vehicle_id).change(); $('#vehicle_no').val(res.data.vehicle_id).select2();
}, 1000);
var tpaValue = ''; var tpaValue = '';
if (res.data.master_tpa_branch_id && res.data.master_tpa_id) { if (res.data.master_tpa_branch_id && res.data.master_tpa_id) {
tpaValue = res.data.master_tpa_branch_id + '-' + res.data.master_tpa_id; tpaValue = res.data.master_tpa_branch_id + '-' + res.data.master_tpa_id;
}else if(res.data.tpa_branch_id && res.data.tpa_id){ } else if (res.data.tpa_branch_id && res.data.tpa_id) {
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id; tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
} }
$('#tpa').val(tpaValue).change(); $('#tpa').val(tpaValue).change();
if(res.data.master_policy_type_id){
if (res.data.master_policy_type_id) {
$('#policy_type_id').val(res.data.master_policy_type_id).change(); $('#policy_type_id').val(res.data.master_policy_type_id).change();
}else{ } else {
$('#policy_type_id').val(res.data.policy_type_id).change(); $('#policy_type_id').val(res.data.policy_type_id).change();
} }
@ -1184,7 +1187,7 @@ function getPolicyTransactionDataForEdit(input) {
appendFileTableBody(res.data.pt_files); appendFileTableBody(res.data.pt_files);
if(res.data.pt_co_share_details){ if (res.data.pt_co_share_details) {
populateTable(res.data.pt_co_share_details); populateTable(res.data.pt_co_share_details);
} }
@ -1193,29 +1196,24 @@ function getPolicyTransactionDataForEdit(input) {
} }
if (res.data.pt_co_share_details && res.data.pt_co_share_details.length > 0) { if (res.data.pt_co_share_details && res.data.pt_co_share_details.length > 0) {
$('#tab_content').empty();
$('#tab_content').empty() count = 0;
count = 0
$.each(res.data.pt_co_share_details, function(index, item) { $.each(res.data.pt_co_share_details, function(index, item) {
// appendNewTab(item); // appendNewTab(item); // Uncomment when implementing tab addition logic
}); });
} }
setTimeout(function() { setTimeout(function() {
$('#cd_ac_no').val(res.data.cd_ac_no); $('#cd_ac_no').val(res.data.cd_ac_no);
$('#client_branch_id').val(res.data.client_branch_id).change(); $('#client_branch_id').val(res.data.client_branch_id).select2();
$('#source_client_policy_id').val(res.data.source_client_policy_id).change(); $('#source_client_policy_id').val(res.data.source_client_policy_id).change();
$('#base_policy').val(res.data.base_policy).change(); $('#base_policy').val(res.data.base_policy).change();
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}, 2000);
}, 1000) // Set additional fields
$('#policy_status').val(res.data.status); $('#policy_status').val(res.data.status);
$('#ref').val(res.data.ref); $('#ref').val(res.data.ref);
$('#spl').val(res.data.spl); $('#spl').val(res.data.spl);
@ -1242,8 +1240,7 @@ function getPolicyTransactionDataForEdit(input) {
$('#sales_generated_by').val(res.data.sales_generated_by ?? '').change(); $('#sales_generated_by').val(res.data.sales_generated_by ?? '').change();
$('#serviced_by').val(res.data.serviced_by ?? '').change(); $('#serviced_by').val(res.data.serviced_by ?? '').change();
// Additional form handling logic
// Issuer Type - JBIS or Nhance
if (res.data.issue_type == 2) { if (res.data.issue_type == 2) {
$('#renewal').show(); $('#renewal').show();
$('#source_client_policy_id').attr('required', true); $('#source_client_policy_id').attr('required', true);
@ -1252,106 +1249,95 @@ function getPolicyTransactionDataForEdit(input) {
$('#source_client_policy_id').attr('required', false); $('#source_client_policy_id').attr('required', false);
} }
//For Base Policy // Handle base policy visibility
if (res.data.is_addon == 2 || res.data.is_addon == 3) { if (res.data.is_addon == 2 || res.data.is_addon == 3) {
$('#base_policy_id').show(); $('#base_policy_id').show();
} else { } else {
$('#base_policy_id').hide(); $('#base_policy_id').hide();
} }
//for Co Share Percentage // Handle co-share percentage
if (res.data.co_share == 1) { if (res.data.co_share == 1) {
$('#cop_yes').prop('checked', true); $('#cop_yes').prop('checked', true);
$('#add_more_row').removeClass('d-none'); $('#add_more_row').removeClass('d-none');
$('.payby').removeClass('d-none'); $('.payby').removeClass('d-none');
$('#is_leader_tr').show() $('#is_leader_tr').show();
$('#co_share_per_tr').show() $('#co_share_per_tr').show();
$('#co_premium_tr').show() $('#co_premium_tr').show();
} else { } else {
$('#cop_yes').prop('checked', false); $('#cop_yes').prop('checked', false);
$('#add_more_row').addClass('d-none'); $('#add_more_row').addClass('d-none');
$('.payby').addClass('d-none'); $('.payby').addClass('d-none');
$('#is_leader_tr').hide() $('#is_leader_tr').hide();
$('#co_share_per_tr').hide() $('#co_share_per_tr').hide();
$('#co_premium_tr').hide() $('#co_premium_tr').hide();
} }
//for Same Insured Name // Handle "Same Insured Name"
if (res.data.same_as_proposer == 1) { if (res.data.same_as_proposer == 1) {
$('#same_as_proposer').prop('checked', true); $('#same_as_proposer').prop('checked', true);
$('#dynamic-form-container-for-insured').empty(); $('#dynamic-form-container-for-insured').empty();
$('#family_details').hide(); $('#family_details').hide();
} else { } else {
$('#same_as_proposer').prop('checked', false); $('#same_as_proposer').prop('checked', false);
if(res.data.client_type == 2 && res.data.policy_type_id != 8){ if (res.data.client_type == 2 && res.data.policy_type_id != 8) {
$('#family_details').show(); $('#family_details').show();
$.each(res.data.emp_data, function(index, emp) { $.each(res.data.emp_data, function(index, emp) {
appendInsured(emp) appendInsured(emp);
}); });
} else {
}else{
$('#dynamic-form-container-for-insured').empty(); $('#dynamic-form-container-for-insured').empty();
$('#family_details').hide(); $('#family_details').hide();
} }
} }
// for Brokerage Pay By // Handle brokerage pay by
if (res.data.bro_payable_by == 1) { if (res.data.bro_payable_by == 1) {
$('#bro_payable_by').prop('checked', true); $('#bro_payable_by').prop('checked', true);
} else { } else {
$('#bro_payable_by').prop('checked', false); $('#bro_payable_by').prop('checked', false);
} }
//for Policy Tranction Status // Policy transaction status handling
if(res.data.status == "completed"){ if (res.data.status == "completed") {
$('#sales_row').show();
$('#sales_row').show() $('#policy_no').prop('required', true);
$('#policy_no').prop('required', true) $('#policy_issue_date').prop('required', true);
$('#policy_issue_date').prop('required', true) $('#policy_start_date').prop('required', true);
$('#policy_start_date').prop('required', true) $('#policy_end_date').prop('required', true);
$('#policy_end_date').prop('required', true) $('#tpa').prop('required', true);
$('#tpa').prop('required', true) $('#emp_count').prop('required', true);
$('#emp_count').prop('required', true) $('#dependent_count').prop('required', true);
$('#dependent_count').prop('required', true) $('.follow_insurer').prop('required', true);
$('.follow_insurer').prop('required', true) } else {
$('#sales_row').hide();
}else{ $('#policy_no').prop('required', false);
$('#sales_row').hide() $('#policy_issue_date').prop('required', false);
$('#policy_no').prop('required', false) $('#policy_start_date').prop('required', false);
$('#policy_issue_date').prop('required', false) $('#policy_end_date').prop('required', false);
$('#policy_start_date').prop('required', false) $('#tpa').prop('required', false);
$('#policy_end_date').prop('required', false) $('#emp_count').prop('required', false);
$('#tpa').prop('required', false) $('#dependent_count').prop('required', false);
$('#emp_count').prop('required', false) $('.follow_insurer').prop('required', false);
$('#dependent_count').prop('required', false)
$('.follow_insurer').prop('required', false)
} }
//for Client Type Changes // Client type changes
if(res.data.client_type == 2){ if (res.data.client_type == 2) {
if(policy_type_id == 8){ if (res.data.policy_type_id == 8) {
$('#policyholdernamediv').hide(); $('#policyholdernamediv').hide();
}else{ } else {
$('#policyholdernamediv').show(); $('#policyholdernamediv').show();
} }
$('.branchdiv').hide(); $('.branchdiv').hide();
$('#client_branch_id').prop('required', false); $('#client_branch_id').prop('required', false);
} else { } else {
$('#policyholdernamediv').hide(); $('#policyholdernamediv').hide();
$('.branchdiv').show(); $('.branchdiv').show();
$('#client_branch_id').prop('required', true); $('#client_branch_id').prop('required', true);
} }
} else { } else {
console.log('No data found'); console.log('No data found');
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
$('.loader').fadeOut(); $('.loader').fadeOut();
@ -1715,7 +1701,7 @@ $("#vehicle_form").submit(function(event) {
getClientAndBranchAndPolicy(); getClientAndBranchAndPolicy();
$('#client_type').val(res.owner_type); $('#client_type').val(res.owner_type);
setTimeout(function(){ setTimeout(function(){
appendVehicles(res.vehicles, res.vehicle_id) appendVehicles(res.vehicles, res.vehicle_id);
$('#client_id').val(res.owner_id).change(); $('#client_id').val(res.owner_id).change();
if(res.owner_type == 1){ if(res.owner_type == 1){

View File

@ -130,6 +130,7 @@ table.dataTable tbody td {
<th><div class="column-header">Issuing Type</div></th> <th><div class="column-header">Issuing Type</div></th>
<th><div class="column-header">Client Type</div></th> <th><div class="column-header">Client Type</div></th>
<th><div class="column-header">Client / Branch</div></th> <th><div class="column-header">Client / Branch</div></th>
<th><div class="column-header">Insurer</div></th>
<th><div class="column-header">Policy</div></th> <th><div class="column-header">Policy</div></th>
<th><div class="column-header">Policy No</div></th> <th><div class="column-header">Policy No</div></th>
<th><div class="column-header">Policy Issue Date</div></th> <th><div class="column-header">Policy Issue Date</div></th>
@ -150,7 +151,8 @@ table.dataTable tbody td {
<td><?php echo $issuing_type[$row['issue_type']]; ?></td> <td><?php echo $issuing_type[$row['issue_type']]; ?></td>
<td><?php echo $client_type[$row['client_type']] ?? '-'; ?></td> <td><?php echo $client_type[$row['client_type']] ?? '-'; ?></td>
<td><?php echo $row['client_type'] == 2 ? $row['client_name'] : $row['client_short_name'] . ' - ' . $row['client_branch_name']; ?></td> <td><?php echo $row['client_type'] == 2 ? $row['client_name'] : $row['client_short_name'] . ' - ' . $row['client_branch_name']; ?></td>
<td><?php echo $row['policy_type'] ?? '-'; ?></td> <td><?php echo $row['insurer_short_name']; ?></td>
<td><?php echo $row['policy_type']; ?></td>
<td><?php echo $row['policy_no']; ?></td> <td><?php echo $row['policy_no']; ?></td>
<td><?php echo date('d-m-Y', strtotime($row['policy_issue_date'])); ?></td> <td><?php echo date('d-m-Y', strtotime($row['policy_issue_date'])); ?></td>
<td><?php echo date('d-m-Y', strtotime($row['policy_start_date'])); ?></td> <td><?php echo date('d-m-Y', strtotime($row['policy_start_date'])); ?></td>