controller.js
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
angular.module('focaAbmPlazoPago')
.controller('focaAbmPlazosPagoController', [
'$scope', 'focaAbmPlazoPagoService', '$location', '$uibModal',
function($scope, focaAbmPlazoPagoService, $location, $uibModal) {
focaAbmPlazoPagoService.obtenerPlazosPago().then(function(datos) {
$scope.plazosPago = datos.data;
});
$scope.editar = function(id) {
$location.path('/plazo-pago/' + id);
};
$scope.solicitarConfirmacion = function(plazoPago) {
$uibModal.open({
templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html',
controller: 'focaAbmPlazosPagoModalConfirmarController',
animation: false,
backdrop: false,
resolve: {plazoPago: function(){return plazoPago;}}
})
.result.then(function(plazoPago){
focaAbmPlazoPagoService.borrarPlazoPago(plazoPago.id);
$scope.plazosPago.splice(
$scope.plazosPago.indexOf(plazoPago), 1
);
});
};
}
])
.controller('focaAbmPlazoPagoController', [
'$scope', 'focaAbmPlazoPagoService',
'$routeParams', '$location',
function(
$scope, focaAbmPlazoPagoService,
$routeParams, $location
) {
focaAbmPlazoPagoService.obtenerPlazoPago($routeParams.id)
.then(function(datos) {
$scope.plazoPago = {
id: 0,
idPreciosCondiciones: $routeParams.idPreciosCondiciones,
item: '',
dias: ''
};
if(datos.data.id) {
$scope.plazoPago = datos.data;
}
});
$scope.cancelar = function() {
$location.path('/plazo-pago');
};
$scope.guardar = function(plazoPago) {
focaAbmPlazoPagoService.guardarPlazoPago(plazoPago)
.then(function() {
$location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones);
});
};
}
])
.controller('focaAbmPlazosPagoModalConfirmarController', [
'$uibModalInstance', '$scope', 'plazoPago',
function($uibModalInstance, $scope, plazoPago) {
$scope.plazoPago = plazoPago;
$scope.cancelar = function() {
$uibModalInstance.dismiss();
};
$scope.borrar = function() {
$uibModalInstance.close(plazoPago);
};
}
]);