controller.js
3.73 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
angular.module('focaAbmPreciosCondiciones')
.controller('focaAbmPreciosCondicionesController', [
'$scope', 'focaAbmPreciosCondicionesService', '$location', 'focaModalService',
function($scope, focaAbmPreciosCondicionesService, $location, focaModalService) {
focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) {
$scope.preciosCondiciones = datos.data;
});
$scope.editar = function(id) {
$location.path('/precio-condicion/' + id);
};
$scope.solicitarConfirmacion = function(precioCondicion) {
focaModalService.confirm('¿Está seguro que desea borrar el precio condición' +
precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then(
function(data) {
if (data) {
focaAbmPreciosCondicionesService
.borrarPrecioCondicion(precioCondicion.id);
$scope.preciosCondiciones.splice(
$scope.preciosCondiciones.indexOf(precioCondicion), 1
);
}
}
);
};
}
])
.controller('focaAbmPrecioCondicionController', [
'$scope', 'focaAbmPreciosCondicionesService',
'$routeParams', '$location', 'focaModalService',
function(
$scope, focaAbmPreciosCondicionesService,
$routeParams, $location, focaModalService
) {
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) {
focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago '+
plazoPago.item+' '+plazoPago.dias + ' ?').then(
function(confirm) {
if (confirm) {
focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id);
$scope.precioCondicion.plazos.splice(
$scope.precioCondicion.plazos.indexOf(plazoPago), 1
);
}
}
);
};
}
]);