From 0f6f654ba9b5f7764a762facff477a3664bdcd95 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Fri, 26 Jun 2020 00:27:36 +0530 Subject: [PATCH] SMART PD FLOW 3 --- api/application/config/routes.php | 1 + api/application/controllers/PD_Controller.php | 93 +++++++++++++++++-- api/application/libraries/AWS_S3.php | 8 +- 3 files changed, 92 insertions(+), 10 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 16d6d30a..0c780c51 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -253,6 +253,7 @@ $route['renewSatellite'] = 'PD_Controller/renewSatellite'; $route['uploadPDImgByApplicant'] = 'PD_Controller/uploadPDPhotosByApplicant'; $route['getPDImgDetails'] = 'PD_Controller/getPDImgDetails'; $route['updateVendorStatus'] = 'PD_Controller/updateVendorStatus'; +$route['getVendorAnswers'] = 'PD_Controller/getVendorAnswers'; //$route['getTypeOfActivetyFromBusinessJSON'] = 'PD_Controller/getTypeOfActivetyFromBusinessJSON'; //Dashboard and Reports Related routes diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 1a23c0f7..1c903adc 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -5971,7 +5971,7 @@ public function getPDFormDetailsJSON_post() { //print_r($this->aws_s3->getAllObjectsInaBucket('test-lender1','pd114'));die(); - //print_r($this->aws_s3->copyS3Object('test-lender1','test-lender1','pd114','pd114-copy'));die(); + print_r($this->aws_s3->copyS3Object('test-lender1','test-lender1','pd114','pd114-copy'));die(); //satellite_image::getSatelliteImage(1704);die(); //echo $this->assignPDTempalate(1325);die(); //$this->getSatelliteImage(342);die();//velmurugan.s@venbainfotech.com @@ -6174,7 +6174,7 @@ public function getPDFormDetailsJSON_post() // $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(json_decode($data['pd_processed_forms'][18][0]['processed_json']));die(); + //print_r(json_decode($data['pd_processed_forms'][13][0]['processed_json']));die(); $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid,null,null,'common',null,'report'); if($data['pd_master_details'][0]['customer_segment_abbr'] == "SAL") { @@ -7373,7 +7373,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $record_data['company_id'] = $company_id ? $company_id : null; $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); if($id != null || $id != "") { $count++; $pks[] = $id;} - $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,$time = '+15 minutes'); + $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,$time = '+30 days'); //print_r($uri); } @@ -9556,7 +9556,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $fk_createdby = $this->post('fk_createdby'); $new_pd_id = null; + // $logger = MYLOG::logFunction(null,$pd_id); + // $logger->info("duplicatePD_post called: ".$pd_id,array('ENV'=>ENVIRONMENT,'DATA' => $lender_applicant_id)); // Get All PD Masters Details + + log_message('ERROR','####duplicatePD_post called:-'.$pdid.'-'.$lender_applicant_id); $pd_master_details = $this->PD_Model->selectCustomRecords(array('*'),array('pd_id' => $pdid),PDTRIGGER); if(count($pd_master_details)) @@ -9589,6 +9593,8 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() //print_r($pd_master_details); //$new_pd_id = $this->PD_Model->saveRecords($pd_master_details,PDTRIGGER); + //$logger->info("NEW PD Trigged by dup funciton : ".$new_pd_id,array('ENV'=>ENVIRONMENT)); + log_message('ERROR','####NEW PD Trigged by dup funciton:-'.$new_pd_id); } @@ -9600,12 +9606,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() //print_r($applicants_details); if(!$new_pd_id && count($applicants_details)) { + log_message('ERROR','####Copying Applicants started:-'.$new_pd_id); foreach ($applicants_details as $key => $value) { $value['fk_pd_id'] = $new_pd_id; $this->PD_Model->saveRecords($value,PDAPPLICANTSDETAILS); //print_r($value); } + log_message('ERROR','####Copying Applicants end:-'.$new_pd_id); } @@ -9613,37 +9621,49 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $pd_documnets = $this->PD_Model->selectCustomRecords(array('fk_pd_id','fk_form_id', 'co_applicant_id', 'img_type', 'pd_document_title', 'pd_document_name','company_id', 'is_show_report', 'rental_count_id','location', 'isactive'),array('isactive' => 1,'fk_pd_type' => $pdid),PDDOCUMENTS); if(!$new_pd_id && count($applicants_details)) { + log_message('ERROR','####Copying ALl Images started:-'.$new_pd_id); foreach ($pd_documnets as $key => $value) { $value['fk_pd_id'] = $new_pd_id; $this->PD_Model->saveRecords($value,PDDOCUMENTS); //print_r($value); } + log_message('ERROR','####Copying All Images END:-'.$new_pd_id); + + log_message('ERROR','####Copying S3 started:-'.$new_pd_id); + + log_message('ERROR','####Copying S3 END:-'.$new_pd_id); } + + //Get All PD Address $pd_address = $this->PD_Model->selectCustomRecords(array('addressline1', 'fk_city', 'fk_state', 'pincode', 'isactive', 'is_visited','other_pincode', 'is_primary'),array('isactive' => 1,'fk_pd_id' => $pdid),PDADDRESS); if(!$new_pd_id && count($pd_address)) { + log_message('ERROR','####Copying address started:-'.$new_pd_id); foreach ($pd_address as $key => $value) { $value['fk_pd_id'] = $new_pd_id; $this->PD_Model->saveRecords($value,PDADDRESS); //print_r($value); } + log_message('ERROR','####Copying address end:-'.$new_pd_id); } //Get Addtional Requirements details $pd_additional_requirements = $this->PD_Model->selectCustomRecords(array('add_requirement','isactive'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDADDTIONALREQUIREMENTS); if(!$new_pd_id && count($pd_additional_requirements)) { + log_message('ERROR','####Copying Additional Req started:-'.$new_pd_id); foreach ($pd_additional_requirements as $key => $value) { $value['fk_pd_id'] = $new_pd_id; $this->PD_Model->saveRecords($value,PDADDTIONALREQUIREMENTS); //print_r($value); } + log_message('ERROR','####Copying Addtional Req end:-'.$new_pd_id); } @@ -9651,12 +9671,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $docs_to_be_collected = $this->PD_Model->selectCustomRecords(array('doc_name'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDDOCSTOBECOLLECTED); if(!$new_pd_id && count($docs_to_be_collected)) { + log_message('ERROR','####Copying Docs to be collected started:-'.$new_pd_id); foreach ($docs_to_be_collected as $key => $value) { $value['fk_pd_id'] = $new_pd_id; $this->PD_Model->saveRecords($value,PDDOCSTOBECOLLECTED); //print_r($value); } + log_message('ERROR','####Copying Docs to be collected end:-'.$new_pd_id); } @@ -9664,19 +9686,21 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $json_data = $this->PD_Model->getAllJSONFormData($pdid); if(!$new_pd_id && count($json_data)) { + log_message('ERROR','####Copying All JSON Data started:-'.$new_pd_id); foreach ($json_data as $key => $value) { $value['fk_pd_id'] = $new_pd_id; $this->PD_Model->saveRecords($value,PDFORMDETAILSJSON); //print_r($value); } + log_message('ERROR','####Copying ALL JSON END:-'.$new_pd_id); } + //copy all s3 into new pd folder - // $logger = MYLOG::logFunction(null,$pd_id); - // $logger->info("NEW PD Trigged : ".$pd_id,array('ENV'=>ENVIRONMENT,'DATA' => $pd_details)); + // PDALERTS::pdnotification($pd_id); @@ -9739,7 +9763,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $record_data['pd_document_name'] = $temp_file_name; $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,$time = '+15 minutes'); + $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,$time = '+30 days'); if($id) { $data['dataStatus'] = true; @@ -9791,6 +9815,63 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() } } + + public function getVendorAnswers_post() + { + //print_r($this->post()); + $fk_pd_id = $this->post('fk_pd_id'); + $fk_form_id = $this->post('fk_form_id'); + + $vendor_pd_form = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $fk_pd_id, 'fk_form_id' => 25,'isactive' => 1),PDFORMDETAILSJSON); + if(count($vendor_pd_form)) + { + $business_forms = array(1,2,13,14,11,16,21,22,23); + $vendor_pd_form = json_decode($vendor_pd_form[0]['json'],true); + $is_business_form = in_array($fk_form_id,$business_forms); + //print_r($vendor_pd_form['questions']);die(); + foreach ($vendor_pd_form['questions'] as $key => $value) + { + if($is_business_form && is_string($value['form_id']) && !strcasecmp($value['form_id'],'BUSINESS_GROUP')) + { + //echo 'busienss';break; + //print_r($value);die(); + foreach ($value['business_group'] as $bkey => $bvalue) + { + + if($bvalue['form_id'] == $fk_form_id) + { + //echo 'nor';break; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $bvalue; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + + } + else if($value['form_id'] == $fk_form_id) + { + //echo 'nor';break; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $value; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Vendor Form Not Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } + } diff --git a/api/application/libraries/AWS_S3.php b/api/application/libraries/AWS_S3.php index c0cf8b8e..7d533a3a 100644 --- a/api/application/libraries/AWS_S3.php +++ b/api/application/libraries/AWS_S3.php @@ -137,9 +137,9 @@ class AWS_S3 // echo "Keys retrieved!" ; // //print_r($objects); - foreach ($objects as $object) { - print_r($object) ; - } + // foreach ($objects as $object) { + // print_r($object) ; + // } } catch (S3Exception $e) { echo $e->getMessage() . PHP_EOL; } @@ -220,7 +220,7 @@ return $result; // Copy an object. $res = $this->S3->copyObject([ 'Bucket' => $targetBucket, - 'Key' => $tagetKeyname.'.png', + 'Key' => $tagetKeyname.'/'.$tagetKeyname.'.png', 'CopySource' => $sourceBucket.'/'.$sourceKeyname.'/v4MLA2019-01-12-18:01:21.png' ]);