Commit 6a049b2db9957317ac60ad6d414528e677aaeda0
Exists in
master
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !4
Showing
1 changed file
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 | if (!$scope[getModulo()].vendedor) { | 181 | if (!$scope[getModulo()].vendedor) { |
182 | focaModalService.alert('Seleccione Vendedor'); | 182 | focaModalService.alert('Seleccione Vendedor'); |
183 | return; | 183 | return; |
184 | } | 184 | } |
185 | 185 | ||
186 | var modalInstance = $uibModal.open( | 186 | var modalInstance = $uibModal.open( |
187 | { | 187 | { |
188 | ariaLabelledBy: 'Busqueda de Cliente', | 188 | ariaLabelledBy: 'Busqueda de Cliente', |
189 | templateUrl: 'foca-busqueda-cliente-modal.html', | 189 | templateUrl: 'foca-busqueda-cliente-modal.html', |
190 | controller: 'focaBusquedaClienteModalController', | 190 | controller: 'focaBusquedaClienteModalController', |
191 | resolve: { | 191 | resolve: { |
192 | vendedor: function() { return $scope.notaPedido.vendedor; }, | 192 | vendedor: function() { return $scope.notaPedido.vendedor; }, |
193 | cobrador: function() { return null; } | 193 | cobrador: function() { return null; } |
194 | }, | 194 | }, |
195 | size: 'lg' | 195 | size: 'lg' |
196 | } | 196 | } |
197 | ); | 197 | ); |
198 | modalInstance.result.then( | 198 | modalInstance.result.then( |
199 | function(cliente) { | 199 | function(cliente) { |
200 | $scope.abrirModalDomicilios(cliente); | 200 | $scope.abrirModalDomicilios(cliente); |
201 | }, function() { } | 201 | }, function() { } |
202 | ); | 202 | ); |
203 | }; | 203 | }; |
204 | 204 | ||
205 | $scope.seleccionarProveedor = function() { | 205 | $scope.seleccionarProveedor = function() { |
206 | 206 | ||
207 | var parametrosModal = { | 207 | var parametrosModal = { |
208 | titulo: 'Búsqueda de Proveedor', | 208 | titulo: 'Búsqueda de Proveedor', |
209 | query: '/proveedor', | 209 | query: '/proveedor', |
210 | columnas: [ | 210 | columnas: [ |
211 | { | 211 | { |
212 | nombre: 'Código', | 212 | nombre: 'Código', |
213 | propiedad: 'COD', | 213 | propiedad: 'COD', |
214 | filtro: { | 214 | filtro: { |
215 | nombre: 'rellenarDigitos', | 215 | nombre: 'rellenarDigitos', |
216 | parametro: 5 | 216 | parametro: 5 |
217 | } | 217 | } |
218 | }, | 218 | }, |
219 | { | 219 | { |
220 | nombre: 'Nombre', | 220 | nombre: 'Nombre', |
221 | propiedad: 'NOM' | 221 | propiedad: 'NOM' |
222 | }, | 222 | }, |
223 | { | 223 | { |
224 | nombre: 'CUIT', | 224 | nombre: 'CUIT', |
225 | propiedad: 'CUIT' | 225 | propiedad: 'CUIT' |
226 | } | 226 | } |
227 | ], | 227 | ], |
228 | tipo: 'POST', | 228 | tipo: 'POST', |
229 | json: {razonCuitCod: ''} | 229 | json: {razonCuitCod: ''} |
230 | }; | 230 | }; |
231 | focaModalService.modal(parametrosModal).then( | 231 | focaModalService.modal(parametrosModal).then( |
232 | function(proveedor) { | 232 | function(proveedor) { |
233 | $scope[getModulo()].proveedor = proveedor; | 233 | $scope[getModulo()].proveedor = proveedor; |
234 | $scope.$broadcast('addCabecera', { | 234 | $scope.$broadcast('addCabecera', { |
235 | label: 'Proveedor:', | 235 | label: 'Proveedor:', |
236 | seccion: getModulo('label'), | 236 | seccion: getModulo('label'), |
237 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 237 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
238 | proveedor.NOM | 238 | proveedor.NOM |
239 | }); | 239 | }); |
240 | }, function() { | 240 | }, function() { |
241 | } | 241 | } |
242 | ); | 242 | ); |
243 | 243 | ||
244 | }; | 244 | }; |
245 | 245 | ||
246 | $scope.abrirModalDomicilios = function(cliente) { | 246 | $scope.abrirModalDomicilios = function(cliente) { |
247 | var modalInstanceDomicilio = $uibModal.open( | 247 | var modalInstanceDomicilio = $uibModal.open( |
248 | { | 248 | { |
249 | ariaLabelledBy: 'Busqueda de Domicilios', | 249 | ariaLabelledBy: 'Busqueda de Domicilios', |
250 | templateUrl: 'modal-domicilio.html', | 250 | templateUrl: 'modal-domicilio.html', |
251 | controller: 'focaModalDomicilioController', | 251 | controller: 'focaModalDomicilioController', |
252 | resolve: { | 252 | resolve: { |
253 | idCliente: function() { return cliente.cod; }, | 253 | idCliente: function() { return cliente.cod; }, |
254 | esNuevo: function() { return cliente.esNuevo; } | 254 | esNuevo: function() { return cliente.esNuevo; } |
255 | }, | 255 | }, |
256 | size: 'lg', | 256 | size: 'lg', |
257 | } | 257 | } |
258 | ); | 258 | ); |
259 | modalInstanceDomicilio.result.then( | 259 | modalInstanceDomicilio.result.then( |
260 | function(domicilio) { | 260 | function(domicilio) { |
261 | 261 | ||
262 | $scope[getModulo()].domicilio = domicilio; | 262 | $scope[getModulo()].domicilio = domicilio; |
263 | 263 | ||
264 | $scope[getModulo()].cliente = { | 264 | $scope[getModulo()].cliente = { |
265 | COD: cliente.cod, | 265 | COD: cliente.cod, |
266 | CUIT: cliente.cuit, | 266 | CUIT: cliente.cuit, |
267 | NOM: cliente.nom, | 267 | NOM: cliente.nom, |
268 | MOD: cliente.mod | 268 | MOD: cliente.mod |
269 | }; | 269 | }; |
270 | 270 | ||
271 | var domicilioStamp = | 271 | var domicilioStamp = |
272 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 272 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
273 | domicilio.Localidad + ', ' + domicilio.Provincia; | 273 | domicilio.Localidad + ', ' + domicilio.Provincia; |
274 | $scope[getModulo()].domicilioStamp = domicilioStamp; | 274 | $scope[getModulo()].domicilioStamp = domicilioStamp; |
275 | 275 | ||
276 | $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; | 276 | $scope[getModulo()].notaPedidoPuntoDescarga = domicilio.puntoDescarga; |
277 | 277 | ||
278 | $scope.$broadcast('addCabecera', { | 278 | $scope.$broadcast('addCabecera', { |
279 | label: 'Cliente:', | 279 | label: 'Cliente:', |
280 | seccion: getModulo('label'), | 280 | seccion: getModulo('label'), |
281 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 281 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
282 | }); | 282 | }); |
283 | $scope.$broadcast('addCabecera', { | 283 | $scope.$broadcast('addCabecera', { |
284 | label: 'Domicilio:', | 284 | label: 'Domicilio:', |
285 | seccion: getModulo('label'), | 285 | seccion: getModulo('label'), |
286 | valor: domicilioStamp | 286 | valor: domicilioStamp |
287 | }); | 287 | }); |
288 | if (domicilio.verPuntos) { | 288 | if (domicilio.verPuntos) { |
289 | delete $scope[getModulo()].domicilio.verPuntos; | 289 | delete $scope[getModulo()].domicilio.verPuntos; |
290 | $scope.seleccionarPuntosDeDescarga(); | 290 | $scope.seleccionarPuntosDeDescarga(); |
291 | } else { | 291 | } else { |
292 | focaParametrosService | 292 | focaParametrosService |
293 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 293 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
294 | .then(function(res) { | 294 | .then(function(res) { |
295 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | 295 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
296 | }); | 296 | }); |
297 | } | 297 | } |
298 | }, function() { | 298 | }, function() { |
299 | $scope.seleccionarCliente(true); | 299 | $scope.seleccionarCliente(true); |
300 | return; | 300 | return; |
301 | } | 301 | } |
302 | ); | 302 | ); |
303 | }; | 303 | }; |
304 | 304 | ||
305 | $scope.seleccionarMoneda = function() { | 305 | $scope.seleccionarMoneda = function() { |
306 | 306 | ||
307 | var parametrosModal = { | 307 | var parametrosModal = { |
308 | titulo: 'Búsqueda de monedas', | 308 | titulo: 'Búsqueda de monedas', |
309 | query: '/moneda', | 309 | query: '/moneda', |
310 | columnas: [ | 310 | columnas: [ |
311 | { | 311 | { |
312 | propiedad: 'DETALLE', | 312 | propiedad: 'DETALLE', |
313 | nombre: 'Nombre' | 313 | nombre: 'Nombre' |
314 | }, | 314 | }, |
315 | { | 315 | { |
316 | propiedad: 'SIMBOLO', | 316 | propiedad: 'SIMBOLO', |
317 | nombre: 'Símbolo' | 317 | nombre: 'Símbolo' |
318 | } | 318 | } |
319 | ], | 319 | ], |
320 | size: 'md' | 320 | size: 'md' |
321 | }; | 321 | }; |
322 | focaModalService.modal(parametrosModal).then( | 322 | focaModalService.modal(parametrosModal).then( |
323 | function(moneda) { | 323 | function(moneda) { |
324 | $scope.abrirModalCotizacion(moneda); | 324 | $scope.abrirModalCotizacion(moneda); |
325 | }, function() { | 325 | }, function() { |
326 | } | 326 | } |
327 | ); | 327 | ); |
328 | 328 | ||
329 | }; | 329 | }; |
330 | 330 | ||
331 | $scope.abrirModalCotizacion = function(moneda) { | 331 | $scope.abrirModalCotizacion = function(moneda) { |
332 | var modalInstance = $uibModal.open( | 332 | var modalInstance = $uibModal.open( |
333 | { | 333 | { |
334 | ariaLabelledBy: 'Busqueda de Cotización', | 334 | ariaLabelledBy: 'Busqueda de Cotización', |
335 | templateUrl: 'modal-cotizacion.html', | 335 | templateUrl: 'modal-cotizacion.html', |
336 | controller: 'focaModalCotizacionController', | 336 | controller: 'focaModalCotizacionController', |
337 | size: 'lg', | 337 | size: 'lg', |
338 | resolve: { | 338 | resolve: { |
339 | idMoneda: function() { | 339 | idMoneda: function() { |
340 | return moneda.ID; | 340 | return moneda.ID; |
341 | } | 341 | } |
342 | } | 342 | } |
343 | } | 343 | } |
344 | ); | 344 | ); |
345 | modalInstance.result.then( | 345 | modalInstance.result.then( |
346 | function(cotizacion) { | 346 | function(cotizacion) { |
347 | $scope[getModulo()].cotizacion = cotizacion; | 347 | $scope[getModulo()].cotizacion = cotizacion; |
348 | $scope[getModulo()].cotizacion.moneda = moneda; | 348 | $scope[getModulo()].cotizacion.moneda = moneda; |
349 | 349 | ||
350 | $scope.$broadcast('addCabecera', { | 350 | $scope.$broadcast('addCabecera', { |
351 | label: 'Moneda:', | 351 | label: 'Moneda:', |
352 | seccion: getModulo('label'), | 352 | seccion: getModulo('label'), |
353 | valor: moneda.DETALLE | 353 | valor: moneda.DETALLE |
354 | }); | 354 | }); |
355 | $scope.$broadcast('addCabecera', { | 355 | $scope.$broadcast('addCabecera', { |
356 | label: 'Fecha cotizacion:', | 356 | label: 'Fecha cotizacion:', |
357 | seccion: getModulo('label'), | 357 | seccion: getModulo('label'), |
358 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 358 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
359 | }); | 359 | }); |
360 | $scope.$broadcast('addCabecera', { | 360 | $scope.$broadcast('addCabecera', { |
361 | label: 'Cotizacion:', | 361 | label: 'Cotizacion:', |
362 | seccion: getModulo('label'), | 362 | seccion: getModulo('label'), |
363 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 363 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
364 | }); | 364 | }); |
365 | 365 | ||
366 | }, function() { | 366 | }, function() { |
367 | 367 | ||
368 | } | 368 | } |
369 | ); | 369 | ); |
370 | }; | 370 | }; |
371 | 371 | ||
372 | $scope.seleccionarObservaciones = function() { | 372 | $scope.seleccionarObservaciones = function() { |
373 | var observacion = { | 373 | var observacion = { |
374 | titulo: 'Ingrese Observaciones', | 374 | titulo: 'Ingrese Observaciones', |
375 | value: $scope[getModulo()].observaciones, | 375 | value: $scope[getModulo()].observaciones, |
376 | maxlength: 155, | 376 | maxlength: 155, |
377 | textarea: true | 377 | textarea: true |
378 | }; | 378 | }; |
379 | 379 | ||
380 | focaModalService | 380 | focaModalService |
381 | .prompt(observacion) | 381 | .prompt(observacion) |
382 | .then(function(observaciones) { | 382 | .then(function(observaciones) { |
383 | $scope[getModulo()].observaciones = observaciones; | 383 | $scope[getModulo()].observaciones = observaciones; |
384 | $scope.$broadcast('addCabecera', { | 384 | $scope.$broadcast('addCabecera', { |
385 | label: 'Observaciones:', | 385 | label: 'Observaciones:', |
386 | valor: observaciones | 386 | valor: observaciones |
387 | }); | 387 | }); |
388 | }); | 388 | }); |
389 | }; | 389 | }; |
390 | 390 | ||
391 | $scope.seleccionarPreciosYCondiciones = function() { | 391 | $scope.seleccionarPreciosYCondiciones = function() { |
392 | if (!$scope[getModulo()].cliente || !$scope[getModulo()].cliente.COD) { | 392 | if (!$scope[getModulo()].cliente || !$scope[getModulo()].cliente.COD) { |
393 | focaModalService.alert('Primero seleccione un cliente'); | 393 | focaModalService.alert('Primero seleccione un cliente'); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | 396 | ||
397 | var modalInstance = $uibModal.open( | 397 | var modalInstance = $uibModal.open( |
398 | { | 398 | { |
399 | ariaLabelledBy: 'Busqueda de Precio Condición', | 399 | ariaLabelledBy: 'Busqueda de Precio Condición', |
400 | templateUrl: 'modal-precio-condicion.html', | 400 | templateUrl: 'modal-precio-condicion.html', |
401 | controller: 'focaModalPrecioCondicionController', | 401 | controller: 'focaModalPrecioCondicionController', |
402 | size: 'lg', | 402 | size: 'lg', |
403 | resolve: { | 403 | resolve: { |
404 | idListaPrecio: function() { | 404 | idListaPrecio: function() { |
405 | return $scope[getModulo()].cliente.MOD || null; | 405 | return $scope[getModulo()].cliente.MOD || null; |
406 | } | 406 | } |
407 | } | 407 | } |
408 | } | 408 | } |
409 | ); | 409 | ); |
410 | 410 | ||
411 | modalInstance.result.then( | 411 | modalInstance.result.then( |
412 | function(precioCondicion) { | 412 | function(precioCondicion) { |
413 | var cabecera = ''; | 413 | var cabecera = ''; |
414 | var plazosConcat = ''; | 414 | var plazosConcat = ''; |
415 | if (!Array.isArray(precioCondicion)) { | 415 | if (!Array.isArray(precioCondicion)) { |
416 | $scope[getModulo()][getModulo() + 'Plazo' ]= precioCondicion.plazoPago; | 416 | $scope[getModulo()][getModulo() + 'Plazo' ]= precioCondicion.plazoPago; |
417 | $scope[getModulo()].precioCondicion = precioCondicion; | 417 | $scope[getModulo()].precioCondicion = precioCondicion; |
418 | $scope[getModulo()].idPrecioCondicion = precioCondicion.id; | 418 | $scope[getModulo()].idPrecioCondicion = precioCondicion.id; |
419 | $scope.idLista = precioCondicion.idListaPrecio; | 419 | $scope.idLista = precioCondicion.idListaPrecio; |
420 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 420 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
421 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 421 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
422 | } | 422 | } |
423 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 423 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
424 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 424 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
425 | } else { //Cuando se ingresan los plazos manualmente | 425 | } else { //Cuando se ingresan los plazos manualmente |
426 | $scope[getModulo()].idPrecioCondicion = 0; | 426 | $scope[getModulo()].idPrecioCondicion = 0; |
427 | //-1, el modal productos busca todos los productos | 427 | //-1, el modal productos busca todos los productos |
428 | $scope.idLista = -1; | 428 | $scope.idLista = -1; |
429 | $scope[getModulo()][ getModulo() + 'Plazo'] = precioCondicion; | 429 | $scope[getModulo()][ getModulo() + 'Plazo'] = precioCondicion; |
430 | for (var j = 0; j < precioCondicion.length; j++) { | 430 | for (var j = 0; j < precioCondicion.length; j++) { |
431 | plazosConcat += precioCondicion[j].dias + ' '; | 431 | plazosConcat += precioCondicion[j].dias + ' '; |
432 | } | 432 | } |
433 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 433 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
434 | } | 434 | } |
435 | $scope.$broadcast('addCabecera', { | 435 | $scope.$broadcast('addCabecera', { |
436 | label: 'Precios y condiciones:', | 436 | label: 'Precios y condiciones:', |
437 | seccion: getModulo('label'), | 437 | seccion: getModulo('label'), |
438 | valor: cabecera | 438 | valor: cabecera |
439 | }); | 439 | }); |
440 | }, function() { | 440 | }, function() { |
441 | 441 | ||
442 | } | 442 | } |
443 | ); | 443 | ); |
444 | 444 | ||
445 | }; | 445 | }; |
446 | 446 | ||
447 | $scope.seleccionarTarifario = function() { | 447 | $scope.seleccionarTarifario = function() { |
448 | 448 | ||
449 | focaModalService | 449 | focaModalService |
450 | .prompt({ | 450 | .prompt({ |
451 | titulo: 'Tarifa flete', | 451 | titulo: 'Tarifa flete', |
452 | value: $scope[getModulo()].tarifario | 452 | value: $scope[getModulo()].tarifario |
453 | }) | 453 | }) |
454 | .then(function(costo) { | 454 | .then(function(costo) { |
455 | if (isNaN(costo)) { | 455 | if (isNaN(costo)) { |
456 | focaModalService | 456 | focaModalService |
457 | .alert('Ingrese un valor válido') | 457 | .alert('Ingrese un valor válido') |
458 | .then(function() { | 458 | .then(function() { |
459 | $scope.seleccionarTarifario(); | 459 | $scope.seleccionarTarifario(); |
460 | }); | 460 | }); |
461 | 461 | ||
462 | return; | 462 | return; |
463 | } | 463 | } |
464 | 464 | ||
465 | $scope[getModulo()].tarifario = costo; | 465 | $scope[getModulo()].tarifario = costo; |
466 | 466 | ||
467 | $scope.$broadcast('addCabecera', { | 467 | $scope.$broadcast('addCabecera', { |
468 | label: 'Tarifario:', | 468 | label: 'Tarifario:', |
469 | valor: costo, | 469 | valor: costo, |
470 | seccion: getModulo('label') | 470 | seccion: getModulo('label') |
471 | }); | 471 | }); |
472 | }); | 472 | }); |
473 | }; | 473 | }; |
474 | 474 | ||
475 | $scope.seleccionarTransportista = function() { | 475 | $scope.seleccionarTransportista = function() { |
476 | 476 | ||
477 | var parametrosModal = { | 477 | var parametrosModal = { |
478 | titulo: 'Búsqueda de transportista', | 478 | titulo: 'Búsqueda de transportista', |
479 | query: '/transportista/no-relacion', | 479 | query: '/transportista/no-relacion', |
480 | columnas: [ | 480 | columnas: [ |
481 | { | 481 | { |
482 | nombre: 'Código', | 482 | nombre: 'Código', |
483 | propiedad: 'COD' | 483 | propiedad: 'COD' |
484 | }, | 484 | }, |
485 | { | 485 | { |
486 | nombre: 'Nombre', | 486 | nombre: 'Nombre', |
487 | propiedad: 'NOM' | 487 | propiedad: 'NOM' |
488 | }, | 488 | }, |
489 | { | 489 | { |
490 | nombre: 'CUIT', | 490 | nombre: 'CUIT', |
491 | propiedad: 'CUIT' | 491 | propiedad: 'CUIT' |
492 | } | 492 | } |
493 | ] | 493 | ] |
494 | }; | 494 | }; |
495 | focaModalService.modal(parametrosModal).then( | 495 | focaModalService.modal(parametrosModal).then( |
496 | function(proveedor) { | 496 | function(proveedor) { |
497 | $scope[getModulo()].transportista = proveedor; | 497 | $scope[getModulo()].transportista = proveedor; |
498 | $scope.$broadcast('addCabecera', { | 498 | $scope.$broadcast('addCabecera', { |
499 | label: 'Transportista:', | 499 | label: 'Transportista:', |
500 | seccion: getModulo('label'), | 500 | seccion: getModulo('label'), |
501 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 501 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
502 | proveedor.NOM | 502 | proveedor.NOM |
503 | }); | 503 | }); |
504 | }, function() { | 504 | }, function() { |
505 | } | 505 | } |
506 | ); | 506 | ); |
507 | }; | 507 | }; |
508 | 508 | ||
509 | $scope.$watch('botonera', function() { | 509 | $scope.$watch('botonera', function() { |
510 | 510 | ||
511 | // Creo el string en donde guardo el objeto parseado | 511 | // Creo el string en donde guardo el objeto parseado |
512 | $scope[getModulo()] = $scope[getModulo()] || {}; | 512 | $scope[getModulo()] = $scope[getModulo()] || {}; |
513 | 513 | ||
514 | getCheckeds(); | 514 | getCheckeds(); |
515 | }, true); | 515 | }, true); |
516 | 516 | ||
517 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { | 517 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { |
518 | 518 | ||
519 | // watch en objetos principales para ir guardando los valores | 519 | // watch en objetos principales para ir guardando los valores |
520 | $scope.$watch(botonPincipal.variable, function() { | 520 | $scope.$watch(botonPincipal.variable, function() { |
521 | 521 | ||
522 | $scope[botonPincipal.variable + 'String'] = { | 522 | $scope[botonPincipal.variable + 'String'] = { |
523 | jsonText: JSON.stringify($scope[botonPincipal.variable]), | 523 | jsonText: JSON.stringify($scope[botonPincipal.variable]), |
524 | modulo: botonPincipal.variable, | 524 | modulo: botonPincipal.variable, |
525 | id: $scope[botonPincipal.variable + 'String'] ? | 525 | id: $scope[botonPincipal.variable + 'String'] ? |
526 | $scope[botonPincipal.variable + 'String'].id : undefined | 526 | $scope[botonPincipal.variable + 'String'].id : undefined |
527 | }; | 527 | }; |
528 | 528 | ||
529 | getCheckeds(); | 529 | getCheckeds(); |
530 | }, true); | 530 | }, true); |
531 | 531 | ||
532 | // creo las funciones para seleccionar boton principal | 532 | // creo las funciones para seleccionar boton principal |
533 | $scope[nombreFuncion(botonPincipal.label)] = function() { | 533 | $scope[nombreFuncion(botonPincipal.label)] = function() { |
534 | 534 | ||
535 | $scope.botoneraPrincipal.filter(function(boton) { | 535 | $scope.botoneraPrincipal.filter(function(boton) { |
536 | boton.checked = false; | 536 | boton.checked = false; |
537 | }); | 537 | }); |
538 | 538 | ||
539 | botonPincipal.checked = true; | 539 | botonPincipal.checked = true; |
540 | $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); | 540 | $scope.botonera = focaParametrosService.getBotones(botonPincipal.modulo); |
541 | }; | 541 | }; |
542 | 542 | ||
543 | }); | 543 | }); |
544 | 544 | ||
545 | function nombreFuncion(string) { | 545 | function nombreFuncion(string) { |
546 | |||
547 | if(!string) return; | ||
548 | |||
546 | var texto = 'seleccionar'; | 549 | var texto = 'seleccionar'; |
547 | var arr = string.split(' '); | 550 | var arr = string.split(' '); |
548 | arr.forEach(function(palabra) { | 551 | arr.forEach(function(palabra) { |
549 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 552 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
550 | texto += palabra; | 553 | texto += palabra; |
551 | }); | 554 | }); |
552 | return texto; | 555 | return texto; |
553 | } | 556 | } |
554 | 557 | ||
555 | function getModulo(propiedad) { | 558 | function getModulo(propiedad) { |
556 | var nombre = ''; | 559 | var nombre = ''; |
557 | 560 | ||
558 | $scope.botoneraPrincipal.filter(function(boton) { | 561 | $scope.botoneraPrincipal.filter(function(boton) { |
559 | if (boton.checked) { | 562 | if (boton.checked) { |
560 | if(!propiedad) { | 563 | if(!propiedad) { |
561 | nombre = boton.variable; | 564 | nombre = boton.variable; |
562 | } else { | 565 | } else { |
563 | nombre = boton[propiedad]; | 566 | nombre = boton[propiedad]; |
564 | } | 567 | } |
565 | } | 568 | } |
566 | }); | 569 | }); |
567 | return nombre; | 570 | return nombre; |
568 | } | 571 | } |
569 | 572 | ||
570 | function getCheckeds() { | 573 | function getCheckeds() { |
571 | 574 | ||
572 | $scope.botonera.forEach(function(boton) { | 575 | $scope.botonera.forEach(function(boton) { |
573 | 576 | ||
574 | if ($scope[getModulo()][boton.variable] !== undefined) { | 577 | if ($scope[getModulo()][boton.variable] !== undefined) { |
575 | 578 | ||
576 | boton.checked = true; | 579 | boton.checked = true; |
577 | 580 | ||
578 | //Creo la función para limpiar obj | 581 | //Creo la función para limpiar obj |
579 | $scope['clean' + boton.variable] = function() { | 582 | $scope['clean' + boton.variable] = function() { |
580 | 583 | ||
581 | focaModalService.alert('Esta seguro que desea eliminar el parámetro?') | 584 | focaModalService.alert('Esta seguro que desea eliminar el parámetro?') |
582 | .then(function() { | 585 | .then(function() { |
583 | delete $scope[getModulo()][boton.variable]; | 586 | delete $scope[getModulo()][boton.variable]; |
584 | $scope.$broadcast('cleanCabecera', { | 587 | $scope.$broadcast('cleanCabecera', { |
585 | seccion: getModulo('label') | 588 | seccion: getModulo('label') |
586 | }); | 589 | }); |
587 | setearEntidad({ | 590 | setearEntidad({ |
588 | jsonText: JSON.stringify($scope[getModulo()]), | 591 | jsonText: JSON.stringify($scope[getModulo()]), |
589 | modulo: getModulo(), | 592 | modulo: getModulo(), |
590 | id: $scope[getModulo() + 'String'].id | 593 | id: $scope[getModulo() + 'String'].id |
591 | }); | 594 | }); |
592 | }); | 595 | }); |
593 | }; | 596 | }; |
594 | 597 | ||
595 | } else { | 598 | } else { |
596 | boton.checked = false; | 599 | boton.checked = false; |
597 | } | 600 | } |
598 | }); | 601 | }); |
599 | } | 602 | } |
600 | 603 | ||
601 | function getCabeceraPuntoDescarga(puntoDescarga) { | 604 | function getCabeceraPuntoDescarga(puntoDescarga) { |
602 | var puntosStamp = ''; | 605 | var puntosStamp = ''; |
603 | puntoDescarga.forEach(function(punto, idx, arr) { | 606 | puntoDescarga.forEach(function(punto, idx, arr) { |
604 | puntosStamp += punto.descripcion; | 607 | puntosStamp += punto.descripcion; |
605 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 608 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
606 | }); | 609 | }); |
607 | return puntosStamp; | 610 | return puntosStamp; |
608 | } | 611 | } |
609 | 612 | ||
610 | function setearEntidad(entidad) { | 613 | function setearEntidad(entidad) { |
611 | 614 | ||
612 | $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; | 615 | $scope[entidad.modulo] = JSON.parse(entidad.jsonText) || {}; |
613 | $scope[entidad.modulo + 'String'].id = entidad.id; | 616 | $scope[entidad.modulo + 'String'].id = entidad.id; |
614 | 617 | ||
615 | if (!$scope[entidad.modulo].domicilio) { | 618 | if (!$scope[entidad.modulo].domicilio) { |
616 | $scope[entidad.modulo].domicilio = { | 619 | $scope[entidad.modulo].domicilio = { |
617 | id: $scope[entidad.modulo].idDomicilio | 620 | id: $scope[entidad.modulo].idDomicilio |
618 | }; | 621 | }; |
619 | } | 622 | } |
620 | 623 | ||
621 | var cabeceras = []; | 624 | var cabeceras = []; |
622 | 625 | ||
623 | if ($scope[entidad.modulo].cotizacion) { | 626 | if ($scope[entidad.modulo].cotizacion) { |
624 | cabeceras.push({ | 627 | cabeceras.push({ |
625 | label: 'Moneda:', | 628 | label: 'Moneda:', |
626 | valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE | 629 | valor: $scope[entidad.modulo].cotizacion.moneda.DETALLE |
627 | }); | 630 | }); |
628 | cabeceras.push({ | 631 | cabeceras.push({ |
629 | label: 'Fecha cotizacion:', | 632 | label: 'Fecha cotizacion:', |
630 | valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, | 633 | valor: $filter('date')($scope[entidad.modulo].cotizacion.FECHA, |
631 | 'dd/MM/yyyy') | 634 | 'dd/MM/yyyy') |
632 | }); | 635 | }); |
633 | cabeceras.push({ | 636 | cabeceras.push({ |
634 | label: 'Cotizacion:', | 637 | label: 'Cotizacion:', |
635 | valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, | 638 | valor: $filter('number')($scope[entidad.modulo].cotizacion.VENDEDOR, |
636 | '2') | 639 | '2') |
637 | }); | 640 | }); |
638 | } | 641 | } |
639 | 642 | ||
640 | if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { | 643 | if ($scope[entidad.modulo].vendedor && $scope[entidad.modulo].vendedor.NUM) { |
641 | cabeceras.push({ | 644 | cabeceras.push({ |
642 | label: 'Vendedor:', | 645 | label: 'Vendedor:', |
643 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + | 646 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].vendedor.NUM, 3) + |
644 | ' - ' + $scope[entidad.modulo].vendedor.NOM | 647 | ' - ' + $scope[entidad.modulo].vendedor.NOM |
645 | }); | 648 | }); |
646 | } | 649 | } |
647 | 650 | ||
648 | if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { | 651 | if ($scope[entidad.modulo].cliente && $scope[entidad.modulo].cliente.COD) { |
649 | cabeceras.push({ | 652 | cabeceras.push({ |
650 | label: 'Cliente:', | 653 | label: 'Cliente:', |
651 | valor: $scope[entidad.modulo].cliente.NOM | 654 | valor: $scope[entidad.modulo].cliente.NOM |
652 | }); | 655 | }); |
653 | cabeceras.push({ | 656 | cabeceras.push({ |
654 | label: 'Domicilio:', | 657 | label: 'Domicilio:', |
655 | valor: $scope[entidad.modulo].domicilioStamp | 658 | valor: $scope[entidad.modulo].domicilioStamp |
656 | }); | 659 | }); |
657 | } | 660 | } |
658 | 661 | ||
659 | if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { | 662 | if ($scope[entidad.modulo].proveedor && $scope[entidad.modulo].proveedor.COD) { |
660 | cabeceras.push({ | 663 | cabeceras.push({ |
661 | label: 'Proveedor:', | 664 | label: 'Proveedor:', |
662 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + | 665 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].proveedor.COD, 5) + |
663 | ' - ' + $scope[entidad.modulo].proveedor.NOM | 666 | ' - ' + $scope[entidad.modulo].proveedor.NOM |
664 | }); | 667 | }); |
665 | } | 668 | } |
666 | 669 | ||
667 | if ($scope[entidad.modulo][entidad + 'Plazo'] && | 670 | if ($scope[entidad.modulo][entidad + 'Plazo'] && |
668 | $scope[entidad.modulo][entidad + 'Plazo'].length) | 671 | $scope[entidad.modulo][entidad + 'Plazo'].length) |
669 | { | 672 | { |
670 | cabeceras.push({ | 673 | cabeceras.push({ |
671 | label: 'Precios y condiciones:', | 674 | label: 'Precios y condiciones:', |
672 | valor: valorPrecioCondicion() + ' ' + | 675 | valor: valorPrecioCondicion() + ' ' + |
673 | focaParametrosService.plazoToString( | 676 | focaParametrosService.plazoToString( |
674 | $scope[entidad.modulo][entidad.modulo + 'Plazo']) | 677 | $scope[entidad.modulo][entidad.modulo + 'Plazo']) |
675 | }); | 678 | }); |
676 | } | 679 | } |
677 | 680 | ||
678 | if ($scope[entidad.modulo].flete !== undefined) { | 681 | if ($scope[entidad.modulo].flete !== undefined) { |
679 | cabeceras.push({ | 682 | cabeceras.push({ |
680 | label: 'Flete:', | 683 | label: 'Flete:', |
681 | valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( | 684 | valor: $scope[entidad.modulo].fob === 1 ? 'FOB' : ( |
682 | $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') | 685 | $scope[entidad.modulo].flete === 1 ? 'Si' : 'No') |
683 | }); | 686 | }); |
684 | } | 687 | } |
685 | 688 | ||
686 | function valorPrecioCondicion() { | 689 | function valorPrecioCondicion() { |
687 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { | 690 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { |
688 | return $scope[entidad.modulo].precioCondicion.nombre; | 691 | return $scope[entidad.modulo].precioCondicion.nombre; |
689 | } else { | 692 | } else { |
690 | return 'Ingreso Manual'; | 693 | return 'Ingreso Manual'; |
691 | } | 694 | } |
692 | } | 695 | } |
693 | 696 | ||
694 | if ($scope[entidad.modulo].flete === 1) { | 697 | if ($scope[entidad.modulo].flete === 1) { |
695 | var cabeceraBomba = { | 698 | var cabeceraBomba = { |
696 | label: 'Bomba:', | 699 | label: 'Bomba:', |
697 | valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' | 700 | valor: $scope[entidad.modulo].bomba === 1 ? 'Si' : 'No' |
698 | }; | 701 | }; |
699 | if ($scope[entidad.modulo].kilometros) { | 702 | if ($scope[entidad.modulo].kilometros) { |
700 | var cabeceraKilometros = { | 703 | var cabeceraKilometros = { |
701 | label: 'Kilometros:', | 704 | label: 'Kilometros:', |
702 | valor: $scope[entidad.modulo].kilometros | 705 | valor: $scope[entidad.modulo].kilometros |
703 | }; | 706 | }; |
704 | cabeceras.push(cabeceraKilometros); | 707 | cabeceras.push(cabeceraKilometros); |
705 | } | 708 | } |
706 | cabeceras.push(cabeceraBomba); | 709 | cabeceras.push(cabeceraBomba); |
707 | } | 710 | } |
708 | 711 | ||
709 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { | 712 | if ($scope[entidad.modulo].idPrecioCondicion > 0) { |
710 | $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; | 713 | $scope.idLista = $scope[entidad.modulo].precioCondicion.idListaPrecio; |
711 | } else { | 714 | } else { |
712 | $scope.idLista = -1; | 715 | $scope.idLista = -1; |
713 | } | 716 | } |
714 | 717 | ||
715 | if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { | 718 | if ($scope[entidad.modulo][entidad.modulo + 'PuntoDescarga']) { |
716 | var puntos = []; | 719 | var puntos = []; |
717 | $scope[entidad.modulo][entidad.modulo + 'PuntoDescarga'] | 720 | $scope[entidad.modulo][entidad.modulo + 'PuntoDescarga'] |
718 | .forEach(function(entidadPuntoDescarga) { | 721 | .forEach(function(entidadPuntoDescarga) { |
719 | puntos.push(entidadPuntoDescarga); | 722 | puntos.push(entidadPuntoDescarga); |
720 | }); | 723 | }); |
721 | cabeceras.push({ | 724 | cabeceras.push({ |
722 | label: 'Puntos de descarga: ', | 725 | label: 'Puntos de descarga: ', |
723 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | 726 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) |
724 | }); | 727 | }); |
725 | } | 728 | } |
726 | 729 | ||
727 | if ($scope[entidad.modulo].tarifario) { | 730 | if ($scope[entidad.modulo].tarifario) { |
728 | cabeceras.push({ | 731 | cabeceras.push({ |
729 | label: 'Tarifario', | 732 | label: 'Tarifario', |
730 | valor: $scope[entidad.modulo].tarifario | 733 | valor: $scope[entidad.modulo].tarifario |
731 | }); | 734 | }); |
732 | } | 735 | } |
733 | 736 | ||
734 | if ($scope[entidad.modulo].transportista) { | 737 | if ($scope[entidad.modulo].transportista) { |
735 | cabeceras.push({ | 738 | cabeceras.push({ |
736 | label: 'Transportista', | 739 | label: 'Transportista', |
737 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].transportista.COD, | 740 | valor: $filter('rellenarDigitos')($scope[entidad.modulo].transportista.COD, |
738 | 5) + ' - ' + $scope[entidad.modulo].transportista.NOM | 741 | 5) + ' - ' + $scope[entidad.modulo].transportista.NOM |
739 | }); | 742 | }); |
740 | } | 743 | } |
741 | 744 | ||
742 | addArrayCabecera(cabeceras, entidad.modulo); | 745 | addArrayCabecera(cabeceras, entidad.modulo); |
743 | 746 | ||
744 | } | 747 | } |
745 | 748 | ||
746 | function addArrayCabecera(array, entidad) { | 749 | function addArrayCabecera(array, entidad) { |
747 | for (var i = 0; i < array.length; i++) { | 750 | for (var i = 0; i < array.length; i++) { |
748 | $scope.$broadcast('addCabecera', { | 751 | $scope.$broadcast('addCabecera', { |
749 | label: array[i].label, | 752 | label: array[i].label, |
750 | valor: array[i].valor, | 753 | valor: array[i].valor, |
751 | seccion: $filter('filter') | 754 | seccion: $filter('filter') |
752 | ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label | 755 | ($scope.botoneraPrincipal, {variable: entidad}, true)[0].label |
753 | }); | 756 | }); |
754 | } | 757 | } |
755 | } | 758 | } |
756 | 759 | ||
757 | function getObjGuardar() { | 760 | function getObjGuardar() { |
758 | var guardar = []; | 761 | var guardar = []; |
759 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { | 762 | $scope.botoneraPrincipal.forEach(function(botonPincipal) { |
760 | if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; | 763 | if (!botonPincipal || !$scope[botonPincipal.variable + 'String']) return; |
761 | guardar.push($scope[botonPincipal.variable + 'String']); | 764 | guardar.push($scope[botonPincipal.variable + 'String']); |
762 | }); | 765 | }); |
763 | 766 | ||
764 | return guardar; | 767 | return guardar; |
765 | } | 768 | } |
766 | 769 | ||
767 | }]); | 770 | }]); |
768 | 771 |