From e63ec25b585c24af5452bfbb735c6a15f23ba4af Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Thu, 26 Mar 2020 10:40:40 +0530 Subject: [PATCH] CUS LINK CHNGES 3 --- api/application/controllers/PD_Controller.php | 108 +++++++++++------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 05d14911..614344a1 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -20,6 +20,8 @@ class PD_Controller extends REST_Controller { //class level variable declaration //protected $external_path; + private $photo_names = array('selfie_with_person_met' => array('Person met','18'),'person_met_id' => array('Person met ID Proof','18'),'approach_to_pd_location' => array('Approach to pd location','5'),'name_board_seen' => array('Name board seen','13'), 'stock_image' => array('Stock image','11'),'attendance_seen_pic' => array('Attendance Img','13'),'attendance_seen_pic' => array('Attendance Img','13'),'client_image' => array('Client Details Image','2'),'supplier_image' => array('Supplier Details Image','1'),'machinary_image' => array('Machinery Image','22'),'gst_Regn_cert' => array('GST Regn Cert','13'),'pf_regn' => array('PF Regn','13'),'esic_regn' => array('ESIC Regn','13'),'export_import_cert' => array('Export Import Cert','13'),'factory_cert' => array('Factory Cert','13'),'shop_eat_act_cert' => array('Shop Est Act Cert','13'),'eb_bill' => array('EB Bill','13')); + private $existing_imges = array(); function __construct() { @@ -9487,6 +9489,8 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() public function uploadPDPhotosByApplicant_post() { $records = $this->post('records'); + print_r($records); + } //Applicant Link Check and Get Image Details @@ -9495,11 +9499,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $random_string = $this->post('random_string'); $pd_id = $this->post('pd_id'); - - if(!$pd_id) - { + $where_condition_array = array('random_string' => $random_string); + if($pd_id){ $where_condition_array['pd_id'] = $pd_id; } + //Get PD ID by Random String - $pd_id = $this->PD_Model->selectCustomRecords(array('pd_id','is_cus_link_valid','cus_link_count','is_cus_link_disabled'),array('random_string' => $random_string),PDTRIGGER); + $pd_id = $this->PD_Model->selectCustomRecords(array('pd_id','is_cus_link_valid','cus_link_count','is_cus_link_disabled'),$where_condition_array,PDTRIGGER); if(count($pd_id) && count($pd_id) == 1) { @@ -9528,11 +9532,6 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $this->response($data,REST_Controller::HTTP_OK); } - } - else - { - //check and update link meta data - } } @@ -9571,56 +9570,79 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() public function getPDImgData($pd_id,$random_string,$is_cus_link_disabled) { - $existing_imges = $this->PD_Model->getSignedPDDocsURL($pd_id,null,null,null,null,'report'); - $photo_names = array('selfie_with_person_met' => array('Person met','18'),'person_met_id' => array('Person met ID Proof','18'),'approach_to_pd_location' => array('Approach to pd location','5'),'name_board_seen' => array('Name board seen','13'), 'stock_image' => array('Stock image','11'),'attendance_seen_pic' => array('Attendance Img','13'),'attendance_seen_pic' => array('Attendance Img','13'),'client_image' => array('Client Details Image','2'),'supplier_image' => array('Supplier Details Image','1'),'machinary_image' => array('Machinery Image','22'),'gst_Regn_cert' => array('GST Regn Cert','13'),'pf_regn' => array('PF Regn','13'),'esic_regn' => array('ESIC Regn','13'),'export_import_cert' => array('Export Import Cert','13'),'factory_cert' => array('Factory Cert','13'),'shop_eat_act_cert' => array('Shop Est Act Cert','13'),'eb_bill' => array('EB Bill','13')); + $this->existing_imges = $this->PD_Model->getSignedPDDocsURL($pd_id,null,null,null,null,'report'); + $final_data = array(); $common_images = array(); - //print_r(($existing_imges)); - if(count($existing_imges)) + //print_r(($this->existing_imges));die(); + if(count($this->existing_imges)) { - foreach ($existing_imges as $key => $value) + foreach ($this->photo_names as $key => $value) { - if($value['img_type'] == 1) - { - $final_data[] = array('img_key' => 'selfie_with_person_met','img_name' => $photo_names['selfie_with_person_met'][0],'fk_form_id' => $photo_names['selfie_with_person_met'][1],'img_url' => $value['doc_url'],'is_multiple' => 0); - continue; - - } - else if($value['img_type'] == 2) - { - $final_data[] = array('img_key' => 'person_met_id','img_name' => $photo_names['person_met_id'][0],'img_url' => $value['doc_url'],'fk_form_id' => $photo_names['selfie_with_person_met'][1],'is_multiple' => 0); - continue; - } - else if(strpos($value['pd_document_title'], 'Approach') !== false) - { - $final_data[] = array('img_key' => 'approach_to_pd_location','img_name' => $photo_names['approach_to_pd_location'][0],'img_url' => $value['doc_url'],'fk_form_id' => $photo_names['approach_to_pd_location'][1],'is_multiple' => 0); - continue; - } - else if(isset($photo_names [ $value['pd_document_title'] ])) - { - $final_data[] = array('img_key' => $value['pd_document_title'],'img_name' => $photo_names[ $value['pd_document_title'] ][0],'img_url' => $value['doc_url'],'fk_form_id' => $photo_names[ $value['pd_document_title'] ][1],'is_multiple' => 0); - continue; - } - else - { - $common_images[] = array('img_key' => $value['pd_document_title'],'img_name' => $value['pd_document_title'],'img_url' => $value['doc_url'],'fk_form_id' => $value['fk_form_id']); - continue; - } - + $final_data[] = $this->photoMapping($key,$value); + unset($this->photo_names[$key]); + } } else { - + foreach ($this->photo_names as $key => $value) + { + $final_data[] = array('img_key' => $key,'img_name' => $key,'img_url' => "",'fk_form_id' => $value[1]); + + } } //print_r($final_data); - $final_data[] = array('imag_data' => $common_images,'is_multiple' => 1); + //$final_data[] = array('imag_data' => $common_images,'is_multiple' => 1); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = array('pd_id' => $pd_id,'random_string' => $random_string,'is_cus_link_disabled' => $is_cus_link_disabled,'img_data' => $final_data); $this->response($data,REST_Controller::HTTP_OK); } + + function photoMapping($current_img_key,$current_img) + { + + //print_r($èxist_img_array);echo $img_key;die(); + //echo $this->photo_names['selfie_with_person_met'][1];die(); + foreach ($this->existing_imges as $key => $value) + { + //print_r($value);die(); + if($value['img_type'] == 1 && $current_img_key == 'selfie_with_person_met') + { + unset($this->existing_imges[$key]); + return array('img_key' => 'selfie_with_person_met','img_name' => $this->photo_names['selfie_with_person_met'][0],'fk_form_id' => $this->photo_names['selfie_with_person_met'][1],'img_url' => $value['doc_url'],'is_multiple' => 0); + + } + else if($value['img_type'] == 2 && $current_img_key == 'person_met_id') + { + unset($this->existing_imges[$key]); + return array('img_key' => 'person_met_id','img_name' => $this->photo_names['person_met_id'][0],'img_url' => $value['doc_url'],'fk_form_id' => $this->photo_names['person_met_id'][1],'is_multiple' => 0); + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } + else if(strpos($value['pd_document_title'], 'Approach') !== false && $current_img_key == 'approach_to_pd_location') + { + unset($this->existing_imges[$key]); + return array('img_key' => 'approach_to_pd_location','img_name' => $this->photo_names['approach_to_pd_location'][0],'img_url' => $value['doc_url'],'fk_form_id' => $this->photo_names['approach_to_pd_location'][1],'is_multiple' => 0); + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } + else if($current_img_key == $value['pd_document_title']) + { + unset($this->existing_imges[$key]); + return array('img_key' => $value['pd_document_title'],'img_name' => $this->photo_names[ $value['pd_document_title'] ][0],'img_url' => $value['doc_url'],'fk_form_id' => $this->photo_names[ $value['pd_document_title'] ][1],'is_multiple' => 0); + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } + else + { + //unset($this->existing_imges[$key]); + return array('img_key' =>$current_img_key,'img_name' => $current_img_key,'img_url' => '','fk_form_id' => $current_img[1]); + } + } + } }