diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 45fb7268..483eb2cf 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -4163,6 +4163,7 @@ class PD_Controller extends REST_Controller { //get zip url from s3 if any $key = 'pd'.$pdid.'/'.$main_applicant_name.'_'.$pdid.'_'.'pd_images.zip'; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); if($pd_master_details[0]['is_zip_created']) { @@ -4175,6 +4176,7 @@ class PD_Controller extends REST_Controller { } else { + $all_pd_images = $this->PD_Model->getSignedPDDocsURL($pdid); @@ -4198,9 +4200,11 @@ class PD_Controller extends REST_Controller { $this->zip->add_data('pdimages/'.$temp_dir_name.'/'.$image['pd_document_name'],file_get_contents($image['doc_url'])); } - $this->zip->archive(APPPATH.'docs/'.$key); + $temp_path = $main_applicant_name.'_'.$pdid.'_'.'pd_images.zip'; + + $this->zip->archive(APPPATH.'docs/'.$temp_path); - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>(APPPATH.'docs/'.$key)); + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>(APPPATH.'docs/'.$temp_path)); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); //print_r($s3result); @@ -5122,8 +5126,8 @@ class PD_Controller extends REST_Controller { // $this->getPDImages_post($fields2,array('fk_pd_id'=>$pdid,'fk_form_id' => $i),PDDOCUMENTS,array(),'','company_id','ASC'); // print_r($this->db->last_query()); } - //print_r($data['pd_processed_forms'][17]); - //die(); + // print_r($data['pd_processed_forms']); + //print_r($data['pd_images']);die(); //print_r(json_decode($data['pd_processed_forms'][14][0]['processed_json'],true)); //die(); //echo "*******************************************"; @@ -5154,8 +5158,8 @@ class PD_Controller extends REST_Controller { $t = substr_replace($t,'',strpos($t,''),(strlen(''))); } - //echo $t; - //die(); + echo $t; + die(); // if (!is_dir(APPPATH.'views/pd_reports/'.$pdid)) { // $dust = mkdir(APPPATH.'views/pd_reports/'.$pdid, 0777, TRUE); @@ -6285,7 +6289,7 @@ class PD_Controller extends REST_Controller { } - //Get All Scorable Question from various PD Forms - 3 Questions Pending + //Get All Score able Question from various PD Forms - 3 Questions Pending public function seperateScoreQuestions($form_data,$OTP) { $score_questions = array(); @@ -6526,7 +6530,7 @@ class PD_Controller extends REST_Controller { foreach ($client_form['trade_details'][0]['trading_products'] as $key => $value) { - if($value['trade_product_name'] != "" && $value['trade_supplier_name'] != "" && $value['trade_product_contact_person_name'] != "" && ($value['trade_product_contact_person_mobile_number'] != "" || $value['person_landline'] != "")) + if($value['trade_product_name'] != "" && $value['trade_client_name'] != "" && $value['trade_product_contact_person_name'] != "" && ($value['trade_product_contact_person_mobile_number'] != "" || $value['person_landline'] != "")) { $client_count++; } @@ -6806,7 +6810,7 @@ class PD_Controller extends REST_Controller { } else { - echo "

DNot Found

"; + echo "

Not Found

"; } } else @@ -6815,6 +6819,8 @@ class PD_Controller extends REST_Controller { } } + + public function pdFormsCompletenessCheck_post() { $pdid = $this->post('pd_id'); @@ -6823,44 +6829,468 @@ class PD_Controller extends REST_Controller { $general_captions = array("otp_done" => "OTP authentication done >>","person_met_is_applicant" => "Is person Met, a loan applicant >>","qualification" => "Qualification of Loan Applicants >>","comment_locality" => "Comment on Locality >>","pd_location_approach" => "Approach to PD location >>","customer_behaviour" => "Customer Behaviour >>","neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>","was_the_company_name_board_sighted" => "Business Board Sighted >>","value_of_other_assets" => "Asset Value by Loan Amount % >>"); - $incomplete_details = array(); - //$form_data = array(); - // for($i = 1;$i<=30;$i++) - // { - // $fields = array('json'); - // $where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pd_id,'fk_form_id' => $i); - // $data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC'); - - // $data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pd_id,$i); - - // } + //Get all form Images - //check General form questions + $pd_images = array(); + $form_data = array(); + for($i = 1;$i<=30;$i++) + { + $pd_images[$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i); + + $fields = array('processed_json'); + $where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i); + $form_data[$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC'); + } + + $incomplete_details = array(); + // print_r($pd_images);die(); $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); - $form_data = $this->PD_Model->getScorablePDFormDetailsJSON($pdid); - $score_questions = $this->seperateScoreQuestions($form_data,$pd_master_details[0]['is_otp_done']); - print_r($score_questions);die(); - foreach ($score_questions['general'] as $g_key => $g_value) { - - //if($g_key != 'value_of_other_assets' && ($g_value == '' || $g_value == null)) - if(($g_value == '' || $g_value == null)) + + #####General Form Questions######## + $general_form = (json_decode($form_data[18][0]['processed_json'],true)); + // echo "seperateScoreQuestions"; + //print_r($general_form);die(); + + + $person_met_is_applicant_count = 0; + $person_met_selfie_count = 0; + $person_met_id_proof_count = 0; + + foreach($general_form['individuals'] as $person) + { + + if($person['is_person_met'] == true ) + { + if($person['is_person_met_pic']) { - $incomplete_details[] = $general_captions[$g_key]; + $person_met_selfie_count++; + } + + if($person['is_person_met_id_proof']) + { + $person_met_id_proof_count++; + } + } + if(($person['is_applicant'] == true && $person['is_person_met'] == true)) + { + $person_met_is_applicant_count++; + } + + } + + if(!$person_met_is_applicant_count){ $incomplete_details[] = 'General Form - Person met is not an applicant'; } + if(!$person_met_selfie_count){ $incomplete_details[] = 'General Form - Person met selfie image with PD officer'; } + if(!$person_met_id_proof_count){ $incomplete_details[] = 'General Form - Person met ID proof image'; } + #####End of General Form Questions######## + + + #####Address Form Questions######## + if(count($pd_images[5])) + { + $approach_image_count = 0; + $name_board_image_count = 0; + foreach ($pd_images[5] as $key => $value) + { + if(substr_count(strtolower($value['pd_document_title']),strtolower('Approach to PD Location'))) + { + $approach_image_count++; + } + if(substr_count(strtolower($value['pd_document_title']),strtolower('Name board Seen'))) + { + $name_board_image_count++; } } - foreach ($score_questions['business'] as $b_key => $b_value) { - - if($g_key != 'value_of_other_assets' && ($g_value == '' || $g_value == null)) + if(!$approach_image_count){ $incomplete_details[] = 'Address Form - Approach to PD location Image'; } + if(!$name_board_image_count){ $incomplete_details[] = 'Address Form - Business Name Board Image'; } + } + else + { + $incomplete_details[] = 'Address Form - Approach to PD location Image'; + $incomplete_details[] = 'Address Form - Business Name Board Image'; + } + + #####Business Form Questions######## + $business_form = (json_decode($form_data[13][0]['processed_json'],true)); + + $is_manufacturing_selected = 0; + foreach ($business_form['select_business_activity_type'] as $key => $value) { + if($value['type_of_activity_id'] == 2){ $is_manufacturing_selected = 1; } + } + // 13 - QNO(2.4) - all business certificate + $certificate_count = 0; + + + (isset($business_form['shop_eat_act_cert']) && strtoupper($business_form['shop_eat_act_cert'])=='YES' && ($business_form['shop_eat_act_cert_pic'] != "")) ? $certificate_count : $certificate_count++; + + (isset($business_form['gst_Regn_cert']) && strtoupper($business_form['gst_Regn_cert'])=='YES' && ($business_form['gst_Regn_cert_pic'] != "")) ? $certificate_count : $certificate_count++; + + (isset($business_form['pf_regn']) && strtoupper($business_form['pf_regn'])=='YES' && ($business_form['pf_regn_pic'] != "")) ? $certificate_count : $certificate_count++; + + (isset($business_form['esic_regn']) && strtoupper($business_form['esic_regn'])=='YES' && ($business_form['esic_regn_pic'] != "")) ? $certificate_count : $certificate_count++; + + (isset($business_form['export_import_cert']) && strtoupper($business_form['export_import_cert'])=='YES' && ($business_form['export_import_cert_pic'] != "")) ? $certificate_count : $certificate_count++; + + (isset($business_form['factory_cert']) && strtoupper($business_form['factory_cert'])=='YES' && ($business_form['factory_cert_pic'] != "")) ? $certificate_count : $certificate_count++; + + (isset($business_form['practice_cert']) && strtoupper($business_form['practice_cert'])=='YES' && ($business_form['practice_cert_pic'] != "")) ? $certificate_count : $certificate_count++; + + if($certificate_count){ $incomplete_details[] = 'Business Form - Images for Document Sighted Not Sufficient'; } + //echo $certificate_count; + + + #####End of Business Form Questions######## + + + #####Business Assets Form Questions######## + $business_assest_form = (json_decode($form_data[22][0]['processed_json'],true)); + $businees_assest_images_count = isset($pd_images[22][0]) ? count($pd_images[22][0]) : 0; + + if(array_key_exists('business_assets_details',$business_assest_form)) + { + + foreach($business_assest_form['business_assets_details'] as $value) + { + if($value['business_assets_mode'] == 4 && !($businees_assest_images_count)) { - $incomplete_details[] = $general_captions[$g_key]; + $incomplete_details[] = 'Business Assets Form - Machinery Image'; } + + } + } + #####End of Business Assets Form Questions######## + + #####supplier Form Questions######## + $supplier_form = isset($form_data[1][0]['processed_json'])?(json_decode($form_data[1][0]['processed_json'],true)):array(); + //print_r($supplier_form);die(); + $supplier_count = 0; + $supplier_images = isset($pd_images[1][0]) ? $pd_images[1][0] : array(); + if(!((count($business_form['select_business_activity_type']) == 1) && ($business_form['select_business_activity_type'][0]['type_of_activity_id'] == 5))) + { + if(count($supplier_form)) + { + + + if(array_key_exists('manufacturing_details',$supplier_form)) + { + if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials'])) + { + + + foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value) + { + + + if($manu_value['manufacturing_raw_material_name'] != "" && $manu_value['manufacturing_supplier_name'] != "" && $manu_value['manufacturing_contact_person_name'] != "" && ($manu_value['manufacturing_contact_person_mobile_number'] != "" || $manu_value['person_landline'] != "")) + { + $supplier_count ++; + $cureent_supplier_images_count = 0 ; + + //Images name check + $supplier_name = $manu_value['manufacturing_supplier_name'].' - Raw Material'.($manu_key+1); + + if(count($supplier_images)) + { + foreach ($supplier_images as $key => $value) + { + if( !strcasecmp($supplier_name, $value['pd_document_title'])) + { + $cureent_supplier_images_count++; + } + + + } + if($cureent_supplier_images_count < 2){ $incomplete_details[] = 'Supplier Form - '.$supplier_name.' - Image Not Sufficient';} + } + else + { + $incomplete_details[] = 'Supplier Form - '.$supplier_name.' - Image Not Sufficient'; + } + } + else + { + $incomplete_details[] = 'Supplier Form - Supplier (Raw Material '.($key+1).') Details not sufficient'; + } + } + + + } + //echo 'IN manu-'.$supplier_count; + } + + + + + if(array_key_exists('trade_details',$supplier_form)) + { + + if(isset($supplier_form['trade_details'][0]['trading_products'])) + { + + foreach ($supplier_form['trade_details'][0]['trading_products'] as $trading_key => $trading_value) + { + if($trading_value['trade_product_name'] != "" && $trading_value['trade_supplier_name'] != "" && $trading_value['trade_product_contact_person_name'] != "" && ($trading_value['trade_product_contact_person_mobile_number'] != "" || $trading_value['person_landline'] != "")) + { + $supplier_count ++; + + $cureent_supplier_images_count = 0 ; + + //Images name check + $supplier_name = $trading_value['trade_supplier_name'].' - Trading Product'.($manu_key+1); + if(count($supplier_images)) + { + foreach ($supplier_images as $key => $value) + { + if( !strcasecmp($supplier_name, $value['pd_document_title'])) + { + $cureent_supplier_images_count++; + } + } + if($cureent_supplier_images_count < 2){ $incomplete_details[] = 'Supplier Form - '.$supplier_name.' - Image Not Sufficient';} + } + else + { + $incomplete_details[] = 'Supplier Form - '.$supplier_name.' - Image Not Sufficient'; + } + } + else + { + $incomplete_details[] = 'Supplier Form - Supplier (Trading Product'.($key+1).') Details not sufficient'; + } + } + + + } + //echo 'IN trade-'.$supplier_count; + } + + + + + } + + if(!$supplier_count){ $incomplete_details[] = 'Supplier Form - supplier informations not Sufficient'; } + } + + //echo $score_questions['business']['minimum_supplier_info'];die(); + #####End of supplier Form Questions######## + + + #####client Form Questions######## + $client_form = isset($form_data[2][0]['processed_json'])?(json_decode($form_data[2][0]['processed_json'],true)):array(); + $client_images = isset($pd_images[2][0]) ? $pd_images[2][0] : array(); + $client_count = 0; + if(count($client_form)) + { + + + if(array_key_exists('manufacturing_details',$client_form)) + { + if(isset($client_form['manufacturing_details'][0]['main_raw_materials'])) + { + + foreach ($client_form['manufacturing_details'][0]['main_raw_materials'] as $key => $value) + { + if($value['manufacturing_product_name'] != "" && $value['manufacturing_client_name'] != "" && $value['manufacturing_contact_person_name'] != "" && ($value['manufacturing_contact_person_mobile_number'] != "" || $value['person_landline'] != "")) + { + $client_count++; + $current_client_images_count = 0 ; + + //Images name check + $client_name = $value['manufacturing_client_name'].' - Manufacturing Product '.($key+1); + + if(count($client_images)) + { + foreach ($client_images as $key => $value) + { + if( !strcasecmp($client_name, $value['pd_document_title'])) + { + $current_client_images_count++; + } + } + if($current_client_images_count < 2){ $incomplete_details[] = 'Client Form - '.$client_name.' - Image Not Sufficient';} + } + else + { + $incomplete_details[] = 'Client Form - '.$client_name .'- Image Not Sufficient'; + } + + } + else + { + $incomplete_details[] = 'Client Form - Client (Manufacturing Product'.($key+1).') Details not sufficient'; + } + } + } + } + + if(array_key_exists('trade_details',$client_form)) + { + + if(isset($client_form['trade_details'][0]['trading_products'])) + { + + foreach ($client_form['trade_details'][0]['trading_products'] as $key => $value) + { + if($value['trade_product_name'] != "" && $value['trade_supplier_name'] != "" && $value['trade_product_contact_person_name'] != "" && ($value['trade_product_contact_person_mobile_number'] != "" || $value['person_landline'] != "")) + { + $client_count++; + $current_client_images_count = 0 ; + + //Images name check + $client_name = $value['trade_supplier_name'].' - Trading Product '.($key+1); + + if(count($client_images)) + { + foreach ($client_images as $key => $value) + { + if( !strcasecmp($client_name, $value['pd_document_title'])) + { + $current_client_images_count++; + } + } + if($current_client_images_count < 2){ $incomplete_details[] = 'Client Form - '.$client_name.' - Image Not Sufficient';} + } + else + { + $incomplete_details[] = 'Client Form - '.$client_name .'- Image Not Sufficient'; + } + } + else + { + $incomplete_details[] = 'Client Form - Client (Trading Product'.($key+1).') Details not sufficient'; + } + } + + } + } + + if(array_key_exists('service_provider_details',$client_form)) + { + if(isset($client_form['service_provider_details'][0]['service_products'])) + { + foreach ($client_form['service_provider_details'][0]['service_products'] as $key => $value) + { + + if($value['service_provider_product_name'] != "" && $value['service_provider_client_name'] != "" && $value['service_provider_product_contact_person_name'] != "" && ($value['service_provider_product_contact_person_mobile_number'] != "" || $value['person_landline'] != "")) + { + $client_count++; + $current_client_images_count = 0 ; + + //Images name check + $client_name = $value['service_provider_client_name'].' - Service Provider '.($key+1); + + if(count($client_images)) + { + foreach ($client_images as $key => $value) + { + if( !strcasecmp($client_name, $value['pd_document_title'])) + { + $current_client_images_count++; + } + } + if($current_client_images_count < 2){ $incomplete_details[] = 'Client Form - '.$client_name.' - Image Not Sufficient';} + } + else + { + $incomplete_details[] ='Client Form - ' .$client_name .'- Image Not Sufficient'; + } + + } + else + { + $incomplete_details[] = 'Client Form - Client (Service Provider'.($key+1).') Details not sufficient'; + } + } + + } + } + + } + + #####End of client Form Questions######## + + + #####Stock Form Questions######## + $stock_form = isset($form_data[11][0]['processed_json'])?(json_decode($form_data[11][0]['processed_json'],true)):array(); + //print_r($stock_form); + if(count($stock_form)) + { + //print_r($stock_form);die(); + if(isset($stock_form['manufacturing_details']) && ($stock_form['manufacturing_details'] != null || $stock_form['manufacturing_details'] != "")) + { + + // if( strcasecmp($stock_form['manufacturing_details'][0]['is_sufficiant_raw'],'not applicable') && strcasecmp($stock_form['is_sufficiant_finished_and_traded_goods'],'not applicable')) + // { + // echo 'Yes'; + // // if( !(isset($pd_images[11][0]) ))//&& !count($pd_images[11][0])) ) + // // { + // // $incomplete_details[] = 'Stock Form - Images not sufficient'; + // // } + // } + // else + // { + + $total_stock_observed = 0; + + if( isset($stock_form['manufacturing_details'][0]['manufacturing_raw_materials']) && count($stock_form['manufacturing_details'][0]['manufacturing_raw_materials'])) + { + foreach ($stock_form['manufacturing_details'][0]['manufacturing_raw_materials'] as $key => $value) + { + //echo strcasecmp($value['stock_observed'],'no');die(); + + if((strcasecmp($value['stock_observed'],'no'))) { $total_stock_observed++; } + + } + } + + + if( isset($stock_form['manufacturing_details'][0]['manufacturing_finished_goods']) && count($stock_form['manufacturing_details'][0]['manufacturing_finished_goods'])) + { + foreach ($stock_form['manufacturing_details'][0]['manufacturing_finished_goods'] as $key => $value) + { + if((strcasecmp($value['goods_observed'],'no'))) { $total_stock_observed++; } + + } + } + + + if( isset($stock_form['retail_details'][0]['retail_traded_goods']) && count($stock_form['retail_details'][0]['retail_traded_goods'])) + { + foreach ($stock_form['retail_details'][0]['retail_traded_goods'] as $key => $value) + { + if((strcasecmp($value['traded_goods_observed'],'no'))) { $total_stock_observed++; } + + } + } + + if( isset($stock_form['trade_details'][0]['trading_traded_goods']) && count($stock_form['trade_details'][0]['trading_traded_goods'])) + { + foreach ($stock_form['trade_details'][0]['trading_traded_goods'] as $key => $value) + { + if((strcasecmp($value['traded_goods_observed'],'no'))) { $total_stock_observed++; } + + } + } + + //echo $total_stock_observed;die(); + if( $total_stock_observed != 0 && !(isset($pd_images[11][0]) ))//&& !count($pd_images[11][0])) ) + { + $incomplete_details[] = 'Stock Form - Images not sufficient'; + } + //} + } + } - print_r($incomplete_details);die(); - + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $incomplete_details; + $data['msg'] = count($incomplete_details) ? 'PD forms are incomplete' : 'All forms were answered'; + $this->response($data,REST_Controller::HTTP_OK); + } diff --git a/api/application/helpers/businessform_helper.php b/api/application/helpers/businessform_helper.php index b1f91b2c..0b6c5c5f 100644 --- a/api/application/helpers/businessform_helper.php +++ b/api/application/helpers/businessform_helper.php @@ -394,7 +394,7 @@ public static function getActivityDetails($values,$type){ // get business peak period details public static function getBusinessPeakDetails($details){ - $getRow='The Business has maximum sales/services during,'; + $getRow='The Business has lower sales/services during,'; $getRow.= count($details) >1 ?' the periods of ' :' the period of '; foreach($details as $key=>$value){ $getRow=$getRow; diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index bd91aa39..ddb56641 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -1671,7 +1671,7 @@ class PD_Model extends SPARQ_Model { $return_data[$value] = $data; } } - // print_r($return_data);die(); + return $return_data; } diff --git a/api/application/views/report_templates/JSONTOREPORT.php b/api/application/views/report_templates/JSONTOREPORT.php index 9289d047..f5e2869a 100644 --- a/api/application/views/report_templates/JSONTOREPORT.php +++ b/api/application/views/report_templates/JSONTOREPORT.php @@ -885,11 +885,17 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $business_assets_details = json_decode($pd_processed_forms[22][0]['processed_json'],true); $address_images = $pd_images[5]; + print_r($address_images);die(); $pd_location_approach_img_url = ''; + $pd_location_approach_img_location = ''; + $pd_location_approach_img_date = ''; + foreach ($address_images as $address_image_key => $address_image_value) { if($address_image_value['is_show_report'] == 1) { $pd_location_approach_img_url = $address_image_value['doc_url']; + $pd_location_approach_img_location = $address_image_value['location']; + $pd_location_approach_img_date = date('Y/m/d h:s:i A',$address_image_value['createdon']); break; } } @@ -917,6 +923,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Name Board + '.$pd_location_approach_img_date; ?>

Location Summary

@@ -2290,7 +2297,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''; echo ''; echo ''; //unset($stock_photo_count[$stock_photo_iter]); @@ -2505,7 +2512,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''; echo ''; echo ''; //unset($stock_photo_count[$stock_photo_iter]); @@ -2705,7 +2712,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''; echo ''; echo ''; //unset($stock_photo_count[$stock_photo_iter]);