log message added : ps

This commit is contained in:
VE10-Sanjeev 2022-04-21 13:28:02 +05:30
parent eec23ec2b3
commit d2217ee019
2 changed files with 21 additions and 4 deletions

View File

@ -11763,7 +11763,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
}
public function getListPDOfficersForNotification_get(){
log_message('ERROR',"getListPDOfficers Function");
$fields = array('fk_user_id');
$where_condition_array = array('isactive' => 1);
$list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS);
@ -11786,6 +11786,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
}
}
}
log_message('ERROR',"getListPDOfficers PDofficer list : ".json_encode($list_of_pd_officers));
// Get Central PD Officers List
$central_pd_officers = array();
@ -11795,7 +11796,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
$this->db->JOIN(ROLES.' as ROLES','USERPROFILEROLES.user_role = ROLES.role_id');
$this->db->WHERE('ROLES.role_id',2);
$central_pd_officers = $this->db->GET()->result_array();
log_message('ERROR',"getListPDOfficers CentralPDofficer list : ".json_encode($central_pd_officers));
if(!empty($list_of_pd_officers) && !empty($central_pd_officers)){
$data['dataStatus'] = true;
@ -11821,6 +11822,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
$this->response($data,REST_Controller::HTTP_OK);
}
public function sendNotificationToOfficers_post(){
log_message('ERROR',"send Notification To Officers ");
$records = $this->post('records');
$users = $records['user_id']; // alluser,multiuser,particularuser
$msg = $records['msg']; // alluser,multiuser,particularuser
@ -11831,20 +11833,25 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post()
// $where_condition_array = array();
// $tokens = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,USERNOTIFICATIONTOKENS);
// pd offier's mobile token get form notification table
PDALERTS::sendNotificationToOfficers($records);
$resp = PDALERTS::sendNotificationToOfficers($records);
log_message('ERROR',"send Notification To Officers : ".json_encode($resp));
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['msg'] = 'Notification Sended';
$data['details'] = $resp;
}else{
if(empty($msg)){
log_message('ERROR',"send Notification To Officers : Message Not Found ");
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Message Data Not Found!';
}else if(empty($users)){
log_message('ERROR',"send Notification To Officers : Officer List Not Found ");
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Users Not Found!';
}else{
log_message('ERROR',"send Notification To Officers : No Content ");
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Records Not Found!';

View File

@ -845,14 +845,16 @@ class PDALERTS
public static function sendNotificationToOfficers($records)
{
log_message('ERROR','send Notification To Officers in pd alert');
$users = $records['user_id']; // alluser,multiuser,particularuser
$msg = $records['msg']; // msg
$CI =&get_instance();
$CI->load->helper('push_notification');
// notification_token_id, fk_user_id, web_token, mob_token, createdon, updatedon
$CI->db->SELECT("USERNOTIFICATIONTOKENS.notification_token_id,USERNOTIFICATIONTOKENS.fk_user_id,USERNOTIFICATIONTOKENS.mob_token");
$CI->db->SELECT("USERNOTIFICATIONTOKENS.notification_token_id,USERNOTIFICATIONTOKENS.fk_user_id,USERNOTIFICATIONTOKENS.mob_token,concat(USERPROFILE.first_name,' ',USERPROFILE.last_name) as pdofficer_name");
$CI->db->FROM(USERNOTIFICATIONTOKENS." as USERNOTIFICATIONTOKENS");
$CI->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILEROLES.fk_userid = USERNOTIFICATIONTOKENS.fk_user_id and USERPROFILEROLES.isactive = 1');
$CI->db->JOIN(USERPROFILE." as USERPROFILE","USERNOTIFICATIONTOKENS.fk_user_id = USERPROFILE.userid",'LEFT');
// $CI->db->WHERE('ROLES.role_id',2);
if(is_array($users) && count($users)){
if($users[0] != 0){
@ -864,15 +866,23 @@ class PDALERTS
}
$CI->db->WHERE('USERNOTIFICATIONTOKENS.mob_token != ""');
$notification_details = $CI->db->GET()->result_array();
log_message('ERROR',"send Notification To Officers Records : ".json_encode($notification_details));
// print_r($CI->db->last_query());die();
// print_r($notification_details);die();
$additional_data_for_logs['to_whom'] = 'PDOFFICERS';
$web_token = "";
// $officers_name = array();
$officers_name['total_count'] = count($notification_details);
$officers_name['officers'] = array();
for($i=0;$i<count($notification_details);$i++){
$mob_token = $notification_details[$i]['mob_token'] ;
PUSH_NOTIFICATION::sendNotification($web_token,$mob_token,$msg,$additional_data_for_logs);
array_push($officers_name['officers'],$notification_details[$i]['pdofficer_name']);
}
log_message('ERROR',"Notification sended Officers List : ".json_encode($officers_name));
return $officers_name;
}
}