diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 5492d267..def251fe 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -209,7 +209,11 @@ $route['sendStudentNotification'] = 'Fees_Status_Controller/sendStudentNotificat * */ $route['getUniveCourseBratchBroadCast'] = 'Broadcast_Controller/getUniveCourseBatch'; $route['getStuListForBroadcast'] = 'Broadcast_Controller/getStuListForBrodcast'; -$route['sendSMSStudentApi'] = 'Broadcast_Controller/sendSMSStudentApi'; +$route['sendSMSStudentApi'] = 'Broadcast_Controller/sendSMSStudentApi';` + +$route['getCronCall'] = 'Broadcast_Controller/getCronCall'; +$route['getSMSSendReportList'] = 'Broadcast_Controller/getSMSSendReportList'; +$route['getSMSGroupDetails'] = 'Broadcast_Controller/getSMSGroupDetails'; diff --git a/Apollo/api/application/controllers/Broadcast_Controller.php b/Apollo/api/application/controllers/Broadcast_Controller.php index 8ba3a8f0..573ad4af 100644 --- a/Apollo/api/application/controllers/Broadcast_Controller.php +++ b/Apollo/api/application/controllers/Broadcast_Controller.php @@ -93,7 +93,7 @@ class Broadcast_Controller extends REST_Controller { ); } - $sendMsgDetails = $this->broadcast_model->send_msg_students($data, $msg);// Check if the employee exist + $sendMsgDetails = $this->broadcast_model->send_msg_students($data, $msg, $reqDetails);// Check if the employee exist if ($sendMsgDetails) { $sendMsgDetails['status'] = REST_Controller::HTTP_OK; @@ -109,4 +109,75 @@ class Broadcast_Controller extends REST_Controller { ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code } } + + public function getSMSGroupDetails_post() { + $reqData = $this->post('data'); + $reqDataBy = $this->post('localReqDetails'); + // print_r($reqData);exit(); + $getMegDetails = $this->broadcast_model->getSMSGroupDetails($reqData);// Check if the employee exist + if ($getMegDetails) + { + $getMegDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getMegDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + + public function getSMSSendReportList_post(){ + + $reqData = $this->post('data'); + $reqDataBy = $this->post('localReqDetails'); + // $time = date('Y-m-d H:i:s'); + // $dateTime = $time; + // $date1 = $dateTime; + // $date2 = $dateTime; + + $getMegCronDetails = $this->broadcast_model->getSmsSendBetweenDate($reqData, $reqDataBy);// Check if the employee exist + if ($getMegCronDetails) + { + $getMegCronDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + + public function getCronCall_get() { + $getMegCronDetails = $this->broadcast_model->getCronUpdate();// Check if the employee exist + // echo $getMegCronDetails;exit(); + if($getMegCronDetails){ + echo $getMegCronDetails; + }else { + + } + // if ($getMegCronDetails) + // { + // $getMegCronDetails['status'] = REST_Controller::HTTP_OK; + // // Set the response and exit + // $this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + // } + // else + // { + // // Set the response and exit + // $this->response([ + // 'message' => 'No list were found', + // 'status' => REST_Controller::HTTP_NOT_FOUND + // ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + // } + } } diff --git a/Apollo/api/application/models/Broadcast_model.php b/Apollo/api/application/models/Broadcast_model.php index 915bfa20..f7e48e48 100644 --- a/Apollo/api/application/models/Broadcast_model.php +++ b/Apollo/api/application/models/Broadcast_model.php @@ -81,44 +81,129 @@ class Broadcast_model extends CI_Model return $results; } + public function getSMSGroupDetails($reqData) { + $querys = "SELECT t1.*, t2.DeliveredStatus, t2.DeliveredOn FROM T_BroadcastStatus as t1 + LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId + WHERE t1.MsgGroup = '$reqData' ORDER BY t1.CreatedOn DESC"; - public function send_msg_students($arr, $msg) { + $smsSendGroupDetails = $this->db->query($querys); + $smsSendGroupDetailsList = $smsSendGroupDetails->result(); + $results['smsSendGroupDetailsListStatus'] = true; + $results['smsSendGroupDetailsList'] = $smsSendGroupDetailsList; + return $results; + } + + public function getSmsSendBetweenDate($reqData, $reqDataBy) { + + if($reqData['date'] != '' && $reqData['dateTo'] != '') { + $d = new DateTime($reqData['date']); + $dTo = new DateTime($reqData['dateTo']); + $fromDate = $d->format('Y-m-d'); + $toDate = $dTo->format('Y-m-d'); + + // $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1 + // LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId + // WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate' + // AND '$toDate' ORDER BY t1.CreatedOn DESC"; + + $querys = "SELECT t1.*, COUNT(t1.MsgGroup) as MSG_SEND_CNT FROM T_BroadcastStatus as t1 + LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId + WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate' + AND '$toDate' GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC"; + + $smsSendDetails = $this->db->query($querys); + $smsSendDetailsList = $smsSendDetails->result(); + $results['smsSendDetailsListStatus'] = true; + $results['smsSendDetailsList'] = $smsSendDetailsList; + + } else { + // $d = new DateTime($d1); + // $dTo = new DateTime($d2); + // $fromDate = $d->format('Y-m-d'); + // $toDate = $dTo->format('Y-m-d'); + + // $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1 + // LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId + // WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate' + // AND '$toDate' ORDER BY t1.CreatedOn DESC"; + + $querys = "SELECT t1.*, COUNT(t1.MsgGroup) FROM T_BroadcastStatus as t1 + LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId + GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC"; + + $smsSendDetails = $this->db->query($querys); + $smsSendDetailsList = $smsSendDetails->result(); + $results['smsSendDetailsListStatus'] = true; + $results['smsSendDetailsList'] = $smsSendDetailsList; + $results['smsSendDetailsListStatus'] = true; + $results['smsSendDetailsList'] = $smsSendDetailsList; + + } + + + return $results; + } + + + public function send_msg_students($arr, $msg, $reqDetails) { $msg_body = $msg['content']; - $mesg = "Status Update : check - check check."; + $sender = $reqDetails['localUserID']; + $mesg = "$msg_body"; + // $mesg = "Status Update : check - check check."; + // $mesg = "Check"; $resp = $this->smssend($arr, $mesg); - // $arrss = explode('
', $resp); - // $results['resp'] = $resp; - // for($i=0; $i MsgID -// [1] => 4fad03cf13734a869307b19fcc293570 -// [2] => 919942080003 -// [3] => 201801191700328088 -// [4] => success -// ) - // $msgId = $a[0]; - // $msgNumb = $a[1]; - // $msgStatus = $a[4]; - // // print_r ($a);exit; - // // echo $a[1];exit(); - // $data[] = array( - // 'MsgID' => $msgId, - // 'MsgNum' => $msgNumb, - // 'MsgDelvStatus' => $msgStatus - // ); - // } - + // echo $resp ;exit(); + $arrss = explode('
', $resp); + // Array + // ( + // [0] => MsgID + // [1] => 4fad03cf13734a869307b19fcc293570 + // [2] => 919942080003 + // [3] => 201801191700328088 + // [4] => success + // ) + $time = date('Y-m-d H:i:s'); + $dateTime = $time; + $msgGroup = date('YmdHis'); + + for($i=0, $c = count($arrss) ; $i< $c; $i++){ + // echo $arrss[$i];exit(); + if( $arrss[$i] === '') { + break; + } else { + $a = explode(':', $arrss[$i]); + $msgIdState = $a[0]; + $msgId = $a[1]; + $msgNumb = $a[2]; + $msgStatus = $a[4]; + $data[] = array( + 'MsgId' => $msgId, + 'MobileNumber' => $msgNumb, + 'MsgBody' => $mesg, + 'Status' => $msgStatus, + 'CreatedOn' => $dateTime, + 'CreatedBy' => $sender, + 'MsgGroup' => $msgGroup + ); + continue; + } + } + $this->db->insert_batch('T_BroadcastStatus', $data); + if ($this->db->affected_rows() >= 1) { + $result['msgStatus'] = true; + $result['message'] = "Successfully Messages Sended!!"; + } else { + $result['msgStatus'] = false; + $result['message'] = "error!!"; + } + // print_r($data); + // exit(); // $msgID = $arrss[1]; // $msgSendTime = $arrss[2]; // $msgDeleveredNum = $arrss[3]; // $msgSendStatus = $arrss[3]; // print_r($data);exit(); - $result['msgStatus'] = true; - $result['message'] = "Successfully Messages Sended!!"; return $result; } @@ -151,7 +236,7 @@ class Broadcast_model extends CI_Model $message = urlencode($msg); // echo $mobile , $message; $ch=curl_init(); - curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=TEMPLATE_BASED"); + curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=PROMOTIONAL_HIGH"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $output =curl_exec($ch); @@ -161,4 +246,64 @@ class Broadcast_model extends CI_Model return $output; } + public function getCronUpdate() { + $date2 = date('Y-m-d'); + + $quw = "SELECT * FROM T_BroadcastDeliveryCron ORDER BY id DESC LIMIT 1"; + $myext = $this->db->query($quw)->first_row(); + // print_r($this->db->query($quw)->first_row());exit(); + if($myext){ + if($myext->CreatedOn){ + $arrsss = explode(' ', $myext->CreatedOn); + } + $date1 = $myext->CreatedOn != '' ? $arrsss[0] : $date2; + } else { + $date1 = $date2; + } + + $ch=curl_init(); + curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/GetReports.aspx?APIKEY=xegCdYUIMf3&StartDate=".$date1."&EndDate=".$date2.""); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + $output =curl_exec($ch); + + curl_close($ch); + + $arrss = explode('
', $output); + // Array + // ( + // [0] => MsgID + // [1] => 4fad03cf13734a869307b19fcc293570 + // [2] => 919942080003 + // [3] => 201801191700328088 + // [4] => success + // ) + $time = date('Y-m-d H:i:s'); + $dateTime = $time; + for($i=0, $c = count($arrss) ; $i< $c; $i++){ + // echo $arrss[$i];exit(); + if( $arrss[$i] === '') { + break; + } else { + $a = explode('|', $arrss[$i]); + $msgId = $a[0]; + $msgNumb = $a[1]; + $delvStatus = $a[2]; + $delvOn = $a[3]; + $qury1 = "SELECT * FROM T_BroadcastDeliveryCron WHERE MsgId = '$msgId'"; + $choe = $this->db->query($qury1)->first_row(); + if($this->db->query($qury1)->first_row()){ + $qury2 = "UPDATE T_BroadcastDeliveryCron SET DeliveredStatus = '$delvStatus', DeliveredOn = '$delvOn' WHERE MsgId = '$msgId'"; + $choe2 = $this->db->query($qury2); + continue; + } else { + $qury3 = " INSERT INTO T_BroadcastDeliveryCron (MsgId, MobileNumber, DeliveredStatus, DeliveredOn, CreatedOn) VALUES('$msgId', '$msgNumb', '$delvStatus', '$delvOn', '$dateTime')"; + $choe3 = $this->db->query($qury3); + continue; + } + } + } + return 'records updated!!'; + } + } \ No newline at end of file diff --git a/Apollo/assets/i18n/en.json b/Apollo/assets/i18n/en.json index fe66f650..108722c4 100755 --- a/Apollo/assets/i18n/en.json +++ b/Apollo/assets/i18n/en.json @@ -126,7 +126,9 @@ "MAIN": "MY PROFILE" }, "sendSMSPage": { - "MAIN": "SMS SEND" + "MAIN": "BROADCAST", + "SENDSMS": "SMS SEND", + "SENDSMSDETAILS": "SEND SMS DETAILS" } } }, diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index 14787d09..420a7c1f 100755 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -158,6 +158,7 @@ app.constant('JS_REQUIRES', { // day book master 'dayBookMasterCtrl':'assets/js/controllers/dayBookMasterCtrl.js', 'sendSMSsuperadminCtrl':'assets/js/controllers/sendSMSsuperadminCtrl.js', + 'sendSMSDetailssuperadminCtrl': 'assets/js/controllers/sendSMSDetailssuperadminCtrl.js', 'feesNotification':'assets/js/controllers/feesNotification.js', diff --git a/Apollo/assets/js/config.router.js b/Apollo/assets/js/config.router.js index 3a001256..59619510 100755 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -384,7 +384,14 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com ncyBreadcrumb: { label: 'daybook' } - }).state('app.sendSMSPage', { + }).state('app.broadCast', { + url: '/broadcast', + template: '
BROADCAST DETAILS
', + title: 'Broadcast', + ncyBreadcrumb: { + label: 'Broadcast' + } + }).state('app.broadCast.sendSMSPage', { url: '/sendSMS', templateUrl: "assets/views/sendSMS/sendSMSsuperadmin.html", title: 'send SMS', @@ -392,6 +399,14 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com ncyBreadcrumb: { label: 'send SMS' } + }).state('app.broadCast.sendSMSDetails', { + url: '/sendSMSDetails', + templateUrl: "assets/views/sendSMS/sendSMSDetailssuperadmin.html", + title: 'Send SMS Details', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'sendSMSDetailssuperadminCtrl','ngTable'), + ncyBreadcrumb: { + label: 'Send SMS Details' + } }).state('app.daybook.income', { url: '/income', templateUrl: "assets/views/utility_search_result.html", diff --git a/Apollo/assets/js/controllers/sendSMSDetailssuperadminCtrl.js b/Apollo/assets/js/controllers/sendSMSDetailssuperadminCtrl.js new file mode 100644 index 00000000..32b137b1 --- /dev/null +++ b/Apollo/assets/js/controllers/sendSMSDetailssuperadminCtrl.js @@ -0,0 +1,115 @@ +'use strict'; +/*** controller for Wizard Form example***/ +app.controller('sendSMSDetailssuperadminCtrl', ["$scope", "$filter", "ngTableParams", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', function ($scope, $filter, ngTableParams, apiPoint, $http, SweetAlert, $state, md5, ipCookie) { + + /** + * Send SMS Details Functionality + * by : kdk + */ + var localDetail = JSON.parse(localStorage.getItem('localObj')); + var localDetails = ipCookie('cookiechk'); + $scope.searchLoading = false; + $scope.searchData = { + "date": "", + "dateTo": "" + } + $scope.init = function () { + if (localDetail != null) { + $scope.currentDate = new Date(); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + $scope.getSmsReport(); + } else { + } + }; + + // change from date, update and call search functionality + $scope.changeDate = function () { + if ($scope.searchData.date !== undefined) { + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.searchData.date), formate); + $scope.getSmsReport(); + } else { + $scope.searchData.date = ''; + $scope.getSmsReport(); + } + } + + // change to date, update and call search functionality + $scope.changeToDate = function () { + if ($scope.searchData.dateTo !== undefined) { + var formate = "dd-MM-yyyy"; + $scope.searchData.dateTo = $filter('date')(new Date($scope.searchData.dateTo), formate); + $scope.getSmsReport(); + } else { + $scope.searchData.dateTo = ''; + $scope.getSmsReport(); + } + } + + $scope.resData = ''; + // get report for the smssended + $scope.getSmsReport = function() { + // console.log($scope.searchData); + $scope.searchLoading = true; + var getSearchDetails = { + method: 'POST', + url: apiPoint.url + 'getSMSSendReportList/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.searchData, + requestDetails: localDetails + } + }; + $http(getSearchDetails).then(function (response) { + if (response.data.smsSendDetailsListStatus) { + $scope.resData = response.data.smsSendDetailsList; + $scope.searchLoading = false; + } else { + $scope.searchLoading = false; + } + }); + }; + + $scope.setEditId = function (P) { + // alert(P); + $scope.editId = P; + } + + $scope.cancel = function () { + $scope.editId = -1; + } + + $scope.resGroupSendData = ''; + $scope.getPartMesgDetailsLoading = false; + $scope.prevNoRecordFound = false; + $scope.getPartMesgDetails = function(p) { + $scope.getPartMesgDetailsLoading = true; + var getMsgDetails = { + method: 'POST', + url: apiPoint.url + 'getSMSGroupDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: p.MsgGroup, + requestDetails: localDetails + } + }; + $http(getMsgDetails).then(function (response) { + if (response.data.smsSendGroupDetailsListStatus) { + $scope.resGroupSendData = response.data.smsSendGroupDetailsList; + $scope.prevNoRecordFound = true; + $scope.getPartMesgDetailsLoading = false; + } else { + $scope.prevNoRecordFound = false; + $scope.getPartMesgDetailsLoading = false; + } + }); + } + + +}]); diff --git a/Apollo/assets/js/controllers/sendSMSsuperadminCtrl.js b/Apollo/assets/js/controllers/sendSMSsuperadminCtrl.js index 8dd2844b..0622b7d2 100644 --- a/Apollo/assets/js/controllers/sendSMSsuperadminCtrl.js +++ b/Apollo/assets/js/controllers/sendSMSsuperadminCtrl.js @@ -175,7 +175,7 @@ app.controller('sendSMSsuperadminCtrl', ["$scope", "$filter", "ngTableParams", " } - $scope.statusUpdate = { + $scope.statusUpdate = { submit: function (form, msg_details) { var firstError = null; if (form.$invalid) { @@ -242,4 +242,28 @@ app.controller('sendSMSsuperadminCtrl', ["$scope", "$filter", "ngTableParams", " } } + // get report for the smssended + $scope.getSmsReport = function() { + // console.log($scope.searchData); + var getSearchDetails = { + method: 'POST', + url: apiPoint.url + 'getSMSSendReportList/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.searchData, + requestDetails: localDetails + } + }; + $http(getSearchDetails).then(function (response) { + if (response.data.searchResult) { + + } else { + + } + }); + }; + + }]); diff --git a/Apollo/assets/views/partials/nav.html b/Apollo/assets/views/partials/nav.html index 1f036dbb..bdf86daa 100755 --- a/Apollo/assets/views/partials/nav.html +++ b/Apollo/assets/views/partials/nav.html @@ -204,19 +204,32 @@ - + + +
  • diff --git a/Apollo/assets/views/sendSMS/listingViewOfSMSSendDetails.html b/Apollo/assets/views/sendSMS/listingViewOfSMSSendDetails.html new file mode 100644 index 00000000..900c5448 --- /dev/null +++ b/Apollo/assets/views/sendSMS/listingViewOfSMSSendDetails.html @@ -0,0 +1,40 @@ +
    +
    +
    +

    Fetching ...

    +
    +
    +
    + + + + + + + + + + + + + + + + + +
    Message IdMobile NumberDelivery StatusDelivery On
    {{s.MsgId}}{{s.MobileNumber}}{{s.DeliveredStatus}}{{s.DeliveredOn}}
    + +
    +
    +

    No + Status Details Exist ...

    +
    +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/Apollo/assets/views/sendSMS/sendSMSDetailssuperadmin.html b/Apollo/assets/views/sendSMS/sendSMSDetailssuperadmin.html new file mode 100644 index 00000000..6ad89c27 --- /dev/null +++ b/Apollo/assets/views/sendSMS/sendSMSDetailssuperadmin.html @@ -0,0 +1,158 @@ + +
    +
    +
    +

    {{ mainTitle }}

    +
    +
    +
    +
    + + +
    +
    +
    + +
    + +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    + +
    +

    loading...

    +
    + +
    + + +
    +
    +

    No + records found...

    +
    +
    + +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    Message + Message Count + Send On +
    {{p.MsgBody}} {{$index}}{{p.MSG_SEND_CNT}}{{p.CreatedOn}} + +
    + + +
    +
    +

    Fetching ...

    +
    +
    +
    + + + + + + + + + + + + + +
    Message IdMobile NumberDelivery StatusDelivery On
    {{s.MsgId}}{{s.MobileNumber}}{{s.DeliveredStatus}}{{s.DeliveredOn}}
    + + +
    +
    +

    No + Status Details Exist ...

    +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    \ No newline at end of file