diff --git a/api/application/composer.json b/api/application/composer.json index c92ae815..f3b10333 100644 --- a/api/application/composer.json +++ b/api/application/composer.json @@ -25,13 +25,11 @@ "guzzlehttp/guzzle": "^6.3", "twilio/sdk": "^6.10", "phpoffice/phpspreadsheet": "^1.15", - "johnathanmiller/secure-env-php": "^2.0" + "johnathanmiller/secure-env-php": "^2.0", + "google/apiclient": "^2.0" }, "suggest": { "paragonie/random_compat": "Provides better randomness in PHP 5.x" - }, - "require-dev": { - } } diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 3b03b974..cbbed1fb 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -354,6 +354,7 @@ $route['awsrek/(:any)'] = 'Test/testAwsrek'; $route['optimizeImages/(:num)'] = 'PD_Controller/optimizeImages'; $route['downloadSMCExcelFile/(:num)'] = 'PD_Controller/downloadSMCExcelFile'; $route['compareFaces'] = 'Test/compareFaces'; +$route['updateGoogleVideoStatus'] = 'Test/updateGoogleVideoStatus'; $route['googleSheet'] = 'Data_Dump_Controller/googleSheet'; @@ -362,8 +363,13 @@ $route['sendNotificationToOfficers'] = 'PD_Controller/sendNotificationToOfficers $route['getMasterForDataDump'] = 'Request_DataDump_Controller/getMasterForDataDump'; $route['getRequestForDataDump'] = 'Request_DataDump_Controller/getRequestForDataDump'; +$route['addgoogleCalenderEvent'] = 'GC_Event_Controller/addGoogleCalenterEvent';//dummy checking purpose +$route['getEventList'] = 'GC_Event_Controller/getGoogleCalenderEventList';//dummy checking purpose +$route['getEvent'] = 'GC_Event_Controller/getEventFromGoogleCalender';//dummy checking purpose + +$route['createGmeetLink'] = 'PD_Controller/createGmeetLink'; //only developer testing, not for APP use +$route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only developer testing, not for APP use -$route['GC_addEvent'] = 'GC_Event_Controller/addEvent'; -$route['GC_eventList'] = 'GC_Event_Controller/eventList'; $route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp'; -$route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; \ No newline at end of file +$route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; + diff --git a/api/application/controllers/GC_Event_Controller.php b/api/application/controllers/GC_Event_Controller.php index eebdb8bb..f9c192ef 100644 --- a/api/application/controllers/GC_Event_Controller.php +++ b/api/application/controllers/GC_Event_Controller.php @@ -7,93 +7,51 @@ defined('BASEPATH') OR exit('No direct script access allowed'); require_once APPPATH . '/libraries/REST_Controller.php'; -require APPPATH . 'vendor/autoload.php'; +//require APPPATH . 'vendor/autoload.php'; class GC_Event_Controller extends REST_Controller { public function __construct() { parent::__construct(); - $this->load->model('GC_Event_Model'); + $this->load->library('Googleapi'); } - public function addEvent_post() + public function addGoogleCalenterEvent_post() { - log_message('ERROR','#/# G-Calender-Event Fns Entered'); + // log_message('ERROR','#/# G-Calender-Event Fns Entered'); $post = $this->post(); $data = array(); - $valErr = ""; - - if(!empty($post)){ - if(empty($post['title'])){ - $valErr .= 'event title is Empty.
'; - } - if(empty($post['date'])){ - $valErr .= 'event date is Empty.
'; - } $event = array( - // 'title' =>$title, - 'title' => !empty($post['title'])?trim($post['title']):'Con Call - 1', + 'location' => !empty($post['location'])?trim($post['location']):'Perambalur', 'summary' => !empty($post['summary'])?trim($post['summary']):'Google meet link', - 'start' => !empty($post['time_from'])?trim($post['time_from']):'10:30', - 'end' => !empty($post['time_to'])?trim($post['time_to']):'17:00', - 'description' => !empty($post['description'])?trim($post['description']):'Generated By Sanjeev', - 'date' => !empty($post['date'])?date_format($date,"Y-m-d"):date('Y-m-d') + 'start' => !empty($post['start'])?trim($post['start']):'10:30', + 'end' => !empty($post['end'])?trim($post['end']):'17:00', + 'pdid' => !empty($post['pdid'])?trim($post['pdid']):'17:00' ); - log_message('ERROR',"GC-Event data : ".json_encode($event)); - if(empty($valErr)){ - $event = $this->GC_Event_Model->addEvent($event); - if(!empty($event['id'])){ - log_message('ERROR','GC-Event Created - ID :'.$event); - $statusMsg = 'Events created'; - }else{ - log_message('ERROR','GC-Event Not Created issues on Insert'); - $statusMsg = 'Something went wrong, please try again after some time.'; - } - }else{ - log_message('ERROR','GC-Event Not Created because of mandatory fields - '.trim($valErr, '
')); - $statusMsg = '

