user-registration.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. define(['app'], function (app) {
  2. app.controller('UserRegistrationCtrl', function ($scope, $rootScope, AppData, $location) {
  3. $rootScope.menucont = true;
  4. $rootScope.pageLoadComp = false;
  5. $scope.formLoad = false;
  6. $scope.listFound = false;
  7. $scope.pageData = registrationData[$rootScope.selLanguage];
  8. $scope.submenu = $scope.pageData.sidemenu;
  9. $scope.url = "../senddata/log/";
  10. $scope.pageurl = "../senddata/report/";
  11. $scope.exporturl = "../senddata/reportdownload/";
  12. $scope.commonurl = "../senddata/common/";
  13. $scope.userurl = "../senddata/user/";
  14. $rootScope.sideselect = $scope.pageData.sidemenu[0];
  15. //Check Session//
  16. $scope.formData = {}
  17. $rootScope.formData = {}
  18. $scope.dseInactive=false;
  19. $scope.remarkslist=[];
  20. $scope.currentDate = moment().format("YYYY-MM-DD");
  21. console.log($scope.currentDate)
  22. $scope.startingDate = moment().startOf('month').format('YYYY-MM-DD');
  23. $scope.startingMonth = moment().startOf('month').format('MMMM YYYY');
  24. $scope.totalremarkscount=0;
  25. //pagination
  26. $scope.viewby = '10';
  27. $scope.currentPage = 1;
  28. $scope.itemsPerPage = $scope.viewby;
  29. $scope.maxSize = 5; //Number of pager buttons to show
  30. //Check Session//
  31. $scope.formData.ismenuload = "Yes";
  32. if ($rootScope.items == undefined || $rootScope.items == null) {
  33. $scope.formData.ismenuload = "No";
  34. }
  35. $scope.formData.funName = "checksession";
  36. $scope.formData.lang = $rootScope.selLanguage;
  37. $scope.formData.start = 2;
  38. $scope.formData.limit = 5;
  39. console.log($scope.startingMonth)
  40. $scope.formData.ismenuload = "Yes";
  41. if ($rootScope.items == undefined || $rootScope.items == null) {
  42. $scope.formData.ismenuload = "No";
  43. }
  44. $scope.formData.funName = "checksession";
  45. $scope.formData.lang = $rootScope.selLanguage;
  46. $scope.formData.start = 0;
  47. $scope.formData.limit = 2;
  48. AppData.sendData($scope.url, $scope.formData, function (res) {
  49. if (res.cont) {
  50. if ($rootScope.items == undefined || $rootScope.items == null) {
  51. $rootScope.items = res.item.control;
  52. }
  53. if ($rootScope.items != undefined) {
  54. for (var i = 0; i < $rootScope.items.length; i++) {
  55. if ($location.path() == $rootScope.items[i].modulepath) {
  56. $rootScope.modulename = $rootScope.items[i].modulename;
  57. $scope.usercontrol = String($rootScope.items[i].permission).split("|");
  58. }
  59. }
  60. }
  61. angular.element(document.querySelector('.table_area')).bind('scroll', function () {
  62. $('.datepicker').datepicker("hide")
  63. })
  64. // $scope.getZm();
  65. $scope.listClick($scope.submenu[0])
  66. console.log($rootScope.sideselect.id)
  67. } else {
  68. $location.path("/login");
  69. }
  70. })
  71. $scope.listClick = function (obj) {
  72. console.log(obj.id)
  73. $scope.formData = {}
  74. // $scope.currentPage = 1;
  75. $rootScope.sideselect = obj;
  76. $rootScope.sideselect.name = obj.name;
  77. if (obj.id == 1) {
  78. // $("<link rel='stylesheet' type='text/css' href='module/report/user-registration/css/user-registration.css' />").appendTo( 'head' );
  79. } else if (obj.id == 2) {
  80. $scope.formData = {};
  81. // $("<link rel='stylesheet' type='text/css' href='module/report/user-registration/css/test.css' />").appendTo( 'head' );
  82. $scope.selectTab('1')
  83. }
  84. $scope.getZm();
  85. }
  86. ///////////// Zone Data /////////////////
  87. $scope.getZm = function () {
  88. $scope.formData = {};
  89. $scope.dseInactive=false;
  90. $scope.formData.datetype = '4';
  91. $scope.formData.from_month = $scope.startingMonth
  92. $scope.formData.regtype = '1';
  93. console.log($scope.formData)
  94. if ($scope.formData.datetype == '1' || $scope.formData.datetype == '2' || $scope.formData.datetype == '3' || $scope.formData.datetype == '4') {
  95. $scope.formData.from_date = '';
  96. $scope.formData.to_date = '';
  97. } else {
  98. $scope.formData.from_date = $scope.startingDate;
  99. $scope.formData.to_date = $scope.currentDate;
  100. }
  101. $scope.formData.zm_email = "all";
  102. $scope.rmInactive = true;
  103. $scope.amInactive = true;
  104. var zobj = {};
  105. zobj.funName = "zmlist";
  106. zobj.lang = $rootScope.selLanguage;
  107. AppData.sendData($scope.commonurl, zobj, function (res) {
  108. console.log(res)
  109. $scope.zmuser_list = res.item;
  110. $scope.zmChange()
  111. })
  112. }
  113. $scope.zmChange = function () {
  114. $scope.dseInactive=false;
  115. $scope.dealerInactive=true;
  116. console.log($scope.formData.zm_email)
  117. $scope.formData.rm_email = "all";
  118. $scope.formData.am_email = "all";
  119. if ($scope.formData.zm_email == "all") {
  120. $scope.rmInactive = true;
  121. $scope.amInactive = true;
  122. if ($rootScope.sideselect.id == 1) {
  123. $scope.userRegistrationData()
  124. $scope.userRegistrationList()
  125. } else if ($rootScope.sideselect.id == 2) {
  126. $scope.userActivationData()
  127. } else if ($rootScope.sideselect.id == 3) {
  128. $scope.userInactiveRegistrationData()
  129. $scope.userInactiveRegistrationList()
  130. }
  131. } else {
  132. $scope.rmInactive = false;
  133. $scope.amInactive = true;
  134. $scope.getRm();
  135. }
  136. }
  137. ///////////// Regional Data //////////////
  138. $scope.getRm = function () {
  139. $scope.dseInactive=false;
  140. $scope.formData.rm_email = "all";
  141. var robj = {};
  142. robj.funName = "rmlist";
  143. robj.lang = $rootScope.selLanguage;
  144. robj.zm_email = $scope.formData.zm_email;
  145. AppData.sendData($scope.commonurl, robj, function (res) {
  146. console.log(res)
  147. $scope.rmuser_list = res.item;
  148. $scope.rmChange()
  149. })
  150. }
  151. $scope.rmChange = function () {
  152. $scope.dseInactive=false;
  153. $scope.dealerInactive=true;
  154. $scope.formData.am_email = "all"
  155. $scope.formData.dealer_code = "";
  156. if ($scope.formData.rm_email == "all") {
  157. $scope.amInactive = true;
  158. if ($rootScope.sideselect.id == 1) {
  159. $scope.userRegistrationData()
  160. $scope.userRegistrationList()
  161. } else if ($rootScope.sideselect.id == 2) {
  162. $scope.userActivationData()
  163. } else if ($rootScope.sideselect.id == 3) {
  164. $scope.userInactiveRegistrationData()
  165. $scope.userInactiveRegistrationList()
  166. }
  167. } else {
  168. // alert($scope.formData.rm_email)
  169. $scope.amInactive = false;
  170. if ($rootScope.sideselect.id == 1) {
  171. $scope.userRegistrationData()
  172. $scope.userRegistrationList()
  173. } else if ($rootScope.sideselect.id == 2) {
  174. $scope.userActivationData()
  175. } else if ($rootScope.sideselect.id == 3) {
  176. $scope.userInactiveRegistrationData()
  177. $scope.userInactiveRegistrationList()
  178. }
  179. $scope.getAm();
  180. }
  181. }
  182. //////////// Area Manager Data ///////////////////
  183. $scope.getAm = function () {
  184. $scope.dseInactive=false;
  185. var aobj = {};
  186. aobj.funName = "amlist";
  187. aobj.lang = $rootScope.selLanguage;
  188. aobj.rm_email = $scope.formData.rm_email;
  189. AppData.sendData($scope.commonurl, aobj, function (res) {
  190. console.log(res)
  191. $scope.amuser_list = res.item;
  192. // $scope.amChange()
  193. })
  194. }
  195. $scope.amChange = function () {
  196. $scope.dseInactive=false;
  197. $scope.dealerInactive=true;
  198. if ($rootScope.sideselect.id == 1) {
  199. $scope.userRegistrationData()
  200. $scope.userRegistrationList()
  201. } else if ($rootScope.sideselect.id == 2) {
  202. $scope.userActivationData()
  203. } else if ($rootScope.sideselect.id == 3) {
  204. $scope.userInactiveRegistrationData()
  205. $scope.userInactiveRegistrationList()
  206. }
  207. $scope.getDealer()
  208. }
  209. $scope.chartData = function () {
  210. $scope.userRegistrationData()
  211. $scope.userRegistrationList();
  212. }
  213. $scope.inactiveChartData = function () {
  214. $scope.userInactiveRegistrationData()
  215. $scope.userInactiveRegistrationList();
  216. }
  217. $scope.userRegistrationList = function () {
  218. var obj = {};
  219. // obj.funName = "user_registration_percent";
  220. obj.funName = "user_registration_percent_v2";
  221. obj.zm_email = $scope.formData.zm_email;
  222. obj.rm_email = $scope.formData.rm_email;
  223. obj.am_email = $scope.formData.am_email;
  224. obj.from_date = $scope.formData.from_date;
  225. obj.to_date = $scope.formData.to_date;
  226. obj.regtype = $scope.formData.regtype;
  227. obj.datetype = $scope.formData.datetype;
  228. AppData.sendData($scope.pageurl, obj, function (res) {
  229. if (res.cont) {
  230. console.log(res.item)
  231. $scope.userPercentList = res.item;
  232. } else {
  233. $scope.userPercentList = []
  234. }
  235. })
  236. }
  237. $scope.userInactiveRegistrationList = function () {
  238. // alert("initialized-->"+$scope.currentPage)
  239. var obj = {};
  240. $scope.searchvalue = ($scope.formData.mymodel != '') ? $scope.formData.mymodel : "";
  241. obj.funName = "inactive_user_registration_list";
  242. obj.zm_email = $scope.formData.zm_email;
  243. obj.rm_email = $scope.formData.rm_email;
  244. obj.am_email = $scope.formData.am_email;
  245. obj.from_date = $scope.formData.from_date;
  246. obj.to_date = $scope.formData.to_date;
  247. obj.regtype = $scope.formData.regtype
  248. obj.lang = $rootScope.selLanguage;
  249. obj.pn = $scope.currentPage;
  250. obj.nr = $scope.itemsPerPage;
  251. obj.key = $scope.searchvalue
  252. AppData.sendData($scope.pageurl, obj, function (res) {
  253. if (res.cont) {
  254. console.log(res.item)
  255. $scope.userPercentList = res.item;
  256. $scope.totalItems = res.item.total_records;
  257. $scope.listFound = true;
  258. $scope.search_box = true;
  259. }else{
  260. $scope.listFound = false;
  261. $scope.errorMsg = res.mess;
  262. }
  263. })
  264. $scope.pageChanged = function(tempval) {
  265. $scope.currentPage=tempval
  266. console.log('Page changed to: ' + $scope.currentPage);
  267. $scope.userInactiveRegistrationList();
  268. };
  269. $scope.filterData = function() {
  270. console.log($scope.searchtext)
  271. $scope.userInactiveRegistrationList();
  272. }
  273. }
  274. $scope.onSearchChange = function () {
  275. console.log($scope.formData.mymodel)
  276. $scope.userInactiveRegistrationList();
  277. }
  278. $scope.selectStatus = function () {
  279. $scope.userRegistrationData();
  280. $scope.userRegistrationList();
  281. }
  282. $scope.selectInActiveStatus = function () {
  283. $scope.userInactiveRegistrationList()
  284. // $scope.userRegistrationData();
  285. // $scope.userRegistrationList();
  286. }
  287. $scope.selectActiveStatus = function () {
  288. $scope.userActivationData();
  289. }
  290. //////////////// User Registration Report ////////////////////
  291. $scope.userRegistrationData = function () {
  292. $scope.userLabel = [];
  293. $scope.userValue = [];
  294. // $scope.formData.status = [];
  295. $scope.formData.funName = "user_registration";
  296. // $scope.formData.from_date = $scope.formData.fromDate;
  297. // $scope.formData.to_date = $scope.formData.toDate;
  298. AppData.sendData($scope.pageurl, $scope.formData, function (res) {
  299. if (res.cont) {
  300. console.log(res.item)
  301. $scope.userReport = res.item;
  302. $rootScope.modulename = 'report';
  303. for (var i = 0; i < $scope.userReport.value.length; i++) {
  304. $scope.userLabel.push($scope.userReport.value[i].title)
  305. $scope.userValue.push(Number($scope.userReport.value[i].value))
  306. }
  307. console.log($scope.userLabel)
  308. console.log($scope.userValue)
  309. var showChart;
  310. if (Math.max(...$scope.userValue) == 0) {
  311. console.log('false')
  312. showChart = false;
  313. $('.inner-container').html('');
  314. $('.inner-container').html("<h4 class='text-center' >No data found</h4>");
  315. } else {
  316. showChart = true;
  317. $scope.areaChart();
  318. }
  319. } else {
  320. $scope.userReport = [];
  321. $('.inner-container').html('');
  322. $('.inner-container').html("<h4 class='text-center' >No data found</h4>");
  323. }
  324. })
  325. }
  326. //////////////// User Registration Report ////////////////////
  327. $scope.userInactiveRegistrationData = function () {
  328. $scope.userLabel = [];
  329. $scope.userValue = [];
  330. $scope.formData.funName = "inactive_user_registration";
  331. // $scope.formData.from_date = $scope.formData.fromDate;
  332. // $scope.formData.to_date = $scope.formData.toDate;
  333. AppData.sendData($scope.pageurl, $scope.formData, function (res) {
  334. if (res.cont) {
  335. console.log(res.item)
  336. $scope.userReport = res.item;
  337. $rootScope.modulename = 'report';
  338. for (var i = 0; i < $scope.userReport.value.length; i++) {
  339. $scope.userLabel.push($scope.userReport.value[i].title)
  340. $scope.userValue.push(Number($scope.userReport.value[i].value))
  341. }
  342. console.log($scope.userLabel)
  343. console.log($scope.userValue)
  344. var showChart;
  345. if (Math.max(...$scope.userValue) == 0) {
  346. console.log('false')
  347. showChart = false;
  348. $('.inner-container').html('');
  349. $('.inner-container').html("<h4 class='text-center' >No data found</h4>");
  350. } else {
  351. showChart = true;
  352. $scope.areaChart();
  353. }
  354. } else {
  355. $scope.userReport = [];
  356. $('.inner-container').html('');
  357. $('.inner-container').html("<h4 class='text-center' >No data found</h4>");
  358. }
  359. })
  360. }
  361. $scope.areaChart = function () {
  362. var maxValue = 0;
  363. if (Math.max.apply(Math, $scope.userValue) == 0) {
  364. maxValue += 10
  365. } else {
  366. maxValue += Math.max.apply(Math, $scope.userValue) + 1;
  367. }
  368. console.log(maxValue)
  369. $('.inner-container').html('');
  370. $('.inner-container').html('<canvas id="registrationChart"></canvas>');
  371. var ctx = document.getElementById('registrationChart').getContext("2d");
  372. Chart.defaults.global.legend.display = true;
  373. var gradientStroke = ctx.createLinearGradient(500, 0, 100, 0);
  374. gradientStroke.addColorStop(0, '#80b6f4');
  375. gradientStroke.addColorStop(1, '#f49080');
  376. var gradientFill = ctx.createLinearGradient(500, 0, 100, 0);
  377. gradientFill.addColorStop(0, "rgba(128, 182, 244, 0.6)");
  378. gradientFill.addColorStop(1, "rgba(244, 144, 128, 0.6)");
  379. var registrationChart = new Chart(ctx, {
  380. type: 'line',
  381. data: {
  382. labels: $scope.userLabel,
  383. datasets: [{
  384. label: "User Registration",
  385. borderColor: gradientStroke,
  386. pointBorderColor: gradientStroke,
  387. pointBackgroundColor: gradientStroke,
  388. pointHoverBackgroundColor: gradientStroke,
  389. pointHoverBorderColor: gradientStroke,
  390. pointBorderWidth: 10,
  391. pointHoverRadius: 10,
  392. pointHoverBorderWidth: 1,
  393. pointRadius: 3,
  394. fill: true,
  395. backgroundColor: gradientFill,
  396. borderWidth: 4,
  397. scaleStartValue: 0,
  398. data: $scope.userValue
  399. }]
  400. },
  401. options: {
  402. beginAtZero: true,
  403. legend: {
  404. position: "bottom"
  405. },
  406. scales: {
  407. yAxes: [{
  408. ticks: {
  409. min: 0,
  410. suggestedMin: 0,
  411. fontColor: "rgba(0,0,0,0.5)",
  412. fontStyle: "bold",
  413. maxTicksLimit: 5,
  414. padding: 20,
  415. max: maxValue,
  416. },
  417. gridLines: {
  418. drawTicks: false,
  419. display: false
  420. }
  421. }],
  422. xAxes: [{
  423. gridLines: {
  424. zeroLineColor: "transparent"
  425. },
  426. ticks: {
  427. padding: 20,
  428. fontColor: "rgba(0,0,0,0.5)",
  429. fontStyle: "bold",
  430. }
  431. }]
  432. },
  433. }
  434. });
  435. }
  436. $scope.exportData = function () {
  437. if ($rootScope.sideselect.id == 1) {
  438. $scope.formData.funName = "user_registration"
  439. } else if ($rootScope.sideselect.id == 2) {
  440. $scope.formData.funName = "activeinactive_report"
  441. // $scope.formData.funName="activeinactive_report_v2"
  442. } else if ($rootScope.sideselect.id == 3) {
  443. $scope.formData.funName = "inactive_user_registration"
  444. }
  445. AppData.sendData($scope.exporturl, $scope.formData, function (res) {
  446. if (res.cont) {
  447. $('body').append("<iframe id='fileDownload' src='" + res.item.report_url + "' ></iframe>");
  448. var setO = setTimeout(function () {
  449. clearTimeout(setO);
  450. $('#fileDownload').remove();
  451. }, 2000);
  452. }
  453. })
  454. }
  455. $scope.viewdetails = function(id){
  456. $rootScope.cofirmWindow = true;
  457. $rootScope.modalShown = true;
  458. $rootScope.message = $scope.pageData.errorMsg[4];
  459. $scope.formData.userid = id;
  460. }
  461. $scope.$on("confirmDelete", function () {
  462. $scope.formData.funName = "activeuser";
  463. AppData.sendData($scope.userurl, $scope.formData, function (res) {
  464. console.log(res);
  465. if (res.cont) {
  466. $scope.userInactiveRegistrationList();
  467. }
  468. })
  469. })
  470. $scope.exportTableData = function () {
  471. if ($rootScope.sideselect.id == 1) {
  472. $scope.formData.funName = "user_registration_percent"
  473. } else if ($rootScope.sideselect.id == 2) {
  474. $scope.formData.funName = "inactive_user_table"
  475. } else if ($rootScope.sideselect.id == 3) {
  476. $scope.formData.funName = "inactive_user_registration"
  477. }
  478. AppData.sendData($scope.exporturl, $scope.formData, function (res) {
  479. if (res.cont) {
  480. $('body').append("<iframe id='fileDownload' src='" + res.item.report_url + "' ></iframe>");
  481. var setO = setTimeout(function () {
  482. clearTimeout(setO);
  483. $('#fileDownload').remove();
  484. }, 2000);
  485. }
  486. })
  487. }
  488. /////////// Custom Filter /////////////
  489. $scope.dataFilter = function () {
  490. if ($scope.formData.datetype == '1' || $scope.formData.datetype == '2' || $scope.formData.datetype == '3' || $scope.formData.datetype == '4') {
  491. $scope.formData.from_date = '';
  492. $scope.formData.to_date = '';
  493. } else {
  494. $scope.formData.from_date = $scope.startingDate;
  495. $scope.formData.to_date = $scope.currentDate;
  496. }
  497. $scope.userRegistrationData();
  498. $scope.userRegistrationList();
  499. }
  500. ///////////////////////// Active / Inactive Report /////////////////////
  501. $scope.activeChart = function () {
  502. console.log($scope.tabActive)
  503. $('.inner-container' + $scope.tabActive).html('');
  504. $('.inner-container' + $scope.tabActive).html('<canvas id="statusChart' + $scope.tabActive + '"></canvas>');
  505. var ctx = document.getElementById("statusChart" + $scope.tabActive).getContext("2d");
  506. Chart.defaults.global.legend.display = true;
  507. var gradientStroke = ctx.createLinearGradient(500, 0, 100, 0);
  508. gradientStroke.addColorStop(0, '#80b6f4');
  509. gradientStroke.addColorStop(1, '#f49080');
  510. var yAxesticks = [];
  511. var highestVal;
  512. var statusChart1 = new Chart(ctx, {
  513. type: 'line',
  514. data: {
  515. labels: $scope.activeLabel,
  516. datasets: [
  517. {
  518. label: "Initial Users",
  519. borderColor: "#FD5F80",
  520. pointBorderColor: "#FD5F80",
  521. pointBackgroundColor: "#FD5F80",
  522. pointHoverBackgroundColor: "#FD5F80",
  523. pointHoverBorderColor: "#FD5F80",
  524. pointBorderWidth: 10,
  525. pointHoverRadius: 10,
  526. pointHoverBorderWidth: 1,
  527. pointRadius: 3,
  528. fill: false,
  529. borderWidth: 4,
  530. backgroundColor: '#FD5F80',
  531. data: $scope.initialArray
  532. },
  533. {
  534. label: "Active Users",
  535. borderColor: "#31A0EA",
  536. pointBorderColor: "#31A0EA",
  537. pointBackgroundColor: "#31A0EA",
  538. pointHoverBackgroundColor: "#31A0EA",
  539. pointHoverBorderColor: "#31A0EA",
  540. pointBorderWidth: 10,
  541. pointHoverRadius: 10,
  542. pointHoverBorderWidth: 1,
  543. pointRadius: 3,
  544. fill: false,
  545. borderWidth: 4,
  546. backgroundColor: '#31A0EA',
  547. data: $scope.activeArray
  548. }, {
  549. label: "Inactive Users",
  550. borderColor: "#FEC94D",
  551. pointBorderColor: "#FEC94D",
  552. pointBackgroundColor: "#FEC94D",
  553. pointHoverBackgroundColor: "#FEC94D",
  554. pointHoverBorderColor: "#FEC94D",
  555. pointBorderWidth: 10,
  556. pointHoverRadius: 10,
  557. pointHoverBorderWidth: 1,
  558. pointRadius: 3,
  559. fill: false,
  560. borderWidth: 4,
  561. backgroundColor: '#FEC94D',
  562. data: $scope.inactiveArray
  563. }
  564. ]
  565. },
  566. options: {
  567. legend: {
  568. position: "bottom"
  569. },
  570. scales: {
  571. yAxes: [{
  572. ticks: {
  573. fontColor: "rgba(0,0,0,0.5)",
  574. fontStyle: "bold",
  575. beginAtZero: true,
  576. maxTicksLimit: 3,
  577. padding: 20,
  578. scaleStartValue: 0,
  579. min: 0,
  580. suggestedmin: 0,
  581. callback: function (value, index, values) {
  582. yAxesticks = values;
  583. return value;
  584. }
  585. },
  586. gridLines: {
  587. drawTicks: false,
  588. display: false
  589. }
  590. }],
  591. xAxes: [{
  592. gridLines: {
  593. zeroLineColor: "transparent"
  594. },
  595. ticks: {
  596. padding: 20,
  597. fontColor: "rgba(0,0,0,0.5)",
  598. fontStyle: "bold"
  599. }
  600. }]
  601. }
  602. }
  603. });
  604. // statusChart1.options.scales.yAxes[0].ticks.min = 0;
  605. // statusChart1.update();
  606. console.log(statusChart1.options.scales.yAxes[0].ticks.min)
  607. }
  608. $scope.selectTab = function (tab) {
  609. $scope.tabActive = tab;
  610. $scope.userActivationData();
  611. // setTimeout(function () {
  612. // $scope.activeChart();
  613. // }, 100)
  614. }
  615. $scope.activeData = function () {
  616. $scope.userActivationData();
  617. }
  618. $scope.userActivationData = function () {
  619. // console.log("hai");
  620. // console.log($("#from").val())
  621. console.log($scope.formData)
  622. var val = $("#from").val();
  623. if (val == '' || val == undefined) {
  624. $('#from').datepicker("setDate", "today");
  625. $('#to').datepicker("setDate", "today");
  626. // $("#from").val($scope.startingMonth)
  627. // $("#to").val($scope.startingMonth)
  628. $scope.startMonth = moment($scope.startingMonth).format("YYYY-MM-DD");
  629. $scope.endMonth = moment($scope.startingMonth).format("YYYY-MM-DD");
  630. } else {
  631. $scope.startMonth = moment($("#from").val()).format("YYYY-MM-DD");
  632. $scope.endMonth = moment($("#to").val()).format("YYYY-MM-DD");
  633. }
  634. // $scope.formData.from_month = moment($("#from").val()).format("DD-MM-YYYY");
  635. // $scope.formData.to_month = moment($("#to").val()).format("DD-MM-YYYY");
  636. // console.log($("#to").val())
  637. if ($scope.tabActive == 1) {
  638. $scope.formData.type = 0;
  639. } else if ($scope.tabActive == 2) {
  640. $scope.formData.type = 1;
  641. }
  642. // $scope.formData.funName = "activeinactive_report";
  643. $scope.formData.funName = "activeinactive_report_v2";
  644. $scope.formData.from_date = $scope.startMonth
  645. $scope.formData.to_date = $scope.endMonth
  646. // console.log($scope.formData)
  647. AppData.sendData($scope.pageurl, $scope.formData, function (res) {
  648. if (res.cont) {
  649. console.log(res.item)
  650. $scope.userPercentList = res.item;
  651. // userPercentList=res.list
  652. // console.log(res.cont)
  653. // $scope.userActiveReport = res.item;
  654. // $scope.activeLabel = res.item.label;
  655. // $scope.activeReportValue = $scope.userActiveReport.value;
  656. // console.log($scope.userActiveReport);
  657. // $scope.activeArray=[]
  658. // $scope.inactiveArray=[]
  659. // $scope.initialArray=[]
  660. // for(var i=0;i<$scope.activeReportValue.length;i++){
  661. // $scope.activeArray.push($scope.activeReportValue[i].active)
  662. // $scope.inactiveArray.push($scope.activeReportValue[i].inactive)
  663. // $scope.initialArray.push($scope.activeReportValue[i].inital)
  664. // }
  665. // var arr = [$scope.activeArray, $scope.inactiveArray,$scope.initialArray];
  666. // var maxRow = arr.map(function(row){ return Math.max.apply(Math, row) });
  667. // if(Math.max(...maxRow)!=0){
  668. // $scope.activeChart();
  669. // }else{
  670. // $('.inner-container' + $scope.tabActive).html('');
  671. // $('.inner-container'+ $scope.tabActive).html("<h4 class='text-center' >No data found</h4>");
  672. // }
  673. }
  674. })
  675. }
  676. $scope.getDealer = function () {
  677. $scope.dealerInactive=false;
  678. // $scope.dseInactive=true;
  679. $scope.formData.dealer_code='all';
  680. var aobj = {};
  681. aobj.funName = "dealerlist";
  682. aobj.lang = $rootScope.selLanguage;
  683. aobj.am_email = $scope.formData.am_email;
  684. AppData.sendData($scope.commonurl, aobj, function (res) {
  685. $scope.dealer_userlist = res.item;
  686. // $scope.amChange()
  687. })
  688. }
  689. $scope.dealerChange = function(){
  690. if($scope.formData.dealer_code =='all'){
  691. $scope.dseInactive=false;
  692. }else{
  693. $scope.dseInactive=true;
  694. }
  695. $scope.userActivationData();
  696. }
  697. $scope.modal_dismiss = function(){
  698. // if($scope.currentPage>=2){
  699. // $scope.currentPage = 1;
  700. // $scope.setPage($scope.currentPage);
  701. // }
  702. // $(".pagination li").removeClass("active");
  703. // $('#modal').on('hidden.bs.modal', function() {
  704. // $(this).removeData('bs.modal');
  705. // });
  706. $('.myViewModal').modal('hide');
  707. // console.log('page'+$scope.currentPage )
  708. }
  709. $scope.viewremarks =function(paramvalue){
  710. console.log(paramvalue);
  711. var aobj = {};
  712. aobj.funName = "dse_remark";
  713. aobj.userid = paramvalue.userid;
  714. aobj.pn='0';
  715. aobj.nr='10';
  716. AppData.sendData($scope.pageurl, aobj, function (res) {
  717. $scope.remarkslist = res.item.report;
  718. $scope.totalremarkscount=res.total_records;
  719. $scope.totalItems=$scope.totalremarkscount;
  720. console.log("$scope.remarkslist--->,$scope.remarkslist")
  721. })
  722. }
  723. });
  724. });