246 lines
8.7 KiB
JavaScript
246 lines
8.7 KiB
JavaScript
'use strict';
|
|
/*** controller for Wizard Form example***/
|
|
app.controller('sendSMSsuperadminCtrl', ["$scope", "$filter", "ngTableParams", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', function ($scope, $filter, ngTableParams, apiPoint, $http, SweetAlert, $state, md5, ipCookie) {
|
|
|
|
/**
|
|
* Send SMS Functionality
|
|
* by : kdk
|
|
*/
|
|
var localDetail = JSON.parse(localStorage.getItem('localObj'));
|
|
var localDetails = ipCookie('cookiechk');
|
|
|
|
$scope.init = function () {
|
|
if (localDetail != null) {
|
|
// $scope.getBranchList();
|
|
$scope.getUniversityList();
|
|
} else {
|
|
}
|
|
};
|
|
|
|
$scope.searchData = {
|
|
'University': '',
|
|
'Course': '',
|
|
'Batch': ''
|
|
};
|
|
|
|
$scope.branchList_data = '';
|
|
// get Branch List
|
|
$scope.getBranchList = function () {
|
|
var empListreq = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getBranchListDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: localDetails
|
|
}
|
|
};
|
|
$http(empListreq).then(function (response) {
|
|
if (response.data.branDetailstatus) {
|
|
$scope.branchList_data = response.data.branch_details;
|
|
|
|
} else {
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.universityData = '';
|
|
// get university list while the page is load
|
|
$scope.getUniversityList = function () {
|
|
var empListreq = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getUniveCourseBratchBroadCast/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: localDetails
|
|
}
|
|
};
|
|
$http(empListreq).then(function (response) {
|
|
if (response.data.univList) {
|
|
$scope.universityData = response.data.university_details;
|
|
} else {
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.getUniveId = function (univ) {
|
|
let name = JSON.parse(univ);
|
|
$scope.searchData.University = name.UniversityID;
|
|
$scope.searchData.Course = '';
|
|
$scope.searchData.Batch = '';
|
|
$scope.courseData = name.Course;
|
|
$scope.batchData = name.Batch;
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.getSearch();
|
|
};
|
|
|
|
$scope.getValueChange = function() {
|
|
$scope.getSearch();
|
|
};
|
|
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.searchLoading = false;
|
|
$scope.getSearch = function() {
|
|
console.log($scope.searchData);
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.searchLoading = true;
|
|
var getSearchDetails = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStuListForBroadcast/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: $scope.searchData,
|
|
requestDetails: localDetails
|
|
}
|
|
};
|
|
$http(getSearchDetails).then(function (response) {
|
|
if (response.data.searchResult) {
|
|
$scope.studentListDetails = response.data.search_result_details;
|
|
let studentListDetails = response.data.search_result_details;
|
|
const filterAddSelect = studentListDetails.filter(val => {
|
|
val['Selected'] = false;
|
|
return val;
|
|
});
|
|
$scope.searchResultDetails = filterAddSelect;
|
|
$scope.searchResultLength = Object.keys($scope.searchResultDetails).length;
|
|
|
|
$scope.searchResultStatus = response.data.searchResult;
|
|
$scope.searchLoading = false;
|
|
} else {
|
|
$scope.searchLoading = false;
|
|
}
|
|
});
|
|
};
|
|
|
|
// select all or individual functionality
|
|
|
|
var getAllSelected = function () {
|
|
var selectedItems = $scope.searchResultDetails.filter(function (item) {
|
|
return item.Selected;
|
|
});
|
|
|
|
return selectedItems.length === $scope.searchResultDetails.length;
|
|
}
|
|
|
|
var setAllSelected = function (value) {
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = value;
|
|
});
|
|
}
|
|
|
|
$scope.allSelected = function (value) {
|
|
if (value !== undefined) {
|
|
return setAllSelected(value);
|
|
} else {
|
|
return getAllSelected();
|
|
}
|
|
}
|
|
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.openScreenSen = function() {
|
|
var ItemsSelected = $scope.searchResultDetails.filter(function (item) {
|
|
if (item.Selected === true) { return true; }
|
|
});
|
|
if(ItemsSelected.length > 0) {
|
|
$scope.OpenWindowStatus = true;
|
|
$scope.openUpdateWind();
|
|
} else {
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.openUpdateWind();
|
|
}
|
|
}
|
|
|
|
$scope.msg_details = {
|
|
"content": ""
|
|
}
|
|
|
|
// Select one row in a table once
|
|
// $scope.setOneSelect = function (value) {
|
|
// angular.forEach($scope.searchResultDetails, function (item) {
|
|
// item.Selected = value;
|
|
// });
|
|
// value.Selected = true;
|
|
// $scope.OpenWindowStatus = true;
|
|
// $scope.openUpdateWind();
|
|
// }
|
|
|
|
// End: select all or individual functionality
|
|
|
|
$scope.openUpdateWind = function() {
|
|
|
|
}
|
|
|
|
$scope.statusUpdate = {
|
|
submit: function (form, msg_details) {
|
|
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();
|
|
// swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error");
|
|
} else {
|
|
$scope.disableButton = true;
|
|
var studentForUpdate = [];
|
|
var ItemsSelected = $scope.searchResultDetails.filter(function (item) {
|
|
if (item.Selected === true) {
|
|
let getStudentID = new getStudentForUpdateDetails(item.StudentID);
|
|
studentForUpdate.push(getStudentID);
|
|
return true;
|
|
}
|
|
});
|
|
function getStudentForUpdateDetails(id) {
|
|
this.StudentID = id;
|
|
}
|
|
var sendMSGApi = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'sendSMSStudentApi/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: studentForUpdate,
|
|
msg: msg_details,
|
|
requestDetails: localDetails
|
|
}
|
|
};
|
|
$http(sendMSGApi).then(function (response) {
|
|
if (response.data.msgStatus) {
|
|
swal("Success!", response.data.message, "success");
|
|
$scope.disableButton = false;
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = false;
|
|
});
|
|
$scope.OpenWindowStatus = false;
|
|
} else {
|
|
swal("Failed!", response.data.message, "error");
|
|
$scope.disableButton = false;
|
|
}
|
|
});
|
|
|
|
}
|
|
},
|
|
reset: function (form) {
|
|
form.$setPristine(false);
|
|
$scope.msg_details = {
|
|
"content": ""
|
|
}
|
|
// $scope.msg_details.content = "";
|
|
}
|
|
}
|
|
|
|
}]);
|