/**
 * @author monitour
 * created on 27.07.2017
 */
(function () {
    'use strict';

    angular.module('Monitour.pages.billing').controller('paymentsCtrl', paymentsCtrl);

    /** @ngInject */
    function paymentsCtrl($scope, $http, BillingService, $filter,  $state, SweetAlert) {
        var vm = this;

    


    
       
        $scope.checked = false;
        $scope.size = '100px';
        $scope.toggle = function () {
            $scope.checked = !$scope.checked
        }
        vm.reset = function () {
            vm.client = [];
            vm.site = [];
        }

        vm.checkpoints = [];
        vm.totalCheckpoints = 0;
        vm.billingsPerPage = 2; // this should match however many results your API puts on one page
        getResultsPage(1);

        vm.pagination = {
            current: 1
        };

        vm.pageChanged = function (newPage) {
            getResultsPage(newPage);
        };
        function getResultsPage(pageNumber) {
            var itemsPerPage = vm.checkpointsPerPage;
            // this is just an example, in reality this stuff should be in a service
            BillingService.GetAll(pageNumber, itemsPerPage)
                .then(function (response) {
                    vm.checkpoints = response.data[0].result;
                    vm.totalCheckpoints = response.data[0].count;
                    console.log(vm.totalCheckpoints);
                    console.log(vm.checkpoints);
                }, function (error) {
                    vm.status = 'Unable to load customer data: ' + error.message;
                });


        }

 

  

       
    }

})();

