Files
brewman/brewman/static/scripts/cash-flow.js
T
Amritanshu d1a4fc1164 Updated: Angularjs to v1.2.0 final.
Updated: Loading-bar to v0.0.5
Updated: Using the $promise of function to return promises instead of $q and callback function.
2013-11-12 00:29:23 +05:30

31 lines
1.3 KiB
JavaScript

'use strict';
var CashFlowCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'cash_flow', function ($scope, $routeParams, $location, dateFilter, cash_flow) {
$scope.info = cash_flow;
$scope.show = function () {
if (angular.isDate($scope.info.StartDate)) {
$scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy');
}
if (angular.isDate($scope.info.FinishDate)) {
$scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy');
}
$location.path('/CashFlow').search({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate});
};
$('#txtStartDate').focus();
}];
CashFlowCtrl.resolve = {
cash_flow:['$route', 'CashFlow', function ($route, CashFlow) {
var id = $route.current.params.id,
start_date = $route.current.params.StartDate,
finish_date = $route.current.params.FinishDate;
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
return CashFlow.get({}).$promise;
} else if (typeof id === 'undefined') {
return CashFlow.get({StartDate:start_date, FinishDate:finish_date}).$promise;
} else {
return CashFlow.get({id:id, StartDate:start_date, FinishDate:finish_date}).$promise;
}
}]
};