Commit e51d8be2478ff85150836e6fa6e842914feb1fd8
1 parent
c401bb111c
Exists in
master
and in
1 other branch
fixs
Showing
2 changed files
with
58 additions
and
1 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaParametros') | 1 | angular.module('focaParametros') |
2 | .controller('focaParametrosCtrl', [ | 2 | .controller('focaParametrosCtrl', [ |
3 | '$scope', | 3 | '$scope', |
4 | 'focaParametrosService', | 4 | 'focaParametrosService', |
5 | 'focaBotoneraLateralService', | 5 | 'focaBotoneraLateralService', |
6 | '$filter', | 6 | '$filter', |
7 | 'focaModalService', | 7 | 'focaModalService', |
8 | '$timeout', | 8 | '$timeout', |
9 | '$uibModal', | 9 | '$uibModal', |
10 | function($scope, focaParametrosService, focaBotoneraLateralService, $filter, | 10 | function($scope, focaParametrosService, focaBotoneraLateralService, $filter, |
11 | focaModalService, $timeout, $uibModal) | 11 | focaModalService, $timeout, $uibModal) |
12 | { | 12 | { |
13 | 13 | ||
14 | $scope.botonera = []; | 14 | $scope.botonera = []; |
15 | $scope.now = new Date(); | 15 | $scope.now = new Date(); |
16 | 16 | ||
17 | $scope.botoneraPrincipal = focaParametrosService.getBotonesPrincipal; | 17 | $scope.botoneraPrincipal = focaParametrosService.getBotonesPrincipal; |
18 | 18 | ||
19 | $timeout(function() { | 19 | $timeout(function() { |
20 | focaBotoneraLateralService.showSalir(true); | 20 | focaBotoneraLateralService.showSalir(true); |
21 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 21 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
22 | }); | 22 | }); |
23 | 23 | ||
24 | focaParametrosService.getParametros().then(function(res) { | 24 | focaParametrosService.getParametros().then(function(res) { |
25 | 25 | ||
26 | $scope.$broadcast('cleanCabecera'); | 26 | $scope.$broadcast('cleanCabecera'); |
27 | res.data.forEach(function(entidad) { | 27 | res.data.forEach(function(entidad) { |
28 | 28 | ||
29 | setearEntidad(entidad); | 29 | setearEntidad(entidad); |
30 | }); | 30 | }); |
31 | }); | 31 | }); |
32 | 32 | ||
33 | $scope.guardar = function() { | 33 | $scope.guardar = function() { |
34 | 34 | ||
35 | focaParametrosService.saveParametros(getObjGuardar()).then(function() { | 35 | focaParametrosService.saveParametros(getObjGuardar()).then(function() { |
36 | focaModalService.alert('Parámetros guardados con éxito'); | 36 | focaModalService.alert('Parámetros guardados con éxito'); |
37 | }); | 37 | }); |
38 | }; | 38 | }; |
39 | 39 | ||
40 | $scope.seleccionarPuntosDeDescarga = function() { | 40 | $scope.seleccionarPuntosDeDescarga = function() { |
41 | if (!$scope[getModulo()].cliente.COD || !$scope[getModulo()].domicilio.id) { | 41 | if (!$scope[getModulo()].cliente.COD || !$scope[getModulo()].domicilio.id) { |
42 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 42 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
43 | return; | 43 | return; |
44 | } else { | 44 | } else { |
45 | var modalInstance = $uibModal.open( | 45 | var modalInstance = $uibModal.open( |
46 | { | 46 | { |
47 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 47 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
48 | templateUrl: 'modal-punto-descarga.html', | 48 | templateUrl: 'modal-punto-descarga.html', |
49 | controller: 'focaModalPuntoDescargaController', | 49 | controller: 'focaModalPuntoDescargaController', |
50 | size: 'lg', | 50 | size: 'lg', |
51 | resolve: { | 51 | resolve: { |
52 | filters: { | 52 | filters: { |
53 | idDomicilio: $scope[getModulo()].domicilio.id, | 53 | idDomicilio: $scope[getModulo()].domicilio.id, |
54 | idCliente: $scope[getModulo()].cliente.COD, | 54 | idCliente: $scope[getModulo()].cliente.COD, |
55 | articulos: $scope[getModulo()].articulosNotaPedido || [], | 55 | articulos: $scope[getModulo()].articulosNotaPedido || [], |
56 | puntoDescarga: $scope[getModulo()].notaPedidoPuntoDescarga, | 56 | puntoDescarga: $scope[getModulo()].notaPedidoPuntoDescarga, |
57 | domicilio: $scope[getModulo()].domicilio | 57 | domicilio: $scope[getModulo()].domicilio |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
61 | ); | 61 | ); |
62 | modalInstance.result.then( | 62 | modalInstance.result.then( |
63 | function(puntoDescarga) { | 63 | function(puntoDescarga) { |
64 | $scope[getModulo()].notaPedidoPuntoDescarga = puntoDescarga; | 64 | $scope[getModulo()].notaPedidoPuntoDescarga = puntoDescarga; |
65 | 65 | ||
66 | $scope.$broadcast('addCabecera', { | 66 | $scope.$broadcast('addCabecera', { |
67 | label: 'Puntos de descarga:', | 67 | label: 'Puntos de descarga:', |
68 | seccion: getModulo('label'), | 68 | seccion: getModulo('label'), |
69 | valor: getCabeceraPuntoDescarga(puntoDescarga) | 69 | valor: getCabeceraPuntoDescarga(puntoDescarga) |
70 | }); | 70 | }); |
71 | }, function() { | 71 | }, function() { |
72 | $scope.abrirModalDomicilios($scope.cliente); | 72 | $scope.abrirModalDomicilios($scope.cliente); |
73 | } | 73 | } |
74 | ); | 74 | ); |
75 | } | 75 | } |
76 | }; | 76 | }; |
77 | 77 | ||
78 | $scope.seleccionarFlete = function() { | 78 | $scope.seleccionarFlete = function() { |
79 | 79 | ||
80 | if ($scope[getModulo()].flete === undefined) { | 80 | if ($scope[getModulo()].flete === undefined) { |
81 | $scope[getModulo()].fob = undefined; | 81 | $scope[getModulo()].fob = undefined; |
82 | $scope[getModulo()].bomba = undefined; | 82 | $scope[getModulo()].bomba = undefined; |
83 | $scope[getModulo()].kilometros = undefined; | 83 | $scope[getModulo()].kilometros = undefined; |
84 | 84 | ||
85 | } | 85 | } |
86 | 86 | ||
87 | var modalInstance = $uibModal.open( | 87 | var modalInstance = $uibModal.open( |
88 | { | 88 | { |
89 | ariaLabelledBy: 'Busqueda de Flete', | 89 | ariaLabelledBy: 'Busqueda de Flete', |
90 | templateUrl: 'modal-flete.html', | 90 | templateUrl: 'modal-flete.html', |
91 | controller: 'focaModalFleteController', | 91 | controller: 'focaModalFleteController', |
92 | size: 'lg', | 92 | size: 'lg', |
93 | resolve: { | 93 | resolve: { |
94 | parametrosFlete: | 94 | parametrosFlete: |
95 | function() { | 95 | function() { |
96 | return { | 96 | return { |
97 | flete: $scope[getModulo()].fob ? 'FOB' : | 97 | flete: $scope[getModulo()].fob ? 'FOB' : |
98 | ( $scope[getModulo()].flete ? '1' : | 98 | ( $scope[getModulo()].flete ? '1' : |
99 | ($scope[getModulo()].flete === undefined ? | 99 | ($scope[getModulo()].flete === undefined ? |
100 | null : '0')), | 100 | null : '0')), |
101 | bomba: $scope[getModulo()].bomba ? '1' : | 101 | bomba: $scope[getModulo()].bomba ? '1' : |
102 | ($scope[getModulo()].bomba === undefined ? | 102 | ($scope[getModulo()].bomba === undefined ? |
103 | null : '0'), | 103 | null : '0'), |
104 | kilometros: $scope[getModulo()].kilometros | 104 | kilometros: $scope[getModulo()].kilometros |
105 | }; | 105 | }; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | } | 108 | } |
109 | ); | 109 | ); |
110 | modalInstance.result.then( | 110 | modalInstance.result.then( |
111 | function(datos) { | 111 | function(datos) { |
112 | $scope[getModulo()].flete = datos.flete; | 112 | $scope[getModulo()].flete = datos.flete; |
113 | $scope[getModulo()].fob = datos.FOB; | 113 | $scope[getModulo()].fob = datos.FOB; |
114 | $scope[getModulo()].bomba = datos.bomba; | 114 | $scope[getModulo()].bomba = datos.bomba; |
115 | $scope[getModulo()].kilometros = datos.kilometros; | 115 | $scope[getModulo()].kilometros = datos.kilometros; |
116 | $scope.$broadcast('addCabecera', { | 116 | $scope.$broadcast('addCabecera', { |
117 | label: 'Flete:', | 117 | label: 'Flete:', |
118 | seccion: getModulo('label'), | 118 | seccion: getModulo('label'), |
119 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 119 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
120 | }); | 120 | }); |
121 | if (datos.flete) { | 121 | if (datos.flete) { |
122 | $scope.$broadcast('addCabecera', { | 122 | $scope.$broadcast('addCabecera', { |
123 | label: 'Bomba:', | 123 | label: 'Bomba:', |
124 | seccion: getModulo('label'), | 124 | seccion: getModulo('label'), |
125 | valor: datos.bomba ? 'Si' : 'No' | 125 | valor: datos.bomba ? 'Si' : 'No' |
126 | }); | 126 | }); |
127 | $scope.$broadcast('addCabecera', { | 127 | $scope.$broadcast('addCabecera', { |
128 | label: 'Kilometros:', | 128 | label: 'Kilometros:', |
129 | seccion: getModulo('label'), | 129 | seccion: getModulo('label'), |
130 | valor: datos.kilometros | 130 | valor: datos.kilometros |
131 | }); | 131 | }); |
132 | } else { | 132 | } else { |
133 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 133 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
134 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 134 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
135 | $scope[getModulo()].bomba = false; | 135 | $scope[getModulo()].bomba = false; |
136 | $scope[getModulo()].kilometros = null; | 136 | $scope[getModulo()].kilometros = null; |
137 | } | 137 | } |
138 | }, function() { | 138 | }, function() { |
139 | } | 139 | } |
140 | ); | 140 | ); |
141 | }; | 141 | }; |
142 | 142 | ||
143 | $scope.seleccionarVendedor = function() { | 143 | $scope.seleccionarVendedor = function() { |
144 | 144 | ||
145 | var parametrosModal = { | 145 | var parametrosModal = { |
146 | titulo: 'Búsqueda vendedores', | 146 | titulo: 'Búsqueda vendedores', |
147 | query: '/vendedor', | 147 | query: '/vendedor', |
148 | columnas: [ | 148 | columnas: [ |
149 | { | 149 | { |
150 | propiedad: 'NUM', | 150 | propiedad: 'NUM', |
151 | nombre: 'Código', | 151 | nombre: 'Código', |
152 | filtro: { | 152 | filtro: { |
153 | nombre: 'rellenarDigitos', | 153 | nombre: 'rellenarDigitos', |
154 | parametro: 3 | 154 | parametro: 3 |
155 | } | 155 | } |
156 | }, | 156 | }, |
157 | { | 157 | { |
158 | propiedad: 'NOM', | 158 | propiedad: 'NOM', |
159 | nombre: 'Nombre' | 159 | nombre: 'Nombre' |
160 | } | 160 | } |
161 | ], | 161 | ], |
162 | size: 'md' | 162 | size: 'md' |
163 | }; | 163 | }; |
164 | focaModalService.modal(parametrosModal).then( | 164 | focaModalService.modal(parametrosModal).then( |
165 | function(vendedor) { | 165 | function(vendedor) { |
166 | $scope.$broadcast('addCabecera', { | 166 | $scope.$broadcast('addCabecera', { |
167 | label: 'Vendedor:', | 167 | label: 'Vendedor:', |
168 | seccion: getModulo('label'), | 168 | seccion: getModulo('label'), |
169 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 169 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
170 | vendedor.NOM | 170 | vendedor.NOM |
171 | }); | 171 | }); |
172 | $scope[getModulo()].vendedor = vendedor; | 172 | $scope[getModulo()].vendedor = vendedor; |
173 | }, function() {} | 173 | }, function() {} |
174 | ); | 174 | ); |
175 | }; | 175 | }; |
176 | 176 | ||
177 | $scope.seleccionarCliente = function() { | 177 | $scope.seleccionarCliente = function() { |
178 | 178 | ||
179 | if (!$scope[getModulo()].vendedor) { | 179 | if (!$scope[getModulo()].vendedor) { |
180 | focaModalService.alert('Seleccione Vendedor'); | 180 | focaModalService.alert('Seleccione Vendedor'); |
181 | return; | 181 | return; |
182 | } | 182 | } |
183 | 183 | ||
184 | var modalInstance = $uibModal.open( | 184 | var modalInstance = $uibModal.open( |
185 | { | 185 | { |
186 | ariaLabelledBy: 'Busqueda de Cliente', | 186 | ariaLabelledBy: 'Busqueda de Cliente', |
187 | templateUrl: 'foca-busqueda-cliente-modal.html', | 187 | templateUrl: 'foca-busqueda-cliente-modal.html', |
188 | controller: 'focaBusquedaClienteModalController', | 188 | controller: 'focaBusquedaClienteModalController', |
189 | resolve: { | 189 | resolve: { |
190 | vendedor: function() { return $scope.notaPedido.vendedor; }, | 190 | vendedor: function() { return $scope.notaPedido.vendedor; }, |
191 | cobrador: function() { return null; } | 191 | cobrador: function() { return null; } |
192 | }, | 192 | }, |
193 | size: 'lg' | 193 | size: 'lg' |
194 | } | 194 | } |
195 | ); | 195 | ); |
196 | modalInstance.result.then( | 196 | modalInstance.result.then( |
197 | function(cliente) { | 197 | function(cliente) { |
198 | $scope.abrirModalDomicilios(cliente); | 198 | $scope.abrirModalDomicilios(cliente); |
199 | }, function() { } | 199 | }, function() { } |
200 | ); | 200 | ); |
201 | }; | 201 | }; |
202 | 202 | ||
203 | $scope.seleccionarProveedor = function() { | 203 | $scope.seleccionarProveedor = function() { |
204 | 204 | ||
205 | var parametrosModal = { | 205 | var parametrosModal = { |
206 | titulo: 'Búsqueda de Proveedor', | 206 | titulo: 'Búsqueda de Proveedor', |
207 | query: '/proveedor', | 207 | query: '/proveedor', |
208 | columnas: [ | 208 | columnas: [ |
209 | { | 209 | { |
210 | nombre: 'Código', | 210 | nombre: 'Código', |
211 | propiedad: 'COD', | 211 | propiedad: 'COD', |
212 | filtro: { | 212 | filtro: { |
213 | nombre: 'rellenarDigitos', | 213 | nombre: 'rellenarDigitos', |
214 | parametro: 5 | 214 | parametro: 5 |
215 | } | 215 | } |
216 | }, | 216 | }, |
217 | { | 217 | { |
218 | nombre: 'Nombre', | 218 | nombre: 'Nombre', |
219 | propiedad: 'NOM' | 219 | propiedad: 'NOM' |
220 | }, | 220 | }, |
221 | { | 221 | { |
222 | nombre: 'CUIT', | 222 | nombre: 'CUIT', |
223 | propiedad: 'CUIT' | 223 | propiedad: 'CUIT' |
224 | } | 224 | } |
225 | ], | 225 | ], |
226 | tipo: 'POST', | 226 | tipo: 'POST', |
227 | json: {razonCuitCod: ''} | 227 | json: {razonCuitCod: ''} |
228 | }; | 228 | }; |
229 | focaModalService.modal(parametrosModal).then( | 229 | focaModalService.modal(parametrosModal).then( |
230 | function(proveedor) { | 230 | function(proveedor) { |
231 | $scope[getModulo()].proveedor = proveedor; | 231 | $scope[getModulo()].proveedor = proveedor; |
232 | $scope.$broadcast('addCabecera', { | 232 | $scope.$broadcast('addCabecera', { |
233 | label: 'Proveedor:', | 233 | label: 'Proveedor:', |
234 | seccion: getModulo('label'), | 234 | seccion: getModulo('label'), |
235 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 235 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
236 | proveedor.NOM | 236 | proveedor.NOM |
237 | }); | 237 | }); |
238 | }, function() { | 238 | }, function() { |
239 | } | 239 | } |
240 | ); | 240 | ); |
241 | 241 | ||
242 | }; | 242 | }; |
243 | 243 | ||
244 | $scope.abrirModalDomicilios = function(cliente) { | 244 | $scope.abrirModalDomicilios = function(cliente) { |
245 | var modalInstanceDomicilio = $uibModal.open( | 245 | var modalInstanceDomicilio = $uibModal.open( |
246 | { | 246 | { |
247 | ariaLabelledBy: 'Busqueda de Domicilios', | 247 | ariaLabelledBy: 'Busqueda de Domicilios', |
248 | templateUrl: 'modal-domicilio.html', | 248 | templateUrl: 'modal-domicilio.html', |
249 | controller: 'focaModalDomicilioController', | 249 | controller: 'focaModalDomicilioController', |
250 | resolve: { | 250 | resolve: { |
251 | idCliente: function() { return cliente.cod; }, | 251 | idCliente: function() { return cliente.cod; }, |
252 | esNuevo: function() { return cliente.esNuevo; } | 252 | esNuevo: function() { return cliente.esNuevo; } |
253 | }, | 253 | }, |
254 | size: 'lg', | 254 | size: 'lg', |
255 | } | 255 | } |
256 | ); | 256 | ); |
257 | modalInstanceDomicilio.result.then( | 257 | modalInstanceDomicilio.result.then( |
258 | function(domicilio) { | 258 | function(domicilio) { |
259 | 259 | ||
260 | $scope[getModulo()].domicilio = domicilio; | 260 | $scope[getModulo()].domicilio = domicilio; |
261 | 261 | ||
262 | $scope[getModulo()].cliente = { | 262 | $scope[getModulo()].cliente = { |
263 | COD: cliente.cod, | 263 | COD: cliente.cod, |
264 | CUIT: cliente.cuit, | 264 | CUIT: cliente.cuit, |
265 | NOM: cliente.nom, | 265 | NOM: cliente.nom, |
266 | MOD: cliente.mod | 266 | MOD: cliente.mod |
267 | }; | 267 | }; |
268 | 268 | ||
269 | var domicilioStamp = | 269 | var domicilioStamp = |
270 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 270 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
271 | domicilio.Localidad + ', ' + domicilio.Provincia; | 271 | domicilio.Localidad + ', ' + domicilio.Provincia; |
272 | $scope[getModulo()].domicilioStamp = domicilioStamp; | 272 | $scope[getModulo()].domicilioStamp = domicilioStamp; |
273 | 273 | ||
274 | $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; | 274 | $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; |
275 | 275 | ||
276 | $scope.$broadcast('addCabecera', { | 276 | $scope.$broadcast('addCabecera', { |
277 | label: 'Cliente:', | 277 | label: 'Cliente:', |
278 | seccion: getModulo('label'), | 278 | seccion: getModulo('label'), |
279 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 279 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
280 | }); | 280 | }); |
281 | $scope.$broadcast('addCabecera', { | 281 | $scope.$broadcast('addCabecera', { |
282 | label: 'Domicilio:', | 282 | label: 'Domicilio:', |
283 | seccion: getModulo('label'), | 283 | seccion: getModulo('label'), |
284 | valor: domicilioStamp | 284 | valor: domicilioStamp |
285 | }); | 285 | }); |
286 | if (domicilio.verPuntos) { | 286 | if (domicilio.verPuntos) { |
287 | delete $scope[getModulo()].domicilio.verPuntos; | 287 | delete $scope[getModulo()].domicilio.verPuntos; |
288 | $scope.seleccionarPuntosDeDescarga(); | 288 | $scope.seleccionarPuntosDeDescarga(); |
289 | } else { | 289 | } else { |
290 | focaParametrosService | 290 | focaParametrosService |
291 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 291 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
292 | .then(function(res) { | 292 | .then(function(res) { |
293 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | 293 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
294 | }); | 294 | }); |
295 | } | 295 | } |
296 | }, function() { | 296 | }, function() { |
297 | $scope.seleccionarCliente(true); | 297 | $scope.seleccionarCliente(true); |
298 | return; | 298 | return; |
299 | } | 299 | } |
300 | ); | 300 | ); |
301 | }; | 301 | }; |
302 | 302 | ||
303 | $scope.seleccionarMoneda = function() { | 303 | $scope.seleccionarMoneda = function() { |
304 | 304 | ||
305 | var parametrosModal = { | 305 | var parametrosModal = { |
306 | titulo: 'Búsqueda de monedas', | 306 | titulo: 'Búsqueda de monedas', |
307 | query: '/moneda', | 307 | query: '/moneda', |
308 | columnas: [ | 308 | columnas: [ |
309 | { | 309 | { |
310 | propiedad: 'DETALLE', | 310 | propiedad: 'DETALLE', |
311 | nombre: 'Nombre' | 311 | nombre: 'Nombre' |
312 | }, | 312 | }, |
313 | { | 313 | { |
314 | propiedad: 'SIMBOLO', | 314 | propiedad: 'SIMBOLO', |
315 | nombre: 'Símbolo' | 315 | nombre: 'Símbolo' |
316 | } | 316 | } |
317 | ], | 317 | ], |
318 | size: 'md' | 318 | size: 'md' |
319 | }; | 319 | }; |
320 | focaModalService.modal(parametrosModal).then( | 320 | focaModalService.modal(parametrosModal).then( |
321 | function(moneda) { | 321 | function(moneda) { |
322 | $scope.abrirModalCotizacion(moneda); | 322 | $scope.abrirModalCotizacion(moneda); |
323 | }, function() { | 323 | }, function() { |
324 | } | 324 | } |
325 | ); | 325 | ); |
326 | 326 | ||
327 | }; | 327 | }; |
328 | 328 | ||
329 | $scope.abrirModalCotizacion = function(moneda) { | 329 | $scope.abrirModalCotizacion = function(moneda) { |
330 | var modalInstance = $uibModal.open( | 330 | var modalInstance = $uibModal.open( |
331 | { | 331 | { |
332 | ariaLabelledBy: 'Busqueda de Cotización', | 332 | ariaLabelledBy: 'Busqueda de Cotización', |
333 | templateUrl: 'modal-cotizacion.html', | 333 | templateUrl: 'modal-cotizacion.html', |
334 | controller: 'focaModalCotizacionController', | 334 | controller: 'focaModalCotizacionController', |
335 | size: 'lg', | 335 | size: 'lg', |
336 | resolve: { | 336 | resolve: { |
337 | idMoneda: function() { | 337 | idMoneda: function() { |
338 | return moneda.ID; | 338 | return moneda.ID; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | } | 341 | } |
342 | ); | 342 | ); |
343 | modalInstance.result.then( | 343 | modalInstance.result.then( |
344 | function(cotizacion) { | 344 | function(cotizacion) { |
345 | // var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; | 345 | // var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; |
346 | // for (var i = 0; i < articulosTablaTemp.length; i++) { | 346 | // for (var i = 0; i < articulosTablaTemp.length; i++) { |
347 | // articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 347 | // articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
348 | // $scope.notaPedido.cotizacion.VENDEDOR; | 348 | // $scope.notaPedido.cotizacion.VENDEDOR; |
349 | // articulosTablaTemp[i].precio = (articulosTablaTemp[i].precio / | 349 | // articulosTablaTemp[i].precio = (articulosTablaTemp[i].precio / |
350 | // cotizacion.VENDEDOR).toFixed(4); | 350 | // cotizacion.VENDEDOR).toFixed(4); |
351 | // } | 351 | // } |
352 | // $scope[getModulo()].articulosNotaPedido = articulosTablaTemp; | 352 | // $scope[getModulo()].articulosNotaPedido = articulosTablaTemp; |
353 | $scope[getModulo()].cotizacion = cotizacion; | 353 | $scope[getModulo()].cotizacion = cotizacion; |
354 | $scope[getModulo()].cotizacion.moneda = moneda; | 354 | $scope[getModulo()].cotizacion.moneda = moneda; |
355 | 355 | ||
356 | $scope.$broadcast('addCabecera', { | 356 | $scope.$broadcast('addCabecera', { |
357 | label: 'Moneda:', | 357 | label: 'Moneda:', |
358 | seccion: getModulo('label'), | 358 | seccion: getModulo('label'), |
359 | valor: moneda.DETALLE | 359 | valor: moneda.DETALLE |
360 | }); | 360 | }); |
361 | $scope.$broadcast('addCabecera', { | 361 | $scope.$broadcast('addCabecera', { |
362 | label: 'Fecha cotizacion:', | 362 | label: 'Fecha cotizacion:', |
363 | seccion: getModulo('label'), | 363 | seccion: getModulo('label'), |
364 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 364 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
365 | }); | 365 | }); |
366 | $scope.$broadcast('addCabecera', { | 366 | $scope.$broadcast('addCabecera', { |
367 | label: 'Cotizacion:', | 367 | label: 'Cotizacion:', |
368 | seccion: getModulo('label'), | 368 | seccion: getModulo('label'), |
369 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 369 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
370 | }); | 370 | }); |
371 | 371 | ||
372 | }, function() { | 372 | }, function() { |
373 | 373 | ||
374 | } | 374 | } |
375 | ); | 375 | ); |
376 | }; | 376 | }; |
377 | 377 | ||
378 | $scope.seleccionarObservaciones = function() { | 378 | $scope.seleccionarObservaciones = function() { |
379 | var observacion = { | 379 | var observacion = { |
380 | titulo: 'Ingrese Observaciones', | 380 | titulo: 'Ingrese Observaciones', |
381 | value: $scope[getModulo()].observaciones, | 381 | value: $scope[getModulo()].observaciones, |
382 | maxlength: 155, | 382 | maxlength: 155, |
383 | textarea: true | 383 | textarea: true |
384 | }; | 384 | }; |
385 | 385 | ||
386 | focaModalService | 386 | focaModalService |
387 | .prompt(observacion) | 387 | .prompt(observacion) |
388 | .then(function(observaciones) { | 388 | .then(function(observaciones) { |
389 | $scope[getModulo()].observaciones = observaciones; | 389 | $scope[getModulo()].observaciones = observaciones; |
390 | $scope.$broadcast('addCabecera', { | 390 | $scope.$broadcast('addCabecera', { |
391 | label: 'Observaciones:', | 391 | label: 'Observaciones:', |
392 | valor: observaciones | 392 | valor: observaciones |
393 | }); | 393 | }); |
394 | }); | 394 | }); |
395 | }; | 395 | }; |
396 | 396 | ||
397 | $scope.seleccionarPreciosYCondiciones = function() { | ||
398 | if (!$scope[getModulo()].cliente || !$scope[getModulo()].cliente.COD) { | ||
399 | focaModalService.alert('Primero seleccione un cliente'); | ||
400 | return; | ||
401 | } | ||
402 | |||
403 | var modalInstance = $uibModal.open( | ||
404 | { | ||
405 | ariaLabelledBy: 'Busqueda de Precio Condición', | ||
406 | templateUrl: 'modal-precio-condicion.html', | ||
407 | controller: 'focaModalPrecioCondicionController', | ||
408 | size: 'lg', | ||
409 | resolve: { | ||
410 | idListaPrecio: function() { | ||
411 | return $scope[getModulo()].cliente.MOD || null; | ||
412 | } | ||
413 | } | ||
414 | } | ||
415 | ); | ||
416 | |||
417 | modalInstance.result.then( | ||
418 | function(precioCondicion) { | ||
419 | var cabecera = ''; | ||
420 | var plazosConcat = ''; | ||
421 | if (!Array.isArray(precioCondicion)) { | ||
422 | $scope[getModulo()][getModulo() + 'Plazo' ]= precioCondicion.plazoPago; | ||
423 | $scope[getModulo()].precioCondicion = precioCondicion; | ||
424 | $scope[getModulo()].idPrecioCondicion = precioCondicion.id; | ||
425 | $scope.idLista = precioCondicion.idListaPrecio; | ||
426 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | ||
427 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | ||
428 | } | ||
429 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | ||
430 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | ||
431 | } else { //Cuando se ingresan los plazos manualmente | ||
432 | $scope[getModulo()].idPrecioCondicion = 0; | ||
433 | //-1, el modal productos busca todos los productos | ||
434 | $scope.idLista = -1; | ||
435 | $scope[getModulo()][ getModulo() + 'Plazo'] = precioCondicion; | ||
436 | for (var j = 0; j < precioCondicion.length; j++) { | ||
437 | plazosConcat += precioCondicion[j].dias + ' '; | ||
438 | } | ||
439 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | ||
440 | } | ||
441 | $scope.$broadcast('addCabecera', { | ||
442 | label: 'Precios y condiciones:', | ||
443 | seccion: getModulo('label'), | ||
444 | valor: cabecera | ||
445 | }); | ||
446 | }, function() { | ||
447 | |||
448 | } | ||
449 | ); | ||
450 | |||
451 | }; | ||
452 | |||
397 | $scope.$watch('botonera', function() { | 453 | $scope.$watch('botonera', function() { |
398 | 454 | ||
399 | // Creo el string en donde guardo el objeto parseado | 455 | // Creo el string en donde guardo el objeto parseado |
400 | $scope[getModulo()] = $scope[getModulo()] || {}; | 456 | $scope[getModulo()] = $scope[getModulo()] || {}; |
401 | 457 | ||
402 | getCheckeds(); | 458 | getCheckeds(); |
403 | }, true); | 459 | }, true); |
404 | 460 | ||
405 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { | 461 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { |
406 | 462 | ||
407 | // watch en objetos principales para ir guardando los valores | 463 | // watch en objetos principales para ir guardando los valores |
408 | $scope.$watch(botonPincipal.variable, function() { | 464 | $scope.$watch(botonPincipal.variable, function() { |
409 | 465 | ||
410 | $scope[botonPincipal.variable + 'String'] = { | 466 | $scope[botonPincipal.variable + 'String'] = { |
411 | jsonText: JSON.stringify($scope[botonPincipal.variable]), | 467 | jsonText: JSON.stringify($scope[botonPincipal.variable]), |
412 | modulo: botonPincipal.variable, | 468 | modulo: botonPincipal.variable, |
413 | id: $scope[botonPincipal.variable] ? | 469 | id: $scope[botonPincipal.variable] ? |
414 | $scope[botonPincipal.variable].id : null | 470 | $scope[botonPincipal.variable].id : null |
415 | }; | 471 | }; |
416 | 472 | ||
417 | getCheckeds(); | 473 | getCheckeds(); |
418 | }, true); | 474 | }, true); |
419 | 475 | ||
420 | // creo las funciones para seleccionar boton principal | 476 | // creo las funciones para seleccionar boton principal |
421 | $scope[nombreFuncion(botonPincipal.label)] = function() { | 477 | $scope[nombreFuncion(botonPincipal.label)] = function() { |
422 | 478 | ||
423 | $scope.botoneraPrincipal.filter(function(boton) { | 479 | $scope.botoneraPrincipal.filter(function(boton) { |
424 | boton.checked = false; | 480 | boton.checked = false; |
425 | }); | 481 | }); |
426 | 482 | ||
427 | botonPincipal.checked = true; | 483 | botonPincipal.checked = true; |
428 | $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); | 484 | $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); |
429 | }; | 485 | }; |
430 | 486 | ||
431 | }); | 487 | }); |
432 | 488 | ||
433 | function nombreFuncion(string) { | 489 | function nombreFuncion(string) { |
434 | var texto = 'seleccionar'; | 490 | var texto = 'seleccionar'; |
435 | var arr = string.split(' '); | 491 | var arr = string.split(' '); |
436 | arr.forEach(function(palabra) { | 492 | arr.forEach(function(palabra) { |
437 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 493 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
438 | texto += palabra; | 494 | texto += palabra; |
439 | }); | 495 | }); |
440 | return texto; | 496 | return texto; |
441 | } | 497 | } |
442 | 498 | ||
443 | function getModulo(propiedad) { | 499 | function getModulo(propiedad) { |
444 | var nombre = ''; | 500 | var nombre = ''; |
445 | 501 | ||
446 | $scope.botoneraPrincipal.filter(function(boton) { | 502 | $scope.botoneraPrincipal.filter(function(boton) { |
447 | if (boton.checked) { | 503 | if (boton.checked) { |
448 | if(!propiedad) { | 504 | if(!propiedad) { |
449 | nombre = boton.variable; | 505 | nombre = boton.variable; |
450 | } else { | 506 | } else { |
451 | nombre = boton[propiedad]; | 507 | nombre = boton[propiedad]; |
452 | } | 508 | } |
453 | } | 509 | } |
454 | }); | 510 | }); |
455 | return nombre; | 511 | return nombre; |
456 | } | 512 | } |
457 | 513 | ||
458 | function getCheckeds() { | 514 | function getCheckeds() { |
459 | 515 | ||
460 | $scope.botonera.forEach(function(boton) { | 516 | $scope.botonera.forEach(function(boton) { |
461 | 517 | ||
462 | if ($scope[getModulo()][boton.variable] !== undefined) { | 518 | if ($scope[getModulo()][boton.variable] !== undefined) { |
463 | 519 | ||
464 | boton.checked = true; | 520 | boton.checked = true; |
465 | 521 | ||
466 | //Creo la función para limpiar obj | 522 | //Creo la función para limpiar obj |
467 | $scope['clean' + boton.variable] = function() { | 523 | $scope['clean' + boton.variable] = function() { |
468 | 524 | ||
469 | focaModalService.alert('Esta seguro que desea eliminar el parámetro?') | 525 | focaModalService.alert('Esta seguro que desea eliminar el parámetro?') |
470 | .then(function() { | 526 | .then(function() { |
471 | delete $scope[getModulo()][boton.variable]; | 527 | delete $scope[getModulo()][boton.variable]; |
472 | $scope.$broadcast('cleanCabecera', { | 528 | $scope.$broadcast('cleanCabecera', { |
473 | seccion: getModulo('label') | 529 | seccion: getModulo('label') |
474 | }); | 530 | }); |
475 | setearEntidad({ | 531 | setearEntidad({ |
476 | jsonText: JSON.stringify($scope[getModulo()]), | 532 | jsonText: JSON.stringify($scope[getModulo()]), |
477 | modulo: getModulo(), | 533 | modulo: getModulo(), |
478 | id: $scope[getModulo()].id | 534 | id: $scope[getModulo()].id |
479 | }); | 535 | }); |
480 | }); | 536 | }); |
481 | }; | 537 | }; |
482 | 538 | ||
483 | } else { | 539 | } else { |
484 | boton.checked = false; | 540 | boton.checked = false; |
485 | } | 541 | } |
486 | }); | 542 | }); |
487 | } | 543 | } |
488 | 544 | ||
489 | function getCabeceraPuntoDescarga(puntoDescarga) { | 545 | function getCabeceraPuntoDescarga(puntoDescarga) { |
490 | var puntosStamp = ''; | 546 | var puntosStamp = ''; |
491 | puntoDescarga.forEach(function(punto, idx, arr) { | 547 | puntoDescarga.forEach(function(punto, idx, arr) { |
492 | puntosStamp += punto.descripcion; | 548 | puntosStamp += punto.descripcion; |
493 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 549 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
494 | }); | 550 | }); |
495 | return puntosStamp; | 551 | return puntosStamp; |
496 | } | 552 | } |
497 | 553 | ||
498 | function setearEntidad(entidad) { | 554 | function setearEntidad(entidad) { |
499 | 555 | ||
500 | $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; | 556 | $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; |
501 | $scope[entidad.modulo].id = entidad.id; | 557 | $scope[entidad.modulo].id = entidad.id; |
502 | 558 | ||
503 | if (!$scope[entidad.modulo].domicilio) { | 559 | if (!$scope[entidad.modulo].domicilio) { |
504 | $scope[entidad.modulo].domicilio = { | 560 | $scope[entidad.modulo].domicilio = { |
505 | id: $scope[entidad.modulo].idDomicilio | 561 | id: $scope[entidad.modulo].idDomicilio |
506 | }; | 562 | }; |
507 | } | 563 | } |
508 | 564 | ||
509 | var cabeceras = []; | 565 | var cabeceras = []; |
510 | 566 | ||
511 | if ($scope[entidad.modulo].cotizacion && | 567 | if ($scope[entidad.modulo].cotizacion && |
512 | $scope[entidad.modulo].cotizacion.moneda.CODIGO_AFIP !== 'PES') | 568 | $scope[entidad.modulo].cotizacion.moneda.CODIGO_AFIP !== 'PES') |
513 | { | 569 | { |
514 | cabeceras.push({ | 570 | cabeceras.push({ |
515 | label: 'Moneda:', | 571 | label: 'Moneda:', |
516 | valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE | 572 | valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE |
517 | }); | 573 | }); |
518 | cabeceras.push({ | 574 | cabeceras.push({ |
519 | label: 'Fecha cotizacion:', | 575 | label: 'Fecha cotizacion:', |
520 | valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, | 576 | valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, |
521 | 'dd/MM/yyyy') | 577 | 'dd/MM/yyyy') |
522 | }); | 578 | }); |
523 | cabeceras.push({ | 579 | cabeceras.push({ |
524 | label: 'Cotizacion:', | 580 | label: 'Cotizacion:', |
525 | valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, | 581 | valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, |
526 | '2') | 582 | '2') |
527 | }); | 583 | }); |
528 | } | 584 | } |
529 | 585 | ||
530 | if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { | 586 | if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { |
531 | cabeceras.push({ | 587 | cabeceras.push({ |
532 | label: 'Vendedor:', | 588 | label: 'Vendedor:', |
533 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + | 589 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + |
534 | ' - ' + $scope[entidad.modulo].vendedor.NOM | 590 | ' - ' + $scope[entidad.modulo].vendedor.NOM |
535 | }); | 591 | }); |
536 | } | 592 | } |
537 | 593 | ||
538 | if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { | 594 | if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { |
539 | cabeceras.push({ | 595 | cabeceras.push({ |
540 | label: 'Cliente:', | 596 | label: 'Cliente:', |
541 | valor: $scope[entidad.modulo].cliente.NOM | 597 | valor: $scope[entidad.modulo].cliente.NOM |
542 | }); | 598 | }); |
543 | cabeceras.push({ | 599 | cabeceras.push({ |
544 | label: 'Domicilio:', | 600 | label: 'Domicilio:', |
545 | valor: $scope[entidad.modulo].domicilioStamp | 601 | valor: $scope[entidad.modulo].domicilioStamp |
546 | }); | 602 | }); |
547 | } | 603 | } |
548 | 604 | ||
549 | if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { | 605 | if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { |
550 | cabeceras.push({ | 606 | cabeceras.push({ |
551 | label: 'Proveedor:', | 607 | label: 'Proveedor:', |
552 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + | 608 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + |
553 | ' - ' + $scope[entidad.modulo].proveedor.NOM | 609 | ' - ' + $scope[entidad.modulo].proveedor.NOM |
554 | }); | 610 | }); |
555 | } | 611 | } |
556 | 612 | ||
557 | if ($scope[entidad.modulo][entidad + 'Plazo'] && | 613 | if ($scope[entidad.modulo][entidad + 'Plazo'] && |
558 | $scope[entidad.modulo][entidad + 'Plazo'].length) | 614 | $scope[entidad.modulo][entidad + 'Plazo'].length) |
559 | { | 615 | { |
560 | cabeceras.push({ | 616 | cabeceras.push({ |
561 | label: 'Precios y condiciones:', | 617 | label: 'Precios y condiciones:', |
562 | valor: valorPrecioCondicion() + ' ' + | 618 | valor: valorPrecioCondicion() + ' ' + |
563 | focaParametrosService.plazoToString( | 619 | focaParametrosService.plazoToString( |
564 | $scope[entidad.modulo][entidad.modulo + 'Plazo']) | 620 | $scope[entidad.modulo][entidad.modulo + 'Plazo']) |
565 | }); | 621 | }); |
566 | } | 622 | } |
567 | 623 | ||
568 | if ($scope[entidad.modulo].flete !== undefined) { | 624 | if ($scope[entidad.modulo].flete !== undefined) { |
569 | cabeceras.push({ | 625 | cabeceras.push({ |
570 | label: 'Flete:', | 626 | label: 'Flete:', |
571 | valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( | 627 | valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( |
572 | $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') | 628 | $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') |
573 | }); | 629 | }); |
574 | } | 630 | } |
575 | 631 | ||
576 | function valorPrecioCondicion() { | 632 | function valorPrecioCondicion() { |
577 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { | 633 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { |
578 | return $scope[entidad.modulo].precioCondicion.nombre; | 634 | return $scope[entidad.modulo].precioCondicion.nombre; |
579 | } else { | 635 | } else { |
580 | return 'Ingreso Manual'; | 636 | return 'Ingreso Manual'; |
581 | } | 637 | } |
582 | } | 638 | } |
583 | 639 | ||
584 | if ($scope[entidad.modulo].flete === 1) { | 640 | if ($scope[entidad.modulo].flete === 1) { |
585 | var cabeceraBomba = { | 641 | var cabeceraBomba = { |
586 | label: 'Bomba:', | 642 | label: 'Bomba:', |
587 | valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' | 643 | valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' |
588 | }; | 644 | }; |
589 | if ($scope[entidad.modulo].kilometros) { | 645 | if ($scope[entidad.modulo].kilometros) { |
590 | var cabeceraKilometros = { | 646 | var cabeceraKilometros = { |
591 | label: 'Kilometros:', | 647 | label: 'Kilometros:', |
592 | valor: $scope[entidad.modulo].kilometros | 648 | valor: $scope[entidad.modulo].kilometros |
593 | }; | 649 | }; |
594 | cabeceras.push(cabeceraKilometros); | 650 | cabeceras.push(cabeceraKilometros); |
595 | } | 651 | } |
596 | cabeceras.push(cabeceraBomba); | 652 | cabeceras.push(cabeceraBomba); |
597 | } | 653 | } |
598 | 654 | ||
599 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { | 655 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { |
600 | $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; | 656 | $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; |
601 | } else { | 657 | } else { |
602 | $scope.idLista = -1; | 658 | $scope.idLista = -1; |
603 | } | 659 | } |
604 | 660 | ||
605 | if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { | 661 | if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { |
606 | var puntos = []; | 662 | var puntos = []; |
607 | $scope[entidad.modulo][entidad + 'PuntoDescarga'] | 663 | $scope[entidad.modulo][entidad.modulo + 'PuntoDescarga'] |
608 | .forEach(function(entidadPuntoDescarga) { | 664 | .forEach(function(entidadPuntoDescarga) { |
609 | puntos.push(entidadPuntoDescarga); | 665 | puntos.push(entidadPuntoDescarga); |
610 | }); | 666 | }); |
611 | cabeceras.push({ | 667 | cabeceras.push({ |
612 | label: 'Puntos de descarga: ', | 668 | label: 'Puntos de descarga: ', |
613 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | 669 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) |
614 | }); | 670 | }); |
615 | } | 671 | } |
616 | 672 | ||
617 | addArrayCabecera(cabeceras, entidad.modulo); | 673 | addArrayCabecera(cabeceras, entidad.modulo); |
618 | 674 | ||
619 | } | 675 | } |
620 | 676 | ||
621 | function addArrayCabecera(array, entidad) { | 677 | function addArrayCabecera(array, entidad) { |
622 | for (var i = 0; i < array.length; i++) { | 678 | for (var i = 0; i < array.length; i++) { |
623 | $scope.$broadcast('addCabecera', { | 679 | $scope.$broadcast('addCabecera', { |
624 | label: array[i].label, | 680 | label: array[i].label, |
625 | valor: array[i].valor, | 681 | valor: array[i].valor, |
626 | seccion: $filter('filter') | 682 | seccion: $filter('filter') |
627 | ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label | 683 | ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label |
628 | }); | 684 | }); |
629 | } | 685 | } |
630 | } | 686 | } |
631 | 687 | ||
632 | function getObjGuardar() { | 688 | function getObjGuardar() { |
633 | var guardar = []; | 689 | var guardar = []; |
634 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { | 690 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { |
635 | if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; | 691 | if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; |
636 | guardar.push($scope[botonPincipal.variable + 'String']); | 692 | guardar.push($scope[botonPincipal.variable + 'String']); |
637 | }); | 693 | }); |
638 | 694 | ||
639 | return guardar; | 695 | return guardar; |
640 | } | 696 | } |
641 | 697 | ||
642 | }]); | 698 | }]); |
643 | 699 |
src/js/service.js
1 | angular.module('focaParametros') | 1 | angular.module('focaParametros') |
2 | .factory('focaParametrosService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { | 2 | .factory('focaParametrosService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { |
3 | return { | 3 | return { |
4 | getNotasPedido: function (fechaDesde, fechaHasta) { | 4 | getNotasPedido: function (fechaDesde, fechaHasta) { |
5 | return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar/' + fechaDesde + '/' + | 5 | return $http.get(API_ENDPOINT.URL + '/nota-pedido/listar/' + fechaDesde + '/' + |
6 | fechaHasta + '/sin-remito'); | 6 | fechaHasta + '/sin-remito'); |
7 | }, | 7 | }, |
8 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 8 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
9 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 9 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
10 | idDomicilio + '/' + idCliente); | 10 | idDomicilio + '/' + idCliente); |
11 | }, | 11 | }, |
12 | saveParametros: function(parametros) { | 12 | saveParametros: function(parametros) { |
13 | return $http.post(API_ENDPOINT.URL + '/parametros', parametros); | 13 | return $http.post(API_ENDPOINT.URL + '/parametros', parametros); |
14 | }, | 14 | }, |
15 | getParametros: function() { | 15 | getParametros: function() { |
16 | return $http.get(API_ENDPOINT.URL + '/parametros'); | 16 | return $http.get(API_ENDPOINT.URL + '/parametros'); |
17 | }, | 17 | }, |
18 | plazoToString: function(plazos) { | 18 | plazoToString: function(plazos) { |
19 | 19 | ||
20 | var result = ''; | 20 | var result = ''; |
21 | 21 | ||
22 | for(var i = 0; i < plazos.length; i++) { | 22 | for(var i = 0; i < plazos.length; i++) { |
23 | result += plazos[i].dias + ' '; | 23 | result += plazos[i].dias + ' '; |
24 | } | 24 | } |
25 | 25 | ||
26 | return result.trim(); | 26 | return result.trim(); |
27 | }, | 27 | }, |
28 | getBotones: function (modulo) { | 28 | getBotones: function (modulo) { |
29 | var botones = [ | 29 | var botones = [ |
30 | { | 30 | { |
31 | label: 'Vendedor', | 31 | label: 'Vendedor', |
32 | variable: 'vendedor', | 32 | variable: 'vendedor', |
33 | image: 'vendedor.png', | 33 | image: 'vendedor.png', |
34 | modulo: [1, 2] | 34 | modulo: [1, 2] |
35 | }, | 35 | }, |
36 | { | 36 | { |
37 | label: 'Cliente', | 37 | label: 'Cliente', |
38 | image: 'cliente.png', | 38 | image: 'cliente.png', |
39 | variable: 'cliente', | 39 | variable: 'cliente', |
40 | modulo: [1, 2] | 40 | modulo: [1, 2] |
41 | }, | 41 | }, |
42 | { | 42 | { |
43 | label: 'Proveedor', | 43 | label: 'Proveedor', |
44 | image: 'proveedor.png', | 44 | image: 'proveedor.png', |
45 | variable: 'proveedor', | 45 | variable: 'proveedor', |
46 | modulo: [1, 2] | 46 | modulo: [1, 2] |
47 | }, | 47 | }, |
48 | { | 48 | { |
49 | label: 'Flete', | 49 | label: 'Flete', |
50 | image: 'flete.png', | 50 | image: 'flete.png', |
51 | variable: 'flete', | 51 | variable: 'flete', |
52 | modulo: [1, 2] | 52 | modulo: [1, 2] |
53 | }, | 53 | }, |
54 | { | 54 | { |
55 | label: 'Moneda', | 55 | label: 'Moneda', |
56 | image: 'moneda.png', | 56 | image: 'moneda.png', |
57 | variable: 'cotizacion', | 57 | variable: 'cotizacion', |
58 | modulo: [1, 2] | 58 | modulo: [1, 2] |
59 | }, | 59 | }, |
60 | { | 60 | { |
61 | label: 'Precios y condiciones', | 61 | label: 'Precios y condiciones', |
62 | image: 'precios-condiciones.png', | 62 | image: 'precios-condiciones.png', |
63 | variable: 'precioCondicion', | ||
63 | modulo: [1, 2] | 64 | modulo: [1, 2] |
64 | }, | 65 | }, |
65 | { | 66 | { |
66 | label: 'Observaciones', | 67 | label: 'Observaciones', |
67 | image: 'botonObservaciones.png', | 68 | image: 'botonObservaciones.png', |
68 | variable: 'observaciones', | 69 | variable: 'observaciones', |
69 | modulo: [1] | 70 | modulo: [1] |
70 | } | 71 | } |
71 | ]; | 72 | ]; |
72 | 73 | ||
73 | // Devuelvo solo los botones correspondietes | 74 | // Devuelvo solo los botones correspondietes |
74 | // Modulo 1 = nota de pedido, 2 remito, 3 ambos | 75 | // Modulo 1 = nota de pedido, 2 remito, 3 ambos |
75 | return botones.filter(function (p) { | 76 | return botones.filter(function (p) { |
76 | return p.modulo.includes(modulo); | 77 | return p.modulo.includes(modulo); |
77 | }); | 78 | }); |
78 | }, | 79 | }, |
79 | getBotonesPrincipal: [ | 80 | getBotonesPrincipal: [ |
80 | { | 81 | { |
81 | label: 'Nota de Pedido', | 82 | label: 'Nota de Pedido', |
82 | image: 'notaPedido.png', | 83 | image: 'notaPedido.png', |
83 | modulo: 1, | 84 | modulo: 1, |
84 | variable: 'notaPedido' | 85 | variable: 'notaPedido' |
85 | }, | 86 | }, |
86 | { | 87 | { |
87 | label: 'Remito', | 88 | label: 'Remito', |
88 | image: 'remito.png', | 89 | image: 'remito.png', |
89 | modulo: 2, | 90 | modulo: 2, |
90 | variable: 'remito' | 91 | variable: 'remito' |
91 | } | 92 | } |
92 | ] | 93 | ] |
93 | }; | 94 | }; |
94 | }]); | 95 | }]); |
95 | 96 |