412 lines
14 KiB
JavaScript
412 lines
14 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(" ", "Message sent successfully.", "success");
|
|
$scope.disableButton = false;
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = false;
|
|
});
|
|
$scope.OpenWindowStatus = false;
|
|
} else {
|
|
swal(" ", response.data.message, "error");
|
|
$scope.disableButton = false;
|
|
}
|
|
});
|
|
|
|
}
|
|
},
|
|
reset: function (form) {
|
|
form.$setPristine(false);
|
|
$scope.msg_details = {
|
|
"content": ""
|
|
}
|
|
// $scope.msg_details.content = "";
|
|
}
|
|
}
|
|
|
|
// 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 {
|
|
|
|
}
|
|
});
|
|
};
|
|
|
|
|
|
}]);
|
|
app.filter('unique', function() {
|
|
return function(collection, primaryKey, secondaryKey) { //optional secondary key
|
|
var output = [],
|
|
keys = [];
|
|
|
|
angular.forEach(collection, function(item) {
|
|
var key;
|
|
secondaryKey === undefined ? key = item[primaryKey] : key = item[primaryKey][secondaryKey];
|
|
|
|
if(keys.indexOf(key) === -1) {
|
|
keys.push(key);
|
|
output.push(item);
|
|
}
|
|
});
|
|
|
|
return output;
|
|
};
|
|
});
|
|
|
|
/*modal controller
|
|
* */
|
|
app.controller('studentModalDemoCtrl', ["$scope", "$modal", "$log", "API_POINTS", "$http", function ($scope, $modal, $log,apiPoint,$http) {
|
|
//Tooltip for print button
|
|
$scope.dynamicTooltip = 'Student View';
|
|
|
|
|
|
|
|
// $scope.items = ['item1', 'item2', 'item3'];
|
|
|
|
$scope.open = function (studentDetails) {
|
|
|
|
|
|
// get student view details
|
|
var getcourse = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentBasicInfo/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy :studentDetails.MobileNumber,
|
|
requestedFrom: 3
|
|
}
|
|
};
|
|
$http(getcourse).then(function (response) {
|
|
|
|
if (response.data.status == 200 && response.data.studentStatus== true) {
|
|
$scope.courseEditLoading = false;
|
|
// $scope.studentDetails = response.data.studentDetails;
|
|
$scope.studentDetails = response.data;
|
|
// $scope.courseDetails = response.data.courseDetails;
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'assets/views/student/studentDetailsModal.html',
|
|
controller: 'ModalInstanceCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
return $scope.studentDetails;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
|
|
} else {
|
|
swal("Failed!", "This student is not registerd", "warning");
|
|
$scope.courseEditLoading = false;
|
|
$scope.studentDetails = "";
|
|
$scope.courseDetails = "";
|
|
|
|
}
|
|
});
|
|
|
|
|
|
};
|
|
$scope.open1 = function (values,type) {
|
|
|
|
var modalInstance1 = $modal.open({
|
|
templateUrl: 'assets/views/student/studentPaymentModal.html',
|
|
controller: 'ModalInstanceCtrl1',
|
|
// size: size,
|
|
resolve: {
|
|
items1: function () {
|
|
var myvalues =
|
|
{
|
|
"values":values,
|
|
"type":type
|
|
};
|
|
return myvalues;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance1.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
};
|
|
|
|
|
|
}]);
|
|
|
|
// Please note that $modalInstance represents a modal window (instance) dependency.
|
|
// It is not the same as the $modal service used above.
|
|
|
|
app.controller('ModalInstanceCtrl', ["$scope", "$modalInstance", "items","WordsService", function ($scope, $modalInstance, items,WordsService) {
|
|
|
|
$scope.items = items;
|
|
$scope.selected = {
|
|
item: $scope.items[0]
|
|
};
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
|
|
|
|
}]);
|
|
app.controller('ModalInstanceCtrl1', ["$scope", "$modalInstance", "items1","WordsService", function ($scope, $modalInstance, items1,WordsService) {
|
|
|
|
$scope.items1 = items1.values;
|
|
$scope.selectedtype = items1.type;
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
|
|
|
|
}]);
|