447 lines
15 KiB
JavaScript
Executable File
447 lines
15 KiB
JavaScript
Executable File
'use strict';
|
|
/**
|
|
* controllers for ng-table
|
|
* Simple table with sorting and filtering on AngularJS
|
|
*/
|
|
|
|
app.controller('dashboardCtrl', ["$scope","$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
|
|
/*
|
|
* used to get dash board call track details
|
|
* this method called from view ng-init directive
|
|
* created by kms
|
|
* */
|
|
|
|
$scope.initCallTracking = function () {
|
|
$rootScope.pendingFolloupDetails = [];
|
|
var getCallTrack = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getDashboardCallTrack/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
|
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType
|
|
|
|
}
|
|
};
|
|
$http(getCallTrack).then(function (response) {
|
|
/* if(response.data.status == 200 && response.data.followupStatus){
|
|
$scope.currentDate = new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
|
|
|
|
$scope.getFollowupDetails = response.data.details;
|
|
angular.forEach($scope.getFollowupDetails, function (value, key) {
|
|
if (($scope.currentDate) < (value[0].FollowupOn)) {
|
|
|
|
$rootScope.pendingFolloupDetails.push(value[0]);
|
|
console.log($rootScope.pendingFolloupDetails);
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
else{
|
|
|
|
}*/
|
|
|
|
if (response.data.status == 200) {
|
|
if (response.data.todayStatus) {
|
|
|
|
$scope.todayFolloupDetails = response.data.todayFolloupDetails.trackingDetails;
|
|
$scope.emptyDataToday = false;
|
|
}
|
|
else {
|
|
$scope.todayFolloupDetails = "";
|
|
$scope.emptyDataToday = true;
|
|
}
|
|
if (response.data.todayPendingStatus) {
|
|
// $scope.currentDate = new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
|
|
// $scope.currentDate = new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
|
|
$scope.currentDate=$filter('date')(new Date(), 'yyyy-MM-dd');
|
|
$scope.fetchFolloupDetails = response.data.PendingFolloupDetails.trackingDetails;
|
|
angular.forEach($scope.fetchFolloupDetails, function (value, key) {
|
|
var getDay = value.FollowupOn.substring(0, 2);
|
|
var getMonth = value.FollowupOn.substring(3, 5);
|
|
var getYear = value.FollowupOn.substring(6, 10);
|
|
// var dbFollowDate = getYear+'-'+getMonth+'-'+getDay;
|
|
$scope.dbFollowDate = getYear+'-'+getMonth+'-'+getDay;
|
|
|
|
if (($scope.currentDate) > ($scope.dbFollowDate) && (value.statusName!='CLOSE')) {
|
|
|
|
$rootScope.pendingFolloupDetails.push(value);
|
|
}
|
|
|
|
});
|
|
if($rootScope.pendingFolloupDetails.length==0){
|
|
$scope.emptyDataPending = true;
|
|
}
|
|
else{
|
|
$scope.emptyDataPending = false;
|
|
}
|
|
|
|
}
|
|
else {
|
|
$scope.pendingFolloupDetails = "";
|
|
$scope.emptyDataPending = true;
|
|
}
|
|
if (response.data.todayLeadStatus) {
|
|
$scope.leadDetails = response.data.todayLeadDetails.trackingDetails;
|
|
$scope.emptyDataLead = false;
|
|
}
|
|
else {
|
|
$scope.leadDetails = "";
|
|
$scope.emptyDataLead = true;
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
$scope.emptyDataToday = true;
|
|
$scope.emptyDataPending = true;
|
|
|
|
}
|
|
});
|
|
|
|
};
|
|
|
|
}]);
|
|
|
|
app.controller('OnotherCtrl', ["$scope", "toaster", "$filter", "$http", "API_POINTS", "$state", '$cookies', 'ipCookie', function ($scope, toaster, $filter, $http, apiPoint, $state, $cookies, ipCookie) {
|
|
|
|
// get local cliend details
|
|
var localDetail = JSON.parse(localStorage.getItem('localObj'));
|
|
var localDetails = ipCookie('cookiechk');
|
|
|
|
$scope.init = function () {
|
|
$scope.this_Student = 0;
|
|
$scope.this_Staff = 0;
|
|
$scope.this_TotalUser = 0;
|
|
$scope.getTotalUsers();
|
|
|
|
}
|
|
|
|
// get Total Number of users in this application
|
|
$scope.getTotalUsers = function () {
|
|
var req = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getTotalUsers/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: localDetails
|
|
}
|
|
};
|
|
$http(req).then(function (response) {
|
|
if (response.data) {
|
|
// $scope.editBranchId = id;
|
|
$scope.this_Student = response.data.total_student;
|
|
$scope.this_Staff = response.data.total_staff;
|
|
$scope.this_TotalUser = $scope.this_Staff + $scope.this_Student;
|
|
// alert($scope.this_TotalUser);
|
|
$scope.data = [
|
|
|
|
{
|
|
value: $scope.this_Student,
|
|
color: '#46BFBD',
|
|
highlight: '#5AD3D1',
|
|
label: 'Student'
|
|
},
|
|
{
|
|
value: $scope.this_Staff,
|
|
color: '#FDB45C',
|
|
highlight: '#FFC870',
|
|
label: 'Staff'
|
|
}
|
|
];
|
|
$scope.total = $scope.this_TotalUser;
|
|
} else {
|
|
// $scope.this_Student = response.total_student;
|
|
// $scope.this_Staff = response.total_staff;
|
|
$scope.data = [
|
|
{
|
|
value: $scope.this_Student,
|
|
color: '#F7464A',
|
|
highlight: '#5AD3D1',
|
|
label: 'Student'
|
|
},
|
|
{
|
|
value: $scope.this_Staff,
|
|
color: '#FDB45C',
|
|
highlight: '#FFC870',
|
|
label: 'Staff'
|
|
}
|
|
];
|
|
$scope.this_TotalUser = 0;
|
|
$scope.total = $scope.this_TotalUser;
|
|
}
|
|
});
|
|
}
|
|
// Chart.js Data
|
|
|
|
// Chart.js Options
|
|
$scope.options = {
|
|
|
|
// Sets the chart to be responsive
|
|
responsive: false,
|
|
|
|
//Boolean - Whether we should show a stroke on each segment
|
|
segmentShowStroke: true,
|
|
|
|
//String - The colour of each segment stroke
|
|
segmentStrokeColor: '#fff',
|
|
|
|
//Number - The width of each segment stroke
|
|
segmentStrokeWidth: 2,
|
|
|
|
//Number - The percentage of the chart that we cut out of the middle
|
|
percentageInnerCutout: 50, // This is 0 for Pie charts
|
|
|
|
//Number - Amount of animation steps
|
|
animationSteps: 100,
|
|
|
|
//String - Animation easing effect
|
|
animationEasing: 'easeOutBounce',
|
|
|
|
//Boolean - Whether we animate the rotation of the Doughnut
|
|
animateRotate: true,
|
|
|
|
//Boolean - Whether we animate scaling the Doughnut from the centre
|
|
animateScale: false,
|
|
|
|
//String - A legend template
|
|
legendTemplate: '<ul class="tc-chart-js-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'
|
|
|
|
};
|
|
|
|
}]);
|
|
|
|
|
|
/*Header Fixed */
|
|
app.directive('fixedHeader', function($timeout){
|
|
return {
|
|
restrict: 'A',
|
|
link: link
|
|
};
|
|
|
|
function link($scope, $elem, $attrs, $ctrl) {
|
|
var elem = $elem[0];
|
|
|
|
// wait for data to load and then transform the table
|
|
$scope.$watch(tableDataLoaded, function(isTableDataLoaded) {
|
|
if (isTableDataLoaded) {
|
|
transformTable();
|
|
}
|
|
});
|
|
|
|
function tableDataLoaded() {
|
|
// first cell in the tbody exists when data is loaded but doesn't have a width
|
|
// until after the table is transformed
|
|
var firstCell = elem.querySelector('tbody tr:first-child td:first-child');
|
|
return firstCell && !firstCell.style.width;
|
|
}
|
|
|
|
function transformTable() {
|
|
// reset display styles so column widths are correct when measured below
|
|
angular.element(elem.querySelectorAll('thead, tbody')).css('display', '');
|
|
|
|
// wrap in $timeout to give table a chance to finish rendering
|
|
$timeout(function () {
|
|
// set widths of columns
|
|
angular.forEach(elem.querySelectorAll('tr:first-child th'), function (thElem, i) {
|
|
|
|
var tdElems = elem.querySelector('tbody tr:first-child td:nth-child(' + (i + 1) + ')');
|
|
var tfElems = elem.querySelector('tfoot tr:first-child td:nth-child(' + (i + 1) + ')');
|
|
|
|
var columnWidth = tdElems ? tdElems.offsetWidth : thElem.offsetWidth;
|
|
if (tdElems) {
|
|
tdElems.style.width = columnWidth + '150px';
|
|
}
|
|
if (thElem) {
|
|
thElem.style.width = columnWidth + '150px';
|
|
}
|
|
|
|
});
|
|
|
|
// set css styles on thead and tbody
|
|
angular.element(elem.querySelectorAll('thead, tfoot')).css('display', 'block');
|
|
|
|
angular.element(elem.querySelectorAll('tbody')).css({
|
|
'display': 'block',
|
|
'height': $attrs.tableHeight || 'inherit',
|
|
'overflow': 'auto'
|
|
});
|
|
|
|
// reduce width of last column by width of scrollbar
|
|
var tbody = elem.querySelector('tbody');
|
|
var scrollBarWidth = tbody.offsetWidth - tbody.clientWidth;
|
|
if (scrollBarWidth > 0) {
|
|
// for some reason trimming the width by 2px lines everything up better
|
|
scrollBarWidth -= 2;
|
|
var lastColumn = elem.querySelector('tbody tr:first-child td:last-child');
|
|
lastColumn.style.width = (lastColumn.offsetWidth - scrollBarWidth) + 'px';
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
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", "$rootScope", "$modal", "$log", "API_POINTS", "$http", function ($scope, $rootScope, $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());
|
|
});
|
|
};
|
|
$scope.printStudentDetails = function (details) {
|
|
$rootScope.pdfItems = details;
|
|
|
|
var printInstance = $modal.open({
|
|
templateUrl: 'assets/views/student/studentPdf.html',
|
|
controller: 'studentModalDemoCtrl',
|
|
});
|
|
};
|
|
|
|
// generate pdf for student view
|
|
$scope.export = function(getName) {
|
|
kendo.drawing.drawDOM($("#exportthis")).then(function(group) {
|
|
kendo.drawing.pdf.saveAs(group, getName+".pdf");
|
|
});
|
|
}
|
|
|
|
|
|
}]);
|
|
|
|
// 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');
|
|
};
|
|
|
|
|
|
}]);
|
|
|