'use strict';

function ClosingStockCtrl($scope, $location, info) {
    $scope.info = info;
    $scope.show = function () {
        $location.path('/ClosingStock/' + $scope.info.Date);
    };
    $('#txtDate').focus();
}
ClosingStockCtrl.resolve = {
    info:function ($q, $route, ClosingStock) {
        var deferred = $q.defer();

        var date = $route.current.params.date;

        var successCb = function(result){
          deferred.resolve(result);
        };

        if (typeof date === 'undefined') {
            ClosingStock.get({}, successCb);
        } else {
            ClosingStock.get({date:date}, successCb);
        }
        return deferred.promise;
    }
};