PUSH SMS LOG CHANGED PDREMARKS API ADDED AUTO ENV SET ENABLED

This commit is contained in:
Velz2020 2019-07-26 18:39:57 +05:30
parent b10d236486
commit 4edd413186
8 changed files with 132 additions and 36 deletions

View File

@ -569,6 +569,9 @@ defined('USERNOTIFICATIONTOKENSID') OR define('USERNOTIFICATIONTOKENSID','notifi
defined('T_PD_INLINE_PHOTO_FORM_STATUS') OR define('T_PD_INLINE_PHOTO_FORM_STATUS','t_pd_inline_photo_form_status'); defined('T_PD_INLINE_PHOTO_FORM_STATUS') OR define('T_PD_INLINE_PHOTO_FORM_STATUS','t_pd_inline_photo_form_status');
defined('PDREMARKS') OR define('PDREMARKS','t_pd_remarks');
defined('PDREMARKSID') OR define('PDREMARKSID','pd_remark_id');

View File

@ -207,6 +207,7 @@ $route['(getPDReportHTML/:any/:any)'] = 'PD_Controller/getPDReportHTML';
$route['convertBase64'] = 'PD_Controller/convertImgUrlToBase64'; $route['convertBase64'] = 'PD_Controller/convertImgUrlToBase64';
$route['updateNotificationToken'] = 'PD_Controller/updateNotificationToken'; $route['updateNotificationToken'] = 'PD_Controller/updateNotificationToken';
$route['getPDScore'] = 'PD_Controller/getPDScoreForDisplay'; $route['getPDScore'] = 'PD_Controller/getPDScoreForDisplay';
$route['savePDRemark'] = 'PD_Controller/savePDRemark';
// $route['savePDFormDetailsJSON'] = 'PD_Controller/savePDFormDetailsJSON'; // $route['savePDFormDetailsJSON'] = 'PD_Controller/savePDFormDetailsJSON';
// $route['getPDFormDetailsJSON'] = 'PD_Controller/getPDFormDetailsJSON'; // $route['getPDFormDetailsJSON'] = 'PD_Controller/getPDFormDetailsJSON';

View File

@ -5118,8 +5118,23 @@ class PD_Controller extends REST_Controller {
$records = $this->post('records'); $records = $this->post('records');
$pdid = $records['pd_id']; $pdid = $records['pd_id'];
$this->load->helper('push_notification'); // $this->load->helper('push_notification');
PUSH_NOTIFICATION::notifyWeb('fbm57p_E5xc:APA91bENk6ZH7J2kj03liCy0FzrtsYUgVjvoYnPBi4bu4UtGjqixn0Z_cUDHjCHeBWNcXlVozoo_uUKr8gwufcOQMfdRK19_sWN9jA5U1hRuwJTpIQKows6wYSHFH7kI4EnnUaj0FtK_','EST','test mesg from server',1);die(); // PUSH_NOTIFICATION::notifyWeb('fbm57p_E5xc:APA91bENk6ZH7J2kj03liCy0FzrtsYUgVjvoYnPBi4bu4UtGjqixn0Z_cUDHjCHeBWNcXlVozoo_uUKr8gwufcOQMfdRK19_sWN9jA5U1hRuwJTpIQKows6wYSHFH7kI4EnnUaj0FtK_','EST','test mesg from server',1);die();
//echo APPPATH;
// $external_path = substr(APPPATH,0,strpos(APPPATH,'sparq'));
// echo $external_path;
// $external_path .= 'dev_external_data/sample/sample.html';
// //$external_path .= 'sample.html';
// $fp = fopen($external_path,'a');
// $data = 'Hi';
// fwrite($fp, $data);
// fclose($fp);
//$d = $_SERVER['DOCUMENT_ROOT'].'/ssa_external_data/'.ENVIRONMENT.'/program_logs/';
//mkdir($d,0777);
//die();
//PDALERTS::pdnotification(1143);die(); //PDALERTS::pdnotification(1143);die();
@ -5286,7 +5301,6 @@ class PD_Controller extends REST_Controller {
public function getQCLenderRemarks_post() public function getQCLenderRemarks_post()
{ {
$records = $this->post('records'); $records = $this->post('records');
$pdid = $records['pd_id']; $pdid = $records['pd_id'];
$fields = array(); $fields = array();
if($records['flag'] == 'QC') if($records['flag'] == 'QC')
@ -5305,6 +5319,28 @@ class PD_Controller extends REST_Controller {
{ {
$fields = array('pd_qc_note'); $fields = array('pd_qc_note');
} }
else if($records['flag'] == 'ALL_REMARKS')// Get All Other remarks from pd remarks table
{
$this->db->SELECT('PDREMARKS.remark,DATE_FORMAT(PDREMARKS.createdon,"%d/%m/%Y %r") as log_time,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby')->FROM(PDREMARKS.' as PDREMARKS');
$this->db->JOIN(USERPROFILE.' as USERPROFILE','USERPROFILE.userid = PDREMARKS.createdby','LEFT');
$this->db->WHERE('PDREMARKS.fk_pd_id',$pdid);
$res = $this->db->GET()->result_array();
if(count($res))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $res;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{ $data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'No Remarks Available for this PD!';
$this->response($data,REST_Controller::HTTP_OK);
}
}
else else
{ {
$data['dataStatus'] = false; $data['dataStatus'] = false;
@ -7826,4 +7862,38 @@ class PD_Controller extends REST_Controller {
$data['records'] = $t; $data['records'] = $t;
$this->response($data,REST_Controller::HTTP_OK); $this->response($data,REST_Controller::HTTP_OK);
} }
public function savePDRemark_post()
{
$pd_id = $this->post('pd_id');
$remark = $this->post('remark');
$createdby = $this->post('createdby');
if($pd_id != null && $remark != null && $createdby != null)
{
$res = $this->PD_Model->saveRecords(array('fk_pd_id' => $pd_id,'remark' => $remark,'createdby' => $createdby),PDREMARKS);
if($res)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $res;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$data['msg'] = 'Something Went Wrong! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$data['msg'] = 'In Appropriate call!';
$this->response($data,REST_Controller::HTTP_OK);
}
}
} }

View File

@ -8,7 +8,7 @@ class MYLOG
// Create the logger // Create the logger
public static function logFunction($dynamic = null) //$msg,$data,$log_type public static function logFunction($dynamic = null) //$msg,$data,$log_type
{ {
$channel = $dynamic ? $dynamic : 'ssa_beta_logger'; $channel = $dynamic ? $dynamic : 'pdgenie_logger';
$log_folder = $dynamic ? 'request_logs' : 'syslogs'; $log_folder = $dynamic ? 'request_logs' : 'syslogs';
include_once APPPATH.'/vendor/autoload.php'; include_once APPPATH.'/vendor/autoload.php';
$logger = new \Monolog\Logger($channel); $logger = new \Monolog\Logger($channel);

View File

@ -25,6 +25,7 @@ class PDALERTS
$CI->load->helper('push_notification'); $CI->load->helper('push_notification');
$pd_notification_configs = array(); $pd_notification_configs = array();
//die(); //die();
$additional_data_for_logs = array('pd_id' =>$pdid);
/*********************************************/ /*********************************************/
/*******Get PD Master Details*****************/ /*******Get PD Master Details*****************/
@ -48,7 +49,7 @@ class PDALERTS
// die(); // die();
if(count($core_details)) if(count($core_details))
{ {
$additional_data_for_logs['pd_status'] = $core_details[0]['pd_status'];
/*********************************************/ /*********************************************/
/*******Get Notification Config Details*****/ /*******Get Notification Config Details*****/
/*********************************************/ /*********************************************/
@ -119,7 +120,8 @@ class PDALERTS
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
//echo $msg; //echo $msg;
$msg = str_replace('<br>','',$msg); $msg = str_replace('<br>','',$msg);
SMS_GUPSHUP::sendSMS($msg,$lender_sms); $additional_data_for_logs['to_whom'] = 'LEDNER';
SMS_GUPSHUP::sendSMS($msg,$lender_sms,$additional_data_for_logs);
} }
@ -160,7 +162,7 @@ class PDALERTS
{ {
$lender_web_token = (string)$core_details[0]['pd_contact_mobileno']; $lender_web_token = (string)$core_details[0]['pd_contact_mobileno'];
$lender_mob_token = (string)$core_details[0]['pd_contact_mobileno']; $lender_mob_token = (string)$core_details[0]['pd_contact_mobileno'];
$pd_status = $core_details[0]['pd_status'];
} }
@ -183,7 +185,8 @@ class PDALERTS
{ {
$msg = $pd_notification_msg[0]['pdofficer']; $msg = $pd_notification_msg[0]['pdofficer'];
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
foreach($mobile_nos_to_send_notification as $mobile){ SMS_GUPSHUP::sendSMS($msg,(string)$mobile); }; $additional_data_for_logs['to_whom'] = 'PD_OFFICER';
foreach($mobile_nos_to_send_notification as $mobile){ SMS_GUPSHUP::sendSMS($msg,(string)$mobile,$additional_data_for_logs); };
} }
@ -195,7 +198,7 @@ class PDALERTS
/*********************************************/ /*********************************************/
if($pd_notification_configs[0]['app_pdofficer'] == 1) if($pd_notification_configs[0]['app_pdofficer'] == 1)
{ {
$pd_status = $core_details[0]['pd_status'];
$pd_offcier_web_token = $core_details[0]['pdofficer_webtoken']; $pd_offcier_web_token = $core_details[0]['pdofficer_webtoken'];
$pd_offcier_mob_token = $core_details[0]['pdofficer_mobtoken']; $pd_offcier_mob_token = $core_details[0]['pdofficer_mobtoken'];
$pd_executive_mob_token = $core_details[0]['pdexecutive_mobtoken']; $pd_executive_mob_token = $core_details[0]['pdexecutive_mobtoken'];
@ -203,8 +206,8 @@ class PDALERTS
$msg = $pd_notification_msg[0]['pdofficer']; $msg = $pd_notification_msg[0]['pdofficer'];
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
PUSH_NOTIFICATION::sendNotification($pd_offcier_mob_token,$pd_offcier_web_token,$pd_status,$msg); PUSH_NOTIFICATION::sendNotification($pd_offcier_mob_token,$pd_offcier_web_token,$msg,$additional_data_for_logs);
PUSH_NOTIFICATION::sendNotification($pd_executive_mob_token,$pd_executive_web_token,$pd_status,$msg); PUSH_NOTIFICATION::sendNotification($pd_executive_mob_token,$pd_executive_web_token,$msg,$additional_data_for_logs);
} }
@ -219,7 +222,8 @@ class PDALERTS
{ {
$msg = $pd_notification_msg[0]['customer']; $msg = $pd_notification_msg[0]['customer'];
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
SMS_GUPSHUP::sendSMS($msg,(string)$core_details[0]['customer_mobile_no']); $additional_data_for_logs['to_whom'] = 'CUSTOMER';
SMS_GUPSHUP::sendSMS($msg,(string)$core_details[0]['customer_mobile_no'],$additional_data_for_logs);
} }
} }
} }
@ -236,7 +240,8 @@ class PDALERTS
{ {
$msg = $pd_notification_msg[0]['pdincharge']; $msg = $pd_notification_msg[0]['pdincharge'];
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
SMS_GUPSHUP::sendSMS($msg,(string)$core_details[0]['centralpdofficer_mobile_no']); $additional_data_for_logs['to_whom'] = 'PDMANAGER/PDINCHARGE';
SMS_GUPSHUP::sendSMS($msg,(string)$core_details[0]['centralpdofficer_mobile_no'],$additional_data_for_logs);
} }
} }
} }
@ -247,12 +252,12 @@ class PDALERTS
/*********************************************/ /*********************************************/
if($pd_notification_configs[0]['app_pdincharge'] == 1) if($pd_notification_configs[0]['app_pdincharge'] == 1)
{ {
$pd_status = $core_details[0]['pd_status'];
$central_offcier_web_token = $core_details[0]['centralpdofficer_webtoken']; $central_offcier_web_token = $core_details[0]['centralpdofficer_webtoken'];
$central_offcier_mob_token = $core_details[0]['centralpdofficer_mobtoken']; $central_offcier_mob_token = $core_details[0]['centralpdofficer_mobtoken'];
$msg = $pd_notification_msg[0]['pdincharge']; $msg = $pd_notification_msg[0]['pdincharge'];
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
PUSH_NOTIFICATION::sendNotification($central_offcier_mob_token,$central_offcier_web_token,$pd_status,$msg); PUSH_NOTIFICATION::sendNotification($central_offcier_mob_token,$central_offcier_web_token,$msg,$additional_data_for_logs);
} }
@ -281,9 +286,9 @@ class PDALERTS
{ {
$msg = $pd_notification_msg[0]['qc_team']; $msg = $pd_notification_msg[0]['qc_team'];
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
$additional_data_for_logs['to_whom'] = 'QC_TEAM';
foreach($mobile_nos_to_send_notification as $mobile){ foreach($mobile_nos_to_send_notification as $mobile){
SMS_GUPSHUP::sendSMS($msg,(string)$mobile['mobile_no']); SMS_GUPSHUP::sendSMS($msg,(string)$mobile['mobile_no'],$additional_data_for_logs);
}; };
} }
} }
@ -308,7 +313,7 @@ class PDALERTS
{ {
$qc_team_web_token = array(); $qc_team_web_token = array();
$qc_team_mob_token = array(); $qc_team_mob_token = array();
$pd_status = $core_details[0]['pd_status'];
foreach($qcteam_push_tokens as $token) foreach($qcteam_push_tokens as $token)
{ {
if(isset($token['web_token']) && ($token['web_token'] != "" || $token['web_token'] != null)) if(isset($token['web_token']) && ($token['web_token'] != "" || $token['web_token'] != null))
@ -326,13 +331,13 @@ class PDALERTS
$msg = $pd_notification_msg[0]['qc_team']; $msg = $pd_notification_msg[0]['qc_team'];
$msg = self::stringReplace($msg,$core_details); $msg = self::stringReplace($msg,$core_details);
$additional_data_for_logs['to_whom'] = 'QC_TEAM';
foreach ($qc_team_web_token as $key => $value) { foreach ($qc_team_web_token as $key => $value) {
PUSH_NOTIFICATION::sendNotification($value,null,$pd_status,$msg); PUSH_NOTIFICATION::sendNotification($value,null,$msg,$additional_data_for_logs);
} }
foreach ($qc_team_mob_token as $key => $value) { foreach ($qc_team_mob_token as $key => $value) {
PUSH_NOTIFICATION::sendNotification(null,$value,$pd_status,$msg); PUSH_NOTIFICATION::sendNotification(null,$value,$msg,$additional_data_for_logs);
} }

View File

@ -6,23 +6,23 @@ class PUSH_NOTIFICATION
public static function sendNotification($web_token,$mob_token,$pd_status,$msg) public static function sendNotification($web_token,$mob_token,$msg,$additional_data = array())
{ {
$CI =&get_instance(); $CI =&get_instance();
if($web_token != "" || $web_token != null) if($web_token != "" || $web_token != null)
{ {
PUSH_NOTIFICATION::notifyWeb($web_token,$pd_status,$msg); PUSH_NOTIFICATION::notifyWeb($web_token,$pd_status,$msg,$additional_data);
} }
if($mob_token != "" || $mob_token != null) if($mob_token != "" || $mob_token != null)
{ {
PUSH_NOTIFICATION::notifyMob($mob_token,$pd_status,$msg); PUSH_NOTIFICATION::notifyMob($mob_token,$pd_status,$msg,$additional_data);
} }
} }
public static function notifyWeb($web_token,$pd_status,$msg) public static function notifyWeb($web_token,$msg,$additional_data)
{ {
$web_msg = array $web_msg = array
( (
@ -34,10 +34,10 @@ class PUSH_NOTIFICATION
); );
self::dispatchNotification(array($web_token),$web_msg,1); self::dispatchNotification(array($web_token),$web_msg,1,$additional_data);
} }
public static function notifyMob($mob_token,$pd_status,$msg) public static function notifyMob($mob_token,$msg,$additional_data)
{ {
$app_msg = array $app_msg = array
@ -52,11 +52,11 @@ class PUSH_NOTIFICATION
'smallIcon'=>'https://ssa.sineedge.com/logo/sinelogo.png' 'smallIcon'=>'https://ssa.sineedge.com/logo/sinelogo.png'
); );
self::dispatchNotification(array($mob_token),$app_msg,2); self::dispatchNotification(array($mob_token),$app_msg,2,$additional_data);
} }
public static function dispatchNotification($token,$msg,$type) public static function dispatchNotification($token,$msg,$type,$additional_data)
{ {
$fields = array $fields = array
@ -80,8 +80,8 @@ class PUSH_NOTIFICATION
$result = curl_exec($ch ); $result = curl_exec($ch );
curl_close( $ch ); curl_close( $ch );
$CI =&get_instance(); $CI =&get_instance();
print_r($result); //print_r($result);
MYLOG::logFunction()->info("PUSH NOTIFICATION ",array($result)); MYLOG::logFunction()->info("PUSH NOTIFICATION ",array('firebase_result' => $result,'additional_data' => $additional_data,'token_type' => ($type == 1? 'WEB' : 'MOB')),'token' => $token);
} }
} }

