Commit dbf2c1c9155c93f12058cb84d3ab2b576670550e
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master(efernandez) See merge request !16
Showing
3 changed files
Show diff stats
.jshintrc
| 1 | { | 1 | { |
| 2 | /* | 2 | /* |
| 3 | * ENVIRONMENTS | 3 | * ENVIRONMENTS |
| 4 | * ================= | 4 | * ================= |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | // Define globals exposed by modern browsers. | 7 | // Define globals exposed by modern browsers. |
| 8 | "browser": true, | 8 | "browser": true, |
| 9 | 9 | ||
| 10 | // Define globals exposed by jQuery. | 10 | // Define globals exposed by jQuery. |
| 11 | "jquery": true, | 11 | "jquery": true, |
| 12 | 12 | ||
| 13 | // Define globals exposed by Node.js. | 13 | // Define globals exposed by Node.js. |
| 14 | "node": true, | 14 | "node": true, |
| 15 | 15 | ||
| 16 | // Allow ES6. | 16 | // Allow ES6. |
| 17 | "esversion": 6, | 17 | "esversion": 6, |
| 18 | 18 | ||
| 19 | /* | 19 | /* |
| 20 | * ENFORCING OPTIONS | 20 | * ENFORCING OPTIONS |
| 21 | * ================= | 21 | * ================= |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | // Force all variable names to use either camelCase style or UPPER_CASE | 24 | // Force all variable names to use either camelCase style or UPPER_CASE |
| 25 | // with underscores. | 25 | // with underscores. |
| 26 | "camelcase": true, | 26 | "camelcase": true, |
| 27 | 27 | ||
| 28 | // Prohibit use of == and != in favor of === and !==. | 28 | // Prohibit use of == and != in favor of === and !==. |
| 29 | "eqeqeq": true, | 29 | "eqeqeq": true, |
| 30 | 30 | ||
| 31 | // Enforce tab width of 2 spaces. | 31 | // Enforce tab width of 2 spaces. |
| 32 | "indent": 4, | 32 | "indent": 4, |
| 33 | 33 | ||
| 34 | // Prohibit use of a variable before it is defined. | 34 | // Prohibit use of a variable before it is defined. |
| 35 | "latedef": true, | 35 | "latedef": false, |
| 36 | 36 | ||
| 37 | // Enforce line length to 100 characters | 37 | // Enforce line length to 100 characters |
| 38 | "maxlen": 100, | 38 | "maxlen": 100, |
| 39 | 39 | ||
| 40 | // Require capitalized names for constructor functions. | 40 | // Require capitalized names for constructor functions. |
| 41 | "newcap": true, | 41 | "newcap": true, |
| 42 | 42 | ||
| 43 | // Enforce use of single quotation marks for strings. | 43 | // Enforce use of single quotation marks for strings. |
| 44 | "quotmark": "single", | 44 | "quotmark": "single", |
| 45 | 45 | ||
| 46 | // Enforce placing 'use strict' at the top function scope | 46 | // Enforce placing 'use strict' at the top function scope |
| 47 | "strict": false, | 47 | "strict": false, |
| 48 | 48 | ||
| 49 | // Prohibit use of explicitly undeclared variables. | 49 | // Prohibit use of explicitly undeclared variables. |
| 50 | "undef": true, | 50 | "undef": true, |
| 51 | 51 | ||
| 52 | // Warn when variables are defined but never used. | 52 | // Warn when variables are defined but never used. |
| 53 | "unused": true, | 53 | "unused": true, |
| 54 | 54 | ||
| 55 | // Para que funcione en angular | 55 | // Para que funcione en angular |
| 56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | 56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], |
| 57 | /* | 57 | /* |
| 58 | * RELAXING OPTIONS | 58 | * RELAXING OPTIONS |
| 59 | * ================= | 59 | * ================= |
| 60 | */ | 60 | */ |
| 61 | 61 | ||
| 62 | // Suppress warnings about == null comparisons. | 62 | // Suppress warnings about == null comparisons. |
| 63 | "eqnull": true | 63 | "eqnull": true |
| 64 | } | 64 | } |
| 65 | 65 |
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-busqueda-cliente.min.js", | 5 | "main": "dist/foca-busqueda-cliente.min.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
| 8 | "gulp-pre-commit": "gulp pre-commit", | ||
| 8 | "compile": "gulp uglify", | 9 | "compile": "gulp uglify", |
| 9 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "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+http://git.focasoftware.com/npm/foca-directivas.git" | 11 | "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 | }, | 12 | }, |
| 13 | "pre-commit": [ | ||
| 14 | "gulp-pre-commit" | ||
| 15 | ], | ||
| 12 | "repository": { | 16 | "repository": { |
| 13 | "type": "git", | 17 | "type": "git", |
| 14 | "url": "http://git.focasoftware.com/npm/foca-busqueda-cliente.git" | 18 | "url": "http://git.focasoftware.com/npm/foca-busqueda-cliente.git" |
| 15 | }, | 19 | }, |
| 16 | "author": "Foca Software", | 20 | "author": "Foca Software", |
| 17 | "license": "ISC", | 21 | "license": "ISC", |
| 18 | "peerDependencies": { | 22 | "peerDependencies": { |
| 19 | "angular": "^1.7.x", | 23 | "angular": "^1.7.x", |
| 20 | "bootstrap": "^4.1.x", | 24 | "bootstrap": "^4.1.x", |
| 21 | "jquery": "^3.3.x", | 25 | "jquery": "^3.3.x", |
| 22 | "font-awesome": "^4.7.x", | 26 | "font-awesome": "^4.7.x", |
| 23 | "gulp": "^3.9.x", | 27 | "gulp": "^3.9.x", |
| 24 | "gulp-concat": "2.6.x", | 28 | "gulp-concat": "2.6.x", |
| 25 | "gulp-jshint": "^2.1.x", | 29 | "gulp-jshint": "^2.1.x", |
| 26 | "gulp-rename": "^1.4.x", | 30 | "gulp-rename": "^1.4.x", |
| 27 | "gulp-replace": "^1.0.x", | 31 | "gulp-replace": "^1.0.x", |
| 28 | "gulp-uglify-es": "^1.0.x", | 32 | "gulp-uglify-es": "^1.0.x", |
| 29 | "jshint": "^2.9.x", | 33 | "jshint": "^2.9.x", |
| 30 | "pump": "^3.0.x" | 34 | "pump": "^3.0.x" |
| 31 | }, | 35 | }, |
| 32 | "devDependencies": { | 36 | "devDependencies": { |
| 33 | "angular": "^1.7.6", | 37 | "angular": "^1.7.6", |
| 34 | "angular-ladda": "^0.4.3", | 38 | "angular-ladda": "^0.4.3", |
| 35 | "angular-ui-bootstrap": "^2.5.6", | 39 | "angular-ui-bootstrap": "^2.5.6", |
| 36 | "bootstrap": "^4.2.1", | 40 | "bootstrap": "^4.2.1", |
| 37 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 41 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 38 | "font-awesome": "^4.7.0", | 42 | "font-awesome": "^4.7.0", |
| 39 | "gulp": "^3.9.1", | 43 | "gulp": "^3.9.1", |
| 40 | "gulp-angular-templatecache": "^2.2.6", | 44 | "gulp-angular-templatecache": "^2.2.6", |
| 41 | "gulp-clean": "^0.4.0", | 45 | "gulp-clean": "^0.4.0", |
| 42 | "gulp-concat": "^2.6.1", | 46 | "gulp-concat": "^2.6.1", |
| 43 | "gulp-connect": "^5.7.0", | 47 | "gulp-connect": "^5.7.0", |
| 44 | "gulp-htmlmin": "^5.0.1", | 48 | "gulp-htmlmin": "^5.0.1", |
| 45 | "gulp-jshint": "^2.1.0", | 49 | "gulp-jshint": "^2.1.0", |
| 46 | "gulp-rename": "^1.4.0", | 50 | "gulp-rename": "^1.4.0", |
| 47 | "gulp-replace": "^1.0.0", | 51 | "gulp-replace": "^1.0.0", |
| 48 | "gulp-uglify": "^3.0.1", | 52 | "gulp-uglify": "^3.0.1", |
| 49 | "gulp-uglify-es": "^1.0.4", | 53 | "gulp-uglify-es": "^1.0.4", |
| 50 | "jasmine-core": "^3.3.0", | 54 | "jasmine-core": "^3.3.0", |
| 51 | "jquery": "^3.3.1", | 55 | "jquery": "^3.3.1", |
| 52 | "jshint": "^2.9.7", | 56 | "jshint": "^2.9.7", |
| 53 | "ladda": "^1.0.6", | 57 | "ladda": "^1.0.6", |
| 54 | "pre-commit": "^1.2.2", | 58 | "pre-commit": "^1.2.2", |
| 55 | "pump": "^3.0.0", | 59 | "pump": "^3.0.0", |
| 56 | "ui-bootstrap4": "^3.0.6" | 60 | "ui-bootstrap4": "^3.0.6" |
| 57 | } | 61 | } |
| 58 | } | 62 | } |
| 59 | 63 |
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', |
| 5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, | 5 | function($uibModalInstance, focaBusquedaClienteService, $scope, $filter, |
| 6 | $uibModal, focaModalService, $timeout, vendedor) { | 6 | $uibModal, focaModalService, $timeout, vendedor) { |
| 7 | 7 | ||
| 8 | $scope.vendedor = vendedor ? vendedor : {}; | 8 | $scope.vendedor = vendedor ? vendedor : {}; |
| 9 | $scope.filters = ''; | 9 | $scope.filters = ''; |
| 10 | $scope.primerBusqueda = false; | 10 | $scope.primerBusqueda = false; |
| 11 | // pagination | 11 | // pagination |
| 12 | $scope.numPerPage = 10; | 12 | $scope.numPerPage = 10; |
| 13 | $scope.currentPage = 1; | 13 | $scope.currentPage = 1; |
| 14 | $scope.filteredClientes = []; | 14 | $scope.filteredClientes = []; |
| 15 | $scope.currentPageClientes = []; | 15 | $scope.currentPageClientes = []; |
| 16 | $scope.selectedClientes = -1; | 16 | $scope.selectedClientes = -1; |
| 17 | $scope.ingreso = false; | 17 | $scope.ingreso = false; |
| 18 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); | 18 | $scope.regexCuit = new RegExp(/\b(20|23|24|27|30|33|34)(\D)?[0-9]{8}(\D)?[0-9]/g); |
| 19 | $scope.focused = 1; | 19 | $scope.focused = 1; |
| 20 | 20 | ||
| 21 | $scope.cliente = { | 21 | $scope.cliente = { |
| 22 | COD: 0, | 22 | COD: 0, |
| 23 | ES_MAY: true, | 23 | ES_MAY: true, |
| 24 | provincia: { | 24 | provincia: { |
| 25 | NOMBRE: '' | 25 | NOMBRE: '' |
| 26 | }, | 26 | }, |
| 27 | localidad: { | 27 | localidad: { |
| 28 | NOMBRE: '' | 28 | NOMBRE: '' |
| 29 | }, | 29 | }, |
| 30 | iva: { | 30 | iva: { |
| 31 | NOMBRE: '' | 31 | NOMBRE: '' |
| 32 | }, | 32 | }, |
| 33 | actividad: { | 33 | actividad: { |
| 34 | NOM: '' | 34 | NOM: '' |
| 35 | }, | 35 | }, |
| 36 | zona: { | 36 | zona: { |
| 37 | NOM: '' | 37 | NOM: '' |
| 38 | }, | 38 | }, |
| 39 | tipoFactura: { | 39 | tipoFactura: { |
| 40 | NOMBRE: '' | 40 | NOMBRE: '' |
| 41 | }, | 41 | }, |
| 42 | tipoComprobante: { | 42 | tipoComprobante: { |
| 43 | NOMBRE: '' | 43 | NOMBRE: '' |
| 44 | }, | 44 | }, |
| 45 | formaPago: { | 45 | formaPago: { |
| 46 | NOMBRE: '' | 46 | NOMBRE: '' |
| 47 | }, | 47 | }, |
| 48 | cobrador: { | 48 | cobrador: { |
| 49 | NomVen: '' | 49 | NomVen: '' |
| 50 | } | 50 | } |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | $scope.busquedaPress = function(key) { | 53 | $scope.busquedaPress = function(key) { |
| 54 | if (key === 13) { | 54 | if (key === 13) { |
| 55 | var funcion = ($scope.vendedor.CodVen) ? | 55 | var funcion = ($scope.vendedor.CodVen) ? |
| 56 | 'obtenerClientesPorNombreOCuitByVendedor' : 'obtenerClientesPorNombreOCuit'; | 56 | 'obtenerClientesPorNombreOCuitByVendedor' : 'obtenerClientesPorNombreOCuit'; |
| 57 | 57 | ||
| 58 | $scope.searchLoading = true; | 58 | $scope.searchLoading = true; |
| 59 | focaBusquedaClienteService | 59 | focaBusquedaClienteService |
| 60 | [funcion]($scope.filters, $scope.vendedor.CodVen) | 60 | [funcion]($scope.filters, $scope.vendedor.CodVen) |
| 61 | .then( | 61 | .then( |
| 62 | function(res) { | 62 | function(res) { |
| 63 | $scope.primerBusqueda = true; | 63 | $scope.primerBusqueda = true; |
| 64 | $scope.clientes = res.data; | 64 | $scope.clientes = res.data; |
| 65 | $scope.search(true); | 65 | $scope.search(true); |
| 66 | primera(); | 66 | primera(); |
| 67 | $scope.searchLoading = false; | 67 | $scope.searchLoading = false; |
| 68 | }); | 68 | }); |
| 69 | } | 69 | } |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | $scope.search = function (pressed) { | 72 | $scope.search = function (pressed) { |
| 73 | if($scope.primerBusqueda) { | 73 | if($scope.primerBusqueda) { |
| 74 | $scope.filteredClientes = $filter('filter')( | 74 | $scope.filteredClientes = $filter('filter')( |
| 75 | $scope.clientes, {$: $scope.filters} | 75 | $scope.clientes, {$: $scope.filters} |
| 76 | ); | 76 | ); |
| 77 | 77 | ||
| 78 | if(pressed && $scope.filteredClientes.length === 0){ | 78 | if(pressed && $scope.filteredClientes.length === 0){ |
| 79 | $timeout(function() { | 79 | $timeout(function() { |
| 80 | angular.element('#search')[0].focus(); | 80 | angular.element('#search')[0].focus(); |
| 81 | $scope.filters = ''; | 81 | $scope.filters = ''; |
| 82 | }); | 82 | }); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | $scope.lastPage = Math.ceil( | 85 | $scope.lastPage = Math.ceil( |
| 86 | $scope.filteredClientes.length / $scope.numPerPage | 86 | $scope.filteredClientes.length / $scope.numPerPage |
| 87 | ); | 87 | ); |
| 88 | 88 | ||
| 89 | $scope.resetPage(); | 89 | $scope.resetPage(); |
| 90 | } | 90 | } |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | $scope.resetPage = function () { | 93 | $scope.resetPage = function () { |
| 94 | $scope.currentPage = 1; | 94 | $scope.currentPage = 1; |
| 95 | $scope.selectPage(1); | 95 | $scope.selectPage(1); |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | $scope.selectPage = function (page) { | 98 | $scope.selectPage = function (page) { |
| 99 | var start = (page - 1) * $scope.numPerPage; | 99 | var start = (page - 1) * $scope.numPerPage; |
| 100 | var end = start + $scope.numPerPage; | 100 | var end = start + $scope.numPerPage; |
| 101 | $scope.paginas = []; | 101 | $scope.paginas = []; |
| 102 | $scope.paginas = calcularPages(page); | 102 | $scope.paginas = calcularPages(page); |
| 103 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); | 103 | $scope.currentPageClientes = $scope.filteredClientes.slice(start, end); |
| 104 | $scope.currentPage = page; | 104 | $scope.currentPage = page; |
| 105 | }; | 105 | }; |
| 106 | 106 | ||
| 107 | $scope.select = function(cliente, esNuevo = false) { | 107 | $scope.select = function(cliente, esNuevo = false) { |
| 108 | cliente.esNuevo = esNuevo; | 108 | cliente.esNuevo = esNuevo; |
| 109 | $uibModalInstance.close(cliente); | 109 | $uibModalInstance.close(cliente); |
| 110 | }; | 110 | }; |
| 111 | 111 | ||
| 112 | $scope.cancel = function() { | 112 | $scope.cancel = function() { |
| 113 | if($scope.ingreso) { | 113 | if($scope.ingreso) { |
| 114 | $scope.ingreso = false; | 114 | $scope.ingreso = false; |
| 115 | }else { | 115 | }else { |
| 116 | $uibModalInstance.dismiss('cancel'); | 116 | $uibModalInstance.dismiss('cancel'); |
| 117 | } | 117 | } |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | $scope.busquedaDown = function(key) { | 120 | $scope.busquedaDown = function(key) { |
| 121 | if (key === 40) { | 121 | if (key === 40) { |
| 122 | primera(key); | 122 | primera(key); |
| 123 | } | 123 | } |
| 124 | }; | 124 | }; |
| 125 | 125 | ||
| 126 | $scope.itemCliente = function(key) { | 126 | $scope.itemCliente = function(key) { |
| 127 | if (key === 38) { | 127 | if (key === 38) { |
| 128 | anterior(key); | 128 | anterior(key); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | if (key === 40) { | 131 | if (key === 40) { |
| 132 | siguiente(key); | 132 | siguiente(key); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | if (key === 37) { | 135 | if (key === 37) { |
| 136 | retrocederPagina(); | 136 | retrocederPagina(); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | if (key === 39) { | 139 | if (key === 39) { |
| 140 | avanzarPagina(); | 140 | avanzarPagina(); |
| 141 | } | 141 | } |
| 142 | }; | 142 | }; |
| 143 | 143 | ||
| 144 | $scope.focus = function(val) { | 144 | $scope.focus = function(val) { |
| 145 | $scope.focused = val; | 145 | $scope.focused = val; |
| 146 | }; | 146 | }; |
| 147 | 147 | ||
| 148 | $scope.next = function(key) { | 148 | $scope.next = function(key) { |
| 149 | if (key === 13) $scope.focused++; | 149 | if (key === 13) $scope.focused++; |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | $scope.seleccionarProvincia = function(key) { | 152 | $scope.seleccionarProvincia = function(key) { |
| 153 | if(key === 13) { | 153 | if(key === 13) { |
| 154 | var parametrosModal = { | 154 | var parametrosModal = { |
| 155 | query: '/provincia', | 155 | query: '/provincia', |
| 156 | columnas: { | 156 | columnas: [ |
| 157 | nombre: ['Código', 'Nombre'], | 157 | { |
| 158 | propiedad: ['ID', 'NOMBRE'] | 158 | propiedad: 'ID', |
| 159 | }, | 159 | nombre: 'Codigo', |
| 160 | filtro: { | ||
| 161 | nombre: 'rellenarDigitos', | ||
| 162 | parametro: 3} | ||
| 163 | }, | ||
| 164 | { | ||
| 165 | propiedad: 'NOMBRE', | ||
| 166 | nombre: 'Nombre' | ||
| 167 | } | ||
| 168 | ], | ||
| 160 | titulo:'Búsqueda de provincias', | 169 | titulo:'Búsqueda de provincias', |
| 161 | size: 'md' | 170 | size: 'md' |
| 162 | } | 171 | }; |
| 163 | focaModalService.modal(parametrosModal).then(function(provincia) { | 172 | focaModalService.modal(parametrosModal).then(function(provincia) { |
| 164 | $scope.cliente.provincia = provincia; | 173 | $scope.cliente.provincia = provincia; |
| 165 | $timeout(function() { | 174 | $timeout(function() { |
| 166 | $scope.focused = 5; | 175 | $scope.focused = 5; |
| 167 | }); | 176 | }); |
| 168 | }, function() { | 177 | }, function() { |
| 169 | //TODO: función llamada cuando cancela el modal | 178 | //TODO: función llamada cuando cancela el modal |
| 170 | }); | 179 | }); |
| 171 | } | 180 | } |
| 172 | }; | 181 | }; |
| 173 | $scope.seleccionarLocalidad = function(key) { | 182 | $scope.seleccionarLocalidad = function(key) { |
| 174 | if($scope.cliente.provincia.ID === undefined) { | 183 | if($scope.cliente.provincia.ID === undefined) { |
| 175 | focaModalService.alert('Seleccione una provincia'); | 184 | focaModalService.alert('Seleccione una provincia'); |
| 176 | return; | 185 | return; |
| 177 | } | 186 | } |
| 178 | if(key === 13) { | 187 | if(key === 13) { |
| 179 | var parametrosModal = { | 188 | var parametrosModal = { |
| 180 | query: '/localidad/' + $scope.cliente.provincia.ID, | 189 | query: '/localidad/' + $scope.cliente.provincia.ID, |
| 181 | columnas: { | 190 | columnas: [ |
| 182 | nombre: ['Código', 'Nombre'], | 191 | { |
| 183 | propiedad: ['ID', 'NOMBRE'] | 192 | propiedad: 'ID', |
| 184 | }, | 193 | nombre: 'Código', |
| 194 | filtro: { | ||
| 195 | nombre: 'rellenarDigitos', | ||
| 196 | parametro: 3 | ||
| 197 | } | ||
| 198 | }, | ||
| 199 | { | ||
| 200 | propiedad: 'NOMBRE', | ||
| 201 | nombre: 'Nombre' | ||
| 202 | } | ||
| 203 | ], | ||
| 185 | titulo:'Búsqueda de localidades', | 204 | titulo:'Búsqueda de localidades', |
| 186 | size: 'md' | 205 | size: 'md' |
| 187 | } | 206 | }; |
| 188 | focaModalService.modal(parametrosModal).then(function(localidad) { | 207 | focaModalService.modal(parametrosModal).then(function(localidad) { |
| 189 | $scope.cliente.localidad = localidad; | 208 | $scope.cliente.localidad = localidad; |
| 190 | $timeout(function() { | 209 | $timeout(function() { |
| 191 | $scope.focused = 6; | 210 | $scope.focused = 6; |
| 192 | }); | 211 | }); |
| 193 | }, function() { | 212 | }, function() { |
| 194 | //TODO: función llamada cuando cancela el modal | 213 | //TODO: función llamada cuando cancela el modal |
| 195 | }); | 214 | }); |
| 196 | } | 215 | } |
| 197 | }; | 216 | }; |
| 198 | $scope.seleccionarIva = function(key) { | 217 | $scope.seleccionarIva = function(key) { |
| 199 | if(key === 13) { | 218 | if(key === 13) { |
| 200 | var parametrosModal = { | 219 | var parametrosModal = { |
| 201 | query: '/iva', | 220 | query: '/iva', |
| 202 | columnas: { | 221 | columnas: [ |
| 203 | nombre: ['Código', 'Nombre'], | 222 | { |
| 204 | propiedad: ['ID', 'NOMBRE',] | 223 | propiedad: 'ID', |
| 205 | }, | 224 | nombre: 'Código', |
| 225 | filtro: { | ||
| 226 | nombre: 'rellenarDigitos', | ||
| 227 | parametro: 3 | ||
| 228 | } | ||
| 229 | }, | ||
| 230 | { | ||
| 231 | propiedad: 'NOMBRE', | ||
| 232 | nombre: 'Nombre' | ||
| 233 | } | ||
| 234 | ], | ||
| 206 | titulo:'Búsqueda de responsabilidad ante el IVA', | 235 | titulo:'Búsqueda de responsabilidad ante el IVA', |
| 207 | size: 'md' | 236 | size: 'md' |
| 208 | } | 237 | }; |
| 209 | focaModalService.modal(parametrosModal).then( | 238 | focaModalService.modal(parametrosModal).then( |
| 210 | function(iva) { | 239 | function(iva) { |
| 211 | $scope.cliente.iva = iva; | 240 | $scope.cliente.iva = iva; |
| 212 | $timeout(function() { | 241 | $timeout(function() { |
| 213 | $scope.focused = 10; | 242 | $scope.focused = 10; |
| 214 | }); | 243 | }); |
| 215 | }, function() { | 244 | }, function() { |
| 216 | // funcion ejecutada cuando se cancela el modal | 245 | // funcion ejecutada cuando se cancela el modal |
| 217 | }); | 246 | }); |
| 218 | } | 247 | } |
| 219 | }; | 248 | }; |
| 220 | $scope.seleccionarActividad = function(key) { | 249 | $scope.seleccionarActividad = function(key) { |
| 221 | if(key === 13) { | 250 | if(key === 13) { |
| 222 | var parametrosModal = { | 251 | var parametrosModal = { |
| 223 | query: '/actividad', | 252 | query: '/actividad', |
| 224 | columnas: { | 253 | columnas: [ |
| 225 | nombre: ['Código', 'Nombre'], | 254 | { |
| 226 | propiedad: ['ID', 'NOM',] | 255 | propiedad: 'ID', |
| 227 | }, | 256 | nombre: 'Código', |
| 257 | filtro: { | ||
| 258 | nombre: 'rellenarDigitos', | ||
| 259 | parametro: 3 | ||
| 260 | } | ||
| 261 | }, | ||
| 262 | { | ||
| 263 | propiedad: 'NOM', | ||
| 264 | nombre: 'Nombre' | ||
| 265 | } | ||
| 266 | ], | ||
| 228 | titulo: 'Búsqueda de actividades', | 267 | titulo: 'Búsqueda de actividades', |
| 229 | size: 'md' | 268 | size: 'md' |
| 230 | } | 269 | }; |
| 231 | focaModalService.modal(parametrosModal).then( | 270 | focaModalService.modal(parametrosModal).then( |
| 232 | function(actividad) { | 271 | function(actividad) { |
| 233 | $scope.cliente.actividad = actividad; | 272 | $scope.cliente.actividad = actividad; |
| 234 | $timeout(function() { | 273 | $timeout(function() { |
| 235 | $scope.focused = 8; | 274 | $scope.focused = 8; |
| 236 | }); | 275 | }); |
| 237 | }, function() { | 276 | }, function() { |
| 238 | // funcion ejecutada cuando se cancela el modal | 277 | // funcion ejecutada cuando se cancela el modal |
| 239 | }); | 278 | }); |
| 240 | } | 279 | } |
| 241 | }; | 280 | }; |
| 242 | $scope.seleccionarZona = function(key) { | 281 | $scope.seleccionarZona = function(key) { |
| 243 | if(key === 13) { | 282 | if(key === 13) { |
| 244 | var parametrosModal = { | 283 | var parametrosModal = { |
| 245 | query: '/zona', | 284 | query: '/zona', |
| 246 | columnas: { | 285 | columnas: [ |
| 247 | nombre: ['Código', 'Nombre'], | 286 | { |
| 248 | propiedad: ['ID', 'NOM',] | 287 | propiedad: 'ID', |
| 249 | }, | 288 | nombre: 'Código', |
| 289 | filtro: { | ||
| 290 | nombre: 'rellenarDigitos', | ||
| 291 | parametro: 3 | ||
| 292 | } | ||
| 293 | }, | ||
| 294 | { | ||
| 295 | propiedad: 'NOM', | ||
| 296 | nombre: 'Nombre' | ||
| 297 | } | ||
| 298 | ], | ||
| 250 | titulo: 'Búsqueda de zonas', | 299 | titulo: 'Búsqueda de zonas', |
| 251 | size: 'md' | 300 | size: 'md' |
| 252 | } | 301 | }; |
| 253 | focaModalService.modal(parametrosModal).then( | 302 | focaModalService.modal(parametrosModal).then( |
| 254 | function(zona) { | 303 | function(zona) { |
| 255 | $scope.cliente.zona = zona; | 304 | $scope.cliente.zona = zona; |
| 256 | $timeout(function() { | 305 | $timeout(function() { |
| 257 | $scope.focused = 7; | 306 | $scope.focused = 7; |
| 258 | }); | 307 | }); |
| 259 | }, function() { | 308 | }, function() { |
| 260 | // funcion ejecutada cuando se cancela el modal | 309 | // funcion ejecutada cuando se cancela el modal |
| 261 | }); | 310 | }); |
| 262 | } | 311 | } |
| 263 | }; | 312 | }; |
| 264 | $scope.seleccionarTipoFactura = function(key) { | 313 | $scope.seleccionarTipoFactura = function(key) { |
| 265 | if(key === 13) { | 314 | if(key === 13) { |
| 266 | var parametrosModal = { | 315 | var parametrosModal = { |
| 267 | query: '/tipo-factura', | 316 | query: '/tipo-factura', |
| 268 | columnas: { | 317 | columnas: [ |
| 269 | nombre: ['Código', 'Nombre'], | 318 | { |
| 270 | propiedad: ['ID', 'NOMBRE',] | 319 | propiedad: 'ID', |
| 271 | }, | 320 | nombre: 'Código' |
| 321 | }, | ||
| 322 | { | ||
| 323 | propiedad: 'NOMBRE', | ||
| 324 | nombre: 'Nombre' | ||
| 325 | } | ||
| 326 | ], | ||
| 272 | titulo: 'Búsqueda de tipos de factura', | 327 | titulo: 'Búsqueda de tipos de factura', |
| 273 | size: 'md' | 328 | size: 'md' |
| 274 | } | 329 | }; |
| 275 | focaModalService.modal(parametrosModal).then( | 330 | focaModalService.modal(parametrosModal).then( |
| 276 | function(tipoFactura) { | 331 | function(tipoFactura) { |
| 277 | $scope.cliente.tipoFactura = tipoFactura; | 332 | $scope.cliente.tipoFactura = tipoFactura; |
| 278 | $timeout(function() { | 333 | $timeout(function() { |
| 279 | $scope.focused = 11; | 334 | $scope.focused = 11; |
| 280 | }); | 335 | }); |
| 281 | }, function() { | 336 | }, function() { |
| 282 | // funcion ejecutada cuando se cancela el modal | 337 | // funcion ejecutada cuando se cancela el modal |
| 283 | }); | 338 | }); |
| 284 | } | 339 | } |
| 285 | }; | 340 | }; |
| 286 | $scope.seleccionarTipoComprobante = function(key) { | 341 | $scope.seleccionarTipoComprobante = function(key) { |
| 287 | if(key === 13) { | 342 | if(key === 13) { |
| 288 | var parametrosModal = { | 343 | var parametrosModal = { |
| 289 | query: '/tipo-comprobante', | 344 | query: '/tipo-comprobante', |
| 290 | columnas: { | 345 | columnas: [ |
| 291 | nombre: ['Código', 'Nombre'], | 346 | { |
| 292 | propiedad: ['ID', 'NOMBRE',] | 347 | propiedad: 'ID', |
| 293 | }, | 348 | nombre: 'Código' |
| 349 | }, | ||
| 350 | { | ||
| 351 | propiedad: 'NOMBRE', | ||
| 352 | nombre: 'Nombre' | ||
| 353 | } | ||
| 354 | ], | ||
| 294 | titulo: 'Búsqueda de tipos de comprobante', | 355 | titulo: 'Búsqueda de tipos de comprobante', |
| 295 | size: 'md' | 356 | size: 'md' |
| 296 | } | 357 | }; |
| 297 | focaModalService.modal(parametrosModal).then( | 358 | focaModalService.modal(parametrosModal).then( |
| 298 | function(tipoComprobante) { | 359 | function(tipoComprobante) { |
| 299 | $scope.cliente.tipoComprobante = tipoComprobante; | 360 | $scope.cliente.tipoComprobante = tipoComprobante; |
| 300 | $timeout(function() { | 361 | $timeout(function() { |
| 301 | $scope.focused = 13; | 362 | $scope.focused = 13; |
| 302 | }); | 363 | }); |
| 303 | }, function() { | 364 | }, function() { |
| 304 | // funcion ejecutada cuando se cancela el modal | 365 | // funcion ejecutada cuando se cancela el modal |
| 305 | }); | 366 | }); |
| 306 | } | 367 | } |
| 307 | }; | 368 | }; |
| 308 | $scope.seleccionarFormaPago = function(key) { | 369 | $scope.seleccionarFormaPago = function(key) { |
| 309 | if(key === 13) { | 370 | if(key === 13) { |
| 310 | var parametrosModal = { | 371 | var parametrosModal = { |
| 311 | query: '/forma-pago', | 372 | query: '/forma-pago', |
| 312 | columnas: { | 373 | columnas: [ |
| 313 | nombre: ['Código', 'Nombre'], | 374 | { |
| 314 | propiedad: ['ID', 'NOMBRE',] | 375 | propiedad: 'ID', |
| 315 | }, | 376 | nombre: 'Código', |
| 377 | filtro: { | ||
| 378 | nombre: 'rellenarDigitos', | ||
| 379 | parametro: 3 | ||
| 380 | } | ||
| 381 | }, | ||
| 382 | { | ||
| 383 | propiedad: 'NOMBRE', | ||
| 384 | nombre: 'Nombre' | ||
| 385 | } | ||
| 386 | ], | ||
| 316 | titulo: 'Búsqueda de formas de pago', | 387 | titulo: 'Búsqueda de formas de pago', |
| 317 | size: 'md' | 388 | size: 'md' |
| 318 | } | 389 | }; |
| 319 | focaModalService.modal(parametrosModal).then( | 390 | focaModalService.modal(parametrosModal).then( |
| 320 | function(formaPago) { | 391 | function(formaPago) { |
| 321 | $scope.cliente.formaPago = formaPago; | 392 | $scope.cliente.formaPago = formaPago; |
| 322 | }, function() { | 393 | }, function() { |
| 323 | // funcion ejecutada cuando se cancela el modal | 394 | // funcion ejecutada cuando se cancela el modal |
| 324 | }); | 395 | }); |
| 325 | } | 396 | } |
| 326 | }; | 397 | }; |
| 327 | $scope.seleccionarCobrador = function(key) { | 398 | $scope.seleccionarCobrador = function(key) { |
| 328 | if(key === 13) { | 399 | if(key === 13) { |
| 329 | var parametrosModal = { | 400 | var parametrosModal = { |
| 330 | query: '/cobrador', | 401 | query: '/cobrador', |
| 331 | columnas: { | 402 | columnas: [ |
| 332 | nombre: ['Código', 'Nombre'], | 403 | { |
| 333 | propiedad: ['CodVen', 'NomVen',] | 404 | propiedad: 'CodVen', |
| 334 | }, | 405 | nombre: 'Código' |
| 406 | }, | ||
| 407 | { | ||
| 408 | propiedad: 'NomVen', | ||
| 409 | nombre: 'Nombre' | ||
| 410 | } | ||
| 411 | ], | ||
| 335 | titulo: 'Búsqueda de cobradores', | 412 | titulo: 'Búsqueda de cobradores', |
| 336 | size: 'md' | 413 | size: 'md' |
| 337 | } | 414 | }; |
| 338 | focaModalService.modal(parametrosModal).then( | 415 | focaModalService.modal(parametrosModal).then( |
| 339 | function(cobrador) { | 416 | function(cobrador) { |
| 340 | $scope.cliente.cobrador = cobrador; | 417 | $scope.cliente.cobrador = cobrador; |
| 341 | }, function() { | 418 | }, function() { |
| 342 | // funcion ejecutada cuando se cancela el modal | 419 | // funcion ejecutada cuando se cancela el modal |
| 343 | }); | 420 | }); |
| 344 | } | 421 | } |
| 345 | }; | 422 | }; |
| 346 | 423 | ||
| 347 | $scope.guardar = function() { | 424 | $scope.guardar = function() { |
| 348 | 425 | ||
| 349 | $scope.cliente.PCX = $scope.cliente.provincia.ID; | 426 | $scope.cliente.PCX = $scope.cliente.provincia.ID; |
| 350 | $scope.cliente.LOX = $scope.cliente.localidad.ID; | 427 | $scope.cliente.LOX = $scope.cliente.localidad.ID; |
| 351 | $scope.cliente.IVA = $scope.cliente.iva.ID; | 428 | $scope.cliente.IVA = $scope.cliente.iva.ID; |
| 352 | $scope.cliente.ACT = $scope.cliente.actividad.ID; | 429 | $scope.cliente.ACT = $scope.cliente.actividad.ID; |
| 353 | $scope.cliente.ZON = $scope.cliente.zona.ID; | 430 | $scope.cliente.ZON = $scope.cliente.zona.ID; |
| 354 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; | 431 | $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; |
| 355 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; | 432 | $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; |
| 356 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; | 433 | $scope.cliente.FPA = $scope.cliente.formaPago.ID; |
| 357 | $scope.cliente.VEN = $scope.vendedor.CodVen; | 434 | $scope.cliente.VEN = $scope.vendedor.CodVen; |
| 358 | $scope.cliente.idCobrador = $scope.cliente.cobrador.CodVen; | 435 | $scope.cliente.idCobrador = $scope.cliente.cobrador.CodVen; |
| 359 | 436 | ||
| 360 | delete $scope.cliente.provincia; | 437 | delete $scope.cliente.provincia; |
| 361 | delete $scope.cliente.localidad; | 438 | delete $scope.cliente.localidad; |
| 362 | delete $scope.cliente.iva; | 439 | delete $scope.cliente.iva; |
| 363 | delete $scope.cliente.actividad; | 440 | delete $scope.cliente.actividad; |
| 364 | delete $scope.cliente.zona; | 441 | delete $scope.cliente.zona; |
| 365 | delete $scope.cliente.tipoFactura; | 442 | delete $scope.cliente.tipoFactura; |
| 366 | delete $scope.cliente.tipoComprobante; | 443 | delete $scope.cliente.tipoComprobante; |
| 367 | delete $scope.cliente.formaPago; | 444 | delete $scope.cliente.formaPago; |
| 368 | delete $scope.cliente.cobrador; | 445 | delete $scope.cliente.cobrador; |
| 369 | 446 | ||
| 370 | focaBusquedaClienteService | 447 | focaBusquedaClienteService |
| 371 | .guardarCliente($scope.cliente) | 448 | .guardarCliente($scope.cliente) |
| 372 | .then(function(res) { | 449 | .then(function(res) { |
| 373 | var cliente = { | 450 | var cliente = { |
| 374 | cod: res.data.COD, | 451 | cod: res.data.COD, |
| 375 | cuit: res.data.CUIT, | 452 | cuit: res.data.CUIT, |
| 376 | esNuevo: res.data.esNuevo, | 453 | esNuevo: res.data.esNuevo, |
| 377 | nom: res.data.NOM | 454 | nom: res.data.NOM |
| 378 | }; | 455 | }; |
| 379 | $scope.select(cliente, true); | 456 | $scope.select(cliente, true); |
| 380 | }); | 457 | }); |
| 381 | }; | 458 | }; |
| 382 | 459 | ||
| 383 | function calcularPages(paginaActual) { | 460 | function calcularPages(paginaActual) { |
| 384 | var paginas = []; | 461 | var paginas = []; |
| 385 | paginas.push(paginaActual); | 462 | paginas.push(paginaActual); |
| 386 | 463 | ||
| 387 | if (paginaActual - 1 > 1) { | 464 | if (paginaActual - 1 > 1) { |
| 388 | 465 | ||
| 389 | paginas.unshift(paginaActual - 1); | 466 | paginas.unshift(paginaActual - 1); |
| 390 | if (paginaActual - 2 > 1) { | 467 | if (paginaActual - 2 > 1) { |
| 391 | paginas.unshift(paginaActual - 2); | 468 | paginas.unshift(paginaActual - 2); |
| 392 | } | 469 | } |
| 393 | } | 470 | } |
| 394 | 471 | ||
| 395 | if (paginaActual + 1 < $scope.lastPage) { | 472 | if (paginaActual + 1 < $scope.lastPage) { |
| 396 | paginas.push(paginaActual + 1); | 473 | paginas.push(paginaActual + 1); |
| 397 | if (paginaActual + 2 < $scope.lastPage) { | 474 | if (paginaActual + 2 < $scope.lastPage) { |
| 398 | paginas.push(paginaActual + 2); | 475 | paginas.push(paginaActual + 2); |
| 399 | } | 476 | } |
| 400 | } | 477 | } |
| 401 | 478 | ||
| 402 | if (paginaActual !== 1) { | 479 | if (paginaActual !== 1) { |
| 403 | paginas.unshift(1); | 480 | paginas.unshift(1); |
| 404 | } | 481 | } |
| 405 | 482 | ||
| 406 | if (paginaActual !== $scope.lastPage) { | 483 | if (paginaActual !== $scope.lastPage) { |
| 407 | paginas.push($scope.lastPage); | 484 | paginas.push($scope.lastPage); |
| 408 | } | 485 | } |
| 409 | 486 | ||
| 410 | return paginas; | 487 | return paginas; |
| 411 | } | 488 | } |
| 412 | 489 | ||
| 413 | function primera() { | 490 | function primera() { |
| 414 | $scope.selectedClientes = 0; | 491 | $scope.selectedClientes = 0; |
| 415 | } | 492 | } |
| 416 | 493 | ||
| 417 | function anterior() { | 494 | function anterior() { |
| 418 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { | 495 | if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { |
| 419 | retrocederPagina(); | 496 | retrocederPagina(); |
| 420 | } else { | 497 | } else { |
| 421 | $scope.selectedClientes--; | 498 | $scope.selectedClientes--; |
| 422 | } | 499 | } |
| 423 | } | 500 | } |
| 424 | 501 | ||
| 425 | function siguiente() { | 502 | function siguiente() { |
| 426 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { | 503 | if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { |
| 427 | $scope.selectedClientes++; | 504 | $scope.selectedClientes++; |
| 428 | } else { | 505 | } else { |
| 429 | avanzarPagina(); | 506 | avanzarPagina(); |
| 430 | } | 507 | } |
| 431 | } | 508 | } |
| 432 | 509 | ||
| 433 | function retrocederPagina() { | 510 | function retrocederPagina() { |
| 434 | if ($scope.currentPage > 1) { | 511 | if ($scope.currentPage > 1) { |
| 435 | $scope.selectPage($scope.currentPage - 1); | 512 | $scope.selectPage($scope.currentPage - 1); |
| 436 | $scope.selectedClientes = $scope.numPerPage - 1; | 513 | $scope.selectedClientes = $scope.numPerPage - 1; |
| 437 | } | 514 | } |
| 438 | } | 515 | } |
| 439 | 516 | ||
| 440 | function avanzarPagina() { | 517 | function avanzarPagina() { |
| 441 | if ($scope.currentPage < $scope.lastPage) { | 518 | if ($scope.currentPage < $scope.lastPage) { |
| 442 | $scope.selectPage($scope.currentPage + 1); | 519 | $scope.selectPage($scope.currentPage + 1); |
| 443 | $scope.selectedClientes = 0; | 520 | $scope.selectedClientes = 0; |
| 444 | } | 521 | } |
| 445 | } | 522 | } |
| 446 | } | 523 | } |
| 447 | ]); | 524 | ]); |
| 448 | 525 |