Commit 92d933c4f52e129d83f62e6f3e8db98f67443178

Authored by Eric Fernandez
1 parent bfa63f2012
Exists in master

semicolon

Showing 3 changed files with 14 additions and 10 deletions   Show diff stats
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
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 { 157 {
158 propiedad: 'ID', 158 propiedad: 'ID',
159 nombre: 'Codigo', 159 nombre: 'Codigo',
160 filtro: { 160 filtro: {
161 nombre: 'rellenarDigitos', 161 nombre: 'rellenarDigitos',
162 parametro: 3} 162 parametro: 3}
163 }, 163 },
164 { 164 {
165 propiedad: 'NOMBRE', 165 propiedad: 'NOMBRE',
166 nombre: 'Nombre' 166 nombre: 'Nombre'
167 } 167 }
168 ], 168 ],
169 titulo:'Búsqueda de provincias', 169 titulo:'Búsqueda de provincias',
170 size: 'md' 170 size: 'md'
171 } 171 };
172 focaModalService.modal(parametrosModal).then(function(provincia) { 172 focaModalService.modal(parametrosModal).then(function(provincia) {
173 $scope.cliente.provincia = provincia; 173 $scope.cliente.provincia = provincia;
174 $timeout(function() { 174 $timeout(function() {
175 $scope.focused = 5; 175 $scope.focused = 5;
176 }); 176 });
177 }, function() { 177 }, function() {
178 //TODO: función llamada cuando cancela el modal 178 //TODO: función llamada cuando cancela el modal
179 }); 179 });
180 } 180 }
181 }; 181 };
182 $scope.seleccionarLocalidad = function(key) { 182 $scope.seleccionarLocalidad = function(key) {
183 if($scope.cliente.provincia.ID === undefined) { 183 if($scope.cliente.provincia.ID === undefined) {
184 focaModalService.alert('Seleccione una provincia'); 184 focaModalService.alert('Seleccione una provincia');
185 return; 185 return;
186 } 186 }
187 if(key === 13) { 187 if(key === 13) {
188 var parametrosModal = { 188 var parametrosModal = {
189 query: '/localidad/' + $scope.cliente.provincia.ID, 189 query: '/localidad/' + $scope.cliente.provincia.ID,
190 columnas: [ 190 columnas: [
191 { 191 {
192 propiedad: 'ID', 192 propiedad: 'ID',
193 nombre: 'Código', 193 nombre: 'Código',
194 filtro: { 194 filtro: {
195 nombre: 'rellenarDigitos', 195 nombre: 'rellenarDigitos',
196 parametro: 3 196 parametro: 3
197 } 197 }
198 }, 198 },
199 { 199 {
200 propiedad: 'NOMBRE', 200 propiedad: 'NOMBRE',
201 nombre: 'Nombre' 201 nombre: 'Nombre'
202 } 202 }
203 ], 203 ],
204 titulo:'Búsqueda de localidades', 204 titulo:'Búsqueda de localidades',
205 size: 'md' 205 size: 'md'
206 } 206 };
207 focaModalService.modal(parametrosModal).then(function(localidad) { 207 focaModalService.modal(parametrosModal).then(function(localidad) {
208 $scope.cliente.localidad = localidad; 208 $scope.cliente.localidad = localidad;
209 $timeout(function() { 209 $timeout(function() {
210 $scope.focused = 6; 210 $scope.focused = 6;
211 }); 211 });
212 }, function() { 212 }, function() {
213 //TODO: función llamada cuando cancela el modal 213 //TODO: función llamada cuando cancela el modal
214 }); 214 });
215 } 215 }
216 }; 216 };
217 $scope.seleccionarIva = function(key) { 217 $scope.seleccionarIva = function(key) {
218 if(key === 13) { 218 if(key === 13) {
219 var parametrosModal = { 219 var parametrosModal = {
220 query: '/iva', 220 query: '/iva',
221 columnas: [ 221 columnas: [
222 { 222 {
223 propiedad: 'ID', 223 propiedad: 'ID',
224 nombre: 'Código', 224 nombre: 'Código',
225 filtro: { 225 filtro: {
226 nombre: 'rellenarDigitos', 226 nombre: 'rellenarDigitos',
227 parametro: 3 227 parametro: 3
228 } 228 }
229 }, 229 },
230 { 230 {
231 propiedad: 'NOMBRE', 231 propiedad: 'NOMBRE',
232 nombre: 'Nombre' 232 nombre: 'Nombre'
233 } 233 }
234 ], 234 ],
235 titulo:'Búsqueda de responsabilidad ante el IVA', 235 titulo:'Búsqueda de responsabilidad ante el IVA',
236 size: 'md' 236 size: 'md'
237 } 237 };
238 focaModalService.modal(parametrosModal).then( 238 focaModalService.modal(parametrosModal).then(
239 function(iva) { 239 function(iva) {
240 $scope.cliente.iva = iva; 240 $scope.cliente.iva = iva;
241 $timeout(function() { 241 $timeout(function() {
242 $scope.focused = 10; 242 $scope.focused = 10;
243 }); 243 });
244 }, function() { 244 }, function() {
245 // funcion ejecutada cuando se cancela el modal 245 // funcion ejecutada cuando se cancela el modal
246 }); 246 });
247 } 247 }
248 }; 248 };
249 $scope.seleccionarActividad = function(key) { 249 $scope.seleccionarActividad = function(key) {
250 if(key === 13) { 250 if(key === 13) {
251 var parametrosModal = { 251 var parametrosModal = {
252 query: '/actividad', 252 query: '/actividad',
253 columnas: [ 253 columnas: [
254 { 254 {
255 propiedad: 'ID', 255 propiedad: 'ID',
256 nombre: 'Código', 256 nombre: 'Código',
257 filtro: { 257 filtro: {
258 nombre: 'rellenarDigitos', 258 nombre: 'rellenarDigitos',
259 parametro: 3 259 parametro: 3
260 } 260 }
261 }, 261 },
262 { 262 {
263 propiedad: 'NOM', 263 propiedad: 'NOM',
264 nombre: 'Nombre' 264 nombre: 'Nombre'
265 } 265 }
266 ], 266 ],
267 titulo: 'Búsqueda de actividades', 267 titulo: 'Búsqueda de actividades',
268 size: 'md' 268 size: 'md'
269 } 269 };
270 focaModalService.modal(parametrosModal).then( 270 focaModalService.modal(parametrosModal).then(
271 function(actividad) { 271 function(actividad) {
272 $scope.cliente.actividad = actividad; 272 $scope.cliente.actividad = actividad;
273 $timeout(function() { 273 $timeout(function() {
274 $scope.focused = 8; 274 $scope.focused = 8;
275 }); 275 });
276 }, function() { 276 }, function() {
277 // funcion ejecutada cuando se cancela el modal 277 // funcion ejecutada cuando se cancela el modal
278 }); 278 });
279 } 279 }
280 }; 280 };
281 $scope.seleccionarZona = function(key) { 281 $scope.seleccionarZona = function(key) {
282 if(key === 13) { 282 if(key === 13) {
283 var parametrosModal = { 283 var parametrosModal = {
284 query: '/zona', 284 query: '/zona',
285 columnas: [ 285 columnas: [
286 { 286 {
287 propiedad: 'ID', 287 propiedad: 'ID',
288 nombre: 'Código', 288 nombre: 'Código',
289 filtro: { 289 filtro: {
290 nombre: 'rellenarDigitos', 290 nombre: 'rellenarDigitos',
291 parametro: 3 291 parametro: 3
292 } 292 }
293 }, 293 },
294 { 294 {
295 propiedad: 'NOM', 295 propiedad: 'NOM',
296 nombre: 'Nombre' 296 nombre: 'Nombre'
297 } 297 }
298 ], 298 ],
299 titulo: 'Búsqueda de zonas', 299 titulo: 'Búsqueda de zonas',
300 size: 'md' 300 size: 'md'
301 } 301 };
302 focaModalService.modal(parametrosModal).then( 302 focaModalService.modal(parametrosModal).then(
303 function(zona) { 303 function(zona) {
304 $scope.cliente.zona = zona; 304 $scope.cliente.zona = zona;
305 $timeout(function() { 305 $timeout(function() {
306 $scope.focused = 7; 306 $scope.focused = 7;
307 }); 307 });
308 }, function() { 308 }, function() {
309 // funcion ejecutada cuando se cancela el modal 309 // funcion ejecutada cuando se cancela el modal
310 }); 310 });
311 } 311 }
312 }; 312 };
313 $scope.seleccionarTipoFactura = function(key) { 313 $scope.seleccionarTipoFactura = function(key) {
314 if(key === 13) { 314 if(key === 13) {
315 var parametrosModal = { 315 var parametrosModal = {
316 query: '/tipo-factura', 316 query: '/tipo-factura',
317 columnas: [ 317 columnas: [
318 { 318 {
319 propiedad: 'ID', 319 propiedad: 'ID',
320 nombre: 'Código' 320 nombre: 'Código'
321 }, 321 },
322 { 322 {
323 propiedad: 'NOMBRE', 323 propiedad: 'NOMBRE',
324 nombre: 'Nombre' 324 nombre: 'Nombre'
325 } 325 }
326 ], 326 ],
327 titulo: 'Búsqueda de tipos de factura', 327 titulo: 'Búsqueda de tipos de factura',
328 size: 'md' 328 size: 'md'
329 } 329 };
330 focaModalService.modal(parametrosModal).then( 330 focaModalService.modal(parametrosModal).then(
331 function(tipoFactura) { 331 function(tipoFactura) {
332 $scope.cliente.tipoFactura = tipoFactura; 332 $scope.cliente.tipoFactura = tipoFactura;
333 $timeout(function() { 333 $timeout(function() {
334 $scope.focused = 11; 334 $scope.focused = 11;
335 }); 335 });
336 }, function() { 336 }, function() {
337 // funcion ejecutada cuando se cancela el modal 337 // funcion ejecutada cuando se cancela el modal
338 }); 338 });
339 } 339 }
340 }; 340 };
341 $scope.seleccionarTipoComprobante = function(key) { 341 $scope.seleccionarTipoComprobante = function(key) {
342 if(key === 13) { 342 if(key === 13) {
343 var parametrosModal = { 343 var parametrosModal = {
344 query: '/tipo-comprobante', 344 query: '/tipo-comprobante',
345 columnas: [ 345 columnas: [
346 { 346 {
347 propiedad: 'ID', 347 propiedad: 'ID',
348 nombre: 'Código' 348 nombre: 'Código'
349 }, 349 },
350 { 350 {
351 propiedad: 'NOMBRE', 351 propiedad: 'NOMBRE',
352 nombre: 'Nombre' 352 nombre: 'Nombre'
353 } 353 }
354 ], 354 ],
355 titulo: 'Búsqueda de tipos de comprobante', 355 titulo: 'Búsqueda de tipos de comprobante',
356 size: 'md' 356 size: 'md'
357 } 357 };
358 focaModalService.modal(parametrosModal).then( 358 focaModalService.modal(parametrosModal).then(
359 function(tipoComprobante) { 359 function(tipoComprobante) {
360 $scope.cliente.tipoComprobante = tipoComprobante; 360 $scope.cliente.tipoComprobante = tipoComprobante;
361 $timeout(function() { 361 $timeout(function() {
362 $scope.focused = 13; 362 $scope.focused = 13;
363 }); 363 });
364 }, function() { 364 }, function() {
365 // funcion ejecutada cuando se cancela el modal 365 // funcion ejecutada cuando se cancela el modal
366 }); 366 });
367 } 367 }
368 }; 368 };
369 $scope.seleccionarFormaPago = function(key) { 369 $scope.seleccionarFormaPago = function(key) {
370 if(key === 13) { 370 if(key === 13) {
371 var parametrosModal = { 371 var parametrosModal = {
372 query: '/forma-pago', 372 query: '/forma-pago',
373 columnas: [ 373 columnas: [
374 { 374 {
375 propiedad: 'ID', 375 propiedad: 'ID',
376 nombre: 'Código', 376 nombre: 'Código',
377 filtro: { 377 filtro: {
378 nombre: 'rellenarDigitos', 378 nombre: 'rellenarDigitos',
379 parametro: 3 379 parametro: 3
380 } 380 }
381 }, 381 },
382 { 382 {
383 propiedad: 'NOMBRE', 383 propiedad: 'NOMBRE',
384 nombre: 'Nombre' 384 nombre: 'Nombre'
385 } 385 }
386 ], 386 ],
387 titulo: 'Búsqueda de formas de pago', 387 titulo: 'Búsqueda de formas de pago',
388 size: 'md' 388 size: 'md'
389 } 389 };
390 focaModalService.modal(parametrosModal).then( 390 focaModalService.modal(parametrosModal).then(
391 function(formaPago) { 391 function(formaPago) {
392 $scope.cliente.formaPago = formaPago; 392 $scope.cliente.formaPago = formaPago;
393 }, function() { 393 }, function() {
394 // funcion ejecutada cuando se cancela el modal 394 // funcion ejecutada cuando se cancela el modal
395 }); 395 });
396 } 396 }
397 }; 397 };
398 $scope.seleccionarCobrador = function(key) { 398 $scope.seleccionarCobrador = function(key) {
399 if(key === 13) { 399 if(key === 13) {
400 var parametrosModal = { 400 var parametrosModal = {
401 query: '/cobrador', 401 query: '/cobrador',
402 columnas: [ 402 columnas: [
403 { 403 {
404 propiedad: 'CodVen', 404 propiedad: 'CodVen',
405 nombre: 'Código' 405 nombre: 'Código'
406 }, 406 },
407 { 407 {
408 propiedad: 'NomVen', 408 propiedad: 'NomVen',
409 nombre: 'Nombre' 409 nombre: 'Nombre'
410 } 410 }
411 ], 411 ],
412 titulo: 'Búsqueda de cobradores', 412 titulo: 'Búsqueda de cobradores',
413 size: 'md' 413 size: 'md'
414 } 414 };
415 focaModalService.modal(parametrosModal).then( 415 focaModalService.modal(parametrosModal).then(
416 function(cobrador) { 416 function(cobrador) {
417 $scope.cliente.cobrador = cobrador; 417 $scope.cliente.cobrador = cobrador;
418 }, function() { 418 }, function() {
419 // funcion ejecutada cuando se cancela el modal 419 // funcion ejecutada cuando se cancela el modal
420 }); 420 });
421 } 421 }
422 }; 422 };
423 423
424 $scope.guardar = function() { 424 $scope.guardar = function() {
425 425
426 $scope.cliente.PCX = $scope.cliente.provincia.ID; 426 $scope.cliente.PCX = $scope.cliente.provincia.ID;
427 $scope.cliente.LOX = $scope.cliente.localidad.ID; 427 $scope.cliente.LOX = $scope.cliente.localidad.ID;
428 $scope.cliente.IVA = $scope.cliente.iva.ID; 428 $scope.cliente.IVA = $scope.cliente.iva.ID;
429 $scope.cliente.ACT = $scope.cliente.actividad.ID; 429 $scope.cliente.ACT = $scope.cliente.actividad.ID;
430 $scope.cliente.ZON = $scope.cliente.zona.ID; 430 $scope.cliente.ZON = $scope.cliente.zona.ID;
431 $scope.cliente.TIP = $scope.cliente.tipoFactura.ID; 431 $scope.cliente.TIP = $scope.cliente.tipoFactura.ID;
432 $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID; 432 $scope.cliente.TCO = $scope.cliente.tipoComprobante.ID;
433 $scope.cliente.FPA = $scope.cliente.formaPago.ID; 433 $scope.cliente.FPA = $scope.cliente.formaPago.ID;
434 $scope.cliente.VEN = $scope.vendedor.CodVen; 434 $scope.cliente.VEN = $scope.vendedor.CodVen;
435 $scope.cliente.idCobrador = $scope.cliente.cobrador.CodVen; 435 $scope.cliente.idCobrador = $scope.cliente.cobrador.CodVen;
436 436
437 delete $scope.cliente.provincia; 437 delete $scope.cliente.provincia;
438 delete $scope.cliente.localidad; 438 delete $scope.cliente.localidad;
439 delete $scope.cliente.iva; 439 delete $scope.cliente.iva;
440 delete $scope.cliente.actividad; 440 delete $scope.cliente.actividad;
441 delete $scope.cliente.zona; 441 delete $scope.cliente.zona;
442 delete $scope.cliente.tipoFactura; 442 delete $scope.cliente.tipoFactura;
443 delete $scope.cliente.tipoComprobante; 443 delete $scope.cliente.tipoComprobante;
444 delete $scope.cliente.formaPago; 444 delete $scope.cliente.formaPago;
445 delete $scope.cliente.cobrador; 445 delete $scope.cliente.cobrador;
446 446
447 focaBusquedaClienteService 447 focaBusquedaClienteService
448 .guardarCliente($scope.cliente) 448 .guardarCliente($scope.cliente)
449 .then(function(res) { 449 .then(function(res) {
450 var cliente = { 450 var cliente = {
451 cod: res.data.COD, 451 cod: res.data.COD,
452 cuit: res.data.CUIT, 452 cuit: res.data.CUIT,
453 esNuevo: res.data.esNuevo, 453 esNuevo: res.data.esNuevo,
454 nom: res.data.NOM 454 nom: res.data.NOM
455 }; 455 };
456 $scope.select(cliente, true); 456 $scope.select(cliente, true);
457 }); 457 });
458 }; 458 };
459 459
460 function calcularPages(paginaActual) { 460 function calcularPages(paginaActual) {
461 var paginas = []; 461 var paginas = [];
462 paginas.push(paginaActual); 462 paginas.push(paginaActual);
463 463
464 if (paginaActual - 1 > 1) { 464 if (paginaActual - 1 > 1) {
465 465
466 paginas.unshift(paginaActual - 1); 466 paginas.unshift(paginaActual - 1);
467 if (paginaActual - 2 > 1) { 467 if (paginaActual - 2 > 1) {
468 paginas.unshift(paginaActual - 2); 468 paginas.unshift(paginaActual - 2);
469 } 469 }
470 } 470 }
471 471
472 if (paginaActual + 1 < $scope.lastPage) { 472 if (paginaActual + 1 < $scope.lastPage) {
473 paginas.push(paginaActual + 1); 473 paginas.push(paginaActual + 1);
474 if (paginaActual + 2 < $scope.lastPage) { 474 if (paginaActual + 2 < $scope.lastPage) {
475 paginas.push(paginaActual + 2); 475 paginas.push(paginaActual + 2);
476 } 476 }
477 } 477 }
478 478
479 if (paginaActual !== 1) { 479 if (paginaActual !== 1) {
480 paginas.unshift(1); 480 paginas.unshift(1);
481 } 481 }
482 482
483 if (paginaActual !== $scope.lastPage) { 483 if (paginaActual !== $scope.lastPage) {
484 paginas.push($scope.lastPage); 484 paginas.push($scope.lastPage);
485 } 485 }
486 486
487 return paginas; 487 return paginas;
488 } 488 }
489 489
490 function primera() { 490 function primera() {
491 $scope.selectedClientes = 0; 491 $scope.selectedClientes = 0;
492 } 492 }
493 493
494 function anterior() { 494 function anterior() {
495 if ($scope.selectedClientes === 0 && $scope.currentPage > 1) { 495 if ($scope.selectedClientes === 0 && $scope.currentPage > 1) {
496 retrocederPagina(); 496 retrocederPagina();
497 } else { 497 } else {
498 $scope.selectedClientes--; 498 $scope.selectedClientes--;
499 } 499 }
500 } 500 }
501 501
502 function siguiente() { 502 function siguiente() {
503 if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) { 503 if ($scope.selectedClientes < $scope.currentPageClientes.length - 1 ) {
504 $scope.selectedClientes++; 504 $scope.selectedClientes++;
505 } else { 505 } else {
506 avanzarPagina(); 506 avanzarPagina();
507 } 507 }
508 } 508 }
509 509
510 function retrocederPagina() { 510 function retrocederPagina() {
511 if ($scope.currentPage > 1) { 511 if ($scope.currentPage > 1) {
512 $scope.selectPage($scope.currentPage - 1); 512 $scope.selectPage($scope.currentPage - 1);
513 $scope.selectedClientes = $scope.numPerPage - 1; 513 $scope.selectedClientes = $scope.numPerPage - 1;
514 } 514 }
515 } 515 }
516 516
517 function avanzarPagina() { 517 function avanzarPagina() {
518 if ($scope.currentPage < $scope.lastPage) { 518 if ($scope.currentPage < $scope.lastPage) {
519 $scope.selectPage($scope.currentPage + 1); 519 $scope.selectPage($scope.currentPage + 1);
520 $scope.selectedClientes = 0; 520 $scope.selectedClientes = 0;
521 } 521 }
522 } 522 }
523 } 523 }
524 ]); 524 ]);
525 525