diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 4c2ec694..edfb63c6 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -8248,10 +8248,10 @@ class PD_Controller extends REST_Controller if ($current_operation == 1) { if ($records['is_person_met_pic'] != "") { - $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'], 'co_applicant_id' => $applicant_id, 'img_type' => 1); + $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'], 'co_applicant_id' => $applicant_id, 'img_type' => 1, 'image_key' => 'selfie_with_person_met'); } if ($records['is_person_met_id_proof'] != "") { - $img_data[] = array('Name' => (trim($records['applicant_name']) . '-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'], 'co_applicant_id' => $applicant_id, 'img_type' => 2); + $img_data[] = array('Name' => (trim($records['applicant_name']) . '-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'], 'co_applicant_id' => $applicant_id, 'img_type' => 2, 'image_key' => 'person_met_id'); } } ///print_r( $img_data ); @@ -8259,18 +8259,18 @@ class PD_Controller extends REST_Controller if ($records['is_person_met_pic'] != "" && !substr_count($records['is_person_met_pic'], 'https')) { - $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'], 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 1); + $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'], 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 1,'image_key' => 'selfie_with_person_met'); // Make inactive old entries with same data $sql = 'UPDATE ' . PDDOCUMENTS . ' SET isactive = 0 where fk_pd_id = ' . $records['fk_pd_id'] . ' and co_applicant_id = ' . $records['pd_co_applicant_id'] . ' and img_type = 1'; $this->db->query($sql); } else { - $this->PD_Model->updateRecords(array('pd_document_title' => trim($records['applicant_name'])), PDDOCUMENTS, array('fk_pd_id' => $records['fk_pd_id'], 'fk_form_id' => 18, 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 1, 'isactive' => 1)); // 1- person met img + $this->PD_Model->updateRecords(array('pd_document_title' => trim($records['applicant_name'])), PDDOCUMENTS, array('fk_pd_id' => $records['fk_pd_id'], 'fk_form_id' => 18, 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 1, 'isactive' => 1,'image_key' => 'selfie_with_person_met')); // 1- person met img } if ($records['is_person_met_id_proof'] != "" && !substr_count($records['is_person_met_id_proof'], 'https')) { - $img_data[] = array('Name' => (trim($records['applicant_name']) . '-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'], 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 2); + $img_data[] = array('Name' => (trim($records['applicant_name']) . '-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'], 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 2,'image_key' => 'person_met_id'); // Make inactive old entries with same data @@ -8278,7 +8278,7 @@ class PD_Controller extends REST_Controller $this->db->query($sql); } else { - $this->PD_Model->updateRecords(array('pd_document_title' => (trim($records['applicant_name']) . '-id_proof')), PDDOCUMENTS, array('fk_pd_id' => $records['fk_pd_id'], 'fk_form_id' => 18, 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 2, 'isactive' => 1)); // 2- person met ID proof img + $this->PD_Model->updateRecords(array('pd_document_title' => (trim($records['applicant_name']) . '-id_proof')), PDDOCUMENTS, array('fk_pd_id' => $records['fk_pd_id'], 'fk_form_id' => 18, 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 2, 'isactive' => 1,'image_key' => 'person_met_id')); // 2- person met ID proof img } } @@ -10633,8 +10633,7 @@ class PD_Controller extends REST_Controller // print_r($bounding_box);//working fine $where_condition_array = array('fk_pd_id' => $pdid, 'isactive' => 1,'co_applicant_id'=>$apcntid); - // $where_condition_array['image_key in ("selfie_with_person_met","person_met_id")'] = null; - $where_condition_array['img_type in ("1","2")'] = null; + $where_condition_array['image_key in ("selfie_with_person_met","person_met_id")'] = null; $select_col = array('pd_document_id', 'pd_document_name', 'pd_document_title', 'image_key','img_type'); $img_result = $this->PD_Model->selectCustomRecords($select_col, $where_condition_array, PDDOCUMENTS); @@ -10656,11 +10655,9 @@ class PD_Controller extends REST_Controller log_message('ERROR', "In PD Ctrl to Make FaceBoundingBox FaceMatches inx " . $k . " singed_uri : " . $singed_uri); // echo $j.$k; - // $response = faceapi::toMakeFaceBoundingBox($bounding_box, $destination_path, $file_name, $img_result[$k]['image_key'], $apcntid); - $response = faceapi::toMakeFaceBoundingBox($bounding_box, $destination_path, $file_name, $img_result[$k]['img_type'], $apcntid); + $response = faceapi::toMakeFaceBoundingBox($bounding_box, $destination_path, $file_name, $img_result[$k]['image_key'], $apcntid); array_push($img_response, $response); - // if (($img_result[$k]['image_key'] == 'selfie_with_person_met')) { - if (($img_result[$k]['img_type'] == '1')) { + if (($img_result[$k]['image_key'] == 'selfie_with_person_met')) { $this->uploadPicInS3($pdid, $destination_path, $bucketname, $applicants_details[$j]['pd_co_applicant_id'],$extension); } @@ -10712,7 +10709,7 @@ class PD_Controller extends REST_Controller log_message('ERROR', "In PD Ctrl uploadPicInS3 destinationPath : " . $destination_path); $file = "face_api_image_".$apcntid.$extension; $dbfile = "face_api_image_".$apcntid.".jpeg"; - $key = 'pd' . $pdid . '/' . $file; + $key = 'pd' . $pdid . '/' . $dbfile; $image = imagecreatefrompng($destination_path.$file); imagejpeg($image, $destination_path.$dbfile, '70'); // imagedestroy($image); @@ -10722,7 +10719,7 @@ class PD_Controller extends REST_Controller $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $destination_path.$dbfile); $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); log_message('ERROR', "In PD Ctrl uploadPicInS3 s3 status : " . $s3result['@metadata']['statusCode']); - log_message('ERROR', "In PD Ctrl uploadPicInS3 s3 result : " .json_encode($s3result)); + // log_message('ERROR', "In PD Ctrl uploadPicInS3 s3 result : " .json_encode($s3result)); if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { log_message('ERROR', "In PD Ctrl uploadPicInS3 updating pdapplicant table facemark_image_generated as 1"); diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index e9ea5c5b..a2dbaca3 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -2,7 +2,7 @@ class faceapi { - public static function toMakeFaceBoundingBox($bounding_box, $path, $file_name, $type,$apcntid) + public static function toMakeFaceBoundingBox($bounding_box, $path, $file_name, $key,$apcntid) { // ($image_name,$BoundingBox,$destination_path,$extension){ @@ -22,7 +22,7 @@ class faceapi $info = getimagesize($file_path); $extension = image_type_to_extension($info[2]); $SrcBoundingBox = $bounding_box['source_image']; - if (count($CmpBoundingBox) > 0 && ($type == '1')) { + if (count($CmpBoundingBox) > 0 && ($key == 'selfie_with_person_met')) { $destination_path = $path . 'face_api_image_'.$apcntid . $extension; if (!copy($file_path, $destination_path)) { log_message('ERROR', 'failed to copy');