Commit 2888ed0ea4c98cede1c4662e2c278c0dfcb88153

Authored by Benjamin Rodriguez
Exists in master and in 1 other branch develop

Merge branch 'develop' of http://git.focasoftware.com/npm/foca-busqueda-cliente

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