Chosen updated to 1.3.0 AngularJS updated to 1.3.8 jQuery updated to 2.1.3 angular-loading-bar updated to 0.6.0 ui-bootstrap updated to 0.12.0 -- All the datepickers updated for is-open so that they open on focus. Chore: Replaces this in controllers with $scope. Don't know the downsides of using "this", but to prevent any unknown side-effects. Chore: Rename Crtl to Controller for all controllers.
96 lines
3.5 KiB
JavaScript
96 lines
3.5 KiB
JavaScript
'use strict';
|
|
|
|
var ReconcileController = ['$scope', '$routeParams', '$location', 'asDateFilter', 'reconcile', 'Reconcile', 'Account', function ($scope, $routeParams, $location, asDate, reconcile, Reconcile, Account) {
|
|
$scope.info = reconcile;
|
|
$scope.show = function () {
|
|
var id = $scope.info.Account.LedgerID,
|
|
startDate = asDate($scope.info.StartDate),
|
|
finishDate = asDate($scope.info.FinishDate);
|
|
if (id === $routeParams.id && startDate === $routeParams.StartDate && finishDate === $routeParams.FinishDate) {
|
|
Reconcile.get({id: id, StartDate: startDate, FinishDate: finishDate}, function (data) {
|
|
$scope.info = data;
|
|
});
|
|
} else {
|
|
$location.path('/Reconcile/' + id).search('StartDate', startDate).search('FinishDate', finishDate);
|
|
}
|
|
};
|
|
$scope.save = function () {
|
|
var i, l,
|
|
len = $scope.info.Body.length;
|
|
for (i = 0, l = len; i < l; i++) {
|
|
$scope.info.Body[i].ReconcileDate = asDate($scope.info.Body[i].ReconcileDate);
|
|
}
|
|
$scope.info.$save({StartDate: $routeParams.StartDate, FinishDate: $routeParams.FinishDate}, function (u, putResponseHeaders) {
|
|
$scope.toasts.push({Type: 'Success', Message: ''});
|
|
$scope.info = u;
|
|
}, function (data, status) {
|
|
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
};
|
|
|
|
$scope.downloadTable = function () {
|
|
var table = $('#gvGrid'),
|
|
html = table.clone().wrap('<div></div>').parent().html();
|
|
html = html.replace(/á/g, 'á');
|
|
window.open('data:application/vnd.ms-excel;charset=UTF-8,' + encodeURIComponent(html));
|
|
};
|
|
|
|
if ($routeParams.id) {
|
|
$('#gvGrid').focus();
|
|
} else {
|
|
$('#txtLedger').focus();
|
|
}
|
|
|
|
$scope.selected = -1;
|
|
$scope.setSelected = function (index) {
|
|
$scope.selected = index;
|
|
};
|
|
|
|
$scope.shortcuts = {
|
|
'up': function (e) {
|
|
if ($scope.selected > 0) {
|
|
$scope.$apply(function () {
|
|
$scope.selected = $scope.selected -= 1;
|
|
});
|
|
$("#" + $scope.selected).scrollintoview({duration: 'fast'});
|
|
e.preventDefault();
|
|
}
|
|
},
|
|
'down': function (e) {
|
|
if ($scope.selected < $scope.info.Body.length - 1) {
|
|
$scope.$apply(function () {
|
|
$scope.selected = $scope.selected += 1;
|
|
});
|
|
$("#" + $scope.selected).scrollintoview({duration: 'fast'});
|
|
e.preventDefault();
|
|
}
|
|
},
|
|
'enter': function (e) {
|
|
var path = $scope.info.Body[$scope.selected].Url.replace(/^(?:\/\/|[^\/]+)*/, "");
|
|
$scope.$apply(function () {
|
|
$location.path(path).search('StartDate', null).search('FinishDate', null);
|
|
});
|
|
}
|
|
};
|
|
|
|
$scope.accounts = function ($viewValue) {
|
|
return Account.autocomplete({term: $viewValue, count: 20, r: true}).$promise;
|
|
};
|
|
}];
|
|
|
|
ReconcileController.resolve = {
|
|
reconcile: ['$route', 'Reconcile', function ($route, Reconcile) {
|
|
var id = $route.current.params.id,
|
|
startDate = $route.current.params.StartDate,
|
|
finishDate = $route.current.params.FinishDate;
|
|
|
|
if (angular.isUndefined(id)) {
|
|
return Reconcile.get({}).$promise;
|
|
} else {
|
|
return Reconcile.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise;
|
|
}
|
|
}]
|
|
};
|
|
|
|
|