Commit 148cc7e7255f02c49f06c3e0be27a836017a79f0
1 parent
99a0a4475f
Exists in
master
Agregada validacion, por si no se ingreso algun vendedor.
Showing
1 changed file
with
3 additions
and
0 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', 'cobrador', | 4 | '$uibModal', 'focaModalService', '$timeout', 'vendedor', 'cobrador', |
| 5 | function ($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | 5 | function ($uibModalInstance, focaBusquedaClienteService, $scope, $filter, |
| 6 | $uibModal, focaModalService, $timeout, vendedor, cobrador) { | 6 | $uibModal, focaModalService, $timeout, vendedor, cobrador) { |
| 7 | 7 | ||
| 8 | $scope.cobrador = cobrador ? cobrador : {}; | 8 | $scope.cobrador = cobrador ? cobrador : {}; |
| 9 | $scope.vendedor = vendedor ? vendedor : {}; | 9 | $scope.vendedor = vendedor ? vendedor : {}; |
| 10 | $scope.filters = ''; | 10 | $scope.filters = ''; |
| 11 | $scope.primerBusqueda = false; | 11 | $scope.primerBusqueda = false; |
| 12 | // pagination | 12 | // pagination |
| 13 | $scope.numPerPage = 10; | 13 | $scope.numPerPage = 10; |
| 14 | $scope.currentPage = 1; | 14 | $scope.currentPage = 1; |
| 15 | $scope.filteredClientes = []; | 15 | $scope.filteredClientes = []; |
| 16 | $scope.currentPageClientes = []; | 16 | $scope.currentPageClientes = []; |
| 17 | $scope.selectedClientes = -1; | 17 | $scope.selectedClientes = -1; |
| 18 | $scope.ingreso = false; | 18 | $scope.ingreso = false; |
| 19 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); | 19 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/); |
| 20 | $scope.focused = 1; | 20 | $scope.focused = 1; |
| 21 | 21 | ||
| 22 | $scope.cliente = { | 22 | $scope.cliente = { |
| 23 | COD: 0, | 23 | COD: 0, |
| 24 | ES_MAY: true, | 24 | ES_MAY: true, |
| 25 | cuit1: '', | 25 | cuit1: '', |
| 26 | cuit2: '', | 26 | cuit2: '', |
| 27 | cuit3: '', | 27 | cuit3: '', |
| 28 | provincia: { | 28 | provincia: { |
| 29 | NOMBRE: '' | 29 | NOMBRE: '' |
| 30 | }, | 30 | }, |
| 31 | localidad: { | 31 | localidad: { |
| 32 | NOMBRE: '' | 32 | NOMBRE: '' |
| 33 | }, | 33 | }, |
| 34 | iva: { | 34 | iva: { |
| 35 | NOMBRE: '' | 35 | NOMBRE: '' |
| 36 | }, | 36 | }, |
| 37 | actividad: { | 37 | actividad: { |
| 38 | NOM: '' | 38 | NOM: '' |
| 39 | }, | 39 | }, |
| 40 | zona: { | 40 | zona: { |
| 41 | NOM: '' | 41 | NOM: '' |
| 42 | }, | 42 | }, |
| 43 | tipoFactura: { | 43 | tipoFactura: { |
| 44 | NOMBRE: '' | 44 | NOMBRE: '' |
| 45 | }, | 45 | }, |
| 46 | tipoComprobante: { | 46 | tipoComprobante: { |
| 47 | NOMBRE: '' | 47 | NOMBRE: '' |
| 48 | }, | 48 | }, |
| 49 | formaPago: { | 49 | formaPago: { |
| 50 | NOMBRE: '' | 50 | NOMBRE: '' |
| 51 | }, | 51 | }, |
| 52 | cobrador: { | 52 | cobrador: { |
| 53 | NomVen: '' | 53 | NomVen: '' |
| 54 | } | 54 | } |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | $scope.busquedaPress = function (key) { | 57 | $scope.busquedaPress = function (key) { |
| 58 | if (key === 13) { | 58 | if (key === 13) { |
| 59 | var funcion; | 59 | var funcion; |
| 60 | if ($scope.vendedor.id) { | 60 | if ($scope.vendedor.id) { |
| 61 | funcion = 'obtenerClientesPorNombreOCuitByVendedor'; | 61 | funcion = 'obtenerClientesPorNombreOCuitByVendedor'; |
| 62 | } else if ($scope.cobrador.id) { | 62 | } else if ($scope.cobrador.id) { |
| 63 | funcion = 'obtenerClientesPorNombreOCuitByCobrador'; | 63 | funcion = 'obtenerClientesPorNombreOCuitByCobrador'; |
| 64 | } else { | 64 | } else { |
| 65 | funcion = 'obtenerClientesPorNombreOCuit'; | 65 | funcion = 'obtenerClientesPorNombreOCuit'; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | $scope.searchLoading = true; | 68 | $scope.searchLoading = true; |
| 69 | focaBusquedaClienteService | 69 | focaBusquedaClienteService |
| 70 | [funcion]($scope.filters, $scope.vendedor.id || $scope.cobrador.id) | 70 | [funcion]($scope.filters, $scope.vendedor.id || $scope.cobrador.id) |
| 71 | .then( | 71 | .then( |
| 72 | function (res) { | 72 | function (res) { |
| 73 | $scope.primerBusqueda = true; | 73 | $scope.primerBusqueda = true; |
| 74 | $scope.clientes = res.data; | 74 | $scope.clientes = res.data; |
| 75 | $scope.search(true); | 75 | $scope.search(true); |
| 76 | primera(); | 76 | primera(); |
| 77 | $scope.searchLoading = false; | 77 | $scope.searchLoading = false; |
| 78 | }); | 78 | }); |
| 79 | } | 79 | } |
| 80 | }; | 80 | }; |
| 81 | 81 | ||
| 82 | $scope.search = function (pressed) { | 82 | $scope.search = function (pressed) { |
| 83 | if ($scope.primerBusqueda) { | 83 | if ($scope.primerBusqueda) { |
| 84 | $scope.filteredClientes = $filter('filter')( | 84 | $scope.filteredClientes = $filter('filter')( |
| 85 | $scope.clientes, { $: $scope.filters } | 85 | $scope.clientes, { $: $scope.filters } |
| 86 | ); | 86 | ); |
| 87 | 87 | ||
| 88 | if (pressed && $scope.filteredClientes.length === 0) { | 88 | if (pressed && $scope.filteredClientes.length === 0) { |
| 89 | $timeout(function () { | 89 | $timeout(function () { |
| 90 | angular.element('#search')[0].focus(); | 90 | angular.element('#search')[0].focus(); |
| 91 | $scope.filters = ''; | 91 | $scope.filters = ''; |
| 92 | }); | 92 | }); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | $scope.lastPage = Math.ceil( | 95 | $scope.lastPage = Math.ceil( |
| 96 | $scope.filteredClientes.length / $scope.numPerPage | 96 | $scope.filteredClientes.length / $scope.numPerPage |
| 97 | ); | 97 | ); |
| 98 | 98 | ||
| 99 | $scope.resetPage(); | 99 | $scope.resetPage(); |
| 100 | } | 100 | } |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | $scope.resetPage = function () { | 103 | $scope.resetPage = function () { |
| 104 | $scope.currentPage = 1; | 104 | $scope.currentPage = 1; |
| 105 | $scope.selectPage(1); | 105 | $scope.selectPage(1); |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | $scope.selectPage = function (page) { | 108 | $scope.selectPage = function (page) { |
| 109 | var start = (page - 1) * $scope.numPerPage; | 109 | var start = (page - 1) * $scope.numPerPage; |
| 110 | var end = start + $scope.numPerPage; | 110 | var end = start + $scope.numPerPage; |
| 111 | $scope.paginas = []; | 111 | $scope.paginas = []; |
| 112 | $scope.paginas = calcularPages(page); | 112 | $scope.paginas = calcularPages(page); |
| 113 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); | 113 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); |
| 114 | $scope.currentPage = page; | 114 | $scope.currentPage = page; |
| 115 | }; | 115 | }; |
| 116 | 116 | ||
| 117 | $scope.select = function (cliente, esNuevo = false) { | 117 | $scope.select = function (cliente, esNuevo = false) { |
| 118 | cliente.esNuevo = esNuevo; | 118 | cliente.esNuevo = esNuevo; |
| 119 | $uibModalInstance.close(cliente); | 119 | $uibModalInstance.close(cliente); |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | $scope.cancel = function () { | 122 | $scope.cancel = function () { |
| 123 | if ($scope.ingreso) { | 123 | if ($scope.ingreso) { |
| 124 | $scope.ingreso = false; | 124 | $scope.ingreso = false; |
| 125 | } else { | 125 | } else { |
| 126 | $uibModalInstance.dismiss('cancel'); | 126 | $uibModalInstance.dismiss('cancel'); |
| 127 | } | 127 | } |
| 128 | }; | 128 | }; |
| 129 | 129 | ||
| 130 | $scope.busquedaDown = function (key) { | 130 | $scope.busquedaDown = function (key) { |
| 131 | if (key === 40) { | 131 | if (key === 40) { |
| 132 | primera(key); | 132 | primera(key); |
| 133 | } | 133 | } |
| 134 | }; | 134 | }; |
| 135 | 135 | ||
| 136 | $scope.itemCliente = function (key) { | 136 | $scope.itemCliente = function (key) { |
| 137 | if (key === 38) { | 137 | if (key === 38) { |
| 138 | anterior(key); | 138 | anterior(key); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | if (key === 40) { | 141 | if (key === 40) { |
| 142 | siguiente(key); | 142 | siguiente(key); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | if (key === 37) { | 145 | if (key === 37) { |
| 146 | retrocederPagina(); | 146 | retrocederPagina(); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | if (key === 39) { | 149 | if (key === 39) { |
| 150 | avanzarPagina(); | 150 | avanzarPagina(); |
| 151 | } | 151 | } |
| 152 | }; | 152 | }; |
| 153 | 153 | ||
| 154 | $scope.focus = function (val) { | 154 | $scope.focus = function (val) { |
| 155 | $scope.focused = val; | 155 | $scope.focused = val; |
| 156 | }; | 156 | }; |
| 157 | 157 | ||
| 158 | $scope.next = function (key) { | 158 | $scope.next = function (key) { |
| 159 | if (key === 13) $scope.focused++; | 159 | if (key === 13) $scope.focused++; |
| 160 | }; | 160 | }; |
| 161 | 161 | ||
| 162 | $scope.seleccionarProvincia = function (key) { | 162 | $scope.seleccionarProvincia = function (key) { |
| 163 | if (key === 13) { | 163 | if (key === 13) { |
| 164 | var parametrosModal = { | 164 | var parametrosModal = { |
| 165 | searchText: $scope.cliente.provincia.NOMBRE, | 165 | searchText: $scope.cliente.provincia.NOMBRE, |
| 166 | query: '/provincia', | 166 | query: '/provincia', |
| 167 | columnas: [ | 167 | columnas: [ |
| 168 | { | 168 | { |
| 169 | propiedad: 'ID', | 169 | propiedad: 'ID', |
| 170 | nombre: 'Codigo', | 170 | nombre: 'Codigo', |
| 171 | filtro: { | 171 | filtro: { |
| 172 | nombre: 'rellenarDigitos', | 172 | nombre: 'rellenarDigitos', |
| 173 | parametro: 3 | 173 | parametro: 3 |
| 174 | } | 174 | } |
| 175 | }, | 175 | }, |
| 176 | { | 176 | { |
| 177 | propiedad: 'NOMBRE', | 177 | propiedad: 'NOMBRE', |
| 178 | nombre: 'Nombre' | 178 | nombre: 'Nombre' |
| 179 | } | 179 | } |
| 180 | ], | 180 | ], |
| 181 | titulo: 'Búsqueda de provincias', | 181 | titulo: 'Búsqueda de provincias', |
| 182 | size: 'md' | 182 | size: 'md' |
| 183 | }; | 183 | }; |
| 184 | focaModalService.modal(parametrosModal).then(function (provincia) { | 184 | focaModalService.modal(parametrosModal).then(function (provincia) { |
| 185 | $scope.cliente.provincia = provincia; | 185 | $scope.cliente.provincia = provincia; |
| 186 | $timeout(function () { | 186 | $timeout(function () { |
| 187 | $scope.focused = 4; | 187 | $scope.focused = 4; |
| 188 | }); | 188 | }); |
| 189 | }, function () { | 189 | }, function () { |
| 190 | //TODO: función llamada cuando cancela el modal | 190 | //TODO: función llamada cuando cancela el modal |
| 191 | }); | 191 | }); |
| 192 | } | 192 | } |
| 193 | }; | 193 | }; |
| 194 | $scope.seleccionarLocalidad = function (key) { | 194 | $scope.seleccionarLocalidad = function (key) { |
| 195 | if ($scope.cliente.provincia.ID === undefined) { | 195 | if ($scope.cliente.provincia.ID === undefined) { |
| 196 | focaModalService.alert('Seleccione una provincia'); | 196 | focaModalService.alert('Seleccione una provincia'); |
| 197 | return; | 197 | return; |
| 198 | } | 198 | } |
| 199 | if (key === 13) { | 199 | if (key === 13) { |
| 200 | var parametrosModal = { | 200 | var parametrosModal = { |
| 201 | searchText: $scope.cliente.localidad.NOMBRE, | 201 | searchText: $scope.cliente.localidad.NOMBRE, |
| 202 | query: '/localidad/' + $scope.cliente.provincia.ID, | 202 | query: '/localidad/' + $scope.cliente.provincia.ID, |
| 203 | columnas: [ | 203 | columnas: [ |
| 204 | { | 204 | { |
| 205 | propiedad: 'ID', | 205 | propiedad: 'ID', |
| 206 | nombre: 'Código', | 206 | nombre: 'Código', |
| 207 | filtro: { | 207 | filtro: { |
| 208 | nombre: 'rellenarDigitos', | 208 | nombre: 'rellenarDigitos', |
| 209 | parametro: 3 | 209 | parametro: 3 |
| 210 | } | 210 | } |
| 211 | }, | 211 | }, |
| 212 | { | 212 | { |
| 213 | propiedad: 'NOMBRE', | 213 | propiedad: 'NOMBRE', |
| 214 | nombre: 'Nombre' | 214 | nombre: 'Nombre' |
| 215 | } | 215 | } |
| 216 | ], | 216 | ], |
| 217 | titulo: 'Búsqueda de localidades', | 217 | titulo: 'Búsqueda de localidades', |
| 218 | size: 'md' | 218 | size: 'md' |
| 219 | }; | 219 | }; |
| 220 | focaModalService.modal(parametrosModal).then(function (localidad) { | 220 | focaModalService.modal(parametrosModal).then(function (localidad) { |
| 221 | $scope.cliente.localidad = localidad; | 221 | $scope.cliente.localidad = localidad; |
| 222 | $timeout(function () { | 222 | $timeout(function () { |
| 223 | $scope.focused = 5; | 223 | $scope.focused = 5; |
| 224 | }); | 224 | }); |
| 225 | }, function () { | 225 | }, function () { |
| 226 | //TODO: función llamada cuando cancela el modal | 226 | //TODO: función llamada cuando cancela el modal |
| 227 | }); | 227 | }); |
| 228 | } | 228 | } |
| 229 | }; | 229 | }; |
| 230 | $scope.seleccionarIva = function (key) { | 230 | $scope.seleccionarIva = function (key) { |
| 231 | if (key === 13) { | 231 | if (key === 13) { |
| 232 | var parametrosModal = { | 232 | var parametrosModal = { |
| 233 | query: '/iva', | 233 | query: '/iva', |
| 234 | searchText: $scope.cliente.iva.NOMBRE, | 234 | searchText: $scope.cliente.iva.NOMBRE, |
| 235 | columnas: [ | 235 | columnas: [ |
| 236 | { | 236 | { |
| 237 | propiedad: 'ID', | 237 | propiedad: 'ID', |
| 238 | nombre: 'Código', | 238 | nombre: 'Código', |
| 239 | filtro: { | 239 | filtro: { |
| 240 | nombre: 'rellenarDigitos', | 240 | nombre: 'rellenarDigitos', |
| 241 | parametro: 3 | 241 | parametro: 3 |
| 242 | } | 242 | } |
| 243 | }, | 243 | }, |
| 244 | { | 244 | { |
| 245 | propiedad: 'NOMBRE', | 245 | propiedad: 'NOMBRE', |
| 246 | nombre: 'Nombre' | 246 | nombre: 'Nombre' |
| 247 | } | 247 | } |
| 248 | ], | 248 | ], |
| 249 | titulo: 'Búsqueda de responsabilidad ante el IVA', | 249 | titulo: 'Búsqueda de responsabilidad ante el IVA', |
| 250 | size: 'md' | 250 | size: 'md' |
| 251 | }; | 251 | }; |
| 252 | focaModalService.modal(parametrosModal).then( | 252 | focaModalService.modal(parametrosModal).then( |
| 253 | function (iva) { | 253 | function (iva) { |
| 254 | if (iva) { | 254 | if (iva) { |
| 255 | delete $scope.cliente.tipoFactura.NOMBRE; | 255 | delete $scope.cliente.tipoFactura.NOMBRE; |
| 256 | } | 256 | } |
| 257 | $scope.cliente.iva = iva; | 257 | $scope.cliente.iva = iva; |
| 258 | $timeout(function () { | 258 | $timeout(function () { |
| 259 | $scope.focused = 12; | 259 | $scope.focused = 12; |
| 260 | }); | 260 | }); |
| 261 | }, function () { | 261 | }, function () { |
| 262 | // funcion ejecutada cuando se cancela el modal | 262 | // funcion ejecutada cuando se cancela el modal |
| 263 | }); | 263 | }); |
| 264 | } | 264 | } |
| 265 | }; | 265 | }; |
| 266 | $scope.seleccionarActividad = function (key) { | 266 | $scope.seleccionarActividad = function (key) { |
| 267 | if (key === 13) { | 267 | if (key === 13) { |
| 268 | var parametrosModal = { | 268 | var parametrosModal = { |
| 269 | searchText: $scope.cliente.actividad.NOM, | 269 | searchText: $scope.cliente.actividad.NOM, |
| 270 | query: '/actividad', | 270 | query: '/actividad', |
| 271 | columnas: [ | 271 | columnas: [ |
| 272 | { | 272 | { |
| 273 | propiedad: 'ID', | 273 | propiedad: 'ID', |
| 274 | nombre: 'Código', | 274 | nombre: 'Código', |
| 275 | filtro: { | 275 | filtro: { |
| 276 | nombre: 'rellenarDigitos', | 276 | nombre: 'rellenarDigitos', |
| 277 | parametro: 3 | 277 | parametro: 3 |
| 278 | } | 278 | } |
| 279 | }, | 279 | }, |
| 280 | { | 280 | { |
| 281 | propiedad: 'NOM', | 281 | propiedad: 'NOM', |
| 282 | nombre: 'Nombre' | 282 | nombre: 'Nombre' |
| 283 | } | 283 | } |
| 284 | ], | 284 | ], |
| 285 | titulo: 'Búsqueda de actividades', | 285 | titulo: 'Búsqueda de actividades', |
| 286 | size: 'md' | 286 | size: 'md' |
| 287 | }; | 287 | }; |
| 288 | focaModalService.modal(parametrosModal).then( | 288 | focaModalService.modal(parametrosModal).then( |
| 289 | function (actividad) { | 289 | function (actividad) { |
| 290 | $scope.cliente.actividad = actividad; | 290 | $scope.cliente.actividad = actividad; |
| 291 | $timeout(function () { | 291 | $timeout(function () { |
| 292 | $scope.focused = 7; | 292 | $scope.focused = 7; |
| 293 | }); | 293 | }); |
| 294 | }, function () { | 294 | }, function () { |
| 295 | // funcion ejecutada cuando se cancela el modal | 295 | // funcion ejecutada cuando se cancela el modal |
| 296 | }); | 296 | }); |
| 297 | } | 297 | } |
| 298 | }; | 298 | }; |
| 299 | $scope.seleccionarZona = function (key) { | 299 | $scope.seleccionarZona = function (key) { |
| 300 | if (key === 13) { | 300 | if (key === 13) { |
| 301 | var parametrosModal = { | 301 | var parametrosModal = { |
| 302 | searchText: $scope.cliente.zona.NOM, | 302 | searchText: $scope.cliente.zona.NOM, |
| 303 | query: '/zona', | 303 | query: '/zona', |
| 304 | columnas: [ | 304 | columnas: [ |
| 305 | { | 305 | { |
| 306 | propiedad: 'ID', | 306 | propiedad: 'ID', |
| 307 | nombre: 'Código', | 307 | nombre: 'Código', |
| 308 | filtro: { | 308 | filtro: { |
| 309 | nombre: 'rellenarDigitos', | 309 | nombre: 'rellenarDigitos', |
| 310 | parametro: 3 | 310 | parametro: 3 |
| 311 | } | 311 | } |
| 312 | }, | 312 | }, |
| 313 | { | 313 | { |
| 314 | propiedad: 'NOM', | 314 | propiedad: 'NOM', |
| 315 | nombre: 'Nombre' | 315 | nombre: 'Nombre' |
| 316 | } | 316 | } |
| 317 | ], | 317 | ], |
| 318 | titulo: 'Búsqueda de zonas', | 318 | titulo: 'Búsqueda de zonas', |
| 319 | size: 'md' | 319 | size: 'md' |
| 320 | }; | 320 | }; |
| 321 | focaModalService.modal(parametrosModal).then( | 321 | focaModalService.modal(parametrosModal).then( |
| 322 | function (zona) { | 322 | function (zona) { |
| 323 | $scope.cliente.zona = zona; | 323 | $scope.cliente.zona = zona; |
| 324 | $timeout(function () { | 324 | $timeout(function () { |
| 325 | $scope.focused = 6; | 325 | $scope.focused = 6; |
| 326 | }); | 326 | }); |
| 327 | }, function () { | 327 | }, function () { |
| 328 | // funcion ejecutada cuando se cancela el modal | 328 | // funcion ejecutada cuando se cancela el modal |
| 329 | }); | 329 | }); |
| 330 | } | 330 | } |
| 331 | }; | 331 | }; |
| 332 | $scope.seleccionarTipoFactura = function (key) { | 332 | $scope.seleccionarTipoFactura = function (key) { |
| 333 | 333 | ||
| 334 | if ($scope.cliente.iva.NOMBRE == '') { | 334 | if ($scope.cliente.iva.NOMBRE == '') { |
| 335 | focaModalService.alert('Seleccione una responsabilidad ante el IVA'); | 335 | focaModalService.alert('Seleccione una responsabilidad ante el IVA'); |
| 336 | return; | 336 | return; |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | if (key === 13) { | 339 | if (key === 13) { |
| 340 | var datos; | 340 | var datos; |
| 341 | if ($scope.cliente.iva.ID == 1) { | 341 | if ($scope.cliente.iva.ID == 1) { |
| 342 | datos = [ | 342 | datos = [ |
| 343 | { | 343 | { |
| 344 | ID: 'A', | 344 | ID: 'A', |
| 345 | NOMBRE: 'Factura A' | 345 | NOMBRE: 'Factura A' |
| 346 | }, | 346 | }, |
| 347 | { | 347 | { |
| 348 | ID: 'M', | 348 | ID: 'M', |
| 349 | NOMBRE: 'Factura M' | 349 | NOMBRE: 'Factura M' |
| 350 | }, | 350 | }, |
| 351 | { | 351 | { |
| 352 | ID: 'R', | 352 | ID: 'R', |
| 353 | NOMBRE: 'Remito' | 353 | NOMBRE: 'Remito' |
| 354 | } | 354 | } |
| 355 | ]; | 355 | ]; |
| 356 | } else { | 356 | } else { |
| 357 | datos = [ | 357 | datos = [ |
| 358 | { | 358 | { |
| 359 | ID: 'B', | 359 | ID: 'B', |
| 360 | NOMBRE: 'Factura B' | 360 | NOMBRE: 'Factura B' |
| 361 | }, | 361 | }, |
| 362 | { | 362 | { |
| 363 | ID: 'R', | 363 | ID: 'R', |
| 364 | NOMBRE: 'Remito' | 364 | NOMBRE: 'Remito' |
| 365 | } | 365 | } |
| 366 | ]; | 366 | ]; |
| 367 | } | 367 | } |
| 368 | focaModalService.modal({ | 368 | focaModalService.modal({ |
| 369 | titulo: 'Seleccionar Factura', | 369 | titulo: 'Seleccionar Factura', |
| 370 | data: datos, | 370 | data: datos, |
| 371 | size: 'md', | 371 | size: 'md', |
| 372 | columnas: [ | 372 | columnas: [ |
| 373 | { | 373 | { |
| 374 | propiedad: 'ID', | 374 | propiedad: 'ID', |
| 375 | NOMBRE: 'Codigo' | 375 | NOMBRE: 'Codigo' |
| 376 | }, | 376 | }, |
| 377 | { | 377 | { |
| 378 | propiedad: 'NOMBRE', | 378 | propiedad: 'NOMBRE', |
| 379 | NOMBRE: 'Factura' | 379 | NOMBRE: 'Factura' |
| 380 | } | 380 | } |
| 381 | ], | 381 | ], |
| 382 | }).then(function (res) { | 382 | }).then(function (res) { |
| 383 | $scope.cliente.tipoFactura = res; | 383 | $scope.cliente.tipoFactura = res; |
| 384 | }); | 384 | }); |
| 385 | } | 385 | } |
| 386 | }; | 386 | }; |
| 387 | $scope.seleccionarTipoComprobante = function (key) { | 387 | $scope.seleccionarTipoComprobante = function (key) { |
| 388 | if (key === 13) { | 388 | if (key === 13) { |
| 389 | var parametrosModal = { | 389 | var parametrosModal = { |
| 390 | searchText: $scope.cliente.tipoComprobante.NOMBRE, | 390 | searchText: $scope.cliente.tipoComprobante.NOMBRE, |
| 391 | query: '/tipo-comprobante', | 391 | query: '/tipo-comprobante', |
| 392 | columnas: [ | 392 | columnas: [ |
| 393 | { | 393 | { |
| 394 | propiedad: 'ID', | 394 | propiedad: 'ID', |
| 395 | nombre: 'Código' | 395 | nombre: 'Código' |
| 396 | }, | 396 | }, |
| 397 | { | 397 | { |
| 398 | propiedad: 'NOMBRE', | 398 | propiedad: 'NOMBRE', |
| 399 | nombre: 'Nombre' | 399 | nombre: 'Nombre' |
| 400 | } | 400 | } |
| 401 | ], | 401 | ], |
| 402 | titulo: 'Búsqueda de tipos de comprobante', | 402 | titulo: 'Búsqueda de tipos de comprobante', |
| 403 | size: 'md' | 403 | size: 'md' |
| 404 | }; | 404 | }; |
| 405 | focaModalService.modal(parametrosModal).then( | 405 | focaModalService.modal(parametrosModal).then( |
| 406 | function (tipoComprobante) { | 406 | function (tipoComprobante) { |
| 407 | $scope.cliente.tipoComprobante = tipoComprobante; | 407 | $scope.cliente.tipoComprobante = tipoComprobante; |
| 408 | $timeout(function () { | 408 | $timeout(function () { |
| 409 | $scope.focused = 17; | 409 | $scope.focused = 17; |
| 410 | }); | 410 | }); |
| 411 | }, function () { | 411 | }, function () { |
| 412 | // funcion ejecutada cuando se cancela el modal | 412 | // funcion ejecutada cuando se cancela el modal |
| 413 | }); | 413 | }); |
| 414 | } | 414 | } |
| 415 | }; | 415 | }; |
| 416 | $scope.seleccionarFormaPago = function (key) { | 416 | $scope.seleccionarFormaPago = function (key) { |
| 417 | if (key === 13) { | 417 | if (key === 13) { |
| 418 | var parametrosModal = { | 418 | var parametrosModal = { |
| 419 | searchText: $scope.cliente.formaPago.NOMBRE, | 419 | searchText: $scope.cliente.formaPago.NOMBRE, |
| 420 | query: '/forma-pago', | 420 | query: '/forma-pago', |
| 421 | columnas: [ | 421 | columnas: [ |
| 422 | { | 422 | { |
| 423 | propiedad: 'ID', | 423 | propiedad: 'ID', |
| 424 | nombre: 'Código', | 424 | nombre: 'Código', |
| 425 | filtro: { | 425 | filtro: { |
| 426 | nombre: 'rellenarDigitos', | 426 | nombre: 'rellenarDigitos', |
| 427 | parametro: 3 | 427 | parametro: 3 |
| 428 | } | 428 | } |
| 429 | }, | 429 | }, |
| 430 | { | 430 | { |
| 431 | propiedad: 'NOMBRE', | 431 | propiedad: 'NOMBRE', |
| 432 | nombre: 'Nombre' | 432 | nombre: 'Nombre' |
| 433 | } | 433 | } |
| 434 | ], | 434 | ], |
| 435 | titulo: 'Búsqueda de formas de pago', | 435 | titulo: 'Búsqueda de formas de pago', |
| 436 | size: 'md' | 436 | size: 'md' |
| 437 | }; | 437 | }; |
| 438 | focaModalService.modal(parametrosModal).then( | 438 | focaModalService.modal(parametrosModal).then( |
| 439 | function (formaPago) { | 439 | function (formaPago) { |
| 440 | $scope.cliente.formaPago = formaPago; | 440 | $scope.cliente.formaPago = formaPago; |
| 441 | }, function () { | 441 | }, function () { |
| 442 | // funcion ejecutada cuando se cancela el modal | 442 | // funcion ejecutada cuando se cancela el modal |
| 443 | }); | 443 | }); |
| 444 | } | 444 | } |
| 445 | }; | 445 | }; |
| 446 | $scope.seleccionarCobrador = function (key) { | 446 | $scope.seleccionarCobrador = function (key) { |
| 447 | if (key === 13) { | 447 | if (key === 13) { |
| 448 | var parametrosModal = { | 448 | var parametrosModal = { |
| 449 | searchText: $scope.cliente.cobrador.NOM, | 449 | searchText: $scope.cliente.cobrador.NOM, |
| 450 | query: '/cobrador', | 450 | query: '/cobrador', |
| 451 | columnas: [ | 451 | columnas: [ |
| 452 | { | 452 | { |
| 453 | propiedad: 'NUM', | 453 | propiedad: 'NUM', |
| 454 | nombre: 'Código' | 454 | nombre: 'Código' |
| 455 | }, | 455 | }, |
| 456 | { | 456 | { |
| 457 | propiedad: 'NOM', | 457 | propiedad: 'NOM', |
| 458 | nombre: 'Nombre' | 458 | nombre: 'Nombre' |
| 459 | } | 459 | } |
| 460 | ], | 460 | ], |
| 461 | titulo: 'Búsqueda de cobradores', | 461 | titulo: 'Búsqueda de cobradores', |
| 462 | size: 'md' | 462 | size: 'md' |
| 463 | }; | 463 | }; |
| 464 | focaModalService.modal(parametrosModal).then( | 464 | focaModalService.modal(parametrosModal).then( |
| 465 | function (cobrador) { | 465 | function (cobrador) { |
| 466 | $scope.cliente.cobrador = cobrador; | 466 | $scope.cliente.cobrador = cobrador; |
| 467 | }, function () { | 467 | }, function () { |
| 468 | // funcion ejecutada cuando se cancela el modal | 468 | // funcion ejecutada cuando se cancela el modal |
| 469 | }); | 469 | }); |
| 470 | } | 470 | } |
| 471 | }; | 471 | }; |
| 472 | $scope.seleccionarVendedor = function (key) { | 472 | $scope.seleccionarVendedor = function (key) { |
| 473 | if (key === 13) { | 473 | if (key === 13) { |
| 474 | var parametrosModal = { | 474 | var parametrosModal = { |
| 475 | titulo: 'Búsqueda vendedores', | 475 | titulo: 'Búsqueda vendedores', |
| 476 | query: '/vendedor', | 476 | query: '/vendedor', |
| 477 | columnas: [ | 477 | columnas: [ |
| 478 | { | 478 | { |
| 479 | propiedad: 'NUM', | 479 | propiedad: 'NUM', |
| 480 | nombre: 'Código', | 480 | nombre: 'Código', |
| 481 | filtro: { | 481 | filtro: { |
| 482 | nombre: 'rellenarDigitos', | 482 | nombre: 'rellenarDigitos', |
| 483 | parametro: 3 | 483 | parametro: 3 |
| 484 | } | 484 | } |
| 485 | }, | 485 | }, |
| 486 | { | 486 | { |
| 487 | propiedad: 'NOM', | 487 | propiedad: 'NOM', |
| 488 | nombre: 'Nombre' | 488 | nombre: 'Nombre' |
| 489 | } | 489 | } |
| 490 | ], | 490 | ], |
| 491 | size: 'md' | 491 | size: 'md' |
| 492 | }; | 492 | }; |
| 493 | focaModalService.modal(parametrosModal).then( | 493 | focaModalService.modal(parametrosModal).then( |
| 494 | function (vendedor) { | 494 | function (vendedor) { |
| 495 | $scope.vendedor = vendedor; | 495 | $scope.vendedor = vendedor; |
| 496 | }, function () { | 496 | }, function () { |
| 497 | // funcion ejecutada cuando se cancela el modal | 497 | // funcion ejecutada cuando se cancela el modal |
| 498 | }); | 498 | }); |
| 499 | } | 499 | } |
| 500 | }; | 500 | }; |
| 501 | 501 | ||
| 502 | $scope.pasarCampoCuit = function (numeroCuit) { | 502 | $scope.pasarCampoCuit = function (numeroCuit) { |
| 503 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { | 503 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { |
| 504 | $scope.cuitActivo = 2; | 504 | $scope.cuitActivo = 2; |
| 505 | } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { | 505 | } else if (numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { |
| 506 | $scope.cuitActivo = 3; | 506 | $scope.cuitActivo = 3; |
| 507 | } | 507 | } |
| 508 | }; | 508 | }; |
| 509 | 509 | ||
| 510 | $scope.guardar = function () { | 510 | $scope.guardar = function () { |
| 511 | if (!$scope.cliente.NOM) { | 511 | if (!$scope.cliente.NOM) { |
| 512 | focaModalService.alert('Ingrese Nombre'); | 512 | focaModalService.alert('Ingrese Nombre'); |
| 513 | return; | 513 | return; |
| 514 | } else if (!$scope.cliente.CPO) { | 514 | } else if (!$scope.cliente.CPO) { |
| 515 | focaModalService.alert('Ingrese Codigo Postal'); | 515 | focaModalService.alert('Ingrese Codigo Postal'); |
| 516 | return; | 516 | return; |
| 517 | } else if (!$scope.cliente.provincia.NOMBRE) { | 517 | } else if (!$scope.cliente.provincia.NOMBRE) { |
| 518 | focaModalService.alert('Seleccione una provincia'); | 518 | focaModalService.alert('Seleccione una provincia'); |
| 519 | return; | 519 | return; |
| 520 | } else if (!$scope.cliente.DOM) { | 520 | } else if (!$scope.cliente.DOM) { |
| 521 | focaModalService.alert('Ingrese Domicilio'); | 521 | focaModalService.alert('Ingrese Domicilio'); |
| 522 | return; | 522 | return; |
| 523 | } else if (!$scope.cliente.localidad.NOMBRE) { | 523 | } else if (!$scope.cliente.localidad.NOMBRE) { |
| 524 | focaModalService.alert('Seleccione una localidad'); | 524 | focaModalService.alert('Seleccione una localidad'); |
| 525 | return; | 525 | return; |
| 526 | } else if (!$scope.cliente.zona.NOM) { | 526 | } else if (!$scope.cliente.zona.NOM) { |
| 527 | focaModalService.alert('Seleccione una zona'); | 527 | focaModalService.alert('Seleccione una zona'); |
| 528 | return; | 528 | return; |
| 529 | } else if (!$scope.cliente.actividad.NOM) { | 529 | } else if (!$scope.cliente.actividad.NOM) { |
| 530 | focaModalService.alert('Seleccione actividad'); | 530 | focaModalService.alert('Seleccione actividad'); |
| 531 | return; | 531 | return; |
| 532 | } else if (!$scope.cliente.cobrador.NUM) { | 532 | } else if (!$scope.cliente.cobrador.NUM) { |
| 533 | focaModalService.alert('Seleccione un cobrador'); | 533 | focaModalService.alert('Seleccione un cobrador'); |
| 534 | return; | 534 | return; |
| 535 | } else if (!$scope.vendedor.NUM) { | ||
| 536 | focaModalService.alert('Seleccione un vendedor'); | ||
| 537 | return; | ||
| 535 | } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { | 538 | } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { |
| 536 | focaModalService.alert('Ingrese un formato de email válido'); | 539 | focaModalService.alert('Ingrese un formato de email válido'); |
| 537 | return; | 540 | return; |
| 538 | } else if (!$scope.cliente.TEL) { | 541 | } else if (!$scope.cliente.TEL) { |
| 539 | focaModalService.alert('Ingrese un numero de telefono'); | 542 | focaModalService.alert('Ingrese un numero de telefono'); |
| 540 | return; | 543 | return; |
| 541 | } else if (!$scope.cliente.iva.NOMBRE) { | 544 | } else if (!$scope.cliente.iva.NOMBRE) { |
| 542 | focaModalService.alert('Seleccione responsabilidad ante el IVA'); | 545 | focaModalService.alert('Seleccione responsabilidad ante el IVA'); |
| 543 | return; | 546 | return; |
| 544 | } else if (!$scope.cliente.tipoFactura.NOMBRE) { | 547 | } else if (!$scope.cliente.tipoFactura.NOMBRE) { |
| 545 | focaModalService.alert('Seleccione tipo de Factura'); | 548 | focaModalService.alert('Seleccione tipo de Factura'); |
| 546 | return; | 549 | return; |
| 547 | } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { | 550 | } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { |
| 548 | focaModalService.alert('Ingrese CUIT'); | 551 | focaModalService.alert('Ingrese CUIT'); |
| 549 | return; | 552 | return; |
| 550 | } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { | 553 | } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { |
| 551 | focaModalService.alert('Ingrese CUIT válido'); | 554 | focaModalService.alert('Ingrese CUIT válido'); |
| 552 | return; | 555 | return; |
| 553 | } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { | 556 | } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { |
| 554 | focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); | 557 | focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); |
| 555 | return; | 558 | return; |
| 556 | } else if (!$scope.cliente.tipoComprobante.NOMBRE) { | 559 | } else if (!$scope.cliente.tipoComprobante.NOMBRE) { |
| 557 | focaModalService.alert('Seleccione un Comprobante'); | 560 | focaModalService.alert('Seleccione un Comprobante'); |
| 558 | return; | 561 | return; |
| 559 | } else if (!$scope.cliente.formaPago.NOMBRE) { | 562 | } else if (!$scope.cliente.formaPago.NOMBRE) { |
| 560 | focaModalService.alert('Seleccione una forma de pago'); | 563 | focaModalService.alert('Seleccione una forma de pago'); |
| 561 | return; | 564 | return; |
| 562 | } | 565 | } |
| 563 | 566 | ||
| 564 | var cliente = crearCopia(); | 567 | var cliente = crearCopia(); |
| 565 | 568 | ||
| 566 | focaBusquedaClienteService | 569 | focaBusquedaClienteService |
| 567 | .guardarCliente(cliente) | 570 | .guardarCliente(cliente) |
| 568 | .then(function (res) { | 571 | .then(function (res) { |
| 569 | var cliente = { | 572 | var cliente = { |
| 570 | cod: res.data.COD, | 573 | cod: res.data.COD, |
| 571 | cuit: res.data.CUIT, | 574 | cuit: res.data.CUIT, |
| 572 | esNuevo: res.data.esNuevo, | 575 | esNuevo: res.data.esNuevo, |
| 573 | nom: res.data.NOM | 576 | nom: res.data.NOM |
| 574 | }; | 577 | }; |
| 575 | $scope.select(cliente, true); | 578 | $scope.select(cliente, true); |
| 576 | }); | 579 | }); |
| 577 | }; | 580 | }; |
| 578 | 581 | ||
| 579 | function crearCopia() { | 582 | function crearCopia() { |
| 580 | var cliente = angular.copy($scope.cliente); | 583 | var cliente = angular.copy($scope.cliente); |
| 581 | 584 | ||
| 582 | cliente.PCX = cliente.provincia.ID; | 585 | cliente.PCX = cliente.provincia.ID; |
| 583 | cliente.LOX = cliente.localidad.ID; | 586 | cliente.LOX = cliente.localidad.ID; |
| 584 | cliente.IVA = cliente.iva.ID; | 587 | cliente.IVA = cliente.iva.ID; |
| 585 | cliente.ACT = cliente.actividad.ID; | 588 | cliente.ACT = cliente.actividad.ID; |
| 586 | cliente.ZON = cliente.zona.ID; | 589 | cliente.ZON = cliente.zona.ID; |
| 587 | cliente.TIP = cliente.tipoFactura.ID; | 590 | cliente.TIP = cliente.tipoFactura.ID; |
| 588 | cliente.TCO = cliente.tipoComprobante.ID; | 591 | cliente.TCO = cliente.tipoComprobante.ID; |
| 589 | cliente.FPA = cliente.formaPago.ID; | 592 | cliente.FPA = cliente.formaPago.ID; |
| 590 | cliente.VEN = vendedor.ID; | 593 | cliente.VEN = vendedor.ID; |
| 591 | cliente.CUIT = cliente.cuit1 + cliente.cuit2 + cliente.cuit3; | 594 | cliente.CUIT = cliente.cuit1 + cliente.cuit2 + cliente.cuit3; |
| 592 | cliente.idCobrador = cliente.cobrador.ID; | 595 | cliente.idCobrador = cliente.cobrador.ID; |
| 593 | 596 | ||
| 594 | delete cliente.provincia; | 597 | delete cliente.provincia; |
| 595 | delete cliente.localidad; | 598 | delete cliente.localidad; |
| 596 | delete cliente.iva; | 599 | delete cliente.iva; |
| 597 | delete cliente.actividad; | 600 | delete cliente.actividad; |
| 598 | delete cliente.zona; | 601 | delete cliente.zona; |
| 599 | delete cliente.tipoFactura; | 602 | delete cliente.tipoFactura; |
| 600 | delete cliente.tipoComprobante; | 603 | delete cliente.tipoComprobante; |
| 601 | delete cliente.formaPago; | 604 | delete cliente.formaPago; |
| 602 | delete cliente.cobrador; | 605 | delete cliente.cobrador; |
| 603 | delete cliente.cuit1; | 606 | delete cliente.cuit1; |
| 604 | delete cliente.cuit2; | 607 | delete cliente.cuit2; |
| 605 | delete cliente.cuit3; | 608 | delete cliente.cuit3; |
| 606 | 609 | ||
| 607 | return cliente; | 610 | return cliente; |
| 608 | } | 611 | } |
| 609 | 612 | ||
| 610 | function calcularPages(paginaActual) { | 613 | function calcularPages(paginaActual) { |
| 611 | var paginas = []; | 614 | var paginas = []; |
| 612 | paginas.push(paginaActual); | 615 | paginas.push(paginaActual); |
| 613 | 616 | ||
| 614 | if (paginaActual - 1 > 1) { | 617 | if (paginaActual - 1 > 1) { |
| 615 | 618 | ||
| 616 | paginas.unshift(paginaActual - 1); | 619 | paginas.unshift(paginaActual - 1); |
| 617 | if (paginaActual - 2 > 1) { | 620 | if (paginaActual - 2 > 1) { |
| 618 | paginas.unshift(paginaActual - 2); | 621 | paginas.unshift(paginaActual - 2); |
| 619 | } | 622 | } |
| 620 | } | 623 | } |
| 621 | 624 | ||
| 622 | if (paginaActual + 1 < $scope.lastPage) { | 625 | if (paginaActual + 1 < $scope.lastPage) { |
| 623 | paginas.push(paginaActual + 1); | 626 | paginas.push(paginaActual + 1); |
| 624 | if (paginaActual + 2 < $scope.lastPage) { | 627 | if (paginaActual + 2 < $scope.lastPage) { |
| 625 | paginas.push(paginaActual + 2); | 628 | paginas.push(paginaActual + 2); |
| 626 | } | 629 | } |
| 627 | } | 630 | } |
| 628 | 631 | ||
| 629 | if (paginaActual !== 1) { | 632 | if (paginaActual !== 1) { |
| 630 | paginas.unshift(1); | 633 | paginas.unshift(1); |
| 631 | } | 634 | } |
| 632 | 635 | ||
| 633 | if (paginaActual !== $scope.lastPage) { | 636 | if (paginaActual !== $scope.lastPage) { |
| 634 | paginas.push($scope.lastPage); | 637 | paginas.push($scope.lastPage); |
| 635 | } | 638 | } |
| 636 | 639 | ||
| 637 | return paginas; | 640 | return paginas; |
| 638 | } | 641 | } |
| 639 | 642 | ||
| 640 | function primera() { | 643 | function primera() { |
| 641 | $scope.selectedClientes = 0; | 644 | $scope.selectedClientes = 0; |
| 642 | } | 645 | } |
| 643 | 646 | ||
| 644 | function anterior() { | 647 | function anterior() { |
| 645 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { | 648 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { |
| 646 | retrocederPagina(); | 649 | retrocederPagina(); |
| 647 | } else { | 650 | } else { |
| 648 | $scope.selectedClientes--; | 651 | $scope.selectedClientes--; |
| 649 | } | 652 | } |
| 650 | } | 653 | } |
| 651 | 654 | ||
| 652 | function siguiente() { | 655 | function siguiente() { |
| 653 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1) { | 656 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1) { |
| 654 | $scope.selectedClientes++; | 657 | $scope.selectedClientes++; |
| 655 | } else { | 658 | } else { |
| 656 | avanzarPagina(); | 659 | avanzarPagina(); |
| 657 | } | 660 | } |
| 658 | } | 661 | } |
| 659 | 662 | ||
| 660 | function retrocederPagina() { | 663 | function retrocederPagina() { |
| 661 | if ($scope.currentPage > 1) { | 664 | if ($scope.currentPage > 1) { |
| 662 | $scope.selectPage($scope.currentPage - 1); | 665 | $scope.selectPage($scope.currentPage - 1); |
| 663 | $scope.selectedClientes = $scope.numPerPage - 1; | 666 | $scope.selectedClientes = $scope.numPerPage - 1; |
| 664 | } | 667 | } |
| 665 | } | 668 | } |
| 666 | 669 | ||
| 667 | function avanzarPagina() { | 670 | function avanzarPagina() { |
| 668 | if ($scope.currentPage < $scope.lastPage) { | 671 | if ($scope.currentPage < $scope.lastPage) { |
| 669 | $scope.selectPage($scope.currentPage + 1); | 672 | $scope.selectPage($scope.currentPage + 1); |
| 670 | $scope.selectedClientes = 0; | 673 | $scope.selectedClientes = 0; |
| 671 | } | 674 | } |
| 672 | } | 675 | } |
| 673 | function validateEmails(emails) { | 676 | function validateEmails(emails) { |
| 674 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | 677 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; |
| 675 | var arr = emails.split(','); | 678 | var arr = emails.split(','); |
| 676 | var result = true; | 679 | var result = true; |
| 677 | arr.forEach(function (email) { | 680 | arr.forEach(function (email) { |
| 678 | var val = String(email).trim().toLowerCase(); | 681 | var val = String(email).trim().toLowerCase(); |
| 679 | if (!re.test(val)) result = false; | 682 | if (!re.test(val)) result = false; |
| 680 | }); | 683 | }); |
| 681 | return result; | 684 | return result; |
| 682 | } | 685 | } |
| 683 | } | 686 | } |
| 684 | ]); | 687 | ]); |
| 685 | 688 |