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

This commit is contained in:
VENKATESHWARAN 2025-05-14 17:29:04 +05:30
commit 36c0ea6511
9 changed files with 684 additions and 432 deletions

View File

@ -360,6 +360,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
$routes->cli("cli/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->group("inception", ["filter" => "authMVC"], function ($routes) {

View File

@ -1680,7 +1680,7 @@ class MasterController extends AdminController
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
];
$email_id = 'srinivas.saravanan@venbainfotech.com';
$email_id = ['srinivas.saravanan@venbainfotech.com','srinivassaravanan2002@gmail.com'];
$params = ['mail'=>$email_id];
$common = ['mail_type'=>'test_mail_cli'];
// $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com";

View File

@ -32,7 +32,10 @@ use App\Models\InvPaymentDetailsModel;
use App\Models\BatchFileModel;
use App\Models\FileModel;
use App\Models\COShareStmtDetailsModel;
use Kint;
use App\Models\BdsPlacementModel;
use Kint\Kint;
use App\Helpers\MailHelper;
use Exception;
class PolicyTransactionController extends BaseController
{
@ -64,6 +67,7 @@ class PolicyTransactionController extends BaseController
protected $batchFileModel;
protected $filesModel;
protected $coShareStmtDetailsModel;
protected $BdsPlacementModel;
public function __construct()
{
@ -94,6 +98,7 @@ class PolicyTransactionController extends BaseController
$this->batchFileModel = new BatchFileModel();
$this->filesModel = new FileModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->BdsPlacementModel = new BdsPlacementModel();
$this->invoiceStatus = [
'pending' => 'Pending',
'generated' => 'Generated',
@ -182,8 +187,7 @@ class PolicyTransactionController extends BaseController
$issuer,
$status
);
}else{
} else {
$ids = $this->request->getPost('ids');
$ids = array_filter(explode(',', $ids));
@ -2801,4 +2805,105 @@ class PolicyTransactionController extends BaseController
->update();
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
}
public function sendInstallmentRemainderMail()
{
$this->myLogger->logme("error", "Cron Job For Send Installment Remainder Mail Started");
try {
try {
$bdsInstallmentData = $this->BdsPlacementModel->getClientInstallmentDetails();
}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);
if (empty($bdsInstallmentData)) {
$this->myLogger->logme("error", "No Client Installment is Due in the 15th Day");
return false;
}
foreach ($bdsInstallmentData as $installmentData) {
$mailData = $this->PrepareBDSMailData($installmentData);
$to_mail = $mailData['to_mail'];
$message = $mailData['message'];
$subject = $mailData['subject'];
$this->myLogger->logme("error", "Installment Pending for" . $subject);
$common = ['mail_type' => 'installment_amount_due_remainder_mail'];
$res = MailHelper::send_email(['mail' => $to_mail, 'subject' => $subject, 'message' => $message, 'common' => $common]);
$res = json_decode($res);
$this->myLogger->logme('error', 'res: ' . json_encode($res));
if ($res->status == 'success') {
return true;
} else {
return false;
}
}
} catch (Exception $e) {
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
}
}
protected function PrepareBDSMailData($data)
{
try {
$installment_amount = $data['installment_amount'];
$payment_date = date('d-m-Y', strtotime($data['payment_date']));
$client = $data['client_name'];
$branch = $data['branch_name'];
$sales_person_mail = $data['sales_person'];
$heads = $data['heads'];
$admins = $data['admins'];
$buisness_team = $data['buisness_team'];
$policy_no = $data['policy_no'];
$client_short_name = isset($data['short_name']) && $data['short_name'] != null ? $data['short_name'] : $data['client_name'];
$subject = "Installment Amount Due For Client - {$client_short_name} - Policy NO({$policy_no}) is Due On - {$payment_date}";
$message = "Policy Installment for Client - {$client}, Branch - {$branch} is Due on {$payment_date}
with amount of {$installment_amount}.<br>
Policy No : {$policy_no}";
$to_mail = array_merge(
array_column($heads, 'email'),
array_column($admins, 'email'),
array_column($buisness_team, 'email'),
[$sales_person_mail]
);
$to_mail = array_unique($to_mail);
$this->myLogger->logme("error", "Selected To Address : " . json_encode($to_mail));
// dd($to_mail);
return [
'to_mail' => $to_mail,
'message' => $message,
'subject' => $subject
];
} catch (Exception $e) {
$this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine());
}
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BdsPlacementModel extends Model
{
protected $table = 'bds_installment_payment_details';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'pt_id',
'lead_id',
'installment_amount',
'payment_date',
'utr_no',
'created_at',
'created_by',
'updated_at',
'updated_by',
'is_active'
];
public function getClientInstallmentDetails()
{
$builder = $this->db->table("bds_installment_payment_details bipd")
->select("bipd.*, ct.client_name,ct.short_name, cb.branch_name, leads.salse_person_id,cp.policy_no")
->join("policy_transaction pt", "pt.id = bipd.pt_id")
->join("clients ct", "ct.id = pt.client_id")
->join("client_branch cb", "cb.id = pt.client_branch_id")
->join("leads", "leads.id = bipd.lead_id")
->join("client_policy cp","cp.id = pt.client_policy_id")
->where("bipd.is_active", 1)
->where("bipd.payment_date", date('Y-m-d', strtotime('+15 days')));
$data = $builder->get()->getResultArray();
// Loop through to extract sales person details
foreach ($data as &$row) {
$sales_person_ids = json_decode($row['salse_person_id'], true);
$sales_person_id = $sales_person_ids[0] ?? null;
if ($sales_person_id) {
$user = $this->db->table('user_profiles')
->select('email') // or whatever field
->where('id', $sales_person_id)
->get()
->getRowArray();
$row['sales_person'] = $user['email'] ?? 'N/A';
} else {
$row['sales_person'] = 'Not Assigned';
}
$head = $this->db->table('user_profiles')
->select('email') // or whatever field
->where('role', 5)
->where('is_active',1)
->get()
->getResultArray();
$row['heads'] = $head;
$admin = $this->db->table('user_profiles')
->select('email')
->where("is_active",1)
->where("role",1)
->get()
->getResultArray();
$row['admins'] = $admin;
$buisenessTeam = $this->db->table("user_teams ut")
->select("up.email")
->join('user_profiles up','up.id = ut.user_id and up.is_active = 1')
->where("ut.team_id",7)
->where("ut.is_active",1)
->get()
->getResultArray();
$row['buisness_team'] = $buisenessTeam;
}
return $data;
}
}

