278 lines
9.1 KiB
JavaScript
Executable File
278 lines
9.1 KiB
JavaScript
Executable File
'use strict';
|
|
/**
|
|
* controllers for ng-table
|
|
* Simple table with sorting and filtering on AngularJS
|
|
*/
|
|
|
|
app.controller('studentViewCtrl', ["$scope","$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", "$modal", "$log", function ($scope,$rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, $modal,$log) {
|
|
/*
|
|
* used to get student course details
|
|
* this method called from view ng-init directive
|
|
* created by kms
|
|
* */
|
|
$rootScope.studentAllDetails="";
|
|
$scope.getStudentDetails = function () {
|
|
var getcourse = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentBasicInfo/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
requestedFrom: 2,
|
|
accessFrom: 'Web'
|
|
}
|
|
};
|
|
$http(getcourse).then(function (response) {
|
|
|
|
if (response.data.status == 200 && response.data.studentStatus== true) {
|
|
$rootScope.studentAllDetails = response.data;
|
|
$rootScope.studentDetails = response.data.studentDetails;
|
|
$scope.courseDetails = response.data.courseDetails;
|
|
|
|
|
|
} else {
|
|
$rootScope.studentDetails = "";
|
|
$scope.courseDetails = "";
|
|
$rootScope.studentAllDetails="";
|
|
|
|
}
|
|
});
|
|
|
|
};
|
|
$scope.printStudentDetails = function (details) {
|
|
$rootScope.pdfItems = details;
|
|
|
|
var modalInstancePrint = $modal.open({
|
|
templateUrl: 'assets/views/student/studentViewPdf.html',
|
|
controller: 'studentViewCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
list: function () {
|
|
|
|
return details;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstancePrint.result.then(function (selectedItem) {
|
|
$scope.selected2 = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
};
|
|
|
|
// generate pdf for student view
|
|
$scope.export = function(getName) {
|
|
kendo.drawing.drawDOM($("#exportthis")).then(function(group) {
|
|
kendo.drawing.pdf.saveAs(group, getName+".pdf");
|
|
});
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
/*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 thElems = elem.querySelector('thead 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';
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
/*modal controller
|
|
* */
|
|
app.controller('FeesModalDemoCtrl', ["$scope", "$rootScope", "$modal", "$log", function ($scope, $rootScope, $modal, $log) {
|
|
//Tooltip for print button
|
|
$scope.dynamicTooltip = 'Click to View Bill Details';
|
|
|
|
|
|
|
|
// $scope.items = ['item1', 'item2', 'item3'];
|
|
|
|
$scope.FeesName="" ;
|
|
$rootScope.CUDetails="" ;
|
|
$scope.open = function (values,type,courseDetails) {
|
|
|
|
$scope.FeesName = values;
|
|
$rootScope.CUDetails=courseDetails ;
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'myModalContent.html',
|
|
controller: 'ModalInstanceCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
var myvalues =
|
|
{
|
|
"values":values,
|
|
"type":type
|
|
};
|
|
return myvalues;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
};
|
|
}]);
|
|
app.directive('visible', function() {
|
|
|
|
return {
|
|
restrict: 'A',
|
|
|
|
link: function(scope, element, attributes) {
|
|
scope.$watch(attributes.visible, function(value){
|
|
element.css('visibility', value ? 'visible' : 'hidden');
|
|
});
|
|
}
|
|
};
|
|
});
|
|
|
|
// 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.values;
|
|
$scope.selectedtype = items.type;
|
|
$scope.selected = {
|
|
item: $scope.items[0]
|
|
};
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
|
|
//show hide function for pdf design
|
|
$scope.billNo="";
|
|
$scope.sessionName="";
|
|
$scope.paymentType="";
|
|
$scope.billDate="";
|
|
$scope.amountInWords = "";
|
|
$scope.billAmount = "";
|
|
$scope.branchName = "";
|
|
$scope.ReceivedBy = "";
|
|
$scope.BranchAddr = "";
|
|
$scope.BranchAddr = "";
|
|
$scope.BranchLogo = "";
|
|
$scope.ShowHide = function (pdfValue) {
|
|
$scope.showButton = true;
|
|
$scope.billNo = pdfValue.BillNO;
|
|
$scope.paymentType=pdfValue.ModeOfPayment;
|
|
$scope.billDate=pdfValue.BillDate;
|
|
$scope.amountInWords = WordsService.convertNumberToWords(pdfValue.BillAmount);
|
|
$scope.billAmount = pdfValue.BillAmount;
|
|
$scope.branchName = pdfValue.BranchName;
|
|
$scope.ReceivedBy = pdfValue.ReceivedBy;
|
|
$scope.BranchAddr = pdfValue.Address;
|
|
$scope.BranchLogo = pdfValue.LogoPath;
|
|
|
|
|
|
}
|
|
|
|
$scope.mouseLeave = function(){
|
|
$scope.showButton = false;
|
|
$scope.billNo="";
|
|
$scope.sessionName="";
|
|
$scope.paymentType="";
|
|
$scope.billDate="";
|
|
$scope.amountInWords = "";
|
|
$scope.billAmount = "";
|
|
$scope.branchName = "";
|
|
$scope.ReceivedBy="";
|
|
$scope.BranchAddr = "";
|
|
$scope.BranchLogo = "";
|
|
}
|
|
|
|
|
|
}]);
|
|
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;
|
|
};
|
|
});
|
|
|