diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 62866e3c..67634315 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -903,16 +903,26 @@ class BDSReportController extends AdminController public function renewalReport() { if ($this->request->is('get')) { - + $default_start = new \DateTime(); $data['default_end'] = $default_start->format('d-m-Y'); $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); + $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; $data['page_name'] = "Renewal Report"; return $this->loadLayout('renewal_search', $data); } else { - $data['page_name'] = "Renewal Report"; + $fromDate = $this->request->getPost('fromDate'); + $toDate = $this->request->getPost('toDate'); + $client_id = $this->request->getPost('client_id'); + $client_type = $this->request->getPost('client_type'); + $issuer = $this->request->getPost('issuer'); + + $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['client_type'] = [1 => 'Group', 2 => 'Individual']; + $data['renewal_data'] = $this->policyTransactionModel->getRenewalReportData($fromDate, $toDate, $client_type, $client_id, $issuer); + // print_r($data); die; $html = view('bds_renewal_report_list', $data); return $this->respond(['status' => true, 'html' => $html], 200); } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 774d3f60..9e81f1a9 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -2225,7 +2225,7 @@ class EmployeeController extends AdminController // print_rr($data);die(); // $data['dob'] = date('Y-m-d', strtotime($data['dob'])); if(isset( $data['dob'])){ - $data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d'); + $data['dob'] = change_date_format($data['dob'], null, 'Y-m-d'); } // print_rr($data); die; diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 33de4fdb..800f6941 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -737,7 +737,7 @@ class EmployeeRestController extends AdminController $jwt = $this->request->getHeaderLine('Authorization'); $jwtParts = explode(' ', $jwt); - $token = $jwtParts[2]; + $token = $jwtParts[1]; $decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true); diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 300a0eaa..197a5b66 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -1193,5 +1193,62 @@ class PolicyTransactionModel extends Model return $builder->get()->getResultArray(); } + + + //function for fetch renewal report data + public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null) + { + $fromDate = date('Y-m-d', strtotime('-60 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = change_date_format($start_date); + $toDate = change_date_format($end_date); + } + + $query = $this->db->table('policy_transaction pt') + ->select(' + pt.*, + c.client_name, + c.short_name AS client_short_name, + c.client_type, + policy_type.policy_type, + i.name as insurer_name, + ib.branch_name as insurer_branch_name, + vehicle.vehicle_no, + leads.status as lead_status + ') + ->join('clients c', 'pt.client_id = c.id', 'left') + ->join('pt_co_share_details pt_co', 'pt.id = pt_co.pt_id and pt_co.co_share_type = 1', 'left') + ->join('insurers i', 'pt_co.insurer_id = i.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('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') + ->where('pt.policy_end_date >=', $fromDate) + ->where('pt.policy_end_date <=', $toDate) + ->where('pt.is_active', 1) + ->where('pt_co.is_active', 1) + ->where('pt.action_type', "inception"); + + // Apply filters if parameters are provided + if (!empty($client_type)) { + $query->where('c.client_type', $client_type); + } + if (!empty($client)) { + $query->where('pt.client_id', $client); + } + if (!empty($issuer)) { // Corrected condition to check $issuer + $query->where('pt.issuer', $issuer); + } + + $query->groupBy('pt.id'); + $query->orderBy('pt.id', 'DESC'); + // Fetch and return results + $results = $query->get()->getResultArray(); + // print($this->db->getLastQuery()); die; + return $results; + } + } diff --git a/app/Views/bds_renewal_report_list.php b/app/Views/bds_renewal_report_list.php index e69de29b..524c917f 100644 --- a/app/Views/bds_renewal_report_list.php +++ b/app/Views/bds_renewal_report_list.php @@ -0,0 +1,145 @@ + + +
|
+ S.No.
+ |
+
+ Renewal Month
+ |
+
+ Issuer
+ |
+
+ Policy No
+ |
+
+ Policy
+ |
+
+ Insurer Name
+ |
+
+ Insurer Branch
+ |
+
+ Insured
+ |
+
+ Client Type
+ |
+
+ Business Type
+ |
+
+ Date of Issue
+ |
+
+ Policy Start Date
+ |
+
+ Policy Expiry Date
+ |
+
+ Vehicle No
+ |
+
+ Lead Status
+ |
+
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| + | + | + | + | + | + | + | + | + | + | + | ++ | ++ | ++ | + |