Commit e8c0136f61cf758bf209448ef3674c254e2c12ec
1 parent
c2b00fff1b
Exists in
master
and in
1 other branch
si le paso vendedor filtra, sino trae todos los clientes
Showing
2 changed files
with
11 additions
and
4 deletions
Show diff stats
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; | 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 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | $scope.busquedaPress = function(key) { | 50 | $scope.busquedaPress = function(key) { |
| 51 | if (key === 13) { | 51 | if (key === 13) { |
| 52 | var funcion = ($scope.vendedor.CodVen) ? | ||
| 53 | 'obtenerClientesPorNombreOCuitByVendedor' : 'obtenerClientesPorNombreOCuit'; | ||
| 54 | |||
| 52 | $scope.searchLoading = true; | 55 | $scope.searchLoading = true; |
| 53 | focaBusquedaClienteService | 56 | focaBusquedaClienteService |
| 54 | .obtenerClientesPorNombreOCuit($scope.filters, vendedor.CodVen) | 57 | [funcion]($scope.filters, $scope.vendedor.CodVen) |
| 55 | .then( | 58 | .then( |
| 56 | function(res) { | 59 | function(res) { |
| 57 | $scope.primerBusqueda = true; | 60 | $scope.primerBusqueda = true; |
| 58 | $scope.clientes = res.data; | 61 | $scope.clientes = res.data; |
| 59 | $scope.search(true); | 62 | $scope.search(true); |
| 60 | primera(); | 63 | primera(); |
| 61 | $scope.searchLoading = false; | 64 | $scope.searchLoading = false; |
| 62 | }); | 65 | }); |
| 63 | } | 66 | } |
| 64 | }; | 67 | }; |
| 65 | 68 | ||
| 66 | $scope.search = function (pressed) { | 69 | $scope.search = function (pressed) { |
| 67 | if($scope.primerBusqueda) { | 70 | if($scope.primerBusqueda) { |
| 68 | $scope.filteredClientes = $filter('filter')( | 71 | $scope.filteredClientes = $filter('filter')( |
| 69 | $scope.clientes, {$: $scope.filters} | 72 | $scope.clientes, {$: $scope.filters} |
| 70 | ); | 73 | ); |
| 71 | 74 | ||
| 72 | if(pressed && $scope.filteredClientes.length === 0){ | 75 | if(pressed && $scope.filteredClientes.length === 0){ |
| 73 | $timeout(function() { | 76 | $timeout(function() { |
| 74 | angular.element('#search')[0].focus(); | 77 | angular.element('#search')[0].focus(); |
| 75 | $scope.filters = ''; | 78 | $scope.filters = ''; |
| 76 | }); | 79 | }); |
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | $scope.lastPage = Math.ceil( | 82 | $scope.lastPage = Math.ceil( |
| 80 | $scope.filteredClientes.length / $scope.numPerPage | 83 | $scope.filteredClientes.length / $scope.numPerPage |
| 81 | ); | 84 | ); |
| 82 | 85 | ||
| 83 | $scope.resetPage(); | 86 | $scope.resetPage(); |
| 84 | } | 87 | } |
| 85 | }; | 88 | }; |
| 86 | 89 | ||
| 87 | $scope.resetPage = function () { | 90 | $scope.resetPage = function () { |
| 88 | $scope.currentPage = 1; | 91 | $scope.currentPage = 1; |
| 89 | $scope.selectPage(1); | 92 | $scope.selectPage(1); |
| 90 | }; | 93 | }; |
| 91 | 94 | ||
| 92 | $scope.selectPage = function (page) { | 95 | $scope.selectPage = function (page) { |
| 93 | var start = (page - 1) * $scope.numPerPage; | 96 | var start = (page - 1) * $scope.numPerPage; |
| 94 | var end = start + $scope.numPerPage; | 97 | var end = start + $scope.numPerPage; |
| 95 | $scope.paginas = []; | 98 | $scope.paginas = []; |
| 96 | $scope.paginas = calcularPages(page); | 99 | $scope.paginas = calcularPages(page); |
| 97 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); | 100 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); |
| 98 | $scope.currentPage = page; | 101 | $scope.currentPage = page; |
| 99 | }; | 102 | }; |
| 100 | 103 | ||
| 101 | $scope.select = function(cliente, esNuevo = false) { | 104 | $scope.select = function(cliente, esNuevo = false) { |
| 102 | cliente.esNuevo = esNuevo; | 105 | cliente.esNuevo = esNuevo; |
| 103 | $uibModalInstance.close(cliente); | 106 | $uibModalInstance.close(cliente); |
| 104 | }; | 107 | }; |
| 105 | 108 | ||
| 106 | $scope.cancel = function() { | 109 | $scope.cancel = function() { |
| 107 | if($scope.ingreso) { | 110 | if($scope.ingreso) { |
| 108 | $scope.ingreso = false; | 111 | $scope.ingreso = false; |
| 109 | }else { | 112 | }else { |
| 110 | $uibModalInstance.dismiss('cancel'); | 113 | $uibModalInstance.dismiss('cancel'); |
| 111 | } | 114 | } |
| 112 | }; | 115 | }; |
| 113 | 116 | ||
| 114 | $scope.busquedaDown = function(key) { | 117 | $scope.busquedaDown = function(key) { |
| 115 | if (key === 40) { | 118 | if (key === 40) { |
| 116 | primera(key); | 119 | primera(key); |
| 117 | } | 120 | } |
| 118 | }; | 121 | }; |
| 119 | 122 | ||
| 120 | $scope.itemCliente = function(key) { | 123 | $scope.itemCliente = function(key) { |
| 121 | if (key === 38) { | 124 | if (key === 38) { |
| 122 | anterior(key); | 125 | anterior(key); |
| 123 | } | 126 | } |
| 124 | 127 | ||
| 125 | if (key === 40) { | 128 | if (key === 40) { |
| 126 | siguiente(key); | 129 | siguiente(key); |
| 127 | } | 130 | } |
| 128 | 131 | ||
| 129 | if (key === 37) { | 132 | if (key === 37) { |
| 130 | retrocederPagina(); | 133 | retrocederPagina(); |
| 131 | } | 134 | } |
| 132 | 135 | ||
| 133 | if (key === 39) { | 136 | if (key === 39) { |
| 134 | avanzarPagina(); | 137 | avanzarPagina(); |
| 135 | } | 138 | } |
| 136 | }; | 139 | }; |
| 137 | 140 | ||
| 138 | $scope.focus = function(val) { | 141 | $scope.focus = function(val) { |
| 139 | $scope.focused = val; | 142 | $scope.focused = val; |
| 140 | }; | 143 | }; |
| 141 | 144 | ||
| 142 | $scope.next = function(key) { | 145 | $scope.next = function(key) { |
| 143 | if (key === 13) $scope.focused++; | 146 | if (key === 13) $scope.focused++; |
| 144 | }; | 147 | }; |
| 145 | 148 | ||
| 146 | $scope.seleccionarProvincia = function(key) { | 149 | $scope.seleccionarProvincia = function(key) { |
| 147 | if(key === 13) { | 150 | if(key === 13) { |
| 148 | var modalInstance = $uibModal.open( | 151 | var modalInstance = $uibModal.open( |
| 149 | { | 152 | { |
| 150 | ariaLabelledBy: 'Búsqueda de provincias', | 153 | ariaLabelledBy: 'Búsqueda de provincias', |
| 151 | templateUrl: 'modal-provincias.html', | 154 | templateUrl: 'modal-provincias.html', |
| 152 | controller: 'focaModalProvinciaController', | 155 | controller: 'focaModalProvinciaController', |
| 153 | size: 'md', | 156 | size: 'md', |
| 154 | resolve: { | 157 | resolve: { |
| 155 | filters: function() { | 158 | filters: function() { |
| 156 | return $scope.cliente.provincia.NOMBRE; | 159 | return $scope.cliente.provincia.NOMBRE; |
| 157 | } | 160 | } |
| 158 | } | 161 | } |
| 159 | } | 162 | } |
| 160 | ); | 163 | ); |
| 161 | modalInstance.result.then(function(provincia) { | 164 | modalInstance.result.then(function(provincia) { |
| 162 | $scope.cliente.provincia = provincia; | 165 | $scope.cliente.provincia = provincia; |
| 163 | $timeout(function() { | 166 | $timeout(function() { |
| 164 | $scope.focused = 5; | 167 | $scope.focused = 5; |
| 165 | }); | 168 | }); |
| 166 | }, function() { | 169 | }, function() { |
| 167 | //TODO: función llamada cuando cancela el modal | 170 | //TODO: función llamada cuando cancela el modal |
| 168 | }); | 171 | }); |
| 169 | } | 172 | } |
| 170 | }; | 173 | }; |
| 171 | $scope.seleccionarLocalidad = function(key) { | 174 | $scope.seleccionarLocalidad = function(key) { |
| 172 | if($scope.cliente.provincia.ID === undefined) { | 175 | if($scope.cliente.provincia.ID === undefined) { |
| 173 | focaModalService.alert('Seleccione una provincia'); | 176 | focaModalService.alert('Seleccione una provincia'); |
| 174 | return; | 177 | return; |
| 175 | } | 178 | } |
| 176 | if(key === 13) { | 179 | if(key === 13) { |
| 177 | var modalInstance = $uibModal.open( | 180 | var modalInstance = $uibModal.open( |
| 178 | { | 181 | { |
| 179 | ariaLabelledBy: 'Búsqueda de localidades', | 182 | ariaLabelledBy: 'Búsqueda de localidades', |
| 180 | templateUrl: 'modal-localidades.html', | 183 | templateUrl: 'modal-localidades.html', |
| 181 | controller: 'focaModalLocalidadController', | 184 | controller: 'focaModalLocalidadController', |
| 182 | size: 'md', | 185 | size: 'md', |
| 183 | resolve: { | 186 | resolve: { |
| 184 | filters: { | 187 | filters: { |
| 185 | idProvincia: $scope.cliente.provincia.ID, | 188 | idProvincia: $scope.cliente.provincia.ID, |
| 186 | busqueda: $scope.cliente.localidad.nombre | 189 | busqueda: $scope.cliente.localidad.nombre |
| 187 | } | 190 | } |
| 188 | } | 191 | } |
| 189 | } | 192 | } |
| 190 | ); | 193 | ); |
| 191 | modalInstance.result.then(function(localidad) { | 194 | modalInstance.result.then(function(localidad) { |
| 192 | $scope.cliente.localidad = localidad; | 195 | $scope.cliente.localidad = localidad; |
| 193 | $timeout(function() { | 196 | $timeout(function() { |
| 194 | $scope.focused = 6; | 197 | $scope.focused = 6; |
| 195 | }); | 198 | }); |
| 196 | }, function() { | 199 | }, function() { |
| 197 | //TODO: función llamada cuando cancela el modal | 200 | //TODO: función llamada cuando cancela el modal |
| 198 | }); | 201 | }); |
| 199 | } | 202 | } |
| 200 | }; | 203 | }; |
| 201 | $scope.seleccionarIva = function(key) { | 204 | $scope.seleccionarIva = function(key) { |
| 202 | if(key === 13) { | 205 | if(key === 13) { |
| 203 | var query = '/iva'; | 206 | var query = '/iva'; |
| 204 | var columnas = { | 207 | var columnas = { |
| 205 | nombre: ['Código', 'Nombre'], | 208 | nombre: ['Código', 'Nombre'], |
| 206 | propiedad: ['ID', 'NOM',] | 209 | propiedad: ['ID', 'NOM',] |
| 207 | }; | 210 | }; |
| 208 | var titulo = 'Búsqueda de responsabilidad ante el IVA'; | 211 | var titulo = 'Búsqueda de responsabilidad ante el IVA'; |
| 209 | focaModalService.modal(columnas, query, titulo, 'md').then( | 212 | focaModalService.modal(columnas, query, titulo, 'md').then( |
| 210 | function(iva) { | 213 | function(iva) { |
| 211 | $scope.cliente.iva = iva; | 214 | $scope.cliente.iva = iva; |
| 212 | $timeout(function() { | 215 | $timeout(function() { |
| 213 | $scope.focused = 9; | 216 | $scope.focused = 9; |
| 214 | }); | 217 | }); |
| 215 | }, function() { | 218 | }, function() { |
| 216 | // funcion ejecutada cuando se cancela el modal | 219 | // funcion ejecutada cuando se cancela el modal |
| 217 | }); | 220 | }); |
| 218 | } | 221 | } |
| 219 | }; | 222 | }; |
| 220 | $scope.seleccionarActividad = function(key) { | 223 | $scope.seleccionarActividad = function(key) { |
| 221 | if(key === 13) { | 224 | if(key === 13) { |
| 222 | var query = '/actividad'; | 225 | var query = '/actividad'; |
| 223 | var columnas = { | 226 | var columnas = { |
| 224 | nombre: ['Código', 'Nombre'], | 227 | nombre: ['Código', 'Nombre'], |
| 225 | propiedad: ['ID', 'NOM',] | 228 | propiedad: ['ID', 'NOM',] |
| 226 | }; | 229 | }; |
| 227 | var titulo = 'Búsqueda de actividades'; | 230 | var titulo = 'Búsqueda de actividades'; |
| 228 | focaModalService.modal(columnas, query, titulo, 'md').then( | 231 | focaModalService.modal(columnas, query, titulo, 'md').then( |
| 229 | function(actividad) { | 232 | function(actividad) { |
| 230 | $scope.cliente.actividad = actividad; | 233 | $scope.cliente.actividad = actividad; |
| 231 | }, function() { | 234 | }, function() { |
| 232 | // funcion ejecutada cuando se cancela el modal | 235 | // funcion ejecutada cuando se cancela el modal |
| 233 | }); | 236 | }); |
| 234 | } | 237 | } |
| 235 | }; | 238 | }; |
| 236 | $scope.seleccionarZona = function(key) { | 239 | $scope.seleccionarZona = function(key) { |
| 237 | if(key === 13) { | 240 | if(key === 13) { |
| 238 | var query = '/zona'; | 241 | var query = '/zona'; |
| 239 | var columnas = { | 242 | var columnas = { |
| 240 | nombre: ['Código', 'Nombre'], | 243 | nombre: ['Código', 'Nombre'], |
| 241 | propiedad: ['ID', 'NOM',] | 244 | propiedad: ['ID', 'NOM',] |
| 242 | }; | 245 | }; |
| 243 | var titulo = 'Búsqueda de zonas'; | 246 | var titulo = 'Búsqueda de zonas'; |
| 244 | focaModalService.modal(columnas, query, titulo, 'md').then( | 247 | focaModalService.modal(columnas, query, titulo, 'md').then( |
| 245 | function(zona) { | 248 | function(zona) { |
| 246 | $scope.cliente.zona = zona; | 249 | $scope.cliente.zona = zona; |
| 247 | $timeout(function() { | 250 | $timeout(function() { |
| 248 | $scope.focused = 7; | 251 | $scope.focused = 7; |
| 249 | }); | 252 | }); |
| 250 | }, function() { | 253 | }, function() { |
| 251 | // funcion ejecutada cuando se cancela el modal | 254 | // funcion ejecutada cuando se cancela el modal |
| 252 | }); | 255 | }); |
| 253 | } | 256 | } |
| 254 | }; | 257 | }; |
| 255 | $scope.seleccionarTipoFactura = function(key) { | 258 | $scope.seleccionarTipoFactura = function(key) { |
| 256 | if(key === 13) { | 259 | if(key === 13) { |
| 257 | var query = '/tipo-factura'; | 260 | var query = '/tipo-factura'; |
| 258 | var columnas = { | 261 | var columnas = { |
| 259 | nombre: ['Código', 'Nombre'], | 262 | nombre: ['Código', 'Nombre'], |
| 260 | propiedad: ['ID', 'NOMBRE',] | 263 | propiedad: ['ID', 'NOMBRE',] |
| 261 | }; | 264 | }; |
| 262 | var titulo = 'Búsqueda de tipos de factura'; | 265 | var titulo = 'Búsqueda de tipos de factura'; |
| 263 | focaModalService.modal(columnas, query, titulo, 'md').then( | 266 | focaModalService.modal(columnas, query, titulo, 'md').then( |
| 264 | function(tipoFactura) { | 267 | function(tipoFactura) { |
| 265 | $scope.cliente.tipoFactura = tipoFactura; | 268 | $scope.cliente.tipoFactura = tipoFactura; |
| 266 | $timeout(function() { | 269 | $timeout(function() { |
| 267 | $scope.focused = 10; | 270 | $scope.focused = 10; |
| 268 | }); | 271 | }); |
| 269 | }, function() { | 272 | }, function() { |
| 270 | // funcion ejecutada cuando se cancela el modal | 273 | // funcion ejecutada cuando se cancela el modal |
| 271 | }); | 274 | }); |
| 272 | } | 275 | } |
| 273 | }; | 276 | }; |
| 274 | $scope.seleccionarTipoComprobante = function(key) { | 277 | $scope.seleccionarTipoComprobante = function(key) { |
| 275 | if(key === 13) { | 278 | if(key === 13) { |
| 276 | var query = '/tipo-comprobante'; | 279 | var query = '/tipo-comprobante'; |
| 277 | var columnas = { | 280 | var columnas = { |
| 278 | nombre: ['Código', 'Nombre'], | 281 | nombre: ['Código', 'Nombre'], |
| 279 | propiedad: ['ID', 'NOMBRE',] | 282 | propiedad: ['ID', 'NOMBRE',] |
| 280 | }; | 283 | }; |
| 281 | var titulo = 'Búsqueda de tipos de comprobante'; | 284 | var titulo = 'Búsqueda de tipos de comprobante'; |
| 282 | focaModalService.modal(columnas, query, titulo, 'md').then( | 285 | focaModalService.modal(columnas, query, titulo, 'md').then( |
| 283 | function(tipoComprobante) { | 286 | function(tipoComprobante) { |
| 284 | $scope.cliente.tipoComprobante = tipoComprobante; | 287 | $scope.cliente.tipoComprobante = tipoComprobante; |
| 285 | $timeout(function() { | 288 | $timeout(function() { |
| 286 | $scope.focused = 12; | 289 | $scope.focused = 12; |
| 287 | }); | 290 | }); |
| 288 | }, function() { | 291 | }, function() { |
| 289 | // funcion ejecutada cuando se cancela el modal | 292 | // funcion ejecutada cuando se cancela el modal |
| 290 | }); | 293 | }); |
| 291 | } | 294 | } |
| 292 | }; | 295 | }; |
| 293 | $scope.seleccionarFormaPago = function(key) { | 296 | $scope.seleccionarFormaPago = function(key) { |
| 294 | if(key === 13) { | 297 | if(key === 13) { |
| 295 | var query = '/forma-pago'; | 298 | var query = '/forma-pago'; |
| 296 | var columnas = { | 299 | var columnas = { |
| 297 | nombre: ['Código', 'Nombre'], | 300 | nombre: ['Código', 'Nombre'], |
| 298 | propiedad: ['ID', 'NOMBRE',] | 301 | propiedad: ['ID', 'NOMBRE',] |
| 299 | }; | 302 | }; |
| 300 | var titulo = 'Búsqueda de formas de pago'; | 303 | var titulo = 'Búsqueda de formas de pago'; |
| 301 | focaModalService.modal(columnas, query, titulo, 'md').then( | 304 | focaModalService.modal(columnas, query, titulo, 'md').then( |
| 302 | function(formaPago) { | 305 | function(formaPago) { |
| 303 | $scope.cliente.formaPago = formaPago; | 306 | $scope.cliente.formaPago = formaPago; |
| 304 | }, function() { | 307 | }, function() { |
| 305 | // funcion ejecutada cuando se cancela el modal | 308 | // funcion ejecutada cuando se cancela el modal |
| 306 | }); | 309 | }); |
| 307 | } | 310 | } |
| 308 | }; | 311 | }; |
| 309 | 312 | ||
| 310 | $scope.guardar = function() { | 313 | $scope.guardar = function() { |
| 311 | 314 | ||
| 312 | $scope.cliente.PCX = $scope.cliente.provincia.ID; | 315 | $scope.cliente.PCX = $scope.cliente.provincia.ID; |
| 313 | $scope.cliente.LOX = $scope.cliente.localidad.ID; | 316 | $scope.cliente.LOX = $scope.cliente.localidad.ID; |
| 314 | $scope.cliente.IVA = $scope.cliente.iva.ID; | 317 | $scope.cliente.IVA = $scope.cliente.iva.ID; |
| 315 | $scope.cliente.ACT = $scope.cliente.actividad.ID; | 318 | $scope.cliente.ACT = $scope.cliente.actividad.ID; |
| 316 | $scope.cliente.ZON = $scope.cliente.zona.ID; | 319 | $scope.cliente.ZON = $scope.cliente.zona.ID; |
| 317 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; | 320 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; |
| 318 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; | 321 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; |
| 319 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; | 322 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; |
| 320 | $scope.cliente.VEN = $scope.vendedor.CodVen; | 323 | $scope.cliente.VEN = $scope.vendedor.CodVen; |
| 321 | 324 | ||
| 322 | delete $scope.cliente.provincia; | 325 | delete $scope.cliente.provincia; |
| 323 | delete $scope.cliente.localidad; | 326 | delete $scope.cliente.localidad; |
| 324 | delete $scope.cliente.iva; | 327 | delete $scope.cliente.iva; |
| 325 | delete $scope.cliente.actividad; | 328 | delete $scope.cliente.actividad; |
| 326 | delete $scope.cliente.zona; | 329 | delete $scope.cliente.zona; |
| 327 | delete $scope.cliente.tipoFactura; | 330 | delete $scope.cliente.tipoFactura; |
| 328 | delete $scope.cliente.tipoComprobante; | 331 | delete $scope.cliente.tipoComprobante; |
| 329 | delete $scope.cliente.formaPago; | 332 | delete $scope.cliente.formaPago; |
| 330 | 333 | ||
| 331 | focaBusquedaClienteService | 334 | focaBusquedaClienteService |
| 332 | .guardarCliente($scope.cliente) | 335 | .guardarCliente($scope.cliente) |
| 333 | .then(function(res) { | 336 | .then(function(res) { |
| 334 | var cliente = { | 337 | var cliente = { |
| 335 | cod: res.data.COD, | 338 | cod: res.data.COD, |
| 336 | cuit: res.data.CUIT, | 339 | cuit: res.data.CUIT, |
| 337 | esNuevo: res.data.esNuevo, | 340 | esNuevo: res.data.esNuevo, |
| 338 | nom: res.data.NOM | 341 | nom: res.data.NOM |
| 339 | }; | 342 | }; |
| 340 | $scope.select(cliente, true); | 343 | $scope.select(cliente, true); |
| 341 | }); | 344 | }); |
| 342 | }; | 345 | }; |
| 343 | 346 | ||
| 344 | function calcularPages(paginaActual) { | 347 | function calcularPages(paginaActual) { |
| 345 | var paginas = []; | 348 | var paginas = []; |
| 346 | paginas.push(paginaActual); | 349 | paginas.push(paginaActual); |
| 347 | 350 | ||
| 348 | if (paginaActual - 1 > 1) { | 351 | if (paginaActual - 1 > 1) { |
| 349 | 352 | ||
| 350 | paginas.unshift(paginaActual - 1); | 353 | paginas.unshift(paginaActual - 1); |
| 351 | if (paginaActual - 2 > 1) { | 354 | if (paginaActual - 2 > 1) { |
| 352 | paginas.unshift(paginaActual - 2); | 355 | paginas.unshift(paginaActual - 2); |
| 353 | } | 356 | } |
| 354 | } | 357 | } |
| 355 | 358 | ||
| 356 | if (paginaActual + 1 < $scope.lastPage) { | 359 | if (paginaActual + 1 < $scope.lastPage) { |
| 357 | paginas.push(paginaActual + 1); | 360 | paginas.push(paginaActual + 1); |
| 358 | if (paginaActual + 2 < $scope.lastPage) { | 361 | if (paginaActual + 2 < $scope.lastPage) { |
| 359 | paginas.push(paginaActual + 2); | 362 | paginas.push(paginaActual + 2); |
| 360 | } | 363 | } |
| 361 | } | 364 | } |
| 362 | 365 | ||
| 363 | if (paginaActual !== 1) { | 366 | if (paginaActual !== 1) { |
| 364 | paginas.unshift(1); | 367 | paginas.unshift(1); |
| 365 | } | 368 | } |
| 366 | 369 | ||
| 367 | if (paginaActual !== $scope.lastPage) { | 370 | if (paginaActual !== $scope.lastPage) { |
| 368 | paginas.push($scope.lastPage); | 371 | paginas.push($scope.lastPage); |
| 369 | } | 372 | } |
| 370 | 373 | ||
| 371 | return paginas; | 374 | return paginas; |
| 372 | } | 375 | } |
| 373 | 376 | ||
| 374 | function primera() { | 377 | function primera() { |
| 375 | $scope.selectedClientes = 0; | 378 | $scope.selectedClientes = 0; |
| 376 | } | 379 | } |
| 377 | 380 | ||
| 378 | function anterior() { | 381 | function anterior() { |
| 379 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { | 382 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { |
| 380 | retrocederPagina(); | 383 | retrocederPagina(); |
| 381 | } else { | 384 | } else { |
| 382 | $scope.selectedClientes--; | 385 | $scope.selectedClientes--; |
| 383 | } | 386 | } |
| 384 | } | 387 | } |
| 385 | 388 | ||
| 386 | function siguiente() { | 389 | function siguiente() { |
| 387 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { | 390 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { |
| 388 | $scope.selectedClientes++; | 391 | $scope.selectedClientes++; |
| 389 | } else { | 392 | } else { |
| 390 | avanzarPagina(); | 393 | avanzarPagina(); |
| 391 | } | 394 | } |
| 392 | } | 395 | } |
| 393 | 396 | ||
| 394 | function retrocederPagina() { | 397 | function retrocederPagina() { |
| 395 | if ($scope.currentPage > 1) { | 398 | if ($scope.currentPage > 1) { |
| 396 | $scope.selectPage($scope.currentPage - 1); | 399 | $scope.selectPage($scope.currentPage - 1); |
| 397 | $scope.selectedClientes = $scope.numPerPage - 1; | 400 | $scope.selectedClientes = $scope.numPerPage - 1; |
| 398 | } | 401 | } |
| 399 | } | 402 | } |
| 400 | 403 | ||
| 401 | function avanzarPagina() { | 404 | function avanzarPagina() { |
| 402 | if ($scope.currentPage < $scope.lastPage) { | 405 | if ($scope.currentPage < $scope.lastPage) { |
| 403 | $scope.selectPage($scope.currentPage + 1); | 406 | $scope.selectPage($scope.currentPage + 1); |
| 404 | $scope.selectedClientes = 0; | 407 | $scope.selectedClientes = 0; |
| 405 | } | 408 | } |
| 406 | } | 409 | } |
| 407 | } | 410 | } |
| 408 | ]); | 411 | ]); |
| 409 | 412 |
src/js/service.js
| 1 | angular.module('focaBusquedaCliente') | 1 | angular.module('focaBusquedaCliente') |
| 2 | .service('focaBusquedaClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('focaBusquedaClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
| 3 | return { | 3 | return { |
| 4 | obtenerClientesPorNombreOCuit: function(nombreOCuit, idVendedor) { | 4 | obtenerClientesPorNombreOCuitByVendedor: function(nombreOCuit, idVendedor) { |
| 5 | return $http.post(API_ENDPOINT.URL + '/cliente', | 5 | return $http.post(API_ENDPOINT.URL + '/cliente/listar', |
| 6 | {nombreOCuit: nombreOCuit, idVendedor: idVendedor}); | 6 | {nombreOCuit: nombreOCuit, idVendedor: idVendedor}); |
| 7 | }, | 7 | }, |
| 8 | obtenerClientesPorNombreOCuit: function(nombreOCuit) { | ||
| 9 | return $http.post(API_ENDPOINT.URL + '/cliente/listar', | ||
| 10 | {nombreOCuit: nombreOCuit}); | ||
| 11 | }, | ||
| 8 | guardarCliente: function(cliente) { | 12 | guardarCliente: function(cliente) { |
| 9 | return $http.post(API_ENDPOINT.URL + '/cliente', {cliente: cliente}); | 13 | return $http.post(API_ENDPOINT.URL + '/cliente', {cliente: cliente}); |
| 10 | } | 14 | } |
| 11 | }; | 15 | }; |
| 12 | }]); | 16 | }]); |
| 13 | 17 |