View File

@ -541,7 +541,7 @@ class TicketMasterModel extends Model
AND th.is_active = 1),
tm.created_at
)) BETWEEN 13 AND 20 THEN "13-20 Days"
ELSE "Above 20 Days"g
ELSE "Above 20 Days"
END AS tat_category',
'COUNT(*) AS count'
])

View File

@ -777,6 +777,7 @@
console.log(response.message, 'SUCCESS');
$('#appendArea_' + dataIncrement).append(response.data);
console.log("Policy Type ID : ",policy_type_id);
if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) {
let newId = 'appendAreaForClaim_' + dataIncrement;

View File

@ -726,6 +726,11 @@ if (isset($selected_lead_type)) {
$('#policy_type_id').val(data.policy_type_id || '').select2();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$(".loss_date").each(function () {
flatpickr(this, {
dateFormat: "d-m-Y",
});
});
}, 1000);
}, 1000);
}, 2000);

View File

@ -1,41 +1,41 @@
<!-- Leads Non EB -->
<style>
.readonly-color {
.readonly-color {
background-color: #e0e0e0;
/* Darker background */
color: #666;
/* Darker text color */
}
}
.readonly-select {
.readonly-select {
pointer-events: none;
background-color: #f0f0f0;
color: #666;
}
}
hr.solid {
hr.solid {
border-top: 3px solid #bbb;
}
}
.select2-hidden-accessible+.select2-container .select2-dropdown {
.select2-hidden-accessible+.select2-container .select2-dropdown {
display: none !important;
}
}
.select2-container .select2-selection--multiple .select2-selection__choice {
.select2-container .select2-selection--multiple .select2-selection__choice {
color: #000000;
}
}
.select2-selection__choice {
.select2-selection__choice {
background-color: #0a8794 !important;
color: white !important;
font-weight: bold;
}
}
.select2-selection__choice__remove {
.select2-selection__choice__remove {
color: white !important;
margin-right: 5px;
}
}
</style>
@ -233,8 +233,8 @@ hr.solid {
<?php
if (isset($policy_type) && count($policy_type)) {
foreach ($policy_type as $value) {
if(in_array($value['allocg'], ["Non-EB", "Marine"])){
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] ."</option>";
if (in_array($value['allocg'], ["Non-EB", "Marine"])) {
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] . "</option>";
}
}
}
@ -260,13 +260,19 @@ hr.solid {
<label for="tpa">TPA <span class="text-danger"></span></label>
<select class="form-control" id="tpa" name="tpa">
<option value="">Select TPA</option>
<?php //if (isset($tpa)) { ?>
<?php //foreach ($tpa as $value) { ?>
<option value="<?php // echo $value['id'] . '-' . $value['tpa_id'] ?>">
<?php // echo $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
<?php //if (isset($tpa)) {
?>
<?php //foreach ($tpa as $value) {
?>
<option value="<?php // echo $value['id'] . '-' . $value['tpa_id']
?>">
<?php // echo $value['tpa_short_name'] . '-' . $value['branch_code']
?>
</option>
<?php //} ?>
<?php //} ?>
<?php //}
?>
<?php //}
?>
</select>
</div> -->
@ -355,8 +361,7 @@ hr.solid {
</div>
<script>
$(document).ready(function(){
$(document).ready(function() {
var today = new Date();
@ -376,9 +381,9 @@ $(document).ready(function(){
});
addFileField(1);
})
})
function getPolicyTypeFields(input) {
function getPolicyTypeFields(input) {
console.log('getPolicyTypeFields', input);
let policy_type_id = $(input).val();
@ -408,14 +413,15 @@ function getPolicyTypeFields(input) {
$('#appendArea').append(response.data);
let lead_type = $('#lead_type').val();
if(lead_type != 1){
// if (lead_type != 1) {
let html = `<hr><div class="form-row"> <div class="form-group col-md-3"><h4> Claim Details </h4></div></div>`
let referenceDiv = document.getElementById('appendAreaForClaim');
referenceDiv.insertAdjacentHTML('beforeend', html);
// alert('hello')
// let html = `<hr><div class="form-row"> <div class="form-group col-md-3"><h4> Claim Details </h4></div></div>`
// let referenceDiv = document.getElementById('appendAreaForClaim');
// referenceDiv.insertAdjacentHTML('beforeend', html);
appendThreeYearsClaims();
}
// appendThreeYearsClaims();
// }
var retro_active_datePicker = flatpickr("#retro_active_date", {
dateFormat: "d/m/Y",
@ -431,6 +437,15 @@ function getPolicyTypeFields(input) {
console.log(response.message, 'WARNING');
}
if (lead_type != 1) {
let html = `<hr><div class="form-row"> <div class="form-group col-md-3"><h4> Claim Details </h4></div></div>`
let referenceDiv = document.getElementById('appendAreaForClaim');
referenceDiv.insertAdjacentHTML('beforeend', html);
appendThreeYearsClaims();
}
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -444,9 +459,9 @@ function getPolicyTypeFields(input) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
}
$("#leads_non_eb_form_id").submit(function(event) {
$("#leads_non_eb_form_id").submit(function(event) {
event.preventDefault();
@ -478,7 +493,7 @@ $("#leads_non_eb_form_id").submit(function(event) {
let customFieldData = {};
$('.custom_fields').find('input, select, textarea').each(function () {
$('.custom_fields').find('input, select, textarea').each(function() {
let key = $(this).attr('name');
let value;
@ -540,14 +555,14 @@ $("#leads_non_eb_form_id").submit(function(event) {
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
});
$('#lead_type').change(function() {
$('#lead_type').change(function() {
let value = $(this).val()
leadTypeBsedHideAndShow(value, true)
})
})
function leadTypeBsedHideAndShow(value, resetValues = false) {
function leadTypeBsedHideAndShow(value, resetValues = false) {
if (value == 1) {
@ -568,7 +583,7 @@ function leadTypeBsedHideAndShow(value, resetValues = false) {
$('#policy_end_date').attr('required', 'required');
$('#policy_start_date').attr('required', 'required');
if(resetValues){
if (resetValues) {
$('#gst').val('');
$('#pan').val('');
@ -606,7 +621,7 @@ function leadTypeBsedHideAndShow(value, resetValues = false) {
$('#policy_start_date').removeAttr('required');
$('#claims').removeAttr('required');
if(resetValues){
if (resetValues) {
$('#gst').val('');
$('#pan').val('');
@ -620,9 +635,9 @@ function leadTypeBsedHideAndShow(value, resetValues = false) {
}
}
}
function getBranchData(input) {
function getBranchData(input) {
var client_branch_id = $(input).val();
@ -685,10 +700,10 @@ function getBranchData(input) {
}
});
}
}
}
// Client Policy Data
function getPolicyData(input) {
// Client Policy Data
function getPolicyData(input) {
var client_policy_id = $(input).val();
console.log('client_policy_id', client_policy_id);
@ -776,11 +791,11 @@ function getPolicyData(input) {
$(`#insurer`).val('').trigger('change');
$(`#tpa`).val('').trigger('change');
}
}
}
var increment = 1;
var increment = 1;
function appendThreeYearsClaims() {
function appendThreeYearsClaims() {
let claimsFields = `
@ -795,6 +810,18 @@ function appendThreeYearsClaims() {
} ?>
</select>
</div>
<div class="form-group col-md-2">
<label for="first_policy_type_${increment}">Policy Type<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_policy_type_${increment}" name="first_policy_type_[]">
</div>
<div class="form-group col-md-2">
<label for="first_date_of_loss_${increment}">Date of Loss<span class="text-danger">*</span></label>
<input type="text" class="form-control loss_date" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]">
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]">
</div>
<div class="form-group col-md-2">
<label for="first_claim_amount_${increment}">Claim Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
@ -803,10 +830,6 @@ function appendThreeYearsClaims() {
<label for="first_claim_amount_${increment}">Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_settled_amount_${increment}" name="first_settled_amount[]">
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]">
</div>
<div class="form-group col-md-2">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]">
@ -828,9 +851,17 @@ function appendThreeYearsClaims() {
// Increment claim index
increment = increment + 1;
}
$(".loss_date").each(function () {
flatpickr(this, {
dateFormat: "d-m-Y",
});
});
function removeClaim(btn) {
}
function removeClaim(btn) {
const container = document.getElementById('appendAreaForClaim');
const rows = container.querySelectorAll('.claim-row');
@ -838,15 +869,17 @@ function removeClaim(btn) {
const row = btn.closest('.claim-row');
row.remove();
}
}
}
function gatherClaimExperienceData() {
function gatherClaimExperienceData() {
let claimData = [];
$(".claim-row").each(function() {
let year = $(this).find("[name='first_year[]']").val();
let policyType = $(this).find("[name='first_policy_type_[]']").val();
let dateOfLoss = $(this).find("[name='first_date_of_loss_[]']").val();
let claimAmount = $(this).find("[name='first_claim_amount[]']").val();
let settledAmount = $(this).find("[name='first_settled_amount[]']").val();
let causeOfLoss = $(this).find("[name='first_cause_of_loss[]']").val();
@ -854,6 +887,8 @@ function gatherClaimExperienceData() {
claimData.push({
"year": year,
"policy_type" : policyType,
'date_of_loss' : dateOfLoss,
"claim_amount": claimAmount,
"settled_amount": settledAmount,
"cause_of_loss": causeOfLoss,
@ -871,6 +906,6 @@ function gatherClaimExperienceData() {
console.log(jsonString);
return jsonString;
}
}
</script>

View File

@ -13,6 +13,21 @@
} ?>
</select>
</div>
<div class="form-group col-md-2">
<label for="first_policy_type_${increment}">Policy Type<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_policy_type_${increment}" name="first_policy_type_[]"
value="<?= htmlspecialchars($value['policy_type']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_date_of_loss_${increment}">Date of Loss<span class="text-danger">*</span></label>
<input type="text" class="form-control loss_date" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]"
value="<?= htmlspecialchars($value['date_of_loss']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]"
value="<?= htmlspecialchars($value['cause_of_loss']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_claim_amount_${increment}">Claim Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]"
@ -23,11 +38,6 @@
<input type="text" class="form-control" id="first_settled_amount_${increment}" name="first_settled_amount[]"
value="<?= htmlspecialchars($value['settled_amount']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]"
value="<?= htmlspecialchars($value['cause_of_loss']) ?>">
</div>
<div class="form-group col-md-2">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]"