FI PD photo : ps
This commit is contained in:
parent
f128004017
commit
f7f2100e6f
@ -342,7 +342,9 @@ $route['getBuinessGroupForms'] = 'Template_Management_Controller/getBuinessGroup
|
||||
$route['getCompaniesListsForBusinessV2'] = 'PD_Controller/getCompaniesListsFromGeneralFormRawJSONV2';
|
||||
|
||||
// $route['getFIPDTemplate'] = 'Template_Management_Controller/getFIPDTemplate';
|
||||
$route['getFIPDFormsDetails'] = 'Template_Management_Controller/getFIPDFormsDetails';
|
||||
$route['getFIPDImgDetails'] = 'Template_Management_Controller/getFIPDPhotograph';
|
||||
$route['saveFIPDImg'] = 'Template_Management_Controller/saveFIPDPhotograph';
|
||||
|
||||
$route['FIformWiseTemplate'] = 'Template_Management_Controller/FIformWiseTemplate';
|
||||
$route['loadFiTemplate'] = 'Template_Management_Controller/loadFiTemplate';
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ class Template_Management_Controller extends REST_Controller {
|
||||
parent::__construct();
|
||||
$this->load->model('PD_Model');
|
||||
$this->load->model('Template_Management_Model');
|
||||
$this->external_path = $this->config->item('external_data_path');
|
||||
|
||||
}
|
||||
|
||||
@ -1690,64 +1691,186 @@ class Template_Management_Controller extends REST_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// public function getFIPDForms_get()
|
||||
// {
|
||||
public function saveFIPDPhotograph_post()
|
||||
{
|
||||
|
||||
// $PDtype_id = $this->get('pd_type_id');
|
||||
// $FItype_id = $this->get('fi_id');
|
||||
// if($PDtype_id == 4){
|
||||
// if(!empty($FItype_id)){
|
||||
// // $field_investigation = array(array("field_investigation_id"=> 1,"field_investigation"=> "Office Visit (DI)"),array("field_investigation_id"=> 2,"field_investigation"=> "Office Visit (Sal)"),array("field_investigation_id"=> 3,"field_investigation"=> "Residence Visit"));
|
||||
// if($FItype_id == 1){
|
||||
$records = $this->post('records');
|
||||
if ($records['pd_document_id'] != null && $records['pd_document_id'] != "") {
|
||||
$where_condition_array = array('pd_document_id' => $records['pd_document_id']);
|
||||
$to_update = array("pd_image_alias_name" => $records['pd_image_alias_name']);
|
||||
$res['count'] = $this->PD_Model->updateRecords($to_update, PDDOCUMENTS, $where_condition_array);
|
||||
$res['msg'] = "Updated";
|
||||
$data['uri'] = null;
|
||||
}else if($records['pd_document_id'] == "") {
|
||||
$res = $this->saveBase64Images($records);
|
||||
}
|
||||
if (!empty($res)) {
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['uri'] = $res['records'];
|
||||
$data['msg'] = $res['msg'];
|
||||
$this->response($data, REST_Controller::HTTP_OK, true);
|
||||
} else {
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Something Went Wrong!';
|
||||
$this->response($data, REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
// }else if($FItype_id == 2){
|
||||
public function saveBase64Images($data)
|
||||
{
|
||||
$pd_id = $data['pd_id'];
|
||||
$form_id = $data['formid'];
|
||||
log_message('ERROR', '###FI-PDIMAGE saveBase64Images function called' . $pd_id . ' - ' . $form_id);
|
||||
$count = 0;
|
||||
$result = array();
|
||||
$pks = array();
|
||||
$uri = null;
|
||||
$pd_details = $this->PD_Model->getPDMasterDetails($pd_id);
|
||||
//print_r($data);die();
|
||||
EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_id);
|
||||
$this->location_for_watermark = $data['location'];
|
||||
$temp_base64_string = $data['image'];
|
||||
$is_show_report = isset($data['is_show_report']) ? $data['is_show_report'] : null;
|
||||
|
||||
$output_file = $this->external_path . "/pd_reports/" . $pd_id . "/temp_base64_image.jpeg";
|
||||
$this->temp_path_for_watermark = $output_file;
|
||||
|
||||
// }else if($FItype_id == 3){
|
||||
//Generate Random File Name
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
$temp_file_name = $randomString . date('Y-m-d-H-i-s') . '.jpeg';
|
||||
|
||||
// }
|
||||
log_message('ERROR', '###FI-PDIMAGE writing started' . $pd_id . ' - ' . $form_id);
|
||||
$ifp = fopen($output_file, 'wb');
|
||||
$temp_data = explode(',', $temp_base64_string);
|
||||
fwrite($ifp, base64_decode($temp_data[1]));
|
||||
fclose($ifp);
|
||||
log_message('ERROR', '###FI-PDIMAGE writing done' . $pd_id . ' - ' . $form_id);
|
||||
|
||||
// }
|
||||
// else{
|
||||
// $data['dataStatus'] = false;
|
||||
// $data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
// $data['msg'] = 'Field Investigation id is Not available';
|
||||
// $this->response($data,REST_Controller::HTTP_OK);
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// $data['dataStatus'] = false;
|
||||
// $data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
// $data['msg'] = 'Its not a FI PD Type';
|
||||
// $this->response($data,REST_Controller::HTTP_OK);
|
||||
// }
|
||||
log_message('ERROR', '###FI-PDIMAGE uploading to S3' . $pd_id . ' - ' . $form_id);
|
||||
$tempdoc = $output_file;
|
||||
$tempdocname = $temp_file_name;
|
||||
$bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_details[0]['fk_lender_id'];
|
||||
$key = 'pd' . $pd_id . '/' . $tempdocname;
|
||||
$sourcefile = $tempdoc;
|
||||
|
||||
$bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile);
|
||||
|
||||
//this line make this bucket data values in obj level so can access in helpers and hook files
|
||||
$this->bucket_data_for_watermark = $bucket_data;
|
||||
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
|
||||
if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) {
|
||||
log_message('ERROR', '###FI-PDIMAGE stored in S3' . $pd_id . ' - ' . $form_id);
|
||||
$record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => (isset($data['pd_document_title']) ? $data['pd_document_title'] : null), 'pd_document_name' => $tempdocname, 'fk_form_id' => $form_id, 'is_show_report' => $is_show_report, 'location' => isset($data['location']) ? $data['location'] : null, 'img_type' => (isset($data['img_type']) ? $data['img_type'] : null), 'image_key' => (isset($data['image_key']) ? $data['image_key'] : null), "pd_image_alias_name" => (isset($data['pd_image_alias_name']) ? $data['pd_image_alias_name'] : null));
|
||||
$id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS);
|
||||
$uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week');
|
||||
$this->img_url_for_watermark = $uri;
|
||||
}
|
||||
|
||||
// $fields = array('form_id');
|
||||
// $where_condition_array = array('fk_template_id'=>$template_id,'isactive'=>1);
|
||||
// $result_array = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATEFORMS);
|
||||
// //print_r($this->db->last_query());
|
||||
// $temp = array();
|
||||
// foreach($result_array as $r)
|
||||
// {
|
||||
// $formid = $r['form_id'];
|
||||
// $temp = array_merge($temp,array($formid));
|
||||
// }
|
||||
|
||||
// if(count($result_array))
|
||||
// {
|
||||
// $data['dataStatus'] = true;
|
||||
// $data['status'] = REST_Controller::HTTP_OK;
|
||||
// $data['records'] = $temp;
|
||||
// $this->response($data,REST_Controller::HTTP_OK);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $data['dataStatus'] = false;
|
||||
// $data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
// $data['msg'] = 'No Data Available';
|
||||
// $this->response($data,REST_Controller::HTTP_OK);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
if ($id) {
|
||||
log_message('ERROR', '###FI-PDIMAGE Saved Sucessfully ID '.$id);
|
||||
//$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id));
|
||||
$result['status'] = true;
|
||||
$result['id'] = $id;
|
||||
$result['records'] = $uri;
|
||||
$result['msg'] = "Images Saved Successfully";
|
||||
} else {
|
||||
//$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id));
|
||||
$result['status'] = true;
|
||||
$result['msg'] = "Images Not Saved!";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function FIPDPhotograph_get(){
|
||||
|
||||
$pd_id = $this->get('pd_id');
|
||||
$form_id = "34"; // FI photograph HardCoded.
|
||||
if(!empty($pd_id)){
|
||||
$fields = array('json');
|
||||
$where_condition_array = array("fk_form_id"=>$form_id,"fk_pd_id"=>$pd_id,'isactive'=>1);
|
||||
$form_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
|
||||
// $file = $this->external_path . '/pd_reports/tmp/1.txt'; // testing purpose;
|
||||
if(count($form_table)>0){
|
||||
// if(1){
|
||||
$json = json_decode($form_table[0]['json'],true);
|
||||
// $json = $this->getArr(); // testing purpose;
|
||||
// print_r($json);die(); // testing purpose;
|
||||
$pd_master = $this->PD_Model->selectCustomRecords(array('pd_id', 'random_string','fk_lender_id'), array('pd_id' => $pd_id ), PDTRIGGER);
|
||||
$pd_docs = $this->PD_Model->selectCustomRecords(array('pd_document_id', 'fk_pd_id', 'fk_pd_detail_id', 'fk_form_id', 'co_applicant_id', 'img_type', 'image_key', 'pd_document_title', 'pd_document_name', 'pd_image_alias_name', 'createdon', 'fk_createdby', 'updatedon', 'fk_updatedby', 'company_id', 'is_show_report', 'is_name_editable', 'rental_count_id', 'location', 'isactive', 'retake_flag'), array('fk_pd_id' => $pd_id, 'fk_form_id' =>$form_id, 'pd_document_title != ""' =>null), PDDOCUMENTS);
|
||||
|
||||
if(count($pd_docs)>0){
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX . $pd_master[0]['fk_lender_id'];
|
||||
// $imgs = array('selfie_with_person_met' => array('is_multiple' => 0,'img_name' => 'Selfie of the person contacted'),'name_board_seen' => array('is_multiple' => 1,'img_name' => 'Business Name Board'),'stock_image' => array('is_multiple' => 1,'img_name' => 'Stock Images'),'workplace_interior_image' => array('is_multiple' => 1,'img_name' => 'Work Place Interior'));
|
||||
foreach ($pd_docs as $key => $value) {
|
||||
$picspath = 'pd' . $pd_master[0]['pd_id'] . '/' . $value['pd_document_name'];
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $picspath, '+5 minutes');
|
||||
$pd_docs[$key]['doc_url'] = $singed_uri;
|
||||
|
||||
}
|
||||
// print_r($pd_docs);die(); // wroking fine
|
||||
for($i=0; $i<count($json); $i++){
|
||||
if(isset($json[$i]['is_multiple']) && $json[$i]['is_multiple'] == 0 && $json[$i]['answer_value'] == "saved"){
|
||||
for($j=0; $j<count($pd_docs); $j++){
|
||||
if($pd_docs[$j]['image_key'] == $json[$i]['question_key']){
|
||||
$json[$i]['answer_value'] = $pd_docs[$j]['doc_url'];
|
||||
$json[$i]['pd_document_id'] = $pd_docs[$j]['pd_document_id'];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(isset($json[$i]['questions_group'])){
|
||||
$second_arr = $json[$i]['questions_group'];
|
||||
for($k=0; $k<count($second_arr); $k++){
|
||||
$thrid_arr = $second_arr[$k]['questions'];
|
||||
for($l=0; $l<count($thrid_arr); $l++){
|
||||
if(isset($thrid_arr[$l]['is_multiple']) && $thrid_arr[$l]['is_multiple'] == 0 && $thrid_arr[$l]['answer_value'] == "saved"){
|
||||
for($j=0; $j<count($pd_docs); $j++){
|
||||
$question = $thrid_arr[$l]['question'].' '.($l+1);
|
||||
// echo "\n";
|
||||
if($pd_docs[$j]['image_key'] == $thrid_arr[$l]['question_key'] && $pd_docs[$j]['pd_document_title'] == $question){
|
||||
// $thrid_arr[$l]['answer_value'] = $pd_docs[$j]['doc_url'];
|
||||
$json[$i]['questions_group'][$k]['questions'][$l]['answer_value'] = $pd_docs[$j]['doc_url'];
|
||||
$json[$i]['questions_group'][$k]['questions'][$l]['pd_document_id'] = $pd_docs[$j]['pd_document_id'];
|
||||
}
|
||||
}
|
||||
// print_r($thrid_arr[$l]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// echo "inxx".$i;
|
||||
}
|
||||
}
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $json;
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
$data['msg'] = 'FI-Document Not Available for Given PD ID ! ';
|
||||
}
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
$data['msg'] = 'FI-Photograph JSON Not Available for Given PD ID ! ';
|
||||
}
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
$data['msg'] = 'PD ID Not available ! ';
|
||||
}
|
||||
$this->response($data, REST_Controller::HTTP_OK);
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user