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