Commit 99a0a4475f5e9472aed929ea7c9235638507b6b7
1 parent
f2fb382aa9
Exists in
master
Codigo identado.
Showing
1 changed file
with
65 additions
and
65 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -2,7 +2,7 @@ angular.module('focaBusquedaCliente') |
2 | 2 | .controller('focaBusquedaClienteModalController', [ |
3 | 3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', |
4 | 4 | '$uibModal', 'focaModalService', '$timeout', 'vendedor', 'cobrador', |
5 | - function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | |
5 | + function ($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | |
6 | 6 | $uibModal, focaModalService, $timeout, vendedor, cobrador) { |
7 | 7 | |
8 | 8 | $scope.cobrador = cobrador ? cobrador : {}; |
... | ... | @@ -54,7 +54,7 @@ angular.module('focaBusquedaCliente') |
54 | 54 | } |
55 | 55 | }; |
56 | 56 | |
57 | - $scope.busquedaPress = function(key) { | |
57 | + $scope.busquedaPress = function (key) { | |
58 | 58 | if (key === 13) { |
59 | 59 | var funcion; |
60 | 60 | if ($scope.vendedor.id) { |
... | ... | @@ -64,29 +64,29 @@ angular.module('focaBusquedaCliente') |
64 | 64 | } else { |
65 | 65 | funcion = 'obtenerClientesPorNombreOCuit'; |
66 | 66 | } |
67 | - | |
67 | + | |
68 | 68 | $scope.searchLoading = true; |
69 | 69 | focaBusquedaClienteService |
70 | - [funcion]($scope.filters, $scope.vendedor.id || $scope.cobrador.id) | |
70 | + [funcion]($scope.filters, $scope.vendedor.id || $scope.cobrador.id) | |
71 | 71 | .then( |
72 | - function(res) { | |
72 | + function (res) { | |
73 | 73 | $scope.primerBusqueda = true; |
74 | 74 | $scope.clientes = res.data; |
75 | 75 | $scope.search(true); |
76 | 76 | primera(); |
77 | 77 | $scope.searchLoading = false; |
78 | - }); | |
78 | + }); | |
79 | 79 | } |
80 | 80 | }; |
81 | 81 | |
82 | 82 | $scope.search = function (pressed) { |
83 | 83 | if ($scope.primerBusqueda) { |
84 | 84 | $scope.filteredClientes = $filter('filter')( |
85 | - $scope.clientes, {$: $scope.filters} | |
85 | + $scope.clientes, { $: $scope.filters } | |
86 | 86 | ); |
87 | 87 | |
88 | 88 | if (pressed && $scope.filteredClientes.length === 0) { |
89 | - $timeout(function() { | |
89 | + $timeout(function () { | |
90 | 90 | angular.element('#search')[0].focus(); |
91 | 91 | $scope.filters = ''; |
92 | 92 | }); |
... | ... | @@ -114,12 +114,12 @@ angular.module('focaBusquedaCliente') |
114 | 114 | $scope.currentPage = page; |
115 | 115 | }; |
116 | 116 | |
117 | - $scope.select = function(cliente, esNuevo = false) { | |
117 | + $scope.select = function (cliente, esNuevo = false) { | |
118 | 118 | cliente.esNuevo = esNuevo; |
119 | 119 | $uibModalInstance.close(cliente); |
120 | 120 | }; |
121 | 121 | |
122 | - $scope.cancel = function() { | |
122 | + $scope.cancel = function () { | |
123 | 123 | if ($scope.ingreso) { |
124 | 124 | $scope.ingreso = false; |
125 | 125 | } else { |
... | ... | @@ -127,13 +127,13 @@ angular.module('focaBusquedaCliente') |
127 | 127 | } |
128 | 128 | }; |
129 | 129 | |
130 | - $scope.busquedaDown = function(key) { | |
130 | + $scope.busquedaDown = function (key) { | |
131 | 131 | if (key === 40) { |
132 | 132 | primera(key); |
133 | 133 | } |
134 | 134 | }; |
135 | 135 | |
136 | - $scope.itemCliente = function(key) { | |
136 | + $scope.itemCliente = function (key) { | |
137 | 137 | if (key === 38) { |
138 | 138 | anterior(key); |
139 | 139 | } |
... | ... | @@ -151,15 +151,15 @@ angular.module('focaBusquedaCliente') |
151 | 151 | } |
152 | 152 | }; |
153 | 153 | |
154 | - $scope.focus = function(val) { | |
154 | + $scope.focus = function (val) { | |
155 | 155 | $scope.focused = val; |
156 | 156 | }; |
157 | 157 | |
158 | - $scope.next = function(key) { | |
158 | + $scope.next = function (key) { | |
159 | 159 | if (key === 13) $scope.focused++; |
160 | 160 | }; |
161 | 161 | |
162 | - $scope.seleccionarProvincia = function(key) { | |
162 | + $scope.seleccionarProvincia = function (key) { | |
163 | 163 | if (key === 13) { |
164 | 164 | var parametrosModal = { |
165 | 165 | searchText: $scope.cliente.provincia.NOMBRE, |
... | ... | @@ -178,20 +178,20 @@ angular.module('focaBusquedaCliente') |
178 | 178 | nombre: 'Nombre' |
179 | 179 | } |
180 | 180 | ], |
181 | - titulo:'Búsqueda de provincias', | |
181 | + titulo: 'Búsqueda de provincias', | |
182 | 182 | size: 'md' |
183 | 183 | }; |
184 | - focaModalService.modal(parametrosModal).then(function(provincia) { | |
184 | + focaModalService.modal(parametrosModal).then(function (provincia) { | |
185 | 185 | $scope.cliente.provincia = provincia; |
186 | - $timeout(function() { | |
186 | + $timeout(function () { | |
187 | 187 | $scope.focused = 4; |
188 | 188 | }); |
189 | - }, function() { | |
189 | + }, function () { | |
190 | 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 | 195 | if ($scope.cliente.provincia.ID === undefined) { |
196 | 196 | focaModalService.alert('Seleccione una provincia'); |
197 | 197 | return; |
... | ... | @@ -214,20 +214,20 @@ angular.module('focaBusquedaCliente') |
214 | 214 | nombre: 'Nombre' |
215 | 215 | } |
216 | 216 | ], |
217 | - titulo:'Búsqueda de localidades', | |
217 | + titulo: 'Búsqueda de localidades', | |
218 | 218 | size: 'md' |
219 | 219 | }; |
220 | - focaModalService.modal(parametrosModal).then(function(localidad) { | |
220 | + focaModalService.modal(parametrosModal).then(function (localidad) { | |
221 | 221 | $scope.cliente.localidad = localidad; |
222 | - $timeout(function() { | |
222 | + $timeout(function () { | |
223 | 223 | $scope.focused = 5; |
224 | 224 | }); |
225 | - }, function() { | |
225 | + }, function () { | |
226 | 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 | 231 | if (key === 13) { |
232 | 232 | var parametrosModal = { |
233 | 233 | query: '/iva', |
... | ... | @@ -246,24 +246,24 @@ angular.module('focaBusquedaCliente') |
246 | 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 | 250 | size: 'md' |
251 | 251 | }; |
252 | 252 | focaModalService.modal(parametrosModal).then( |
253 | - function(iva) { | |
253 | + function (iva) { | |
254 | 254 | if (iva) { |
255 | 255 | delete $scope.cliente.tipoFactura.NOMBRE; |
256 | 256 | } |
257 | 257 | $scope.cliente.iva = iva; |
258 | - $timeout(function() { | |
258 | + $timeout(function () { | |
259 | 259 | $scope.focused = 12; |
260 | 260 | }); |
261 | - }, function() { | |
261 | + }, function () { | |
262 | 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 | 267 | if (key === 13) { |
268 | 268 | var parametrosModal = { |
269 | 269 | searchText: $scope.cliente.actividad.NOM, |
... | ... | @@ -286,17 +286,17 @@ angular.module('focaBusquedaCliente') |
286 | 286 | size: 'md' |
287 | 287 | }; |
288 | 288 | focaModalService.modal(parametrosModal).then( |
289 | - function(actividad) { | |
289 | + function (actividad) { | |
290 | 290 | $scope.cliente.actividad = actividad; |
291 | - $timeout(function() { | |
291 | + $timeout(function () { | |
292 | 292 | $scope.focused = 7; |
293 | 293 | }); |
294 | - }, function() { | |
294 | + }, function () { | |
295 | 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 | 300 | if (key === 13) { |
301 | 301 | var parametrosModal = { |
302 | 302 | searchText: $scope.cliente.zona.NOM, |
... | ... | @@ -319,18 +319,18 @@ angular.module('focaBusquedaCliente') |
319 | 319 | size: 'md' |
320 | 320 | }; |
321 | 321 | focaModalService.modal(parametrosModal).then( |
322 | - function(zona) { | |
322 | + function (zona) { | |
323 | 323 | $scope.cliente.zona = zona; |
324 | - $timeout(function() { | |
324 | + $timeout(function () { | |
325 | 325 | $scope.focused = 6; |
326 | 326 | }); |
327 | - }, function() { | |
327 | + }, function () { | |
328 | 328 | // funcion ejecutada cuando se cancela el modal |
329 | 329 | }); |
330 | 330 | } |
331 | 331 | }; |
332 | - $scope.seleccionarTipoFactura = function(key) { | |
333 | - | |
332 | + $scope.seleccionarTipoFactura = function (key) { | |
333 | + | |
334 | 334 | if ($scope.cliente.iva.NOMBRE == '') { |
335 | 335 | focaModalService.alert('Seleccione una responsabilidad ante el IVA'); |
336 | 336 | return; |
... | ... | @@ -372,19 +372,19 @@ angular.module('focaBusquedaCliente') |
372 | 372 | columnas: [ |
373 | 373 | { |
374 | 374 | propiedad: 'ID', |
375 | - NOMBRE: 'Codigo' | |
375 | + NOMBRE: 'Codigo' | |
376 | 376 | }, |
377 | 377 | { |
378 | 378 | propiedad: 'NOMBRE', |
379 | 379 | NOMBRE: 'Factura' |
380 | 380 | } |
381 | 381 | ], |
382 | - }).then(function(res) { | |
382 | + }).then(function (res) { | |
383 | 383 | $scope.cliente.tipoFactura = res; |
384 | 384 | }); |
385 | 385 | } |
386 | 386 | }; |
387 | - $scope.seleccionarTipoComprobante = function(key) { | |
387 | + $scope.seleccionarTipoComprobante = function (key) { | |
388 | 388 | if (key === 13) { |
389 | 389 | var parametrosModal = { |
390 | 390 | searchText: $scope.cliente.tipoComprobante.NOMBRE, |
... | ... | @@ -403,17 +403,17 @@ angular.module('focaBusquedaCliente') |
403 | 403 | size: 'md' |
404 | 404 | }; |
405 | 405 | focaModalService.modal(parametrosModal).then( |
406 | - function(tipoComprobante) { | |
406 | + function (tipoComprobante) { | |
407 | 407 | $scope.cliente.tipoComprobante = tipoComprobante; |
408 | - $timeout(function() { | |
408 | + $timeout(function () { | |
409 | 409 | $scope.focused = 17; |
410 | 410 | }); |
411 | - }, function() { | |
411 | + }, function () { | |
412 | 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 | 417 | if (key === 13) { |
418 | 418 | var parametrosModal = { |
419 | 419 | searchText: $scope.cliente.formaPago.NOMBRE, |
... | ... | @@ -436,14 +436,14 @@ angular.module('focaBusquedaCliente') |
436 | 436 | size: 'md' |
437 | 437 | }; |
438 | 438 | focaModalService.modal(parametrosModal).then( |
439 | - function(formaPago) { | |
439 | + function (formaPago) { | |
440 | 440 | $scope.cliente.formaPago = formaPago; |
441 | - }, function() { | |
441 | + }, function () { | |
442 | 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 | 447 | if (key === 13) { |
448 | 448 | var parametrosModal = { |
449 | 449 | searchText: $scope.cliente.cobrador.NOM, |
... | ... | @@ -462,14 +462,14 @@ angular.module('focaBusquedaCliente') |
462 | 462 | size: 'md' |
463 | 463 | }; |
464 | 464 | focaModalService.modal(parametrosModal).then( |
465 | - function(cobrador) { | |
465 | + function (cobrador) { | |
466 | 466 | $scope.cliente.cobrador = cobrador; |
467 | - }, function() { | |
467 | + }, function () { | |
468 | 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 | 473 | if (key === 13) { |
474 | 474 | var parametrosModal = { |
475 | 475 | titulo: 'Búsqueda vendedores', |
... | ... | @@ -491,23 +491,23 @@ angular.module('focaBusquedaCliente') |
491 | 491 | size: 'md' |
492 | 492 | }; |
493 | 493 | focaModalService.modal(parametrosModal).then( |
494 | - function(vendedor) { | |
494 | + function (vendedor) { | |
495 | 495 | $scope.vendedor = vendedor; |
496 | - }, function() { | |
496 | + }, function () { | |
497 | 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 | 503 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { |
504 | 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 | 506 | $scope.cuitActivo = 3; |
507 | 507 | } |
508 | 508 | }; |
509 | 509 | |
510 | - $scope.guardar = function() { | |
510 | + $scope.guardar = function () { | |
511 | 511 | if (!$scope.cliente.NOM) { |
512 | 512 | focaModalService.alert('Ingrese Nombre'); |
513 | 513 | return; |
... | ... | @@ -547,10 +547,10 @@ angular.module('focaBusquedaCliente') |
547 | 547 | } else if (!$scope.cliente.cuit1 && !$scope.cliente.cuit2 && !$scope.cliente.cuit3) { |
548 | 548 | focaModalService.alert('Ingrese CUIT'); |
549 | 549 | return; |
550 | - } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3){ | |
550 | + } else if (!$scope.cliente.cuit1 || !$scope.cliente.cuit2 || !$scope.cliente.cuit3) { | |
551 | 551 | focaModalService.alert('Ingrese CUIT válido'); |
552 | 552 | return; |
553 | - } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3) ) { | |
553 | + } else if (!$scope.regexCuit.test($scope.cliente.cuit1 + $scope.cliente.cuit2 + $scope.cliente.cuit3)) { | |
554 | 554 | focaModalService.alert('Ingrese CUIT con formato: XX-XXXXXXXX-X'); |
555 | 555 | return; |
556 | 556 | } else if (!$scope.cliente.tipoComprobante.NOMBRE) { |
... | ... | @@ -565,7 +565,7 @@ angular.module('focaBusquedaCliente') |
565 | 565 | |
566 | 566 | focaBusquedaClienteService |
567 | 567 | .guardarCliente(cliente) |
568 | - .then(function(res) { | |
568 | + .then(function (res) { | |
569 | 569 | var cliente = { |
570 | 570 | cod: res.data.COD, |
571 | 571 | cuit: res.data.CUIT, |
... | ... | @@ -576,7 +576,7 @@ angular.module('focaBusquedaCliente') |
576 | 576 | }); |
577 | 577 | }; |
578 | 578 | |
579 | - function crearCopia(){ | |
579 | + function crearCopia() { | |
580 | 580 | var cliente = angular.copy($scope.cliente); |
581 | 581 | |
582 | 582 | cliente.PCX = cliente.provincia.ID; |
... | ... | @@ -612,7 +612,7 @@ angular.module('focaBusquedaCliente') |
612 | 612 | paginas.push(paginaActual); |
613 | 613 | |
614 | 614 | if (paginaActual - 1 > 1) { |
615 | - | |
615 | + | |
616 | 616 | paginas.unshift(paginaActual - 1); |
617 | 617 | if (paginaActual - 2 > 1) { |
618 | 618 | paginas.unshift(paginaActual - 2); |
... | ... | @@ -650,10 +650,10 @@ angular.module('focaBusquedaCliente') |
650 | 650 | } |
651 | 651 | |
652 | 652 | function siguiente() { |
653 | - if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { | |
653 | + if ($scope.selectedClientes < $scope.currentPageClientes.length - 1) { | |
654 | 654 | $scope.selectedClientes++; |
655 | 655 | } else { |
656 | - avanzarPagina(); | |
656 | + avanzarPagina(); | |
657 | 657 | } |
658 | 658 | } |
659 | 659 | |
... | ... | @@ -674,7 +674,7 @@ angular.module('focaBusquedaCliente') |
674 | 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,}))$/; |
675 | 675 | var arr = emails.split(','); |
676 | 676 | var result = true; |
677 | - arr.forEach(function(email) { | |
677 | + arr.forEach(function (email) { | |
678 | 678 | var val = String(email).trim().toLowerCase(); |
679 | 679 | if (!re.test(val)) result = false; |
680 | 680 | }); |