broadcast changes: kdk (1-6-2018)

This commit is contained in:
dineshkumarkannan 2018-06-01 09:58:36 +05:30
parent 713cef0857
commit dfaa6683c7
5 changed files with 330 additions and 13 deletions

View File

@ -229,7 +229,7 @@ $route['sendSMSStudentApi'] = 'Broadcast_Controller/sendSMSStudentApi';
$route['getCronCall'] = 'Broadcast_Controller/getCronCall';
$route['getSMSSendReportList'] = 'Broadcast_Controller/getSMSSendReportList';
$route['getSMSGroupDetails'] = 'Broadcast_Controller/getSMSGroupDetails';
$route['sendPromotionalMsg'] = 'Broadcast_Controller/sendPromotionalMsg';
//center
$route['addCenterDetails'] = 'Center_Controller/addCenterDetails';

View File

@ -121,6 +121,25 @@ class Broadcast_Controller extends REST_Controller {
}
}
public function sendPromotionalMsg_post() {
$reqData = $this->post('data');
$reqDataBy = $this->post('requestDetails');
$message = $reqData["message"];
$numsArr = $reqData["numbers"];
// print_r($numsArr);exit();
$getMegCronDetails = $this->broadcast_model->sendPromotionalMsg( $message ,$numsArr, $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();

View File

@ -131,6 +131,54 @@ class Broadcast_model extends CI_Model {
return $results;
}
public function sendPromotionalMsg($msg, $nums, $reqData){
// print_r($msg);
// print_r($nums);
// print_r($reqData);exit();
$msg_body = $msg;
$sender = $reqData['localUserID'];
$localBranch = $reqData['localBranchID'];
$mesg = "$msg_body";
// $mesg = "Status Update : check - check check.";
// $mesg = "Check";
$resp = $this->smssendPromotional($nums, $mesg);
// echo $resp ;exit();
$arrss = explode('<br>', $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, 'BranchCode' => $localBranch);
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!!";
}
return $result;
}
//get sms sent details
public function getSmsSendBetweenDate($reqData, $reqDataBy) {
$localBranch = $reqDataBy['localBranchID'];
@ -260,6 +308,30 @@ class Broadcast_model extends CI_Model {
return $output;
}
// This is the template to be used.
public function smssendPromotional($arr, $msg) {
$number = array();
// echo $msg;exit();
foreach ($arr as $ar) {
$result = substr($ar, 0, 3);
if($result === '+91'){
array_push($number, "$ar");
} else {
array_push($number, "91$ar");
}
}
$mobile = implode(',', $number);
// $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login.";
// $mobile = "91$mobile";
$message = urlencode($msg);
$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=PROMOTIONAL_HIGH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
//get cron job call
public function getCronUpdate() {
$date2 = date('Y-m-d');

View File

@ -272,6 +272,122 @@ app.controller('sendSMSsuperadminCtrl', ["$scope", "$filter", "ngTableParams", "
});
};
// ===================================== send individual sms
$scope.mobileNumList = {
"mobile" : "",
"messange": ""
}
$scope.listMobileNums = [];
$scope.addContactsList = function() {
// alert($scope.mobileNumList.mobile);
// if($scope.mobileNumList.mobile !=='' && $scope.mobileNumList.mobile !== null && $scope.mobileNumList.mobile !== undefined
// ) {
// $scope.listMobileNums.push($scope.mobileNumList.mobile);
// }else {
// swal(" ", "Please Should Enter Valid Mobile Number.", "warning");
// }
}
$scope.deletMobileList = function(num) {
var index = $scope.listMobileNums.indexOf(num);
$scope.listMobileNums.splice(index, 1);
}
$scope.composeMsgNumber = function() {
var phoneno = /^\d{10}$/;
var mobileNumber = $scope.mobileNumList.mobile;
if($scope.mobileNumList.mobile !=='' && $scope.mobileNumList.mobile !== null && $scope.mobileNumList.mobile !== undefined
&& mobileNumber.match(phoneno)) {
$scope.listMobileNums.push($scope.mobileNumList.mobile);
$scope.mobileNumList.mobile = '';
}else {
swal(" ", "Please Should Enter Valid Mobile Number.", "warning");
}
}
// add a new daybook entry
$scope.composeMsg = {
submit: function (form) {
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
for (field in form) {
if (field[0] != '$') {
if (firstError === null && !form[field].$valid) {
firstError = form[field].$name;
}
if (form[field].$pristine) {
form[field].$dirty = true;
}
}
}
angular.element('.ng-invalid[name=' + firstError + ']').focus();
} else {
if($scope.listMobileNums.length > 0) {
var msg = $scope.mobileNumList.message;
// alert(msg);
var nums = $scope.listMobileNums;
var datas = {
"message": msg,
"numbers": nums
};
var sendMsgStatus = {
method: 'POST',
url: apiPoint.url + 'sendPromotionalMsg/',
headers: {
'Content-Type': 'application/json'
},
data: {
data: datas,
requestDetails: localDetails
}
};
$http(sendMsgStatus).then(function (response) {
if (response.data.msgStatus == true) {
swal(" ", response.data.message, "success");
$scope.mobileNumList.message = '';
} else {
swal(" ", response.data.message, "error");
}
});
} else {
swal(" ", "Please Enter Mobile Number.", "warning");
}
// $scope.disableAddButton = true;
// var sdate= $('#datere').val();
// var formate = "dd-MM-yyyy";
// $scope.myModelAdd.date= sdate;
// $scope.myModelAdd.status = $scope.myModelAdd.name == 'I001' ? 'Pending' : 'Approved';
// var addDayBookDetails = {
// method: 'POST',
// url: apiPoint.url + 'addDayBook/',
// headers: {
// 'Content-Type': 'application/json'
// },
// data: {
// data: myModelAdd,
// localReqDetails: localDetails
// }
// };
// $http(addDayBookDetails).then(function (response) {
// if (response.data.addDayBookStatus) {
// swal(" ", "Income/Expense added successfully.", "success");
// $state.go($state.current, {}, { reload: true });
// $scope.disableAddButton = false;
// } else {
// swal(" ", response.data.message, "error");
// $scope.disableAddButton = false;
// }
// });
}
},
reset: function (form) {
}
}
}]);
app.filter('unique', function() {
@ -394,7 +510,6 @@ app.controller('studentModalDemoCtrl', ["$scope", "$rootScope", "$modal", "$log"
});
}
}]);
// Please note that $modalInstance represents a modal window (instance) dependency.

