'use strict';

var ClosingStockCtrl = ['$scope', '$location', 'asDateFilter', 'info', function ($scope, $location, asDate, info) {
    $scope.info = info;
    $scope.show = function () {
        var date = asDate($scope.info.Date);
        $location.path('/ClosingStock/' + date);
    };
    $('#txtDate').focus();
}];

ClosingStockCtrl.resolve = {
    info: ['$route', 'ClosingStock', function ($route, ClosingStock) {
        var date = $route.current.params.date;

        if (angular.isUndefined(date)) {
            return ClosingStock.get({}).$promise;
        } else {
            return ClosingStock.get({date: date}).$promise;
        }
    }]
};