|  | @@ -0,0 +1,82 @@
 | 
	
		
			
				|  |  | +starter.controller('SigninFilterCtrl', function ($scope, $state, $ionicPlatform, $interval, $timeout, $rootScope, SigninFilter, showPopup, global, Tool) {
 | 
	
		
			
				|  |  | +    $scope.loading = true;
 | 
	
		
			
				|  |  | +    global.fetch_user().then(function () {
 | 
	
		
			
				|  |  | +        $scope.doRefresh();
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $scope.loadMore = function () {
 | 
	
		
			
				|  |  | +        Tool.get_nextpage($scope.signin.next).then(function (res) {
 | 
	
		
			
				|  |  | +            var old_data = angular.copy($scope.signin.Data);
 | 
	
		
			
				|  |  | +            $scope.signin = res.Data;
 | 
	
		
			
				|  |  | +            $scope.signin.Data = old_data.concat(res.data.Data);
 | 
	
		
			
				|  |  | +        }).finally(function (f) {
 | 
	
		
			
				|  |  | +            $scope.$broadcast('scroll.infiniteScrollComplete');
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $scope.doRefresh = function () {
 | 
	
		
			
				|  |  | +        global.refresh = true;
 | 
	
		
			
				|  |  | +        SigninFilter.signin.get({"condi": 6, "page": 0}, function (res) {
 | 
	
		
			
				|  |  | +            console.log(res);
 | 
	
		
			
				|  |  | +            $scope.signin = res;
 | 
	
		
			
				|  |  | +            get_results($scope.signin.Data)
 | 
	
		
			
				|  |  | +        }).$promise.finally(function (f) {
 | 
	
		
			
				|  |  | +            $scope.loading = false;
 | 
	
		
			
				|  |  | +            $scope.$broadcast('scroll.refreshComplete');
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $scope.date_list = [
 | 
	
		
			
				|  |  | +        {"value": "去年", "key": 9},
 | 
	
		
			
				|  |  | +        {"value": "本年", "key": 8},
 | 
	
		
			
				|  |  | +        {"value": "上季", "key": 7},
 | 
	
		
			
				|  |  | +        {"value": "本季", "key": 6},
 | 
	
		
			
				|  |  | +        {"value": "上月", "key": 5},
 | 
	
		
			
				|  |  | +        {"value": "本月", "key": 4},
 | 
	
		
			
				|  |  | +        {"value": "上周", "key": 3},
 | 
	
		
			
				|  |  | +        {"value": "本周", "key": 2},
 | 
	
		
			
				|  |  | +        {"value": "当日", "key": 1},
 | 
	
		
			
				|  |  | +        {"value": "全部", "key": 0}
 | 
	
		
			
				|  |  | +    ].reverse();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $scope.acitve_date = $scope.date_list[1];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    showPopup.modalTemplate('templates/modal-filter.html', 'slide-in-right', $scope).then(function (model) {
 | 
	
		
			
				|  |  | +        $rootScope.commons.model = model;
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $scope.openModel = function () {
 | 
	
		
			
				|  |  | +        $rootScope.commons.model.show();
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $scope.change = function (item) {
 | 
	
		
			
				|  |  | +        if ($scope.acitve_date.value == item.value) {
 | 
	
		
			
				|  |  | +            $rootScope.commons.model.hide();
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $scope.acitve_date = item;
 | 
	
		
			
				|  |  | +        $scope.loading = true;
 | 
	
		
			
				|  |  | +        SigninFilter.signin.get({"condi": item.key, "page": 0}, function (res) {
 | 
	
		
			
				|  |  | +            $scope.signin = res;
 | 
	
		
			
				|  |  | +            get_results($scope.signin.Data);
 | 
	
		
			
				|  |  | +        }, function (err) {
 | 
	
		
			
				|  |  | +            alert(JSON.stringify(err))
 | 
	
		
			
				|  |  | +        }).$promise.finally(function (f) {
 | 
	
		
			
				|  |  | +            $scope.loading = false;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        $rootScope.commons.model.hide();
 | 
	
		
			
				|  |  | +        console.log(JSON.stringify(item));
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    function get_results(data) {
 | 
	
		
			
				|  |  | +        var date_list = _.uniq(_.map(data, function (item) {
 | 
	
		
			
				|  |  | +            item.date = item.bil_date.substring(0, 10);
 | 
	
		
			
				|  |  | +            return item.bil_date.substring(0, 10);
 | 
	
		
			
				|  |  | +        }));
 | 
	
		
			
				|  |  | +        data = _.map(date_list, function (item) {
 | 
	
		
			
				|  |  | +            return {'date': item, "daystr": Tool.getTranslateByKey("weekdays", new Date(item).getDay()), "items": _.filter(data, {"date": item})}
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        $scope.signin.Data = data;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +})
 |