sparqapi/api/application/helpers/neighbourreferencecheckform_helper.php
2019-12-13 20:24:46 +05:30

133 lines
6.3 KiB
PHP

<?php
class Neighbourreferencecheckform
{
public static function getNeighbourhoodDetails($company_name,$values,$pdMasterValue,$applicants_details){
//print_r($applicants_details);die();
// $latest_applicants_names = APPLICANTNAME_GRABBER::getLatestApplicantsName($pdMasterValue['pd_id']);
$applicantName=$pdMasterValue['main_applicant'];
$values = array_map(function($tag) use ($applicantName,$company_name,$applicants_details) {
$neighbourhood_name='Neighbour Check was done with ';
$neighbourhood_name.= $tag['neighbourhood_name'].'.';
$neighbourhood_do_know = null;
$neighbourhood_business_running_yr = null;
$ownership = null;
$neighbourhood_name_only = $tag['neighbourhood_name'];
if(strtoupper($tag['do_know'])=='YES'){
$neighbourhood_do_know = $tag['neighbourhood_name']." knows about applicants and their business.";
} else if(strtoupper($tag['do_know'])=='NO'){
$neighbourhood_do_know = $tag['neighbourhood_name']." did not know about the applicant or their business.";
}
if($tag['how_long_do_know_in_year'] || $tag['how_long_do_know_in_month'])
{
$neighbourhood_business_running_yr = $tag['neighbourhood_name']." confirmed that the business has been in operation for ";
$neighbourhood_business_running_yr .= ($tag['how_long_do_know_in_year'] == 1) ? $tag['how_long_do_know_in_year']." year" : (($tag['how_long_do_know_in_year'] > 1) ? $tag['how_long_do_know_in_year']." years" : "");
$tag['how_long_do_know_in_year'] && $tag['how_long_do_know_in_month'] ? $neighbourhood_business_running_yr .= ' and ':'';
$neighbourhood_business_running_yr .= ($tag['how_long_do_know_in_month'] == 1) ? $tag['how_long_do_know_in_month']." month" : (($tag['how_long_do_know_in_month'] > 1) ? $tag['how_long_do_know_in_month']." months" : "");
$neighbourhood_business_running_yr .= '.';
}
else
{
$neighbourhood_business_running_yr = $tag['neighbourhood_name']." was not aware of how long the business is in operation.";
}
$ownwers_list = '';
if($tag['organisation_owner']){
foreach($tag['organisation_owner'] as $owner)
{
if($owner['id'] != 0)
{
$title = MYUTIL::applicantTitleName($applicants_details,$owner['id']);
$ownwers_list .= $title.' '.APPLICANTNAME_GRABBER::getApplicantsNameById($owner['id'],$applicants_details).' , ';
}
else
{
$ownwers_list .= ' '.$tag['other_organisation_owner'].' , ';
}
}
//echo $ownwers_list;
//$ownwers_list = substr_replace($ownwers_list,'', strrpos(-$ownwers_list,','),1);
//echo $ownwers_list;
//echo $ownwers_list;echo "**********";
$ownwers_list = substr_replace($ownwers_list,'', strrpos($ownwers_list,','),1);
if(strrpos($ownwers_list,','))
{
$ownwers_list = substr_replace($ownwers_list,' and ', strrpos($ownwers_list,','),1);
}
$grammer1 = count($tag['organisation_owner']) > 1 ? ' are ': ' is ';
$grammer2 = count($tag['organisation_owner']) > 1 ? 'owners': 'owner';
$ownership = 'As per '.$tag['neighbourhood_name'].' the '.$grammer2 .' of '.$company_name.$grammer1.$ownwers_list.'.';
}else
{
$ownership = $tag['neighbourhood_name']." was not aware of the business ownership.";
}
//$makeSentense.=(strtoupper($tag['is_applicant_owner']) == 'YES') ? "owner of the business." : ((strtoupper($tag['is_applicant_owner']) == 'NO') ? "not owner of the business." : "");
return array('neighbourhood_name_only' => $neighbourhood_name_only,'neighbourhood_name' => $neighbourhood_name,'neighbourhood_do_know' => $neighbourhood_do_know,'neighbourhood_business_running_yr' => $neighbourhood_business_running_yr,'ownership' => $ownership);
}, $values);
//print_r($values);die();
return $values;
}
public static function getReferenceDetails($values,$pdMasterValue) {
$applicantName=$pdMasterValue['main_applicant'];
$values = array_map(function($tag) use ($applicantName) {
$makeSentense=($tag['relationship_with'] == 1) ? $tag['others'] : (($tag['relationship_with'] > 1) ? $tag['relationship_with_master'] : "");
$makeSentense.= ' '.$tag['reference_name'].' of SineEdge was contacted over phone at ';
$makeSentense.=$tag['mobile'].'. ';
$makeSentense.='He is related to this business since last ';
$makeSentense.=($tag['year_relation_applicant'] == 1) ? $tag['year_relation_applicant']." year" : (($tag['year_relation_applicant'] > 1) ? $tag['year_relation_applicant']." years" : "");
$makeSentense.=" is doing a business of Rs.".$tag['business_volume_amount'];
switch($tag['business_volume_unit']) {
case 1:
$makeSentense .= ' per '.$tag['others_unit'].'.';
break;
case 2:
$makeSentense .= ' per annum.';
break;
case 3:
$makeSentense .= ' per halfyearly.';
break;
case 4:
$makeSentense .= ' per fortnightly.';
break;
case 5:
$makeSentense .= ' per daily.';
break;
case 6:
$makeSentense .= ' per quarterly.';
break;
case 7:
$makeSentense .= ' per month.';
break;
default:
$makeSentense .= '. ';
}
if($tag['reference_final_remarks']==3){
$makeSentense .=($tag['relationship_with'] == 1) ? $tag['others'] : (($tag['relationship_with'] > 1) ? $tag['relationship_with_master'] : "");
$makeSentense .=' did not provide sufficient information to validate the business credentials.';
}
else if($tag['reference_final_remarks']==2) {
$makeSentense .=($tag['relationship_with'] == 1) ? $tag['others'] : (($tag['relationship_with'] > 1) ? $tag['relationship_with_master'] : "");
$makeSentense .=' reference check was negative.';
}
else if($tag['reference_final_remarks']==1) {
$makeSentense .=($tag['relationship_with'] == 1) ? $tag['others'] : (($tag['relationship_with'] > 1) ? $tag['relationship_with_master'] : "");
$makeSentense .=' reference check was positive.';
}
return $makeSentense;
}, $values);
return $values;
}
}
?>