FEAT_ADDON_POLICY_POLICY_LIST_FIX_DATE_FORMATE_CHANGE_SESSION_TIMEOUT_FEAT_INSURER_CATAGORY : RV

This commit is contained in:
VENKATESHWARAN 2024-04-08 18:05:07 +05:30
parent 5c4ca76ac3
commit 5d69cc47df
12 changed files with 1017 additions and 712 deletions

View File

@ -16,6 +16,7 @@ $routes->get('/login', 'LoginController::index');///auth/google
$routes->get('/logout', 'LoginController::logout');
$routes->get('/oauth2callback', 'LoginController::receiveGoogleOAuthResponse');
$routes->get('/auth/google', 'LoginController::initiateGoogleOAuth');
$routes->get('/update-policy', 'ClientController::checkPolicyEndDateUpdateClientPolicyStatusExpired');
$routes->group("/user", ["filter" => "authMVC"], function($routes){
@ -209,6 +210,8 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){
$routes->get("download-excel/(:any)", "EmployeeController::downloadSampleExcelFile/$1");
$routes->get("get-emp-endorsement/(:any)", "EmployeeController::getEmpEndoresmentEntry/$1");
$routes->post("import-export", "EmployeeController::importExport");
$routes->get("featch-client-policy-list/(:any)", "ClientController::getClientPolicyList/$1");
});
$routes->cli('cli/processjob', 'JobWorker::processJob');

View File