Please fill all the mandatory fields:

'.trim($valErr, '
'); - } - }else{ - log_message('ERROR','GC-Event Data Not Available'); - $statusMsg = 'Data Not Available.'; - } + + $data = $this->googleapi->addGoogleCalenterEvent($event); + $this->response($data,REST_Controller::HTTP_OK); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['msg'] = $statusMsg; - $this->response($data,REST_Controller::HTTP_OK); } - public function eventList_get() + public function getGoogleCalenderEventList_get() { - log_message('ERROR','#/# G-Calender-Event List'); - $get = $this->get(); + - if($get){ + $data = ($this->googleapi->getEventListFromGoogleCalender()); + $this->response($data,REST_Controller::HTTP_OK); - $start = $get['start'].' 00:00:00'; + } - $end = $get['end'].' 23:59:59'; - - $data['msg'] = 'Events of between '.$get['start']." and ".$get['end']; - - } else { - - $start = false; - - $end = false; - - $data['msg'] = 'Events of today'; - - } - - $data['events'] = $this->GC_Event_Model->getEvents('primary', $start, $end, 40); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $this->response($data,REST_Controller::HTTP_OK); + public function getEventFromGoogleCalender_get() + { + + $eventId = $this->get('eventid');// = '112e17c49k57uni51qp8l7gf18' + $data = ($this->googleapi->getGoogleCalenderEvent($eventId)); + $this->response($data,REST_Controller::HTTP_OK); } diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index dad5c83d..02428358 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -792,6 +792,11 @@ class PD_Controller extends REST_Controller { /****************END OF ADDTIONAL REQUIREMENTS SECTION*******************************************/ + //create gmeet link + if($pd_id != null && $pd_id != '' && ($pd_details['fk_pd_type'] == 2 || $pd_details['fk_pd_type'] == 3)) + { + $this->createGmeetLink($pdid); + } if($pd_id != null || $pd_id != '' && $count != 0) { @@ -1046,6 +1051,10 @@ class PD_Controller extends REST_Controller { if((isset($pd_details['pd_status']) && $pd_details['pd_status'] == QC_COMPLETED)) { $pd_details['is_cus_link_disabled'] = 1; + + //call delete google calender event + $this->deleteCalenderEvent($exist_pd_details[0]['gmeet_id']); + } if(isset($pd_details['pd_status']) && ($pd_details['pd_status'] == TRIGGERED || $pd_details['pd_status'] == INITIATED || $pd_details['pd_status'] == INPROGRESS)) @@ -10247,7 +10256,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() foreach ($video_info as $key => $value) { - if($value['composition_id']) + if($value['composition_id'] && $value['vps'] != 'google') { $res = $this->twlio->getCompositionStatus($value['composition_id']); //echo $res['status']; @@ -11872,7 +11881,53 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } } $this->response($data,REST_Controller::HTTP_OK); - } + + } + + /**** + create gmeet link for smart and tele pd and update it in pd trigger table + */ + // function createGmeetLink_get() + function createGmeetLink($pdid) + { + // $pdid = $this->get('pdid'); + $this->load->library('Googleapi'); + $pd_details = $this->PD_Model->getPDMasterDetails($pdid); + $event = array( + 'summary' => 'PD for case -'.$pd_details[0]['pd_sno'].' & Applicant ID - '.$pd_details[0]['lender_applicant_id'], + 'start' => Date('Y-m-d'), + 'end' => Date('Y-m-d'), + 'pdid' => $pdid, + + ); + + $event_data = $this->googleapi->addGoogleCalenterEvent($event); + if(is_object($event_data)) + { + $meet_code = isset($event_data['conferenceData']['conferenceId']) ? $event_data['conferenceData']['conferenceId'] : null; + $meet_id = isset($event_data['id']) ? $event_data['id'] : null; + $where_condition_array = array('pd_id' => $pdid); + $this->PD_Model->updateRecords(['gmeet_code' => $meet_code,'gmeet_id' => $meet_id],PDTRIGGER,$where_condition_array); + } + + + + } + + + /**** + delete Calender Event from google calender + */ + // function deleteCalenderEvent_get() + function deleteCalenderEvent($eventID) + { + // $eventID = $this->get('eventID'); + $this->load->library('Googleapi'); + $event_data = $this->googleapi->deleteGoogleCalenderEvent($eventID); + } + + + // public function facemark_get(){ public function toMakeFaceBoundingBox($master_details){ // $pdid = $this->get('pd');//pdid 3184 comment this @@ -11939,4 +11994,5 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } + } \ No newline at end of file diff --git a/api/application/controllers/Test.php b/api/application/controllers/Test.php index 1847840d..f4df771d 100644 --- a/api/application/controllers/Test.php +++ b/api/application/controllers/Test.php @@ -8,8 +8,9 @@ class Test extends REST_Controller { */ function __Construct(){ parent::__Construct(); + $this->external_path = $this->config->item('external_data_path'); $this->load->helper(array('form', 'url')); - //$this->load->model('test_model'); + $this->load->model('PD_Model'); $this->load->library('asynclibrary'); $this->load->library('AWS_REKONITION'); $this->load->helper('MYUTIL'); @@ -133,6 +134,9 @@ class Test extends REST_Controller { // echo '***********************'; } } + //update face api result in main table + $where_condition_array = array('pd_id' => $pd_id); + $this->PD_Model->updateRecords(['faceapi_result' => json_encode($res_data)],PDTRIGGER,$where_condition_array); //delete local files if created if($dest_url_type == 'base64') @@ -145,4 +149,63 @@ class Test extends REST_Controller { } $this->response($res_data,REST_Controller::HTTP_OK); } + + + + function handleGoolgeVideoFile($file,$pd_details) + { + $file_content = $this->googleapi->downloadDriveFile($file['id']); + if($file_content) + { + //store locally + $is_downloaded = file_put_contents($this->external_path.'/pd_reports/'.$pd_details[0]['pd_id'].'/'.$file['id'].'.mp4',$file_content); + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; + // $bucketname = LENDER_BUCKET_NAME_PREFIX.'1'; + $key = 'pd'.$pd_details[0]['pd_id'].'/video/'.$file['id'].'.mp4'; + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($this->external_path.'/pd_reports/'.$pd_details[0]['pd_id'].'/'.$file['id'].'.mp4')); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + $record_data = array('fk_pd_id' => $pd_details[0]['pd_id'],'composition_id' => $file['id'].'.mp4','is_call_ended' => 1,'twilo_status'=>'completed','s3_copied' => 1,'vsp' => 'google'); + $this->PD_Model->saveRecords($record_data,VIDEO_ROOM_INFO); + //echo 'done'; + unlink($this->external_path.'/pd_reports/'.$pd_details[0]['pd_id'].'/'.$file['id'].'.mp4'); + $file_content = $this->googleapi->deleteDriveFile($file['id']); + + } + + + } + } + + function updateGoogleVideoStatus_get() + { + $this->load->library('Googleapi'); + $pdid = $this->get('pdid'); + $pd_details = $this->PD_Model->getPDMasterDetails($pdid); + if(($pd_details[0]['fk_pd_type'] == 2 || $pd_details[0]['fk_pd_type'] == 3) && $pd_details[0]['gmeet_code'] != "") + { + $driveFilesList = $this->googleapi->getDriveFilesList($pd_details[0]['gmeet_code']); + if(count($driveFilesList)) + { + foreach ($driveFilesList as $key => $file) + { + $this->handleGoolgeVideoFile($file,$pd_details); + } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + // $data['msg'] = 'Officers Records Not Found!'; + $this->response($data,REST_Controller::HTTP_OK); + + } + else + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + // $data['msg'] = 'Officers Records Not Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + } } \ No newline at end of file diff --git a/api/application/libraries/Googleapi.php b/api/application/libraries/Googleapi.php index b6bcd9e3..b2b98023 100644 --- a/api/application/libraries/Googleapi.php +++ b/api/application/libraries/Googleapi.php @@ -2,66 +2,234 @@ /** * @package Google API : Google Client API * - * @author TechArise Team + * @author Velz * - * @email info@techarise.com + * * Description of Contact Controller */ if (!defined('BASEPATH')) exit('No direct script access allowed'); + +include_once APPPATH.'/vendor/autoload.php'; +// use Google\Service\Calendar\Event; +// use Google\Service\Calendar\EventDateTime; + class Googleapi { - /** - * Googleapi constructor. - */ - public function __construct() { - // load google client api - require_once BASH_PATH.'vendor/autoload.php'; + private $client; + private $calender; + private $drive; + function __construct() + { $this->client = new Google_Client(); - $this->client->setApplicationName('Learning Gmeet Event in Php'); - $this->ci =& get_instance(); - $this->ci->config->load('calendar'); - $this->client->setClientId($this->ci->config->item('client_id')); - $this->client->setClientSecret($this->ci->config->item('client_secret')); - // $this->client->setRedirectUri($this->ci->config->base_url().'gc/auth/oauth'); - $this->client->addScope(Google_Service_Calendar::CALENDAR); - $this->client->addScope('profile'); + $this->client->setApplicationName('GmeetPOC App'); + $this->client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS); + $this->client->setAuthConfig($_SERVER['DOCUMENT_ROOT'].'/env/pdgenie_credentials.json'); + // $this->client->setDeveloperKey('AIzaSyBFuekMZZFvQFdA4I1GLTMgYUg1vMqRR0Q'); + $this->client->setAccessType('offline'); + // $this->client->setPrompt('select_account consent'); + + // Load previously authorized token from a file, if it exists. + // The file token.json stores the user's access and refresh tokens, and is + // created automatically when the authorization flow completes for the first + // time. + $tokenPath = $_SERVER['DOCUMENT_ROOT'].'/env/pdgenie_token.json'; + if (file_exists($tokenPath)) { + $accessToken = json_decode(file_get_contents($tokenPath), true); + $this->client->setAccessToken($accessToken); + } + + // If there is no previous token or it's expired. + if ($this->client->isAccessTokenExpired()) { + // Refresh the token if possible, else fetch a new one. + if ($this->client->getRefreshToken()) { + $this->client->fetchAccessTokenWithRefreshToken($this->client->getRefreshToken()); + } else { + // Request authorization from the user. + $authUrl = $this->client->createAuthUrl(); + echo "Open the following link in your browser:\n%s\n", $authUrl; + print 'Enter verification code: '; + $authCode = trim(fgets(STDIN)); + + // Exchange authorization code for an access token. + $accessToken = $this->client->fetchAccessTokenWithAuthCode($authCode); + $this->client->setAccessToken($accessToken); + + // Check to see if there was an error. + if (array_key_exists('error', $accessToken)) { + throw new Exception(join(', ', $accessToken)); + } + } + // Save the token to a file. + if (!file_exists(dirname($tokenPath))) { + mkdir(dirname($tokenPath), 0700, true); + } + file_put_contents($tokenPath, json_encode($this->client->getAccessToken())); + } + // return //$this->client; + //create new calender service + $this->calender = new Google_Service_Calendar($this->client); + $this->drive = new Google_Service_Drive($this->client); } - - public function loginUrl() { - return $this->client->createAuthUrl(); + + + public function getEventListFromGoogleCalender() + { + $optParams = array( + 'maxResults' => 25, + 'orderBy' => 'startTime', + 'singleEvents' => true, + // 'timeMin' => $timeMin, + // 'timeMax' => $timeMax, + //'timeZone' => 'Asia/Kolkata', + ); + + $events_list = $this->calender->events->listEvents('primary', $optParams); + $result = []; + if(count($events_list)) + { + foreach ($events_list as $key => $event) { + + $result[($key+1)]['id'] = $event->getId(); + $result[($key+1)]['summary'] = $event->getSummary(); + $result[($key+1)]['description'] = $event->getDescription(); + // $result[($key+1)]['creator'] = $event->getCreator(); + // $result[($key+1)]['start'] = $event->getStart()->dateTime; + // $result[($key+1)]['end'] = $event->getEnd()->dateTime; + $result[($key+1)]['gmeetlink'] = $event->getHangoutLink(); + // $result[($key+1)]['link'] = $event->getHtmlLink(); + + } + return $result; + } + else + { + return $result; + } } - - public function getAuthenticate() { - return $this->client->authenticate(); + + public function getGoogleCalenderEvent($eventId) + { + + try + { + $event = $events_list = $this->calender->events->get('primary', $eventId); + return $event; + } + catch(Exception $e) { + //echo 'Message: ' .$e->getMessage(); + return []; + } + + } - - public function getAccessToken() { - return $this->client->getAccessToken(); + + public function addGoogleCalenterEvent($eventdata) + { + // $eventObj = new Event();//cast('A',$b); + // $eventTimeObj = new EventDateTime();//cast('A',$b); + // $eventTimeObj->setDateTime('2022-05-21T00:00:00'); + // $eventTimeObj->setTimeZone('Asia/Kolkata'); + + + // $eventObj->setSummary($eventdata['summary']); + // $eventObj->setStart($eventTimeObj); + // $eventObj->setEnd($eventTimeObj); + + $event = new Google_Service_Calendar_Event(array( + 'summary' => $eventdata['summary'], + 'location' => 'Online', + 'description' => '', + 'start' => array( + 'dateTime' => $eventdata['start'].'T00:00:00', + 'timeZone' => 'Asia/Kolkata', + ), + 'end' => array( + 'dateTime' => $eventdata['end'].'T00:00:00', + 'timeZone' => 'Asia/Kolkata', + ),"conferenceData" => [ + "createRequest"=> [ + "requestId" => $eventdata['pdid'].'_'.$eventdata['start'].'-'.rand()]] + )); + try + { + $event = $this->calender->events->insert('primary',$event,['conferenceDataVersion' => 1]); + return $event; + } + catch(Exception $e) { + echo 'Message: ' .$e->getMessage(); + return []; + } } - - public function setAccessToken() { - return $this->client->setAccessToken(); + + + public function deleteGoogleCalenderEvent($eventId) + { + + try + { + $event = $events_list = $this->calender->events->delete('primary', $eventId); + return $event; + } + catch(Exception $e) { + //echo 'Message: ' .$e->getMessage(); + return []; + } + + } - - public function revokeToken() { - return $this->client->revokeToken(); + + public function getDriveFilesList($gmeet_code) + { + $filter = ['q' => "mimeType='video/mp4' and name contains '".$gmeet_code."'"]; + try + { + $files = $this->drive->files->listFiles($filter); + if(count($files->getFiles())) + { + // echo count($files->getFiles()); + $res = []; + foreach($files->getFiles() as $key => $file) + { + $res[($key+1)]['id'] = $file->getId(); + $res[($key+1)]['name'] = $file->getName(); + $res[($key+1)]['type'] = $file->getMimeType(); + } + return $res; + } + return []; + } + catch(Exception $e) { + //echo 'Message: ' .$e->getMessage(); + return []; + } + } - - public function client() { - return $this->client; + + + public function downloadDriveFile($fileID) + { + $files = $this->drive->files->get($fileID,['alt' => 'media']); + if($files->getStatusCode() == 200) + { + return $files->getBody(); + } + return false; + // echo $files->getStatusCode(); + // echo $files->getContentType(); + // $files = file_put_contents(__DIR__.'/temp',$files->getBody()); } - - public function getUser() { - $google_ouath = new Google_Service_Oauth2($this->client); - return (object)$google_ouath->userinfo->get(); - } - - public function isAccessTokenExpired() { - return $this->client->isAccessTokenExpired(); + + public function deleteDriveFile($fileID) + { + $files = $this->drive->files->delete($fileID); + return true; + // echo $files->getStatusCode(); + // echo $files->getContentType(); + // $files = file_put_contents(__DIR__.'/temp',$files->getBody()); } } ?> \ No newline at end of file diff --git a/api/application/models/GC_Event_Model.php b/api/application/models/GC_Event_Model.php index 8926ce38..ebe5ebc7 100644 --- a/api/application/models/GC_Event_Model.php +++ b/api/application/models/GC_Event_Model.php @@ -44,14 +44,14 @@ class GC_Event_Model extends SPARQ_Model { 'maxResults' => $maxResults, 'orderBy' => 'startTime', 'singleEvents' => true, - 'timeMin' => $timeMin, - 'timeMax' => $timeMax, + // 'timeMin' => $timeMin, + // 'timeMax' => $timeMax, 'timeZone' => 'Asia/Kolkata', ); - $results = $this->googlecalendar->calendar->events->listEvents($calendarId, $optParams); - + $results = $this->Googleapi->calendar->events->listEvents('primary', $optParams); + print_r($results);die(); $data = array(); diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 6ec382f7..6457d14b 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -1054,7 +1054,8 @@ class PD_Model extends SPARQ_Model { */ public function getPDMasterDetails($pdid,$random_string = null) { - $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.sub_entity_id,SUBENTITY.short_name as sub_entity_short_name,PDTRIGGER.imgc_fin_institute,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,ENTITY.is_score_card_enabled,ENTITY.is_otp_enabled, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation,PDTRIGGER.pd_date_of_initiation as pd_date_of_initiation_sqlformat, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PRODUCTS.prod_catagory,PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %h:%i:%s %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",IFNULL(USERPROFILE.last_name,"")) as createdby,concat(USERPROFILE1.first_name," ",IFNULL(USERPROFILE1.last_name,"")) as updatedby,DESIGNATION.designation as updatedby_designation,PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.is_qc_enabled,AGENCY.full_name as agency_name,AGENCY.short_name as agency_short_name,PDTRIGGER.vendor_pdofficer,concat(VENDORPDOFFICER.first_name," ",VENDORPDOFFICER.last_name) as vendor_pdofficer_name,PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.lender_sales_person,concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email,PDTRIGGER.lender_credit_person,concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,OTPREJECTION.rejection_reason,PDTRIGGER.otp_reject_other_reason,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string,PDTRIGGER.pd_report_html_filename,PDTRIGGER.is_qc_edited,PDTRIGGER.is_zip_created,PDTRIGGER.pd_qc_note,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,AGENCY.is_vendor_visit_disabled,PDTRIGGER.is_notify_enabled,ENTITYFININSTITUTION.institute_name as fin_institute_name,PDTRIGGER.is_img_pdf_created,PDTRIGGER.is_video_merged,PDTRIGGER.vendor_status,PDTRIGGER.vendor_scheduled_on as vendor_scheduled_on_validation,DATE_FORMAT(PDTRIGGER.vendor_scheduled_on,"%d/%m/%Y %h:%i %p") as vendor_scheduled_on,PDTRIGGER.complete_override_data,PDTRIGGER.excel_file_id,SMC_EXCEL_FILELIST.file_name,SMC_EXCEL_FILELIST.modified_fname,PDTRIGGER.mwise_sales_person,PDTRIGGER.is_field_visit_done,PDTRIGGER.cancel_pd_remark,if(SMC_EXCEL_FILELIST_RE_UPLOAD.fk_pd_id is not null,"1","0") as re_uploaded,SMC_EXCEL_FILELIST_RE_UPLOAD.modified_fname as re_uploaded_file_name,ROLES.role_id as pd_allocated_to_role_id,AGENCYLIST.agency_name as SMC_vendor_agency_name,AGENCYLIST.agency_abbr as SMC_vendor_agency_short_name,PDTRIGGER.facemark_image_generated,ENTITY.is_face_api_enabled'); + + $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.sub_entity_id,SUBENTITY.short_name as sub_entity_short_name,PDTRIGGER.imgc_fin_institute,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,ENTITY.is_score_card_enabled,ENTITY.is_otp_enabled, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation,PDTRIGGER.pd_date_of_initiation as pd_date_of_initiation_sqlformat, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PRODUCTS.prod_catagory,PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %h:%i:%s %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",IFNULL(USERPROFILE.last_name,"")) as createdby,concat(USERPROFILE1.first_name," ",IFNULL(USERPROFILE1.last_name,"")) as updatedby,DESIGNATION.designation as updatedby_designation,PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.is_qc_enabled,AGENCY.full_name as agency_name,AGENCY.short_name as agency_short_name,PDTRIGGER.vendor_pdofficer,concat(VENDORPDOFFICER.first_name," ",VENDORPDOFFICER.last_name) as vendor_pdofficer_name,PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.lender_sales_person,concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email,PDTRIGGER.lender_credit_person,concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,OTPREJECTION.rejection_reason,PDTRIGGER.otp_reject_other_reason,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string,PDTRIGGER.pd_report_html_filename,PDTRIGGER.is_qc_edited,PDTRIGGER.is_zip_created,PDTRIGGER.pd_qc_note,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,AGENCY.is_vendor_visit_disabled,PDTRIGGER.is_notify_enabled,ENTITYFININSTITUTION.institute_name as fin_institute_name,PDTRIGGER.is_img_pdf_created,PDTRIGGER.is_video_merged,PDTRIGGER.vendor_status,PDTRIGGER.vendor_scheduled_on as vendor_scheduled_on_validation,DATE_FORMAT(PDTRIGGER.vendor_scheduled_on,"%d/%m/%Y %h:%i %p") as vendor_scheduled_on,PDTRIGGER.complete_override_data,PDTRIGGER.excel_file_id,SMC_EXCEL_FILELIST.file_name,SMC_EXCEL_FILELIST.modified_fname,PDTRIGGER.mwise_sales_person,PDTRIGGER.is_field_visit_done,PDTRIGGER.cancel_pd_remark,if(SMC_EXCEL_FILELIST_RE_UPLOAD.fk_pd_id is not null,"1","0") as re_uploaded,SMC_EXCEL_FILELIST_RE_UPLOAD.modified_fname as re_uploaded_file_name,ROLES.role_id as pd_allocated_to_role_id,AGENCYLIST.agency_name as SMC_vendor_agency_name,AGENCYLIST.agency_abbr as SMC_vendor_agency_short_name,PDTRIGGER.gmeet_code,PDTRIGGER.gmeet_id,PDTRIGGER.facemark_image_generated,ENTITY.is_face_api_enabled'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id ','LEFT'); $this->db->JOIN(ENTITY.' as SUBENTITY','PDTRIGGER.sub_entity_id = SUBENTITY.entity_id ','LEFT');