diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 224505e1..5a53f62f 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -10085,17 +10085,24 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // print_r($_FILES); // die(); - + $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; + $lender_id = $records['pd_category'] == "1" ? $pd_master_details[0]['fk_lender_id'] : $pd_master_details[0]['lender_id']; + $file_folder = $records['pd_category'] == "2" ? "sales_pd" : "pd_reports" ; if(!empty($_FILES['video_file'])) { - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); + + if($pd_category == '2'){ + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} + if($pd_category == '1'){ + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']);} + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; $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.'/'.$file_folder.'/'.$records['pd_id'].'/videos'; //echo $folder_to_check;//die(); - if(!file_exists($folder_to_check)) { mkdir(XLPATH.'/pd_reports/'.$records['pd_id'],0777); mkdir($folder_to_check,0777); } + if(!file_exists($folder_to_check)) { mkdir(XLPATH.'/'.$file_folder.'/'.$records['pd_id'],0777); 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); @@ -10120,7 +10127,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_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'],'video_key' => $records['video_key']); + $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename'],'video_key' => $records['video_key'],'pd_category'=>$pd_category); $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'); @@ -10132,7 +10139,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $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']); + $this->mergeVideo($records['pd_id'],$pd_master_details,$final_video_name,$records['video_key'],$pd_category); } @@ -10187,9 +10194,13 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $pd_id = $this->post('pd_id'); $random_string = $this->post('random_string'); + $pd_category = $this->post('pd_category') ? $this->post('pd_category') : "1"; $this->load->helper('video_grabber_helper'); + if($pd_category == '1'){//normal Credit PD; $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); - $result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details); + }if($pd_category == '2'){//Sales PD; + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} + $result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details,$pd_category); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; @@ -10222,8 +10233,9 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $pd_id = $this->post('pd_id'); $random_string = $this->post('random_string'); $room_id = $this->post('room_id'); + $pd_category = $this->post('pd_category') ? $this->post('pd_category') : "1"; - $result_data = $this->getTwiloVideoStatus($pd_id,$random_string,$room_id); + $result_data = $this->getTwiloVideoStatus($pd_id,$random_string,$room_id,$pd_category); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; @@ -10233,13 +10245,13 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } - function getTwiloVideoStatus($pd_id,$random_string,$room_id = '') + function getTwiloVideoStatus($pd_id,$random_string,$room_id = '',$pd_category) { $this->load->library('twlio'); $result_data = 0; // $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and twilo_status = 'enqueued' and composition_id is not null;"; $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); - $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0";// and twilo_status = 'enqueued' and composition_id is not null;"; + $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0 and pd_category = $pd_category";// and twilo_status = 'enqueued' and composition_id is not null;"; if($room_id) { $query .=" and room_id = '$room_id'"; @@ -10294,19 +10306,21 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() return $result_data; } - function copyMediaFromTwiloToS3($pd_master_details,$value)// copy media from twlio s3 to our s3 + function copyMediaFromTwiloToS3($pd_master_details,$value,$pd_catgory)// copy media from twlio s3 to our s3 { EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['pd_id']); //get media uri from twlio $singed_uri = $this->twlio->compositionVideoFile($value['composition_id']); //echo $singed_uri; - $internal_server_tmp_location = XLPATH.'/pd_reports/'.$pd_master_details[0]['pd_id'].'/videos'; + $file_folder = $pd_catgory == "2" ? "sales_pd" : "pd_reports" ; + $lender_id = $pd_catgory == "1" ? $pd_master_details[0]['fk_lender_id'] : $pd_master_details[0]['lender_id']; + $internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos'; $internal_server_tmp_location_filename = ($internal_server_tmp_location.'/'.$value['composition_id'].'.mp4'); //echo $internal_server_tmp_location; if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location); }; $is_writed = file_put_contents($internal_server_tmp_location_filename,file_get_contents($singed_uri)); //upload it to aws s3 - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id; $final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$value['composition_id'].'.mp4'; $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$final_key,'sourcefile'=>($internal_server_tmp_location_filename)); @@ -10324,8 +10338,10 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } - function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key) + function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key,$pd_category) { + $pd_category = $pd_category ? $pd_category : "1"; + $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports" ; // $pd_id = $this->post('pd_id'); // $random_string = $this->post('random_string'); //$final_video_name = $pd_id.'-'.$random_string; @@ -10346,7 +10362,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() where fk_pd_id = $pd_id and video_key = '$video_key' and is_active = 1 order by sno"; $video_info = $this->db->query($qu)->result_array(); - $folder_to_check = XLPATH.'/pd_reports/'.$pd_id.'/videos'; + $folder_to_check = XLPATH.'/'.$file_folder.'/'.$pd_id.'/videos'; $file_list = $folder_to_check.'/filelist.txt'; //Get All video and temp store it in xlpath @@ -11485,7 +11501,14 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() public function uploadVideoFile_post() { $records = json_decode($this->post('records'),true); - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id'],$records['random_string']); + $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; + $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports" ; + if($pd_category == '1'){//normal Credit PD; + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id'],$records['random_string']); + }if($pd_category == '2'){//Sales PD; + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $records['fk_pd_id'],'rand_string'=>$records['random_string']),SALES_PD_DATA); + } + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; // echo XLPATH; // print_r($records);die(); @@ -11495,7 +11518,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() //die(); if(!empty($_FILES['video_file'])) { - $folder_to_check = XLPATH.'/pd_reports/'.$records['fk_pd_id'].'/videos'; + $folder_to_check = XLPATH.'/'.$file_folder.'/'.$records['fk_pd_id'].'/videos'; if(!file_exists($folder_to_check)) { diff --git a/api/application/helpers/video_grabber_helper.php b/api/application/helpers/video_grabber_helper.php index 58d8ca72..beca56e4 100644 --- a/api/application/helpers/video_grabber_helper.php +++ b/api/application/helpers/video_grabber_helper.php @@ -9,19 +9,22 @@ class video_grabber_helper } - public function grabAllVideo($pdid,$random_string,$pd_master_details = array()) + public function grabAllVideo($pdid,$random_string,$pd_master_details = array(),$pd_category) { $CI =&get_instance(); // $CI->load->helper('url_shortener'); if(!count($pd_master_details)) { - $pd_master_details = $CI->PD_Model->getPDMasterDetails($pd_id,$random_string); + if($pd_category == '2'){ + $pd_master_details = $CI->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} + if($pd_category == '1'){ + $pd_master_details = $CI->PD_Model->getPDMasterDetails($pd_id,$random_string);} } $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; $result_data = array(); - $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pdid and isactive = 1"; + $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pdid and isactive = 1 and pd_category = $pd_category"; $video_info = $CI->db->query($query); // print_r($video_info->result_array());die(); if($video_info->num_rows())