Commit 98ac776ac3ae7ab284b0f23094f3b67662a932d5
Exists in
master
Merge remote-tracking branch 'origin/master'
Showing
5 changed files
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "foca-busqueda-cliente", | 2 | "name": "foca-busqueda-cliente", |
3 | "version": "1.0.0", | 3 | "version": "1.0.0", |
4 | "description": "Búsqueda de clientes", | 4 | "description": "Búsqueda de clientes", |
5 | "main": "dist/foca-abm-sectores.js", | 5 | "main": "dist/foca-abm-sectores.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
9 | "postinstall": "npm run compile && gulp clean-post-install", | 9 | "postinstall": "npm run compile && gulp clean-post-install", |
10 | "install-dev": "npm install -D angular bootstrap angular-ladda ladda@1.0.6 angular-ui-bootstrap ui-bootstrap4 font-awesome jquery pre-commit jshint pump jasmine-core gulp gulp-connect gulp-angular-templatecache gulp-concat gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean gulp-uglify git+https://debo.suite.repo/modulos-npm/foca-directivas.git" | 10 | "install-dev": "npm install -D angular bootstrap angular-ladda ladda@1.0.6 angular-ui-bootstrap ui-bootstrap4 font-awesome jquery pre-commit jshint pump jasmine-core gulp gulp-connect gulp-angular-templatecache gulp-concat gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es gulp-clean gulp-uglify git+http://git.focasoftware.com/npm/foca-directivas.git" |
11 | }, | 11 | }, |
12 | "repository": { | 12 | "repository": { |
13 | "type": "git", | 13 | "type": "git", |
14 | "url": "https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git" | 14 | "url": "http://git.focasoftware.com/npm/foca-busqueda-cliente.git" |
15 | }, | 15 | }, |
16 | "author": "Foca Software", | 16 | "author": "Foca Software", |
17 | "license": "ISC", | 17 | "license": "ISC", |
18 | "peerDependencies": { | 18 | "peerDependencies": { |
19 | "angular": "^1.7.x", | 19 | "angular": "^1.7.x", |
20 | "bootstrap": "^4.1.x", | 20 | "bootstrap": "^4.1.x", |
21 | "jquery": "^3.3.x", | 21 | "jquery": "^3.3.x", |
22 | "font-awesome": "^4.7.x", | 22 | "font-awesome": "^4.7.x", |
23 | "gulp": "^3.9.x", | 23 | "gulp": "^3.9.x", |
24 | "gulp-concat": "2.6.x", | 24 | "gulp-concat": "2.6.x", |
25 | "gulp-jshint": "^2.1.x", | 25 | "gulp-jshint": "^2.1.x", |
26 | "gulp-rename": "^1.4.x", | 26 | "gulp-rename": "^1.4.x", |
27 | "gulp-replace": "^1.0.x", | 27 | "gulp-replace": "^1.0.x", |
28 | "gulp-uglify-es": "^1.0.x", | 28 | "gulp-uglify-es": "^1.0.x", |
29 | "jshint": "^2.9.x", | 29 | "jshint": "^2.9.x", |
30 | "pump": "^3.0.x" | 30 | "pump": "^3.0.x" |
31 | }, | 31 | }, |
32 | "devDependencies": { | 32 | "devDependencies": { |
33 | "angular": "^1.7.4", | 33 | "angular": "^1.7.4", |
34 | "angular-ladda": "^0.4.3", | 34 | "angular-ladda": "^0.4.3", |
35 | "angular-ui-bootstrap": "^2.5.6", | 35 | "angular-ui-bootstrap": "^2.5.6", |
36 | "bootstrap": "^4.1.3", | 36 | "bootstrap": "^4.1.3", |
37 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 37 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
38 | "font-awesome": "^4.7.0", | 38 | "font-awesome": "^4.7.0", |
39 | "gulp": "^3.9.1", | 39 | "gulp": "^3.9.1", |
40 | "gulp-angular-templatecache": "^2.2.1", | 40 | "gulp-angular-templatecache": "^2.2.1", |
41 | "gulp-clean": "^0.4.0", | 41 | "gulp-clean": "^0.4.0", |
42 | "gulp-concat": "^2.6.1", | 42 | "gulp-concat": "^2.6.1", |
43 | "gulp-connect": "^5.6.1", | 43 | "gulp-connect": "^5.6.1", |
44 | "gulp-htmlmin": "^5.0.1", | 44 | "gulp-htmlmin": "^5.0.1", |
45 | "gulp-jshint": "^2.1.0", | 45 | "gulp-jshint": "^2.1.0", |
46 | "gulp-rename": "^1.4.0", | 46 | "gulp-rename": "^1.4.0", |
47 | "gulp-replace": "^1.0.0", | 47 | "gulp-replace": "^1.0.0", |
48 | "gulp-uglify": "^3.0.1", | 48 | "gulp-uglify": "^3.0.1", |
49 | "gulp-uglify-es": "^1.0.4", | 49 | "gulp-uglify-es": "^1.0.4", |
50 | "jasmine-core": "^3.2.1", | 50 | "jasmine-core": "^3.2.1", |
51 | "jquery": "^3.3.1", | 51 | "jquery": "^3.3.1", |
52 | "jshint": "^2.9.6", | 52 | "jshint": "^2.9.6", |
53 | "ladda": "1.0.6", | 53 | "ladda": "1.0.6", |
54 | "pre-commit": "^1.2.2", | 54 | "pre-commit": "^1.2.2", |
55 | "pump": "^3.0.0", | 55 | "pump": "^3.0.0", |
56 | "ui-bootstrap4": "^3.0.5" | 56 | "ui-bootstrap4": "^3.0.5" |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 |
src/js/app.js
1 | angular.module('focaBusquedaCliente', ['ui.bootstrap', 'focaDirectivas', 'angular-ladda']); | 1 | angular.module('focaBusquedaCliente', [ |
2 | 'ui.bootstrap', | ||
3 | 'focaDirectivas', | ||
4 | 'angular-ladda', | ||
5 | 'focaModal' | ||
6 | ]); | ||
2 | 7 |
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 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter) { | 4 | '$uibModal', 'focaModalService', |
5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | ||
6 | $uibModal, focaModalService) { | ||
5 | 7 | ||
6 | $scope.filters = ''; | 8 | $scope.filters = ''; |
7 | $scope.primerBusqueda = false; | 9 | $scope.primerBusqueda = false; |
8 | // pagination | 10 | // pagination |
9 | $scope.numPerPage = 10; | 11 | $scope.numPerPage = 10; |
10 | $scope.currentPage = 1; | 12 | $scope.currentPage = 1; |
11 | $scope.filteredClientes = []; | 13 | $scope.filteredClientes = []; |
12 | $scope.currentPageClientes = []; | 14 | $scope.currentPageClientes = []; |
13 | $scope.selectedClientes = -1; | 15 | $scope.selectedClientes = -1; |
16 | $scope.ingreso = false; | ||
17 | |||
18 | $scope.cliente = { | ||
19 | COD: 0, | ||
20 | ES_MAY: true, | ||
21 | provincia: { | ||
22 | NOMBRE: '' | ||
23 | }, | ||
24 | localidad: { | ||
25 | NOMBRE: '' | ||
26 | }, | ||
27 | iva: { | ||
28 | NOMBRE: '' | ||
29 | }, | ||
30 | actividad: { | ||
31 | NOM: '' | ||
32 | }, | ||
33 | zona: { | ||
34 | NOM: '' | ||
35 | }, | ||
36 | tipoFactura: { | ||
37 | NOMBRE: '' | ||
38 | }, | ||
39 | tipoComprobante: { | ||
40 | NOMBRE: '' | ||
41 | }, | ||
42 | formaPago: { | ||
43 | NOMBRE: '' | ||
44 | } | ||
45 | }; | ||
14 | 46 | ||
15 | $scope.busquedaPress = function(key) { | 47 | $scope.busquedaPress = function(key) { |
16 | if (key === 13) { | 48 | if (key === 13) { |
17 | $scope.searchLoading = true; | 49 | $scope.searchLoading = true; |
18 | focaBusquedaClienteService.obtenerClientesPorNombreOCuit($scope.filters).then( | 50 | focaBusquedaClienteService.obtenerClientesPorNombreOCuit($scope.filters).then( |
19 | function(res) { | 51 | function(res) { |
20 | $scope.primerBusqueda = true; | 52 | $scope.primerBusqueda = true; |
21 | $scope.clientes = res.data; | 53 | $scope.clientes = res.data; |
22 | $scope.search(); | 54 | $scope.search(true); |
23 | primera(); | 55 | primera(); |
24 | $scope.searchLoading = false; | 56 | $scope.searchLoading = false; |
25 | }); | 57 | }); |
26 | } | 58 | } |
27 | }; | 59 | }; |
28 | 60 | ||
29 | $scope.search = function () { | 61 | $scope.search = function (pressed) { |
30 | if($scope.primerBusqueda) { | 62 | if($scope.primerBusqueda) { |
31 | $scope.filteredClientes = $filter('filter')( | 63 | $scope.filteredClientes = $filter('filter')( |
32 | $scope.clientes, {$: $scope.filters} | 64 | $scope.clientes, {$: $scope.filters} |
33 | ); | 65 | ); |
34 | 66 | ||
67 | if(pressed && $scope.filteredClientes.length === 0){ | ||
68 | $timeout(function() { | ||
69 | angular.element('#search')[0].focus(); | ||
70 | $scope.filters = ''; | ||
71 | }); | ||
72 | } | ||
73 | |||
35 | $scope.lastPage = Math.ceil( | 74 | $scope.lastPage = Math.ceil( |
36 | $scope.filteredClientes.length / $scope.numPerPage | 75 | $scope.filteredClientes.length / $scope.numPerPage |
37 | ); | 76 | ); |
38 | 77 | ||
39 | $scope.resetPage(); | 78 | $scope.resetPage(); |
40 | } | 79 | } |
41 | }; | 80 | }; |
42 | 81 | ||
43 | $scope.resetPage = function () { | 82 | $scope.resetPage = function () { |
44 | $scope.currentPage = 1; | 83 | $scope.currentPage = 1; |
45 | $scope.selectPage(1); | 84 | $scope.selectPage(1); |
46 | }; | 85 | }; |
47 | 86 | ||
48 | $scope.selectPage = function (page) { | 87 | $scope.selectPage = function (page) { |
49 | var start = (page - 1) * $scope.numPerPage; | 88 | var start = (page - 1) * $scope.numPerPage; |
50 | var end = start + $scope.numPerPage; | 89 | var end = start + $scope.numPerPage; |
51 | $scope.paginas = []; | 90 | $scope.paginas = []; |
52 | $scope.paginas = calcularPages(page); | 91 | $scope.paginas = calcularPages(page); |
53 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); | 92 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); |
54 | $scope.currentPage = page; | 93 | $scope.currentPage = page; |
55 | }; | 94 | }; |
56 | 95 | ||
57 | $scope.select = function(cliente) { | 96 | $scope.select = function(cliente, esNuevo = false) { |
97 | cliente.esNuevo = esNuevo; | ||
58 | $uibModalInstance.close(cliente); | 98 | $uibModalInstance.close(cliente); |
59 | }; | 99 | }; |
60 | 100 | ||
61 | $scope.cancel = function() { | 101 | $scope.cancel = function() { |
62 | $uibModalInstance.dismiss('cancel'); | 102 | if($scope.ingreso) { |
103 | $scope.ingreso = false; | ||
104 | }else { | ||
105 | $uibModalInstance.dismiss('cancel'); | ||
106 | } | ||
63 | }; | 107 | }; |
64 | 108 | ||
65 | $scope.busquedaDown = function(key) { | 109 | $scope.busquedaDown = function(key) { |
66 | if (key === 40) { | 110 | if (key === 40) { |
67 | primera(key); | 111 | primera(key); |
68 | } | 112 | } |
69 | }; | 113 | }; |
70 | 114 | ||
71 | $scope.itemCliente = function(key) { | 115 | $scope.itemCliente = function(key) { |
72 | if (key === 38) { | 116 | if (key === 38) { |
73 | anterior(key); | 117 | anterior(key); |
74 | } | 118 | } |
75 | 119 | ||
76 | if (key === 40) { | 120 | if (key === 40) { |
77 | siguiente(key); | 121 | siguiente(key); |
78 | } | 122 | } |
79 | 123 | ||
80 | if (key === 37) { | 124 | if (key === 37) { |
81 | retrocederPagina(); | 125 | retrocederPagina(); |
82 | } | 126 | } |
83 | 127 | ||
84 | if (key === 39) { | 128 | if (key === 39) { |
85 | avanzarPagina(); | 129 | avanzarPagina(); |
86 | } | 130 | } |
87 | }; | 131 | }; |
88 | 132 | ||
133 | $scope.seleccionarProvincia = function(key) { | ||
134 | if(key === 13) { | ||
135 | var modalInstance = $uibModal.open( | ||
136 | { | ||
137 | ariaLabelledBy: 'Búsqueda de provincias', | ||
138 | templateUrl: 'modal-provincias.html', | ||
139 | controller: 'focaModalProvinciaController', | ||
140 | size: 'md', | ||
141 | resolve: {filters: function() { | ||
142 | return $scope.cliente.provincia; | ||
143 | }} | ||
144 | } | ||
145 | ); | ||
146 | modalInstance.result.then(function(provincia) { | ||
147 | $scope.cliente.provincia = provincia; | ||
148 | $scope.focused = 3; | ||
149 | }, function() { | ||
150 | //TODO: función llamada cuando cancela el modal | ||
151 | }); | ||
152 | } | ||
153 | }; | ||
154 | $scope.seleccionarLocalidad = function(key) { | ||
155 | if($scope.cliente.provincia.ID === undefined) { | ||
156 | //TODO: Poner modal alert de foca | ||
157 | alert('Seleccione una provincia'); | ||
158 | return; | ||
159 | } | ||
160 | if(key === 13) { | ||
161 | var modalInstance = $uibModal.open( | ||
162 | { | ||
163 | ariaLabelledBy: 'Búsqueda de localidades', | ||
164 | templateUrl: 'modal-localidades.html', | ||
165 | controller: 'focaModalLocalidadController', | ||
166 | size: 'md', | ||
167 | resolve: { | ||
168 | filters: { | ||
169 | idProvincia: $scope.cliente.provincia.ID, | ||
170 | busqueda: $scope.cliente.localidad.nombre | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | ); | ||
175 | modalInstance.result.then(function(localidad) { | ||
176 | $scope.cliente.localidad = localidad; | ||
177 | $scope.focused = 4; | ||
178 | }, function() { | ||
179 | //TODO: función llamada cuando cancela el modal | ||
180 | }); | ||
181 | } | ||
182 | }; | ||
183 | $scope.seleccionarIva = function(key) { | ||
184 | if(key === 13) { | ||
185 | var modalInstance = $uibModal.open( | ||
186 | { | ||
187 | ariaLabelledBy: 'Búsqueda de responsabilidad ante el IVA', | ||
188 | templateUrl: 'modal-iva.html', | ||
189 | controller: 'focaModalIvaController', | ||
190 | size: 'md', | ||
191 | resolve: {filters: function() { | ||
192 | return $scope.cliente.iva.NOMBRE; | ||
193 | }} | ||
194 | } | ||
195 | ); | ||
196 | modalInstance.result.then(function(iva) { | ||
197 | $scope.cliente.iva = iva; | ||
198 | }, function() { | ||
199 | //TODO: función llamada cuando cancela el modal | ||
200 | }); | ||
201 | } | ||
202 | }; | ||
203 | $scope.seleccionarActividad = function(key) { | ||
204 | if(key === 13) { | ||
205 | var modalInstance = $uibModal.open( | ||
206 | { | ||
207 | ariaLabelledBy: 'Búsqueda de actividades', | ||
208 | templateUrl: 'modal-actividad.html', | ||
209 | controller: 'focaModalActividadController', | ||
210 | size: 'md', | ||
211 | resolve: {filters: function() { | ||
212 | return $scope.cliente.actividad.NOM; | ||
213 | }} | ||
214 | } | ||
215 | ); | ||
216 | modalInstance.result.then(function(actividad) { | ||
217 | $scope.cliente.actividad = actividad; | ||
218 | }, function() { | ||
219 | //TODO: función llamada cuando cancela el modal | ||
220 | }); | ||
221 | } | ||
222 | }; | ||
223 | $scope.seleccionarZona = function(key) { | ||
224 | if(key === 13) { | ||
225 | var modalInstance = $uibModal.open( | ||
226 | { | ||
227 | ariaLabelledBy: 'Búsqueda de zonas', | ||
228 | templateUrl: 'modal-zona.html', | ||
229 | controller: 'focaModalZonaController', | ||
230 | size: 'md', | ||
231 | resolve: {filters: function() { | ||
232 | return $scope.cliente.zona.NOM; | ||
233 | }} | ||
234 | } | ||
235 | ); | ||
236 | modalInstance.result.then(function(zona) { | ||
237 | $scope.cliente.zona = zona; | ||
238 | }, function() { | ||
239 | //TODO: función llamada cuando cancela el modal | ||
240 | }); | ||
241 | } | ||
242 | }; | ||
243 | $scope.seleccionarTipoFactura = function(key) { | ||
244 | if(key === 13) { | ||
245 | var modalInstance = $uibModal.open( | ||
246 | { | ||
247 | ariaLabelledBy: 'Búsqueda de tipos de factura', | ||
248 | templateUrl: 'modal-tipo-factura.html', | ||
249 | controller: 'focaModalTipoFacturaController', | ||
250 | size: 'md', | ||
251 | resolve: {filters: function() { | ||
252 | return $scope.cliente.tipoFactura.NOMBRE; | ||
253 | }} | ||
254 | } | ||
255 | ); | ||
256 | modalInstance.result.then(function(tipoFactura) { | ||
257 | $scope.cliente.tipoFactura = tipoFactura; | ||
258 | }, function() { | ||
259 | //TODO: función llamada cuando cancela el modal | ||
260 | }); | ||
261 | } | ||
262 | }; | ||
263 | $scope.seleccionarTipoComprobante = function(key) { | ||
264 | if(key === 13) { | ||
265 | var modalInstance = $uibModal.open( | ||
266 | { | ||
267 | ariaLabelledBy: 'Búsqueda de tipos de comprobante', | ||
268 | templateUrl: 'modal-tipo-comprobante.html', | ||
269 | controller: 'focaModalTipoComprobanteController', | ||
270 | size: 'md', | ||
271 | resolve: {filters: function() { | ||
272 | return $scope.cliente.tipoComprobante.NOMBRE; | ||
273 | }} | ||
274 | } | ||
275 | ); | ||
276 | modalInstance.result.then(function(tipoComprobante) { | ||
277 | $scope.cliente.tipoComprobante = tipoComprobante; | ||
278 | }, function() { | ||
279 | //TODO: función llamada cuando cancela el modal | ||
280 | }); | ||
281 | } | ||
282 | }; | ||
283 | $scope.seleccionarFormaPago = function(key) { | ||
284 | if(key === 13) { | ||
285 | var modalInstance = $uibModal.open( | ||
286 | { | ||
287 | ariaLabelledBy: 'Búsqueda de formas de pago', | ||
288 | templateUrl: 'modal-forma-pago.html', | ||
289 | controller: 'focaModalFormaPagoController', | ||
290 | size: 'md', | ||
291 | resolve: {filters: function() { | ||
292 | return $scope.cliente.formaPago.NOMBRE; | ||
293 | }} | ||
294 | } | ||
295 | ); | ||
296 | modalInstance.result.then(function(formaPago) { | ||
297 | $scope.cliente.formaPago = formaPago; | ||
298 | }, function() { | ||
299 | //TODO: función llamada cuando cancela el modal | ||
300 | }); | ||
301 | } | ||
302 | }; | ||
303 | |||
304 | $scope.guardar = function() { | ||
305 | |||
306 | if(!validarForm()) return; | ||
307 | |||
308 | $scope.cliente.PCX = $scope.cliente.provincia.ID; | ||
309 | $scope.cliente.LOX = $scope.cliente.localidad.ID; | ||
310 | $scope.cliente.IVA = $scope.cliente.iva.ID; | ||
311 | $scope.cliente.ACT = $scope.cliente.actividad.ID; | ||
312 | $scope.cliente.ZON = $scope.cliente.zona.ID; | ||
313 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; | ||
314 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; | ||
315 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; | ||
316 | |||
317 | delete $scope.cliente.provincia; | ||
318 | delete $scope.cliente.localidad; | ||
319 | delete $scope.cliente.iva; | ||
320 | delete $scope.cliente.actividad; | ||
321 | delete $scope.cliente.zona; | ||
322 | delete $scope.cliente.tipoFactura; | ||
323 | delete $scope.cliente.tipoComprobante; | ||
324 | delete $scope.cliente.formaPago; | ||
325 | |||
326 | focaBusquedaClienteService.guardarCliente($scope.cliente).then(function(res) { | ||
327 | $scope.select(res.data, true); | ||
328 | }); | ||
329 | }; | ||
330 | |||
89 | function calcularPages(paginaActual) { | 331 | function calcularPages(paginaActual) { |
90 | var paginas = []; | 332 | var paginas = []; |
91 | paginas.push(paginaActual); | 333 | paginas.push(paginaActual); |
92 | 334 | ||
93 | if (paginaActual - 1 > 1) { | 335 | if (paginaActual - 1 > 1) { |
94 | 336 | ||
95 | paginas.unshift(paginaActual - 1); | 337 | paginas.unshift(paginaActual - 1); |
96 | if (paginaActual - 2 > 1) { | 338 | if (paginaActual - 2 > 1) { |
97 | paginas.unshift(paginaActual - 2); | 339 | paginas.unshift(paginaActual - 2); |
98 | } | 340 | } |
99 | } | 341 | } |
100 | 342 | ||
101 | if (paginaActual + 1 < $scope.lastPage) { | 343 | if (paginaActual + 1 < $scope.lastPage) { |
102 | paginas.push(paginaActual + 1); | 344 | paginas.push(paginaActual + 1); |
103 | if (paginaActual + 2 < $scope.lastPage) { | 345 | if (paginaActual + 2 < $scope.lastPage) { |
104 | paginas.push(paginaActual + 2); | 346 | paginas.push(paginaActual + 2); |
105 | } | 347 | } |
106 | } | 348 | } |
107 | 349 | ||
108 | if (paginaActual !== 1) { | 350 | if (paginaActual !== 1) { |
109 | paginas.unshift(1); | 351 | paginas.unshift(1); |
110 | } | 352 | } |
111 | 353 | ||
112 | if (paginaActual !== $scope.lastPage) { | 354 | if (paginaActual !== $scope.lastPage) { |
113 | paginas.push($scope.lastPage); | 355 | paginas.push($scope.lastPage); |
114 | } | 356 | } |
115 | 357 | ||
116 | return paginas; | 358 | return paginas; |
117 | } | 359 | } |
118 | 360 | ||
119 | function primera() { | 361 | function primera() { |
120 | $scope.selectedClientes = 0; | 362 | $scope.selectedClientes = 0; |
121 | } | 363 | } |
122 | 364 | ||
123 | function anterior() { | 365 | function anterior() { |
124 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { | 366 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { |
125 | retrocederPagina(); | 367 | retrocederPagina(); |
126 | } else { | 368 | } else { |
127 | $scope.selectedClientes--; | 369 | $scope.selectedClientes--; |
128 | } | 370 | } |
129 | } | 371 | } |
130 | 372 | ||
131 | function siguiente() { | 373 | function siguiente() { |
132 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { | 374 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { |
133 | $scope.selectedClientes++; | 375 | $scope.selectedClientes++; |
134 | } else { | 376 | } else { |
135 | avanzarPagina(); | 377 | avanzarPagina(); |
136 | } | 378 | } |
137 | } | 379 | } |
138 | 380 | ||
139 | function retrocederPagina() { | 381 | function retrocederPagina() { |
140 | if ($scope.currentPage > 1) { | 382 | if ($scope.currentPage > 1) { |
141 | $scope.selectPage($scope.currentPage - 1); | 383 | $scope.selectPage($scope.currentPage - 1); |
142 | $scope.selectedClientes = $scope.numPerPage - 1; | 384 | $scope.selectedClientes = $scope.numPerPage - 1; |
143 | } | 385 | } |
144 | } | 386 | } |
145 | 387 | ||
146 | function avanzarPagina() { | 388 | function avanzarPagina() { |
147 | if ($scope.currentPage < $scope.lastPage) { | 389 | if ($scope.currentPage < $scope.lastPage) { |
148 | $scope.selectPage($scope.currentPage + 1); | 390 | $scope.selectPage($scope.currentPage + 1); |
149 | $scope.selectedClientes = 0; | 391 | $scope.selectedClientes = 0; |
150 | } | 392 | } |
151 | } | 393 | } |
394 | |||
395 | function validarForm() { | ||
396 | var regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); | ||
397 | if(!regexCuit.test($scope.cliente.CUIT)) { | ||
398 | focaModalService.alert('Número de CUIT inválido') | ||
399 | return false; | ||
400 | } | ||
401 | return true; | ||
402 | } | ||
152 | } | 403 | } |
153 | ]); | 404 | ]); |
154 | 405 |
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 | obtenerClientes: function() { | 4 | obtenerClientes: function() { |
5 | return $http.get(API_ENDPOINT.URL + '/cliente'); | 5 | return $http.get(API_ENDPOINT.URL + '/cliente'); |
6 | }, | 6 | }, |
7 | obtenerCliente: function(id) { | 7 | obtenerCliente: function(id) { |
8 | return $http.get(API_ENDPOINT.URL + '/cliente/' + id); | 8 | return $http.get(API_ENDPOINT.URL + '/cliente/' + id); |
9 | }, | 9 | }, |
10 | obtenerClientesPorNombreOCuit: function(nombreOCuit) { | 10 | obtenerClientesPorNombreOCuit: function(nombreOCuit) { |
11 | return $http.post(API_ENDPOINT.URL + '/cliente', {nombreOCuit: nombreOCuit}); | 11 | return $http.post(API_ENDPOINT.URL + '/cliente', {nombreOCuit: nombreOCuit}); |
12 | }, | ||
13 | guardarCliente: function(cliente) { | ||
14 | return $http.post(API_ENDPOINT.URL + '/cliente', {cliente: cliente}); | ||
12 | } | 15 | } |
13 | }; | 16 | }; |
14 | }]); | 17 | }]); |
15 | 18 |
src/views/foca-busqueda-cliente-modal.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <h5 class="modal-title">Búsqueda de Cliente</h5> | 2 | <div class="row w-100"> |
3 | <div class="col-lg-6"> | ||
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">Crear Cliente</h5> | ||
6 | </div> | ||
7 | <div ng-show="ingreso" class="col-lg-6"> | ||
8 | <div class="custom-control custom-checkbox"> | ||
9 | <input | ||
10 | type="checkbox" | ||
11 | class="custom-control-input" | ||
12 | id="checkProspecto" | ||
13 | ng-model="cliente.ES_PROS"> | ||
14 | <label class="custom-control-label" for="checkProspecto">¿Es prospecto?</label> | ||
15 | </div> | ||
16 | </div> | ||
17 | <div class="input-group col-lg-6 pr-0 my-2"> | ||
18 | <button | ||
19 | class="btn btn-outline-primary mr-2" | ||
20 | ng-click="ingreso = true" | ||
21 | ng-show="!ingreso"> | ||
22 | <i class="fa fa-plus" aria-hidden="true"></i> | ||
23 | </button> | ||
24 | <input | ||
25 | ladda="searchLoading" | ||
26 | type="text" | ||
27 | class="form-control form-control-sm" | ||
28 | id="search" | ||
29 | placeholder="Busqueda" | ||
30 | ng-model="filters" | ||
31 | ng-change="search()" | ||
32 | ng-keydown="busquedaDown($event.keyCode)" | ||
33 | ng-keypress="busquedaPress($event.keyCode)" | ||
34 | foca-focus="selectedClientes == -1" | ||
35 | ng-focus="selectedClientes = -1" | ||
36 | teclado-virtual | ||
37 | ng-hide="ingreso" | ||
38 | > | ||
39 | <div class="input-group-append" ng-hide="ingreso"> | ||
40 | <button | ||
41 | ladda="searchLoading" | ||
42 | data-spinner-color="#FF0000" | ||
43 | class="btn btn-outline-secondary" | ||
44 | type="button" | ||
45 | ng-click="busquedaPress(13)"> | ||
46 | <i class="fa fa-search" aria-hidden="true"></i> | ||
47 | </button> | ||
48 | </div> | ||
49 | </div> | ||
50 | </div> | ||
3 | </div> | 51 | </div> |
4 | <div class="modal-body" id="modal-body"> | 52 | <div class="modal-body" id="modal-body"> |
5 | <div class="input-group"> | 53 | |
6 | <input | 54 | <div ng-show="!primerBusqueda && !ingreso"> |
7 | ladda="searchLoading" | 55 | Debe realizar una primer búsqueda. |
8 | type="text" | ||
9 | class="form-control" | ||
10 | placeholder="Busqueda" | ||
11 | ng-model="filters" | ||
12 | ng-change="search()" | ||
13 | ng-keydown="busquedaDown($event.keyCode)" | ||
14 | ng-keypress="busquedaPress($event.keyCode)" | ||
15 | foca-focus="selectedClientes == -1" | ||
16 | ng-focus="selectedClientes = -1" | ||
17 | > | ||
18 | <div class="input-group-append"> | ||
19 | <button | ||
20 | ladda="searchLoading" | ||
21 | class="btn btn-outline-secondary" | ||
22 | type="button" | ||
23 | ng-click="busquedaPress(13)"> | ||
24 | <i class="fa fa-search" aria-hidden="true"></i> | ||
25 | </button> | ||
26 | </div> | 56 | </div> |
27 | </div> | 57 | |
28 | <table ng-show="primerBusqueda" class="table table-striped table-sm"> | 58 | <table ng-show="primerBusqueda && !ingreso" class="table table-striped table-sm"> |
29 | <thead> | 59 | <thead> |
30 | <tr> | 60 | <tr> |
31 | <th>Código</th> | 61 | <th>Código</th> |
32 | <th>Nombre</th> | 62 | <th>Nombre</th> |
33 | <th>CUIT</th> | 63 | <th>CUIT</th> |
34 | <th></th> | 64 | <th></th> |
35 | </tr> | 65 | </tr> |
36 | </thead> | 66 | </thead> |
37 | <tbody> | 67 | <tbody> |
38 | <tr ng-show="currentPageClientes.length == 0 && primerBusqueda"> | 68 | <tr ng-show="currentPageClientes.length == 0 && primerBusqueda"> |
39 | <td colspan="4"> | 69 | <td colspan="4"> |
40 | No se encontraron resultados. | 70 | No se encontraron resultados. |
41 | </td> | 71 | </td> |
42 | </tr> | 72 | </tr> |
43 | <tr | 73 | <tr |
44 | class="selectable" | 74 | class="selectable" |
45 | ng-repeat="(key, cliente) in currentPageClientes" | 75 | ng-repeat="(key, cliente) in currentPageClientes" |
46 | ng-click="select(cliente)"> | 76 | ng-click="select(cliente)"> |
47 | <td ng-bind="cliente.cod"></td> | 77 | <td ng-bind="('00000'+cliente.cod).slice(-5)"></td> |
48 | <td ng-bind="cliente.nom"></td> | 78 | <td ng-bind="cliente.nom"></td> |
49 | <td ng-bind="cliente.cuit"></td> | 79 | <td ng-bind="cliente.cuit"></td> |
50 | <td> | 80 | <td> |
51 | <button | 81 | <button |
52 | type="button" | 82 | type="button" |
53 | class="btn btn-xs p-1 float-right" | 83 | class="btn btn-xs p-1 float-right" |
54 | ng-class="{ | 84 | ng-class="{ |
55 | 'btn-secondary': selectedClientes != key, | 85 | 'btn-secondary': selectedClientes != key, |
56 | 'btn-primary': selectedClientes == key | 86 | 'btn-primary': selectedClientes == key |
57 | }" | 87 | }" |
58 | ng-click="select(cliente)" | 88 | ng-click="select(cliente)" |
59 | foca-focus="selectedClientes == {{key}}" | 89 | foca-focus="selectedClientes == {{key}}" |
60 | ng-keydown="itemCliente($event.keyCode)" | 90 | ng-keydown="itemCliente($event.keyCode)" |
61 | > | 91 | > |
62 | <i class="fa fa-arrow-right" aria-hidden="true"></i> | 92 | <i class="fa fa-circle-thin" aria-hidden="true"></i> |
63 | </button> | 93 | </button> |
64 | </td> | 94 | </td> |
65 | </tr> | 95 | </tr> |
66 | </tbody> | 96 | </tbody> |
67 | </table> | 97 | </table> |
68 | <nav ng-show="currentPageClientes.length > 0 && primerBusqueda"> | 98 | |
99 | <form name="formCliente"> | ||
100 | <uib-tabset class="tabs-right" ng-show="ingreso"> | ||
101 | <uib-tab heading="Datos clientes"> | ||
102 | <div class="row"> | ||
103 | <div class="col-3"> | ||
104 | <label>Código</label> | ||
105 | <input | ||
106 | type="text" | ||
107 | class="form-control form-control-sm" | ||
108 | ng-model="cliente.codigo" | ||
109 | ng-required="true" | ||
110 | readonly | ||
111 | /> | ||
112 | </div> | ||
113 | <div class="col-9"> | ||
114 | <label>Nombre</label> | ||
115 | <input | ||
116 | type="text" | ||
117 | foca-focus="ingreso" | ||
118 | class="form-control form-control-sm" | ||
119 | ng-model="cliente.NOM" | ||
120 | placeholder="Ingrese nombre" | ||
121 | ng-required="true" | ||
122 | teclado-virtual | ||
123 | /> | ||
124 | </div> | ||
125 | </div> | ||
126 | <div class="row"> | ||
127 | <div class="col-9"> | ||
128 | <label>Domicilio</label> | ||
129 | <input | ||
130 | type="text" | ||
131 | class="form-control form-control-sm" | ||
132 | ng-model="cliente.DOM" | ||
133 | placeholder="Ingrese domicilio" | ||
134 | ng-required="true" | ||
135 | teclado-virtual | ||
136 | /> | ||
137 | </div> | ||
138 | <div class="col-3"> | ||
139 | <label>Código postal</label> | ||
140 | <input | ||
141 | type="text" | ||
142 | class="form-control form-control-sm" | ||
143 | ng-model="cliente.CPO" | ||
144 | placeholder="Ingrese CP" | ||
145 | ng-required="true" | ||
146 | teclado-virtual | ||
147 | /> | ||
148 | </div> | ||
149 | </div> | ||
150 | <div class="row"> | ||
151 | <div class="col-6"> | ||
152 | <label>Provincia</label> | ||
153 | <div class="input-group"> | ||
154 | <input | ||
155 | type="text" | ||
156 | class="form-control form-control-sm" | ||
157 | ng-model="cliente.provincia.NOMBRE" | ||
158 | ng-keypress="seleccionarProvincia($event.keyCode)" | ||
159 | placeholder="Ingrese provincia" | ||
160 | ng-required="true" | ||
161 | teclado-virtual | ||
162 | /> | ||
163 | <div class="input-group-append"> | ||
164 | <button | ||
165 | ladda="searchLoading" | ||
166 | class="btn btn-outline-secondary form-control-sm" | ||
167 | type="button" | ||
168 | ng-click="seleccionarProvincia(13)" | ||
169 | > | ||
170 | <i class="fa fa-search" aria-hidden="true"></i> | ||
171 | </button> | ||
172 | </div> | ||
173 | </div> | ||
174 | </div> | ||
175 | <div class="col-6"> | ||
176 | <label>Localidad</label> | ||
177 | <div class="input-group"> | ||
178 | <input | ||
179 | type="text" | ||
180 | class="form-control form-control-sm" | ||
181 | ng-model="cliente.localidad.NOMBRE" | ||
182 | ng-keypress="seleccionarLocalidad($event.keyCode)" | ||
183 | placeholder="Ingrese localidad" | ||
184 | ng-required="true" | ||
185 | teclado-virtual | ||
186 | /> | ||
187 | <div class="input-group-append"> | ||
188 | <button | ||
189 | ladda="searchLoading" | ||
190 | class="btn btn-outline-secondary form-control-sm" | ||
191 | type="button" | ||
192 | ng-click="seleccionarLocalidad(13)" | ||
193 | > | ||
194 | <i class="fa fa-search" aria-hidden="true"></i> | ||
195 | </button> | ||
196 | </div> | ||
197 | </div> | ||
198 | </div> | ||
199 | </div> | ||
200 | <div class="row"> | ||
201 | <div class="col-6"> | ||
202 | <label>Zona</label> | ||
203 | <div class="input-group"> | ||
204 | <input | ||
205 | type="text" | ||
206 | class="form-control form-control-sm" | ||
207 | ng-model="cliente.zona.NOM" | ||
208 | ng-keypress="seleccionarZona($event.keyCode)" | ||
209 | placeholder="Ingrese zona" | ||
210 | ng-required="true" | ||
211 | teclado-virtual | ||
212 | /> | ||
213 | <div class="input-group-append"> | ||
214 | <button | ||
215 | ladda="searchLoading" | ||
216 | class="btn btn-outline-secondary form-control-sm" | ||
217 | type="button" | ||
218 | ng-click="seleccionarZona(13)" | ||
219 | > | ||
220 | <i class="fa fa-search" aria-hidden="true"></i> | ||
221 | </button> | ||
222 | </div> | ||
223 | </div> | ||
224 | </div> | ||
225 | <div class="col-6"> | ||
226 | <label>Actividad</label> | ||
227 | <div class="input-group"> | ||
228 | <input | ||
229 | type="text" | ||
230 | class="form-control form-control-sm" | ||
231 | ng-model="cliente.actividad.NOM" | ||
232 | ng-keypress="seleccionarActividad($event.keyCode)" | ||
233 | placeholder="Ingrese actividad" | ||
234 | ng-required="true" | ||
235 | teclado-virtual | ||
236 | /> | ||
237 | <div class="input-group-append"> | ||
238 | <button | ||
239 | ladda="searchLoading" | ||
240 | class="btn btn-outline-secondary form-control-sm" | ||
241 | type="button" | ||
242 | ng-click="seleccionarActividad(13)" | ||
243 | > | ||
244 | <i class="fa fa-search" aria-hidden="true"></i> | ||
245 | </button> | ||
246 | </div> | ||
247 | </div> | ||
248 | </div> | ||
249 | </div> | ||
250 | <div class="row"> | ||
251 | <div class="col-6"> | ||
252 | <div class="custom-control custom-checkbox"> | ||
253 | <input | ||
254 | type="checkbox" | ||
255 | class="custom-control-input" | ||
256 | id="checkDistribuidor" | ||
257 | ng-model="cliente.ES_MAY" | ||
258 | checked> | ||
259 | <label class="custom-control-label" for="checkDistribuidor">¿Este cliente es distribuidor?</label> | ||
260 | </div> | ||
261 | </div> | ||
262 | </div> | ||
263 | </uib-tab> | ||
264 | <uib-tab heading="Datos impositivos"> | ||
265 | <div class="row"> | ||
266 | <div class="col-7"> | ||
267 | <label>Responsabilidad ante el IVA</label> | ||
268 | <div class="input-group"> | ||
269 | <input | ||
270 | type="text" | ||
271 | class="form-control form-control-sm" | ||
272 | ng-model="cliente.iva.NOMBRE" | ||
273 | ng-keypress="seleccionarIva($event.keyCode)" | ||
274 | ng-required="true" | ||
275 | teclado-virtual | ||
276 | /> | ||
277 | <div class="input-group-append"> | ||
278 | <button | ||
279 | ladda="searchLoading" | ||
280 | class="btn btn-outline-secondary form-control-sm" | ||
281 | type="button" | ||
282 | ng-click="seleccionarIva(13)" | ||
283 | > | ||
284 | <i class="fa fa-search" aria-hidden="true"></i> | ||
285 | </button> | ||
286 | </div> | ||
287 | </div> | ||
288 | </div> | ||
289 | <div class="col-5"> | ||
290 | <label>Factura que emite</label> | ||
291 | <div class="input-group"> | ||
292 | <input | ||
293 | type="text" | ||
294 | class="form-control form-control-sm" | ||
295 | placeholder="Ingrese factura que emite" | ||
296 | ng-model="cliente.tipoFactura.NOMBRE" | ||
297 | ng-required="true" | ||
298 | ng-keypress="seleccionarTipoFactura(13)" | ||
299 | teclado-virtual> | ||
300 | <div class="input-group-append"> | ||
301 | <button | ||
302 | ladda="searchLoading" | ||
303 | class="btn btn-outline-secondary form-control-sm" | ||
304 | type="button" | ||
305 | ng-click="seleccionarTipoFactura(13)" | ||
306 | > | ||
307 | <i class="fa fa-search" aria-hidden="true"></i> | ||
308 | </button> | ||
309 | </div> | ||
310 | </div> | ||
311 | </div> | ||
312 | </div> | ||
313 | <div class="row"> | ||
314 | <div class="col-4"> | ||
315 | <label>CUIT</label> | ||
316 | <div class="input-group"> | ||
317 | <input | ||
318 | type="text" | ||
319 | class="form-control form-control-sm" | ||
320 | placeholder="Ingrese CUIT" | ||
321 | ng-model="cliente.CUIT" | ||
322 | ng-required="true" | ||
323 | teclado-virtual> | ||
324 | </div> | ||
325 | </div> | ||
326 | <div class="col-4"> | ||
327 | <label>Clase de comprobante</label> | ||
328 | <div class="input-group"> | ||
329 | <input | ||
330 | type="text" | ||
331 | class="form-control form-control-sm" | ||
332 | placeholder="Ingrese clase de comprobante" | ||
333 | ng-keypress="seleccionarTipoComprobante($event.keyCode)" | ||
334 | ng-model="cliente.tipoComprobante.NOMBRE" | ||
335 | ng-required="true" | ||
336 | teclado-virtual> | ||
337 | <div class="input-group-append"> | ||
338 | <button | ||
339 | ladda="searchLoading" | ||
340 | class="btn btn-outline-secondary form-control-sm" | ||
341 | type="button" | ||
342 | ng-click="seleccionarTipoComprobante(13)" | ||
343 | > | ||
344 | <i class="fa fa-search" aria-hidden="true"></i> | ||
345 | </button> | ||
346 | </div> | ||
347 | </div> | ||
348 | </div> | ||
349 | <div class="col-4"> | ||
350 | <label>Forma de pago</label> | ||
351 | <div class="input-group"> | ||
352 | <input | ||
353 | type="text" | ||
354 | class="form-control form-control-sm" | ||
355 | placeholder="Ingrese forma de pago" | ||
356 | ng-model="cliente.formaPago.NOMBRE" | ||
357 | ng-required="true" | ||
358 | ng-keypress="seleccionarFormaPago($event.keyCode)" | ||
359 | teclado-virtual> | ||
360 | <div class="input-group-append"> | ||
361 | <button | ||
362 | ladda="searchLoading" | ||
363 | class="btn btn-outline-secondary form-control-sm" | ||
364 | type="button" | ||
365 | ng-click="seleccionarFormaPago(13)" | ||
366 | > | ||
367 | <i class="fa fa-search" aria-hidden="true"></i> | ||
368 | </button> | ||
369 | </div> | ||
370 | </div> | ||
371 | </div> | ||
372 | </div> | ||
373 | </uib-tab> | ||
374 | </uib-tabset> | ||
375 | </form> | ||
376 | </div> | ||
377 | <div class="modal-footer py-1"> | ||
378 | <nav ng-show="currentPageClientes.length > 0 && primerBusqueda && !ingreso" class="mr-auto"> | ||
69 | <ul class="pagination pagination-sm mb-0"> | 379 | <ul class="pagination pagination-sm mb-0"> |
70 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | 380 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |
71 | <a class="page-link" href="#" ng-click="selectPage(currentPage - 1)"> | 381 | <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage - 1)"> |
72 | <span aria-hidden="true">«</span> | 382 | <span aria-hidden="true">«</span> |
73 | <span class="sr-only">Anterior</span> | 383 | <span class="sr-only">Anterior</span> |
74 | </a> | 384 | </a> |
75 | </li> | 385 | </li> |
76 | <li | 386 | <li |
77 | class="page-item" | 387 | class="page-item" |
78 | ng-repeat="pagina in paginas" | 388 | ng-repeat="pagina in paginas" |
79 | ng-class="{'active': pagina == currentPage}" | 389 | ng-class="{'active': pagina == currentPage}" |
80 | > | 390 | > |
81 | <a | 391 | <a |