52 lines
1.9 KiB
PHP
52 lines
1.9 KiB
PHP
<?php
|
|
|
|
class applicantname_grabber
|
|
{
|
|
|
|
public static function getLatestApplicantsName($pd_id)
|
|
{
|
|
$CI =&get_instance();
|
|
$CI->load->model('PD_Model');
|
|
//return ( $CI->PD_Model->selectCustomRecords(array('pd_co_applicant_id','applicant_name'),array('fk_pd_id' => $pd_id),PDAPPLICANTSDETAILS));
|
|
|
|
$columns = array('PDAPPLICANTSDETAILS.pd_co_applicant_id','PDAPPLICANTSDETAILS.applicant_name','TITLES.name as title');
|
|
$table = array(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS');
|
|
$joins = array(
|
|
array('table' => TITLES. ' as TITLES',
|
|
'condition' =>"PDAPPLICANTSDETAILS.applicant_title_name = TITLES.title_id AND PDAPPLICANTSDETAILS.fk_pd_id = $pd_id",
|
|
'jointype' => 'LEFT')
|
|
);
|
|
$where_condition_array = array('PDAPPLICANTSDETAILS.fk_pd_id'=>$pd_id);
|
|
return ( $CI->PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array));
|
|
|
|
}
|
|
|
|
public static function getApplicantsNameById($id,$latest_applicants_names,$type = 1) //$type i for return name only, 2 for return title only, and 3 for return both
|
|
{
|
|
foreach ($latest_applicants_names as $key => $value) {
|
|
|
|
if($id == $value['pd_co_applicant_id'])
|
|
{
|
|
return $type == 1 ? $value['applicant_name'] : ($type == 2 ? $value['title'] : ($value['title'].' '.$value['applicant_name']));
|
|
}
|
|
}
|
|
}
|
|
|
|
public static function getMultipleApplicantsNameById($arr,$latest_applicants_names) //$type i for return name only, 2 for return title only, and 3 for return both
|
|
{
|
|
$mergered_applicants_name = '';
|
|
foreach ($arr as $key => $value) {
|
|
|
|
foreach ($latest_applicants_names as $k => $val)
|
|
{
|
|
if($value == $val['pd_co_applicant_id'])
|
|
{
|
|
$mergered_applicants_name .= $val['applicant_name'].', ';
|
|
}
|
|
}
|
|
}
|
|
if($mergered_applicants_name != ''){ $mergered_applicants_name = substr_replace($mergered_applicants_name, '',-2);}
|
|
return $mergered_applicants_name;
|
|
}
|
|
}
|
|
?>
|