View File

@ -3,7 +3,7 @@
class SMS_GUPSHUP class SMS_GUPSHUP
{ {
public static function sendSMS($msg,$no) public static function sendSMS($msg,$no,$additional_data = array())
{ {
$CI =&get_instance(); $CI =&get_instance();
$msg=str_replace(array(" ","'",":",",","/","#",),array('%20','%27', '%3A', '%2C', '%2F', '%23'),$msg); $msg=str_replace(array(" ","'",":",",","/","#",),array('%20','%27', '%3A', '%2C', '%2F', '%23'),$msg);
@ -19,7 +19,7 @@ class SMS_GUPSHUP
$contents = (string) $response->getBody(); $contents = (string) $response->getBody();
$logger = MYLOG::logFunction(); $logger = MYLOG::logFunction();
$logger->info("Msg Send Status",array('response_data' => $contents,'mobile_no' => $no,'msg' => $msg,'sms_api_url' => $sms_api_url)); $logger->info("Msg Send Status",array('response_data' => $contents,'mobile_no' => $no,'msg' => $msg,'sms_api_url' => $sms_api_url,'additional_data' => $additional_data));
} }

View File

@ -53,10 +53,27 @@
* *
* NOTE: If you change these, also change the error_reporting() code below * NOTE: If you change these, also change the error_reporting() code below
*/ */
//define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
define('ENVIRONMENT','testing');
date_default_timezone_set('Asia/Kolkata');
date_default_timezone_set('Asia/Kolkata');
if(isset($_SERVER['HTTP_HOST']) && !strcasecmp($_SERVER['HTTP_HOST'],'demo.pdgenie.com') && isset($_SERVER['REQUEST_URI']) && substr_count($_SERVER['REQUEST_URI'], 'sparqapi') == 1)
{
define('ENVIRONMENT','development');
}
else if(isset($_SERVER['HTTP_HOST']) && !strcasecmp($_SERVER['HTTP_HOST'],'demo.pdgenie.com') && isset($_SERVER['REQUEST_URI']) && substr_count($_SERVER['REQUEST_URI'], 'sparqtest') == 1)
{
define('ENVIRONMENT','testing');
}
else if(isset($_SERVER['HTTP_HOST']) && !strcasecmp($_SERVER['HTTP_HOST'],'demo.pdgenie.com') && isset($_SERVER['REQUEST_URI']) && substr_count($_SERVER['REQUEST_URI'], 'sparqprod') == 1)
{
define('ENVIRONMENT','sparqprod');
}
else
{
define('ENVIRONMENT','development');
}
//echo ENVIRONMENT;
//die();
/* /*