Commit 65c9405b5c5ae6356c716120a5e7aa4a16677d8d

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

See merge request !29
src/js/controller.js
... ... @@ -8,10 +8,12 @@ angular.module('focaModalDetalleCisternas')
8 8 '$filter',
9 9 'focaModalDetalleCisternasService',
10 10 'fechaReparto',
  11 + 'orden',
11 12 function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter,
12   - focaModalDetalleCisternasService, fechaReparto
  13 + focaModalDetalleCisternasService, fechaReparto, orden
13 14 ) {
14 15 //seteo variables
  16 + $scope.orden = orden;
15 17 $scope.cargandoDatos = true;
16 18 $scope.idRemito = idRemito;
17 19 $scope.articulos = [];
... ... @@ -28,9 +30,9 @@ angular.module('focaModalDetalleCisternas')
28 30 }
29 31 var promesaVehiculo = focaModalDetalleCisternasService.obtenerVehiculoById(idVehiculo);
30 32 var promesaCisternas = focaModalDetalleCisternasService
31   - .obtenerCisternasPorFecha(idVehiculo);
  33 + .obtenerCisternasPorFecha(idVehiculo, $scope.orden);
32 34  
33   - if(idRemito !== -1) {
  35 + if (idRemito !== -1) {
34 36 promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito);
35 37 }
36 38  
... ... @@ -51,7 +53,7 @@ angular.module('focaModalDetalleCisternas')
51 53 $scope.vehiculo = res[0].data;
52 54 $scope.cisternas = res[1].data;
53 55  
54   - if(!$scope.cisternas.length) {
  56 + if (!$scope.cisternas.length) {
55 57 focaModalService.alert('El vehículo no tiene cisternas')
56 58 .then(function () {
57 59 $uibModalInstance.dismiss();
... ... @@ -68,14 +70,22 @@ angular.module('focaModalDetalleCisternas')
68 70  
69 71 $scope.remito = res[2].data;
70 72  
71   - if($scope.remito.idUsuarioProceso) {
  73 + if ($scope.remito.idUsuarioProceso) {
72 74  
73   - $uibModalInstance.dismiss(focaModalService.alert('Remito ya asignado'));
  75 + focaModalService.alert('Remito ya asignado').then(function() {
  76 +
  77 + $uibModalInstance.dismiss();
  78 + });
74 79 }
75 80  
76 81 $scope.articulos = $scope.remito.articulosRemito;
77   - if(!$scope.articulos.length) {
78   - $uibModalInstance.dismiss(focaModalService.alert('El remito no tiene articulos'));
  82 +
  83 + if (!$scope.articulos.length) {
  84 +
  85 + focaModalService.alert('El remito no tiene articulos').then(function() {
  86 +
  87 + $uibModalInstance.dismiss();
  88 + });
79 89 return;
80 90 }
81 91  
... ... @@ -142,7 +152,7 @@ angular.module('focaModalDetalleCisternas')
142 152  
143 153 $scope.cargarACisternas = function() {
144 154  
145   - for(var i = 0; i < $scope.cisternas.length; i++) {
  155 + for (var i = 0; i < $scope.cisternas.length; i++) {
146 156 var cisterna = $scope.cisternas[i];
147 157 var aCargar = parseFloat($scope.aCargar[i]);
148 158 var fechaReparto = focaModalDetalleCisternasService.fecha;
... ... @@ -235,9 +245,9 @@ angular.module(&#39;focaModalDetalleCisternas&#39;)
235 245 for (var i = 0; i < $scope.cisternas.length; i++) {
236 246 var cisterna = $scope.cisternas[i];
237 247 cisterna.posicion = i;
238   - console.info(i, cisterna.posicion);
  248 +
239 249 if (!cisterna.disabled && cisterna.disponible > 0) {
240   - if (cisterna.cisternaCarga) {
  250 + if (cisterna.cisternaCarga.idProducto) {
241 251 arrayMismoProducto.push(cisterna);
242 252 } else {
243 253 arrayVacioProducto.push(cisterna);
... ... @@ -306,12 +316,15 @@ angular.module(&#39;focaModalDetalleCisternas&#39;)
306 316 return false;
307 317 }
308 318 for(var i = 0; i < $scope.cisternas.length; i++) {
309   - if($scope.aCargar[i] > $scope.cisternas[i].disponible) {
  319 + if ($scope.aCargar[i] > $scope.cisternas[i].disponible &&
  320 + !$scope.cisternas[i].disabled)
  321 + {
310 322 return false;
311 323 }
312 324 }
313 325 return true;
314 326 };
  327 +
315 328 $scope.tieneArticulosPendientes = function() {
316 329 var algunValorNegativo = $scope.aCargar.filter(function(p) {
317 330 return p < 0;
... ... @@ -360,11 +373,29 @@ angular.module(&#39;focaModalDetalleCisternas&#39;)
360 373 }
361 374 ]
362 375 };
  376 +
363 377 focaModalService.modal(parametrosModal).then(function(transportista) {
364 378 $scope.selectVehiculo(transportista.COD, transportista.NOM);
365 379 });
366 380 };
  381 +
  382 + function aplicarOrden(cisternas, orden) {
  383 +
  384 + cisternas.forEach(function (cisterna) {
  385 +
  386 + if (!cisterna.cisternaCarga) {
  387 + cisterna.cisternaCarga = { orden: orden };
  388 + cisterna.disponible = cisterna.capacidad;
  389 + }
  390 +
  391 + });
  392 +
  393 + }
  394 +
367 395 function validarCargas(cis, remito) {
  396 +
  397 + aplicarOrden(cis, $scope.orden);
  398 +
368 399 var result = true;
369 400 var cisternas = angular.copy(cis);
370 401 var articulos = angular.copy(remito.articulosRemito);
... ... @@ -17,9 +17,13 @@ angular.module(&#39;focaModalDetalleCisternas&#39;)
17 17 return $http.post(url + '/cisterna/guardar/cargar/' +
18 18 this.idUsuario + '/' + idRemito,cisterna);
19 19 },
20   - obtenerCisternasPorFecha: function(idVehiculo) {
  20 + obtenerCisternasPorFecha: function(idVehiculo, orden) {
21 21 return $http.post(url + '/cisterna/listar/fecha',
22   - {idVehiculo: idVehiculo, fechaReparto: this.fecha});
  22 + {
  23 + idVehiculo: idVehiculo,
  24 + fechaReparto: this.fecha,
  25 + orden: orden
  26 + });
23 27 }
24 28 };
25 29 }