'use strict'; /*** controller***/ app.controller('report_leadCtrl', ["$scope", "$filter","$rootScope","$modal", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window',"dateListDescService", function ($scope, $filter,$rootScope,$modal, apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window, dateListDescService) { /* * auto call tracking/ */ $scope.userType=JSON.parse(sessionStorage.getItem('localObj')).localType $scope.isTblShow = false; $scope.isLoader = false; $scope.isLoaderShow = false; $scope.isLoaderShow1 =false; $scope.isLoaderTxt = "Loading..."; $scope.isLoaderTxt1 ="Selected Date Range is wrong"; $scope.generateButtonTxt = "GENERATE"; $scope.generateButtonStatus = false; $scope.currentPage = 1; $scope.myModel = { "date": new Date(), "activity": "", "assignedTo": "", "status": "", "referedBy": '', "comments":'', "enquiryStatus":'', "important":false, "branch":"", }; // $scope.init = function() { // alert(); var localDetail = JSON.parse(sessionStorage.getItem('localObj')); const LOCALTYPE = localDetail.localType; //console.log(LOCALTYPE) if (localDetail != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' )) { }else { if((localDetail != null) && (LOCALTYPE !='R001')) { $state.go('app.dashboard'); } else { //ipCookie.remove('cookiechk'); window.sessionStorage.clear(); $state.go('login.signin'); } } // } //get current date $scope.hideDateSearch=true; $scope.modifyMinDate = moment(); //$scope.minDate = $filter('date')($scope.modifyMinDate, 'MM-dd-yyyy'); $scope.currentDate=$filter('date')(new Date(), 'dd-MM-yyyy'); // get 30 plus date for follwup details $scope.modifyDate = moment(); $scope.modifyDate.add(30, 'days'); $scope.futureDate = $filter('date')($scope.modifyDate, 'dd-MM-yyyy'); $scope.myModel.date=$scope.currentDate; // console.log($scope.currentDate); /** * End of the call tracking */ // DataTables configurable options $scope.filtersList = { "univ": "", "activity": "", "status": "", "assigned": "", "from_date": "", "to_date": "", }; console.log($scope.filters); $scope.filters = function () { var filterlist = { method: 'POST', url: apiPoint.url + 'report_filter/', headers: { 'Content-Type': 'application/json' }, data: { branch : JSON.parse(sessionStorage.getItem('localObj')).localBranchID } }; $http(filterlist).then(function (response) { if (response.data) { $scope.batch=[]; $scope.activity = response.data.Activity; $scope.university = response.data.Univ.university; $scope.staff = response.data.Staff.staff; // console.log($scope.activity); console.log($scope.university); // console.log($scope.staff); // console.log(response.data); } else { } }); } /* watch university model for bind batch objects*/ $scope.$watch('filtersList.activity', function (newValue,oldValue) { if(newValue==undefined || newValue==''){ $scope.statusDetails=""; } else{ if(angular.isString(newValue)){ $scope.statusDetails=angular.fromJson(newValue); // console.log($scope.statusDetails); } } }); // if($scope.filtersList.activity) // { // } //Button disable if no fields selected $scope.disableSubmit=true; $scope.click = function(){ $scope.disableSubmit=false; console.log('hi'); } $scope.show = false; $scope.onSubmit = function (form) { $scope.isLoaderShow1 =true; console.log($scope.filtersList); if($scope.filtersList.activity) { $scope.filterActivity = angular.fromJson($scope.filtersList.activity); } else{ $scope.filterActivity=''; } //$scope.filterActivity = angular.fromJson($scope.filtersList.activity); $scope.lead_data = ''; $scope.message = ''; var response_data = { method: 'POST', url: apiPoint.url + 'report_lead/', headers: { 'Content-Type': 'application/json' }, data: { branch: JSON.parse(sessionStorage.getItem('localObj')).localBranchID, university : $scope.filtersList.univ, activity : $scope.filterActivity.activityID, status : $scope.filtersList.status, assigned : $scope.filtersList.assigned, from : $scope.filters.from_date, to : $scope.filters.to_date } }; if($scope.filters.from_date > $scope.filters.to_date){ $scope.isLoaderShow =true; }else{ $scope.isLoaderShow =false; } console.log($scope.filtersList.univ); console.log($scope.filterActivity.activityID); console.log($scope.filtersList.status); console.log($scope.filtersList.assigned); $http(response_data).then(function (response) { if (response.data.leadList == true) { $scope.isLoaderShow1 =false; $scope.lead_data = response.data.lead_data; for(var i=0;i<$scope.lead_data.length;i++) $scope.lead_data[i].SL_NO = i+1; } else { $scope.isLoaderShow1 =false; $scope.message = response.data.message; } }); } var mystyle = { sheetid: 'Lead REPORT', headers: true, caption: { title:'Calls done on a Particular Day/Period - Report', width: '300px', style:'font-size:50px;' }, // style:'background:#00FF00', column: { style:'font-size:10px' }, }; $scope.exportData = function () { alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,date as Date,CAST(tid AS NUMBER) as TrackingID,fup as FollowupDate,name as Name,CAST(mobile as NUMBER) as PhoneNumber,univ as University,course as Course,prsStatus as PresentStatus,cmnts as Comments,activity as Activity,AssignTo as AssignTo INTO XLS("Lead_Report.xls",?) FROM ?',[mystyle,$scope.lead_data]); }; /*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.Phone_number, requestedFrom: 3, branchCode:JSON.parse(sessionStorage.getItem('localObj')).localBranchID } }; $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'); }; }]); /** * Auto Call Tracking Sriram */ $scope.selectedStudentsID = []; $scope.isCheckAll = function(e){ var val = (e.target.checked ? true : false); if(val) { // $scope.disable = false; var len = $scope.lead_data.length; var i = 0; for(i=0;i