@ -40,7 +40,8 @@ class Session extends BaseConfig
* The number of SECONDS you want the session to last.
* Setting to 0 (zero) means expire when the browser is closed.
*/
public int $expiration = 7200;
// public int $expiration = 7200;
public int $expiration = 86400; //24 Hours
/**
* --------------------------------------------------------------------------

View File

@ -29,6 +29,8 @@ use App\Models\PolicyGridModel;
use App\Models\PolicyPremium1Model;
use App\Models\PolicyPremium2Model;
use App\Models\EmployeeModel;
use App\Models\EmployeePolicyModel;
@ -57,6 +59,7 @@ class ClientController extends AdminController
protected $policyPremium2Model;
protected $clientDepositModel;
protected $employeeModel;
protected $employeePolicyModel;
public function __construct()
{
@ -83,6 +86,9 @@ class ClientController extends AdminController
$this->policyPremium1Model = new PolicyPremium1Model();
$this->policyPremium2Model = new PolicyPremium2Model();
$this->employeeModel = new EmployeeModel();
$this->employeePolicyModel = new EmployeePolicyModel();
}
@ -103,6 +109,14 @@ class ClientController extends AdminController
}
public function checkPolicyEndDateUpdateClientPolicyStatusExpired(){
$return = $this->clientPolicyModel->updateStatus();
$this->myLogger->logme('error', 'Client Policy Status Update Count: {data}', ['data' => $return['client']]);
$this->myLogger->logme('error', 'Employee Policy Status Update Count: {data}', ['data' => $return['emp']]);
}
public function removeClient($id = null)
{
@ -248,10 +262,21 @@ class ClientController extends AdminController
$editData['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $id)->findAll();
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_policy'] = $this->clientPolicyModel->getClientPolicyByClientId($id);
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
foreach ($clientPoliceData as $key => $value) {
$clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
$clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date));
}
$editData['client_policy'] = $clientPoliceData;
// echo "<pre>";
// print_r($editData); die;
// print_r($clientPoliceData); die;
echo view('layout/header', $headerData);
echo view('client_onboarding', $editData);
@ -577,6 +602,7 @@ class ClientController extends AdminController
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
$data['is_addon'] = $this->request->getPost('is_addon');
$data['base_policy'] = $this->request->getPost('base_policy');
if (!isset($data['is_addon'])) {
$data['is_addon'] = 0;
@ -594,6 +620,11 @@ class ClientController extends AdminController
$insert = $this->clientPolicyModel->insert($data);
if($insert){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
foreach ($clientPoliceData as $key => $value) {
$clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
$clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date));
}
return $this->respond(['status' => true,'code' => 200,'data' => $clientPoliceData, 'method' => 'CERATE'], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
@ -637,6 +668,8 @@ class ClientController extends AdminController
$data['earned_premium_amount'] = $this->request->getPost('earned_premium_amount');
$data['claims_incurred_amount'] = $this->request->getPost('claims_incurred_amount');
$data['is_addon'] = $this->request->getPost('is_addon');
$data['base_policy'] = $this->request->getPost('base_policy');
if (!isset($data['is_addon'])) {
@ -654,6 +687,11 @@ class ClientController extends AdminController
if($insert){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($client_id);
foreach ($clientPoliceData as $key => $value) {
$clientPoliceData[$key]->policy_start_date = date('d-M-Y', strtotime($value->policy_start_date));
$clientPoliceData[$key]->policy_end_date = date('d-M-Y', strtotime($value->policy_end_date));
}
return $this->respond(['status' => true,'code' => 200,'data' => $clientPoliceData, 'method' => 'EDIT'], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
@ -903,8 +941,13 @@ class ClientController extends AdminController
if($id){
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
$insurer_id = $client_policy_data['insurer_id'];
$client_id = $client_policy_data['client_id'];
$polices = $this->policesModel->where(['insurer_id' => $insurer_id, 'is_active' => 1])->findAll();
return $this->respond(['status' => true,'code' => 200,'data' => $client_policy_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
$client_policy_list = $this->clientPolicyModel->select('policies.*')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_id', $client_id)
->findAll();
return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
}
@ -1393,4 +1436,19 @@ class ClientController extends AdminController
}
public function getClientPolicyList($client_id = null){
$record = $this->clientPolicyModel->select('policies.*')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_id', $client_id)
->findAll();
if ($record) {
return $this->respond(['Status' => true,'code' => 200,'data' => $record], 200);
} else {
return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.'], 200);
}
}
}

View File

@ -77,7 +77,7 @@ if (!function_exists('generate_excel')) {
if($totals == 1){
// Call the helper function for Calculate GST, Pro Rata Premium, and Total sums for inception
add_totals_row($spreadsheet, $data);
add_totals_row($spreadsheet, $data, $headers);
}else if($totals == 2){
add_totals_for_deletion($spreadsheet, $data);
}
@ -268,25 +268,39 @@ if (! function_exists('transform_objects_to_array_for_deletion')) {
if (!function_exists('add_totals_row')) {
function add_totals_row(Spreadsheet $spreadsheet, array $data)
{
function add_totals_row(Spreadsheet $spreadsheet, array $data, array $headers)
{
//find the index value
$rata = array_search('PRO RATA PREMIUM', $headers);
$gst = array_search('GST', $headers);
$total = array_search('TOTAL', $headers);
// Calculate GST, Pro Rata Premium, and Total sums
$gstSum = 0;
$proRataPremiumSum = 0;
$totalSum = 0;
foreach ($data as $row) {
$gstSum += $row[18];
$proRataPremiumSum += $row[19];
$totalSum += $row[20];
$gstSum += $row[$gst];
$proRataPremiumSum += $row[$rata];
$totalSum += $row[$total];
}
$cellValue = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
$prev_index = $rata - 1;
$cellValueTotal = $cellValue[$prev_index];
$cellValueRata = $cellValue[$rata];
$cellValueGST = $cellValue[$gst];
$cellValueTotalSum = $cellValue[$total];
// Add a new row with sums
$lastRow = count($data) + 1; // To get the last row number
$spreadsheet->getActiveSheet()->setCellValue('R' . ($lastRow + 1), 'TOTALS');
$spreadsheet->getActiveSheet()->setCellValue('S' . ($lastRow + 1), $gstSum);
$spreadsheet->getActiveSheet()->setCellValue('T' . ($lastRow + 1), $proRataPremiumSum);
$spreadsheet->getActiveSheet()->setCellValue('U' . ($lastRow + 1), $totalSum);
$spreadsheet->getActiveSheet()->setCellValue($cellValueTotal . ($lastRow + 1), 'TOTALS');
$spreadsheet->getActiveSheet()->setCellValue($cellValueRata . ($lastRow + 1), $proRataPremiumSum);
$spreadsheet->getActiveSheet()->setCellValue($cellValueGST . ($lastRow + 1), $gstSum);
$spreadsheet->getActiveSheet()->setCellValue($cellValueTotalSum . ($lastRow + 1), $totalSum);
}
}

View File

@ -34,6 +34,7 @@ class ClientPolicyModel extends Model
"policy_terms",
"open_for_enrollment",
"is_addon",
"base_policy",
"created_by",
"updated_by",
"Is_active",
@ -249,4 +250,21 @@ public function getDepositlistsummary($id)
->getResult();
}
public function updateStatus(){
// Update client_policy table
$client = $this->db->query("UPDATE client_policy SET policy_status = 0 WHERE policy_end_date < CURDATE()");
$client_count = $this->db->affectedRows();
// Update employee_polices table
$employee = $this->db->query("UPDATE employee_polices SET status = 'expired' WHERE policy_end_date < CURDATE()");
$emp_count = $this->db->affectedRows();
return ['client'=>$client_count, 'emp' => $emp_count];
}
}

View File

@ -11,6 +11,7 @@ class InsurerModel extends Model
protected $allowedFields = [
"id",
"type",
"category",
"name",
"short_name",
"created_by",

View File

@ -75,12 +75,21 @@ $(document).ready(function() {
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'Client_Deposit',
title: 'Client Deposit Details - ' + ' <?php echo $clientName[0]['client_name'];?>',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
}],
},
{
extend: 'pdf',
text: 'PDF',
title: 'Client Deposit Details - ' + ' <?php echo $clientName[0]['client_name'];?>',
exportOptions: {
columns: ':not(:last-child)'
},
}
],
language: {

View File

@ -28,6 +28,10 @@ body {
}
.navtab-bg .nav-link {
margin: 0 5px 10px!important;
}
</style>
<div class="row" id="client_add">

File diff suppressed because it is too large Load Diff

View File

@ -2,38 +2,56 @@
<div class="row">
<div class="col-12">
<div class="card-body">
<form role="form" class="parsley-examples" method="post" id="insurer_general_form" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="insurer_General_PrimaryKey" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>"/>
<form role="form" class="parsley-examples" method="post" id="insurer_general_form"
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="insurer_General_PrimaryKey"
value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>" />
<input type="hidden" name="insurer_id" id="insurer_id" />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label for="entity_type_id">Insurer Type <span class="text-danger">*</span></label>
<select class="form-control" id="type" name="type" required>
<option value="">Select Type</option>
<?php foreach ($types as $type): ?>
<option value="<?= $type->id; ?>" <?= isset($insurer['type']) && $insurer['type'] == $type->id ? 'selected' : ''; ?>>
<?= $type->name; ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="insurer_name">Insurer Name<span
class="text-danger">*</span></label>
<label for="insurer_name">Insurer Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="insurer_name"
placeholder="Enter Insurer Name" value="<?= isset($insurer['name']) ? $insurer['name'] : '' ?>" name="name" required>
</div>
<div class="form-group col-md-4">
<label for="short_name">Insurer Short Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="short_name"
placeholder="Enter Short Name" value="<?= isset($insurer['short_name']) ? $insurer['short_name'] : '' ?>" name="short_name" required>
placeholder="Enter Insurer Name"
value="<?= isset($insurer['name']) ? $insurer['name'] : '' ?>" name="name" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-2">
<label for="short_name">Insurer Short Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="short_name" placeholder="Enter Short Name"
value="<?= isset($insurer['short_name']) ? $insurer['short_name'] : '' ?>"
name="short_name" required minlength="3" maxlength="8">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="html">Insurer Type</label><br>
<div style="margin-top: 10px;">
<input type="radio" id="html" name="type" value="pvt" <?= isset($insurer['type']) && $insurer['type'] == 'pvt' ? 'checked' : '' ?>>
<label for="html">PVT</label>&nbsp;
<input type="radio" id="css" name="type" value="psu" <?= isset($insurer['type']) && $insurer['type'] == 'psu' ? 'checked' : '' ?>>
<label for="css">PSU</label>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4" style="position: relative;right: 0px;">
<label for="html">Insurer Category</label><br>
<div style="margin-top: 10px;">
<input type="radio" id="html" name="category" value="life" <?= isset($insurer['category']) && $insurer['category'] == 'life' ? 'checked' : '' ?>>
<label for="html">Life</label>&nbsp;
<input type="radio" id="css" name="category" value="general" <?= isset($insurer['category']) && $insurer['category'] == 'general' ? 'checked' : '' ?>>
<label for="css" style="position: absolute;left: 70px;">General(Non Life)</label>
</div>
</div>
</div>
<hr>
</div>
<div class="form-group text-right m-b-0">
@ -50,30 +68,29 @@
<!-- end -->
<script>
$(document).ready(function () {
$(document).ready(function() {
$("#insurer_general_form").submit(function(events) {
events.preventDefault();
events.preventDefault();
// var isValid = validateForm();
var isValid = true;
jQuery.each(events.target, function(index, event) {
if (event.validity.valid) {
jQuery.each(events.target, function(index, event) {
if (event.validity.valid) {
}else{
isValid = false;
}
});
} else {
isValid = false;
}
});
var PrimaryKey = $('#insurer_General_PrimaryKey').val();
var PrimaryKey = $('#insurer_General_PrimaryKey').val();
var form_action = '';
if (isValid) {
if(PrimaryKey === ''){
if (PrimaryKey === '') {
form_action = '<?= base_url("master/insurer/createpost"); ?>';
}else{
} else {
form_action = '<?= base_url("master/insurer/edit"); ?>';
}
@ -82,7 +99,7 @@ $(document).ready(function () {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
data: formData,
url: form_action,
@ -114,49 +131,48 @@ $(document).ready(function () {
// });
},
error: function (xhr, status, error) {
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
});
}
});
function validateForm() {
var isValid = true;
// Perform validation for each field
$('#insurer_general_form input, #insurer_general_form select').each(function() {
// Check for empty text inputs and selects
if ($(this).is('input[type="text"]') || $(this).is('select')) {
if ($.trim($(this).val()) == '') {
alert('Please fill in all fields');
isValid = false;
return false; // Exit the loop early
}
}
// Check for file inputs (assuming image files)
if ($(this).is('input[type="file"]')) {
var fileInput = $(this)[0];
if (fileInput.files.length === 0) {
alert('Please select an image file');
isValid = false;
return false; // Exit the loop early
}
}
});
function validateForm() {
var isValid = true;
return isValid;
}
// Perform validation for each field
$('#insurer_general_form input, #insurer_general_form select').each(function() {
// Check for empty text inputs and selects
if ($(this).is('input[type="text"]') || $(this).is('select')) {
if ($.trim($(this).val()) == '') {
alert('Please fill in all fields');
isValid = false;
return false; // Exit the loop early
}
}
// Check for file inputs (assuming image files)
if ($(this).is('input[type="file"]')) {
var fileInput = $(this)[0];
if (fileInput.files.length === 0) {
alert('Please select an image file');
isValid = false;
return false; // Exit the loop early
}
}
});
return isValid;
}
});
</script>

View File

@ -111,11 +111,10 @@
<tbody>
<?php foreach($depositdata as $row) { ?>
<tr id="<?php echo $row->id;?>">
<td class=""><?php echo date('d-m-y h:i A', strtotime($row->created_at)); ?></td>
<td><?php echo date('d-M-Y h:i A', strtotime($row->created_at)); ?></td>
<td><?php echo $row->username; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?>
</td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?></td>
<td><?php echo ($row->transaction_type == 'Credit') ? $row->amount : ''; ?></td>
<td><?php echo ($row->transaction_type == 'Debit') ? $row->amount : ''; ?></td>
<td><?php echo $row->balance; ?></td>
@ -229,7 +228,16 @@ $(document).ready(function() {
exportOptions: {
columns: ''
}
}],
},
{
extend: 'pdf',
text: 'PDF',
title: 'TransactionDetails',
exportOptions: {
columns: ''
}
}
],
language: {

View File

@ -0,0 +1,40 @@
<?php
namespace App\Tests;
use CodeIgniter\Test\CIUnitTestCase;
use App\Controllers\EmpDataServiceController;
use App\Models\EmployeePolicyModel;
use App\Models\EmployeeModel;
use App\Models\ClientModel;
use App\Models\ClientPolicyModel;
use App\Models\FileModel;
use App\Models\BatchListModel;
use App\Models\BatchFileModel;
use App\Models\EmpEndorsementModel;
use App\Models\ClientDepositModel;
class CheckFormateDataTest extends CIUnitTestCase
{
public function testGenerateExcelForAdditionAndInception()
{
$batch_data = [
'client_id' => 12,
'client_policy_id' => 12,
'insurer_or_tpa' => 'insurer',
'event_type' => 'inception',
'actions' => 'export',
'file_name' => 'TCS_HealthFlex_Advantage_Policy_IEI_06-04-2024_17-42-31.xlsx',
];
$empServiceController = new EmpDataServiceController();
$result = $empServiceController->generateExcelForAdditionAndInception($batch_data);
// You can add assertions here to verify the result if needed
$this->assertTrue($result);
}
}