load->model('PD_Model'); $return_data =array(); switch($section['fk_form_id']) { case 1://borrower $return_data = SELF::getBorrowerSectionData($section); break; case 4://General Business case 5://Key Stakeholders case 6://bbusiness brief case 7://emp strength case 9://banking case 10://finance case 14://future case 18://credit case 19://final remarks $return_data = json_decode($section['json'],true); break; case 3://fund $return_data = SELF::getLoanSectionData($section); break; case 2://address $return_data = SELF::getAddressSectionData($section); break; case 8://assest $return_data = SELF::getAssestSectionData($section); break; case 11://supplier $return_data = SELF::getSupplierSectionData($section,$company); break; case 12://client $return_data = SELF::getClientSectionData($section,$company); break; case 13://stock $return_data = SELF::getStockSectionData($section); break; case 15://existing loan $return_data = SELF::getExistingLoanSectionData($section); break; case 16://other family $return_data = SELF::getFamilySectionData($section); // print_r($return_data);die(); break; case 17://neighborhood $return_data = SELF::getNeibourSectionData($section); break; case 21://General Section $return_data = json_decode($section['json'],true); break; case 22://Profile $return_data = json_decode($section['json'],true); break; case 23://Size and Geographical Reach $return_data = json_decode($section['json'],true); break; case 24://Product and Process $return_data = json_decode($section['json'],true); break; case 25://Portfolio Health $return_data = json_decode($section['json'],true); break; case 26://Total Overall Debt/Equity Profile $return_data = json_decode($section['json'],true); break; case 27://Financial Analysis $return_data = json_decode($section['json'],true); break; case 28://Overall Plan of Action $return_data = json_decode($section['json'],true); break; case 29://Validation Points vide Systems and Books at HQ & Branches $return_data = json_decode($section['json'],true); break; } // print_r($return_data);die(); return $return_data; } static function getBorrowerSectionData($section) { $json = json_decode($section['json'],true); $person_met = ''; $mobile_numbers_array = array(); // echo "Step 1 Mobile Number Arr Empty";print_r($mobile_numbers_array); $inx = 0; foreach ($json['borrower_details'] as $key => $value) { $mobile_numbers = ''; if(isset($value['mobile_numbers']) && count($value['mobile_numbers'])) { // echo "Step 2 Incoming Mobile Numbers Checks"; print_r($value['mobile_numbers']); foreach ($value['mobile_numbers'] as $k => $smn) { if((count($value['mobile_numbers']) - 1) == $k){$mobile_numbers .= ($smn['mobile_no']); break;} $mobile_numbers .= ($smn['mobile_no'].',
'); } $json['borrower_details'][ $key ] ['mobile_numbers'] = $mobile_numbers; if($mobile_numbers) { $mobile_numbers_array[('##'.$inx.'##')] = '( ' . str_replace('
', '', $mobile_numbers) . ' ) '; } // echo "Step 3 Now I have Mobile Arrs"; print_r($mobile_numbers_array); } if(isset($value['borrower_met']) && !strcasecmp($value['borrower_met'],'yes')) { $temp_person_met = $value['borrower_name'].', '; // echo "Step 4 In person Met and I have "; print_r($mobile_numbers_array); if(isset($value['mobile_numbers']) && count($value['mobile_numbers'])) { //echo "Step 5 person met is connected to spec inx ".$value['borrower_name'].'##'.$inx.'##'; $temp_person_met = $value['borrower_name'].'##'.$inx.'## , '; } //$temp_person_met .= ($mobile_numbers != '' ? '(' .$mobile_numbers. ') ,': ','); $person_met .= $temp_person_met; } $mobile_numbers = ''; $inx++; } // echo 'Step 6 Visted Person are '.$person_met; // if(!isset($json['person_met'])) // { // $json['person_met'] = ''; // } if($person_met != '') { $person_met = substr_replace($person_met,'',-2); // echo 'Step 7 Visted Person are but removed Comma'.$person_met; if(substr_count($person_met,',')) { $person_met = substr_replace($person_met,' and ',strrpos($person_met,','),2); } } // print_r($person_met); foreach ($mobile_numbers_array as $key => $value) { $person_met = str_replace($key, $value, $person_met); } // echo "Step 8 person with Mobile Number".$person_met; $json['person_met'] = $person_met; return $json; } static function getAssestSectionData($section) { $json = json_decode($section['json'],true); $rupee_symbol = ""; // $CI =&get_instance(); // $CI->load->model('PD_Model'); if(isset($json['business_assets_details']) && is_array($json['business_assets_details']) && count($json['business_assets_details'])) { $applicant_details = applicantname_grabber::getLatestApplicantsName($section['fk_pd_id']); $asset_type = array('2' => 'Property','3' => 'Vehicle','4' => 'Equipments and machinery','5' => 'Jewellery','6' => 'Life Insurance Policy','7' => 'Investments','1' => 'Others'); $address_type = array('2' => 'Clinic','3' => 'Factory','4' => 'Warehouse / Godown','5' => 'Shop','6' => 'Residence','7' => 'Residence cum Office','1' => 'Others','8' => 'Industrial Shed','9'=> 'Workshop','10'=> 'Business Centre','11'=> 'Shared Office','12'=> 'Office'); $vehicle_type = array('2' => 'Car/Jeep','3' => 'Truck/ Bus','4' => 'Rickshaw/Tempo','5' => 'Tractor','6' => 'Two Wheeler','1' => 'Others'); // print_r($applicant_details);die(); $header_row = ''.' Particulars '; $first_row = ''.' Asset Type '; $second_row = ''.' Asset Description '; $third_row = ''.' Asset Ownership (Owned / Rented) '; $fourth_row = ''.' If Owned then Owner Name '; $five_row = ''.' If Owned then Market Value '; $siz_row = ''.' Age of the Asset (Years) '; $seven_row = ''.' Is there a Loan Against the Asset? (Yes / No) '; foreach ($json['business_assets_details'] as $key => $value) { $description = $value['other_asset_description']; if(isset($value['property_type'])) { if($value['property_type'] == 1){ $description .= '('. $value['property_type_others'] .')'; } else{ $description .= '('. $address_type[ $value['property_type'] ] .')'; } } if(isset($value['vehicle_type'])) { if($value['vehicle_type'] == 1){ $description .= '('. $value['vehicle_type_others'] .')'; } else{$description .= '('. $vehicle_type[ $value['vehicle_type'] ] .')';} } if(isset($value['business_purchase_year'])) { $description .= ' purchased at '.$value['business_purchase_year']; } if(isset($value['property_address'])) { $description .= ' is in '. $value['property_address']; } $business_ownership_type = $value['business_ownership_type'] . (isset($value['business_monthly_rented_amt']) ? ' ( '. $rupee_symbol .' '. MYUTIL::customIndianNumberFormat($value['business_monthly_rented_amt']) .' ) ' : ''); $header_row .= ' Assest '. ( $key + 1 ).''; $first_row .= ''. ( $value['business_assets_mode'] == 1 ? $value['other_asset_description'] : $asset_type [ $value['business_assets_mode'] ]).''; $second_row .= ''. $description .''; $third_row .= ' '.$business_ownership_type.' '; $business_name_of_the_owner = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getMultipleApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); $fourth_row .= ' '. $business_name_of_the_owner .' '; $five_row .= ' '. (isset($value['business_approximate_market_value']) ? ( $rupee_symbol .' '. MYUTIL::customIndianNumberFormat($value['business_approximate_market_value'])) : 'NA') .' '; $siz_row .= ' '. (isset($value['business_purchase_year']) ? $value['business_purchase_year'] : 'NA') .' '; $seven_row .= ' '. (isset($value['business_emi']) ? $value['business_emi'] : 'NA') .' '; } $header_row .= ''; $first_row .= ''; $second_row .= ''; $third_row .= ''; $fourth_row .= ''; $five_row .= ''; $siz_row .= ''; $json['display_data'] = array('header_row' => $header_row,'first_row' => $first_row,'second_row' => $second_row,'third_row' => $third_row,'fourth_row' => $fourth_row,'five_row' => $five_row,'siz_row' => $siz_row,'seven_row' => $seven_row); } return $json; } static function getSupplierSectionData($section,$company) { // echo "i am in supp Fns";print_r($company);exit(); $json = json_decode($section['json'],true); // print_r(json_decode($section['clist'],true)); $payment_term = array('1' => 'Supply against advance payment','2' => 'Payment on Receipt of goods / service','3' => 'Payment after Credit Period provided'); // print_r($json);//die(); $header_row = ''.' Particulars '; $first_row = ''.' Item Purchased '; $second_row = ''.' Contact Person '; $third_row = ''.' Mobile Number '; $fourth_row = ''.' Landline No '; $five_row = ''.' Payment Terms '; $siz_row = ''.' Payment Mode '; $seven_row = ''.' No of days credit '; $eigth_row = ''.'Total purchase done on credit '; $ninth_row = ''.'Name of the Company'; if(isset($json['supplier_details']) && is_array($json['supplier_details']) && count($json['supplier_details'])) { foreach ($json['supplier_details'] as $key => $value) { $header_row .= 'Supplier '.$value['supplier_name'].''; $first_row .= ''. $value['provider_name'] .''; $second_row .= ''. $value['contact_person_name'] .''; $third_row .= ' '. (empty($value['contact_person_mobile_no']) ? '-':$value['contact_person_mobile_no']) .' '; // $business_name_of_the_owner = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); $fourth_row .= ' '. $value['person_stdcode'].' - '.$value['person_landline'] .' '; $five_row .= ' '. (isset($value['payment_type']) ? $payment_term [ $value['payment_type'] ]: 'NA') .' '; $siz_row .= ' '. (isset($value['payment_mode']) ? $value['payment_mode'] : 'NA') .' '; $seven_row .= ' '. (isset($value['credit_period_no']) ? $value['credit_period_no'] : 'NA') .' '; $eigth_row .= ' '. (isset($value['credit_total_purchase']) ? $value['credit_total_purchase'].'%' : 'NA') .' '; $ninth_row .= ' '. (isset($value['company_name']) ? $company[$value['company_name']] : 'NA') .' '; } $header_row .= ''; $first_row .= ''; $second_row .= ''; $third_row .= ''; $fourth_row .= ''; $five_row .= ''; $siz_row .= ''; $seven_row .= ''; $eigth_row .= ''; $ninth_row .= ''; $json['display_data'] = array('header_row' => $header_row,'first_row' => $first_row,'second_row' => $second_row,'third_row' => $third_row,'fourth_row' => $fourth_row,'five_row' => $five_row,'siz_row' => $siz_row,'seven_row' => $seven_row,'eigth_row' => $eigth_row,'ninth_row'=>$ninth_row); } return $json; } static function getClientSectionData($section,$company) { $json = json_decode($section['json'],true); $payment_term = array('1' => 'Supply against advance payment','2' => 'Payment on Receipt of goods / service','3' => 'Payment after Credit Period provided'); // print_r($json);die(); if(isset($json['client_details']) && is_array($json['client_details']) && count($json['client_details'])) { $header_row = ''.' Particulars '; $first_row = ''.' Product/ Service '; $second_row = ''.' Contact Person '; $third_row = ''.' Mobile Number '; $fourth_row = ''.' Landline No '; $five_row = ''.' Payment Terms '; $siz_row = ''.' Payment Mode '; $seven_row = ''.' No of days credit '; $eight_row = ''.'Total sales done on credit'; $ninth_row = ''.'Name of the Company'; foreach ($json['client_details'] as $key => $value) { $header_row .= 'Client '.$value['client_name'].''; $first_row .= ''. $value['provider_name'] .''; $second_row .= ''. $value['contact_person_name'] .''; $third_row .= ' '. (empty($value['contact_person_mobile_no']) ? '-':$value['contact_person_mobile_no']) .' '; // $business_name_of_the_owner = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); $fourth_row .= ' '. $value['person_stdcode'].' - '.$value['person_landline'] .' '; $five_row .= ' '. (isset($value['payment_type']) ? $payment_term [ $value['payment_type'] ]: 'NA') .' '; $siz_row .= ' '. (isset($value['payment_mode']) ? $value['payment_mode'] : 'NA') .' '; $seven_row .= ' '. (isset($value['credit_period_no']) ? $value['credit_period_no'] : 'NA') .' '; $eight_row .= ' '. (isset($value['credit_total_purchase']) ? $value['credit_total_purchase'].'%' : 'NA') .' '; $ninth_row .= ' '. (isset($value['company_name']) ? $company[$value['company_name']] : 'NA') .' '; } $header_row .= ''; $first_row .= ''; $second_row .= ''; $third_row .= ''; $fourth_row .= ''; $five_row .= ''; $siz_row .= ''; $seven_row .= ''; $eight_row .= ''; $ninth_row .= ''; $json['display_data'] = array('header_row' => $header_row,'first_row' => $first_row,'second_row' => $second_row,'third_row' => $third_row,'fourth_row' => $fourth_row,'five_row' => $five_row,'siz_row' => $siz_row,'seven_row' => $seven_row,'eight_row' => $eight_row,'ninth_row'=>$ninth_row); } return $json; } static function getStockSectionData($section) { $json = json_decode($section['json'],true); $CI =&get_instance(); $CI->load->model('PD_Model'); $uom_master = $CI->PD_Model->selectCustomRecords(array('*'),array('isactive' => 1),UOM); // print_r($json);die(); if(isset($json['stock_details']) && is_array($json['stock_details']) && count($json['stock_details'])) { foreach ($json['stock_details'] as $key => $value) { if(isset($value['estimated_uom'])) { //echo $value['estimated_uom'];die(); foreach ($uom_master as $m_key => $mvalue) { if($value['estimated_uom'] == $mvalue['uom_id']) { $json['stock_details'][$key]['estimated_uom'] = $mvalue['name'];break; } } } } } //echo 'asfter'; // print_r($json);die(); return $json; } static function getExistingLoanSectionData($section) { $json = json_decode($section['json'],true); $payment_term = array('1' => 'Supply against advance payment','2' => 'Payment on Receipt of goods / service','3' => 'Payment after Credit Period provided'); // print_r($json);die(); $header_row = ''.' Particulars '; $first_row = ''.' Loan Type '; $second_row = ''.' Loan Amount '; $third_row = ''.' Availed From '; $fourth_row = ''.' Borrower`s Name '; $five_row = ''.' Instalment Amount (Rs) '; $install_fre_row = ''.' Instalment Frequency (Rs) '; $siz_row = ''.' Original Tenure (Mnts) '; $seven_row = ''.' Elapsed Tenure (Mnts) '; $eight_row = ''.' Balance Tenure (Mnts) '; foreach ($json['existing_loan_details'] as $key => $value) { $header_row .= 'Loan '.($key + 1).''; $first_row .= ''. $value['loan_type'] .''; $second_row .= ''. $value['loan_amount'] .''; $third_row .= ' '. $value['loan_taken_by'] .' '; // $business_name_of_the_owner = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); $fourth_row .= ' '. $value['lender_name'] .' '; $five_row .= ' '. (isset($value['instalment_amount']) ? $value['instalment_amount'] : 'NA') .' '; $install_fre_row .= ' '. (isset($value['instalment_frequency']) ? $value['instalment_frequency'] : 'NA') .' '; $siz_row .= ' '. (isset($value['original_tenure_months']) ? $value['original_tenure_months'] : 'NA') .' '; $seven_row .= ' '. (isset($value['elapsed_tenure_months']) ? $value['elapsed_tenure_months'] : 'NA') .' '; $eight_row .= ' '. (isset($value['current_tenure_months']) ? $value['current_tenure_months'] : 'NA') .' '; } $header_row .= ''; $first_row .= ''; $second_row .= ''; $third_row .= ''; $fourth_row .= ''; $five_row .= ''; $install_fre_row .= ''; $siz_row .= ''; $seven_row .= ''; $eight_row .= ''; $json['display_data'] = array('header_row' => $header_row,'first_row' => $first_row,'second_row' => $second_row,'third_row' => $third_row,'fourth_row' => $fourth_row,'five_row' => $five_row,'siz_row' => $siz_row,'seven_row' => $seven_row,'eight_row' => $eight_row,'install_fre_row' => $install_fre_row); return $json; } static function getNeibourSectionData($section) { $json = json_decode($section['json'],true); $applicant_details = applicantname_grabber::getLatestApplicantsName(SELF::$current_pd_id); $payment_term = array('1' => 'Supply against advance payment','2' => 'Payment on Receipt of goods / service','3' => 'Payment after Credit Period provided'); // print_r($json);die(); // $header_row = ''.' Particulars '; $first_row = ''.' Name & brief of Person
with whom check done '; $second_row = ''.' Does the person met
know who operates this business? (Yes / NO) '; $third_row = ''.' As per person met, how long has the applicants`
business been running from this location '; $owner_row = ''.' As per person met, Name of the owner(s) '; $fourth_row = ''.' Any other remarks '; $five_row = ''.' Neighbourhood Check
Positive / Negative / Could not verify '; // $siz_row = ''.' Payment Mode '; // $seven_row = ''.' No of days credit '; $colspan = 0; foreach ($json['neighbourhood_list'] as $key => $value) { // $header_row .= 'Client '.$value['client_name'].''; $first_row .= ''. $value['neighbourhood_name'] .''; $second_row .= ''. ucfirst($value['know_business_operation']) .''; $time = isset($value['how_long_do_know_in_year']) ? $value['how_long_do_know_in_year'].'Yr(s)' : '';$time .= (isset($value['how_long_do_know_in_month']) && $value['how_long_do_know_in_month'] != 0 ? (' & '.$value['how_long_do_know_in_month'].' Mnt(s)'): ''); $time = empty($time) ? '-' : $time; $third_row .= ' '. $time .' '; $owner_name = isset($value['organisation_owner']) ? applicantname_grabber::getMultipleApplicantsNameById($value['organisation_owner'],$applicant_details) : ''; $owner_row .= ''.($owner_name != '' ? $owner_name : '-').''; $colspan++; // $business_name_of_the_owner = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); // $fourth_row .= ' '. $value['how_long_do_know_in_year'].' - '.$value['how_long_do_know_in_month'] .' '; // $five_row .= ' '. (isset($value['payment_type']) ? $payment_term [ $value['payment_type'] ]: 'NA') .' '; // $siz_row .= ' '. (isset($value['payment_mode']) ? $value['payment_mode'] : 'NA') .' '; // $seven_row .= ' '. (isset($value['credit_period_no']) ? $value['credit_period_no'] : 'NA') .' '; } // $header_row .= ''; $first_row .= ''; $second_row .= ''; $third_row .= ''; $fourth_row .= ''.$json['neighbourhood_remarks'].''.''; $five_row .= ''.$json['neighbourhood_status'].''.''; // $siz_row .= ''; // $seven_row .= ''; $json['display_data'] = array('first_row' => $first_row,'second_row' => $second_row,'third_row' => $third_row,'fourth_row' => $fourth_row,'five_row' => $five_row,'owner_row' => $owner_row); return $json; } static function getAddressSectionData($section) { $json = json_decode($section['json'],true); // print_r($json);//die(); $json['address_type'] = isset($json['address_type_others']) && ($json['address_type'] == 1) ? (array('address_type' => $json['address_type_others'])):SELF::getDBvalue(ADDRESSTYPE,ADDRESSTYPEID,$json['address_type']); $json['pd_locality'] = isset($json['locality_other']) && $json['pd_locality'] == 1 ? (array('locality_name' => $json['locality_other'])) : SELF::getDBvalue(LOCALITY,LOCALITYID,$json['pd_locality']); $json['pd_location'] = SELF::getDBvalue(PDLOCATIONAPPROACH,PDLOCATIONAPPROACHID,$json['pd_location']); $json['comment_locality'] = SELF::getDBvalue(COMMENTSONLOCALITY,COMMENTSONLOCALITYID,$json['comment_locality']); $json['alternative_address'] = isset($json['alternative_address']) ? $json['alternative_address'] : ''; // die(); return $json; } static function getDBvalue($table_name,$field_name,$pk) { $CI =&get_instance(); $CI->load->model('PD_Model'); $res_data = $CI->PD_Model->selectCustomRecords(array('*'),array('isactive' => 1,$field_name => $pk),$table_name); //print_r($CI->db->last_query()); if(is_array($res_data) && count($res_data)) { return $res_data[0]; } return null; } static function getFamilySectionData($section) { $json = json_decode($section['json'],true); $applicant_details = applicantname_grabber::getLatestApplicantsName(SELF::$current_pd_id); // print_r($json);die(); if(isset($json['family_details']) && count($json['family_details'])) { foreach ($json['family_details'] as $key => $value) { $json['family_details'][$key]['relationship'] = SELF::getDBvalue(RELATIONSHIPS,RELATIONSHIPSID,$value['relationship']); $json['family_details'][$key]['stakeholder_relation'] = applicantname_grabber::getApplicantsNameById($value['stakeholder_relation'],$applicant_details); $json['family_details'][$key]['company_relation'] = SELF::getDBvalue(COMPANYRELATIONSHIPS,COMPANYRELATIONSHIPSID,$value['company_relation']); // $json[$key]['comment_locality'] = SELF::getDBvalue(COMMENTSONLOCALITY,COMMENTSONLOCALITYID,$value['comment_locality']); // $json['alternative_address'] = isset($json['alternative_address']) ? $json['alternative_address'] : ''; } } // print_r($json);die(); // die(); return $json; } static function getLoanSectionData($section) { $json = json_decode($section['json'],true); $applicant_details = applicantname_grabber::getLatestApplicantsName(SELF::$current_pd_id); // print_r($json);die(); $json['owner_name'] = isset($json['owner_name']) ? applicantname_grabber::getMultipleApplicantsNameById($json['owner_name'],$applicant_details) : ''; if(isset($json['lender'])) { $json['lender'] = SELF::getDBvalue(BTLENDERLIST,BTLENDERLISTID,$json['lender']); } $json['state'] = isset($json['state']) ? SELF::getDBvalue(STATE,STATEID,$json['state']) : ''; $json['city'] = isset($json['city']) ? SELF::getDBvalue(CITY,CITYID,$json['city']) : ''; if(isset($json['pincode'])) { $pin = $json['pincode'] != 1 ? SELF::getDBvalue(PINCODE,PINCODEID,$json['pincode']) : $json['pincode_others']; $json['pincode'] = is_array($pin) ? $pin['pincode'] : $pin; } // print_r($json);die(); return $json; } } ?>