Commit 81eaebec12d433f85b3ced24685273335b979604
1 parent
50d198324a
Exists in
master
and in
1 other branch
refactor modal
Showing
2 changed files
with
99 additions
and
87 deletions
Show diff stats
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-busqueda-cliente", | 2 | "name": "foca-busqueda-cliente", |
| 3 | "version": "1.0.0", | 3 | "version": "1.0.0", |
| 4 | "description": "Búsqueda de clientes", | 4 | "description": "Búsqueda de clientes", |
| 5 | "main": "dist/foca-abm-sectores.js", | 5 | "main": "dist/foca-busqueda-cliente.min.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
| 9 | "postinstall": "npm run compile && gulp clean-post-install", | 9 | "postinstall": "npm run compile && gulp clean-post-install", |
| 10 | "install-dev": "npm install -D angular bootstrap angular-ladda ladda@1.0.6 angular-ui-bootstrap ui-bootstrap4 font-awesome jquery pre-commit jshint pump jasmine-core gulp gulp-connect gulp-angular-templatecache gulp-concat gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean gulp-uglify git+http://git.focasoftware.com/npm/foca-directivas.git" | 10 | "install-dev": "npm install -D angular bootstrap angular-ladda ladda@1.0.6 angular-ui-bootstrap ui-bootstrap4 font-awesome jquery pre-commit jshint pump jasmine-core gulp gulp-connect gulp-angular-templatecache gulp-concat gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean gulp-uglify git+http://git.focasoftware.com/npm/foca-directivas.git" |
| 11 | }, | 11 | }, |
| 12 | "repository": { | 12 | "repository": { |
| 13 | "type": "git", | 13 | "type": "git", |
| 14 | "url": "http://git.focasoftware.com/npm/foca-busqueda-cliente.git" | 14 | "url": "http://git.focasoftware.com/npm/foca-busqueda-cliente.git" |
| 15 | }, | 15 | }, |
| 16 | "author": "Foca Software", | 16 | "author": "Foca Software", |
| 17 | "license": "ISC", | 17 | "license": "ISC", |
| 18 | "peerDependencies": { | 18 | "peerDependencies": { |
| 19 | "angular": "^1.7.x", | 19 | "angular": "^1.7.x", |
| 20 | "bootstrap": "^4.1.x", | 20 | "bootstrap": "^4.1.x", |
| 21 | "jquery": "^3.3.x", | 21 | "jquery": "^3.3.x", |
| 22 | "font-awesome": "^4.7.x", | 22 | "font-awesome": "^4.7.x", |
| 23 | "gulp": "^3.9.x", | 23 | "gulp": "^3.9.x", |
| 24 | "gulp-concat": "2.6.x", | 24 | "gulp-concat": "2.6.x", |
| 25 | "gulp-jshint": "^2.1.x", | 25 | "gulp-jshint": "^2.1.x", |
| 26 | "gulp-rename": "^1.4.x", | 26 | "gulp-rename": "^1.4.x", |
| 27 | "gulp-replace": "^1.0.x", | 27 | "gulp-replace": "^1.0.x", |
| 28 | "gulp-uglify-es": "^1.0.x", | 28 | "gulp-uglify-es": "^1.0.x", |
| 29 | "jshint": "^2.9.x", | 29 | "jshint": "^2.9.x", |
| 30 | "pump": "^3.0.x" | 30 | "pump": "^3.0.x" |
| 31 | }, | 31 | }, |
| 32 | "devDependencies": { | 32 | "devDependencies": { |
| 33 | "angular": "^1.7.4", | 33 | "angular": "^1.7.6", |
| 34 | "angular-ladda": "^0.4.3", | 34 | "angular-ladda": "^0.4.3", |
| 35 | "angular-ui-bootstrap": "^2.5.6", | 35 | "angular-ui-bootstrap": "^2.5.6", |
| 36 | "bootstrap": "^4.1.3", | 36 | "bootstrap": "^4.2.1", |
| 37 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 37 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 38 | "font-awesome": "^4.7.0", | 38 | "font-awesome": "^4.7.0", |
| 39 | "gulp": "^3.9.1", | 39 | "gulp": "^3.9.1", |
| 40 | "gulp-angular-templatecache": "^2.2.1", | 40 | "gulp-angular-templatecache": "^2.2.6", |
| 41 | "gulp-clean": "^0.4.0", | 41 | "gulp-clean": "^0.4.0", |
| 42 | "gulp-concat": "^2.6.1", | 42 | "gulp-concat": "^2.6.1", |
| 43 | "gulp-connect": "^5.6.1", | 43 | "gulp-connect": "^5.7.0", |
| 44 | "gulp-htmlmin": "^5.0.1", | 44 | "gulp-htmlmin": "^5.0.1", |
| 45 | "gulp-jshint": "^2.1.0", | 45 | "gulp-jshint": "^2.1.0", |
| 46 | "gulp-rename": "^1.4.0", | 46 | "gulp-rename": "^1.4.0", |
| 47 | "gulp-replace": "^1.0.0", | 47 | "gulp-replace": "^1.0.0", |
| 48 | "gulp-uglify": "^3.0.1", | 48 | "gulp-uglify": "^3.0.1", |
| 49 | "gulp-uglify-es": "^1.0.4", | 49 | "gulp-uglify-es": "^1.0.4", |
| 50 | "jasmine-core": "^3.2.1", | 50 | "jasmine-core": "^3.3.0", |
| 51 | "jquery": "^3.3.1", | 51 | "jquery": "^3.3.1", |
| 52 | "jshint": "^2.9.6", | 52 | "jshint": "^2.9.7", |
| 53 | "ladda": "1.0.6", | 53 | "ladda": "^1.0.6", |
| 54 | "pre-commit": "^1.2.2", | 54 | "pre-commit": "^1.2.2", |
| 55 | "pump": "^3.0.0", | 55 | "pump": "^3.0.0", |
| 56 | "ui-bootstrap4": "^3.0.5" | 56 | "ui-bootstrap4": "^3.0.6" |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 |
src/js/controller.js
| 1 | angular.module('focaBusquedaCliente') | 1 | angular.module('focaBusquedaCliente') |
| 2 | .controller('focaBusquedaClienteModalController', [ | 2 | .controller('focaBusquedaClienteModalController', [ |
| 3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', | 3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', |
| 4 | '$uibModal', 'focaModalService', '$timeout', 'vendedor', | 4 | '$uibModal', 'focaModalService', '$timeout', 'vendedor', |
| 5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | 5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, |
| 6 | $uibModal, focaModalService, $timeout, vendedor) { | 6 | $uibModal, focaModalService, $timeout, vendedor) { |
| 7 | 7 | ||
| 8 | $scope.vendedor = vendedor ? vendedor : {}; | 8 | $scope.vendedor = vendedor ? vendedor : {}; |
| 9 | $scope.filters = ''; | 9 | $scope.filters = ''; |
| 10 | $scope.primerBusqueda = false; | 10 | $scope.primerBusqueda = false; |
| 11 | // pagination | 11 | // pagination |
| 12 | $scope.numPerPage = 10; | 12 | $scope.numPerPage = 10; |
| 13 | $scope.currentPage = 1; | 13 | $scope.currentPage = 1; |
| 14 | $scope.filteredClientes = []; | 14 | $scope.filteredClientes = []; |
| 15 | $scope.currentPageClientes = []; | 15 | $scope.currentPageClientes = []; |
| 16 | $scope.selectedClientes = -1; | 16 | $scope.selectedClientes = -1; |
| 17 | $scope.ingreso = false; | 17 | $scope.ingreso = false; |
| 18 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); | 18 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); |
| 19 | $scope.focused = 1; | 19 | $scope.focused = 1; |
| 20 | 20 | ||
| 21 | $scope.cliente = { | 21 | $scope.cliente = { |
| 22 | COD: 0, | 22 | COD: 0, |
| 23 | ES_MAY: true, | 23 | ES_MAY: true, |
| 24 | provincia: { | 24 | provincia: { |
| 25 | NOMBRE: '' | 25 | NOMBRE: '' |
| 26 | }, | 26 | }, |
| 27 | localidad: { | 27 | localidad: { |
| 28 | NOMBRE: '' | 28 | NOMBRE: '' |
| 29 | }, | 29 | }, |
| 30 | iva: { | 30 | iva: { |
| 31 | NOMBRE: '' | 31 | NOMBRE: '' |
| 32 | }, | 32 | }, |
| 33 | actividad: { | 33 | actividad: { |
| 34 | NOM: '' | 34 | NOM: '' |
| 35 | }, | 35 | }, |
| 36 | zona: { | 36 | zona: { |
| 37 | NOM: '' | 37 | NOM: '' |
| 38 | }, | 38 | }, |
| 39 | tipoFactura: { | 39 | tipoFactura: { |
| 40 | NOMBRE: '' | 40 | NOMBRE: '' |
| 41 | }, | 41 | }, |
| 42 | tipoComprobante: { | 42 | tipoComprobante: { |
| 43 | NOMBRE: '' | 43 | NOMBRE: '' |
| 44 | }, | 44 | }, |
| 45 | formaPago: { | 45 | formaPago: { |
| 46 | NOMBRE: '' | 46 | NOMBRE: '' |
| 47 | }, | 47 | }, |
| 48 | cobrador: { | 48 | cobrador: { |
| 49 | NomVen: '' | 49 | NomVen: '' |
| 50 | } | 50 | } |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | $scope.busquedaPress = function(key) { | 53 | $scope.busquedaPress = function(key) { |
| 54 | if (key === 13) { | 54 | if (key === 13) { |
| 55 | var funcion = ($scope.vendedor.CodVen) ? | 55 | var funcion = ($scope.vendedor.CodVen) ? |
| 56 | 'obtenerClientesPorNombreOCuitByVendedor' : 'obtenerClientesPorNombreOCuit'; | 56 | 'obtenerClientesPorNombreOCuitByVendedor' : 'obtenerClientesPorNombreOCuit'; |
| 57 | 57 | ||
| 58 | $scope.searchLoading = true; | 58 | $scope.searchLoading = true; |
| 59 | focaBusquedaClienteService | 59 | focaBusquedaClienteService |
| 60 | [funcion]($scope.filters, $scope.vendedor.CodVen) | 60 | [funcion]($scope.filters, $scope.vendedor.CodVen) |
| 61 | .then( | 61 | .then( |
| 62 | function(res) { | 62 | function(res) { |
| 63 | $scope.primerBusqueda = true; | 63 | $scope.primerBusqueda = true; |
| 64 | $scope.clientes = res.data; | 64 | $scope.clientes = res.data; |
| 65 | $scope.search(true); | 65 | $scope.search(true); |
| 66 | primera(); | 66 | primera(); |
| 67 | $scope.searchLoading = false; | 67 | $scope.searchLoading = false; |
| 68 | }); | 68 | }); |
| 69 | } | 69 | } |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | $scope.search = function (pressed) { | 72 | $scope.search = function (pressed) { |
| 73 | if($scope.primerBusqueda) { | 73 | if($scope.primerBusqueda) { |
| 74 | $scope.filteredClientes = $filter('filter')( | 74 | $scope.filteredClientes = $filter('filter')( |
| 75 | $scope.clientes, {$: $scope.filters} | 75 | $scope.clientes, {$: $scope.filters} |
| 76 | ); | 76 | ); |
| 77 | 77 | ||
| 78 | if(pressed && $scope.filteredClientes.length === 0){ | 78 | if(pressed && $scope.filteredClientes.length === 0){ |
| 79 | $timeout(function() { | 79 | $timeout(function() { |
| 80 | angular.element('#search')[0].focus(); | 80 | angular.element('#search')[0].focus(); |
| 81 | $scope.filters = ''; | 81 | $scope.filters = ''; |
| 82 | }); | 82 | }); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | $scope.lastPage = Math.ceil( | 85 | $scope.lastPage = Math.ceil( |
| 86 | $scope.filteredClientes.length / $scope.numPerPage | 86 | $scope.filteredClientes.length / $scope.numPerPage |
| 87 | ); | 87 | ); |
| 88 | 88 | ||
| 89 | $scope.resetPage(); | 89 | $scope.resetPage(); |
| 90 | } | 90 | } |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | $scope.resetPage = function () { | 93 | $scope.resetPage = function () { |
| 94 | $scope.currentPage = 1; | 94 | $scope.currentPage = 1; |
| 95 | $scope.selectPage(1); | 95 | $scope.selectPage(1); |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | $scope.selectPage = function (page) { | 98 | $scope.selectPage = function (page) { |
| 99 | var start = (page - 1) * $scope.numPerPage; | 99 | var start = (page - 1) * $scope.numPerPage; |
| 100 | var end = start + $scope.numPerPage; | 100 | var end = start + $scope.numPerPage; |
| 101 | $scope.paginas = []; | 101 | $scope.paginas = []; |
| 102 | $scope.paginas = calcularPages(page); | 102 | $scope.paginas = calcularPages(page); |
| 103 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); | 103 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); |
| 104 | $scope.currentPage = page; | 104 | $scope.currentPage = page; |
| 105 | }; | 105 | }; |
| 106 | 106 | ||
| 107 | $scope.select = function(cliente, esNuevo = false) { | 107 | $scope.select = function(cliente, esNuevo = false) { |
| 108 | cliente.esNuevo = esNuevo; | 108 | cliente.esNuevo = esNuevo; |
| 109 | $uibModalInstance.close(cliente); | 109 | $uibModalInstance.close(cliente); |
| 110 | }; | 110 | }; |
| 111 | 111 | ||
| 112 | $scope.cancel = function() { | 112 | $scope.cancel = function() { |
| 113 | if($scope.ingreso) { | 113 | if($scope.ingreso) { |
| 114 | $scope.ingreso = false; | 114 | $scope.ingreso = false; |
| 115 | }else { | 115 | }else { |
| 116 | $uibModalInstance.dismiss('cancel'); | 116 | $uibModalInstance.dismiss('cancel'); |
| 117 | } | 117 | } |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | $scope.busquedaDown = function(key) { | 120 | $scope.busquedaDown = function(key) { |
| 121 | if (key === 40) { | 121 | if (key === 40) { |
| 122 | primera(key); | 122 | primera(key); |
| 123 | } | 123 | } |
| 124 | }; | 124 | }; |
| 125 | 125 | ||
| 126 | $scope.itemCliente = function(key) { | 126 | $scope.itemCliente = function(key) { |
| 127 | if (key === 38) { | 127 | if (key === 38) { |
| 128 | anterior(key); | 128 | anterior(key); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | if (key === 40) { | 131 | if (key === 40) { |
| 132 | siguiente(key); | 132 | siguiente(key); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | if (key === 37) { | 135 | if (key === 37) { |
| 136 | retrocederPagina(); | 136 | retrocederPagina(); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | if (key === 39) { | 139 | if (key === 39) { |
| 140 | avanzarPagina(); | 140 | avanzarPagina(); |
| 141 | } | 141 | } |
| 142 | }; | 142 | }; |
| 143 | 143 | ||
| 144 | $scope.focus = function(val) { | 144 | $scope.focus = function(val) { |
| 145 | $scope.focused = val; | 145 | $scope.focused = val; |
| 146 | }; | 146 | }; |
| 147 | 147 | ||
| 148 | $scope.next = function(key) { | 148 | $scope.next = function(key) { |
| 149 | if (key === 13) $scope.focused++; | 149 | if (key === 13) $scope.focused++; |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | $scope.seleccionarProvincia = function(key) { | 152 | $scope.seleccionarProvincia = function(key) { |
| 153 | if(key === 13) { | 153 | if(key === 13) { |
| 154 | var modalInstance = $uibModal.open( | 154 | var parametrosModal = { |
| 155 | { | 155 | query: '/provincia', |
| 156 | ariaLabelledBy: 'Búsqueda de provincias', | 156 | columnas: { |
| 157 | templateUrl: 'modal-provincias.html', | 157 | nombre: ['Código', 'Nombre'], |
| 158 | controller: 'focaModalProvinciaController', | 158 | propiedad: ['ID', 'NOMBRE'] |
| 159 | size: 'md', | 159 | }, |
| 160 | resolve: { | 160 | titulo:'Búsqueda de provincias', |
| 161 | filters: function() { | 161 | size: 'md' |
| 162 | return $scope.cliente.provincia.NOMBRE; | 162 | } |
| 163 | } | 163 | focaModalService.modal(parametrosModal).then(function(provincia) { |
| 164 | } | ||
| 165 | } | ||
| 166 | ); | ||
| 167 | modalInstance.result.then(function(provincia) { | ||
| 168 | $scope.cliente.provincia = provincia; | 164 | $scope.cliente.provincia = provincia; |
| 169 | $timeout(function() { | 165 | $timeout(function() { |
| 170 | $scope.focused = 5; | 166 | $scope.focused = 5; |
| 171 | }); | 167 | }); |
| 172 | }, function() { | 168 | }, function() { |
| 173 | //TODO: función llamada cuando cancela el modal | 169 | //TODO: función llamada cuando cancela el modal |
| 174 | }); | 170 | }); |
| 175 | } | 171 | } |
| 176 | }; | 172 | }; |
| 177 | $scope.seleccionarLocalidad = function(key) { | 173 | $scope.seleccionarLocalidad = function(key) { |
| 178 | if($scope.cliente.provincia.ID === undefined) { | 174 | if($scope.cliente.provincia.ID === undefined) { |
| 179 | focaModalService.alert('Seleccione una provincia'); | 175 | focaModalService.alert('Seleccione una provincia'); |
| 180 | return; | 176 | return; |
| 181 | } | 177 | } |
| 182 | if(key === 13) { | 178 | if(key === 13) { |
| 183 | var modalInstance = $uibModal.open( | 179 | var parametrosModal = { |
| 184 | { | 180 | query: '/localidad/' + $scope.cliente.provincia.ID, |
| 185 | ariaLabelledBy: 'Búsqueda de localidades', | 181 | columnas: { |
| 186 | templateUrl: 'modal-localidades.html', | 182 | nombre: ['Código', 'Nombre'], |
| 187 | controller: 'focaModalLocalidadController', | 183 | propiedad: ['ID', 'NOMBRE'] |
| 188 | size: 'md', | 184 | }, |
| 189 | resolve: { | 185 | titulo:'Búsqueda de localidades', |
| 190 | filters: { | 186 | size: 'md' |
| 191 | idProvincia: $scope.cliente.provincia.ID, | 187 | } |
| 192 | busqueda: $scope.cliente.localidad.nombre | 188 | focaModalService.modal(parametrosModal).then(function(localidad) { |
| 193 | } | ||
| 194 | } | ||
| 195 | } | ||
| 196 | ); | ||
| 197 | modalInstance.result.then(function(localidad) { | ||
| 198 | $scope.cliente.localidad = localidad; | 189 | $scope.cliente.localidad = localidad; |
| 199 | $timeout(function() { | 190 | $timeout(function() { |
| 200 | $scope.focused = 6; | 191 | $scope.focused = 6; |
| 201 | }); | 192 | }); |
| 202 | }, function() { | 193 | }, function() { |
| 203 | //TODO: función llamada cuando cancela el modal | 194 | //TODO: función llamada cuando cancela el modal |
| 204 | }); | 195 | }); |
| 205 | } | 196 | } |
| 206 | }; | 197 | }; |
| 207 | $scope.seleccionarIva = function(key) { | 198 | $scope.seleccionarIva = function(key) { |
| 208 | if(key === 13) { | 199 | if(key === 13) { |
| 209 | var query = '/iva'; | 200 | var parametrosModal = { |
| 210 | var columnas = { | 201 | query: '/iva', |
| 211 | nombre: ['Código', 'Nombre'], | 202 | columnas: { |
| 212 | propiedad: ['ID', 'NOMBRE',] | 203 | nombre: ['Código', 'Nombre'], |
| 213 | }; | 204 | propiedad: ['ID', 'NOMBRE',] |
| 214 | var titulo = 'Búsqueda de responsabilidad ante el IVA'; | 205 | }, |
| 215 | focaModalService.modal(columnas, query, titulo, 'md').then( | 206 | titulo:'Búsqueda de responsabilidad ante el IVA', |
| 207 | size: 'md' | ||
| 208 | } | ||
| 209 | focaModalService.modal(parametrosModal).then( | ||
| 216 | function(iva) { | 210 | function(iva) { |
| 217 | $scope.cliente.iva = iva; | 211 | $scope.cliente.iva = iva; |
| 218 | $timeout(function() { | 212 | $timeout(function() { |
| 219 | $scope.focused = 10; | 213 | $scope.focused = 10; |
| 220 | }); | 214 | }); |
| 221 | }, function() { | 215 | }, function() { |
| 222 | // funcion ejecutada cuando se cancela el modal | 216 | // funcion ejecutada cuando se cancela el modal |
| 223 | }); | 217 | }); |
| 224 | } | 218 | } |
| 225 | }; | 219 | }; |
| 226 | $scope.seleccionarActividad = function(key) { | 220 | $scope.seleccionarActividad = function(key) { |
| 227 | if(key === 13) { | 221 | if(key === 13) { |
| 228 | var query = '/actividad'; | 222 | var parametrosModal = { |
| 229 | var columnas = { | 223 | query: '/actividad', |
| 230 | nombre: ['Código', 'Nombre'], | 224 | columnas: { |
| 231 | propiedad: ['ID', 'NOM',] | 225 | nombre: ['Código', 'Nombre'], |
| 232 | }; | 226 | propiedad: ['ID', 'NOM',] |
| 233 | var titulo = 'Búsqueda de actividades'; | 227 | }, |
| 234 | focaModalService.modal(columnas, query, titulo, 'md').then( | 228 | titulo: 'Búsqueda de actividades', |
| 229 | size: 'md' | ||
| 230 | } | ||
| 231 | focaModalService.modal(parametrosModal).then( | ||
| 235 | function(actividad) { | 232 | function(actividad) { |
| 236 | $scope.cliente.actividad = actividad; | 233 | $scope.cliente.actividad = actividad; |
| 237 | $timeout(function() { | 234 | $timeout(function() { |
| 238 | $scope.focused = 8; | 235 | $scope.focused = 8; |
| 239 | }); | 236 | }); |
| 240 | }, function() { | 237 | }, function() { |
| 241 | // funcion ejecutada cuando se cancela el modal | 238 | // funcion ejecutada cuando se cancela el modal |
| 242 | }); | 239 | }); |
| 243 | } | 240 | } |
| 244 | }; | 241 | }; |
| 245 | $scope.seleccionarZona = function(key) { | 242 | $scope.seleccionarZona = function(key) { |
| 246 | if(key === 13) { | 243 | if(key === 13) { |
| 247 | var query = '/zona'; | 244 | var parametrosModal = { |
| 248 | var columnas = { | 245 | query: '/zona', |
| 249 | nombre: ['Código', 'Nombre'], | 246 | columnas: { |
| 250 | propiedad: ['ID', 'NOM',] | 247 | nombre: ['Código', 'Nombre'], |
| 251 | }; | 248 | propiedad: ['ID', 'NOM',] |
| 252 | var titulo = 'Búsqueda de zonas'; | 249 | }, |
| 253 | focaModalService.modal(columnas, query, titulo, 'md').then( | 250 | titulo: 'Búsqueda de zonas', |
| 251 | size: 'md' | ||
| 252 | } | ||
| 253 | focaModalService.modal(parametrosModal).then( | ||
| 254 | function(zona) { | 254 | function(zona) { |
| 255 | $scope.cliente.zona = zona; | 255 | $scope.cliente.zona = zona; |
| 256 | $timeout(function() { | 256 | $timeout(function() { |
| 257 | $scope.focused = 7; | 257 | $scope.focused = 7; |
| 258 | }); | 258 | }); |
| 259 | }, function() { | 259 | }, function() { |
| 260 | // funcion ejecutada cuando se cancela el modal | 260 | // funcion ejecutada cuando se cancela el modal |
| 261 | }); | 261 | }); |
| 262 | } | 262 | } |
| 263 | }; | 263 | }; |
| 264 | $scope.seleccionarTipoFactura = function(key) { | 264 | $scope.seleccionarTipoFactura = function(key) { |
| 265 | if(key === 13) { | 265 | if(key === 13) { |
| 266 | var query = '/tipo-factura'; | 266 | var parametrosModal = { |
| 267 | var columnas = { | 267 | query: '/tipo-factura', |
| 268 | nombre: ['Código', 'Nombre'], | 268 | columnas: { |
| 269 | propiedad: ['ID', 'NOMBRE',] | 269 | nombre: ['Código', 'Nombre'], |
| 270 | }; | 270 | propiedad: ['ID', 'NOMBRE',] |
| 271 | var titulo = 'Búsqueda de tipos de factura'; | 271 | }, |
| 272 | focaModalService.modal(columnas, query, titulo, 'md').then( | 272 | titulo: 'Búsqueda de tipos de factura', |
| 273 | size: 'md' | ||
| 274 | } | ||
| 275 | focaModalService.modal(parametrosModal).then( | ||
| 273 | function(tipoFactura) { | 276 | function(tipoFactura) { |
| 274 | $scope.cliente.tipoFactura = tipoFactura; | 277 | $scope.cliente.tipoFactura = tipoFactura; |
| 275 | $timeout(function() { | 278 | $timeout(function() { |
| 276 | $scope.focused = 11; | 279 | $scope.focused = 11; |
| 277 | }); | 280 | }); |
| 278 | }, function() { | 281 | }, function() { |
| 279 | // funcion ejecutada cuando se cancela el modal | 282 | // funcion ejecutada cuando se cancela el modal |
| 280 | }); | 283 | }); |
| 281 | } | 284 | } |
| 282 | }; | 285 | }; |
| 283 | $scope.seleccionarTipoComprobante = function(key) { | 286 | $scope.seleccionarTipoComprobante = function(key) { |
| 284 | if(key === 13) { | 287 | if(key === 13) { |
| 285 | var query = '/tipo-comprobante'; | 288 | var parametrosModal = { |
| 286 | var columnas = { | 289 | query: '/tipo-comprobante', |
| 287 | nombre: ['Código', 'Nombre'], | 290 | columnas: { |
| 288 | propiedad: ['ID', 'NOMBRE',] | 291 | nombre: ['Código', 'Nombre'], |
| 289 | }; | 292 | propiedad: ['ID', 'NOMBRE',] |
| 290 | var titulo = 'Búsqueda de tipos de comprobante'; | 293 | }, |
| 291 | focaModalService.modal(columnas, query, titulo, 'md').then( | 294 | titulo: 'Búsqueda de tipos de comprobante', |
| 295 | size: 'md' | ||
| 296 | } | ||
| 297 | focaModalService.modal(parametrosModal).then( | ||
| 292 | function(tipoComprobante) { | 298 | function(tipoComprobante) { |
| 293 | $scope.cliente.tipoComprobante = tipoComprobante; | 299 | $scope.cliente.tipoComprobante = tipoComprobante; |
| 294 | $timeout(function() { | 300 | $timeout(function() { |
| 295 | $scope.focused = 13; | 301 | $scope.focused = 13; |
| 296 | }); | 302 | }); |
| 297 | }, function() { | 303 | }, function() { |
| 298 | // funcion ejecutada cuando se cancela el modal | 304 | // funcion ejecutada cuando se cancela el modal |
| 299 | }); | 305 | }); |
| 300 | } | 306 | } |
| 301 | }; | 307 | }; |
| 302 | $scope.seleccionarFormaPago = function(key) { | 308 | $scope.seleccionarFormaPago = function(key) { |
| 303 | if(key === 13) { | 309 | if(key === 13) { |
| 304 | var query = '/forma-pago'; | 310 | var parametrosModal = { |
| 305 | var columnas = { | 311 | query: '/forma-pago', |
| 306 | nombre: ['Código', 'Nombre'], | 312 | columnas: { |
| 307 | propiedad: ['ID', 'NOMBRE',] | 313 | nombre: ['Código', 'Nombre'], |
| 308 | }; | 314 | propiedad: ['ID', 'NOMBRE',] |
| 309 | var titulo = 'Búsqueda de formas de pago'; | 315 | }, |
| 310 | focaModalService.modal(columnas, query, titulo, 'md').then( | 316 | titulo: 'Búsqueda de formas de pago', |
| 317 | size: 'md' | ||
| 318 | } | ||
| 319 | focaModalService.modal(parametrosModal).then( | ||
| 311 | function(formaPago) { | 320 | function(formaPago) { |
| 312 | $scope.cliente.formaPago = formaPago; | 321 | $scope.cliente.formaPago = formaPago; |
| 313 | }, function() { | 322 | }, function() { |
| 314 | // funcion ejecutada cuando se cancela el modal | 323 | // funcion ejecutada cuando se cancela el modal |
| 315 | }); | 324 | }); |
| 316 | } | 325 | } |
| 317 | }; | 326 | }; |
| 318 | $scope.seleccionarCobrador = function(key) { | 327 | $scope.seleccionarCobrador = function(key) { |
| 319 | if(key === 13) { | 328 | if(key === 13) { |
| 320 | var query = '/cobrador'; | 329 | var parametrosModal = { |
| 321 | var columnas = { | 330 | query: '/cobrador', |
| 322 | nombre: ['Código', 'Nombre'], | 331 | columnas: { |
| 323 | propiedad: ['CodVen', 'NomVen',] | 332 | nombre: ['Código', 'Nombre'], |
| 324 | }; | 333 | propiedad: ['CodVen', 'NomVen',] |
| 325 | var titulo = 'Búsqueda de cobradores'; | 334 | }, |
| 326 | focaModalService.modal(columnas, query, titulo, 'md').then( | 335 | titulo: 'Búsqueda de cobradores', |
| 336 | size: 'md' | ||
| 337 | } | ||
| 338 | focaModalService.modal(parametrosModal).then( | ||
| 327 | function(cobrador) { | 339 | function(cobrador) { |
| 328 | $scope.cliente.cobrador = cobrador; | 340 | $scope.cliente.cobrador = cobrador; |
| 329 | }, function() { | 341 | }, function() { |
| 330 | // funcion ejecutada cuando se cancela el modal | 342 | // funcion ejecutada cuando se cancela el modal |
| 331 | }); | 343 | }); |
| 332 | } | 344 | } |
| 333 | }; | 345 | }; |
| 334 | 346 | ||
| 335 | $scope.guardar = function() { | 347 | $scope.guardar = function() { |
| 336 | 348 | ||
| 337 | $scope.cliente.PCX = $scope.cliente.provincia.ID; | 349 | $scope.cliente.PCX = $scope.cliente.provincia.ID; |
| 338 | $scope.cliente.LOX = $scope.cliente.localidad.ID; | 350 | $scope.cliente.LOX = $scope.cliente.localidad.ID; |
| 339 | $scope.cliente.IVA = $scope.cliente.iva.ID; | 351 | $scope.cliente.IVA = $scope.cliente.iva.ID; |
| 340 | $scope.cliente.ACT = $scope.cliente.actividad.ID; | 352 | $scope.cliente.ACT = $scope.cliente.actividad.ID; |
| 341 | $scope.cliente.ZON = $scope.cliente.zona.ID; | 353 | $scope.cliente.ZON = $scope.cliente.zona.ID; |
| 342 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; | 354 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; |
| 343 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; | 355 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; |
| 344 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; | 356 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; |
| 345 | $scope.cliente.VEN = $scope.vendedor.CodVen; | 357 | $scope.cliente.VEN = $scope.vendedor.CodVen; |
| 346 | $scope.cliente.idCobrador = $scope.cliente.cobrador.CodVen; | 358 | $scope.cliente.idCobrador = $scope.cliente.cobrador.CodVen; |
| 347 | 359 | ||
| 348 | delete $scope.cliente.provincia; | 360 | delete $scope.cliente.provincia; |
| 349 | delete $scope.cliente.localidad; | 361 | delete $scope.cliente.localidad; |
| 350 | delete $scope.cliente.iva; | 362 | delete $scope.cliente.iva; |
| 351 | delete $scope.cliente.actividad; | 363 | delete $scope.cliente.actividad; |
| 352 | delete $scope.cliente.zona; | 364 | delete $scope.cliente.zona; |
| 353 | delete $scope.cliente.tipoFactura; | 365 | delete $scope.cliente.tipoFactura; |
| 354 | delete $scope.cliente.tipoComprobante; | 366 | delete $scope.cliente.tipoComprobante; |
| 355 | delete $scope.cliente.formaPago; | 367 | delete $scope.cliente.formaPago; |
| 356 | delete $scope.cliente.cobrador; | 368 | delete $scope.cliente.cobrador; |
| 357 | 369 | ||
| 358 | focaBusquedaClienteService | 370 | focaBusquedaClienteService |
| 359 | .guardarCliente($scope.cliente) | 371 | .guardarCliente($scope.cliente) |
| 360 | .then(function(res) { | 372 | .then(function(res) { |
| 361 | var cliente = { | 373 | var cliente = { |
| 362 | cod: res.data.COD, | 374 | cod: res.data.COD, |
| 363 | cuit: res.data.CUIT, | 375 | cuit: res.data.CUIT, |
| 364 | esNuevo: res.data.esNuevo, | 376 | esNuevo: res.data.esNuevo, |
| 365 | nom: res.data.NOM | 377 | nom: res.data.NOM |
| 366 | }; | 378 | }; |
| 367 | $scope.select(cliente, true); | 379 | $scope.select(cliente, true); |
| 368 | }); | 380 | }); |
| 369 | }; | 381 | }; |
| 370 | 382 | ||
| 371 | function calcularPages(paginaActual) { | 383 | function calcularPages(paginaActual) { |
| 372 | var paginas = []; | 384 | var paginas = []; |
| 373 | paginas.push(paginaActual); | 385 | paginas.push(paginaActual); |
| 374 | 386 | ||
| 375 | if (paginaActual - 1 > 1) { | 387 | if (paginaActual - 1 > 1) { |
| 376 | 388 | ||
| 377 | paginas.unshift(paginaActual - 1); | 389 | paginas.unshift(paginaActual - 1); |
| 378 | if (paginaActual - 2 > 1) { | 390 | if (paginaActual - 2 > 1) { |
| 379 | paginas.unshift(paginaActual - 2); | 391 | paginas.unshift(paginaActual - 2); |
| 380 | } | 392 | } |
| 381 | } | 393 | } |
| 382 | 394 | ||
| 383 | if (paginaActual + 1 < $scope.lastPage) { | 395 | if (paginaActual + 1 < $scope.lastPage) { |
| 384 | paginas.push(paginaActual + 1); | 396 | paginas.push(paginaActual + 1); |
| 385 | if (paginaActual + 2 < $scope.lastPage) { | 397 | if (paginaActual + 2 < $scope.lastPage) { |
| 386 | paginas.push(paginaActual + 2); | 398 | paginas.push(paginaActual + 2); |
| 387 | } | 399 | } |
| 388 | } | 400 | } |
| 389 | 401 | ||
| 390 | if (paginaActual !== 1) { | 402 | if (paginaActual !== 1) { |
| 391 | paginas.unshift(1); | 403 | paginas.unshift(1); |
| 392 | } | 404 | } |
| 393 | 405 | ||
| 394 | if (paginaActual !== $scope.lastPage) { | 406 | if (paginaActual !== $scope.lastPage) { |
| 395 | paginas.push($scope.lastPage); | 407 | paginas.push($scope.lastPage); |
| 396 | } | 408 | } |
| 397 | 409 | ||
| 398 | return paginas; | 410 | return paginas; |
| 399 | } | 411 | } |
| 400 | 412 | ||
| 401 | function primera() { | 413 | function primera() { |
| 402 | $scope.selectedClientes = 0; | 414 | $scope.selectedClientes = 0; |
| 403 | } | 415 | } |
| 404 | 416 | ||
| 405 | function anterior() { | 417 | function anterior() { |
| 406 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { | 418 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { |
| 407 | retrocederPagina(); | 419 | retrocederPagina(); |
| 408 | } else { | 420 | } else { |
| 409 | $scope.selectedClientes--; | 421 | $scope.selectedClientes--; |
| 410 | } | 422 | } |
| 411 | } | 423 | } |
| 412 | 424 | ||
| 413 | function siguiente() { | 425 | function siguiente() { |
| 414 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { | 426 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { |
| 415 | $scope.selectedClientes++; | 427 | $scope.selectedClientes++; |
| 416 | } else { | 428 | } else { |
| 417 | avanzarPagina(); | 429 | avanzarPagina(); |
| 418 | } | 430 | } |
| 419 | } | 431 | } |
| 420 | 432 | ||
| 421 | function retrocederPagina() { | 433 | function retrocederPagina() { |
| 422 | if ($scope.currentPage > 1) { | 434 | if ($scope.currentPage > 1) { |
| 423 | $scope.selectPage($scope.currentPage - 1); | 435 | $scope.selectPage($scope.currentPage - 1); |
| 424 | $scope.selectedClientes = $scope.numPerPage - 1; | 436 | $scope.selectedClientes = $scope.numPerPage - 1; |
| 425 | } | 437 | } |
| 426 | } | 438 | } |
| 427 | 439 |