CHANGE_RENEWAL_REPORT_CHANGE

This commit is contained in:
VENKATESHWARAN 2025-12-08 12:10:39 +05:30
parent f1e4dade06
commit fff305be38
3 changed files with 22 additions and 18 deletions

View File

@ -15,6 +15,7 @@ use App\Models\PolicyTransactionModel;
use App\Models\PTCOShareDetailsModel; use App\Models\PTCOShareDetailsModel;
use App\Models\COShareStmtDetailsModel; use App\Models\COShareStmtDetailsModel;
use App\Models\PolicyTypeModel; use App\Models\PolicyTypeModel;
use App\Models\NhanceBranchModel;
use CodeIgniter\API\ResponseTrait; use CodeIgniter\API\ResponseTrait;
@ -34,6 +35,7 @@ class BDSReportController extends AdminController
protected $coShareStmtDetailsModel; protected $coShareStmtDetailsModel;
protected $policyTypeModel; protected $policyTypeModel;
protected $policyTatReportType; protected $policyTatReportType;
protected $nhanceBranchModel;
public function __construct() public function __construct()
{ {
@ -47,6 +49,7 @@ class BDSReportController extends AdminController
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->policyTypeModel = new PolicyTypeModel(); $this->policyTypeModel = new PolicyTypeModel();
$this->nhanceBranchModel = new NhanceBranchModel();
$this->policyTatReportType = [ $this->policyTatReportType = [
@ -925,7 +928,7 @@ class BDSReportController extends AdminController
$default_start = new \DateTime(); $default_start = new \DateTime();
$data['default_end'] = $default_start->format('d-m-Y'); $data['default_end'] = $default_start->format('d-m-Y');
$data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y');
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();;
$data['tab_name'] = "Renewal Reports"; $data['tab_name'] = "Renewal Reports";
$data['page_name'] = "Renewal Report"; $data['page_name'] = "Renewal Report";
return $this->loadLayout('renewal_search', $data); return $this->loadLayout('renewal_search', $data);
@ -935,11 +938,11 @@ class BDSReportController extends AdminController
$toDate = $this->request->getPost('toDate'); $toDate = $this->request->getPost('toDate');
$client_id = $this->request->getPost('client_id'); $client_id = $this->request->getPost('client_id');
$client_type = $this->request->getPost('client_type'); $client_type = $this->request->getPost('client_type');
$issuer = $this->request->getPost('issuer'); $issuer_branch = $this->request->getPost('issuer_branch');
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();
$data['client_type'] = [1 => 'Group', 2 => 'Individual']; $data['client_type'] = [1 => 'Group', 2 => 'Individual'];
$data['renewal_data'] = $this->policyTransactionModel->getRenewalReportData($fromDate, $toDate, $client_type, $client_id, $issuer); $data['renewal_data'] = $this->policyTransactionModel->getRenewalReportData($fromDate, $toDate, $client_type, $client_id, $issuer_branch);
// print_r($data); die; // print_r($data); die;
$view_name = "bds_renewal_report_list"; $view_name = "bds_renewal_report_list";
$html = view('bds_renewal_report_list', $data); $html = view('bds_renewal_report_list', $data);

View File

@ -1787,7 +1787,7 @@
//function for fetch renewal report data //function for fetch renewal report data
public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null) public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer_branch = null)
{ {
$fromDate = date('Y-m-d', strtotime('-90 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
@ -1815,13 +1815,14 @@
->join('insurer_branch ib', 'pt_co.insurer_branch_id = ib.id', 'left') ->join('insurer_branch ib', 'pt_co.insurer_branch_id = ib.id', 'left')
->join('policy_type', 'pt.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'pt.policy_type_id = policy_type.id', 'left')
->join('vehicle', 'pt.vehicle_id = vehicle.id and vehicle.is_active = 1', 'left') ->join('vehicle', 'pt.vehicle_id = vehicle.id and vehicle.is_active = 1', 'left')
// ->join('leads', 'pt.client_policy_id = leads.source_policy_id and leads.source_policy_id != 0 and leads.is_active = 1', 'left') ->join('leads', 'pt.client_policy_id = leads.source_policy_id and leads.source_policy_id != 0 and leads.is_active = 1', 'left')
->where('pt.renewal_date >=', $fromDate) ->where('pt.renewal_date >=', $fromDate)
->where('pt.renewal_date <=', $toDate) ->where('pt.renewal_date <=', $toDate)
->where('pt.is_active', 1) ->where('pt.is_active', 1)
->where('pt.source_client_policy_id != pt.client_policy_id')
->where('pt_co.is_active', 1) ->where('pt_co.is_active', 1)
->where('pt.action_type', "inception"); ->where('pt.action_type', "inception")
->where("NOT EXISTS (SELECT 1 FROM policy_transaction p2 WHERE p2.source_client_policy_id = pt.client_policy_id AND p2.is_active = 1)");
// Apply filters if parameters are provided // Apply filters if parameters are provided
if (!empty($client_type)) { if (!empty($client_type)) {
@ -1830,8 +1831,8 @@
if (!empty($client)) { if (!empty($client)) {
$query->where('pt.client_id', $client); $query->where('pt.client_id', $client);
} }
if (!empty($issuer)) { // Corrected condition to check $issuer if (!empty($issuer_branch)) { // Corrected condition to check $issuer
$query->where('pt.issuer', $issuer); $query->where('pt.issuer_branch', $issuer_branch);
} }
$query->groupBy('pt.id'); $query->groupBy('pt.id');

View File

@ -30,13 +30,13 @@
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger"></span></label> <label for="client_branch">Nhance Branch<span class="text-danger"></span></label>
<select class="form-control" id="issuer" name="issuer"> <select class="form-control" id="issuer_branch" name="issuer_branch">
<option value="">Select Issuer</option> <option value="">Select Branch</option>
<?php <?php
if (isset($issuer) && count($issuer)) { if (isset($issuer_branch) && count($issuer_branch)) {
foreach ($issuer as $key => $value) { foreach ($issuer_branch as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>"; echo "<option value=" . $value['id'] . ">" . $value['branch_name'] . "</option>";
} }
} }
?> ?>
@ -133,13 +133,13 @@
var toDate = $('#endDate').val(); var toDate = $('#endDate').val();
var client_id = $('#client_id').val(); var client_id = $('#client_id').val();
var client_type = $('#client_type').val(); var client_type = $('#client_type').val();
var issuer = $('#issuer').val(); var issuer_branch = $('#issuer_branch').val();
var requestData = { var requestData = {
fromDate: fromDate, fromDate: fromDate,
toDate: toDate, toDate: toDate,
client_id: client_id, client_id: client_id,
client_type: client_type, client_type: client_type,
issuer: issuer, issuer_branch: issuer_branch,
}; };
console.log(typeof fromDate); console.log(typeof fromDate);
var url = '<?= base_url('/bdsReport/renewal_report') ?>'; var url = '<?= base_url('/bdsReport/renewal_report') ?>';