sparqapi/api/application/helpers/vendor_form_helper.php
2020-10-20 19:05:51 +05:30

121 lines
5.7 KiB
PHP

<?php
class vendor_form
{
public static function getVendorGeneralSectionContent($vendor_gen_section,$cus_type = 1)//1 = Di, 2 = SAL
{
$CI =&get_instance();
$CI->load->model('PD_Model');
//print_r($vendor_gen_section);die();
$return_data = '';
$is_applicant_not = false;
foreach ($vendor_gen_section['individuals'] as $ind_key => $ind_value)
{
if($ind_value['is_person_met'])
{
$return_data = "Applicant ( ".$ind_value['applicant_name']." ) was met at the visited address during Field Visit.<br>";
$is_applicant_not = true;
break;
}
}
if($cus_type == 2 && !$is_applicant_not)
{
$return_data = "Applicant ( ".$vendor_gen_section['individuals'][0]['applicant_name']." ) was not met at the visited address during Field Visit.<br>";
//echo 'XXXXXXXXXXXXX';
}
if(!$is_applicant_not && $vendor_gen_section['is_met_during_visit'] && $vendor_gen_section['person_met_entered'])
{
$return_data .= ($cus_type == 1 ? $vendor_gen_section['person_met_entered']." ( ".$vendor_gen_section['designation_entered'] ." ) met at the visited address during Field Visit.<br>" : $vendor_gen_section['person_met_entered']. " met at the visited address during Field Visit.<br>");
}
else if(!$is_applicant_not)
{
if($vendor_gen_section['is_employer_available'] != 'yes')
{
$return_data .= 'During Field Visit, No one met at the visited premises.';
}
if($cus_type == 2)
{
$return_data .= 'Field Visit officer clicked Office/Name Board/Entrance photographs and same is available in zipped folder attached with report.';
}
}
return $return_data;
}
public static function getVendoraddressSectionContent($vendor_add_section,$cus_type = 1)
{
$CI =&get_instance();
$CI->load->model('PD_Model');
$return_data = array();//fi_initiated_address
//print_r($vendor_add_section);die();
$initiated_address = vendor_form::getAddress($CI,$vendor_add_section,1);
$actual_address = $vendor_add_section['is_pd_done_on_initiated_address'] ? array() : vendor_form::getAddress($CI,$vendor_add_section,2);
$address_type_name = $vendor_add_section['address_type_others'] ? $vendor_add_section['address_type_others'] : $CI->PD_Model->selectCustomRecords(array('address_type'),array('address_type_id' => $vendor_add_section['address_type']),ADDRESSTYPE);
$address_locality = $vendor_add_section['locality_others'] ? $vendor_add_section['locality_others'] : $CI->PD_Model->selectCustomRecords(array('locality_name'),array('locality_id' => $vendor_add_section['locality']),LOCALITY);
$uom = $vendor_add_section['uom_others'] ? $vendor_add_section['uom_others'] : $CI->PD_Model->selectCustomRecords(array('name'),array('uom_id' => $vendor_add_section['uom']),UOM);
$pd_location_approach = $CI->PD_Model->selectCustomRecords(array('description'),array('pd_location_approach_id' => $vendor_add_section['pd_location']),PDLOCATIONAPPROACH);
$comment_locality = $CI->PD_Model->selectCustomRecords(array('rating'),array('comments_on_locality_id' => $vendor_add_section['comment_locality']),COMMENTSONLOCALITY);
$return_data = array('initiated_address' => $initiated_address,'actual_address' => $actual_address,'address_type' => (is_array($address_type_name) ? $address_type_name[0]['address_type'] : $address_type_name),'address_locality' => (is_array($address_locality) ? $address_locality[0]['locality_name'] : $address_locality),'pd_location_approach' => $pd_location_approach[0]['description'],'comment_locality' => $comment_locality[0]['rating']);
if($cus_type == 1){ $return_data['uom'] = ( is_array($uom) ? $uom[0]['name'] : $uom); }
return $return_data;
}
static function getAddress($CI,$vendor_add_section,$addres_type = 1)//1 = visited address, 2 = alternative address
{
$CI->load->model('PD_Model');
$state_id = $addres_type == 1 ? $vendor_add_section['state'] : $vendor_add_section['alternative_addresses'][0]['alternative_state'];
$city_id = $addres_type == 1 ? $vendor_add_section['city'] : $vendor_add_section['alternative_addresses'][0]['alternative_city'];
$pincode_id = $addres_type == 1 ? $vendor_add_section['pincode'] : $vendor_add_section['alternative_addresses'][0]['alternative_pincode'];
$state_name = $CI->PD_Model->selectCustomRecords(array('name'),array('state_id' => $state_id),STATE);
$city_name = $CI->PD_Model->selectCustomRecords(array('name'),array('city_id' => $city_id),CITY);
$pincode = $CI->PD_Model->selectCustomRecords(array('pincode'),array('pincode_id' => $pincode_id),PINCODE);
return array('state_name' => $state_name[0]['name'],'city_name' => $city_name[0]['name'],'pincode' => $pincode[0]['pincode']);
}
static function getVendorEmpSectionContent($vendor_employer_info)
{
$CI =&get_instance();
$CI->load->model('PD_Model');
$company_relationship_id = $vendor_employer_info['employer_details']['designation_person_met'];
$company_relationship = $CI->PD_Model->selectCustomRecords(array('name'),array('company_relationship_id' => $company_relationship_id),COMPANYRELATIONSHIPS);
return $company_relationship && count($company_relationship) ? $company_relationship[0]['name'] : '';
}
static function getSalNotConfirmedResons($reson_array,$ot_reason)
{
if(is_array($reson_array) && count($reson_array))
{
$reason = '';
foreach ($reson_array as $key => $value)
{
// if(strtolower($value) != 'others please specify')
// echo $value.'---'.stripos($value,'others');
if((stripos($value,'others')) === false)
{
$reason .= $value.', ';
}
}
if($ot_reason){$reason.= $ot_reason.', ';}
if($reason){ $reason = substr_replace($reason,'',-2);$reason .='.'; }
return $reason;
}
}
}
?>