diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 5b348a0f..2708abc4 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -825,9 +825,15 @@ // Fetch Sales Team $data['salse_team'] = $this->userModel - ->select('user_profiles.*,nhance_branch.id as nhance_branch_id, nhance_branch.branch_name as nhance_branch_name') + ->select(' + user_profiles.*, + nhance_branch.id as nhance_branch_id, + nhance_branch.branch_name as nhance_branch_name, + rm.first_name AS rm_name + ') ->join('user_teams', 'user_profiles.id = user_teams.user_id') ->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left') + ->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left') ->where('user_teams.team_id', 5) ->where('user_teams.is_active', 1) ->where('user_profiles.is_active', 1) @@ -841,9 +847,19 @@ // Fetch ACM $data['ACM'] = $this->userModel - ->where('role', 3) // Assuming `role` is in `user_profiles` - ->where('is_active', 1) - ->findAll(); + ->select(' + user_profiles.*, + nhance_branch.id AS nhance_branch_id, + nhance_branch.branch_name AS nhance_branch_name, + rm.first_name AS rm_name + ') + ->join('user_teams', 'user_profiles.id = user_teams.user_id') + ->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id', 'left') + ->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left') + ->where('user_profiles.role', 3) + ->where('user_profiles.is_active', 1) + ->findAll(); + // echo '
';
// print_r($data['ppTeamsData']); die;
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 44a0550d..7fed2681 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -85,6 +85,9 @@
'agent_code',
'file_id',
'entry_from',
+ 'salse_person_manager_id',
+ 'service_person_manager_id',
+ 'service_person_branch_id',
];
@@ -1794,6 +1797,61 @@
$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.renewal_date >=', $fromDate)
+ ->where('pt.renewal_date <=', $toDate)
+ ->where('pt.is_active', 1)
+ ->where('pt.source_client_policy_id != pt.client_policy_id')
+ ->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;
+ }
+
+ public function getRenewalReportDataOld($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null)
+ {
+ $fromDate = date('Y-m-d', strtotime('-90 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.*,
diff --git a/app/Views/policy_transaction_inception_form_2.php b/app/Views/policy_transaction_inception_form_2.php
index 79ac1444..dfd6a662 100644
--- a/app/Views/policy_transaction_inception_form_2.php
+++ b/app/Views/policy_transaction_inception_form_2.php
@@ -333,6 +333,9 @@
+
+
+
@@ -439,14 +442,21 @@
class="text-right"
style="font-size: x-small;">
+
+
-