From 73061ded23a948974a2fb86ab8bf439f81817659 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Thu, 26 Mar 2020 13:43:30 +0530 Subject: [PATCH] SAVE CUS IMG UPLAOD --- api/application/controllers/PD_Controller.php | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 614344a1..bcc362d0 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -7248,7 +7248,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { log_message('ERROR','###PDIMAGE stored in S3'.$pd_id.' - '.$form_id); - $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname,'fk_form_id'=>$form_id,'is_show_report' =>$is_show_report,'rental_count_id' => $rental_count_id,'location' => $doc['link'],'co_applicant_id' => $co_applicant_id,'img_type' => $img_type); + $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname,'fk_form_id'=>$form_id,'is_show_report' =>$is_show_report,'rental_count_id' => $rental_count_id,'location' => isset($doc['link']) ? $doc['link'] : null,'co_applicant_id' => $co_applicant_id,'img_type' => $img_type); $record_data['company_id'] = $company_id ? $company_id : null; $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); if($id != null || $id != "") { $count++; $pks[] = $id;} @@ -9489,7 +9489,65 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() public function uploadPDPhotosByApplicant_post() { $records = $this->post('records'); - print_r($records); + //print_r($records);die(); + $img_array = array(); + $current_doc_title = null; + if($records['image_key'] == 'selfie_with_person_met' || $records['image_key'] == 'person_met_id') + { + //get main applicant name + $main_applicant_name = $this->PD_Model->selectCustomRecords(array('fk_pd_id','applicant_name','pd_co_applicant_id'),array('fk_pd_id' => $records['fk_pd_id'],'applicant_type' => 1),PDAPPLICANTSDETAILS); + //print_r($main_applicant_name); + + if($records['image_key'] == 'selfie_with_person_met') + { + $img_array['img_type'] = 1; + $img_array['co_applicant_id'] = $main_applicant_name[0]['pd_co_applicant_id']; + $img_array['image'] = $records['image']; + $img_array['Name'] = $main_applicant_name[0]['applicant_name']; + $current_doc_title = $main_applicant_name[0]['applicant_name']; + } + else if($records['image_key'] == 'person_met_id') + { + $img_array['img_type'] = 2; + $img_array['co_applicant_id'] = $main_applicant_name[0]['pd_co_applicant_id'].'-id_proof'; + $img_array['image'] = $records['image']; + $img_array['Name'] = $main_applicant_name[0]['applicant_name'].'-id_proof'; + $current_doc_title = $main_applicant_name[0]['applicant_name'].'-id_proof'; + } + } + else if(strpos($records['image_key'], 'approach') !== false) + { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['name']; + $current_doc_title = $records['name']; + } + else + { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['name']; + $current_doc_title = $records['name']; + } + + // echo $current_doc_title;die(); + //de activate previous one + $this->PD_Model->updateRecords(array('isactive' => 0),PDDOCUMENTS,array('fk_pd_id' => $records['fk_pd_id'],'fk_form_id' => $records['fk_form_id'],'pd_document_title' => $current_doc_title)); + // print_r($this->db->last_query()); + $res = $this->saveBase64Images($records['fk_pd_id'],$records['fk_form_id'],$company_id = null,$rental_count_id = null,array($img_array)); + if($res) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $res; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = "Something Went Wrong! Try Later"; + $this->response($data,REST_Controller::HTTP_OK); + } + }