Commit 5cb462bd1c5de2e5817b00000f6717ef3f3e2b66

Authored by Marcelo Puebla
1 parent 2a7ec7e0d9
Exists in develop

Fix

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