Commit b4e49ed42ccdcf2d1ec3345d3e301b36aa02b93d
Merge branch 'develop' into 'master'
Develop See merge request !21
Showing
3 changed files
 
Show diff stats
src/js/controller.js
| 1 | angular.module('focaModalPrecioCondicion') | 1 | angular.module('focaModalPrecioCondicion') | 
| 2 | .controller('focaModalPrecioCondicionController', | 2 | .controller('focaModalPrecioCondicionController', | 
| 3 | [ | 3 | [ | 
| 4 | '$timeout', | 4 | '$timeout', | 
| 5 | '$filter', | 5 | '$filter', | 
| 6 | '$scope', | 6 | '$scope', | 
| 7 | '$uibModal', | 7 | '$uibModal', | 
| 8 | '$uibModalInstance', | 8 | '$uibModalInstance', | 
| 9 | 'focaModalService', | 9 | 'focaModalService', | 
| 10 | 'focaModalPrecioCondicionService', | 10 | 'focaModalPrecioCondicionService', | 
| 11 | 'idListaPrecio', | 11 | 'parametros', | 
| 12 | 'idCliente', | ||
| 13 | function ( | 12 | function ( | 
| 14 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 13 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 
| 15 | focaModalService, focaModalPrecioCondicionService, idListaPrecio, idCliente | 14 | focaModalService, focaModalPrecioCondicionService, parametros | 
| 16 | ) { | 15 | ) { | 
| 17 | $scope.plazos = [ | 16 | $scope.plazos = [ | 
| 18 | { | 17 | { | 
| 19 | dias: 0, | 18 | dias: 0, | 
| 20 | idCliente: idCliente, | 19 | idCliente: parametros.idCliente, | 
| 21 | activo: true | 20 | activo: true | 
| 22 | } | 21 | } | 
| 23 | ]; | 22 | ]; | 
| 24 | $scope.openModalListaDePrecios = false; | 23 | $scope.openModalListaDePrecios = false; | 
| 25 | $scope.associatedList = true; | 24 | $scope.associatedList = true; | 
| 26 | $scope.listaDePreciosAlternativa = null; | 25 | $scope.listaDePreciosAlternativa = null; | 
| 27 | 26 | ||
| 28 | onInit(); | 27 | onInit(); | 
| 29 | 28 | ||
| 30 | function onInit() { | 29 | function onInit() { | 
| 31 | //Metodo para traer la lista de precio asociada al cliente | 30 | //Metodo para traer la lista de precio asociada al cliente | 
| 32 | focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) | 31 | focaModalPrecioCondicionService.getListaPrecio(parametros.idListaPrecio) | 
| 33 | .then(function (res) { | 32 | .then(function (res) { | 
| 34 | $scope.listaDePreciosAsociada = res.data[0]; | 33 | $scope.listaDePreciosAsociada = res.data[0]; | 
| 35 | }) | 34 | }) | 
| 36 | .catch(function (e) { console.error(e) }); | 35 | .catch(function (e) { console.error(e) }); | 
| 37 | focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) | 36 | focaModalPrecioCondicionService.getPlazosByIdCliente(parametros.idCliente) | 
| 38 | .then(function (res) { | 37 | .then(function (res) { | 
| 39 | res.data.forEach(function (item) { | 38 | res.data.forEach(function (item) { | 
| 40 | $scope.plazos.push(item); | 39 | $scope.plazos.push(item); | 
| 41 | }); | 40 | }); | 
| 42 | }) | 41 | }) | 
| 43 | .catch(function (e) { console.error(e) }); | 42 | .catch(function (e) { console.error(e) }); | 
| 44 | } | 43 | } | 
| 45 | 44 | ||
| 46 | //#region Metodos para la lista de precios | 45 | //#region Metodos para la lista de precios | 
| 47 | $scope.openListaDePrecios = function () { | 46 | $scope.openListaDePrecios = function () { | 
| 48 | var datos = null; | 47 | var datos = null; | 
| 49 | focaModalPrecioCondicionService.getAllListaPrecio() | 48 | focaModalPrecioCondicionService.getAllListaPrecio() | 
| 50 | .then(function (res) { | 49 | .then(function (res) { | 
| 51 | datos = res.data; | 50 | datos = res.data; | 
| 52 | focaModalService.modal({ | 51 | focaModalService.modal({ | 
| 53 | titulo: 'Lista de precios', | 52 | titulo: 'Lista de precios', | 
| 54 | data: datos, | 53 | data: datos, | 
| 55 | size: 'md', | 54 | size: 'md', | 
| 56 | columnas: [ | 55 | columnas: [ | 
| 57 | { | 56 | { | 
| 58 | propiedad: 'ID', | 57 | propiedad: 'ID', | 
| 59 | nombre: 'Codigo' | 58 | nombre: 'Codigo' | 
| 60 | }, | 59 | }, | 
| 61 | { | 60 | { | 
| 62 | propiedad: 'DES', | 61 | propiedad: 'DES', | 
| 63 | NOMBRE: 'Nombre' | 62 | NOMBRE: 'Nombre' | 
| 64 | } | 63 | } | 
| 65 | ], | 64 | ], | 
| 66 | }).then(function (res) { | 65 | }).then(function (res) { | 
| 67 | $scope.associatedList = false; | 66 | focaModalService.confirm('¿Desea cambiar la lista de precios?\n'+ | 
| 68 | $scope.listaDePreciosAlternativa = res; | 67 | 'Se perderan los productos ingresados').then(function (data){ | 
| 68 | if (data) { | ||
| 69 | $scope.associatedList = false; | ||
| 70 | $scope.listaDePreciosAlternativa = res; | ||
| 71 | } | ||
| 72 | }); | ||
| 69 | }).catch(function (e) { | 73 | }).catch(function (e) { | 
| 70 | console.error(e); | 74 | console.error(e); | 
| 71 | }); | 75 | }); | 
| 72 | }); | 76 | }); | 
| 73 | }; | 77 | }; | 
| 74 | $scope.selectListaDePrecios = function () { | 78 | $scope.selectListaDePrecios = function () { | 
| 75 | $scope.associatedList = true; | 79 | $scope.associatedList = true; | 
| 76 | }; | 80 | }; | 
| 77 | $scope.verListaProductos = function (id) { | 81 | $scope.verListaProductos = function (id) { | 
| 78 | $uibModal.open( | 82 | $uibModal.open( | 
| 79 | { | 83 | { | 
| 80 | ariaLabelledBy: 'Busqueda de Productos', | 84 | ariaLabelledBy: 'Busqueda de Productos', | 
| 81 | templateUrl: 'modal-busqueda-productos.html', | 85 | templateUrl: 'modal-busqueda-productos.html', | 
| 82 | controller: 'modalBusquedaProductosCtrl', | 86 | controller: 'modalBusquedaProductosCtrl', | 
| 83 | resolve: { | 87 | resolve: { | 
| 84 | parametroProducto: { | 88 | parametroProducto: { | 
| 85 | idLista: parseInt(id), | 89 | idLista: parseInt(id), | 
| 86 | cotizacion: 1, | 90 | cotizacion: 1, | 
| 87 | simbolo: '$', | 91 | simbolo: '$', | 
| 88 | soloMostrar: true | 92 | soloMostrar: true | 
| 89 | } | 93 | } | 
| 90 | }, | 94 | }, | 
| 91 | size: 'md' | 95 | size: 'md' | 
| 92 | } | 96 | } | 
| 93 | ); | 97 | ); | 
| 94 | }; | 98 | }; | 
| 95 | //#endregion | 99 | //#endregion | 
| 96 | 100 | ||
| 97 | //#region Metodos para los plazos | 101 | //#region Metodos para los plazos | 
| 98 | $scope.addPlazo = function (key) { | 102 | $scope.addPlazo = function (key) { | 
| 99 | if (key != 13) return; | 103 | if (key != 13) return; | 
| 100 | if ($scope.plazos.length === 100) return; | 104 | if ($scope.plazos.length === 100) return; | 
| 101 | for (var i = 1; i < $scope.plazos.length; i++) { | 105 | for (var i = 1; i < $scope.plazos.length; i++) { | 
| 102 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { | 106 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { | 
| 103 | focaModalService.alert("Ya existe un plazo con este valor"); | 107 | focaModalService.alert("Ya existe un plazo con este valor"); | 
| 104 | return; | 108 | return; | 
| 105 | } | 109 | } | 
| 106 | } | 110 | } | 
| 107 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); | 111 | $scope.plazos.unshift({ dias: 0, idCliente: parametros.idCliente, activo: true }); | 
| 108 | $scope.focused = 1; | 112 | $scope.focused = 1; | 
| 109 | }; | 113 | }; | 
| 110 | $scope.deletePlazo = function (index) { | 114 | $scope.deletePlazo = function (index) { | 
| 111 | $scope.plazos[index].activo = false; | 115 | $scope.plazos[index].activo = false; | 
| 112 | }; | 116 | }; | 
| 113 | $scope.validateMinMax = function (plazo, min, max) { | 117 | $scope.validateMinMax = function (plazo, min, max) { | 
| 114 | plazo.dias = parseInt(plazo.dias); | 118 | plazo.dias = parseInt(plazo.dias); | 
| 115 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { | 119 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { | 
| 116 | plazo.dias = '0'; | 120 | plazo.dias = '0'; | 
| 117 | return; | 121 | return; | 
| 118 | } | 122 | } | 
| 119 | if (parseInt(plazo.dias) < min) { | 123 | if (parseInt(plazo.dias) < min) { | 
| 120 | plazo.dias = '0'; | 124 | plazo.dias = '0'; | 
| 121 | return; | 125 | return; | 
| 122 | } | 126 | } | 
| 123 | if (parseInt(plazo.dias) > max) { | 127 | if (parseInt(plazo.dias) > max) { | 
| 124 | plazo.dias = '365'; | 128 | plazo.dias = '365'; | 
| 125 | return; | 129 | return; | 
| 126 | } | 130 | } | 
| 127 | }; | 131 | }; | 
| 128 | //#endregion | 132 | //#endregion | 
| 129 | 133 | ||
| 130 | $scope.closeModalPrecioCondicion = function () { | 134 | $scope.closeModalPrecioCondicion = function () { | 
| 131 | $uibModalInstance.dismiss('cancel'); | 135 | $uibModalInstance.dismiss('cancel'); | 
| 132 | }; | 136 | }; | 
| 133 | $scope.guardarPrecioCondicion = function () { | 137 | $scope.guardarPrecioCondicion = function () { | 
| 134 | $scope.plazos.shift(); | 138 | var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); | 
| 135 | focaModalPrecioCondicionService.createPlazo($scope.plazos) | 139 | focaModalPrecioCondicionService.actualizarLista(parametros.idCliente, mod).then(function (){ | 
| 136 | .then(function () { | 140 | $scope.plazos.shift(); | 
| 137 | var precioCondicion = { | 141 | focaModalPrecioCondicionService.createPlazo($scope.plazos) | 
| 138 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | 142 | .then(function () { | 
| 139 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | 143 | var precioCondicion = { | 
| 140 | }; | 144 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | 
| 141 | $uibModalInstance.close(precioCondicion); | 145 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | 
| 142 | }) | 146 | }; | 
| 143 | .catch(function (e) { console.error(e) }) | 147 | $uibModalInstance.close(precioCondicion); | 
| 144 | } | 148 | }) | 
| 149 | .catch(function (e) { console.error(e) }) | ||
| 150 | }); | ||
| 151 | }; | ||
| 145 | } | 152 | } | 
| 146 | ]); | 153 | ]); | 
src/js/controllerCliente.js
| 1 | angular.module('focaModalPrecioCondicion') | 1 | angular.module('focaModalPrecioCondicion') | 
| 2 | .controller('focaModalListaPreciosController', | 2 | .controller('focaModalListaPreciosController', | 
| 3 | [ | 3 | [ | 
| 4 | '$timeout', | 4 | '$timeout', | 
| 5 | '$filter', | 5 | '$filter', | 
| 6 | '$scope', | 6 | '$scope', | 
| 7 | '$uibModal', | 7 | '$uibModal', | 
| 8 | '$uibModalInstance', | 8 | '$uibModalInstance', | 
| 9 | 'focaModalService', | 9 | 'focaModalService', | 
| 10 | 'focaModalPrecioCondicionService', | 10 | 'focaModalPrecioCondicionService', | 
| 11 | 'idListaPrecio', | 11 | 'parametros', | 
| 12 | function ( | 12 | function ( | 
| 13 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 13 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 
| 14 | focaModalService, focaModalPrecioCondicionService, idListaPrecio | 14 | focaModalService, focaModalPrecioCondicionService, parametros | 
| 15 | ) { | 15 | ) { | 
| 16 | $scope.openModalListaDePrecios = false; | 16 | $scope.openModalListaDePrecios = false; | 
| 17 | $scope.associatedList = true; | 17 | $scope.associatedList = true; | 
| 18 | $scope.listaDePreciosAlternativa = null; | 18 | $scope.listaDePreciosAlternativa = null; | 
| 19 | 19 | ||
| 20 | onInit(); | 20 | onInit(); | 
| 21 | 21 | ||
| 22 | function onInit() { | 22 | function onInit() { | 
| 23 | //Metodo para traer la lista de precio asociada al cliente | 23 | //Metodo para traer la lista de precio asociada al cliente | 
| 24 | focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) | 24 | focaModalPrecioCondicionService.getListaPrecio(parametros.idListaPrecio) | 
| 25 | .then(function (res) { | 25 | .then(function (res) { | 
| 26 | $scope.listaDePreciosAsociada = res.data[0]; | 26 | $scope.listaDePreciosAsociada = res.data[0]; | 
| 27 | }) | 27 | }) | 
| 28 | .catch(function (e) { console.error(e) }); | 28 | .catch(function (e) { console.error(e) }); | 
| 29 | } | 29 | } | 
| 30 | 30 | ||
| 31 | //#region Metodos para la lista de precios | 31 | //#region Metodos para la lista de precios | 
| 32 | $scope.openListaDePrecios = function () { | 32 | $scope.openListaDePrecios = function () { | 
| 33 | var datos = null; | 33 | var datos = null; | 
| 34 | focaModalPrecioCondicionService.getAllListaPrecio() | 34 | focaModalPrecioCondicionService.getAllListaPrecio() | 
| 35 | .then(function (res) { | 35 | .then(function (res) { | 
| 36 | datos = res.data; | 36 | datos = res.data; | 
| 37 | focaModalService.modal({ | 37 | focaModalService.modal({ | 
| 38 | titulo: 'Lista de precios', | 38 | titulo: 'Lista de precios', | 
| 39 | data: datos, | 39 | data: datos, | 
| 40 | size: 'md', | 40 | size: 'md', | 
| 41 | columnas: [ | 41 | columnas: [ | 
| 42 | { | 42 | { | 
| 43 | propiedad: 'ID', | 43 | propiedad: 'ID', | 
| 44 | nombre: 'Codigo' | 44 | nombre: 'Codigo' | 
| 45 | }, | 45 | }, | 
| 46 | { | 46 | { | 
| 47 | propiedad: 'DES', | 47 | propiedad: 'DES', | 
| 48 | NOMBRE: 'Nombre' | 48 | NOMBRE: 'Nombre' | 
| 49 | } | 49 | } | 
| 50 | ], | 50 | ], | 
| 51 | }).then(function (res) { | 51 | }).then(function (res) { | 
| 52 | $scope.associatedList = false; | 52 | $scope.associatedList = false; | 
| 53 | $scope.listaDePreciosAlternativa = res; | 53 | $scope.listaDePreciosAlternativa = res; | 
| 54 | }).catch(function (e) { | 54 | }).catch(function (e) { | 
| 55 | console.error(e); | 55 | console.error(e); | 
| 56 | }); | 56 | }); | 
| 57 | }); | 57 | }); | 
| 58 | }; | 58 | }; | 
| 59 | $scope.selectListaDePrecios = function () { | 59 | $scope.selectListaDePrecios = function () { | 
| 60 | $scope.associatedList = true; | 60 | $scope.associatedList = true; | 
| 61 | }; | 61 | }; | 
| 62 | $scope.verListaProductos = function (id) { | 62 | $scope.verListaProductos = function (id) { | 
| 63 | $uibModal.open( | 63 | $uibModal.open( | 
| 64 | { | 64 | { | 
| 65 | ariaLabelledBy: 'Busqueda de Productos', | 65 | ariaLabelledBy: 'Busqueda de Productos', | 
| 66 | templateUrl: 'modal-busqueda-productos.html', | 66 | templateUrl: 'modal-busqueda-productos.html', | 
| 67 | controller: 'modalBusquedaProductosCtrl', | 67 | controller: 'modalBusquedaProductosCtrl', | 
| 68 | resolve: { | 68 | resolve: { | 
| 69 | parametroProducto: { | 69 | parametroProducto: { | 
| 70 | idLista: parseInt(id), | 70 | idLista: parseInt(id), | 
| 71 | cotizacion: 1, | 71 | cotizacion: 1, | 
| 72 | simbolo: '$', | 72 | simbolo: '$', | 
| 73 | soloMostrar: true | 73 | soloMostrar: true | 
| 74 | } | 74 | } | 
| 75 | }, | 75 | }, | 
| 76 | size: 'md' | 76 | size: 'md' | 
| 77 | } | 77 | } | 
| 78 | ); | 78 | ); | 
| 79 | }; | 79 | }; | 
| 80 | //#endregion | 80 | //#endregion | 
| 81 | $scope.closeModalPrecioCondicion = function () { | 81 | $scope.closeModalPrecioCondicion = function () { | 
| 82 | $uibModalInstance.dismiss('cancel'); | 82 | $uibModalInstance.dismiss('cancel'); | 
| 83 | }; | 83 | }; | 
| 84 | $scope.guardarPrecioCondicion = function () { | 84 | $scope.guardarPrecioCondicion = function () { | 
| 85 | var precioCondicion = { | 85 | var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); | 
| 86 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | 86 | |
| 87 | }; | 87 | focaModalPrecioCondicionService.actualizarLista(parametros.idCliente, mod).then(function (){ | 
| 88 | $uibModalInstance.close(precioCondicion); | 88 | var precioCondicion = { | 
| 89 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | ||
| 90 | }; | ||
| 91 | $uibModalInstance.close(precioCondicion); | ||
| 92 | }); | ||
| 89 | }; | 93 | }; | 
| 90 | } | 94 | } | 
| 91 | ]) | 95 | ]) | 
| 92 | 96 | ||
| 93 | .controller('focaModalListaPlazosController', | 97 | .controller('focaModalListaPlazosController', | 
| 94 | [ | 98 | [ | 
| 95 | '$timeout', | 99 | '$timeout', | 
| 96 | '$filter', | 100 | '$filter', | 
| 97 | '$scope', | 101 | '$scope', | 
| 98 | '$uibModal', | 102 | '$uibModal', | 
| 99 | '$uibModalInstance', | 103 | '$uibModalInstance', | 
| 100 | 'focaModalService', | 104 | 'focaModalService', | 
| 101 | 'focaModalPrecioCondicionService', | 105 | 'focaModalPrecioCondicionService', | 
| 102 | 'idCliente', | 106 | 'parametros', | 
| 103 | function ( | 107 | function ( | 
| 104 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 108 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 
| 105 | focaModalService, focaModalPrecioCondicionService,idCliente | 109 | focaModalService, focaModalPrecioCondicionService,parametros | 
| 106 | ) { | 110 | ) { | 
| 107 | $scope.plazos = [ | 111 | $scope.plazos = [ | 
| 108 | { | 112 | { | 
| 109 | dias: 0, | 113 | dias: 0, | 
| 110 | idCliente: idCliente, | 114 | idCliente: parametros.idCliente, | 
| 111 | activo: true | 115 | activo: true | 
| 112 | } | 116 | } | 
| 113 | ]; | 117 | ]; | 
| 114 | 118 | ||
| 115 | onInit(); | 119 | onInit(); | 
| 116 | 120 | ||
| 117 | function onInit() { | 121 | function onInit() { | 
| 118 | focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) | 122 | focaModalPrecioCondicionService.getPlazosByIdCliente(parametros.idCliente) | 
| 119 | .then(function (res) { | 123 | .then(function (res) { | 
| 120 | res.data.forEach(function (item) { | 124 | res.data.forEach(function (item) { | 
| 121 | $scope.plazos.push(item); | 125 | $scope.plazos.push(item); | 
| 122 | }); | 126 | }); | 
| 123 | }) | 127 | }) | 
| 124 | .catch(function (e) { console.error(e) }); | 128 | .catch(function (e) { console.error(e) }); | 
| 125 | } | 129 | } | 
| 126 | 130 | ||
| 127 | //#region Metodos para los plazos | 131 | //#region Metodos para los plazos | 
| 128 | $scope.addPlazo = function (key) { | 132 | $scope.addPlazo = function (key) { | 
| 129 | if (key != 13) return; | 133 | if (key != 13) return; | 
| 130 | if ($scope.plazos.length === 100) return; | 134 | if ($scope.plazos.length === 100) return; | 
| 131 | for (var i = 1; i < $scope.plazos.length; i++) { | 135 | for (var i = 1; i < $scope.plazos.length; i++) { | 
| 132 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { | 136 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { | 
| 133 | focaModalService.alert("Ya existe un plazo con este valor"); | 137 | focaModalService.alert("Ya existe un plazo con este valor"); | 
| 134 | return; | 138 | return; | 
| 135 | } | 139 | } | 
| 136 | } | 140 | } | 
| 137 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); | 141 | $scope.plazos.unshift({ dias: 0, idCliente: parametros.idCliente, activo: true }); | 
| 138 | $scope.focused = 1; | 142 | $scope.focused = 1; | 
| 139 | }; | 143 | }; | 
| 140 | $scope.deletePlazo = function (index) { | 144 | $scope.deletePlazo = function (index) { | 
| 141 | $scope.plazos[index].activo = false; | 145 | $scope.plazos[index].activo = false; | 
| 142 | }; | 146 | }; | 
| 143 | $scope.validateMinMax = function (plazo, min, max) { | 147 | $scope.validateMinMax = function (plazo, min, max) { | 
| 144 | plazo.dias = parseInt(plazo.dias); | 148 | plazo.dias = parseInt(plazo.dias); | 
| 145 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { | 149 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { | 
| 146 | plazo.dias = '0'; | 150 | plazo.dias = '0'; | 
| 147 | return; | 151 | return; | 
| 148 | } | 152 | } | 
| 149 | if (parseInt(plazo.dias) < min) { | 153 | if (parseInt(plazo.dias) < min) { | 
| 150 | plazo.dias = '0'; | 154 | plazo.dias = '0'; | 
| 151 | return; | 155 | return; | 
| 152 | } | 156 | } | 
| 153 | if (parseInt(plazo.dias) > max) { | 157 | if (parseInt(plazo.dias) > max) { | 
| 154 | plazo.dias = '365'; | 158 | plazo.dias = '365'; | 
| 155 | return; | 159 | return; | 
| 156 | } | 160 | } | 
| 157 | }; | 161 | }; | 
| 158 | //#endregion | 162 | //#endregion | 
| 159 | 163 | ||
| 160 | $scope.closeModalPrecioCondicion = function () { | 164 | $scope.closeModalPrecioCondicion = function () { | 
| 161 | $uibModalInstance.dismiss('cancel'); | 165 | $uibModalInstance.dismiss('cancel'); | 
| 162 | }; | 166 | }; | 
| 163 | $scope.guardarPlazos = function () { | 167 | $scope.guardarPlazos = function () { | 
| 164 | $scope.plazos.shift(); | 168 | $scope.plazos.shift(); | 
| 165 | focaModalPrecioCondicionService.createPlazo($scope.plazos) | 169 | focaModalPrecioCondicionService.createPlazo($scope.plazos) | 
| 166 | .then(function () { | 170 | .then(function () { | 
| 167 | var precioCondicion = { | 171 | var precioCondicion = { | 
| 168 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | 172 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | 
| 169 | }; | 173 | }; | 
| 170 | $uibModalInstance.close(precioCondicion); | 174 | $uibModalInstance.close(precioCondicion); | 
| 171 | }) | 175 | }) | 
| 172 | .catch(function (e) { console.error(e) }) | 176 | .catch(function (e) { console.error(e) }) | 
| 173 | }; | 177 | }; | 
| 174 | } | 178 | } | 
| 175 | ]); | 179 | ]); | 
| 176 | 180 | 
src/js/service.js
| 1 | angular.module('focaModalPrecioCondicion') | 1 | angular.module('focaModalPrecioCondicion') | 
| 2 | .service('focaModalPrecioCondicionService', [ | 2 | .service('focaModalPrecioCondicionService', [ | 
| 3 | '$http', | 3 | '$http', | 
| 4 | 'API_ENDPOINT', | 4 | 'API_ENDPOINT', | 
| 5 | function ($http, API_ENDPOINT) { | 5 | function ($http, API_ENDPOINT) { | 
| 6 | return { | 6 | return { | 
| 7 | getPlazosByIdPrecioCondicion: function (id) { | 7 | getPlazosByIdPrecioCondicion: function (id) { | 
| 8 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + id); | 8 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + id); | 
| 9 | }, | 9 | }, | 
| 10 | getPreciosCondiciones: function () { | 10 | getPreciosCondiciones: function () { | 
| 11 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago'); | 11 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago'); | 
| 12 | }, | 12 | }, | 
| 13 | getPreciosCondicionesByIdListaPrecio: function (idListaPrecio) { | 13 | getPreciosCondicionesByIdListaPrecio: function (idListaPrecio) { | 
| 14 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago/' + | 14 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago/' + | 
| 15 | idListaPrecio); | 15 | idListaPrecio); | 
| 16 | }, | 16 | }, | 
| 17 | getListaPrecio: function (idListaPrecio) { | 17 | getListaPrecio: function (idListaPrecio) { | 
| 18 | return $http.get(API_ENDPOINT.URL + '/lista-precio/' + | 18 | return $http.get(API_ENDPOINT.URL + '/lista-precio/' + | 
| 19 | idListaPrecio); | 19 | idListaPrecio); | 
| 20 | }, | 20 | }, | 
| 21 | getAllListaPrecio: function () { | 21 | getAllListaPrecio: function () { | 
| 22 | return $http.get(API_ENDPOINT.URL + '/lista-precio'); | 22 | return $http.get(API_ENDPOINT.URL + '/lista-precio'); | 
| 23 | }, | 23 | }, | 
| 24 | getPlazosByIdCliente: function (id) { | 24 | getPlazosByIdCliente: function (id) { | 
| 25 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/cliente/' + id); | 25 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/cliente/' + id); | 
| 26 | }, | 26 | }, | 
| 27 | createPlazo: function (plazosPago){ | 27 | createPlazo: function (plazosPago){ | 
| 28 | return $http.post(API_ENDPOINT.URL + '/plazos-pago', { plazosPago: plazosPago }); | 28 | return $http.post(API_ENDPOINT.URL + '/plazos-pago', { plazosPago: plazosPago }); | 
| 29 | }, | ||
| 30 | actualizarLista: function(id , mod) { | ||
| 31 | return $http.post(API_ENDPOINT.URL + '/cliente/update/mod', { id: id, mod: mod}); | ||
| 29 | } | 32 | } | 
| 30 | }; | 33 | }; | 
| 31 | } | 34 | } | 
| 32 | ]); | 35 | ]); | 
| 33 | 36 |