Commit 90642465ec290b8d2b247c7c5a4f0e4d0c366a33
1 parent
cf9baac986
Exists in
master
and in
1 other branch
busca por idvendedor o idcobrador
Showing
2 changed files
with
20 additions
and
7 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaBusquedaCliente') | 1 | angular.module('focaBusquedaCliente') |
2 | .controller('focaBusquedaClienteModalController', [ | 2 | .controller('focaBusquedaClienteModalController', [ |
3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', | 3 | '$uibModalInstance', 'focaBusquedaClienteService', '$scope', '$filter', |
4 | '$uibModal', 'focaModalService', '$timeout', 'vendedor', | 4 | '$uibModal', 'focaModalService', '$timeout', 'vendedor', 'cobrador', |
5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | 5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, |
6 | $uibModal, focaModalService, $timeout, vendedor) { | 6 | $uibModal, focaModalService, $timeout, vendedor, cobrador) { |
7 | 7 | ||
8 | $scope.cobrador = cobrador; | ||
8 | $scope.vendedor = vendedor ? vendedor : {}; | 9 | $scope.vendedor = vendedor ? vendedor : {}; |
9 | $scope.filters = ''; | 10 | $scope.filters = ''; |
10 | $scope.primerBusqueda = false; | 11 | $scope.primerBusqueda = false; |
11 | // pagination | 12 | // pagination |
12 | $scope.numPerPage = 10; | 13 | $scope.numPerPage = 10; |
13 | $scope.currentPage = 1; | 14 | $scope.currentPage = 1; |
14 | $scope.filteredClientes = []; | 15 | $scope.filteredClientes = []; |
15 | $scope.currentPageClientes = []; | 16 | $scope.currentPageClientes = []; |
16 | $scope.selectedClientes = -1; | 17 | $scope.selectedClientes = -1; |
17 | $scope.ingreso = false; | 18 | $scope.ingreso = false; |
18 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); | 19 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); |
19 | $scope.focused = 1; | 20 | $scope.focused = 1; |
20 | 21 | ||
21 | $scope.cliente = { | 22 | $scope.cliente = { |
22 | COD: 0, | 23 | COD: 0, |
23 | ES_MAY: true, | 24 | ES_MAY: true, |
24 | provincia: { | 25 | provincia: { |
25 | NOMBRE: '' | 26 | NOMBRE: '' |
26 | }, | 27 | }, |
27 | localidad: { | 28 | localidad: { |
28 | NOMBRE: '' | 29 | NOMBRE: '' |
29 | }, | 30 | }, |
30 | iva: { | 31 | iva: { |
31 | NOMBRE: '' | 32 | NOMBRE: '' |
32 | }, | 33 | }, |
33 | actividad: { | 34 | actividad: { |
34 | NOM: '' | 35 | NOM: '' |
35 | }, | 36 | }, |
36 | zona: { | 37 | zona: { |
37 | NOM: '' | 38 | NOM: '' |
38 | }, | 39 | }, |
39 | tipoFactura: { | 40 | tipoFactura: { |
40 | NOMBRE: '' | 41 | NOMBRE: '' |
41 | }, | 42 | }, |
42 | tipoComprobante: { | 43 | tipoComprobante: { |
43 | NOMBRE: '' | 44 | NOMBRE: '' |
44 | }, | 45 | }, |
45 | formaPago: { | 46 | formaPago: { |
46 | NOMBRE: '' | 47 | NOMBRE: '' |
47 | }, | 48 | }, |
48 | cobrador: { | 49 | cobrador: { |
49 | NomVen: '' | 50 | NomVen: '' |
50 | } | 51 | } |
51 | }; | 52 | }; |
52 | 53 | ||
53 | $scope.busquedaPress = function(key) { | 54 | $scope.busquedaPress = function(key) { |
54 | if (key === 13) { | 55 | if (key === 13) { |
55 | var funcion = ($scope.vendedor.id) ? | 56 | var funcion; |
56 | 'obtenerClientesPorNombreOCuitByVendedor' : 'obtenerClientesPorNombreOCuit'; | 57 | if($scope.vendedor.id) { |
58 | funcion = 'obtenerClientesPorNombreOCuitByVendedor'; | ||
59 | } else if ($scope.cobrador.id) { | ||
60 | funcion = 'obtenerClientesPorNombreOCuitByCobrador'; | ||
61 | } else { | ||
62 | funcion = 'obtenerClientesPorNombreOCuit'; | ||
63 | } | ||
64 | |||
57 | 65 | ||
58 | $scope.searchLoading = true; | 66 | $scope.searchLoading = true; |
59 | focaBusquedaClienteService | 67 | focaBusquedaClienteService |
60 | [funcion]($scope.filters, $scope.vendedor.id) | 68 | [funcion]($scope.filters, $scope.vendedor.id || $scope.cobrador.id) |
61 | .then( | 69 | .then( |
62 | function(res) { | 70 | function(res) { |
63 | $scope.primerBusqueda = true; | 71 | $scope.primerBusqueda = true; |
64 | $scope.clientes = res.data; | 72 | $scope.clientes = res.data; |
65 | $scope.search(true); | 73 | $scope.search(true); |
66 | primera(); | 74 | primera(); |
67 | $scope.searchLoading = false; | 75 | $scope.searchLoading = false; |
68 | }); | 76 | }); |
69 | } | 77 | } |
70 | }; | 78 | }; |
71 | 79 | ||
72 | $scope.search = function (pressed) { | 80 | $scope.search = function (pressed) { |
73 | if($scope.primerBusqueda) { | 81 | if($scope.primerBusqueda) { |
74 | $scope.filteredClientes = $filter('filter')( | 82 | $scope.filteredClientes = $filter('filter')( |
75 | $scope.clientes, {$: $scope.filters} | 83 | $scope.clientes, {$: $scope.filters} |
76 | ); | 84 | ); |
77 | 85 | ||
78 | if(pressed && $scope.filteredClientes.length === 0){ | 86 | if(pressed && $scope.filteredClientes.length === 0){ |
79 | $timeout(function() { | 87 | $timeout(function() { |
80 | angular.element('#search')[0].focus(); | 88 | angular.element('#search')[0].focus(); |
81 | $scope.filters = ''; | 89 | $scope.filters = ''; |
82 | }); | 90 | }); |
83 | } | 91 | } |
84 | 92 | ||
85 | $scope.lastPage = Math.ceil( | 93 | $scope.lastPage = Math.ceil( |
86 | $scope.filteredClientes.length / $scope.numPerPage | 94 | $scope.filteredClientes.length / $scope.numPerPage |
87 | ); | 95 | ); |
88 | 96 | ||
89 | $scope.resetPage(); | 97 | $scope.resetPage(); |
90 | } | 98 | } |
91 | }; | 99 | }; |
92 | 100 | ||
93 | $scope.resetPage = function () { | 101 | $scope.resetPage = function () { |
94 | $scope.currentPage = 1; | 102 | $scope.currentPage = 1; |
95 | $scope.selectPage(1); | 103 | $scope.selectPage(1); |
96 | }; | 104 | }; |
97 | 105 | ||
98 | $scope.selectPage = function (page) { | 106 | $scope.selectPage = function (page) { |
99 | var start = (page - 1) * $scope.numPerPage; | 107 | var start = (page - 1) * $scope.numPerPage; |
100 | var end = start + $scope.numPerPage; | 108 | var end = start + $scope.numPerPage; |
101 | $scope.paginas = []; | 109 | $scope.paginas = []; |
102 | $scope.paginas = calcularPages(page); | 110 | $scope.paginas = calcularPages(page); |
103 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); | 111 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); |
104 | $scope.currentPage = page; | 112 | $scope.currentPage = page; |
105 | }; | 113 | }; |
106 | 114 | ||
107 | $scope.select = function(cliente, esNuevo = false) { | 115 | $scope.select = function(cliente, esNuevo = false) { |
108 | cliente.esNuevo = esNuevo; | 116 | cliente.esNuevo = esNuevo; |
109 | $uibModalInstance.close(cliente); | 117 | $uibModalInstance.close(cliente); |
110 | }; | 118 | }; |
111 | 119 | ||
112 | $scope.cancel = function() { | 120 | $scope.cancel = function() { |
113 | if($scope.ingreso) { | 121 | if($scope.ingreso) { |
114 | $scope.ingreso = false; | 122 | $scope.ingreso = false; |
115 | }else { | 123 | }else { |
116 | $uibModalInstance.dismiss('cancel'); | 124 | $uibModalInstance.dismiss('cancel'); |
117 | } | 125 | } |
118 | }; | 126 | }; |
119 | 127 | ||
120 | $scope.busquedaDown = function(key) { | 128 | $scope.busquedaDown = function(key) { |
121 | if (key === 40) { | 129 | if (key === 40) { |
122 | primera(key); | 130 | primera(key); |
123 | } | 131 | } |
124 | }; | 132 | }; |
125 | 133 | ||
126 | $scope.itemCliente = function(key) { | 134 | $scope.itemCliente = function(key) { |
127 | if (key === 38) { | 135 | if (key === 38) { |
128 | anterior(key); | 136 | anterior(key); |
129 | } | 137 | } |
130 | 138 | ||
131 | if (key === 40) { | 139 | if (key === 40) { |
132 | siguiente(key); | 140 | siguiente(key); |
133 | } | 141 | } |
134 | 142 | ||
135 | if (key === 37) { | 143 | if (key === 37) { |
136 | retrocederPagina(); | 144 | retrocederPagina(); |
137 | } | 145 | } |
138 | 146 | ||
139 | if (key === 39) { | 147 | if (key === 39) { |
140 | avanzarPagina(); | 148 | avanzarPagina(); |
141 | } | 149 | } |
142 | }; | 150 | }; |
143 | 151 | ||
144 | $scope.focus = function(val) { | 152 | $scope.focus = function(val) { |
145 | $scope.focused = val; | 153 | $scope.focused = val; |
146 | }; | 154 | }; |
147 | 155 | ||
148 | $scope.next = function(key) { | 156 | $scope.next = function(key) { |
149 | if (key === 13) $scope.focused++; | 157 | if (key === 13) $scope.focused++; |
150 | }; | 158 | }; |
151 | 159 | ||
152 | $scope.seleccionarProvincia = function(key) { | 160 | $scope.seleccionarProvincia = function(key) { |
153 | if(key === 13) { | 161 | if(key === 13) { |
154 | var parametrosModal = { | 162 | var parametrosModal = { |
155 | query: '/provincia', | 163 | query: '/provincia', |
156 | columnas: [ | 164 | columnas: [ |
157 | { | 165 | { |
158 | propiedad: 'ID', | 166 | propiedad: 'ID', |
159 | nombre: 'Codigo', | 167 | nombre: 'Codigo', |
160 | filtro: { | 168 | filtro: { |
161 | nombre: 'rellenarDigitos', | 169 | nombre: 'rellenarDigitos', |
162 | parametro: 3} | 170 | parametro: 3 |
163 | }, | 171 | } |
172 | }, | ||
164 | { | 173 | { |
165 | propiedad: 'NOMBRE', | 174 | propiedad: 'NOMBRE', |
166 | nombre: 'Nombre' | 175 | nombre: 'Nombre' |
167 | } | 176 | } |
168 | ], | 177 | ], |
169 | titulo:'Búsqueda de provincias', | 178 | titulo:'Búsqueda de provincias', |
170 | size: 'md' | 179 | size: 'md' |
171 | }; | 180 | }; |
172 | focaModalService.modal(parametrosModal).then(function(provincia) { | 181 | focaModalService.modal(parametrosModal).then(function(provincia) { |
173 | $scope.cliente.provincia = provincia; | 182 | $scope.cliente.provincia = provincia; |
174 | $timeout(function() { | 183 | $timeout(function() { |
175 | $scope.focused = 5; | 184 | $scope.focused = 5; |
176 | }); | 185 | }); |
177 | }, function() { | 186 | }, function() { |
178 | //TODO: función llamada cuando cancela el modal | 187 | //TODO: función llamada cuando cancela el modal |
179 | }); | 188 | }); |
180 | } | 189 | } |
181 | }; | 190 | }; |
182 | $scope.seleccionarLocalidad = function(key) { | 191 | $scope.seleccionarLocalidad = function(key) { |
183 | if($scope.cliente.provincia.ID === undefined) { | 192 | if($scope.cliente.provincia.ID === undefined) { |
184 | focaModalService.alert('Seleccione una provincia'); | 193 | focaModalService.alert('Seleccione una provincia'); |
185 | return; | 194 | return; |
186 | } | 195 | } |
187 | if(key === 13) { | 196 | if(key === 13) { |
188 | var parametrosModal = { | 197 | var parametrosModal = { |
189 | query: '/localidad/' + $scope.cliente.provincia.ID, | 198 | query: '/localidad/' + $scope.cliente.provincia.ID, |
190 | columnas: [ | 199 | columnas: [ |
191 | { | 200 | { |
192 | propiedad: 'ID', | 201 | propiedad: 'ID', |
193 | nombre: 'Código', | 202 | nombre: 'Código', |
194 | filtro: { | 203 | filtro: { |
195 | nombre: 'rellenarDigitos', | 204 | nombre: 'rellenarDigitos', |
196 | parametro: 3 | 205 | parametro: 3 |
197 | } | 206 | } |
198 | }, | 207 | }, |
199 | { | 208 | { |
200 | propiedad: 'NOMBRE', | 209 | propiedad: 'NOMBRE', |
201 | nombre: 'Nombre' | 210 | nombre: 'Nombre' |
202 | } | 211 | } |
203 | ], | 212 | ], |
204 | titulo:'Búsqueda de localidades', | 213 | titulo:'Búsqueda de localidades', |
205 | size: 'md' | 214 | size: 'md' |
206 | }; | 215 | }; |
207 | focaModalService.modal(parametrosModal).then(function(localidad) { | 216 | focaModalService.modal(parametrosModal).then(function(localidad) { |
208 | $scope.cliente.localidad = localidad; | 217 | $scope.cliente.localidad = localidad; |
209 | $timeout(function() { | 218 | $timeout(function() { |
210 | $scope.focused = 6; | 219 | $scope.focused = 6; |
211 | }); | 220 | }); |
212 | }, function() { | 221 | }, function() { |
213 | //TODO: función llamada cuando cancela el modal | 222 | //TODO: función llamada cuando cancela el modal |
214 | }); | 223 | }); |
215 | } | 224 | } |
216 | }; | 225 | }; |
217 | $scope.seleccionarIva = function(key) { | 226 | $scope.seleccionarIva = function(key) { |
218 | if(key === 13) { | 227 | if(key === 13) { |
219 | var parametrosModal = { | 228 | var parametrosModal = { |
220 | query: '/iva', | 229 | query: '/iva', |
221 | columnas: [ | 230 | columnas: [ |
222 | { | 231 | { |
223 | propiedad: 'ID', | 232 | propiedad: 'ID', |
224 | nombre: 'Código', | 233 | nombre: 'Código', |
225 | filtro: { | 234 | filtro: { |
226 | nombre: 'rellenarDigitos', | 235 | nombre: 'rellenarDigitos', |
227 | parametro: 3 | 236 | parametro: 3 |
228 | } | 237 | } |
229 | }, | 238 | }, |
230 | { | 239 | { |
231 | propiedad: 'NOMBRE', | 240 | propiedad: 'NOMBRE', |
232 | nombre: 'Nombre' | 241 | nombre: 'Nombre' |
233 | } | 242 | } |
234 | ], | 243 | ], |
235 | titulo:'Búsqueda de responsabilidad ante el IVA', | 244 | titulo:'Búsqueda de responsabilidad ante el IVA', |
236 | size: 'md' | 245 | size: 'md' |
237 | }; | 246 | }; |
238 | focaModalService.modal(parametrosModal).then( | 247 | focaModalService.modal(parametrosModal).then( |
239 | function(iva) { | 248 | function(iva) { |
240 | $scope.cliente.iva = iva; | 249 | $scope.cliente.iva = iva; |
241 | $timeout(function() { | 250 | $timeout(function() { |
242 | $scope.focused = 10; | 251 | $scope.focused = 10; |
243 | }); | 252 | }); |
244 | }, function() { | 253 | }, function() { |
245 | // funcion ejecutada cuando se cancela el modal | 254 | // funcion ejecutada cuando se cancela el modal |
246 | }); | 255 | }); |
247 | } | 256 | } |
248 | }; | 257 | }; |
249 | $scope.seleccionarActividad = function(key) { | 258 | $scope.seleccionarActividad = function(key) { |
250 | if(key === 13) { | 259 | if(key === 13) { |
251 | var parametrosModal = { | 260 | var parametrosModal = { |
252 | query: '/actividad', | 261 | query: '/actividad', |
253 | columnas: [ | 262 | columnas: [ |
254 | { | 263 | { |
255 | propiedad: 'ID', | 264 | propiedad: 'ID', |
256 | nombre: 'Código', | 265 | nombre: 'Código', |
257 | filtro: { | 266 | filtro: { |
258 | nombre: 'rellenarDigitos', | 267 | nombre: 'rellenarDigitos', |
259 | parametro: 3 | 268 | parametro: 3 |
260 | } | 269 | } |
261 | }, | 270 | }, |
262 | { | 271 | { |
263 | propiedad: 'NOM', | 272 | propiedad: 'NOM', |
264 | nombre: 'Nombre' | 273 | nombre: 'Nombre' |
265 | } | 274 | } |
266 | ], | 275 | ], |
267 | titulo: 'Búsqueda de actividades', | 276 | titulo: 'Búsqueda de actividades', |
268 | size: 'md' | 277 | size: 'md' |
269 | }; | 278 | }; |
270 | focaModalService.modal(parametrosModal).then( | 279 | focaModalService.modal(parametrosModal).then( |
271 | function(actividad) { | 280 | function(actividad) { |
272 | $scope.cliente.actividad = actividad; | 281 | $scope.cliente.actividad = actividad; |
273 | $timeout(function() { | 282 | $timeout(function() { |
274 | $scope.focused = 8; | 283 | $scope.focused = 8; |
275 | }); | 284 | }); |
276 | }, function() { | 285 | }, function() { |
277 | // funcion ejecutada cuando se cancela el modal | 286 | // funcion ejecutada cuando se cancela el modal |
278 | }); | 287 | }); |
279 | } | 288 | } |
280 | }; | 289 | }; |
281 | $scope.seleccionarZona = function(key) { | 290 | $scope.seleccionarZona = function(key) { |
282 | if(key === 13) { | 291 | if(key === 13) { |
283 | var parametrosModal = { | 292 | var parametrosModal = { |
284 | query: '/zona', | 293 | query: '/zona', |
285 | columnas: [ | 294 | columnas: [ |
286 | { | 295 | { |
287 | propiedad: 'ID', | 296 | propiedad: 'ID', |
288 | nombre: 'Código', | 297 | nombre: 'Código', |
289 | filtro: { | 298 | filtro: { |
290 | nombre: 'rellenarDigitos', | 299 | nombre: 'rellenarDigitos', |
291 | parametro: 3 | 300 | parametro: 3 |
292 | } | 301 | } |
293 | }, | 302 | }, |
294 | { | 303 | { |
295 | propiedad: 'NOM', | 304 | propiedad: 'NOM', |
296 | nombre: 'Nombre' | 305 | nombre: 'Nombre' |
297 | } | 306 | } |
298 | ], | 307 | ], |
299 | titulo: 'Búsqueda de zonas', | 308 | titulo: 'Búsqueda de zonas', |
300 | size: 'md' | 309 | size: 'md' |
301 | }; | 310 | }; |
302 | focaModalService.modal(parametrosModal).then( | 311 | focaModalService.modal(parametrosModal).then( |
303 | function(zona) { | 312 | function(zona) { |
304 | $scope.cliente.zona = zona; | 313 | $scope.cliente.zona = zona; |
305 | $timeout(function() { | 314 | $timeout(function() { |
306 | $scope.focused = 7; | 315 | $scope.focused = 7; |
307 | }); | 316 | }); |
308 | }, function() { | 317 | }, function() { |
309 | // funcion ejecutada cuando se cancela el modal | 318 | // funcion ejecutada cuando se cancela el modal |
310 | }); | 319 | }); |
311 | } | 320 | } |
312 | }; | 321 | }; |
313 | $scope.seleccionarTipoFactura = function(key) { | 322 | $scope.seleccionarTipoFactura = function(key) { |
314 | if(key === 13) { | 323 | if(key === 13) { |
315 | var parametrosModal = { | 324 | var parametrosModal = { |
316 | query: '/tipo-factura', | 325 | query: '/tipo-factura', |
317 | columnas: [ | 326 | columnas: [ |
318 | { | 327 | { |
319 | propiedad: 'ID', | 328 | propiedad: 'ID', |
320 | nombre: 'Código' | 329 | nombre: 'Código' |
321 | }, | 330 | }, |
322 | { | 331 | { |
323 | propiedad: 'NOMBRE', | 332 | propiedad: 'NOMBRE', |
324 | nombre: 'Nombre' | 333 | nombre: 'Nombre' |
325 | } | 334 | } |
326 | ], | 335 | ], |
327 | titulo: 'Búsqueda de tipos de factura', | 336 | titulo: 'Búsqueda de tipos de factura', |
328 | size: 'md' | 337 | size: 'md' |
329 | }; | 338 | }; |
330 | focaModalService.modal(parametrosModal).then( | 339 | focaModalService.modal(parametrosModal).then( |
331 | function(tipoFactura) { | 340 | function(tipoFactura) { |
332 | $scope.cliente.tipoFactura = tipoFactura; | 341 | $scope.cliente.tipoFactura = tipoFactura; |
333 | $timeout(function() { | 342 | $timeout(function() { |
334 | $scope.focused = 11; | 343 | $scope.focused = 11; |
335 | }); | 344 | }); |
336 | }, function() { | 345 | }, function() { |
337 | // funcion ejecutada cuando se cancela el modal | 346 | // funcion ejecutada cuando se cancela el modal |
338 | }); | 347 | }); |
339 | } | 348 | } |
340 | }; | 349 | }; |
341 | $scope.seleccionarTipoComprobante = function(key) { | 350 | $scope.seleccionarTipoComprobante = function(key) { |
342 | if(key === 13) { | 351 | if(key === 13) { |
343 | var parametrosModal = { | 352 | var parametrosModal = { |
344 | query: '/tipo-comprobante', | 353 | query: '/tipo-comprobante', |
345 | columnas: [ | 354 | columnas: [ |
346 | { | 355 | { |
347 | propiedad: 'ID', | 356 | propiedad: 'ID', |
348 | nombre: 'Código' | 357 | nombre: 'Código' |
349 | }, | 358 | }, |
350 | { | 359 | { |
351 | propiedad: 'NOMBRE', | 360 | propiedad: 'NOMBRE', |
352 | nombre: 'Nombre' | 361 | nombre: 'Nombre' |
353 | } | 362 | } |
354 | ], | 363 | ], |
355 | titulo: 'Búsqueda de tipos de comprobante', | 364 | titulo: 'Búsqueda de tipos de comprobante', |
356 | size: 'md' | 365 | size: 'md' |
357 | }; | 366 | }; |
358 | focaModalService.modal(parametrosModal).then( | 367 | focaModalService.modal(parametrosModal).then( |
359 | function(tipoComprobante) { | 368 | function(tipoComprobante) { |
360 | $scope.cliente.tipoComprobante = tipoComprobante; | 369 | $scope.cliente.tipoComprobante = tipoComprobante; |
361 | $timeout(function() { | 370 | $timeout(function() { |
362 | $scope.focused = 13; | 371 | $scope.focused = 13; |
363 | }); | 372 | }); |
364 | }, function() { | 373 | }, function() { |
365 | // funcion ejecutada cuando se cancela el modal | 374 | // funcion ejecutada cuando se cancela el modal |
366 | }); | 375 | }); |
367 | } | 376 | } |
368 | }; | 377 | }; |
369 | $scope.seleccionarFormaPago = function(key) { | 378 | $scope.seleccionarFormaPago = function(key) { |
370 | if(key === 13) { | 379 | if(key === 13) { |
371 | var parametrosModal = { | 380 | var parametrosModal = { |
372 | query: '/forma-pago', | 381 | query: '/forma-pago', |
373 | columnas: [ | 382 | columnas: [ |
374 | { | 383 | { |
375 | propiedad: 'ID', | 384 | propiedad: 'ID', |
376 | nombre: 'Código', | 385 | nombre: 'Código', |
377 | filtro: { | 386 | filtro: { |
378 | nombre: 'rellenarDigitos', | 387 | nombre: 'rellenarDigitos', |
379 | parametro: 3 | 388 | parametro: 3 |
380 | } | 389 | } |
381 | }, | 390 | }, |
382 | { | 391 | { |
383 | propiedad: 'NOMBRE', | 392 | propiedad: 'NOMBRE', |
384 | nombre: 'Nombre' | 393 | nombre: 'Nombre' |
385 | } | 394 | } |
386 | ], | 395 | ], |
387 | titulo: 'Búsqueda de formas de pago', | 396 | titulo: 'Búsqueda de formas de pago', |
388 | size: 'md' | 397 | size: 'md' |
389 | }; | 398 | }; |
390 | focaModalService.modal(parametrosModal).then( | 399 | focaModalService.modal(parametrosModal).then( |
391 | function(formaPago) { | 400 | function(formaPago) { |
392 | $scope.cliente.formaPago = formaPago; | 401 | $scope.cliente.formaPago = formaPago; |
393 | }, function() { | 402 | }, function() { |
394 | // funcion ejecutada cuando se cancela el modal | 403 | // funcion ejecutada cuando se cancela el modal |
395 | }); | 404 | }); |
396 | } | 405 | } |
397 | }; | 406 | }; |
398 | $scope.seleccionarCobrador = function(key) { | 407 | $scope.seleccionarCobrador = function(key) { |
399 | if(key === 13) { | 408 | if(key === 13) { |
400 | var parametrosModal = { | 409 | var parametrosModal = { |
401 | query: '/cobrador', | 410 | query: '/cobrador', |
402 | columnas: [ | 411 | columnas: [ |
403 | { | 412 | { |
404 | propiedad: 'NUM', | 413 | propiedad: 'NUM', |
405 | nombre: 'Código' | 414 | nombre: 'Código' |
406 | }, | 415 | }, |
407 | { | 416 | { |
408 | propiedad: 'NOM', | 417 | propiedad: 'NOM', |
409 | nombre: 'Nombre' | 418 | nombre: 'Nombre' |
410 | } | 419 | } |
411 | ], | 420 | ], |
412 | titulo: 'Búsqueda de cobradores', | 421 | titulo: 'Búsqueda de cobradores', |
413 | size: 'md' | 422 | size: 'md' |
414 | }; | 423 | }; |
415 | focaModalService.modal(parametrosModal).then( | 424 | focaModalService.modal(parametrosModal).then( |
416 | function(cobrador) { | 425 | function(cobrador) { |
417 | $scope.cliente.cobrador = cobrador; | 426 | $scope.cliente.cobrador = cobrador; |
418 | }, function() { | 427 | }, function() { |
419 | // funcion ejecutada cuando se cancela el modal | 428 | // funcion ejecutada cuando se cancela el modal |
420 | }); | 429 | }); |
421 | } | 430 | } |
422 | }; | 431 | }; |
423 | 432 | ||
424 | $scope.guardar = function() { | 433 | $scope.guardar = function() { |
425 | 434 | ||
426 | $scope.cliente.PCX = $scope.cliente.provincia.ID; | 435 | $scope.cliente.PCX = $scope.cliente.provincia.ID; |
427 | $scope.cliente.LOX = $scope.cliente.localidad.ID; | 436 | $scope.cliente.LOX = $scope.cliente.localidad.ID; |
428 | $scope.cliente.IVA = $scope.cliente.iva.ID; | 437 | $scope.cliente.IVA = $scope.cliente.iva.ID; |
429 | $scope.cliente.ACT = $scope.cliente.actividad.ID; | 438 | $scope.cliente.ACT = $scope.cliente.actividad.ID; |
430 | $scope.cliente.ZON = $scope.cliente.zona.ID; | 439 | $scope.cliente.ZON = $scope.cliente.zona.ID; |
431 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; | 440 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; |
432 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; | 441 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; |
433 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; | 442 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; |
434 | $scope.cliente.VEN = $scope.vendedor.id; | 443 | $scope.cliente.VEN = $scope.vendedor.id; |
435 | $scope.cliente.idCobrador = $scope.cliente.cobrador.id; | 444 | $scope.cliente.idCobrador = $scope.cliente.cobrador.id; |
436 | 445 | ||
437 | delete $scope.cliente.provincia; | 446 | delete $scope.cliente.provincia; |
438 | delete $scope.cliente.localidad; | 447 | delete $scope.cliente.localidad; |
439 | delete $scope.cliente.iva; | 448 | delete $scope.cliente.iva; |
440 | delete $scope.cliente.actividad; | 449 | delete $scope.cliente.actividad; |
441 | delete $scope.cliente.zona; | 450 | delete $scope.cliente.zona; |
442 | delete $scope.cliente.tipoFactura; | 451 | delete $scope.cliente.tipoFactura; |
443 | delete $scope.cliente.tipoComprobante; | 452 | delete $scope.cliente.tipoComprobante; |
444 | delete $scope.cliente.formaPago; | 453 | delete $scope.cliente.formaPago; |
445 | delete $scope.cliente.cobrador; | 454 | delete $scope.cliente.cobrador; |
446 | 455 | ||
447 | focaBusquedaClienteService | 456 | focaBusquedaClienteService |
448 | .guardarCliente($scope.cliente) | 457 | .guardarCliente($scope.cliente) |
449 | .then(function(res) { | 458 | .then(function(res) { |
450 | var cliente = { | 459 | var cliente = { |
451 | cod: res.data.COD, | 460 | cod: res.data.COD, |
452 | cuit: res.data.CUIT, | 461 | cuit: res.data.CUIT, |
453 | esNuevo: res.data.esNuevo, | 462 | esNuevo: res.data.esNuevo, |
454 | nom: res.data.NOM | 463 | nom: res.data.NOM |
455 | }; | 464 | }; |
456 | $scope.select(cliente, true); | 465 | $scope.select(cliente, true); |
457 | }); | 466 | }); |
458 | }; | 467 | }; |
459 | 468 | ||
460 | function calcularPages(paginaActual) { | 469 | function calcularPages(paginaActual) { |
461 | var paginas = []; | 470 | var paginas = []; |
462 | paginas.push(paginaActual); | 471 | paginas.push(paginaActual); |
463 | 472 | ||
464 | if (paginaActual - 1 > 1) { | 473 | if (paginaActual - 1 > 1) { |
465 | 474 | ||
466 | paginas.unshift(paginaActual - 1); | 475 | paginas.unshift(paginaActual - 1); |
467 | if (paginaActual - 2 > 1) { | 476 | if (paginaActual - 2 > 1) { |
468 | paginas.unshift(paginaActual - 2); | 477 | paginas.unshift(paginaActual - 2); |
469 | } | 478 | } |
470 | } | 479 | } |
471 | 480 | ||
472 | if (paginaActual + 1 < $scope.lastPage) { | 481 | if (paginaActual + 1 < $scope.lastPage) { |
473 | paginas.push(paginaActual + 1); | 482 | paginas.push(paginaActual + 1); |
474 | if (paginaActual + 2 < $scope.lastPage) { | 483 | if (paginaActual + 2 < $scope.lastPage) { |
475 | paginas.push(paginaActual + 2); | 484 | paginas.push(paginaActual + 2); |
476 | } | 485 | } |
477 | } | 486 | } |
478 | 487 | ||
479 | if (paginaActual !== 1) { | 488 | if (paginaActual !== 1) { |
480 | paginas.unshift(1); | 489 | paginas.unshift(1); |
481 | } | 490 | } |
482 | 491 | ||
483 | if (paginaActual !== $scope.lastPage) { | 492 | if (paginaActual !== $scope.lastPage) { |
484 | paginas.push($scope.lastPage); | 493 | paginas.push($scope.lastPage); |
485 | } | 494 | } |
486 | 495 | ||
487 | return paginas; | 496 | return paginas; |
488 | } | 497 | } |
489 | 498 | ||
490 | function primera() { | 499 | function primera() { |
491 | $scope.selectedClientes = 0; | 500 | $scope.selectedClientes = 0; |
492 | } | 501 | } |
493 | 502 | ||
494 | function anterior() { | 503 | function anterior() { |
495 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { | 504 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { |
496 | retrocederPagina(); | 505 | retrocederPagina(); |
497 | } else { | 506 | } else { |
498 | $scope.selectedClientes--; | 507 | $scope.selectedClientes--; |
499 | } | 508 | } |
500 | } | 509 | } |
501 | 510 | ||
502 | function siguiente() { | 511 | function siguiente() { |
503 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { | 512 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { |
504 | $scope.selectedClientes++; | 513 | $scope.selectedClientes++; |
505 | } else { | 514 | } else { |
506 | avanzarPagina(); | 515 | avanzarPagina(); |
507 | } | 516 | } |
508 | } | 517 | } |
509 | 518 | ||
510 | function retrocederPagina() { | 519 | function retrocederPagina() { |
511 | if ($scope.currentPage > 1) { | 520 | if ($scope.currentPage > 1) { |
512 | $scope.selectPage($scope.currentPage - 1); | 521 | $scope.selectPage($scope.currentPage - 1); |
513 | $scope.selectedClientes = $scope.numPerPage - 1; | 522 | $scope.selectedClientes = $scope.numPerPage - 1; |
514 | } | 523 | } |
515 | } | 524 | } |
516 | 525 | ||
517 | function avanzarPagina() { | 526 | function avanzarPagina() { |
518 | if ($scope.currentPage < $scope.lastPage) { | 527 | if ($scope.currentPage < $scope.lastPage) { |
519 | $scope.selectPage($scope.currentPage + 1); | 528 | $scope.selectPage($scope.currentPage + 1); |
520 | $scope.selectedClientes = 0; | 529 | $scope.selectedClientes = 0; |
521 | } | 530 | } |
522 | } | 531 | } |
523 | } | 532 | } |
524 | ]); | 533 | ]); |
525 | 534 |
src/js/service.js
1 | angular.module('focaBusquedaCliente') | 1 | angular.module('focaBusquedaCliente') |
2 | .service('focaBusquedaClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('focaBusquedaClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | return { | 3 | return { |
4 | obtenerClientesPorNombreOCuitByVendedor: function(nombreOCuit, idVendedor) { | 4 | obtenerClientesPorNombreOCuitByVendedor: function(nombreOCuit, idVendedor) { |
5 | return $http.post(API_ENDPOINT.URL + '/cliente/listar', | 5 | return $http.post(API_ENDPOINT.URL + '/cliente/listar', |
6 | {nombreOCuit: nombreOCuit, idVendedor: idVendedor}); | 6 | {nombreOCuit: nombreOCuit, idVendedor: idVendedor}); |
7 | }, | 7 | }, |
8 | obtenerClientesPorNombreOCuitByCobrador: function(nombreOCuit, idCobrador) { | ||
9 | return $http.post(API_ENDPOINT.URL + '/cliente/listar', | ||
10 | {nombreOCuit: nombreOCuit, idCobrador: idCobrador}); | ||
11 | }, | ||
8 | obtenerClientesPorNombreOCuit: function(nombreOCuit) { | 12 | obtenerClientesPorNombreOCuit: function(nombreOCuit) { |
9 | return $http.post(API_ENDPOINT.URL + '/cliente/listar', | 13 | return $http.post(API_ENDPOINT.URL + '/cliente/listar', |
10 | {nombreOCuit: nombreOCuit}); | 14 | {nombreOCuit: nombreOCuit}); |
11 | }, | 15 | }, |
12 | guardarCliente: function(cliente) { | 16 | guardarCliente: function(cliente) { |
13 | return $http.post(API_ENDPOINT.URL + '/cliente', {cliente: cliente}); | 17 | return $http.post(API_ENDPOINT.URL + '/cliente', {cliente: cliente}); |
14 | } | 18 | } |
15 | }; | 19 | }; |
16 | }]); | 20 | }]); |
17 | 21 |