FIX_RAC_RATE_IN_CONTROLLER : RV

This commit is contained in:
VENKATESHWARAN 2024-04-06 09:00:58 +05:30
parent 39179cf477
commit 7402a80992
2 changed files with 173 additions and 45 deletions

View File

@ -936,73 +936,102 @@ class ClientController extends AdminController
$data = $this->policesModel->getPolicyPremium($record['policy_id']);
$policy_name = $data[0]->policy_name;
$pattern = '/gmc/i';
$gmc_pattern = '/gmc/i';
$gpa_pattern = '/gpa/i';
$subject = $data[0]->policy_type;
if (preg_match($pattern, $subject)) {
if (preg_match($gmc_pattern, $subject)) {
$search_term = 'GMC';
} else {
} else if (preg_match($gpa_pattern, $subject)){
$search_term = 'GPA';
}else{
$search_term = "";
}
$results = $this->policyGridModel->like('policy_type', $search_term)->findAll();
if($search_term === 'GPA'){
$premiumData = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll();
}else{
}else if($search_term === 'GMC'){
$premiumData = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll();
}else{
$premiumData = "";
}
// echo $record['client_id'];
// echo "-----";
// echo $client_policy_id;
// print_r($premiumData);die;
// echo '<pre>';
// echo $family_floater;
$resultss = [];
if ($family_floater == 1) {
if($search_term === 'GMC'){
foreach ($results as $index => $record) {
if ($index == '8' || $index == '7') {
// Clearing the $results array
$resultss = [];
if ($family_floater == 1) {
foreach ($results as $index => $record) {
if ($index == '8' || $index == '7') {
// Clearing the $results array
$resultss[$index] = $record;
}
}
}else if($family_floater == 0){
foreach ($results as $index => $record) {
if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6') {
// Clearing the $results array
$resultss[$index] = $record;
}
}
}else{
foreach ($results as $index => $record) {
$resultss[$index] = $record;
}
}
}else if($family_floater == 0){
foreach ($results as $index => $record) {
if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6') {
// Clearing the $results array
$resultss[$index] = $record;
}
$premiumDataa ='';
if ($family_floater == 0) {
// print_r($premiumData);die;
if (count($premiumData) == 0) {
$premiumDataa = $premiumData;
}else if ($premiumData[0]['policy_grid_id'] == '3' || $premiumData[0]['policy_grid_id'] == '4' || $premiumData[0]['policy_grid_id'] == '5' || $premiumData[0]['policy_grid_id'] == '6' || $premiumData[0]['policy_grid_id'] == '7' || $premiumData[0]['policy_grid_id'] == '8' || $premiumData[0]['policy_grid_id'] == '9' ) {
$premiumDataa = $premiumData;
}
}
else if($family_floater == 1){
if(count($premiumData) == 0){
$premiumDataa = $premiumData;
}else if ($premiumData[0]['policy_grid_id'] == '10' || $premiumData[0]['policy_grid_id'] == '11') {
$premiumDataa = $premiumData;
}
}else{
$premiumDataa = $premiumData;
}
}else{
foreach ($results as $index => $record) {
$resultss[$index] = $record;
if($premiumDataa == ""){
$premiumDataa = $premiumData;
}
}
$premiumDataa ='';
if ($family_floater == 0) {
// print_r($premiumData);die;
if (count($premiumData) == 0) {
$premiumDataa = $premiumData;
}else if ($premiumData[0]['policy_grid_id'] == '3' || $premiumData[0]['policy_grid_id'] == '4' || $premiumData[0]['policy_grid_id'] == '5' || $premiumData[0]['policy_grid_id'] == '6' || $premiumData[0]['policy_grid_id'] == '7' || $premiumData[0]['policy_grid_id'] == '8' || $premiumData[0]['policy_grid_id'] == '9' ) {
$premiumDataa = $premiumData;
}
}
else if($family_floater == 1){
if(count($premiumData) == 0){
$premiumDataa = $premiumData;
}else if ($premiumData[0]['policy_grid_id'] == '10' || $premiumData[0]['policy_grid_id'] == '11') {
$premiumDataa = $premiumData;
}
// print_r($data[0]->policy_type); die;
// echo "hello";
// return json_encode($premiumData);
return $this->respond(['status' => true,'code' => 200,'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
}else if($search_term === 'GPA'){
return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
}else{
$premiumDataa = $premiumData;
return $this->respond(['status' => false,'code' => 200,'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
}
// print_r($premiumData);die;
// print_r($data[0]->policy_type); die;
// echo "hello";
// return json_encode($premiumData);
return $this->respond(['status' => true,'code' => 200,'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name,], 200);
}
public function policyGMCTerms()

View File

@ -87,9 +87,9 @@ if (!function_exists('generate_excel')) {
try {
// Save Excel file to the specified path
// $writer->save($filename);
$filePath = WRITEPATH."/uploads/import_excel/" . $filename;
$writer->save($filePath);
$writer->save($filename);
// $filePath = WRITEPATH."/uploads/import_excel/" . $filename;
// $writer->save($filePath);
return true; // Return true if file was successfully saved
} catch (\Exception $e) {
// Log or handle the exception
@ -417,4 +417,103 @@ if (!function_exists('formatDateOrReturn')) {
return $value;
}
}
}
if (!function_exists('format_Excel_BasedOn_Client'))
{
function format_Excel_BasedOn_Client($objects, $client_excel_header)
{
$data = [];
// Initialize serial number
$serialNumber = 1;
// Iterate through each object
foreach ($objects as $obj)
{
// Extract all values for the object based on the header order
$rowData = [];
foreach ($client_excel_header as $header) {
$normalizedHeader = strtolower(str_replace(' ', '', $header));
switch ($normalizedHeader) {
case 's.no':
$rowData[] = $serialNumber++; // Serial Number
break;
case 'empid':
$rowData[] = $obj->emp_code; // Employee Code
break;
case 'nameofemp/dep':
$rowData[] = $obj->emp_name; // Employee Name
break;
case 'emp/deptype':
$rowData[] = $obj->emp_type; // Employee Type
break;
case 'relation':
$rowData[] = $obj->emp_relationship_code; // RELATION
break;
case 'dob':
$rowData[] = $obj->emp_dob; // Employee DOB
break;
case 'gender':
$rowData[] = $obj->emp_gender; //Employee GENDER
break;
case 'preexistingailments':
$rowData[] = $obj->pre_existing_alignments; // PRE EXISTING AILMENTS
break;
case 'basiccoversi':
$rowData[] = $obj->basic_cover_si; // Employee BASIC COVER SI
break;
case 'dateofcoverage':
$rowData[] = $obj->date_coverage; // DATE OF COVERAGE
break;
case 'age':
$rowData[] = $obj->emp_age; // Employee AGE
break;
case 'relationship':
$rowData[] = $obj->emp_relationship; // Employee RELATIONSHIP
break;
case 'remarks':
$rowData[] = $obj->change_event; // REMARKS
break;
case 'policyenddate':
$rowData[] = $obj->policy_end_date; // POLICY END DATE
break;
case 'noofdays':
$rowData[] = $obj->days; // NO OF DAYS
break;
case 'tpaid':
$rowData[] = ''; // TPA ID
break;
case 'uhid':
$rowData[] = ''; // UHID
break;
case 'premium':
$rowData[] = $obj->premium; // PREMIUM
break;
case 'proratapremium':
$rowData[] = $obj->rata_premimum; // PR0 RATA PREMIUM
break;
case 'gst':
$rowData[] = $obj->gst; // GST
break;
case 'total':
$rowData[] = $obj->total; // TOTAL
break;
default:
// If the header doesn't match any property, add an empty string
$rowData[] = '';
break;
}
}
// Append the row data to the main data array
$data[] = $rowData;
}
return $data;
}
}