diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index d274600b..ddd29387 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -64,6 +64,9 @@ class LeadsController extends BaseController protected $clientType; protected $leadType; protected $leadsStatus; + protected $claim_type_for_gpa; + protected $cause_of_death; + public function __construct() { @@ -96,6 +99,19 @@ class LeadsController extends BaseController 'completed_with_corrections' => 'Completed with Corrections', 'completed_without_corrections' => 'Completed w/o Corrections', ]; + $this->claim_type_for_gpa = [ + 'accident_death' => 'Accident Death', + 'permanent_total_disablement' => 'Permanent Total Disablement', + 'permanent_partial_disablement' => 'Permanent Partial Disablement', + 'temporary_total_disablement_benefit' => 'Temporary Total Disablement benefit' + ]; + + $this->cause_of_death = [ + 'natural_death' => 'Natural Death', + 'suicide' => 'Suicide', + 'accident' => 'Accident' + ]; + } public function viewLeadsList() @@ -123,7 +139,7 @@ class LeadsController extends BaseController // Fetch insurer and TPA branch data $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); - + // print_r($data['tpa']);die(); // Fetch sales team members who are active in team 5 $data['salse_team'] = $this->userModel ->select('user_profiles.*') @@ -134,7 +150,10 @@ class LeadsController extends BaseController ->findAll(); // dd($data); - + $data['lastFiveYears'] = $this->getLastFiveFinancialYears(); + $data['gpaClaimType'] = $this->claim_type_for_gpa; + $data['causeOfDeath'] = $this->cause_of_death; + // dd($lastFiveYears); if ($this->request->is('get')) { // Fetch leads data $data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising(); @@ -270,7 +289,25 @@ class LeadsController extends BaseController $last_3_years_claims = null; if($value != 2){ - $last_3_years_claims = $data['finyear']; + $last_3_years_claims = []; + $finyear = json_decode($data['finyear']); + + foreach ($finyear as $year){ + $received_policy_type = ($year->finyear[0]->policy_type); + if ($value == $received_policy_type){ + array_push($last_3_years_claims,$year); + }else{ + continue; + } + // print_r($last_3_years_claims); + + // $last_3_years_claims = json_encode($last_3_years_claims); + } + $last_3_years_claims = json_encode($last_3_years_claims); + // print_r($last_3_years_claims); + // die(); + + // $last_3_years_claims = $data['finyear']; } $processedData[] = [ @@ -338,7 +375,7 @@ class LeadsController extends BaseController 'notes' => $data['notes'] ?? null, ]; } - + // print_r($processedData);die(); return $processedData; } @@ -2103,4 +2140,26 @@ class LeadsController extends BaseController } + function getLastFiveFinancialYears() { + $currentYear = date('Y'); + $currentMonth = date('m'); + + // In India, the financial year starts from April (04) + if ($currentMonth < 4) { + $currentYear--; // Adjust year if it's Jan-Mar + } + + $financialYears = []; + + for ($i = 0; $i < 5; $i++) { + $startYear = $currentYear - $i - 1; + $endYear = $currentYear - $i; + $financialYears[] = "$startYear-$endYear"; + } + + return $financialYears; + } + + + } diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index fe5079b7..0587df3e 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -1,38 +1,41 @@ @@ -82,11 +85,11 @@ @@ -103,11 +106,11 @@ @@ -117,11 +120,11 @@ @@ -233,11 +236,11 @@ @@ -247,16 +250,16 @@ @@ -280,242 +283,316 @@ \ No newline at end of file diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index 9c6c8390..261083b4 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -161,28 +161,29 @@ table.dataTable tbody td {