diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 45f7119b..12852f64 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -20,7 +20,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),'person_met_id' => array('Person met ID Proof','18',0),'name_board_seen' => array('Name Board Seen','13',0),'machinary_image' => array('Machinery Image','22',0),'gst_Regn_cert_pic' => array('GST Regn Cert','13',0),'pf_regn_pic' => array('PF Regn','13',0),'esic_regn_pic' => array('ESIC Regn','13',0),'export_import_cert_pic' => array('Export Import Cert','13',0),'factory_cert_pic' => array('Factory Cert','13',0),'shop_eat_act_cert_pic' => array('Shop Est Act Cert','13',0),'eb_bill_pic' => array('EB Bill','13',0),'practice_cert_pic' => array('Cert of Practice','13',0),'fire_noc_pic' => array('Fire NOC','13',0),'stock_image' => array('Stock image','11',1),'client_image' => array('Client Bills','2',1),'supplier_image' => array('Supplier Bills','1',1)); + private $photo_names = array('selfie_with_person_met' => array('Person met','18',0),'person_met_id' => array('Person met ID Proof','18',0),'address_proof_visited' => array('Address Proof','5',0),'name_board_seen' => array('Name Board Seen','13',0),'machinary_image' => array('Machinery Image','22',0),'gst_Regn_cert_pic' => array('GST Regn Cert','13',0),'pf_regn_pic' => array('PF Regn','13',0),'esic_regn_pic' => array('ESIC Regn','13',0),'export_import_cert_pic' => array('Export Import Cert','13',0),'factory_cert_pic' => array('Factory Cert','13',0),'shop_eat_act_cert_pic' => array('Shop Est Act Cert','13',0),'eb_bill_pic' => array('EB Bill','13',0),'practice_cert_pic' => array('Cert of Practice','13',0),'fire_noc_pic' => array('Fire NOC','13',0),'stock_image' => array('Stock image','11',1),'client_image' => array('Client Bills','2',1),'supplier_image' => array('Supplier Bills','1',1)); private $existing_imges = array(); function __construct() @@ -1852,7 +1852,6 @@ public function assignPDTempalate($data) $fields = array('fk_user_id','fk_pd_type_id'); $where_condition_array = array('fk_team_id' => $general_team_id[0]['pdteam_id'],'isactive' => 1); $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); - if(count($list_of_pd_officers)) { foreach($list_of_pd_officers as $key => $pdofficer) @@ -6011,7 +6010,10 @@ public function getPDFormDetailsJSON_post() // $res = SMS_GUPSHUP::sendSMS($msg,9715454901 ,array(),true); //print_r($res); //PDALERTS::pdnotification(1797); - die(); + // $this->aws_cognito->adminSetUserPassword('sineedge2019@gmail.com'); + + // echo 'Hi'; + // die(); //$this->dupAssessedIncomeInfo(1192,9999,1);die(); //print_r($this->aws_s3->getAllObjectsInaBucket('test-lender1','pd114'));die(); @@ -9471,9 +9473,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $records = json_decode($this->post('records'),true); $id = null; //log_message('ERROR','hi'); - //print_r($records); - //print_r($_FILES); - //die(); + // print_r($records); + // print_r($_FILES); + // die(); + + if(!empty($_FILES['video_file'])) { $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); @@ -9481,9 +9485,10 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $key = 'pd'.$records['pd_id'].'/video/'.$records['filename']; $file_name_wo_extension = explode('.', ($records['filename']))[0]; $file_type = explode('/', ($_FILES['video_file']['type']))[1]; - $folder_to_check = XLPATH.'/pd_reports/'.$records['pd_id'].'/videos'; + $folder_to_check = XLPATH.'/pd_reports/'.$records['pd_id'].'/videos'; + //echo $folder_to_check;//die(); if(!file_exists($folder_to_check)) { mkdir($folder_to_check,0777); } - + //die(); $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')) @@ -9507,15 +9512,26 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { log_message('ERROR','###PDVIDEO stored in S3'.$records['pd_id']); - $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename']); + $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename'],'video_key' => $records['video_key']); $id = $this->PD_Model->saveRecords($record_data,CUS_VIDEO); unlink($folder_to_check.'/'.$file_name_wo_extension.'webm'); unlink($folder_to_check.'/'.$file_name_wo_extension.'.mp4'); } + // if it is last part of a video call, then call video merge functionality + if(isset($records['is_call_ended']) && $records['is_call_ended'] == 1) + { + $final_video_name = $records['pd_id'].'-'.$records['video_key']; + sleep(10); + $this->mergeVideo($records['pd_id'],$pd_master_details,$final_video_name,$records['video_key']); + } + + if($id != null || $id != "") { + + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['msg'] = 'Video Saved Successfully'; @@ -9561,33 +9577,61 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() //merge all splitted videos public function getVideoURL_post() { - $pd_id = $this->post('pd_id'); - $random_string = $this->post('random_string'); - $final_video_name = $pd_id.'-'.$random_string; + $random_string = $this->post('random_string'); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + $result_data = array(); + //echo $bucket_name; + $query = "SELECT * FROM ".CUS_VIDEO." where fk_pd_id = $pd_id group by video_key"; + //$video_info = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'is_active' => 1,'video_key' => $video_key),CUS_VIDEO); + $video_info = $this->db->query($query); + if($video_info->num_rows()) + { + $video_info = $video_info->result_array(); + foreach ($video_info as $key => $value) + { + if($value['video_key'] != null && $value['video_key'] != "") + { + $video_name = $pd_id.'-'.$value['video_key'].'.webm'; + $final_key = 'pd'.$pd_id.'/video/'.$video_name; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+3 hrs'); + $result_data[] = array('video_name' => $video_name, 'url' => $singed_uri); + } + } + + } + //print_r($video_info);die(); + + + + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + + + } + + function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key) + { + // $pd_id = $this->post('pd_id'); + // $random_string = $this->post('random_string'); + //$final_video_name = $pd_id.'-'.$random_string; //echo $final_video_name;die(); //Get PD master DEtails - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); + //$pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); //$is_video_merged = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'video_part_name' => $final_video_name),CUS_VIDEO); //prit_r($pd_master_details);die(); - if(count($pd_master_details) && isset($pd_master_details[0]['pd_id'])) - { + // if(count($pd_master_details) && isset($pd_master_details[0]['pd_id'])) + // { $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - $final_key = 'pd'.$pd_id.'/video/'.$final_video_name.'.webm'; - if($pd_master_details[0]['is_video_merged']) - { + $final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$final_video_name.'.webm'; - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+3 hrs'); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['url'] = $singed_uri; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { //Get all video info - $video_info = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'is_active' => 1),CUS_VIDEO); + $video_info = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'is_active' => 1,'video_key' => $video_key),CUS_VIDEO); $folder_to_check = XLPATH.'/pd_reports/'.$pd_id.'/videos'; $file_list = $folder_to_check.'/filelist.txt'; @@ -9623,7 +9667,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - log_message('ERROR','###PDVIDEO final video tored in S3'.$pd_id); + log_message('ERROR','###PDVIDEO final video stored in S3'.$pd_id); $record_data = array('is_video_merged' => 1); $id = $this->PD_Model->updateRecords($record_data,PDTRIGGER,array('pd_id' => $pd_id)); unlink($folder_to_check.'/'.$final_video_name.'.mp4'); @@ -9637,34 +9681,25 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() } - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+3 hrs'); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['url'] = $singed_uri; - $this->response($data,REST_Controller::HTTP_OK); + // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+3 hrs'); + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_OK; + // $data['url'] = $singed_uri; + // $this->response($data,REST_Controller::HTTP_OK); } else { - echo 'Not DOne'; + log_message('ERROR','###PDVIDEO final video not stored in S3'.$pd_id); } - } - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'No PD Found...!'; - $this->response($data,REST_Controller::HTTP_OK); - } + - } - - + + } //make duplicate of a exist pd public function duplicatePD_post()