View File

@ -15,6 +15,8 @@
<!-- /// controller: 'UserCtrl' - localtion: assets/js/controllers/sendSMSsuperadminCtrl.js /// -->
<div ng-controller="sendSMSsuperadminCtrl" ng-init="init()">
<!--<h1>D</h1>-->
<tabset class="tabbable">
<tab heading="Send Student Messages" id="viewDayBook">
<div class="row">
<!--<div class="col-md-3">
<label for="form-field-select-2">
@ -36,7 +38,16 @@
<option ng-repeat="item in universityData" value="{{item}}">{{item.UniversityName}}</option>
</select>
</div>
<div class="col-md-3">
<label for="form-field-select-2">
Batch
</label>
<select class="form-control" tabindex="3" class="cs-select cs-skin-elastic" name="batch" ng-model="searchData.Batch" ng-change="getValueChange()">
<option value="" selected>Select Batch</option>
<option ng-repeat="itemBatch in batchData" value="{{itemBatch.BatchCode}}">{{itemBatch.BatchName}}</option>
</select>
</div>
<div class="col-md-3">
<label for="form-field-select-2">
@ -49,16 +60,7 @@
</select>
</div>
<div class="col-md-3">
<label for="form-field-select-2">
Batch
</label>
<select class="form-control" tabindex="3" class="cs-select cs-skin-elastic" name="batch" ng-model="searchData.Batch" ng-change="getValueChange()">
<option value="" selected>Select Batch</option>
<option ng-repeat="itemBatch in batchData" value="{{itemBatch.BatchCode}}">{{itemBatch.BatchName}}</option>
</select>
</div>
</div>
<!--<pre>{{ branchList_data }}</pre>-->
<!--<pre>{{ studentListDetails | json }}</pre>-->
@ -110,7 +112,7 @@
cursor: pointer;
}
</style>
<input class="form-control" type="text" ng-change="mySearchChangeFunc(search.MobileNumber)" ng-model="search.MobileNumber"
<input class="form-control" type="text" ng-change="mySearchChangeFunc(search.MobileNumber)" ng-model="search"
id="search" autofocus tabindex="1" placeholder="Search Mobile" /><br><br>
</div>
</div>
@ -238,6 +240,115 @@
</div>
<!--studen search result end-->
</div>
</tab>
<tab heading="Send Promotional Messages">
<style>
.mobileNumberList {
margin: 6px;
width: 100%;
height: 180px;
overflow-x: scroll;
}
.mobileNumberList ul {
list-style: none;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.mobileNumberList ul li{
padding: 4px 2px;
margin: 1px 2px;
border: 1px solid gray;
border-radius: 4px;
background: #70a5d0;
color: #000;
}
.deletBtn {
margin: 0 2px;
padding: 2px;
background: #2ba3ca;
border-radius: 50%;
border: 2px solid #469cad;
cursor: pointer;
color: #063742;
}
.deletBtn:hover{
background: #2ac3ca;
}
.lableValue{
margin: 0 4px;
}
.addBtn{
margin: 1px 2px;
padding: 4px 6px;
text-transform: uppercase;
background: #de1072;
border: none;
color: #dadada;
border-radius: 4px;
clear: both;
}
.inputCls{
padding: 7px 4px;
}
</style>
<form name="Form" id="form" novalidate ng-submit="composeMsg.submit(Form)" method="post">
<div>
<div class="row">
<div class="col-md-6" ng-class="{'has-error':Form.addMessage.$dirty && Form.addMessage.$invalid, 'has-success':Form.addMessage.$valid}">
<label>
Message :<span class="symbol required"></span>
</label>
<textarea type="text" placeholder="Enter Message Details" tabindex="3" class="form-control inputCls" name="addMessage"
ng-model="mobileNumList.message"
required maxlength="100" />
<span class="text-small block" style="color: rgba(128, 128, 128, 0.64)">Max 100 Characters.</span>
<span class="error text-small block" ng-if="Form.addMessage.$dirty && Form.addMessage.$error.required">Message is Required </span>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label>Mobile Numbers : <span class="symbol required"></span>
</label>
<input type="text" class="form-control inputCls"
ng-model="mobileNumList.mobile" name="mobile" ng-pattern="/^[0-9-+]*$/" minlength="6" maxlength="13">
<i ng-click="composeMsgNumber()" class="addBtn" >add</i>
<!--<span class="error text-small block" ng-if="addressForm.mobile.$error.pattern && addressForm.mobile.$error.minlength && addressForm.mobile.$error.maxlength">Valid Mobile is Required </span>-->
<!--ng-click="addContactsList(mobileNumList)"-->
</div>
<div class="col-md-6">
<div class="mobileNumberList">
<ul>
<li ng-repeat="num in listMobileNums track by $index"><span class="lableValue">{{num}}</span><span class="deletBtn" ng-click="deletMobileList(num)">X</span></li>
</ul>
</div>
</div>
</div>
<!--<div>
<label>Mobile Numbers : </label> <textarea class="inputCls" ng-model="mobileNumList.mobile"></textarea>
</div>
<div>
<label>Mobile Numbers : </label> <input type="text" class="inputCls" ng-model="mobileNumList.mobile"><button class="addBtn" ng-click="addContactsList(mobileNumList)">add</button>
</div>-->
<div class="row">
<div class="pull-left">
<button type="submit" ng-disabled="disableAddButton" tabindex="4" ladda="ldloading1.zoom_in" class="btn btn-sm btn-success"
data-style="zoom-in">
<i class='fa fa-spinner fa-spin' ng-if="disableSendButton"> </i>Send
</button>
<!--<button type="cancel" ng-click="daybookAdd.reset(Form)" tabindex="5" class="btn btn-warning btn-sm" ng-click="employeeForm.resetCourse(Form)">
Reset
</button>-->
</div>
</div>
</div>
</form>
</tab>
</tabset>
</div>
</div>
</div>