| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- define(['app'], function (app) {
- app.controller('RedeemCtrl', function ($scope, $rootScope, AppData, $location) {
- $rootScope.menucont = true;
- $rootScope.pageLoadComp = false;
- $scope.formLoad = false;
- $scope.listFound = false;
- $scope.pageData = redeemData[$rootScope.selLanguage];
- $scope.itemdetail = [];
- $scope.approvedListDetail = [];
- $scope.selectedList = [];
- $scope.expiredtype = [];
- $scope.isExpiredRowVisible = false;
- $scope.isExpiredDaysVisible = false;
- $scope.isfirst = false;
- $scope.selectedIndex = null;
- $rootScope.cofirmWindow = false;
- $rootScope.modalLogShown = false;
- $scope.search_show = true;
- $scope.url = "../senddata/log/";
- $scope.pageurl = "../senddata/redeem/";
- $scope.exporturl = "../senddata/export/";
- $scope.commonurl = "../senddata/common/";
- $scope.search_box = true;
- $scope.showButton = false;
- $scope.submenu = $scope.pageData.sidemenu;
- $rootScope.sideselect = $scope.pageData.sidemenu[0];
- $scope.tblheading = $rootScope.sideselect.headingText;
- //pagination
- $scope.viewby = '10';
- $scope.currentPage = 1;
- $scope.itemsPerPage = $scope.viewby;
- $scope.maxSize = 5; //Number of pager buttons to show
- //Check Session//
- $scope.formData = {}
- $rootScope.formData = {}
- $scope.formData.ismenuload = "Yes";
- if ($rootScope.items == undefined || $rootScope.items == null) {
- $scope.formData.ismenuload = "No";
- }
- $scope.formData.funName = "checksession";
- $scope.formData.lang = $rootScope.selLanguage;
- $scope.formData.start = 0;
- $scope.formData.limit = 2;
- //this page Variable//
- //$scope.roleitem = null;
- $scope.cateitem = null;
- $scope.questionitem = null;
- $scope.assignquestionitem = [];
- $scope.assignquestionnum = [];
- AppData.sendData($scope.url, $scope.formData, function (res) {
- if (res.cont) {
- if ($rootScope.items == undefined || $rootScope.items == null) {
- $rootScope.items = res.item.control;
- }
- for (var i = 0; i < $rootScope.items.length; i++) {
- if ($location.path() == $rootScope.items[i].modulepath) {
- $rootScope.modulename = $rootScope.items[i].modulename;
- $scope.usercontrol = String($rootScope.items[i].permission).split("|");
- }
- }
- $scope.statusobj = res.item.status;
- $rootScope.username = res.item.username;
- $scope.listFound = true;
- $scope.start_time = $scope.pageData.assessment_publish_time;
- $scope.end_time = $scope.pageData.assessment_publish_time;
- $scope.waitingList();
- } else {
- $location.path("/login");
- }
- })
- $scope.waitingList = function () {
- $scope.search_show = true;
- $scope.searchvalue = ($scope.formData.mymodel != '') ? $scope.formData.mymodel : "";
- var fobj = {};
- fobj.funName = "redeemlist";
- if ($rootScope.sideselect.id == 1) {
- fobj.pn = $scope.currentPage;
- fobj.nr = $scope.itemsPerPage;
- } else {
- fobj.pn = '';
- fobj.nr = '';
- }
- fobj.lang = $rootScope.selLanguage;
- fobj.key = $scope.searchvalue;
- $rootScope.pageLoadComp = true;
- AppData.sendData($scope.pageurl, fobj, function (res) {
- $rootScope.pageLoadComp = true;
- if (res.cont) {
- if (res.item != undefined) {
- $scope.itemdetail = res.item.users;
- $scope.totalItems = res.item.total_records;
- $scope.listFound = true;
- $scope.formLoad = false;
- $scope.search_box = true;
- }
- //$scope.formData = {}
- } else {
- $scope.listFound = false;
- $scope.errorMsg = res.mess;
- }
- //$scope.roleitem=res.item.roleitem;
- })
- }
- $scope.approvedList = function () {
- $scope.search_show = true;
- $scope.searchvalue = ($scope.formData.mymodel != '') ? $scope.formData.mymodel : "";
- var fobj = {};
- fobj.funName = "redeemapprovedlist";
- if ($rootScope.sideselect.id == 1) {
- fobj.pn = $scope.currentPage;
- fobj.nr = $scope.itemsPerPage;
- } else {
- fobj.pn = '';
- fobj.nr = '';
- }
- fobj.lang = $rootScope.selLanguage;
- fobj.key = $scope.searchvalue;
- $rootScope.pageLoadComp = true;
- AppData.sendData($scope.pageurl, fobj, function (res) {
- $rootScope.pageLoadComp = true;
- if (res.cont) {
- if (res.item != undefined) {
- $scope.approvedListDetail = res.item.users;
- $scope.totalItems = res.item.total_records;
- $scope.listFound = true;
- $scope.formLoad = false;
- $scope.search_box = true;
- }
- //$scope.formData = {}
- } else {
- $scope.listFound = false;
- $scope.errorMsg = res.mess;
- }
- //$scope.roleitem=res.item.roleitem;
- })
- }
- $scope.toggleSelect = function () {
- $scope.selectedList=[];
- $scope.isAllSelected =!event.target.checked
- console.log($scope.isAllSelected)
- if($scope.isAllSelected){
- console.log('if')
- angular.forEach($scope.itemdetail, function (item) {
- item.selected = false;
- });
- $scope.showButton = false;
- }else{
- console.log('ifdfsdf')
- angular.forEach($scope.itemdetail, function (item) {
- item.selected = event.target.checked;
- $scope.selectedList.push(item.id);
- console.log($scope.selectedList)
- });
- $scope.showButton = true;
- }
-
- // angular.forEach($scope.itemdetail, function (item) {
- // item.selected = event.target.checked;
- // var index = $scope.selectedList.indexOf(item.id)
- // console.log(index)
- // if(index>-1){
- // $scope.selectedList.splice(index,1)
- // $scope.showButton = false;
- // }else{
- // $scope.selectedList.push(item.id)
- // $scope.showButton = true;
- // }
-
- // console.log($scope.selectedList)
- // });
- }
- $scope.childSelect = function (id) {
- console.log($scope.isAllSelected)
- // if($scope.isAllSelected || $scope.isAllSelected==undefined){
- // $scope.itemdetail.every(function (itm) {
- // console.log(itm)
- // if(itm.selected){
- // $scope.showButton = true;
- // }else{
- // $scope.showButton = false;
- // }
- // })
- // }
-
- var index = $scope.selectedList.indexOf(id)
- console.log(index)
- if (index > -1) {
- $scope.selectedList.splice(index, 1)
-
- } else {
- $scope.selectedList.push(id)
- }
- if($scope.selectedList.length==0){
- $scope.showButton = false;
- }else{
- $scope.showButton = true;
- }
- console.log($scope.selectedList)
- }
- $scope.sendConfirmation = function () {
- console.log($scope.selectedList)
- var obj = {};
- obj.funName = "approveredeem";
- obj.lang = $rootScope.selLanguage;
- obj.id = $scope.selectedList.toString();
- $rootScope.pageLoadComp = true;
- console.log(obj)
- AppData.sendData($scope.pageurl, obj, function (res) {
- $rootScope.modalLogShown = true;
- $rootScope.message = res.mess;
- $scope.waitingList()
-
- })
- }
- $scope.setPage = function (pageNo) {
- $scope.currentPage = pageNo;
- };
- $scope.pageChanged = function () {
- if ($rootScope.sideselect.id == 1) {
- $scope.waitingList();
- } else if ($rootScope.sideselect.id == 2) {
- $scope.approvedList();
- }
- };
- $scope.setItemsPerPage = function (num) {
- $scope.itemsPerPage = num;
- $scope.currentPage = 1; //reset to first page
- if ($rootScope.sideselect.id == 1) {
- $scope.waitingList();
- } else if ($rootScope.sideselect.id == 2) {
- $scope.approvedList();
- }
- }
- $scope.filterData = function () {
- if ($rootScope.sideselect.id == 1) {
- $scope.waitingList();
- } else if ($rootScope.sideselect.id == 2) {
- $scope.approvedList();
- }
- }
- $scope.listClick = function (obj) {
- $scope.searchtext = '';
- $scope.formData = {};
- $scope.currentPage = 1;
- $(".clsbuttoncont .clsbutton").removeClass("disable_btn");
- $scope.formLoad = false;
- $rootScope.sideselect = obj;
- $scope.selectedIndex = null;
- $scope.tblheading = obj.headingText;
- if ($rootScope.sideselect.id == 1) {
- $scope.waitingList();
- } else if ($rootScope.sideselect.id == 2) {
- $scope.approvedList();
- }
- }
- $scope.onSearchChange = function () {
- // console.log($scope.formData.mymodel)
- if ($rootScope.sideselect.id == 1) {
- $scope.waitingList();
- } else if ($rootScope.sideselect.id == 2) {
- $scope.approvedList();
- }
- }
- });
- });
|