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 $json = json_decode($section['json'],true); if(isset($json['business_entity'])){ for($i=0;$i $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); // print_r($json); $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) { $json['business_assets_details'][$key]['business_assets_mode_name'] = ( $value['business_assets_mode'] == 1 ? $value['other_asset_description'] : $asset_type [ $value['business_assets_mode'] ]); $json['business_assets_details'][$key]['business_owner_name'] = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); $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) { $json['supplier_details'][$key]['name_of_the_company'] = (isset($value['company_name']) ? $company[$value['company_name']] : 'NA'); $json['supplier_details'][$key]['type_of_payment'] = (isset($value['payment_type']) ? $payment_term [ $value['payment_type'] ]: 'NA'); $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) { $json['client_details'][$key]['name_of_the_company'] = (isset($value['company_name']) ? $company[$value['company_name']] : 'NA'); $json['client_details'][$key]['type_of_payment'] = (isset($value['payment_type']) ? $payment_term [ $value['payment_type'] ]: 'NA'); $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,$company) { $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['company_name'])) { $json['stock_details'][$key]['name_of_the_company'] = (isset($value['company_name']) ? $company[$value['company_name']] : 'NA'); } 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) { $json['existing_loan_details'][$key]['lender_name'] = ((isset($value['lender_name']) && $value['lender_name'] != 0) ? $value['lender_name'] : 'NA'); $json['existing_loan_details'][$key]['business_owner_name'] = (isset($value['business_name_of_the_owner']) ? (applicantname_grabber::getApplicantsNameById($value['business_name_of_the_owner'],$applicant_details)): 'NA'); $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); $json['owner_name'] = isset($json['owner_name']) && !empty($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; } static function getFinalRemarksSectionData($section) { $json = json_decode($section['json'],true); $customer_behaviour = array("1" => 'Others',"2" => 'Rude',"3" => 'Polite'); $pd_officer_recommandations = array("2"=>'Positive',"3"=>'Negative',"5"=>'Refer to Credit',"0"=>'Others'); $json['pd_officer_recommendation_name'] = isset($json['pd_officer_recommendation'])? $pd_officer_recommandations[$json['pd_officer_recommendation']] : 'NA'; $json['customer_behaviour_name'] = (isset($json['customer_behaviour']) ? $customer_behaviour[ $json['customer_behaviour'] ] : 'NA'); // echo 'json***'; // print_r($json); return $json; } public static function covertSMCImgs2ZIP($pdid,$random_string,$pd_master_details = array(),$regenerate = 0) { $CI =&get_instance(); $CI->load->model('PD_Model'); if(!count($pd_master_details)) { $pd_master_details = $CI->PD_Model->getPDMasterDetails($pdid,$random_string,$pd_master_details); } if(!file_exists($CI->external_path.'/pd_reports/'.$pdid)) { mkdir($CI->external_path.'/pd_reports/'.$pdid,0777); } $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; $main_applicant_name = $pd_master_details[0]['main_applicant']; //get zip url from s3 if any $key = 'pd'.$pdid.'/'.$main_applicant_name.'_'.$pdid.'_'.'pd_images.zip'; //$singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); if($pd_master_details[0]['is_zip_created'] && ($regenerate == 0)) { return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); // $response_data['dataStatus'] = true; // $response_data['status'] = REST_Controller::HTTP_OK; // $response_data['records'] = $singed_uri; // $CI->response($response_data,REST_Controller::HTTP_OK); 9344876517 } else { $all_pd_images = $CI->PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1 ),SMC_CREDIT_PD_DOCS); if(count($all_pd_images)>0){ // $all_form_names = array('pd_form_id'=>19,'pd_form_name'=>"photograph"); // $form_name[19] = "photograph"; //Generate zip file $CI->load->library('zip'); $CI->zip->add_dir('pdimages'); $is_this_multiple_image = array('property_images','supplier_image','stock_image','client_image','additional_photograph'); $cl=1;$st=1;$su=1;$pr=1;$ad=1;//$first2character flag don't Deleted it. foreach($all_pd_images as $image) { $temp_dir_name = 'Common'; $doc_name = str_replace(':', '-', $image['img_name']); $src_local_file = XLPATH.'/tmp/'.$doc_name.'.png'; $ifp = fopen( $src_local_file, 'wb' ); $img = explode( ',', $image['img'] ); // fwrite( $ifp, base64_decode( $img[ 1 ] ) ); if($doc_name == "satellite"){ fwrite( $ifp, base64_decode($image['img']) ); }else{ fwrite( $ifp, base64_decode( $img[ 1 ] ) ); } fclose( $ifp ); $MyFile = file_get_contents($src_local_file); if( in_array($image['img_name'] ,$is_this_multiple_image)) { $first2character = substr($image['img_name'], 0, 2); $char = ${$first2character}; $doc_name = $image['img_name']."_".$char; ${$first2character}++; } $CI->zip->add_data('pdimages/'.$doc_name.'.png',$MyFile); unlink($src_local_file); } $temp_path = $main_applicant_name.'_'.$pdid.'_'.'pd_images.zip'; $CI->zip->archive($CI->external_path.'/pd_reports/'.$pdid.'/'.$temp_path); $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($CI->external_path.'/pd_reports/'.$pdid.'/'.$temp_path)); $s3result= $CI->aws_s3->uploadFileToS3Bucket($bucket_data); //print_r($s3result); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { //$result_array[0]['content'] $where_condition_array = array("pd_id" => $pdid); $temp_array['is_zip_created'] = 1; $id = $CI->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); unlink($CI->external_path.'/pd_reports/'.$pdid.'/'.$temp_path); } return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); }else return ""; } } public static function covertSMCImgs2PDF($pdid,$random_string,$pd_master_details = array(),$regenerate = 0) { $CI =&get_instance(); $CI->load->model('PD_Model'); $CI->load->model('SMC_Credit_PD_Model'); $CI->load->library('pdfgenerator'); if(!count($pd_master_details)) { $pd_master_details = $CI->PD_Model->getPDMasterDetails($pdid,$random_string); } set_time_limit(60); $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; $main_applicant_name = $pd_master_details[0]['main_applicant']; //get zip url from s3 if any $key = 'pd'.$pdid.'/'.$main_applicant_name.'_'.$pdid.'_'.'pd_images.pdf'; //$singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); if($pd_master_details[0]['is_img_pdf_created'] && ($regenerate == 0)) { return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+7 days'); } else { $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1),SMC_CREDIT_PD_DOCS); // $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1),SMC_CREDIT_PD_DOCS); if(count($all_pd_images)>0){ $data_to_view['all_pd_images'] = $all_pd_images; $img_pdf_data = $CI->load->view('report_templates/PDSMCIMG_PDF',$data_to_view,true); //print_r($img_pdf_data);die(); $pdf_doc = $CI->pdfgenerator->generate($img_pdf_data, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file2 = $CI->external_path ."/pd_reports/" . $pdid . "/pd_images_pdf.pdf"; $ti = file_put_contents($output_file2, $pdf_doc); //echo $ti;die(); $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($output_file2)); $s3result= $CI->aws_s3->uploadFileToS3Bucket($bucket_data); //print_r($s3result); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { //$result_array[0]['content'] $where_condition_array = array("pd_id" => $pdid); $temp_array['is_img_pdf_created'] = 1; $id = $CI->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); unlink($output_file2); } return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+7 days'); } else return ""; } } } ?>