diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 0a3d4f6f..2fa496a0 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -8842,7 +8842,7 @@ class PD_Controller extends REST_Controller // return $arr; } else if ($current_img_key == 'video' && strpos($value['pd_document_title'], 'Video') !== false) { - $arr = array('img_key' => 'Video', 'img_name' => $this->photo_names['video'][0], 'img_url' => $value['doc_url'], 'fk_form_id' => $this->photo_names['video'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $this->photo_names['video'][3]); + $arr = array('img_key' => 'video', 'img_name' => $this->photo_names['video'][0], 'img_url' => $value['doc_url'], 'fk_form_id' => $this->photo_names['video'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $this->photo_names['video'][3]); unset($this->existing_imges[$key]); return $arr; // unset($this->photo_names['selfie_with_person_met']); @@ -9046,7 +9046,7 @@ class PD_Controller extends REST_Controller if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week'); log_message('ERROR', '###PD SHORTS VIDEO stored in S3 uri = ' . $uri); - $record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => 'Video', 'pd_document_name' => $temp_file_name, 'fk_form_id' => $form_id, 'is_show_report' => 1, 'rental_count_id' => null, 'location' => null, 'co_applicant_id' => null, 'img_type' => null, 'image_key' => "video", "pd_image_alias_name" => null,"content_type"=>2); + $record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => isset($records['pd_document_title']) ? $records['pd_document_title'] : 'Video', 'pd_document_name' => $temp_file_name, 'fk_form_id' => $form_id, 'is_show_report' => 1, 'rental_count_id' => null, 'location' => null, 'co_applicant_id' => null, 'img_type' => null, 'image_key' => "video", "pd_image_alias_name" => null,"content_type"=>2); $record_data['company_id'] = null; $id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); if(file_exists($folder_to_check . '/' . $file_name_wo_extension . '.webm')){unlink($folder_to_check . '/' . $file_name_wo_extension . '.webm');} diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 230f9414..8773a75d 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -1707,7 +1707,11 @@ class Template_Management_Controller extends REST_Controller { $this->PD_Model->updateRecords(array('start_location' => $records['location']), PDTRIGGER, array('pd_id' => $records['pd_id'])); satellite_image::getSatelliteImage($records['pd_id']); } - $res = $this->saveBase64Images($records); + // if ($records['image_key'] == 'video') { + // $res = $this->saveShortsVideo($records,$_FILES); + // }else{ + $res = $this->saveBase64Images($records); + // } } if (!empty($res)) { $data['dataStatus'] = true; @@ -1795,7 +1799,85 @@ class Template_Management_Controller extends REST_Controller { return $result; } + // public function saveShortsVideo($records,$files) + // { + // log_message('ERROR', "saveShortsVideo FNS called"); + // $file_folder = "pd_reports"; + // $_FILES = $files; + // if (!empty($_FILES['video_file'])) { + // $form_id = $records['form_id']; + // $pd_id = $records['pd_id']; + // $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); + // if(isset($records['filename']) && $records['filename'] !=""){ + // $temp_file_name = $records['filename']; + // }else{ + // //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') . '.mp4'; + + // } + // log_message('ERROR', "filename = ".$temp_file_name); + // $lender_id = $pd_master_details[0]['fk_lender_id']; + // $bucketname = LENDER_BUCKET_NAME_PREFIX . $lender_id; + // $key = 'pd' . $records['pd_id'] . '/video/' . $temp_file_name; + // log_message('ERROR', "bucket key = ".$bucketname); + // $file_name_wo_extension = explode('.', ($temp_file_name))[0]; + // log_message('ERROR', "file_name_extension = ".$file_name_wo_extension); + // $file_type = explode('/', ($_FILES['video_file']['type']))[1]; + // log_message('ERROR', "file_type ".$file_type); + // $folder_to_check = XLPATH . '/' . $file_folder . '/' . $records['pd_id'] . '/videos'; + // // echo $folder_to_check;//die(); + // if (!file_exists($folder_to_check)) { + // mkdir(XLPATH . '/' . $file_folder . '/' . $records['pd_id'], 0777); + // mkdir($folder_to_check, 0777); + // } + // $config = array('upload_path' => $folder_to_check, 'overwrite' => TRUE, 'allowed_types' => '*', 'file_name' => $file_name_wo_extension . '.' . $file_type); + // $this->load->library('upload', $config); + // if ($this->upload->do_upload('video_file')) { + // $sourcefile = $folder_to_check . '/' . $file_name_wo_extension . '.mp4'; + // $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + // $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + // if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + // $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week'); + // log_message('ERROR', '###PD SHORTS VIDEO stored in S3 uri = ' . $uri); + // $record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => isset($records['pd_document_title']) ? $records['pd_document_title'] : 'Video', 'pd_document_name' => $temp_file_name, 'fk_form_id' => $form_id, 'is_show_report' => 1, 'rental_count_id' => null, 'location' => null, 'co_applicant_id' => null, 'img_type' => null, 'image_key' => "video", "pd_image_alias_name" => null,"content_type"=>2); + // $record_data['company_id'] = null; + // $id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); + // if(file_exists($folder_to_check . '/' . $file_name_wo_extension . '.webm')){unlink($folder_to_check . '/' . $file_name_wo_extension . '.webm');} + // if(file_exists($folder_to_check . '/' . $file_name_wo_extension . '.mp4')){unlink($folder_to_check . '/' . $file_name_wo_extension . '.mp4');} + // if ($id != null || $id != "") { + // log_message('ERROR', '###PD SHORTS VIDEO Saved'); + // $result['status'] = true; + // $result['msg'] = 'Video Saved Successfully'; + // $result['records'] = array('id'=>$id,'uri'=>$uri); + // } + // else{ + // log_message('ERROR', '###PD SHORTS VIDEO Entry Not saved'); + // $result['status'] = false; + // $result['msg'] = 'Something Wrong. Try Later!'; + // } + // }else{ + // log_message('ERROR', '###PD SHORTS VIDEO S3 Uri not saved'); + // $result['status'] = false; + // $result['msg'] = 'Something Wrong. Try Later!'; + // } + // } else { + // $result['status'] = false; + // $result['msg'] = 'Something Wrong. Try Later!'; + // } + // } else { + // log_message('ERROR', '###PD SHORTS No Video Found'); + // $result['status'] = false; + // $result['msg'] = 'No Video found to upload'; + // } + // return $result; + // } public function FIPDPhotograph_get(){ $pd_id = $this->get('pd_id');