Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
cd87339514
@ -1211,7 +1211,8 @@ class LeadsController extends BaseController
|
||||
|
||||
//Construct excel file and save the file to the folder and return file path
|
||||
public function constructExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null)
|
||||
{
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
|
||||
$is_placement = false;
|
||||
|
||||
@ -1229,7 +1230,7 @@ class LeadsController extends BaseController
|
||||
'No of Dependents' => $rfq_data['incept_dept_count'],
|
||||
'Total Lives' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
// 'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
];
|
||||
} else if (in_array( $rfq_data['policy_type_id'], [1, 6, 7])) {
|
||||
@ -1237,7 +1238,7 @@ class LeadsController extends BaseController
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
];
|
||||
}
|
||||
@ -1261,22 +1262,22 @@ class LeadsController extends BaseController
|
||||
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
|
||||
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
'Inception Premium' => $rfq_data['premium_at_inception'],
|
||||
'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'],
|
||||
'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||
'Premium as on ('.date('d-m-Y', strtotime($rfq_data['premium_date'])).')' => formatIndianCurrency($rfq_data['premium_amount']),
|
||||
'Earned Premium' => $rfq_data['earned_premium'],
|
||||
'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'],
|
||||
'Annualised Claims' => $rfq_data['annualised_claims'],
|
||||
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'],
|
||||
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'],
|
||||
'Incurred Claims as on ('.date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])).')' => formatIndianCurrency($rfq_data['incurred_claims']),
|
||||
'Annualised Claims' => formatIndianCurrency($rfq_data['annualised_claims']),
|
||||
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio']." %",
|
||||
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio']." %",
|
||||
];
|
||||
} else if (in_array( $rfq_data['policy_type_id'], [1, 6, 7])) {
|
||||
$lead_data = [
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
'Existing Insurer' => $rfq_data['insurer_name'],
|
||||
'TPA ' => $rfq_data['tpa_name'],
|
||||
|
||||
@ -461,9 +461,10 @@ class PolicyTransactionController extends BaseController
|
||||
$insurer_id = null;
|
||||
}
|
||||
|
||||
if($data['bro_payable_by'] == 1){
|
||||
$cop_amt = isset($data['co_premium'][$index]) && ($data['co_premium'][$index] != "0.00" || !empty($data['co_premium'][$index]) ) ? $data['co_premium'][$index] : ($data['base_premium'][$index] ?? 0);
|
||||
}else{
|
||||
if ($data['bro_payable_by'] == 1) {
|
||||
$cop_amt = isset($data['co_premium'][$index]) && ($data['co_premium'][$index] != "0.00" && !empty($data['co_premium'][$index])) ? $data['co_premium'][$index] : ($data['base_premium'][$index] ?? 0);
|
||||
// print_r($cop_amt);die();
|
||||
} else {
|
||||
$cop_amt = $data['co_premium'][$index] ?? 0;
|
||||
}
|
||||
|
||||
@ -1098,13 +1099,19 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
$data['endorsement_data_list'] = $this->policyTransactionModel->getEndorsementTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
|
||||
$data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
|
||||
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
|
||||
|
||||
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
|
||||
// $data['tpa'] = $this->tpaModel->where('is_active', 1)->findAll();
|
||||
$data['insurer_branch'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
$data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
|
||||
list($policyList, $policyListByClient) = $this->getPolicyForEndorsment();
|
||||
|
||||
$data['endorsementPolicies'] = $policyList;
|
||||
$data['endorsementPolicyListByClient'] = $policyListByClient;
|
||||
|
||||
// dd($data);
|
||||
// print_r($data['endorsementPolicies']);die();
|
||||
|
||||
$this->loadLayout('policy_transaction_endorsement_list', $data);
|
||||
}
|
||||
@ -2821,11 +2828,9 @@ class PolicyTransactionController extends BaseController
|
||||
try {
|
||||
|
||||
$bdsInstallmentData = $this->BdsPlacementModel->getClientInstallmentDetails();
|
||||
|
||||
}catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
|
||||
|
||||
}
|
||||
$this->myLogger->logme("error", "Data for BDS Installment " . json_encode($bdsInstallmentData));
|
||||
// dd($bdsInstallmentData);
|
||||
@ -2905,17 +2910,17 @@ class PolicyTransactionController extends BaseController
|
||||
'message' => $message,
|
||||
'subject' => $subject
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function getMoreInfo() {
|
||||
public function getMoreInfo()
|
||||
{
|
||||
|
||||
$pt_id = $this->request->getPost("pt_id");
|
||||
$data_to_send['bds_data'] = $this->BdsPlacementModel->where("is_active",1)->where("pt_id",$pt_id)->findAll();
|
||||
$data_to_send['bds_data'] = $this->BdsPlacementModel->where("is_active", 1)->where("pt_id", $pt_id)->findAll();
|
||||
|
||||
foreach ($data_to_send['bds_data'] as &$data) {
|
||||
|
||||
@ -2924,23 +2929,23 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
if (!empty($data_to_send)) {
|
||||
|
||||
return $this->respond(['status' => true , "data" => $data_to_send],200);
|
||||
}else {
|
||||
return $this->respond(['status' => true, "data" => $data_to_send], 200);
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => false,"No Data Found For the Policy Transaction"],404);
|
||||
return $this->respond(['status' => false, "No Data Found For the Policy Transaction"], 404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function saveInstallment() {
|
||||
|
||||
public function saveInstallment()
|
||||
{
|
||||
|
||||
$installments = $this->request->getPost('installments');
|
||||
|
||||
|
||||
if (!$installments || !is_array($installments)) {
|
||||
return $this->respond(['status' => false, 'message' => 'No data received'], 400);
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error",json_encode($installments));
|
||||
$this->myLogger->logme("error", json_encode($installments));
|
||||
// die();
|
||||
|
||||
foreach ($installments as &$row) {
|
||||
@ -2957,6 +2962,49 @@ class PolicyTransactionController extends BaseController
|
||||
return $this->respond(['status' => true, 'message' => 'Data saved successfully'], 200);
|
||||
}
|
||||
|
||||
protected function getPolicyForEndorsment()
|
||||
{
|
||||
|
||||
$policyList = [];
|
||||
$policyListByClient = [];
|
||||
|
||||
|
||||
$clients = $this->clientModel
|
||||
->select("*, DATE_FORMAT(dob, '%d-%m-%Y') as dob")
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$clientIds = array_column($clients, 'id');
|
||||
|
||||
$policies = $this->clientPolicyModel
|
||||
->select("
|
||||
client_policy.*,
|
||||
policy_type.policy_type,
|
||||
policy_type.ebp,
|
||||
policy_type.etp,
|
||||
policy_type.iep,
|
||||
policy_type.itp,
|
||||
policy_type.bap,
|
||||
policy_type.allocg,
|
||||
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||
")
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('policy_transaction pt', 'pt.client_policy_id = client_policy.id and pt.action_type = "inception" and pt.is_active = 1 and pt.client_policy_id is not null')
|
||||
->whereIn('client_policy.client_id', $clientIds)
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
foreach ($policies as $policy) {
|
||||
$policyList[$policy['client_branch_id']][] = $policy;
|
||||
$policyListByClient[$policy['client_id']][] = $policy;
|
||||
if (isset($policyCount[$policy['client_id']])) {
|
||||
$policyCount[$policy['client_id']]++;
|
||||
} else {
|
||||
$policyCount[$policy['client_id']] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return [$policyList, $policyListByClient];
|
||||
}
|
||||
}
|
||||
|
||||
@ -2008,4 +2008,30 @@ if (!function_exists('generate_family_floater_key')) {
|
||||
|
||||
return $relation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('formatIndianCurrency')) {
|
||||
function formatIndianCurrency($amount)
|
||||
{
|
||||
$amount = (string) $amount;
|
||||
$decimal = '';
|
||||
|
||||
// Split decimal part if exists
|
||||
if (strpos($amount, '.') !== false) {
|
||||
list($amount, $decimal) = explode('.', $amount);
|
||||
$decimal = '.' . substr($decimal, 0, 2); // Limit to 2 decimal places
|
||||
}
|
||||
|
||||
$lastThree = substr($amount, -3);
|
||||
$rest = substr($amount, 0, -3);
|
||||
|
||||
if ($rest != '') {
|
||||
$rest = preg_replace("/\B(?=(\d{2})+(?!\d))/", ",", $rest);
|
||||
$formatted = $rest . ',' . $lastThree;
|
||||
} else {
|
||||
$formatted = $lastThree;
|
||||
}
|
||||
|
||||
return $formatted . $decimal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,8 +121,8 @@
|
||||
<input type="hidden" name="cd_ac_no" id="cd_ac_no">
|
||||
<input type="hidden" name="cd_ac_pk" id="cd_ac_pk">
|
||||
<input type="hidden" name="ct_type" id="ct_type">
|
||||
<input type="hidden" name="" id="bro_payable_by">
|
||||
<input type="hidden" name="" id="cop_yes">
|
||||
<input type="hidden" name="bro_payable_by" id="bro_payable_by">
|
||||
<input type="hidden" name="cop_yes" id="cop_yes">
|
||||
|
||||
|
||||
<!-- Client Row -->
|
||||
@ -560,7 +560,10 @@ $(document).ready(function(){
|
||||
if(policyListByClient != '') {
|
||||
// console.log(branch_list[client_id]);
|
||||
let data = policyListByClient[client_id];
|
||||
if (data) {
|
||||
appendPolicies(data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@ -445,10 +445,11 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
</script>
|
||||
<script>
|
||||
|
||||
var client_list = ''; // local variable for storing the client branch list
|
||||
var branch_list = ''; // local variable for storing the client branch list
|
||||
var policy_list = ''; // local variable for storing the client policy list
|
||||
var policyListByClient = ''; // local variable for storing the client policy list
|
||||
var client_list = '';
|
||||
var branch_list = '';
|
||||
var policy_list = <?= json_encode($endorsementPolicies) ?>;
|
||||
// console.log("POLICY List",policy_list);
|
||||
var policyListByClient = <?= json_encode($endorsementPolicyListByClient) ?>;
|
||||
var branch_policy = '';
|
||||
var unit_list = '';
|
||||
|
||||
@ -607,8 +608,8 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
if(res.status == true){
|
||||
branch_list = res.branch_data;
|
||||
policy_list = res.policy_data;
|
||||
policyListByClient = res.policyListByClient;
|
||||
// policy_list = res.policy_data;
|
||||
// policyListByClient = res.policyListByClient;
|
||||
client_list = res.client_data;
|
||||
unit_list = res.unit_data;
|
||||
appendClients(res.client_data);
|
||||
@ -674,6 +675,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
function appendPolicies(data)
|
||||
{
|
||||
if (!data) {
|
||||
|
||||
toastr.warning("There are no policies in Inception for the selected client and branch.");
|
||||
}
|
||||
console.log('appendPolicies', data);
|
||||
console.log('appendPolicies', $('#client_policy_id'));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user