Commit 25301a33fd82810482d276f769ef6f1193fe7114

Authored by Eric Fernandez
1 parent b160261a48
Exists in master

upstream

Showing 1 changed file with 1 additions and 0 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaAbmPreciosCondiciones') 1 angular.module('focaAbmPreciosCondiciones')
2 .controller('focaAbmPreciosCondicionesController', [ 2 .controller('focaAbmPreciosCondicionesController', [
3 '$scope', 'focaAbmPreciosCondicionesService', '$location', 'focaModalService', 3 '$scope', 'focaAbmPreciosCondicionesService', '$location', 'focaModalService',
4 function($scope, focaAbmPreciosCondicionesService, $location, focaModalService) { 4 function($scope, focaAbmPreciosCondicionesService, $location, focaModalService) {
5 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { 5 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) {
6 $scope.preciosCondiciones = datos.data; 6 $scope.preciosCondiciones = datos.data;
7 }); 7 });
8 $scope.editar = function(id) { 8 $scope.editar = function(id) {
9 $location.path('/precio-condicion/' + id); 9 $location.path('/precio-condicion/' + id);
10 }; 10 };
11 $scope.solicitarConfirmacion = function(precioCondicion) { 11 $scope.solicitarConfirmacion = function(precioCondicion) {
12 focaModalService.confirm('¿Está seguro que desea borrar el precio condición' + 12 focaModalService.confirm('¿Está seguro que desea borrar el precio condición' +
13 precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then( 13 precioCondicion.codigo + ' ' + precioCondicion.nombre + ' ?').then(
14 function(data) { 14 function(data) {
15 if (data) { 15 if (data) {
16 focaAbmPreciosCondicionesService 16 focaAbmPreciosCondicionesService
17 .borrarPrecioCondicion(precioCondicion.id); 17 .borrarPrecioCondicion(precioCondicion.id);
18 $scope.preciosCondiciones.splice( 18 $scope.preciosCondiciones.splice(
19 $scope.preciosCondiciones.indexOf(precioCondicion), 1 19 $scope.preciosCondiciones.indexOf(precioCondicion), 1
20 ); 20 );
21 } 21 }
22 } 22 }
23 ); 23 );
24 }; 24 };
25 } 25 }
26 ]) 26 ])
27 .controller('focaAbmPrecioCondicionController', [ 27 .controller('focaAbmPrecioCondicionController', [
28 '$scope', 'focaAbmPreciosCondicionesService', 28 '$scope', 'focaAbmPreciosCondicionesService',
29 '$routeParams', '$location', 'focaModalService', 29 '$routeParams', '$location', 'focaModalService',
30 function( 30 function(
31 $scope, focaAbmPreciosCondicionesService, 31 $scope, focaAbmPreciosCondicionesService,
32 $routeParams, $location, focaModalService 32 $routeParams, $location, focaModalService
33 ) { 33 ) {
34 $scope.mostrarPlazos = $routeParams.id > 0;
34 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) 35 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id)
35 .then(function(datos) { 36 .then(function(datos) {
36 $scope.precioCondicion = { 37 $scope.precioCondicion = {
37 id: 0, 38 id: 0,
38 codigo: '', 39 codigo: '',
39 nombre: '', 40 nombre: '',
40 descripcion: '', 41 descripcion: '',
41 idListaPrecio: 0, 42 idListaPrecio: 0,
42 vigencia: new Date() 43 vigencia: new Date()
43 }; 44 };
44 if (datos.data.id) { 45 if (datos.data.id) {
45 $scope.precioCondicion = datos.data; 46 $scope.precioCondicion = datos.data;
46 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) 47 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id)
47 .then(function(datos) { 48 .then(function(datos) {
48 $scope.precioCondicion.plazos = datos.data; 49 $scope.precioCondicion.plazos = datos.data;
49 }); 50 });
50 } 51 }
51 }); 52 });
52 $scope.cancelar = function() { 53 $scope.cancelar = function() {
53 $location.path('/precio-condicion'); 54 $location.path('/precio-condicion');
54 }; 55 };
55 $scope.guardar = function(precioCondicion) { 56 $scope.guardar = function(precioCondicion) {
56 focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) 57 focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion)
57 .then(function() { 58 .then(function() {
58 $location.path('/precio-condicion'); 59 $location.path('/precio-condicion');
59 }); 60 });
60 }; 61 };
61 $scope.editarPlazoPago = function(id) { 62 $scope.editarPlazoPago = function(id) {
62 $location.path( 63 $location.path(
63 '/precio-condicion/' + $scope.precioCondicion.id + 64 '/precio-condicion/' + $scope.precioCondicion.id +
64 '/plazo-pago/' + id 65 '/plazo-pago/' + id
65 ); 66 );
66 }; 67 };
67 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { 68 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) {
68 focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago '+ 69 focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago '+
69 plazoPago.item+' '+plazoPago.dias + ' ?').then( 70 plazoPago.item+' '+plazoPago.dias + ' ?').then(
70 function(confirm) { 71 function(confirm) {
71 if (confirm) { 72 if (confirm) {
72 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); 73 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id);
73 $scope.precioCondicion.plazos.splice( 74 $scope.precioCondicion.plazos.splice(
74 $scope.precioCondicion.plazos.indexOf(plazoPago), 1 75 $scope.precioCondicion.plazos.indexOf(plazoPago), 1
75 ); 76 );
76 } 77 }
77 } 78 }
78 ); 79 );
79 }; 80 };
80 } 81 }
81 ]); 82 ]);
82 83