'use strict'; /*** controller***/ app.controller('staffleadCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$sessionStorage" ,"$http", "$state","$modal","$log", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $sessionStorage, $http,ipCookie ,$state,$modal,$log){ //function ($scope, apiPoint, $http, SweetAlert, $state,$modal, md5, ipCookie, $window, dateListDescService) { // DataTables configurable options $scope.filters = { "from_date": "", "to_date": "", }; var localDetails = JSON.parse(sessionStorage.getItem('localObj')); //var localDetails = ipCookie('cookiechk'); // console.log(localDetails); // $scope.initHead = function() { //console.log('rfd'); var logcheck = JSON.parse(sessionStorage.getItem('localObj')); const LOCALTYPE = logcheck.localType; if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R002' || LOCALTYPE == 'R005')) { console.log("if"); }else { if(logcheck != null && LOCALTYPE !='R001') { console.log("else if"); $state.go('app.dashboard'); } else { console.log("else else"); //ipCookie.remove('cookiechk'); window.sessionStorage.clear(); $state.go('login.signin'); } } // } $scope.universitySearchData = ''; $scope.filters = { "to_date": "", }; $scope.init = function() { // console.log('in') var date = new Date(); var t = new Date(date), month = '' + (t.getMonth() + 1), day = '' + t.getDate(), year = t.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var to_dt = [year, month ,day].join('-'); $scope.tod = to_dt; $scope.GetstaffwiseCounts($scope.tod); }; $scope.changeDate = function() { var to = $scope.filters.to_date; //alert(to); if(to !='') { var t = new Date(to), month = '' + (t.getMonth() + 1), day = '' + t.getDate(), year = t.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var to_dt = [year, month ,day].join('-'); $scope.tod = to_dt; } else { var date = new Date(); var t = new Date(date), month = '' + (t.getMonth() + 1), day = '' + t.getDate(), year = t.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var to_dt = [year, month ,day].join('-'); $scope.tod = to_dt; } $scope.GetstaffwiseCounts($scope.tod); } $scope.GetstaffwiseCounts = function (date) { var getcountDetails = { method: 'POST', url: apiPoint.url + 'getstaffCountDetails/', headers: { 'Content-Type': 'application/json' }, data: { branch:JSON.parse(sessionStorage.getItem('localObj')).localBranchID, date:date, } }; $http(getcountDetails).then(function (response) { // console.log(response.data.details); if (response.data.status == 200 && response.data.details !='No records found!' ) { $scope.SatffCountDetails=response.data.details; $scope.callnodata=true; $scope.calldata=false; for(var i=0;i<$scope.SatffCountDetails.length;i++) $scope.SatffCountDetails[i].SL_NO = i+1; //console.log($scope.SatffCountDetails); } else { // swal("Failed!", "No details Availble", "warning"); $scope.calldata=true; $scope.callnodata=false; //console.log($scope.calldata); } }); } $scope.closeDetails = function() { $scope.staffdet = '-1'; } $scope.SatffCallDetails $scope.staffdet = '-1'; $scope.AssignedStaff_id =''; $scope.getLeadDetails = function (staff) { var assignedstaffid = staff.AssignedStaff; var checkdate = $scope.tod; $scope.AssignedStaff_id =assignedstaffid; var getDetails = { method: 'POST', url: apiPoint.url + 'getstaffcallDetails/', headers: { 'Content-Type': 'application/json' }, data: { branch:JSON.parse(sessionStorage.getItem('localObj')).localBranchID, date:checkdate, staff:assignedstaffid, } }; $http(getDetails).then(function (response) { if (response.data.status == 200 && response.data.details !='No records found!' ) { $scope.SatffCallDetails=response.data.details; $scope.calldetnodata=true; $scope.calldetdata=false; // console.log(response.data.details); // console.log($scope.SatffCallDetails) $scope.staffdet = $scope.SatffCallDetails[0].AssignedStaff; //console.log($scope.staffdet) for(var i=0;i<$scope.SatffCallDetails.length;i++) $scope.SatffCallDetails[i].SL_NO = i+1; } else { // swal("Failed!", "No details Availble", "warning"); $scope.calldetdata=true; $scope.calldetnodata=false; } }); } }]);