Video test 1 : ps

This commit is contained in:
VE10-Sanjeev 2022-11-02 21:49:15 +05:30
parent 37d5f6fa7d
commit 81ff52ae83

View File

@ -22,7 +22,7 @@ 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', 0, 0), 'person_met_id' => array('Person met ID Proof', '18', 0, 0), 'address_proof_visited' => array('Address Proof', '5', 0, 0), 'name_board_seen' => array('Name Board Seen', '13', 0, 0), 'machinery_image' => array('Machinery Image', '22', 0, 0), 'gst_Regn_cert_pic' => array('GST Regn Cert', '13', 0, 0), 'pf_regn_pic' => array('PF Regn', '13', 0, 0), 'esic_regn_pic' => array('ESIC Regn', '13', 0, 0), 'export_import_cert_pic' => array('Export Import Cert', '13', 0, 0), 'factory_cert_pic' => array('Factory Cert', '13', 0, 0), 'shop_eat_act_cert_pic' => array('Shop Est Act Cert', '13', 0, 0), 'eb_bill_pic' => array('EB Bill', '13', 0, 0), 'practice_cert_pic' => array('Cert of Practice', '13', 0, 0), 'fire_noc_pic' => array('Fire NOC', '13', 0, 0), 'stock_image' => array('Stock image', '11', 1, 1), 'client_image' => array('Client Bills', '2', 1, 1), 'supplier_image' => array('Supplier Bills', '1', 1, 1), 'office_setup' => array('Office/Business Setup', '13', 1, 1), 'additional_photos' => array('Additional Photographs', '13', 1, 1));
private $photo_names = array('selfie_with_person_met' => array('Person met', '18', 0, 0), 'person_met_id' => array('Person met ID Proof', '18', 0, 0), 'address_proof_visited' => array('Address Proof', '5', 0, 0), 'name_board_seen' => array('Name Board Seen', '13', 0, 0), 'machinery_image' => array('Machinery Image', '22', 0, 0), 'gst_Regn_cert_pic' => array('GST Regn Cert', '13', 0, 0), 'pf_regn_pic' => array('PF Regn', '13', 0, 0), 'esic_regn_pic' => array('ESIC Regn', '13', 0, 0), 'export_import_cert_pic' => array('Export Import Cert', '13', 0, 0), 'factory_cert_pic' => array('Factory Cert', '13', 0, 0), 'shop_eat_act_cert_pic' => array('Shop Est Act Cert', '13', 0, 0), 'eb_bill_pic' => array('EB Bill', '13', 0, 0), 'practice_cert_pic' => array('Cert of Practice', '13', 0, 0), 'fire_noc_pic' => array('Fire NOC', '13', 0, 0), 'stock_image' => array('Stock image', '11', 1, 1), 'client_image' => array('Client Bills', '2', 1, 1), 'supplier_image' => array('Supplier Bills', '1', 1, 1), 'office_setup' => array('Office/Business Setup', '13', 1, 1), 'additional_photos' => array('Additional Photographs', '13', 1, 1),'Video'=>array('Video','18',0,0));
private $existing_imges = array();
function __construct()
@ -6958,6 +6958,7 @@ class PD_Controller extends REST_Controller
$company_id = isset($records['company_id']) && $records['company_id'] ? $records['company_id'] : null;
$rental_count_id = isset($records['rental_count_id']) && $records['rental_count_id'] ? $records['rental_count_id'] : null;
$content_type = isset($records['content_type']) && $records['content_type'] ? $records['content_type'] : 1;
//$location = isset($records['link']) ? $records['link'] : null;
//echo $rental_count_id;die();
if (isset($records['images'][0]['pd_document_id']) && $records['images'][0]['pd_document_id'] != null && $records['images'][0]['pd_document_id'] != "") {
@ -8494,6 +8495,21 @@ class PD_Controller extends REST_Controller
// for business related images
$company_id = null;
if(isset($records['content_type']) && $records['content_type'] == 2){
// echo "VT".$records['content_type'];
$img_array['pd_image_alias_name'] = isset($records['pd_image_alias_name']) ? $records['pd_image_alias_name'] : null;
$img_array['image_key'] = $records['image_key'];
$img_array['link'] = isset($records['link']) ? $records['link'] : null;
$img_array['image'] = $records['image'];
$img_array['Name'] = isset($records['name']) ? $records['name'] : $records['image_key'];
$img_array['content_type'] = isset($records['content_type']) ? $records['content_type'] : null;
if($records['image']){
$res = $this->saveBase64Video($records['fk_pd_id'], ($records['fk_form_id'] ? $records['fk_form_id'] : null), array($img_array));
}else{
$res = array();
}
}//Video Type End Here content type = 2
else{
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','facemark_image_generated'), array('fk_pd_id' => $records['fk_pd_id'], 'applicant_type' => 1), PDAPPLICANTSDETAILS);
@ -8589,6 +8605,7 @@ class PD_Controller extends REST_Controller
if ($records['image'] != "") {
$res = $this->saveBase64Images($records['fk_pd_id'], ($records['fk_form_id'] ? $records['fk_form_id'] : null), $company_id, $rental_count_id = null, array($img_array));
}
}//Image Type End Here content type = 1
if ($res) {
$data['dataStatus'] = true;
@ -8675,6 +8692,7 @@ class PD_Controller extends REST_Controller
$this->photo_names['attendance_seen_pic'] = array('Attendance Img', '13');
}
// print_r($this->photo_names);die();
$final_data = array();
$common_images = array();
//print_r(($this->existing_imges));die();
@ -10744,5 +10762,98 @@ class PD_Controller extends REST_Controller
}
}
public function saveBase64Video($pd_id, $form_id = null, $data)
{
log_message('ERROR', '### PD 30`s Video 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);
foreach ($data as $iter => $doc) {
//make location for water mark helper function
// $this->location_for_watermark = $doc['link'];
$temp_base64_string = $doc['image'];
$title = $doc['Name'];
$is_show_report = isset($doc['is_show_report']) ? $doc['is_show_report'] : null;
//echo $title.'-'.$is_show_report;die();
$img_type = isset($doc['img_type']) ? $doc['img_type'] : null;
$output_file = $this->external_path . "/pd_reports/" . $pd_id . "/temp_base64_video.mp4";
// $this->temp_path_for_watermark = $output_file;
//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', '### PD VDO 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', '### PD VDO writing done' . $pd_id . ' - ' . $form_id);
// //###########end of image water marking with logo
log_message('ERROR', '### PD VDO 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;
// if($form_id != null)
// {
// $key = 'pd'.$pd_id.'/'.'form'.$form_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', '### PD VDO 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' => isset($doc['link']) ? $doc['link'] : null,'co_applicant_id' => $co_applicant_id,'img_type' => $img_type,'image_key' => (isset($doc['image_key']) ? $doc['image_key'] : null));
$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' => null, 'location' => isset($doc['link']) ? $doc['link'] : null, 'co_applicant_id' => null, 'img_type' => $img_type, 'image_key' => (isset($doc['image_key']) ? $doc['image_key'] : null), "pd_image_alias_name" => (isset($doc['pd_image_alias_name']) ? $doc['pd_image_alias_name'] : null),"content_type"=>(isset($doc['content_type']) ? $doc['content_type'] : null));
$record_data['company_id'] = null;
$id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS);
if ($id != null || $id != "") {
$count++;
$pks[] = $id;
}
$uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week');
// $this->img_url_for_watermark = $uri;
//print_r($uri);
}
}
if ($count == count($data)) {
//$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id));
$result['status'] = true;
$result['count'] = $count;
$result['pks'] = $pks;
$result['records'] = $uri;
$result['msg'] = "Video Saved Successfully";
} else {
//$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id));
$result['status'] = true;
$result['count'] = $count;
$result['pks'] = $pks;
$result['msg'] = "Video Not Saved!";
}
return $result;
}
}