controller.js
4.68 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
angular.module('focaAbmPreciosCondiciones')
.controller('focaAbmPreciosCondicionesController', [
'$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal',
function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) {
focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) {
$scope.preciosCondiciones = datos.data;
});
$scope.editar = function(id) {
$location.path('/precio-condicion/' + id);
};
$scope.solicitarConfirmacion = function(precioCondicion) {
$uibModal.open({
templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html',
controller: 'focaAbmPreciosCondicionesModalConfirmarController',
animation: false,
backdrop: false,
resolve: {precioCondicion: function(){return precioCondicion;}}
})
.result.then(function(precioCondicion){
focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id);
$scope.preciosCondiciones.splice(
$scope.preciosCondiciones.indexOf(precioCondicion), 1
);
});
};
}
])
.controller('focaAbmPrecioCondicionController', [
'$scope', 'focaAbmPreciosCondicionesService',
'$routeParams', '$location', '$uibModal',
function(
$scope, focaAbmPreciosCondicionesService,
$routeParams, $location, $uibModal
) {
focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id)
.then(function(datos) {
$scope.precioCondicion = {
id: 0,
codigo: '',
nombre: '',
descripcion: '',
idListaPrecio: 0,
vigencia: new Date()
};
if(datos.data.id) {
$scope.precioCondicion = datos.data;
focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id)
.then(function(datos){
$scope.precioCondicion.plazos = datos.data;
});
}
});
$scope.cancelar = function() {
$location.path('/precio-condicion');
};
$scope.guardar = function(precioCondicion) {
focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion)
.then(function() {
$location.path('/precio-condicion');
});
};
$scope.editarPlazoPago = function(id) {
$location.path(
'/precio-condicion/' + $scope.precioCondicion.id +
'/plazo-pago/' + id
);
};
$scope.solicitarConfirmacionPlazoPago = function(plazoPago) {
$uibModal.open({
templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html',
controller: 'focaAbmPlazosPagosModalConfirmarController',
animation: false,
backdrop: false,
resolve: {plazoPago: function(){return plazoPago;}}
})
.result.then(function(plazoPago){
focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id);
$scope.precioCondicion.plazos.splice(
$scope.precioCondicion.plazos.indexOf(plazoPago), 1
);
});
};
}
])
.controller('focaAbmPreciosCondicionesModalConfirmarController', [
'$uibModalInstance', '$scope', 'precioCondicion',
function($uibModalInstance, $scope, precioCondicion) {
$scope.precioCondicion = precioCondicion;
$scope.cancelar = function() {
$uibModalInstance.dismiss();
};
$scope.borrar = function() {
$uibModalInstance.close(precioCondicion);
};
}
])
.controller('focaAbmPlazosPagosModalConfirmarController', [
'$uibModalInstance', '$scope', 'plazoPago',
function($uibModalInstance, $scope, plazoPago) {
$scope.plazoPago = plazoPago;
$scope.cancelar = function() {
$uibModalInstance.dismiss();
};
$scope.borrar = function() {
$uibModalInstance.close(plazoPago);
};
}
]);