Commit fd0bfdeb8500ee1fa3db1b784f4449e728cfc2a0
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !11
Showing
2 changed files
 
Show diff stats
src/js/controller.js
| 1 | angular.module('focaModalDetalleCisternas') | 1 | angular.module('focaModalDetalleCisternas') | 
| 2 | .controller('focaDetalleVehiculo', | 2 | .controller('focaDetalleVehiculo', | 
| 3 | ['$scope', | 3 | ['$scope', | 
| 4 | '$uibModalInstance', | 4 | '$uibModalInstance', | 
| 5 | 'idVehiculo', | 5 | 'idVehiculo', | 
| 6 | 'idRemito', | 6 | 'idRemito', | 
| 7 | 'focaModalService', | 7 | 'focaModalService', | 
| 8 | '$filter', | 8 | '$filter', | 
| 9 | 'focaModalDetalleCisternasService', | 9 | 'focaModalDetalleCisternasService', | 
| 10 | 'fechaReparto', | 10 | 'fechaReparto', | 
| 11 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | 11 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | 
| 12 | focaModalDetalleCisternasService, fechaReparto | 12 | focaModalDetalleCisternasService, fechaReparto | 
| 13 | ) { | 13 | ) { | 
| 14 | //seteo variables | 14 | //seteo variables | 
| 15 | $scope.cargandoDatos = true; | 15 | $scope.cargandoDatos = true; | 
| 16 | $scope.idRemito = idRemito; | 16 | $scope.idRemito = idRemito; | 
| 17 | $scope.articulos = []; | 17 | $scope.articulos = []; | 
| 18 | $scope.vehiculo = {}; | 18 | $scope.vehiculo = {}; | 
| 19 | $scope.cisternas = []; | 19 | $scope.cisternas = []; | 
| 20 | $scope.cisternasCarga = []; | 20 | $scope.cisternasCarga = []; | 
| 21 | $scope.remito = {}; | 21 | $scope.remito = {}; | 
| 22 | $scope.aCargar = []; | 22 | $scope.aCargar = []; | 
| 23 | var cisternaMovimientos = []; | 23 | var cisternaMovimientos = []; | 
| 24 | var promesaRemito; | 24 | var promesaRemito; | 
| 25 | 25 | ||
| 26 | if(fechaReparto) { | 26 | if(fechaReparto) { | 
| 27 | focaModalDetalleCisternasService.fecha = fechaReparto; | 27 | focaModalDetalleCisternasService.fecha = fechaReparto; | 
| 28 | } | 28 | } | 
| 29 | var promesaVehiculo = focaModalDetalleCisternasService.obtenerVehiculoById(idVehiculo); | 29 | var promesaVehiculo = focaModalDetalleCisternasService.obtenerVehiculoById(idVehiculo); | 
| 30 | var promesaCisternas = focaModalDetalleCisternasService | 30 | var promesaCisternas = focaModalDetalleCisternasService | 
| 31 | .obtenerCisternasPorFecha(idVehiculo); | 31 | .obtenerCisternasPorFecha(idVehiculo); | 
| 32 | if(idRemito !== -1) { | 32 | if(idRemito !== -1) { | 
| 33 | promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito); | 33 | promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito); | 
| 34 | } | 34 | } | 
| 35 | Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { | 35 | Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { | 
| 36 | $scope.cargandoDatos = false; | 36 | $scope.cargandoDatos = false; | 
| 37 | $scope.vehiculo = res[0].data; | 37 | $scope.vehiculo = res[0].data; | 
| 38 | $scope.cisternas = res[1].data; | 38 | $scope.cisternas = res[1].data; | 
| 39 | if(!$scope.cisternas.length) { | 39 | if(!$scope.cisternas.length) { | 
| 40 | focaModalService.alert('El vehículo no tiene cisternas'); | 40 | focaModalService.alert('El vehículo no tiene cisternas'); | 
| 41 | $uibModalInstance.dismiss(); | 41 | $uibModalInstance.dismiss(); | 
| 42 | return; | 42 | return; | 
| 43 | } | 43 | } | 
| 44 | if(!res[2]) { | 44 | if(!res[2]) { | 
| 45 | $scope.$digest(); | 45 | $scope.$digest(); | 
| 46 | return; | 46 | return; | 
| 47 | } | 47 | } | 
| 48 | $scope.remito = res[2].data; | 48 | $scope.remito = res[2].data; | 
| 49 | if($scope.remito.idUsuarioProceso) { | 49 | if($scope.remito.idUsuarioProceso) { | 
| 50 | focaModalService.alert('Remito ya asignado'); | 50 | focaModalService.alert('Remito ya asignado'); | 
| 51 | $uibModalInstance.close(); | 51 | $uibModalInstance.close(); | 
| 52 | } | 52 | } | 
| 53 | $scope.articulos = $scope.remito.articulosRemito; | 53 | $scope.articulos = $scope.remito.articulosRemito; | 
| 54 | if(!$scope.articulos.length) { | 54 | if(!$scope.articulos.length) { | 
| 55 | focaModalService.alert('El remito no tiene articulos'); | 55 | focaModalService.alert('El remito no tiene articulos'); | 
| 56 | $uibModalInstance.dismiss(); | 56 | $uibModalInstance.dismiss(); | 
| 57 | return; | 57 | return; | 
| 58 | } | 58 | } | 
| 59 | |||
| 59 | $scope.seleccionarArticulo($scope.articulos[0]); | 60 | $scope.seleccionarArticulo($scope.articulos[0]); | 
| 60 | var tieneUsuario = $scope.cisternas.filter(function(cisterna) { | 61 | var tieneUsuario = $scope.cisternas.filter(function(cisterna) { | 
| 61 | if(cisterna.cisternaCarga && cisterna.cisternaCarga.idUsuarioProceso) { | 62 | if(cisterna.cisternaCarga && cisterna.cisternaCarga.idUsuarioProceso) { | 
| 62 | return cisterna.cisternaCarga.idUsuarioProceso !== | 63 | return cisterna.cisternaCarga.idUsuarioProceso !== | 
| 63 | focaModalDetalleCisternasService.idUsuario; | 64 | focaModalDetalleCisternasService.idUsuario; | 
| 64 | } | 65 | } | 
| 65 | }); | 66 | }); | 
| 66 | if(tieneUsuario.length) { | 67 | if(tieneUsuario.length) { | 
| 67 | focaModalService.alert('Otro usario esta usando este vehículo'); | 68 | focaModalService.alert('Otro usario esta usando este vehículo'); | 
| 68 | $uibModalInstance.close(); | 69 | $uibModalInstance.close(); | 
| 69 | } | 70 | } | 
| 70 | $scope.$digest(); | 71 | $scope.$digest(); | 
| 71 | }); | 72 | }); | 
| 72 | $scope.aceptar = function() { | 73 | $scope.aceptar = function() { | 
| 73 | $scope.cargando = true; | 74 | $scope.cargando = true; | 
| 74 | for(var i = 0; i < $scope.cisternasCarga.length; i++) { | 75 | for(var i = 0; i < $scope.cisternasCarga.length; i++) { | 
| 75 | $scope.cisternasCarga[i].idUsuarioProceso = | 76 | $scope.cisternasCarga[i].idUsuarioProceso = | 
| 76 | focaModalDetalleCisternasService.idUsuario; | 77 | focaModalDetalleCisternasService.idUsuario; | 
| 77 | delete $scope.cisternasCarga[i].articulo; | 78 | delete $scope.cisternasCarga[i].articulo; | 
| 78 | } | 79 | } | 
| 79 | var cisterna = { | 80 | var cisterna = { | 
| 80 | cisternaMovimientos: cisternaMovimientos, | 81 | cisternaMovimientos: cisternaMovimientos, | 
| 81 | cisternaCargas: $scope.cisternasCarga, | 82 | cisternaCargas: $scope.cisternasCarga, | 
| 82 | idVehiculo: $scope.vehiculo.id, | 83 | idVehiculo: $scope.vehiculo.id, | 
| 83 | fechaReparto: focaModalDetalleCisternasService.fecha | 84 | fechaReparto: focaModalDetalleCisternasService.fecha | 
| 84 | }; | 85 | }; | 
| 85 | if(!focaModalDetalleCisternasService.idUsuario) { | 86 | if(!focaModalDetalleCisternasService.idUsuario) { | 
| 86 | focaModalService.alert('No logeado como vendedor'); | 87 | focaModalService.alert('No logeado como vendedor'); | 
| 87 | $scope.cargando = false; | 88 | $scope.cargando = false; | 
| 88 | return; | 89 | return; | 
| 89 | } | 90 | } | 
| 90 | focaModalDetalleCisternasService.guardarCisternas(cisterna, $scope.remito.id) | 91 | focaModalDetalleCisternasService.guardarCisternas(cisterna, $scope.remito.id) | 
| 91 | .then(function() { | 92 | .then(function() { | 
| 92 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { | 93 | $scope.cargando = false; | 
| 93 | $scope.cargando = false; | 94 | $uibModalInstance.close(); | 
| 94 | $uibModalInstance.close(); | ||
| 95 | }); | ||
| 96 | }).catch(function(error) { | 95 | }).catch(function(error) { | 
| 97 | $scope.cargando = false; | 96 | $scope.cargando = false; | 
| 98 | $uibModalInstance.close(); | 97 | $uibModalInstance.close(); | 
| 99 | if (error.status === 403) { | 98 | if (error.status === 403) { | 
| 100 | focaModalService.alert('ERROR: ' + error.data); | 99 | focaModalService.alert('ERROR: ' + error.data); | 
| 101 | return; | 100 | return; | 
| 102 | } | 101 | } | 
| 103 | focaModalService.alert('Hubo un error al cargar las cisternas'); | 102 | focaModalService.alert('Hubo un error al cargar las cisternas'); | 
| 104 | }); | 103 | }); | 
| 105 | }; | 104 | }; | 
| 106 | $scope.cancelar = function() { | 105 | $scope.cancelar = function() { | 
| 107 | $uibModalInstance.dismiss(); | 106 | $uibModalInstance.dismiss(); | 
| 108 | }; | 107 | }; | 
| 109 | $scope.cargarACisternas = function() { | 108 | $scope.cargarACisternas = function() { | 
| 110 | for(var i = 0; i < $scope.cisternas.length; i++) { | 109 | for(var i = 0; i < $scope.cisternas.length; i++) { | 
| 111 | var cisterna = $scope.cisternas[i]; | 110 | var cisterna = $scope.cisternas[i]; | 
| 112 | var aCargar = parseFloat($scope.aCargar[i]); | 111 | var aCargar = parseFloat($scope.aCargar[i]); | 
| 113 | var fechaReparto = focaModalDetalleCisternasService.fecha; | 112 | var fechaReparto = focaModalDetalleCisternasService.fecha; | 
| 114 | //validaciones | 113 | //validaciones | 
| 115 | if(!aCargar) { | 114 | if(!aCargar) { | 
| 116 | continue; | 115 | continue; | 
| 117 | } | 116 | } | 
| 118 | //cargar | 117 | //cargar | 
| 119 | if(cisterna.cisternaCarga.cantidad) { | 118 | if(cisterna.cisternaCarga.cantidad) { | 
| 120 | cisterna.cisternaCarga.cantidad += aCargar; | 119 | cisterna.cisternaCarga.cantidad += aCargar; | 
| 121 | }else { | 120 | }else { | 
| 122 | cisterna.cisternaCarga.cantidad = aCargar; | 121 | cisterna.cisternaCarga.cantidad = aCargar; | 
| 123 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | 122 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | 
| 124 | } | 123 | } | 
| 125 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | 124 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | 
| 126 | 125 | ||
| 127 | cisterna.cisternaCarga.articulo = { | 126 | cisterna.cisternaCarga.articulo = { | 
| 128 | DetArt: $scope.articuloSeleccionado.descripcion | 127 | DetArt: $scope.articuloSeleccionado.descripcion | 
| 129 | }; | 128 | }; | 
| 130 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | 129 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | 
| 131 | .cargado = true; | 130 | .cargado = true; | 
| 132 | 131 | ||
| 133 | $scope.calcularPorcentaje(cisterna); | 132 | $scope.calcularPorcentaje(cisterna); | 
| 134 | //Guardar | 133 | //Guardar | 
| 135 | var now = new Date(); | 134 | var now = new Date(); | 
| 136 | var cisternaMovimiento = { | 135 | var cisternaMovimiento = { | 
| 137 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 136 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 
| 138 | cantidad: aCargar, | 137 | cantidad: aCargar, | 
| 139 | metodo: 'carga', | 138 | metodo: 'carga', | 
| 140 | idCisternaCarga: cisterna.cisternaCarga.id, | 139 | idCisternaCarga: cisterna.cisternaCarga.id, | 
| 141 | idRemito: $scope.remito.id | 140 | idRemito: $scope.remito.id | 
| 142 | }; | 141 | }; | 
| 143 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | 142 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | 
| 144 | cisterna.cisternaCarga.idCisterna = cisterna.id; | 143 | cisterna.cisternaCarga.idCisterna = cisterna.id; | 
| 145 | $scope.cisternasCarga.push(cisterna.cisternaCarga); | 144 | $scope.cisternasCarga.push(cisterna.cisternaCarga); | 
| 146 | cisternaMovimientos.push(cisternaMovimiento); | 145 | cisternaMovimientos.push(cisternaMovimiento); | 
| 147 | } | 146 | } | 
| 148 | var articuloSiguiente = $scope.articulos.filter( | 147 | var articuloSiguiente = $scope.articulos.filter( | 
| 149 | function(filter) { | 148 | function(filter) { | 
| 150 | return filter.cargado !== true; | 149 | return filter.cargado !== true; | 
| 151 | } | 150 | } | 
| 152 | ); | 151 | ); | 
| 153 | if(articuloSiguiente.length > 0) { | 152 | if(articuloSiguiente.length > 0) { | 
| 154 | $scope.seleccionarArticulo(articuloSiguiente[0]); | 153 | $scope.seleccionarArticulo(articuloSiguiente[0]); | 
| 155 | } | 154 | } | 
| 156 | }; | 155 | }; | 
| 157 | $scope.calcularPorcentaje = function(cisterna) { | 156 | $scope.calcularPorcentaje = function(cisterna) { | 
| 158 | if(!cisterna.cisternaCarga) { | 157 | if(!cisterna.cisternaCarga) { | 
| 159 | cisterna.cisternaCarga = { | 158 | cisterna.cisternaCarga = { | 
| 160 | cantidad: 0 | 159 | cantidad: 0 | 
| 161 | }; | 160 | }; | 
| 162 | } | 161 | } | 
| 163 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | 162 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | 
| 164 | cisterna.capacidad) + '%'; | 163 | cisterna.capacidad) + '%'; | 
| 165 | var elementHtml = document.getElementById(cisterna.id); | 164 | var elementHtml = document.getElementById(cisterna.id); | 
| 166 | if(elementHtml) { | 165 | if(elementHtml) { | 
| 167 | elementHtml.style.width = porcentaje; | 166 | elementHtml.style.width = porcentaje; | 
| 168 | } | 167 | } | 
| 169 | }; | 168 | }; | 
| 169 | |||
| 170 | $scope.seleccionarArticulo = function(articulo) { | 170 | $scope.seleccionarArticulo = function(articulo) { | 
| 171 | $scope.articuloSeleccionado = articulo; | 171 | $scope.articuloSeleccionado = articulo; | 
| 172 | $scope.cisternaDisponible(); | 172 | $scope.cisternaDisponible(); | 
| 173 | $scope.autoCompletar(); | 173 | $scope.autoCompletar(); | 
| 174 | $scope.actualizarArticulo(); | 174 | $scope.actualizarArticulo(); | 
| 175 | }; | 175 | }; | 
| 176 | |||
| 176 | $scope.actualizarArticulo = function() { | 177 | $scope.actualizarArticulo = function() { | 
| 177 | $scope.articuloSeleccionado.cantidadCargada = 0; | 178 | $scope.articuloSeleccionado.cantidadCargada = 0; | 
| 178 | for(var i = 0; i < $scope.aCargar.length; i++) { | 179 | for(var i = 0; i < $scope.aCargar.length; i++) { | 
| 179 | $scope.articuloSeleccionado.cantidadCargada += | 180 | $scope.articuloSeleccionado.cantidadCargada += | 
| 180 | parseFloat($scope.aCargar[i]) || 0; | 181 | parseFloat($scope.aCargar[i]) || 0; | 
| 181 | } | 182 | } | 
| 182 | }; | 183 | }; | 
| 184 | |||
| 183 | $scope.autoCompletar = function() { | 185 | $scope.autoCompletar = function() { | 
| 186 | var arrayMismoProducto = []; | ||
| 187 | var arrayVacioProducto = []; | ||
| 184 | for(var i = 0; i < $scope.cisternas.length; i++) { | 188 | for(var i = 0; i < $scope.cisternas.length; i++) { | 
| 185 | if($scope.cisternas[i].disabled) { | 189 | var cisterna = $scope.cisternas[i]; | 
| 186 | continue; | 190 | cisterna.posicion = i; | 
| 191 | console.info(i, cisterna.posicion); | ||
| 192 | if (!cisterna.disabled && cisterna.disponible > 0) { | ||
| 193 | if (cisterna.cisternaCarga) { | ||
| 194 | arrayMismoProducto.push(cisterna); | ||
| 195 | } else { | ||
| 196 | arrayVacioProducto.push(cisterna); | ||
| 197 | } | ||
| 187 | } | 198 | } | 
| 199 | } | ||
| 200 | |||
| 201 | arrayMismoProducto.sort(function(a,b) { | ||
| 202 | return a.disponible - b.disponible; | ||
| 203 | }); | ||
| 204 | |||
| 205 | var cisternas = arrayMismoProducto.concat(arrayVacioProducto); | ||
| 206 | |||
| 207 | for (var j = 0; j < cisternas.length; j++) { | ||
| 188 | var aCargar = $scope.articuloSeleccionado.cantidad - | 208 | var aCargar = $scope.articuloSeleccionado.cantidad - | 
| 189 | ($scope.articuloSeleccionado.cantidadCargada || 0); | 209 | ($scope.articuloSeleccionado.cantidadCargada || 0); | 
| 190 | if(aCargar > $scope.cisternas[i].disponible) { | 210 | |
| 191 | aCargar = $scope.cisternas[i].disponible; | 211 | if(aCargar > cisternas[j].disponible) { | 
| 212 | aCargar = cisternas[j].disponible; | ||
| 192 | } | 213 | } | 
| 193 | if(aCargar) { | 214 | |
| 194 | $scope.aCargar[i] = aCargar; | 215 | if(aCargar > 0) { | 
| 216 | $scope.aCargar[cisternas[j].posicion] = aCargar; | ||
| 195 | $scope.actualizarArticulo(); | 217 | $scope.actualizarArticulo(); | 
| 196 | } | 218 | } | 
| 197 | } | 219 | } | 
| 198 | }; | 220 | }; | 
| 199 | $scope.cisternaDisponible = function() { | 221 | $scope.cisternaDisponible = function() { | 
| 200 | for(var i = 0; i < $scope.cisternas.length; i++) { | 222 | for(var i = 0; i < $scope.cisternas.length; i++) { | 
| 201 | //Puede meter un porcentaje del total | 223 | //Puede meter un porcentaje del total | 
| 202 | // if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { | 224 | // if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { | 
| 203 | // $scope.cisternas[i].disabled = true; | 225 | // $scope.cisternas[i].disabled = true; | 
| 204 | // continue; | 226 | // continue; | 
| 205 | // } | 227 | // } | 
| 206 | if($scope.cisternas[i].cisternaCarga && | 228 | if($scope.cisternas[i].cisternaCarga && | 
| 207 | $scope.cisternas[i].cisternaCarga.idProducto && | 229 | $scope.cisternas[i].cisternaCarga.idProducto && | 
| 208 | $scope.articuloSeleccionado.idArticulo !== | 230 | $scope.articuloSeleccionado.idArticulo !== | 
| 209 | $scope.cisternas[i].cisternaCarga.idProducto) | 231 | $scope.cisternas[i].cisternaCarga.idProducto) | 
| 210 | { | 232 | { | 
| 211 | $scope.cisternas[i].disabled = true; | 233 | $scope.cisternas[i].disabled = true; | 
| 212 | continue; | 234 | continue; | 
| 213 | } | 235 | } | 
| 214 | $scope.cisternas[i].disabled = false; | 236 | $scope.cisternas[i].disabled = false; | 
| 215 | } | 237 | } | 
| 216 | }; | 238 | }; | 
| 217 | $scope.rellenarInput = function(input, cisterna) { | 239 | $scope.rellenarInput = function(input, cisterna) { | 
| 218 | if(!$scope.articuloSeleccionado) return; | 240 | if(!$scope.articuloSeleccionado) return; | 
| 219 | if($scope.articuloSeleccionado.cantidad - | 241 | if($scope.articuloSeleccionado.cantidad - | 
| 220 | $scope.articuloSeleccionado.cantidadCargada === 0) { | 242 | $scope.articuloSeleccionado.cantidadCargada === 0) { | 
| 221 | return input; | 243 | return input; | 
| 222 | } | 244 | } | 
| 223 | if(!input) input = 0; | 245 | if(!input) input = 0; | 
| 224 | input = parseFloat(input); | 246 | input = parseFloat(input); | 
| 225 | input += parseFloat($scope.articuloSeleccionado.cantidad - | 247 | input += parseFloat($scope.articuloSeleccionado.cantidad - | 
| 226 | $scope.articuloSeleccionado.cantidadCargada); | 248 | $scope.articuloSeleccionado.cantidadCargada); | 
| 227 | if(input <= 0) return; | 249 | if(input <= 0) return; | 
| 228 | if(input > cisterna.disponible) { | 250 | if(input > cisterna.disponible) { | 
| 229 | input = cisterna.disponible; | 251 | input = cisterna.disponible; | 
| 230 | } | 252 | } | 
| 231 | return input; | 253 | return input; | 
| 232 | }; | 254 | }; | 
| 233 | $scope.distribucionDisponible = function() { | 255 | $scope.distribucionDisponible = function() { | 
| 234 | if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad - | 256 | if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad - | 
| 235 | $scope.articuloSeleccionado.cantidadCargada !== 0 || | 257 | $scope.articuloSeleccionado.cantidadCargada !== 0 || | 
| 236 | !$scope.tieneArticulosPendientes()) { | 258 | !$scope.tieneArticulosPendientes()) { | 
| 237 | return false; | 259 | return false; | 
| 238 | } | 260 | } | 
| 239 | for(var i = 0; i < $scope.cisternas.length; i++) { | 261 | for(var i = 0; i < $scope.cisternas.length; i++) { | 
| 240 | if($scope.aCargar[i] > $scope.cisternas[i].disponible) { | 262 | if($scope.aCargar[i] > $scope.cisternas[i].disponible) { | 
| 241 | return false; | 263 | return false; | 
| 242 | } | 264 | } | 
| 243 | } | 265 | } | 
| 244 | return true; | 266 | return true; | 
| 245 | }; | 267 | }; | 
| 246 | $scope.tieneArticulosPendientes = function() { | 268 | $scope.tieneArticulosPendientes = function() { | 
| 247 | var algunValorNegativo = $scope.aCargar.filter(function(p) { | 269 | var algunValorNegativo = $scope.aCargar.filter(function(p) { | 
| 248 | return p < 0; | 270 | return p < 0; | 
| 249 | }); | 271 | }); | 
| 250 | if(algunValorNegativo.length) { | 272 | if(algunValorNegativo.length) { | 
| 251 | return false; | 273 | return false; | 
| 252 | } | 274 | } | 
| 253 | var articulosDescargados = $scope.articulos.filter(function(filter) { | 275 | var articulosDescargados = $scope.articulos.filter(function(filter) { | 
| 254 | return filter.cargado === true; | 276 | return filter.cargado === true; | 
| 255 | }); | 277 | }); | 
| 256 | if(articulosDescargados.length === $scope.articulos.length) { | 278 | if(articulosDescargados.length === $scope.articulos.length) { | 
| 257 | $scope.aCargar = []; | 279 | $scope.aCargar = []; | 
| 258 | return false; | 280 | return false; | 
| 259 | } | 281 | } | 
| 260 | return true; | 282 | return true; | 
| 261 | }; | 283 | }; | 
src/views/foca-detalle-vehiculo.html
| 1 | <div class="modal-header"> | 1 | <div class="modal-header"> | 
| 2 | <h4>Detalle de carga</h4> | 2 | <h4>Detalle de carga</h4> | 
| 3 | Transportista | 3 | Transportista | 
| 4 | <strong ng-bind="vehiculo.transportista.COD"></strong> | 4 | <strong ng-bind="vehiculo.transportista.COD"></strong> | 
| 5 | <strong ng-bind="vehiculo.transportista.NOM"></strong> | 5 | <strong ng-bind="vehiculo.transportista.NOM"></strong> | 
| 6 | Unidad <strong ng-bind="vehiculo.codigo"></strong> | 6 | Unidad <strong ng-bind="vehiculo.codigo"></strong> | 
| 7 | Tractor <strong ng-bind="vehiculo.tractor"></strong> | 7 | Tractor <strong ng-bind="vehiculo.tractor"></strong> | 
| 8 | <br> | 8 | <br> | 
| 9 | <div ng-show="idRemito !== -1"> | 9 | <div ng-show="idRemito !== -1"> | 
| 10 | <span>Remito Nº</span> | 10 | <span>Remito Nº</span> | 
| 11 | <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong> | 11 | <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong> | 
| 12 | <span>, Fecha</span> | 12 | <span>, Fecha</span> | 
| 13 | <strong ng-bind="remito.fechaRemito | date: 'dd/MM/yyyy HH:mm'"></strong> | 13 | <strong ng-bind="remito.fechaRemito | date: 'dd/MM/yyyy HH:mm'"></strong> | 
| 14 | <span>, Cliente</span> | 14 | <span>, Cliente</span> | 
| 15 | <strong ng-bind="remito.nombreCliente"></strong> | 15 | <strong ng-bind="remito.nombreCliente"></strong> | 
| 16 | <span>, Domicilio entrega</span> | 16 | <span>, Domicilio entrega</span> | 
| 17 | <strong ng-bind="remito.domicilioStamp"></strong> | 17 | <strong ng-bind="remito.domicilioStamp"></strong> | 
| 18 | </div> | 18 | </div> | 
| 19 | </div> | 19 | </div> | 
| 20 | <div class="modal-body"> | 20 | <div class="modal-body"> | 
| 21 | <div> | 21 | <div> | 
| 22 | <table class="table table-sm" ng-show="idRemito !== -1"> | 22 | <table class="table table-sm" ng-show="idRemito !== -1"> | 
| 23 | <thead> | 23 | <thead> | 
| 24 | <tr> | 24 | <tr> | 
| 25 | <th></th> | 25 | <th></th> | 
| 26 | <th>Articulo</th> | 26 | <th>Articulo</th> | 
| 27 | <th>Cantidad</th> | 27 | <th>Cantidad</th> | 
| 28 | <th>Cargado</th> | 28 | <th>Cargado</th> | 
| 29 | <th>Resta asignar</th> | 29 | <th>Resta asignar</th> | 
| 30 | </tr> | 30 | </tr> | 
| 31 | </thead> | 31 | </thead> | 
| 32 | <tbody> | 32 | <tbody> | 
| 33 | <tr ng-repeat="(key, articulo) in articulos"> | 33 | <tr ng-repeat="(key, articulo) in articulos"> | 
| 34 | <td><input | 34 | <td><input | 
| 35 | type="radio" | 35 | type="radio" | 
| 36 | name="articuloRadio" | 36 | name="articuloRadio" | 
| 37 | id="{{'articulo' + articulo.id}}" | 37 | id="{{'articulo' + articulo.id}}" | 
| 38 | ng-checked="articuloSeleccionado.id === articulo.id" | 38 | ng-checked="articuloSeleccionado.id === articulo.id" | 
| 39 | ng-disabled="articulo.cargado" | 39 | ng-disabled="articulo.cargado" | 
| 40 | ng-click="seleccionarArticulo(articulo)" | 40 | ng-click="seleccionarArticulo(articulo)" | 
| 41 | ></td> | 41 | ></td> | 
| 42 | <td ng-bind="articulo.descripcion"></td> | 42 | <td ng-bind="articulo.descripcion"></td> | 
| 43 | <td ng-bind="articulo.cantidad"></td> | 43 | <td ng-bind="articulo.cantidad"></td> | 
| 44 | <td ng-bind="articulo.cantidadCargada || 0"></td> | 44 | <td ng-bind="articulo.cantidadCargada || 0"></td> | 
| 45 | <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td> | 45 | <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td> | 
| 46 | </tr> | 46 | </tr> | 
| 47 | </tbody> | 47 | </tbody> | 
| 48 | </table> | 48 | </table> | 
| 49 | <table class="table table-sm" ladda="cargandoDatos" data-spinner-color="#FF0000"> | 49 | <table class="table table-sm" ladda="cargandoDatos" data-spinner-color="#FF0000"> | 
| 50 | <thead> | 50 | <thead> | 
| 51 | <tr> | 51 | <tr> | 
| 52 | <th width="10%">Cisterna</th> | 52 | <th width="10%">Cisterna</th> | 
| 53 | <th>Capacidad</th> | 53 | <th>Capacidad</th> | 
| 54 | <th>Articulo cargado</th> | 54 | <th>Articulo cargado</th> | 
| 55 | <th width="20%">A asignar</th> | 55 | <th width="20%">Por asignar</th> | 
| 56 | <th>Cargado / Capacidad Disponible</th> | 56 | <th>Cargado / Capacidad Disponible</th> | 
| 57 | </tr> | 57 | </tr> | 
| 58 | </thead> | 58 | </thead> | 
| 59 | <tbody> | 59 | <tbody> | 
| 60 | <tr ng-repeat="(key, cisterna) in cisternas"> | 60 | <tr ng-repeat="(key, cisterna) in cisternas"> | 
| 61 | <td class="py-3" ng-bind="cisterna.codigo"></td> | 61 | <td class="py-3" ng-bind="cisterna.codigo"></td> | 
| 62 | <td class="py-3" ng-bind="cisterna.capacidad"></td> | 62 | <td class="py-3" ng-bind="cisterna.capacidad"></td> | 
| 63 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> | 63 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> | 
| 64 | <td ng-if="idRemito != -1"> | 64 | <td ng-if="idRemito != -1"> | 
| 65 | <input | 65 | <input | 
| 66 | class="form-control" | 66 | class="form-control" | 
| 67 | foca-tipo-input | 67 | foca-tipo-input | 
| 68 | foca-teclado | 68 | foca-teclado | 
| 69 | placeholder="A cargar..." | 69 | placeholder="A cargar..." | 
| 70 | ng-model="aCargar[key]" | 70 | ng-model="aCargar[key]" | 
| 71 | ng-disabled="cisterna.disabled || !tieneArticulosPendientes()" | 71 | ng-disabled="cisterna.disabled || !tieneArticulosPendientes()" | 
| 72 | ng-focus="aCargar[key] = rellenarInput(aCargar[key], cisterna); actualizarArticulo()" | 72 | ng-focus="aCargar[key] = rellenarInput(aCargar[key], cisterna); actualizarArticulo()" | 
| 73 | ng-change="actualizarArticulo()" | 73 | ng-change="actualizarArticulo()" | 
| 74 | > | 74 | > | 
| 75 | </td> | 75 | </td> | 
| 76 | <td ng-if="idRemito == -1"> | 76 | <td ng-if="idRemito == -1"> | 
| 77 | <input | 77 | <input | 
| 78 | class="form-control" | 78 | class="form-control" | 
| 79 | placeholder="A cargar..." | 79 | placeholder="A cargar..." | 
| 80 | readonly> | 80 | readonly> | 
| 81 | </td> | 81 | </td> | 
| 82 | <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> | 82 | <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> | 
| 83 | <strong | 83 | <strong | 
| 84 | class="mt-2 col-4 text-center position-absolute" | 84 | class="mt-2 col-4 text-center position-absolute" | 
| 85 | ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + | 85 | ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + | 
| 86 | (cisterna.capacidad - cisterna.cisternaCarga.cantidad)"> | 86 | (cisterna.capacidad - cisterna.cisternaCarga.cantidad)"> | 
| 87 | </strong> | 87 | </strong> | 
| 88 | <div | 88 | <div | 
| 89 | id="{{cisterna.id}}" | 89 | id="{{cisterna.id}}" | 
| 90 | class="progress-bar" | 90 | class="progress-bar" | 
| 91 | role="progressbar" | 91 | role="progressbar" | 
| 92 | aria-valuemin="0" | 92 | aria-valuemin="0" | 
| 93 | aria-valuemax="{{cisterna.capacidad}}" | 93 | aria-valuemax="{{cisterna.capacidad}}" | 
| 94 | ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> | 94 | ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> | 
| 95 | </div> | 95 | </div> | 
| 96 | </div> | 96 | </div> | 
| 97 | </td> | 97 | </td> | 
| 98 | </tr> | 98 | </tr> | 
| 99 | </tbody> | 99 | </tbody> | 
| 100 | </table> | 100 | </table> | 
| 101 | <div class="col-12"> | 101 | <div class="col-12"> | 
| 102 | <button | 102 | <button | 
| 103 | class="form-control btn btn-success" | 103 | class="form-control btn btn-success" | 
| 104 | ladda="cargando" | 104 | ladda="cargando" | 
| 105 | data-spinner-color="#FF0000" | 105 | data-spinner-color="#FF0000" | 
| 106 | type="button" | 106 | type="button" | 
| 107 | ng-disabled="!distribucionDisponible()" | 107 | ng-disabled="!distribucionDisponible()" | 
| 108 | ng-class="{'btn-light': !distribucionDisponible()}" | 108 | ng-class="{'btn-light': !distribucionDisponible()}" | 
| 109 | ng-click="cargarACisternas(vehiculo)" | 109 | ng-click="cargarACisternas(vehiculo)" | 
| 110 | foca-focus="distribucionDisponible()"> | 110 | foca-focus="distribucionDisponible()"> | 
| 111 | Aplicar distribución de cargas | 111 | Aplicar distribución de cargas | 
| 112 | </button> | 112 | </button> | 
| 113 | </div> | 113 | </div> | 
| 114 | </div> | 114 | </div> | 
| 115 | </div> | 115 | </div> | 
| 116 | <div class="modal-footer py-1"> | 116 | <div class="modal-footer py-1"> | 
| 117 | <button | 117 | <button | 
| 118 | class="btn btn-sm btn-secondary" | 118 | class="btn btn-sm btn-secondary" | 
| 119 | ladda="cargando" | 119 | ladda="cargando" | 
| 120 | type="button" | 120 | type="button" | 
| 121 | ng-click="cancelar()">Cancelar</button> | 121 | ng-click="cancelar()">Cancelar</button> | 
| 122 | <button | 122 | <button | 
| 123 | class="btn btn-sm btn-primary" | 123 | class="btn btn-sm btn-primary" | 
| 124 | ladda="cargando" | 124 | ladda="cargando" | 
| 125 | type="button" | 125 | type="button" | 
| 126 | ng-click="aceptar()" | 126 | ng-click="aceptar()" | 
| 127 | ng-disabled="tieneArticulosPendientes() || idRemito === -1" | 127 | ng-disabled="tieneArticulosPendientes() || idRemito === -1" | 
| 128 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> | 128 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> | 
| 129 | </div> | 129 | </div> | 
| 130 | 130 |