redeem.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. define(['app'], function (app) {
  2. app.controller('RedeemCtrl', function ($scope, $rootScope, AppData, $location) {
  3. $rootScope.menucont = true;
  4. $rootScope.pageLoadComp = false;
  5. $scope.formLoad = false;
  6. $scope.listFound = false;
  7. $scope.pageData = redeemData[$rootScope.selLanguage];
  8. $scope.itemdetail = [];
  9. $scope.approvedListDetail = [];
  10. $scope.selectedList = [];
  11. $scope.expiredtype = [];
  12. $scope.isExpiredRowVisible = false;
  13. $scope.isExpiredDaysVisible = false;
  14. $scope.isfirst = false;
  15. $scope.selectedIndex = null;
  16. $rootScope.cofirmWindow = false;
  17. $rootScope.modalLogShown = false;
  18. $scope.search_show = true;
  19. $scope.url = "../senddata/log/";
  20. $scope.pageurl = "../senddata/redeem/";
  21. $scope.exporturl = "../senddata/export/";
  22. $scope.commonurl = "../senddata/common/";
  23. $scope.search_box = true;
  24. $scope.showButton = false;
  25. $scope.submenu = $scope.pageData.sidemenu;
  26. $rootScope.sideselect = $scope.pageData.sidemenu[0];
  27. $scope.tblheading = $rootScope.sideselect.headingText;
  28. //pagination
  29. $scope.viewby = '10';
  30. $scope.currentPage = 1;
  31. $scope.itemsPerPage = $scope.viewby;
  32. $scope.maxSize = 5; //Number of pager buttons to show
  33. //Check Session//
  34. $scope.formData = {}
  35. $rootScope.formData = {}
  36. $scope.formData.ismenuload = "Yes";
  37. if ($rootScope.items == undefined || $rootScope.items == null) {
  38. $scope.formData.ismenuload = "No";
  39. }
  40. $scope.formData.funName = "checksession";
  41. $scope.formData.lang = $rootScope.selLanguage;
  42. $scope.formData.start = 0;
  43. $scope.formData.limit = 2;
  44. //this page Variable//
  45. //$scope.roleitem = null;
  46. $scope.cateitem = null;
  47. $scope.questionitem = null;
  48. $scope.assignquestionitem = [];
  49. $scope.assignquestionnum = [];
  50. AppData.sendData($scope.url, $scope.formData, function (res) {
  51. if (res.cont) {
  52. if ($rootScope.items == undefined || $rootScope.items == null) {
  53. $rootScope.items = res.item.control;
  54. }
  55. for (var i = 0; i < $rootScope.items.length; i++) {
  56. if ($location.path() == $rootScope.items[i].modulepath) {
  57. $rootScope.modulename = $rootScope.items[i].modulename;
  58. $scope.usercontrol = String($rootScope.items[i].permission).split("|");
  59. }
  60. }
  61. $scope.statusobj = res.item.status;
  62. $rootScope.username = res.item.username;
  63. $scope.listFound = true;
  64. $scope.start_time = $scope.pageData.assessment_publish_time;
  65. $scope.end_time = $scope.pageData.assessment_publish_time;
  66. $scope.waitingList();
  67. } else {
  68. $location.path("/login");
  69. }
  70. })
  71. $scope.waitingList = function () {
  72. $scope.search_show = true;
  73. $scope.searchvalue = ($scope.formData.mymodel != '') ? $scope.formData.mymodel : "";
  74. var fobj = {};
  75. fobj.funName = "redeemlist";
  76. if ($rootScope.sideselect.id == 1) {
  77. fobj.pn = $scope.currentPage;
  78. fobj.nr = $scope.itemsPerPage;
  79. } else {
  80. fobj.pn = '';
  81. fobj.nr = '';
  82. }
  83. fobj.lang = $rootScope.selLanguage;
  84. fobj.key = $scope.searchvalue;
  85. $rootScope.pageLoadComp = true;
  86. AppData.sendData($scope.pageurl, fobj, function (res) {
  87. $rootScope.pageLoadComp = true;
  88. if (res.cont) {
  89. if (res.item != undefined) {
  90. $scope.itemdetail = res.item.users;
  91. $scope.totalItems = res.item.total_records;
  92. $scope.listFound = true;
  93. $scope.formLoad = false;
  94. $scope.search_box = true;
  95. }
  96. //$scope.formData = {}
  97. } else {
  98. $scope.listFound = false;
  99. $scope.errorMsg = res.mess;
  100. }
  101. //$scope.roleitem=res.item.roleitem;
  102. })
  103. }
  104. $scope.approvedList = function () {
  105. $scope.search_show = true;
  106. $scope.searchvalue = ($scope.formData.mymodel != '') ? $scope.formData.mymodel : "";
  107. var fobj = {};
  108. fobj.funName = "redeemapprovedlist";
  109. if ($rootScope.sideselect.id == 1) {
  110. fobj.pn = $scope.currentPage;
  111. fobj.nr = $scope.itemsPerPage;
  112. } else {
  113. fobj.pn = '';
  114. fobj.nr = '';
  115. }
  116. fobj.lang = $rootScope.selLanguage;
  117. fobj.key = $scope.searchvalue;
  118. $rootScope.pageLoadComp = true;
  119. AppData.sendData($scope.pageurl, fobj, function (res) {
  120. $rootScope.pageLoadComp = true;
  121. if (res.cont) {
  122. if (res.item != undefined) {
  123. $scope.approvedListDetail = res.item.users;
  124. $scope.totalItems = res.item.total_records;
  125. $scope.listFound = true;
  126. $scope.formLoad = false;
  127. $scope.search_box = true;
  128. }
  129. //$scope.formData = {}
  130. } else {
  131. $scope.listFound = false;
  132. $scope.errorMsg = res.mess;
  133. }
  134. //$scope.roleitem=res.item.roleitem;
  135. })
  136. }
  137. $scope.toggleSelect = function () {
  138. $scope.selectedList=[];
  139. $scope.isAllSelected =!event.target.checked
  140. console.log($scope.isAllSelected)
  141. if($scope.isAllSelected){
  142. console.log('if')
  143. angular.forEach($scope.itemdetail, function (item) {
  144. item.selected = false;
  145. });
  146. $scope.showButton = false;
  147. }else{
  148. console.log('ifdfsdf')
  149. angular.forEach($scope.itemdetail, function (item) {
  150. item.selected = event.target.checked;
  151. $scope.selectedList.push(item.id);
  152. console.log($scope.selectedList)
  153. });
  154. $scope.showButton = true;
  155. }
  156. // angular.forEach($scope.itemdetail, function (item) {
  157. // item.selected = event.target.checked;
  158. // var index = $scope.selectedList.indexOf(item.id)
  159. // console.log(index)
  160. // if(index>-1){
  161. // $scope.selectedList.splice(index,1)
  162. // $scope.showButton = false;
  163. // }else{
  164. // $scope.selectedList.push(item.id)
  165. // $scope.showButton = true;
  166. // }
  167. // console.log($scope.selectedList)
  168. // });
  169. }
  170. $scope.childSelect = function (id) {
  171. console.log($scope.isAllSelected)
  172. // if($scope.isAllSelected || $scope.isAllSelected==undefined){
  173. // $scope.itemdetail.every(function (itm) {
  174. // console.log(itm)
  175. // if(itm.selected){
  176. // $scope.showButton = true;
  177. // }else{
  178. // $scope.showButton = false;
  179. // }
  180. // })
  181. // }
  182. var index = $scope.selectedList.indexOf(id)
  183. console.log(index)
  184. if (index > -1) {
  185. $scope.selectedList.splice(index, 1)
  186. } else {
  187. $scope.selectedList.push(id)
  188. }
  189. if($scope.selectedList.length==0){
  190. $scope.showButton = false;
  191. }else{
  192. $scope.showButton = true;
  193. }
  194. console.log($scope.selectedList)
  195. }
  196. $scope.sendConfirmation = function () {
  197. console.log($scope.selectedList)
  198. var obj = {};
  199. obj.funName = "approveredeem";
  200. obj.lang = $rootScope.selLanguage;
  201. obj.id = $scope.selectedList.toString();
  202. $rootScope.pageLoadComp = true;
  203. console.log(obj)
  204. AppData.sendData($scope.pageurl, obj, function (res) {
  205. $rootScope.modalLogShown = true;
  206. $rootScope.message = res.mess;
  207. $scope.waitingList()
  208. })
  209. }
  210. $scope.setPage = function (pageNo) {
  211. $scope.currentPage = pageNo;
  212. };
  213. $scope.pageChanged = function () {
  214. if ($rootScope.sideselect.id == 1) {
  215. $scope.waitingList();
  216. } else if ($rootScope.sideselect.id == 2) {
  217. $scope.approvedList();
  218. }
  219. };
  220. $scope.setItemsPerPage = function (num) {
  221. $scope.itemsPerPage = num;
  222. $scope.currentPage = 1; //reset to first page
  223. if ($rootScope.sideselect.id == 1) {
  224. $scope.waitingList();
  225. } else if ($rootScope.sideselect.id == 2) {
  226. $scope.approvedList();
  227. }
  228. }
  229. $scope.filterData = function () {
  230. if ($rootScope.sideselect.id == 1) {
  231. $scope.waitingList();
  232. } else if ($rootScope.sideselect.id == 2) {
  233. $scope.approvedList();
  234. }
  235. }
  236. $scope.listClick = function (obj) {
  237. $scope.searchtext = '';
  238. $scope.formData = {};
  239. $scope.currentPage = 1;
  240. $(".clsbuttoncont .clsbutton").removeClass("disable_btn");
  241. $scope.formLoad = false;
  242. $rootScope.sideselect = obj;
  243. $scope.selectedIndex = null;
  244. $scope.tblheading = obj.headingText;
  245. if ($rootScope.sideselect.id == 1) {
  246. $scope.waitingList();
  247. } else if ($rootScope.sideselect.id == 2) {
  248. $scope.approvedList();
  249. }
  250. }
  251. $scope.onSearchChange = function () {
  252. // console.log($scope.formData.mymodel)
  253. if ($rootScope.sideselect.id == 1) {
  254. $scope.waitingList();
  255. } else if ($rootScope.sideselect.id == 2) {
  256. $scope.approvedList();
  257. }
  258. }
  259. });
  260. });