controller.js
2.33 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
angular.module('focaAbmPlazoPago')
.controller('focaAbmPlazosPagoController', [
'$scope', 'focaAbmPlazoPagoService', '$location', 'focaModalService',
function($scope, focaAbmPlazoPagoService, $location, focaModalService) {
focaAbmPlazoPagoService.obtenerPlazosPago().then(function(datos) {
$scope.plazosPago = datos.data;
});
$scope.editar = function(idPreciosCondiciones, id) {
$location.path('/precio-condicion/' + idPreciosCondiciones + '/plazo-pago/' + id);
};
$scope.solicitarConfirmacion = function(plazoPago) {
focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago '+
plazoPago.item+' '+plazoPago.dias+' ?').then(
function(confirm) {
if(confirm){
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('/precio-condicion/' + $routeParams.idPreciosCondiciones);
};
$scope.guardar = function(plazoPago) {
focaAbmPlazoPagoService.guardarPlazoPago(plazoPago)
.then(function() {
$location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones);
});
};
}
]);