GWM : relationship array handled

This commit is contained in:
Gowtham M 2025-12-01 18:12:24 +05:30
parent c2958edcda
commit 074f988f0f

View File

@ -1361,41 +1361,47 @@ class EmployeeRestController extends AdminController
array_push($data,$temp2);
array_push($array->to_be_added_relationship,$temp2['data']['relationship']);
$array->to_be_added_relationship = array_unique($array->to_be_added_relationship);
array_push($array->to_be_added_relationship,['relationship'=>$temp2['data']['relationship'],'age_validation'=>$temp2['data']['age_validation']]);
$array->to_be_added_relationship = array_values(
array_map('unserialize',
array_unique(
array_map('serialize', $array->to_be_added_relationship)
)
)
);
}
}
$array->relationship = [];
foreach ($array->to_be_added_relationship as $value) {
if($value == 'Spouse'){
array_push($array->relationship,'Spouse');
}else if($value == 'Child'){
array_push($array->relationship, 'Son');
array_push($array->relationship, 'Daughter');
}else if($value == 'Parent'){
foreach ($array->to_be_added_relationship as $key => $value) {
if($value['relationship'] == 'Spouse'){
array_push($array->relationship,['relationship'=>'Spouse','age_validation'=>$value['age_validation']]);
}else if($value['relationship'] == 'Child'){
array_push($array->relationship, ['relationship'=>'Son','age_validation'=>$value['age_validation']]);
array_push($array->relationship, ['relationship'=>'Daughter','age_validation'=>$value['age_validation']]);
}else if($value['relationship'] == 'Parent'){
$Father = array_search('Father',$array->existing_relationship);
$Mother = array_search('Mother',$array->existing_relationship);
if ($Father === false && $Mother === false) {
array_push($array->relationship, 'Father');
array_push($array->relationship, 'Mother');
array_push($array->relationship, ['relationship'=>'Father','age_validation'=>$value['age_validation']]);
array_push($array->relationship, ['relationship'=>'Mother','age_validation'=>$value['age_validation']]);
}else if ($Father !== false && $Mother === false) {
array_push($array->relationship, 'Mother');
array_push($array->relationship, ['relationship'=>'Mother','age_validation'=>$value['age_validation']]);
} else if ($Mother !== false && $Father === false) {
array_push($array->relationship, 'Father');
array_push($array->relationship, ['relationship'=>'Father','age_validation'=>$value['age_validation']]);
}
}else if($value == 'Parent in law'){
}else if($value['relationship'] == 'Parent in law'){
$FatherinLaw = array_search('Father in Law',$array->existing_relationship);
$MotherinLaw = array_search('Mother in Law',$array->existing_relationship);
if ($FatherinLaw === false && $MotherinLaw === false) {
array_push($array->relationship, 'Father in Law');
array_push($array->relationship, 'Mother in Law');
array_push($array->relationship, ['relationship'=>'Father in Law','age_validation'=>$value['age_validation']]);
array_push($array->relationship, ['relationship'=>'Mother in Law','age_validation'=>$value['age_validation']]);
}else if ($FatherinLaw !== false && $MotherinLaw === false) {
array_push($array->relationship, 'Mother in Law');
array_push($array->relationship, ['relationship'=>'Mother in Law','age_validation'=>$value['age_validation']]);
} else if ($MotherinLaw !== false && $FatherinLaw === false) {
array_push($array->relationship, 'Father in Law');
array_push($array->relationship, ['relationship'=>'Father in Law','age_validation'=>$value['age_validation']]);
}
}
}
@ -1614,41 +1620,48 @@ class EmployeeRestController extends AdminController
$temp2['data']['age_validation'] = $this->getAgeRange($array->Policy_Terms,$familyFloatesValue);
array_push($data,$temp2);
array_push($array->to_be_added_relationship,$temp2['data']['relationship']);
$array->to_be_added_relationship = array_unique($array->to_be_added_relationship);
array_push($array->to_be_added_relationship,['relationship'=>$temp2['data']['relationship'],'age_validation'=>$temp2['data']['age_validation']]);
$array->to_be_added_relationship = array_values(
array_map('unserialize',
array_unique(
array_map('serialize', $array->to_be_added_relationship)
)
)
);
}
}
$array->relationship = [];
foreach ($array->to_be_added_relationship as $value) {
if($value == 'Spouse'){
array_push($array->relationship,'Spouse');
}else if($value == 'Child'){
array_push($array->relationship, 'Son');
array_push($array->relationship, 'Daughter');
}else if($value == 'Parent'){
$Father = array_search('Father',$array->existing_relationship);
$Mother = array_search('Mother',$array->existing_relationship);
if ($Father === false && $Mother === false) {
array_push($array->relationship, 'Father');
array_push($array->relationship, 'Mother');
}else if ($Father !== false && $Mother === false) {
array_push($array->relationship, 'Mother');
} else if ($Mother !== false && $Father === false) {
array_push($array->relationship, 'Father');
}
}else if($value == 'Parent in law'){
$FatherinLaw = array_search('Father in Law',$array->existing_relationship);
$MotherinLaw = array_search('Mother in Law',$array->existing_relationship);
if ($FatherinLaw === false && $MotherinLaw === false) {
array_push($array->relationship, 'Father in Law');
array_push($array->relationship, 'Mother in Law');
}else if ($FatherinLaw !== false && $MotherinLaw === false) {
array_push($array->relationship, 'Mother in Law');
} else if ($MotherinLaw !== false && $FatherinLaw === false) {
array_push($array->relationship, 'Father in Law');
}
foreach ($array->to_be_added_relationship as $key => $value) {
if($value['relationship'] == 'Spouse'){
array_push($array->relationship,['relationship'=>'Spouse','age_validation'=>$value['age_validation']]);
}else if($value['relationship'] == 'Child'){
array_push($array->relationship, ['relationship'=>'Son','age_validation'=>$value['age_validation']]);
array_push($array->relationship, ['relationship'=>'Daughter','age_validation'=>$value['age_validation']]);
}else if($value['relationship'] == 'Parent'){
$Father = array_search('Father',$array->existing_relationship);
$Mother = array_search('Mother',$array->existing_relationship);
if ($Father === false && $Mother === false) {
array_push($array->relationship, ['relationship'=>'Father','age_validation'=>$value['age_validation']]);
array_push($array->relationship, ['relationship'=>'Mother','age_validation'=>$value['age_validation']]);
}else if ($Father !== false && $Mother === false) {
array_push($array->relationship, ['relationship'=>'Mother','age_validation'=>$value['age_validation']]);
} else if ($Mother !== false && $Father === false) {
array_push($array->relationship, ['relationship'=>'Father','age_validation'=>$value['age_validation']]);
}
}else if($value['relationship'] == 'Parent in law'){
$FatherinLaw = array_search('Father in Law',$array->existing_relationship);
$MotherinLaw = array_search('Mother in Law',$array->existing_relationship);
if ($FatherinLaw === false && $MotherinLaw === false) {
array_push($array->relationship, ['relationship'=>'Father in Law','age_validation'=>$value['age_validation']]);
array_push($array->relationship, ['relationship'=>'Mother in Law','age_validation'=>$value['age_validation']]);
}else if ($FatherinLaw !== false && $MotherinLaw === false) {
array_push($array->relationship, ['relationship'=>'Mother in Law','age_validation'=>$value['age_validation']]);
} else if ($MotherinLaw !== false && $FatherinLaw === false) {
array_push($array->relationship, ['relationship'=>'Father in Law','age_validation'=>$value['age_validation']]);
}
}
}