Commit e2b3485e5414185a87d8a4de92580bb4d79ae515
1 parent
3abde74d8a
Exists in
master
and in
2 other branches
Crear Hoja de ruta RA
Showing
6 changed files
with
1159 additions
and
208 deletions
Show diff stats
src/js/businessService.js
1 | 1 | angular.module('focaCrearHojaRuta') |
2 | 2 | .factory('hojaRutaBusinessService', [ |
3 | - 'crearHojaRutaService', | |
3 | + 'focaCrearHojaRutaService', | |
4 | 4 | function(crearHojaRutaService) { |
5 | 5 | return { |
6 | - addArticulos: function(articulosHojaRuta, idHojaRuta, cotizacion) { | |
6 | + addArticulos: function(articulosHojaRuta, idRemito, cotizacion) { | |
7 | 7 | for(var i = 0; i < articulosHojaRuta.length; i++) { |
8 | 8 | delete articulosHojaRuta[i].editCantidad; |
9 | 9 | delete articulosHojaRuta[i].editPrecio; |
10 | - articulosHojaRuta[i].idHojaRuta = idHojaRuta; | |
10 | + delete articulosHojaRuta[i].sectorCodigo; | |
11 | + articulosHojaRuta[i].idRemito = idRemito; | |
11 | 12 | articulosHojaRuta[i].precio = articulosHojaRuta[i].precio * cotizacion; |
12 | 13 | crearHojaRutaService.crearArticulosParaHojaRuta(articulosHojaRuta[i]); |
13 | 14 | } |
... | ... | @@ -22,6 +23,6 @@ angular.module('focaCrearHojaRuta') |
22 | 23 | idVendedor: idVendedor |
23 | 24 | }; |
24 | 25 | crearHojaRutaService.crearEstadoParaHojaRuta(estado); |
25 | - } | |
26 | + }, | |
26 | 27 | }; |
27 | 28 | }]); |
src/js/controller.js
1 | -angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | |
1 | +angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', | |
2 | 2 | [ |
3 | 3 | '$scope', |
4 | 4 | '$uibModal', |
... | ... | @@ -10,48 +10,59 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
10 | 10 | 'focaBotoneraLateralService', |
11 | 11 | 'focaLoginService', |
12 | 12 | '$localStorage', |
13 | - function($scope, $uibModal, $location, $filter, $timeout, | |
13 | + 'hojaRutaBusinessService', | |
14 | + '$cookies', | |
15 | + function ($scope, $uibModal, $location, $filter, $timeout, | |
14 | 16 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, |
15 | - focaLoginSrv, $localStorage) | |
16 | - { | |
17 | + focaLoginSrv, $localStorage, hojaRutaBusinessService, $cookies) { | |
17 | 18 | config(); |
18 | 19 | |
19 | 20 | function config() { |
20 | - $scope.botonera = focaCrearHojaRutaService.getBotonera(); | |
21 | + | |
22 | + $scope.botoneraPrincipal = focaCrearHojaRutaService.getBotones(); | |
23 | + $scope.botonera = []; | |
24 | + | |
21 | 25 | $scope.datepickerAbierto = false; |
22 | 26 | $scope.show = false; |
27 | + $scope.precargado = false; | |
28 | + $scope.cargaRemito = false; | |
29 | + $scope.remitoAbierto = false; | |
30 | + $scope.cisternaCargas = []; | |
23 | 31 | $scope.cargando = true; |
32 | + $scope.articulos = []; | |
33 | + $scope.remito = { | |
34 | + id: '', | |
35 | + numeroRemito: '' | |
36 | + }; | |
24 | 37 | $scope.now = new Date(); |
25 | 38 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
26 | 39 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
27 | 40 | |
28 | 41 | //SETEO BOTONERA LATERAL |
29 | - $timeout(function() { | |
42 | + $timeout(function () { | |
30 | 43 | focaBotoneraLateralService.showSalir(false); |
31 | 44 | focaBotoneraLateralService.showPausar(true); |
32 | 45 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
33 | 46 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
34 | 47 | }); |
35 | 48 | |
36 | - focaCrearHojaRutaService.getParametros().then(function(res) { | |
49 | + focaCrearHojaRutaService.getParametros().then(function (res) { | |
37 | 50 | |
38 | 51 | var parametros = JSON.parse(res.data[0].jsonText); |
39 | 52 | |
40 | 53 | if ($localStorage.hojaRuta) { |
41 | - $timeout(function() {getLSHojaRuta();}); | |
54 | + $timeout(function () { getLSHojaRuta(); }); | |
42 | 55 | } else { |
43 | - | |
44 | - for(var property in parametros) { | |
56 | + for (var property in parametros) { | |
45 | 57 | $scope.hojaRuta[property] = parametros[property]; |
46 | 58 | $scope.inicial[property] = parametros[property]; |
47 | 59 | } |
48 | - | |
49 | - setearHojaRuta($scope.hojaRuta); | |
60 | + //Setear Hoja de Ruta | |
61 | + //setearHojaRuta($scope.hojaRuta); | |
50 | 62 | } |
51 | 63 | }); |
52 | 64 | init(); |
53 | 65 | } |
54 | - | |
55 | 66 | function init() { |
56 | 67 | $scope.$broadcast('cleanCabecera'); |
57 | 68 | |
... | ... | @@ -68,11 +79,11 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
68 | 79 | $scope.idLista = undefined; |
69 | 80 | |
70 | 81 | focaCrearHojaRutaService.getNumeroHojaRuta().then( |
71 | - function(res) { | |
82 | + function (res) { | |
72 | 83 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); |
73 | 84 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); |
74 | 85 | }, |
75 | - function(err) { | |
86 | + function (err) { | |
76 | 87 | focaModalService.alert('La terminal no esta configurada correctamente'); |
77 | 88 | console.info(err); |
78 | 89 | } |
... | ... | @@ -81,49 +92,426 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
81 | 92 | $scope.inicial = angular.copy($scope.hojaRuta); |
82 | 93 | } |
83 | 94 | |
84 | - $scope.$watch('hojaRuta', function(newValue) { | |
85 | - | |
86 | - // Seteo checked en remitos | |
87 | - if ($scope.hojaRuta.remitosTabla.length) { | |
95 | + // $scope.$watch('hojaRuta', function(newValue) { | |
96 | + | |
97 | + // // Seteo checked en remitos | |
98 | + // if ($scope.hojaRuta.remitosTabla.length) { | |
99 | + // $filter('filter')($scope.botonera, { | |
100 | + // label: 'Remitos', | |
101 | + // })[0].checked = true; | |
102 | + // } else { | |
103 | + // $filter('filter')($scope.botonera, { | |
104 | + // label: 'Remitos', | |
105 | + // })[0].checked = false; | |
106 | + // } | |
107 | + | |
108 | + // focaBotoneraLateralService.setPausarData({ | |
109 | + // label: 'hojaRuta', | |
110 | + // val: newValue | |
111 | + // }); | |
112 | + // }, true); | |
113 | + | |
114 | + $scope.seleccionarRemitoAbierto = function () { | |
115 | + $scope.remitoAbierto = true; | |
116 | + $scope.cargaRemito = false; | |
117 | + $scope.botoneraPrincipal.forEach(function (boton) { | |
118 | + boton.checked = false; | |
119 | + }); | |
120 | + $filter('filter')($scope.botoneraPrincipal, { | |
121 | + label: 'Remito Abierto', | |
122 | + })[0].checked = false; | |
123 | + | |
124 | + $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto(); | |
125 | + }; | |
88 | 126 | |
89 | - $filter('filter')($scope.botonera, { | |
90 | - label: 'Remitos', | |
91 | - })[0].checked = true; | |
127 | + $scope.seleccionarCargarRemitos = function () { | |
128 | + $scope.cargaRemito = true; | |
129 | + | |
130 | + var isBotoneraDirty = $scope.botonera.find(function (boton) { | |
131 | + return boton.checked; | |
132 | + }); | |
133 | + | |
134 | + if (isBotoneraDirty) { | |
135 | + focaModalService.confirm('Se perderan los cambios') | |
136 | + .then(function () { | |
137 | + limpiarBotonera($scope.botonera); | |
138 | + $scope.preCargados = false; | |
139 | + $filter('filter')($scope.botoneraPrincipal, { | |
140 | + label: 'Cargar Remitos', | |
141 | + })[0].checked = true; | |
142 | + $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | |
143 | + }); | |
92 | 144 | } else { |
93 | - $filter('filter')($scope.botonera, { | |
94 | - label: 'Remitos', | |
95 | - })[0].checked = false; | |
145 | + $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | |
96 | 146 | } |
147 | + $scope.precargado = false; | |
148 | + }; | |
149 | + | |
150 | + $scope.seleccionarPrecargados = function () { | |
151 | + $scope.precargado = true; | |
152 | + $filter('filter')($scope.botoneraPrincipal, { | |
153 | + label: '', | |
154 | + })[0].checked = true; | |
155 | + $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | |
156 | + }; | |
97 | 157 | |
98 | - focaBotoneraLateralService.setPausarData({ | |
99 | - label: 'hojaRuta', | |
100 | - val: newValue | |
158 | + $scope.quitarArticulo = function (articulo) { | |
159 | + $scope.articulosSeleccionados.forEach( function () { | |
101 | 160 | }); |
102 | - }, true); | |
161 | + articulo = -1; | |
162 | + }; | |
103 | 163 | |
104 | - $scope.crearHojaRuta = function() { | |
105 | - if (!$scope.hojaRuta.remitosTabla.length) { | |
106 | - focaModalService.alert('Ingrese Remitos'); | |
107 | - return; | |
108 | - } | |
109 | - if (!$scope.hojaRuta.chofer.id) { | |
110 | - focaModalService.alert('Ingrese Chofer'); | |
111 | - return; | |
164 | + function validarHojaRuta() { | |
165 | + if ($scope.precargado) { | |
166 | + if (!$scope.hojaRuta.chofer.id) { | |
167 | + focaModalService.alert('Ingrese Chofer'); | |
168 | + return false; | |
169 | + } | |
170 | + if (!$scope.hojaRuta.vehiculo.id) { | |
171 | + focaModalService.alert('Ingrese Vehiculo'); | |
172 | + return false; | |
173 | + } | |
174 | + if (!$scope.hojaRuta.transportista.COD) { | |
175 | + focaModalService.alert('Ingrese Transportista'); | |
176 | + return false; | |
177 | + } | |
178 | + if (!$scope.hojaRuta.datosExtra) { | |
179 | + focaModalService.alert('Ingrese Datos extra'); | |
180 | + return false; | |
181 | + } | |
182 | + } else if ($scope.cargaRemito) { | |
183 | + if (!$scope.hojaRuta.remitosTabla.length) { | |
184 | + focaModalService.alert('Ingrese Remitos'); | |
185 | + return false; | |
186 | + } else if (!$scope.hojaRuta.chofer.id) { | |
187 | + focaModalService.alert('Ingrese Chofer'); | |
188 | + return false; | |
189 | + } | |
190 | + if (!$scope.hojaRuta.vehiculo.id) { | |
191 | + focaModalService.alert('Ingrese Vehiculo'); | |
192 | + return false; | |
193 | + } | |
194 | + if (!$scope.hojaRuta.transportista.COD) { | |
195 | + focaModalService.alert('Ingrese Transportista'); | |
196 | + return false; | |
197 | + } | |
198 | + if (!$scope.hojaRuta.datosExtra) { | |
199 | + focaModalService.alert('Ingrese Datos extra'); | |
200 | + return false; | |
201 | + } | |
202 | + } else if ($scope.remitoAbierto) { | |
203 | + if (!$scope.hojaRuta.transportista.COD) { | |
204 | + focaModalService.alert('Ingrese Transportista'); | |
205 | + return false; | |
206 | + } else if (!$scope.hojaRuta.vehiculo.id) { | |
207 | + focaModalService.alert('Ingrese Vehiculo'); | |
208 | + return false; | |
209 | + } else if (!$scope.hojaRuta.chofer.id) { | |
210 | + focaModalService.alert('Ingrese Chofer'); | |
211 | + return false; | |
212 | + } else if (!$scope.hojaRuta.proveedor.COD) { | |
213 | + focaModalService.alert('Ingrese Proveedor'); | |
214 | + return false; | |
215 | + } else if (!$scope.hojaRuta.cliente.COD) { | |
216 | + focaModalService.alert('Ingrese un Cliente'); | |
217 | + return; | |
218 | + } | |
112 | 219 | } |
113 | - if (!$scope.hojaRuta.vehiculo.id) { | |
114 | - focaModalService.alert('Ingrese Vehiculo'); | |
220 | + return true; | |
221 | + | |
222 | + } | |
223 | + | |
224 | + function getImporte(propiedad) { | |
225 | + var importe = 0; | |
226 | + | |
227 | + $scope.articulos.forEach(function (articulo) { | |
228 | + | |
229 | + if (articulo[propiedad]) { | |
230 | + importe += articulo[propiedad] * articulo.cantidad; | |
231 | + } | |
115 | 232 | return; |
233 | + | |
234 | + }); | |
235 | + | |
236 | + return importe; | |
237 | + } | |
238 | + | |
239 | + function guardarRemitoAbierto() { | |
240 | + //guardar nuevo objeto (?) | |
241 | + var date = new Date(); | |
242 | + if ($scope.hojaRuta !== null) { | |
243 | + focaBotoneraLateralService.startGuardar(); | |
244 | + var save = { | |
245 | + remito: { | |
246 | + id: 0, | |
247 | + fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | |
248 | + idCliente: $scope.hojaRuta.cliente.COD, | |
249 | + nombreCliente: $scope.hojaRuta.cliente.NOM, | |
250 | + cuitCliente: $scope.hojaRuta.cliente.CUIT, | |
251 | + idVendedor: $cookies.get('vendedorCobrador'), | |
252 | + idProveedor: $scope.hojaRuta.proveedor.COD, | |
253 | + idDomicilio: $scope.hojaRuta.idDomicilio || $scope.hojaRuta.domicilio.id, | |
254 | + idCotizacion: $scope.hojaRuta.cotizacion.ID, | |
255 | + domicilioStamp: $scope.hojaRuta.domicilioStamp, | |
256 | + observaciones: $scope.hojaRuta.observaciones, | |
257 | + idListaPrecio: $scope.hojaRuta.cliente.MOD.trim(), | |
258 | + total: getImporte('total') || 0, | |
259 | + descuento: 0,//TODO, | |
260 | + importeNeto: getImporte('netoUnitario') || 0, //TODO: arreglar, | |
261 | + importeExento: getImporte('exentoUnitario'), | |
262 | + importeIva: getImporte('ivaUnitario') || 0, //TODO: arreglar | |
263 | + importeIvaServicios: 0,//TODO | |
264 | + importeImpuestoInterno: getImporte('impuestoInternoUnitario'), | |
265 | + importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), | |
266 | + importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), | |
267 | + percepcion: 0,//TODO | |
268 | + percepcionIva: 0,//TODO | |
269 | + redondeo: 0,//TODO | |
270 | + anulado: false, | |
271 | + planilla: $filter('date')($scope.now, 'ddMMyyyy'), | |
272 | + lugar: parseInt($scope.puntoVenta), | |
273 | + cuentaMadre: 0,//TODO | |
274 | + cuentaContable: 0,//TODO | |
275 | + asiento: 0,//TODO | |
276 | + e_hd: '',//TODO | |
277 | + c_hd: '', | |
278 | + numeroLiquidoProducto: 0,//TODO | |
279 | + estado: 0, | |
280 | + destinoVenta: 0,//TODO | |
281 | + operacionTipo: 0, //TODO | |
282 | + }, | |
283 | + notaPedido: { | |
284 | + id: 0 | |
285 | + } | |
286 | + }; | |
287 | + focaCrearHojaRutaService.crearRemito(save).then( | |
288 | + function (data) { | |
289 | + focaBotoneraLateralService.endGuardar(true); | |
290 | + $scope.saveLoading = false; | |
291 | + | |
292 | + $scope.remito.id = data.data.id; | |
293 | + | |
294 | + focaCrearHojaRutaService.guardarCisternas({ | |
295 | + cisternaCargas: $scope.cisternaCargas, | |
296 | + cisternaMovimientos: $scope.cisternaMovimientos, | |
297 | + fechaReparto: $scope.hojaRuta.fechaReparto, | |
298 | + idVehiculo: $scope.hojaRuta.vehiculo.id | |
299 | + }, data.data.id); | |
300 | + $scope.remito.numeroRemito = data.data.numero; | |
301 | + | |
302 | + // if ($scope.remito.remitoPuntoDescarga.length > 0) { | |
303 | + // remitoBusinessService.addPuntosDescarga(data.data.id, | |
304 | + // $scope.remito.remitoPuntoDescarga); | |
305 | + // } | |
306 | + | |
307 | + hojaRutaBusinessService.addArticulos($scope.articulosRecibidos, | |
308 | + data.data.id, $scope.hojaRuta.cotizacion.VENDEDOR); | |
309 | + | |
310 | + guardarHojaRuta(data.data.id); | |
311 | + | |
312 | + }, function (error) { | |
313 | + focaModalService.alert(error.data || 'Hubo un error al crear el remito'); | |
314 | + focaBotoneraLateralService.endGuardar(); | |
315 | + $scope.saveLoading = false; | |
316 | + console.info(error); | |
317 | + } | |
318 | + ); | |
319 | + | |
320 | + function guardarHojaRuta(idRemito) { | |
321 | + | |
322 | + | |
323 | + var save2 = { | |
324 | + hojaRuta: { | |
325 | + id: 0, | |
326 | + fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | |
327 | + .replace('T', ' '), | |
328 | + idTransportista: $scope.hojaRuta.transportista.COD, | |
329 | + idChofer: $scope.hojaRuta.chofer.id, | |
330 | + idVehiculo: $scope.hojaRuta.vehiculo.id, | |
331 | + proveedor: $scope.hojaRuta.proveedor.id, | |
332 | + fechaReparto: | |
333 | + new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | |
334 | + estado: 0, | |
335 | + abierta: 1 | |
336 | + }, | |
337 | + remitos: [{id: idRemito}] | |
338 | + } | |
339 | + save2.hojaRuta = angular.extend({}, save2.hojaRuta, $scope.hojaRuta.datosExtra); | |
340 | + focaCrearHojaRutaService.crearHojaRuta(save2).then( | |
341 | + function (data) { | |
342 | + focaModalService.alert( | |
343 | + 'Hoja ruta creada Nยบ: ' + | |
344 | + $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | |
345 | + $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) | |
346 | + ); | |
347 | + | |
348 | + config(); | |
349 | + }, | |
350 | + function (error) { | |
351 | + focaModalService.alert('Hubo un error al crear la hoja de ruta'); | |
352 | + console.info(error); | |
353 | + } | |
354 | + ); | |
355 | + } | |
116 | 356 | } |
117 | - if (!$scope.hojaRuta.transportista.COD) { | |
118 | - focaModalService.alert('Ingrese Transportista'); | |
357 | + } | |
358 | + | |
359 | + $scope.seleccionarCliente = function () { | |
360 | + var modalInstance = $uibModal.open( | |
361 | + { | |
362 | + ariaLabelledBy: 'Busqueda de Cliente', | |
363 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
364 | + controller: 'focaBusquedaClienteModalController', | |
365 | + resolve: { | |
366 | + vendedor: function () { return null; }, | |
367 | + cobrador: function () { return null; } | |
368 | + }, | |
369 | + size: 'lg' | |
370 | + } | |
371 | + ); | |
372 | + modalInstance.result.then( | |
373 | + function (cliente) { | |
374 | + $scope.abrirModalDomicilios(cliente); | |
375 | + $scope.cliente = cliente; | |
376 | + }, function () { | |
377 | + } | |
378 | + ); | |
379 | + }; | |
380 | + | |
381 | + $scope.abrirModalDomicilios = function (cliente) { | |
382 | + var modalInstanceDomicilio = $uibModal.open( | |
383 | + { | |
384 | + ariaLabelledBy: 'Busqueda de Domicilios', | |
385 | + templateUrl: 'modal-domicilio.html', | |
386 | + controller: 'focaModalDomicilioController', | |
387 | + size: 'lg', | |
388 | + resolve: { | |
389 | + idCliente: function () { return cliente.cod; }, | |
390 | + esNuevo: function () { return cliente.esNuevo; } | |
391 | + } | |
392 | + } | |
393 | + ); | |
394 | + modalInstanceDomicilio.result.then( | |
395 | + function (domicilio) { | |
396 | + $scope.hojaRuta.domicilio = domicilio; | |
397 | + $scope.hojaRuta.cliente = { | |
398 | + COD: cliente.cod, | |
399 | + CUIT: cliente.cuit, | |
400 | + NOM: cliente.nom, | |
401 | + MAIL: cliente.mail, | |
402 | + MOD: cliente.mod, | |
403 | + IVA: cliente.iva, | |
404 | + VEN: cliente.ven | |
405 | + }; | |
406 | + focaCrearHojaRutaService.getVendedorById($scope.hojaRuta.cliente.VEN) | |
407 | + .then(function (res) { | |
408 | + if (res.data !== '') { | |
409 | + $scope.hojaRuta.vendedor = res.data; | |
410 | + $scope.$broadcast('addCabecera', { | |
411 | + label: 'Vendedor:', | |
412 | + valor: $filter('rellenarDigitos')($scope.hojaRuta.vendedor | |
413 | + .NUM, 3) +' - ' + $scope.hojaRuta.vendedor.NOM | |
414 | + }); | |
415 | + } | |
416 | + var domicilioStamp = | |
417 | + domicilio.Calle + ' ' + domicilio.Numero + ', ' + | |
418 | + domicilio.Localidad + ', ' + domicilio.Provincia; | |
419 | + $scope.hojaRuta.domicilioStamp = domicilioStamp; | |
420 | + $scope.$broadcast('addCabecera', { | |
421 | + label: 'Cliente:', | |
422 | + valor: $filter('rellenarDigitos')(cliente.cod, 3) + | |
423 | + ' - ' + cliente.nom | |
424 | + }); | |
425 | + $scope.$broadcast('addCabecera', { | |
426 | + label: 'Domicilio:', | |
427 | + valor: domicilioStamp | |
428 | + }); | |
429 | + | |
430 | + if (domicilio.verPuntos) { | |
431 | + delete $scope.hojaRuta.domicilio.verPuntos; | |
432 | + $scope.seleccionarPuntosDeDescarga(); | |
433 | + } else { | |
434 | + focaCrearHojaRutaService | |
435 | + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | |
436 | + .then(function (res) { | |
437 | + if (res.data.length) { | |
438 | + $scope.seleccionarPuntosDeDescarga(); | |
439 | + } | |
440 | + }); | |
441 | + } | |
442 | + | |
443 | + $filter('filter')($scope.botonera, { | |
444 | + label: 'Cliente', | |
445 | + })[0].checked = true; | |
446 | + }) | |
447 | + .catch(function (e) { console.log(e); }); | |
448 | + }, function () { | |
449 | + $scope.seleccionarCliente(true); | |
450 | + return; | |
451 | + } | |
452 | + ); | |
453 | + }; | |
454 | + | |
455 | + $scope.seleccionarPuntosDeDescarga = function () { | |
456 | + if (!$scope.hojaRuta.cliente.COD || !$scope.hojaRuta.domicilio.id) { | |
457 | + focaModalService.alert('Primero seleccione un cliente y un domicilio'); | |
119 | 458 | return; |
459 | + } else { | |
460 | + var modalInstance = $uibModal.open( | |
461 | + { | |
462 | + ariaLabelledBy: 'Bรบsqueda de Puntos de descarga', | |
463 | + templateUrl: 'modal-punto-descarga.html', | |
464 | + controller: 'focaModalPuntoDescargaController', | |
465 | + size: 'lg', | |
466 | + resolve: { | |
467 | + filters: { | |
468 | + idDomicilio: $scope.remito.domicilio.id, | |
469 | + idCliente: $scope.remito.cliente.COD, | |
470 | + articulos: $scope.remito.articulosRemito, | |
471 | + puntosDescarga: $scope.remito.remitoPuntoDescarga, | |
472 | + domicilio: $scope.remito.domicilio | |
473 | + } | |
474 | + } | |
475 | + } | |
476 | + ); | |
477 | + modalInstance.result.then( | |
478 | + function(puntosDescarga) { | |
479 | + | |
480 | + puntosDescarga.forEach(function(punto) { | |
481 | + $scope.hojaRuta.remitoPuntoDescarga.push( | |
482 | + { | |
483 | + puntoDescarga: punto | |
484 | + } | |
485 | + ); | |
486 | + }); | |
487 | + | |
488 | + $scope.$broadcast('addCabecera', { | |
489 | + label: 'Puntos de descarga:', | |
490 | + valor: getCabeceraPuntoDescarga(puntosDescarga) | |
491 | + }); | |
492 | + }, function () { | |
493 | + $scope.abrirModalDomicilios($scope.cliente); | |
494 | + } | |
495 | + ); | |
120 | 496 | } |
121 | - if (!$scope.hojaRuta.tarifario) { | |
122 | - focaModalService.alert('Ingrese Tarifario'); | |
497 | + }; | |
498 | + | |
499 | + function getCabeceraPuntoDescarga(puntosDescarga) { | |
500 | + var puntosStamp = ''; | |
501 | + puntosDescarga.forEach(function (punto, idx, arr) { | |
502 | + puntosStamp += punto.descripcion; | |
503 | + if ((idx + 1) !== arr.length) puntosStamp += ', '; | |
504 | + }); | |
505 | + return puntosStamp; | |
506 | + } | |
507 | + | |
508 | + $scope.crearHojaRuta = function () { | |
509 | + | |
510 | + var continuar = validarHojaRuta(); | |
511 | + if (!continuar) { | |
123 | 512 | return; |
124 | - } | |
125 | - if (!$scope.hojaRuta.datosExtra) { | |
126 | - focaModalService.alert('Ingrese Datos extra'); | |
513 | + } else if ($scope.remitoAbierto) { | |
514 | + guardarRemitoAbierto(); | |
127 | 515 | return; |
128 | 516 | } |
129 | 517 | var date = new Date(); |
... | ... | @@ -142,9 +530,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
142 | 530 | }, |
143 | 531 | remitos: $scope.hojaRuta.remitosTabla |
144 | 532 | }; |
533 | + | |
145 | 534 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); |
146 | 535 | focaCrearHojaRutaService.crearHojaRuta(save).then( |
147 | - function(data) { | |
536 | + function (data) { | |
148 | 537 | focaModalService.alert( |
149 | 538 | 'Hoja ruta creada Nยบ: ' + |
150 | 539 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + |
... | ... | @@ -153,14 +542,54 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
153 | 542 | |
154 | 543 | config(); |
155 | 544 | }, |
156 | - function(error) { | |
545 | + function (error) { | |
157 | 546 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
158 | 547 | console.info(error); |
159 | 548 | } |
160 | 549 | ); |
161 | 550 | }; |
162 | 551 | |
163 | - $scope.seleccionarTransportista = function() { | |
552 | + $scope.seleccionarProveedor = function () { | |
553 | + var parametrosModal = { | |
554 | + titulo: 'Bรบsqueda de Proveedor', | |
555 | + query: '/proveedor', | |
556 | + columnas: [ | |
557 | + { | |
558 | + nombre: 'Cรณdigo', | |
559 | + propiedad: 'COD', | |
560 | + filtro: { | |
561 | + nombre: 'rellenarDigitos', | |
562 | + parametro: 5 | |
563 | + } | |
564 | + }, | |
565 | + { | |
566 | + nombre: 'Nombre', | |
567 | + propiedad: 'NOM' | |
568 | + }, | |
569 | + { | |
570 | + nombre: 'CUIT', | |
571 | + propiedad: 'CUIT' | |
572 | + } | |
573 | + ], | |
574 | + tipo: 'POST', | |
575 | + json: { razonCuitCod: '' } | |
576 | + }; | |
577 | + focaModalService.modal(parametrosModal).then( | |
578 | + function (proveedor) { | |
579 | + $filter('filter')($scope.botonera, { | |
580 | + label: 'Proveedor', | |
581 | + })[0].checked = true; | |
582 | + | |
583 | + $scope.$broadcast('addCabecera', { | |
584 | + label: 'Proveedor:', | |
585 | + valor: proveedor.COD + ' - ' + proveedor.NOM | |
586 | + }); | |
587 | + $scope.hojaRuta.proveedor = proveedor; | |
588 | + }, function () { } | |
589 | + ); | |
590 | + }; | |
591 | + | |
592 | + $scope.seleccionarTransportista = function () { | |
164 | 593 | if (eligioPreConfirmado()) return; |
165 | 594 | var parametrosModal = { |
166 | 595 | titulo: 'Bรบsqueda de transportista', |
... | ... | @@ -181,7 +610,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
181 | 610 | ] |
182 | 611 | }; |
183 | 612 | focaModalService.modal(parametrosModal).then( |
184 | - function(proveedor) { | |
613 | + function (proveedor) { | |
185 | 614 | $scope.hojaRuta.transportista = proveedor; |
186 | 615 | $scope.$broadcast('addCabecera', { |
187 | 616 | label: 'Transportista:', |
... | ... | @@ -192,13 +621,13 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
192 | 621 | $filter('filter')($scope.botonera, { |
193 | 622 | label: 'Transportista', |
194 | 623 | })[0].checked = true; |
195 | - }, function() { | |
624 | + }, function () { | |
196 | 625 | |
197 | 626 | } |
198 | 627 | ); |
199 | 628 | }; |
200 | 629 | |
201 | - $scope.seleccionarChofer = function() { | |
630 | + $scope.seleccionarChofer = function () { | |
202 | 631 | var parametrosModal = { |
203 | 632 | titulo: 'Bรบsqueda de Chofer', |
204 | 633 | query: '/chofer', |
... | ... | @@ -226,41 +655,43 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
226 | 655 | ] |
227 | 656 | }; |
228 | 657 | focaModalService.modal(parametrosModal).then( |
229 | - function(chofer) { | |
658 | + function (chofer) { | |
230 | 659 | $scope.hojaRuta.chofer = chofer; |
231 | 660 | $scope.$broadcast('addCabecera', { |
232 | 661 | label: 'Chofer:', |
233 | - valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre | |
662 | + valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre | |
234 | 663 | }); |
235 | 664 | |
236 | 665 | $filter('filter')($scope.botonera, { |
237 | 666 | label: 'Chofer', |
238 | 667 | })[0].checked = true; |
239 | - }, function() { | |
668 | + $scope.mostrarDetalle($scope.hojaRuta); | |
669 | + | |
670 | + }, function () { | |
240 | 671 | // funcion ejecutada cuando se cancela el modal |
241 | 672 | } |
242 | 673 | ); |
243 | 674 | }; |
244 | 675 | |
245 | - $scope.seleccionarVehiculo = function() { | |
676 | + $scope.seleccionarVehiculo = function () { | |
246 | 677 | if (!eligioFecha() || eligioPreConfirmado()) return; |
247 | 678 | modalVehiculos(); |
248 | 679 | }; |
249 | 680 | |
250 | - $scope.seleccionarTarifario = function() { | |
681 | + $scope.seleccionarTarifario = function () { | |
251 | 682 | focaModalService |
252 | 683 | .prompt({ |
253 | 684 | titulo: 'Tarifa flete', |
254 | 685 | value: $scope.hojaRuta.tarifario |
255 | 686 | }) |
256 | - .then(function(costo) { | |
687 | + .then(function (costo) { | |
257 | 688 | if (isNaN(costo)) { |
258 | 689 | focaModalService |
259 | 690 | .alert('Ingrese un valor vรกlido') |
260 | - .then(function() { | |
691 | + .then(function () { | |
261 | 692 | $scope.seleccionarTarifario(); |
262 | 693 | }); |
263 | - | |
694 | + | |
264 | 695 | return; |
265 | 696 | } |
266 | 697 | |
... | ... | @@ -276,7 +707,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
276 | 707 | }); |
277 | 708 | }; |
278 | 709 | |
279 | - $scope.seleccionarRemitos = function() { | |
710 | + $scope.seleccionarRemitos = function () { | |
280 | 711 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; |
281 | 712 | var modalInstance = $uibModal.open( |
282 | 713 | { |
... | ... | @@ -284,11 +715,11 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
284 | 715 | templateUrl: 'foca-modal-remito.html', |
285 | 716 | controller: 'focaModalRemitoController', |
286 | 717 | size: 'lg', |
287 | - resolve: {usadoPor: function() {return 'hojaRuta';}} | |
718 | + resolve: { usadoPor: function () { return 'hojaRuta'; } } | |
288 | 719 | } |
289 | 720 | ); |
290 | 721 | modalInstance.result.then( |
291 | - function(remito) { | |
722 | + function (remito) { | |
292 | 723 | // TODO: borrar cuando no se use definitivamente |
293 | 724 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
294 | 725 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
... | ... | @@ -321,36 +752,36 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
321 | 752 | |
322 | 753 | // remito.litros = litros; |
323 | 754 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
324 | - $scope.cargarCisterna(remito.id).then(function() { | |
755 | + $scope.cargarCisterna(remito.id).then(function () { | |
325 | 756 | $scope.hojaRuta.remitosTabla.push(remito); |
326 | - }, function(error) { | |
757 | + $filter('filter')($scope.botonera, { | |
758 | + label: 'Remitos', | |
759 | + })[0].checked = true; | |
327 | 760 | |
761 | + }, function (error) { | |
328 | 762 | if (error && error !== 'backdrop click') { |
329 | - | |
330 | 763 | focaModalService |
331 | 764 | .alert(error || 'Ha ocurrido un error') |
332 | - .then(function() { | |
765 | + .then(function () { | |
333 | 766 | $scope.seleccionarRemitos(); |
334 | 767 | }); |
335 | 768 | |
336 | 769 | } else { |
337 | - | |
338 | 770 | $scope.seleccionarRemitos(); |
339 | - | |
340 | 771 | } |
341 | 772 | }); |
342 | - }, function() { | |
773 | + }, function () { | |
343 | 774 | // funcion ejecutada cuando se cancela el modal |
344 | 775 | } |
345 | 776 | ); |
346 | 777 | }; |
347 | 778 | |
348 | - $scope.seleccionarVehiculosPrecargados = function() { | |
779 | + $scope.seleccionarVehiculosPrecargados = function () { | |
349 | 780 | if (!eligioFecha()) return; |
350 | 781 | modalVehiculos(true); |
351 | 782 | }; |
352 | 783 | |
353 | - $scope.cargarCisterna = function(idRemito) { | |
784 | + $scope.cargarCisterna = function (idRemito) { | |
354 | 785 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; |
355 | 786 | var modalInstance = $uibModal.open( |
356 | 787 | { |
... | ... | @@ -359,41 +790,41 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
359 | 790 | controller: 'focaDetalleVehiculo', |
360 | 791 | size: 'lg', |
361 | 792 | resolve: { |
362 | - idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, | |
363 | - idRemito: function() {return idRemito;}, | |
364 | - fechaReparto: function() {return $scope.hojaRuta.fechaReparto;} | |
793 | + idVehiculo: function () { return $scope.hojaRuta.vehiculo.id; }, | |
794 | + idRemito: function () { return idRemito; }, | |
795 | + fechaReparto: function () { return $scope.hojaRuta.fechaReparto; } | |
365 | 796 | } |
366 | 797 | } |
367 | 798 | ); |
368 | 799 | return modalInstance.result; |
369 | 800 | }; |
370 | 801 | |
371 | - $scope.seleccionarFechaEntrega = function() { | |
802 | + $scope.seleccionarFechaEntrega = function () { | |
372 | 803 | var confirmacion = false; |
373 | 804 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; |
374 | 805 | var hasTarifario = $scope.hojaRuta.tarifario !== null; |
375 | 806 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; |
376 | - var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; | |
807 | + var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; | |
377 | 808 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; |
378 | - | |
809 | + | |
379 | 810 | if (hasVehiculoId || hasTarifario || hasTransportista || |
380 | - hasChofer || hasDatosExtra) { | |
811 | + hasChofer || hasDatosExtra) { | |
381 | 812 | confirmacion = true; |
382 | 813 | if (confirmacion) { |
383 | 814 | focaModalService |
384 | - .confirm('Si cambia la fecha se perderรกn los datos actuales') | |
385 | - .then(function(data) { | |
386 | - if(data) { | |
387 | - $scope.hojaRuta.vehiculo.id = undefined; | |
388 | - $scope.hojaRuta.tarifario = null; | |
389 | - $scope.hojaRuta.transportista = {}; | |
390 | - $scope.hojaRuta.chofer = {}; | |
391 | - $scope.hojaRuta.datosExtra = undefined; | |
392 | - elegirFecha(); | |
393 | - } | |
394 | - }, function() { | |
395 | - return ; | |
396 | - }); | |
815 | + .confirm('Si cambia la fecha se perderรกn los datos actuales') | |
816 | + .then(function (data) { | |
817 | + if (data) { | |
818 | + $scope.hojaRuta.vehiculo.id = undefined; | |
819 | + $scope.hojaRuta.tarifario = null; | |
820 | + $scope.hojaRuta.transportista = {}; | |
821 | + $scope.hojaRuta.chofer = {}; | |
822 | + $scope.hojaRuta.datosExtra = undefined; | |
823 | + elegirFecha(); | |
824 | + } | |
825 | + }, function () { | |
826 | + return; | |
827 | + }); | |
397 | 828 | } |
398 | 829 | } else { |
399 | 830 | elegirFecha(); |
... | ... | @@ -401,7 +832,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
401 | 832 | }; |
402 | 833 | |
403 | 834 | function setearFecha(fecha) { |
404 | - $timeout(function() { | |
835 | + $timeout(function () { | |
405 | 836 | $scope.$broadcast('addCabecera', { |
406 | 837 | label: 'Fecha de entrega: ', |
407 | 838 | valor: fecha.toLocaleDateString() |
... | ... | @@ -411,7 +842,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
411 | 842 | }); |
412 | 843 | } |
413 | 844 | |
414 | - $scope.seleccionarDatosExtra = function() { | |
845 | + $scope.seleccionarDatosExtra = function () { | |
415 | 846 | var datosHojaRuta = $scope.hojaRuta.datosExtra; |
416 | 847 | var modalInstance = $uibModal.open( |
417 | 848 | { |
... | ... | @@ -419,7 +850,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
419 | 850 | controller: 'focaModalDatosHojaRutaCtrl', |
420 | 851 | size: 'lg', |
421 | 852 | resolve: { |
422 | - parametrosDatos: function() { | |
853 | + parametrosDatos: function () { | |
423 | 854 | return { |
424 | 855 | datosHojaRuta: datosHojaRuta |
425 | 856 | }; |
... | ... | @@ -427,32 +858,32 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
427 | 858 | } |
428 | 859 | } |
429 | 860 | ); |
430 | - return modalInstance.result.then(function(datosExtra) { | |
861 | + return modalInstance.result.then(function (datosExtra) { | |
431 | 862 | |
432 | 863 | $filter('filter')($scope.botonera, { |
433 | 864 | label: 'Datos extra', |
434 | 865 | })[0].checked = true; |
435 | 866 | |
436 | 867 | $scope.hojaRuta.datosExtra = datosExtra; |
437 | - }, function() { | |
868 | + }, function () { | |
438 | 869 | //se ejecuta cuando se cancela el modal |
439 | 870 | }); |
440 | 871 | }; |
441 | 872 | |
442 | - $scope.desasociarRemito = function(key, idRemito) { | |
873 | + $scope.desasociarRemito = function (key, idRemito) { | |
443 | 874 | var idsRemito = [idRemito]; |
444 | 875 | focaModalService.confirm('ยฟEstรก seguro que desea desasociar este remito del' + |
445 | - ' vehรญculo?').then(function() { | |
876 | + ' vehรญculo?').then(function () { | |
446 | 877 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, |
447 | 878 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) |
448 | - .then(function() { | |
449 | - $scope.hojaRuta.remitosTabla.splice(key, 1); | |
450 | - focaModalService.alert('Remito desasociado con รฉxito'); | |
451 | - }); | |
879 | + .then(function () { | |
880 | + $scope.hojaRuta.remitosTabla.splice(key, 1); | |
881 | + focaModalService.alert('Remito desasociado con รฉxito'); | |
882 | + }); | |
452 | 883 | }); |
453 | 884 | }; |
454 | 885 | |
455 | - $scope.verProductosRemito = function(idRemito) { | |
886 | + $scope.verProductosRemito = function (idRemito) { | |
456 | 887 | var parametrosModal = { |
457 | 888 | titulo: 'Articulos remito', |
458 | 889 | query: '/articulos/remito/' + idRemito, |
... | ... | @@ -475,12 +906,36 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
475 | 906 | focaModalService.modal(parametrosModal).then(); |
476 | 907 | }; |
477 | 908 | |
909 | + $scope.mostrarDetalle = function (hojasRutas) { | |
910 | + var modalInstance =$uibModal.open( | |
911 | + { | |
912 | + ariaLabelledBy: '', | |
913 | + templateUrl: 'modal-detalle-carga.html', | |
914 | + controller: 'focaModalDetalleController', | |
915 | + resolve: { | |
916 | + hojasRutas: function () { return hojasRutas; } | |
917 | + }, | |
918 | + size: 'lg', | |
919 | + } | |
920 | + ); | |
921 | + return modalInstance.result.then(function (res) { | |
922 | + res.cisternas.forEach( function (cisterna) { | |
923 | + $scope.cisternaCargas.push(cisterna.cisternaCarga); | |
924 | + }); | |
925 | + $scope.cisternaMovimientos = res.movimientos; | |
926 | + $scope.articulosRecibidos = res.articulos; | |
927 | + $scope.articulos = res.articulos; | |
928 | + }, function () { | |
929 | + //se ejecuta cuando se cancela el modal | |
930 | + }); | |
931 | + }; | |
932 | + | |
478 | 933 | function elegirFecha() { |
479 | - var fechaEntrega = { | |
934 | + var fechaEntrega = { | |
480 | 935 | titulo: 'Fecha de entrega', |
481 | 936 | minDate: new Date() |
482 | 937 | }; |
483 | - focaModalService.modalFecha(fechaEntrega).then(function(fecha) { | |
938 | + focaModalService.modalFecha(fechaEntrega).then(function (fecha) { | |
484 | 939 | |
485 | 940 | $scope.hojaRuta.fechaReparto = fecha; |
486 | 941 | |
... | ... | @@ -488,6 +943,22 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
488 | 943 | label: 'Fecha de entrega: ', |
489 | 944 | valor: fecha.toLocaleDateString() |
490 | 945 | }); |
946 | + //habilitar los otros botones | |
947 | + var temp = []; | |
948 | + if ($scope.botonera.length > 1) { | |
949 | + limpiarBotonera($scope.botonera); | |
950 | + } else if ($scope.precargado) { | |
951 | + temp = focaCrearHojaRutaService.getBotoneraPrecargado(); | |
952 | + modalVehiculos(true); | |
953 | + } else if ($scope.cargaRemito && $scope.precargado === false) { | |
954 | + temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | |
955 | + } else { | |
956 | + temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | |
957 | + modalVehiculos(true); | |
958 | + } | |
959 | + temp.forEach(function (e) { | |
960 | + $scope.botonera.push(e); | |
961 | + }); | |
491 | 962 | |
492 | 963 | $filter('filter')($scope.botonera, { |
493 | 964 | label: 'Fecha Entrega', |
... | ... | @@ -498,7 +969,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
498 | 969 | function eligioPreConfirmado() { |
499 | 970 | if ($scope.eligioPreConfirmado) { |
500 | 971 | focaModalService.alert('No puede elegir si eligiรณ un vehiculo pre cargado'); |
501 | - return true; | |
972 | + return true; | |
502 | 973 | } |
503 | 974 | return false; |
504 | 975 | } |
... | ... | @@ -524,7 +995,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
524 | 995 | if (preCargados) { |
525 | 996 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + |
526 | 997 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); |
527 | - parametrosModal.titulo = 'Bรบsqueda de vehiculos pre confirmados'; | |
998 | + parametrosModal.titulo = 'Bรบsqueda de vehiculos precargados'; | |
528 | 999 | } else { |
529 | 1000 | parametrosModal.query = '/vehiculo'; |
530 | 1001 | parametrosModal.titulo = 'Bรบsqueda de vehรญculos'; |
... | ... | @@ -543,10 +1014,11 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
543 | 1014 | nombre: 'Semi' |
544 | 1015 | } |
545 | 1016 | ]; |
546 | - focaModalService.modal(parametrosModal).then(function(vehiculo) { | |
1017 | + focaModalService.modal(parametrosModal).then(function (vehiculo) { | |
547 | 1018 | if (!preCargados && vehiculoEnUso(vehiculo)) return; |
548 | 1019 | $scope.hojaRuta.vehiculo = vehiculo; |
549 | 1020 | $scope.hojaRuta.transportista = vehiculo.transportista; |
1021 | + // mostrarDetalle(vehiculo); | |
550 | 1022 | if (preCargados) { |
551 | 1023 | $scope.eligioPreConfirmado = true; |
552 | 1024 | $scope.hojaRuta.vehiculo = vehiculo; |
... | ... | @@ -557,10 +1029,13 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
557 | 1029 | }); |
558 | 1030 | focaCrearHojaRutaService |
559 | 1031 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
560 | - .then(function(res) { | |
561 | - | |
1032 | + .then(function (res) { | |
562 | 1033 | $filter('filter')($scope.botonera, { |
563 | - label: 'Vehiculos precargados', | |
1034 | + label: 'Transportista', | |
1035 | + })[0].checked = true; | |
1036 | + | |
1037 | + $filter('filter')($scope.botonera, { | |
1038 | + label: 'Vehiculo', | |
564 | 1039 | })[0].checked = true; |
565 | 1040 | |
566 | 1041 | $scope.hojaRuta.remitosTabla = res.data; |
... | ... | @@ -568,7 +1043,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
568 | 1043 | } else { |
569 | 1044 | focaCrearHojaRutaService |
570 | 1045 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
571 | - .then(function(res) { | |
1046 | + .then(function (res) { | |
572 | 1047 | |
573 | 1048 | $filter('filter')($scope.botonera, { |
574 | 1049 | label: 'Vehiculo', |
... | ... | @@ -598,11 +1073,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
598 | 1073 | for (var i = 0; i < vehiculo.cisternas.length; i++) { |
599 | 1074 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
600 | 1075 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
601 | - if (cisternaCarga.fechaReparto.substring(0, 10) === | |
1076 | + if (cisternaCarga.fechaReparto.substring(0, 10) === | |
602 | 1077 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && |
603 | 1078 | cisternaCarga.idUsuarioProceso && |
604 | - cisternaCarga.idUsuarioProceso !== idUsuario) | |
605 | - { | |
1079 | + cisternaCarga.idUsuarioProceso !== idUsuario) { | |
606 | 1080 | focaModalService.alert('El vehรญculo estรก siendo usado por otro' + |
607 | 1081 | ' usuario'); |
608 | 1082 | return true; |
... | ... | @@ -622,7 +1096,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
622 | 1096 | if (confirmacion) { |
623 | 1097 | focaModalService.confirm( |
624 | 1098 | 'ยฟEstรก seguro de que desea salir? Se perderรกn todos los datos cargados.' |
625 | - ).then(function(data) { | |
1099 | + ).then(function (data) { | |
626 | 1100 | if (data) { |
627 | 1101 | $location.path('/'); |
628 | 1102 | } |
... | ... | @@ -632,6 +1106,11 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
632 | 1106 | } |
633 | 1107 | } |
634 | 1108 | |
1109 | + function limpiarBotonera(botonera) { | |
1110 | + botonera.forEach(function (boton) { | |
1111 | + boton.checked = false; | |
1112 | + }); | |
1113 | + } | |
635 | 1114 | function setearHojaRuta(hojaRuta) { |
636 | 1115 | $scope.$broadcast('cleanCabecera'); |
637 | 1116 | |
... | ... | @@ -642,7 +1121,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
642 | 1121 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
643 | 1122 | }); |
644 | 1123 | |
645 | - $filter('filter')( $scope.botonera, { | |
1124 | + $filter('filter')($scope.botonera, { | |
646 | 1125 | label: 'Fecha Entrega' |
647 | 1126 | })[0].checked = true; |
648 | 1127 | } |
... | ... | @@ -653,7 +1132,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
653 | 1132 | hojaRuta.transportista.NOM |
654 | 1133 | }); |
655 | 1134 | |
656 | - $filter('filter')( $scope.botonera, { | |
1135 | + $filter('filter')($scope.botonera, { | |
657 | 1136 | label: 'Transportista' |
658 | 1137 | })[0].checked = true; |
659 | 1138 | } |
... | ... | @@ -664,7 +1143,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
664 | 1143 | ' - ' + hojaRuta.chofer.nombre |
665 | 1144 | }); |
666 | 1145 | |
667 | - $filter('filter')( $scope.botonera, { | |
1146 | + $filter('filter')($scope.botonera, { | |
668 | 1147 | label: 'Chofer' |
669 | 1148 | })[0].checked = true; |
670 | 1149 | } |
... | ... | @@ -682,7 +1161,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
682 | 1161 | valor: hojaRuta.vehiculo.capacidad |
683 | 1162 | }); |
684 | 1163 | |
685 | - $filter('filter')( $scope.botonera, { | |
1164 | + $filter('filter')($scope.botonera, { | |
686 | 1165 | label: 'Vehiculo' |
687 | 1166 | })[0].checked = true; |
688 | 1167 | } |
... | ... | @@ -692,7 +1171,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
692 | 1171 | valor: hojaRuta.tarifario |
693 | 1172 | }); |
694 | 1173 | |
695 | - $filter('filter')( $scope.botonera, { | |
1174 | + $filter('filter')($scope.botonera, { | |
696 | 1175 | label: 'Tarifario' |
697 | 1176 | })[0].checked = true; |
698 | 1177 | } |
... | ... | @@ -709,7 +1188,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
709 | 1188 | } |
710 | 1189 | } |
711 | 1190 | function addArrayCabecera(array) { |
712 | - for(var i = 0; i < array.length; i++) { | |
1191 | + for (var i = 0; i < array.length; i++) { | |
713 | 1192 | $scope.$broadcast('addCabecera', { |
714 | 1193 | label: array[i].label, |
715 | 1194 | valor: array[i].valor |
src/js/controllerDetalles.js
... | ... | @@ -0,0 +1,157 @@ |
1 | +angular.module('focaCrearHojaRuta') | |
2 | + .controller('focaModalDetalleController', [ | |
3 | + '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | |
4 | + 'focaCrearHojaRutaService', 'hojasRutas', '$uibModal', '$filter', | |
5 | + function ($scope, $timeout, $uibModalInstance, focaModalService, | |
6 | + focaCrearHojaRutaService, hojasRutas, $uibModal, $filter) { | |
7 | + | |
8 | + $scope.mostrar = false; | |
9 | + $scope.articulos = []; | |
10 | + $scope.cisternaMovimientos = []; | |
11 | + | |
12 | + init(); | |
13 | + function init() { | |
14 | + $scope.hojasRutas = hojasRutas; | |
15 | + | |
16 | + $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( | |
17 | + function (cisterna) { | |
18 | + return !cisterna.desactivado; | |
19 | + } | |
20 | + ); | |
21 | + focaCrearHojaRutaService.getArticulos() | |
22 | + .then(function (articulos) { | |
23 | + $scope.articulos = articulos.data; | |
24 | + }); | |
25 | + } | |
26 | + | |
27 | + $scope.validarCisternaDisponible = function (cisterna) { | |
28 | + if (parseInt(cisterna.disponible) > cisterna.capacidad) { | |
29 | + focaModalService.alert('No se puede ingresar una capacidad disponible ' + | |
30 | + 'superior a la ' + 'capacidad del vehiculo '); | |
31 | + cisterna.disponible = cisterna.capacidad; | |
32 | + return; | |
33 | + } | |
34 | + }; | |
35 | + | |
36 | + $scope.seleccionarProductos = function (cisterna) { | |
37 | + focaModalService.modal({ | |
38 | + titulo: 'Productos', | |
39 | + data: $scope.articulos, | |
40 | + size: 'md', | |
41 | + columnas: [ | |
42 | + { | |
43 | + propiedad: 'CodRub', | |
44 | + nombre: 'Codigo' | |
45 | + }, | |
46 | + { | |
47 | + propiedad: 'descripcion', | |
48 | + nombre: 'Nombre' | |
49 | + }, | |
50 | + ], | |
51 | + }).then(function (res) { | |
52 | + console.log('Res: ', res); | |
53 | + | |
54 | + var newArt = | |
55 | + { | |
56 | + id: 0, | |
57 | + idRemito: 0, | |
58 | + codigo: res.codigo, | |
59 | + sector: res.sector, | |
60 | + sectorCodigo: res.sector + '-' + res.codigo, | |
61 | + descripcion: res.descripcion, | |
62 | + item: 1, | |
63 | + nombre: res.descripcion, | |
64 | + precio: parseFloat(res.precio.toFixed(4)), | |
65 | + costoUnitario: res.costo, | |
66 | + editCantidad: false, | |
67 | + editPrecio: false, | |
68 | + rubro: res.CodRub, | |
69 | + ivaUnitario: res.IMPIVA, | |
70 | + impuestoInternoUnitario: res.ImpInt, | |
71 | + impuestoInterno1Unitario: res.ImpInt2, | |
72 | + impuestoInterno2Unitario: res.ImpInt3, | |
73 | + precioLista: res.precio, | |
74 | + combustible: 1, | |
75 | + facturado: 0, | |
76 | + idArticulo: res.id, | |
77 | + tasaIva: res.tasaIVA | |
78 | + }; | |
79 | + | |
80 | + newArt.exentoUnitario = newArt.ivaUnitario ? 0 : res.neto; | |
81 | + newArt.netoUnitario = newArt.ivaUnitario ? res.neto : 0; | |
82 | + | |
83 | + cisterna.articuloSeleccionado = newArt; | |
84 | + cisterna.nombreArticulo = res.descripcion; | |
85 | + }).catch(function (e) { | |
86 | + console.log(e); | |
87 | + }); | |
88 | + }; | |
89 | + | |
90 | + $scope.guardar = function () { | |
91 | + | |
92 | + var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas.filter(function (cisterna) { | |
93 | + return parseInt(cisterna.disponible) > 0; | |
94 | + }); | |
95 | + | |
96 | + var articulos = []; | |
97 | + | |
98 | + cisternasFilter.forEach(function (cisterna) { | |
99 | + | |
100 | + var fechaReparto = $scope.hojasRutas.fechaReparto; | |
101 | + | |
102 | + var filtroCisternaCarga = cisterna.cisternasCarga.filter(function(carga) { | |
103 | + return carga.fechaReparto === fechaReparto; | |
104 | + }); | |
105 | + | |
106 | + if (filtroCisternaCarga.length) { | |
107 | + cisterna.cisternaCarga = filtroCisternaCarga[0]; | |
108 | + } else { | |
109 | + cisterna.cisternaCarga = { | |
110 | + confirmado: null, | |
111 | + fechaReparto: fechaReparto, | |
112 | + idCisterna: cisterna.id, | |
113 | + }; | |
114 | + } | |
115 | + | |
116 | + if (!cisterna.articuloSeleccionado) { | |
117 | + focaModalService.alert('Seleccione Articulo'); | |
118 | + | |
119 | + return; | |
120 | + } | |
121 | + | |
122 | + //cargar | |
123 | + if (cisterna.cisternaCarga.cantidad) { | |
124 | + cisterna.cisternaCarga.cantidad += cisterna.disponible; | |
125 | + } else { | |
126 | + cisterna.cisternaCarga.cantidad = cisterna.disponible; | |
127 | + cisterna.cisternaCarga.idProducto = | |
128 | + cisterna.articuloSeleccionado.idArticulo; | |
129 | + } | |
130 | + | |
131 | + //Guardar | |
132 | + var now = new Date(); | |
133 | + var cisternaMovimiento = { | |
134 | + fecha: now.toISOString().slice(0, 19).replace('T', ' '), | |
135 | + cantidad: cisterna.disponible, | |
136 | + metodo: 'carga', | |
137 | + idCisternaCarga: cisterna.cisternaCarga.id, | |
138 | + }; | |
139 | + | |
140 | + cisterna.cisternaCarga.fechaReparto = fechaReparto; | |
141 | + cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | |
142 | + articulos.push(cisterna.articuloSeleccionado); | |
143 | + $scope.cisternaMovimientos.push(cisternaMovimiento); | |
144 | + }); | |
145 | + | |
146 | + $uibModalInstance.close({ | |
147 | + cisternas: cisternasFilter, | |
148 | + movimientos: $scope.cisternaMovimientos, | |
149 | + articulos: articulos | |
150 | + }); | |
151 | + }; | |
152 | + | |
153 | + $scope.cancel = function () { | |
154 | + $uibModalInstance.close(null); | |
155 | + }; | |
156 | + } | |
157 | + ]); |
src/js/service.js
1 | 1 | angular.module('focaCrearHojaRuta') |
2 | - .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', | |
3 | - function($http, API_ENDPOINT) { | |
2 | + .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', '$cookies', | |
3 | + function($http, API_ENDPOINT, $cookies) { | |
4 | 4 | var route = API_ENDPOINT.URL; |
5 | 5 | return { |
6 | + idUsuario: $cookies.get('vendedorCobrador'), | |
6 | 7 | crearHojaRuta: function(hojaRuta) { |
7 | 8 | return $http.post(route + '/hoja-ruta', hojaRuta); |
8 | 9 | }, |
10 | + crearRemito: function(remito) { | |
11 | + console.log('Crear remito-----: ', remito); | |
12 | + // TODO: Cambiar para usar el servicio /remito | |
13 | + return $http.post(route + '/remito', remito); | |
14 | + }, | |
9 | 15 | obtenerHojaRuta: function() { |
10 | 16 | return $http.get(route +'/hoja-ruta'); |
11 | 17 | }, |
... | ... | @@ -22,8 +28,8 @@ angular.module('focaCrearHojaRuta') |
22 | 28 | return $http.get(route+'/articulos/hoja-ruta/'+id); |
23 | 29 | }, |
24 | 30 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { |
25 | - return $http.post(route + '/articulos/hoja-ruta', | |
26 | - {articuloHojaRuta: articuloHojaRuta}); | |
31 | + return $http.post(route + '/articulos/remito', | |
32 | + {articuloRemito: articuloHojaRuta}); | |
27 | 33 | }, |
28 | 34 | getDomiciliosByIdHojaRuta: function(id) { |
29 | 35 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); |
... | ... | @@ -107,6 +113,133 @@ angular.module('focaCrearHojaRuta') |
107 | 113 | image: 'tarifario.png' |
108 | 114 | } |
109 | 115 | ]; |
116 | + }, | |
117 | + getBotones: function () { | |
118 | + return [ | |
119 | + { | |
120 | + label: 'Precargados', | |
121 | + image: 'vehiculos.png' | |
122 | + }, | |
123 | + { | |
124 | + label: 'Cargar Remitos', | |
125 | + image: 'remito.png' | |
126 | + }, | |
127 | + { | |
128 | + label: 'Remito Abierto', | |
129 | + image: 'remitoabierto.png' | |
130 | + } | |
131 | + ]; | |
132 | + }, | |
133 | + getRemitoAbierto: function () { | |
134 | + return [ | |
135 | + { | |
136 | + label: 'Fecha Entrega', | |
137 | + image: 'FechaEntrega.png' | |
138 | + }, | |
139 | + { | |
140 | + label: 'Transportista', | |
141 | + image: 'transportista.png' | |
142 | + }, | |
143 | + { | |
144 | + label: 'Vehiculo', | |
145 | + image: 'vehiculos.png' | |
146 | + }, | |
147 | + { | |
148 | + label: 'Chofer', | |
149 | + image: 'chofer.png' | |
150 | + }, | |
151 | + { | |
152 | + label: 'Proveedor', | |
153 | + image: 'proveedor.png' | |
154 | + }, | |
155 | + { | |
156 | + label: 'Tarifario', | |
157 | + image: 'tarifario.png' | |
158 | + }, | |
159 | + { | |
160 | + label: 'Cliente', | |
161 | + image: 'cliente.png' | |
162 | + } | |
163 | + ]; | |
164 | + }, | |
165 | + getArticulos : function () { | |
166 | + return $http.get(API_ENDPOINT.URL + '/articulos'); | |
167 | + }, | |
168 | + getVendedorById : function (idVendedor) { | |
169 | + return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idVendedor); | |
170 | + }, | |
171 | + getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | |
172 | + return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | |
173 | + idDomicilio + '/' + idCliente); | |
174 | + }, | |
175 | + getBotonFecha : function () { | |
176 | + return [ | |
177 | + { | |
178 | + label: 'Fecha Entrega', | |
179 | + image: 'FechaEntrega.png' | |
180 | + }, | |
181 | + ]; | |
182 | + }, | |
183 | + getBotoneraPrecargado: function () { | |
184 | + return [ | |
185 | + | |
186 | + { | |
187 | + label: 'Transportista', | |
188 | + image: 'transportista.png' | |
189 | + }, | |
190 | + { | |
191 | + label: 'Chofer', | |
192 | + image: 'chofer.png' | |
193 | + }, | |
194 | + { | |
195 | + label: 'Vehiculo', | |
196 | + image: 'vehiculos.png' | |
197 | + }, | |
198 | + { | |
199 | + label: 'Tarifario', | |
200 | + image: 'tarifario.png' | |
201 | + }, | |
202 | + { | |
203 | + label: 'Datos extra', | |
204 | + image: 'tarifario.png' | |
205 | + } | |
206 | + ]; | |
207 | + }, | |
208 | + getBotoneraCargarRemito: function () { | |
209 | + return [ | |
210 | + { | |
211 | + label: 'Transportista', | |
212 | + image: 'transportista.png' | |
213 | + }, | |
214 | + { | |
215 | + label: 'Chofer', | |
216 | + image: 'chofer.png' | |
217 | + }, | |
218 | + { | |
219 | + label: 'Vehiculo', | |
220 | + image: 'flete.png' | |
221 | + }, | |
222 | + { | |
223 | + label: 'Remitos', | |
224 | + image: 'remito.png' | |
225 | + }, | |
226 | + { | |
227 | + label: 'Tarifario', | |
228 | + image: 'tarifario.png' | |
229 | + }, | |
230 | + { | |
231 | + label: 'Datos extra', | |
232 | + image: 'tarifario.png' | |
233 | + } | |
234 | + ]; | |
235 | + }, | |
236 | + guardarCisternas: function(cisterna, idRemito) { | |
237 | + return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | |
238 | + this.idUsuario + '/' + idRemito, cisterna); | |
239 | + }, | |
240 | + crearArticulosParaRemito: function(articuloRemito) { | |
241 | + return $http.post(route + '/articulos/remito', | |
242 | + {articuloRemito: articuloRemito}); | |
110 | 243 | } |
111 | 244 | }; |
112 | 245 | }]); |
src/views/hoja-ruta.html
... | ... | @@ -9,86 +9,192 @@ |
9 | 9 | <div class="row mt-4"> |
10 | 10 | <div class="col-12 col-md-10 border border-light rounded"> |
11 | 11 | <div class="row px-5 py-2 botonera-secundaria"> |
12 | - <div class="col-12"> | |
13 | - <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> | |
12 | + <div class="col"> | |
13 | + <foca-botonera-facturador botones="botoneraPrincipal" max="botoneraPrincipal.length" class="row"></foca-botonera-facturador> | |
14 | 14 | </div> |
15 | 15 | </div> |
16 | - <!-- PC --> | |
17 | - <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | |
18 | - <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | |
19 | - <thead> | |
20 | - <tr class="d-flex"> | |
21 | - <th class="col-auto">#</th> | |
22 | - <th class="col-2">Remito</th> | |
23 | - <th class="col">Cliente</th> | |
24 | - <th class="col">Direcciรณn</th> | |
25 | - <th class="col-auto"></th> | |
26 | - <th class="col-auto"> | |
27 | - <button | |
28 | - class="btn btn-outline-light selectable" | |
29 | - ng-click="show = !show; masMenos()" | |
30 | - > | |
31 | - <i | |
32 | - class="fa fa-chevron-down" | |
33 | - ng-show="show" | |
34 | - aria-hidden="true" | |
35 | - > | |
36 | - </i> | |
37 | - <i | |
38 | - class="fa fa-chevron-up" | |
39 | - ng-hide="show" | |
40 | - aria-hidden="true"> | |
41 | - </i> | |
42 | - </button> | |
43 | - </th> | |
44 | - </tr> | |
45 | - </thead> | |
46 | - <tbody class="tabla-articulo-body"> | |
47 | - <tr | |
48 | - ng-repeat="(key, remito) in hojaRuta.remitosTabla" | |
49 | - class="d-flex" | |
50 | - ng-show="show || key == hojaRuta.remitosTabla.length - 1" | |
51 | - > | |
52 | - <td ng-bind="key + 1" class="col-auto"></td> | |
53 | - <td | |
54 | - class="col-2" | |
55 | - >{{remito.sucursal | rellenarDigitos: 4}}-{{remito.numeroRemito | rellenarDigitos: 8}}</td> | |
56 | - <th class="col" ng-bind="remito.nombreCliente"></th> | |
57 | - <th class="col" ng-bind="remito.domicilioStamp"></th> | |
58 | - <td class="text-center col-auto"> | |
59 | - <button | |
60 | - class="btn btn-outline-light" | |
61 | - ng-click="verProductosRemito(remito.id)" | |
62 | - title="Ver productos" | |
63 | - > | |
64 | - <i class="fa fa-eye"></i> | |
65 | - </button> | |
66 | - </td> | |
67 | - <td class="text-center col-auto"> | |
68 | - <button | |
69 | - class="btn btn-outline-light" | |
70 | - ng-click="desasociarRemito(key, remito.id)" | |
71 | - title="Eliminar" | |
16 | + </div> | |
17 | + </div> | |
18 | + <div class="row mt-2"> | |
19 | + <div class="col-12 col-md-10 border border-light rounded"> | |
20 | + <div class="row px-5 py-2 botonera-secundaria"> | |
21 | + <div class="col"> | |
22 | + <foca-botonera-facturador botones="botonera" max="botonera.length" class="row"></foca-botonera-facturador> | |
23 | + </div> | |
24 | + </div> | |
25 | + <div class="row"> | |
26 | + <div class="col"> | |
27 | + <!-- PC --> | |
28 | + <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | |
29 | + <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | |
30 | + <thead> | |
31 | + <tr class="d-flex"> | |
32 | + <th class="">#</th> | |
33 | + <th class="col">Cรณdigo</th> | |
34 | + <th class="col-4">Descripciรณn</th> | |
35 | + <th class="col text-right">Cantidad</th> | |
36 | + <th class="col text-right">Precio Unitario</th> | |
37 | + <th class="col text-right">SubTotal</th> | |
38 | + <th class="text-right"> | |
39 | + <button | |
40 | + class="btn btn-outline-light selectable" | |
41 | + ng-click="show = !show; masMenos()" | |
42 | + > | |
43 | + <i | |
44 | + class="fa fa-chevron-down" | |
45 | + ng-show="show" | |
46 | + aria-hidden="true" | |
47 | + > | |
48 | + </i> | |
49 | + <i | |
50 | + class="fa fa-chevron-up" | |
51 | + ng-hide="show" | |
52 | + aria-hidden="true"> | |
53 | + </i> | |
54 | + </button> | |
55 | + </th> | |
56 | + </tr> | |
57 | + </thead> | |
58 | + <tbody class="tabla-articulo-body"> | |
59 | + <tr | |
60 | + ng-repeat="(key, articulo) in articulos" | |
61 | + ng-show="show || key == (articulos.length - 1)" | |
62 | + class="d-flex" | |
72 | 63 | > |
73 | - <i class="fa fa-trash"></i> | |
74 | - </button> | |
75 | - </td> | |
76 | - </tr> | |
77 | - </tbody> | |
78 | - <tfoot> | |
79 | - <tr class="d-flex"> | |
80 | - <td class="col-auto px-1"> | |
81 | - <strong>Remitos:</strong> | |
82 | - <a ng-bind="hojaRuta.remitosTabla.length"></a> | |
83 | - </td> | |
84 | - <td class="col"></td> | |
85 | - <td class="col-auto px-1"> | |
86 | - <strong>Cantidad:</strong> | |
87 | - <a ng-bind="hojaRuta.litros"></a> | |
88 | - </td> | |
89 | - </tr> | |
90 | - </tfoot> | |
91 | - </table> | |
64 | + <td ng-bind="key + 1"></td> | |
65 | + <td | |
66 | + class="col" | |
67 | + ng-bind="articulo.sector + '-' + articulo.codigo" | |
68 | + ></td> | |
69 | + <td | |
70 | + class="col-4" | |
71 | + ng-bind="articulo.descripcion" | |
72 | + ></td> | |
73 | + <td class="col text-right"> | |
74 | + <input | |
75 | + ng-show="articulo.editCantidad" | |
76 | + ng-model="tmpCantidad" | |
77 | + class="form-control" | |
78 | + foca-tipo-input | |
79 | + min="1" | |
80 | + foca-focus="articulo.editCantidad" | |
81 | + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | |
82 | + esc-key="cancelarEditar(articulo)" | |
83 | + ng-focus="selectFocus($event); | |
84 | + tmpCantidad = articulo.cantidad; | |
85 | + tmpPrecio = 0" | |
86 | + teclado-virtual | |
87 | + > | |
88 | + <i | |
89 | + class="selectable" | |
90 | + ng-click="cambioEdit(articulo, 'cantidad')" | |
91 | + ng-hide="articulo.editCantidad" | |
92 | + ng-bind="articulo.cantidad"> | |
93 | + </i> | |
94 | + </td> | |
95 | + <td class="col text-right"> | |
96 | + <i | |
97 | + class="selectable" | |
98 | + ng-bind="0 | number: 4"> | |
99 | + </i> | |
100 | + </td> | |
101 | + <td | |
102 | + class="col text-right" | |
103 | + ng-bind="0 | number: 2"> | |
104 | + </td> | |
105 | + <td class="text-center"> | |
106 | + <button | |
107 | + class="btn btn-outline-light" | |
108 | + ng-click="quitarArticulo(articulo)" | |
109 | + > | |
110 | + <i class="fa fa-trash"></i> | |
111 | + </button> | |
112 | + </td> | |
113 | + </tr> | |
114 | + </tbody> | |
115 | + <tfoot> | |
116 | + <tr ng-show="!cargando" class="d-flex"> | |
117 | + <td | |
118 | + class="align-middle" | |
119 | + ng-bind="articulosFiltro.length + 1" | |
120 | + ></td> | |
121 | + <td class="col"> | |
122 | + <input | |
123 | + class="form-control" | |
124 | + ng-model="articuloACargar.sectorCodigo" | |
125 | + readonly | |
126 | + > | |
127 | + </td> | |
128 | + <td class="col-4 tabla-articulo-descripcion"> | |
129 | + <input | |
130 | + class="form-control" | |
131 | + ng-model="articuloACargar.descripcion" | |
132 | + readonly | |
133 | + > | |
134 | + </td> | |
135 | + <td class="col text-right"> | |
136 | + <input | |
137 | + class="form-control" | |
138 | + foca-tipo-input | |
139 | + min="1" | |
140 | + ng-model="articuloACargar.cantidad" | |
141 | + foca-focus="!cargando" | |
142 | + esc-key="resetFilter()" | |
143 | + ng-keypress="agregarATabla($event.keyCode)" | |
144 | + teclado-virtual | |
145 | + > | |
146 | + </td> | |
147 | + <td class="col text-right"> | |
148 | + <input | |
149 | + class="form-control" | |
150 | + ng-model="articuloACargar.precio" | |
151 | + ng-show="idLista != -1" | |
152 | + ng-keypress="agregarATabla($event.keyCode)" | |
153 | + > | |
154 | + <input | |
155 | + class="form-control" | |
156 | + foca-tipo-input | |
157 | + step="0.0001" | |
158 | + ng-model="articuloACargar.precio" | |
159 | + esc-key="resetFilter()" | |
160 | + ng-keypress="agregarATabla($event.keyCode)" | |
161 | + ng-show="idLista == -1" | |
162 | + teclado-virtual | |
163 | + > | |
164 | + </td> | |
165 | + <td class="col text-right"> | |
166 | + <input | |
167 | + class="form-control" | |
168 | + ng-value="getSubTotal() | number: 2" | |
169 | + readonly | |
170 | + > | |
171 | + </td> | |
172 | + </tr> | |
173 | + | |
174 | + <tr class="d-flex"> | |
175 | + <td colspan="4" class="no-border-top"> | |
176 | + <strong>Items:</strong> | |
177 | + <a ng-bind="articulos.length"></a> | |
178 | + </td> | |
179 | + <td class="text-right ml-auto table-celda-total no-border-top"> | |
180 | + <h3>Total:</h3> | |
181 | + </td> | |
182 | + <td class="table-celda-total text-right no-border-top" colspan="1"> | |
183 | + <h3>{{getTotal() | currency: hojaRuta.cotizacion.moneda.SIMBOLO}}</h3> | |
184 | + </td> | |
185 | + <td class="text-right no-border-top"> | |
186 | + <button | |
187 | + type="button" | |
188 | + class="btn btn-sm" | |
189 | + > | |
190 | + Totales | |
191 | + </button> | |
192 | + </td> | |
193 | + </tr> | |
194 | + </tfoot> | |
195 | + </table> | |
196 | + </div> | |
197 | + </div> | |
92 | 198 | </div> |
93 | 199 | </div> |
94 | 200 | </div> |
src/views/modal-detalle-carga.html
... | ... | @@ -0,0 +1,75 @@ |
1 | +<div class="modal-header py-1"> | |
2 | + <div class="row w-100"> | |
3 | + <div class="col-lg-6"> | |
4 | + <h5 class="modal-title my-1">Detalle de Carga</h5> | |
5 | + </div> | |
6 | + </div> | |
7 | + </div> | |
8 | + <div class="row"> | |
9 | + <div class="col ml-3 mt-2"> | |
10 | + <span class=" text-left"> | |
11 | + Transportista <b>{{hojasRutas.idTransportista}} {{hojasRutas.transportista.NOM}}</b> | |
12 | + Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> | |
13 | + </span> | |
14 | + | |
15 | + </div> | |
16 | + </div> | |
17 | + <div class="row"> | |
18 | + <div class="col ml-3"> | |
19 | + <span class=" text-left">Fecha <b>{{hojasRutas.fecha | date:'yyyy-MM-dd':'-0300'}}</b></span> | |
20 | + </div> | |
21 | + </div> | |
22 | + <div class="modal-body" id="modal-body"> | |
23 | + <table class="table table-hover table-sm table-striped"> | |
24 | + <thead> | |
25 | + <tr> | |
26 | + <th>Cisterna</th> | |
27 | + <th>Capacidad</th> | |
28 | + <th>Disponibles</th> | |
29 | + <th>Articulo Cargado</th> | |
30 | + </tr> | |
31 | + </thead> | |
32 | + <tbody> | |
33 | + <tr | |
34 | + ng-repeat="cisterna in hojasRutas.vehiculo.cisternas" | |
35 | + > | |
36 | + <td ng-bind="cisterna.id"></td> | |
37 | + <td ng-bind="cisterna.capacidad"></td> | |
38 | + <td class="w-50"> | |
39 | + <input | |
40 | + ng-model="cisterna.disponible" | |
41 | + ng-keyup="validarCisternaDisponible(cisterna)" | |
42 | + class="form-control" | |
43 | + solo-positivos | |
44 | + foca-tipo-input | |
45 | + /> | |
46 | + </td> | |
47 | + <td class="w-25"> | |
48 | + <div class="input-group "> | |
49 | + <input | |
50 | + ng-model="cisterna.nombreArticulo" | |
51 | + class="form-control" | |
52 | + ng-click="seleccionarProductos(cisterna)" | |
53 | + readonly | |
54 | + /> | |
55 | + <div class="input-group-append"> | |
56 | + <button | |
57 | + ladda="searchLoading" | |
58 | + class="btn btn-outline-secondary form-control" | |
59 | + type="button" | |
60 | + ng-click="seleccionarProductos(cisterna)" | |
61 | + > | |
62 | + <i class="fa fa-search" aria-hidden="true"></i> | |
63 | + </button> | |
64 | + </div> | |
65 | + </div> | |
66 | + </td> | |
67 | + </tr> | |
68 | + </tbody> | |
69 | + </table> | |
70 | + </div> | |
71 | + <div class="modal-footer py-1"> | |
72 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
73 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="guardar()">Guardar</button> | |
74 | + </div> | |
75 | +</div> | |
0 | 76 | \ No newline at end of file |