Commit de330bd4476fe6e1bd06130abafec44c0b080a3e
1 parent
4b63e4145a
Exists in
master
falta guardar
Showing
2 changed files
with
107 additions
and
313 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -27,12 +27,15 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 27 | 27 | |
| 28 | 28 | $scope.hojaRuta = { |
| 29 | 29 | fecha: new Date(), |
| 30 | - vendedor: {}, | |
| 31 | - cliente: {}, | |
| 30 | + litros: 0, | |
| 31 | + chofer: {}, | |
| 32 | + vehiculo: { | |
| 33 | + capacidad: 0 | |
| 34 | + }, | |
| 32 | 35 | transportista: {}, |
| 33 | - domicilio: {dom: ''}, | |
| 34 | - moneda: {}, | |
| 35 | - cotizacion: {} | |
| 36 | + tarifario: { | |
| 37 | + costo: null | |
| 38 | + } | |
| 36 | 39 | }; |
| 37 | 40 | |
| 38 | 41 | $scope.cabecera = []; |
| ... | ... | @@ -43,7 +46,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 43 | 46 | $scope.comprobante = '00000000'; |
| 44 | 47 | $scope.remitosTabla = []; |
| 45 | 48 | $scope.idLista = undefined; |
| 46 | - $ | |
| 47 | 49 | //La pantalla solo se usa para cargar pedidos |
| 48 | 50 | //var hojaRutaTemp = crearHojaRutaService.getHojaRuta(); |
| 49 | 51 | |
| ... | ... | @@ -190,70 +192,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 190 | 192 | ); |
| 191 | 193 | }; |
| 192 | 194 | |
| 193 | - $scope.seleccionarArticulo = function() { | |
| 194 | - if ($scope.idLista === undefined) { | |
| 195 | - focaModalService.alert( | |
| 196 | - 'Primero seleccione una lista de precio y condicion'); | |
| 197 | - return; | |
| 198 | - } | |
| 199 | - var modalInstance = $uibModal.open( | |
| 200 | - { | |
| 201 | - ariaLabelledBy: 'Busqueda de Productos', | |
| 202 | - templateUrl: 'modal-busqueda-productos.html', | |
| 203 | - controller: 'modalBusquedaProductosCtrl', | |
| 204 | - resolve: { | |
| 205 | - parametroProducto: { | |
| 206 | - idLista: $scope.idLista, | |
| 207 | - cotizacion: $scope.hojaRuta.cotizacion.COTIZACION, | |
| 208 | - simbolo: $scope.hojaRuta.moneda.simbolo | |
| 209 | - } | |
| 210 | - }, | |
| 211 | - size: 'lg' | |
| 212 | - } | |
| 213 | - ); | |
| 214 | - modalInstance.result.then( | |
| 215 | - function(producto) { | |
| 216 | - var newArt = | |
| 217 | - { | |
| 218 | - id: 0, | |
| 219 | - codigo: producto.codigo, | |
| 220 | - sector: producto.sector, | |
| 221 | - sectorCodigo: producto.sector + '-' + producto.codigo, | |
| 222 | - descripcion: producto.descripcion, | |
| 223 | - item: $scope.remitosTabla.length + 1, | |
| 224 | - nombre: producto.descripcion, | |
| 225 | - precio: parseFloat(producto.precio.toFixed(4)), | |
| 226 | - costoUnitario: producto.costo, | |
| 227 | - editCantidad: false, | |
| 228 | - editPrecio: false | |
| 229 | - }; | |
| 230 | - $scope.articuloACargar = newArt; | |
| 231 | - $scope.cargando = false; | |
| 232 | - }, function() { | |
| 233 | - // funcion ejecutada cuando se cancela el modal | |
| 234 | - } | |
| 235 | - ); | |
| 236 | - }; | |
| 237 | - | |
| 238 | - $scope.seleccionarVendedor = function() { | |
| 239 | - var modalInstance = $uibModal.open( | |
| 240 | - { | |
| 241 | - ariaLabelledBy: 'Busqueda de Vendedores', | |
| 242 | - templateUrl: 'modal-vendedores.html', | |
| 243 | - controller: 'modalVendedoresCtrl', | |
| 244 | - size: 'lg' | |
| 245 | - } | |
| 246 | - ); | |
| 247 | - modalInstance.result.then( | |
| 248 | - function(vendedor) { | |
| 249 | - addCabecera('Vendedor:', vendedor.NomVen); | |
| 250 | - $scope.hojaRuta.vendedor.codigo = vendedor.CodVen; | |
| 251 | - }, function() { | |
| 252 | - | |
| 253 | - } | |
| 254 | - ); | |
| 255 | - }; | |
| 256 | - | |
| 257 | 195 | $scope.seleccionarProveedor = function() { |
| 258 | 196 | var modalInstance = $uibModal.open( |
| 259 | 197 | { |
| ... | ... | @@ -279,293 +217,136 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 279 | 217 | ); |
| 280 | 218 | }; |
| 281 | 219 | |
| 282 | - $scope.seleccionarCliente = function() { | |
| 283 | - | |
| 220 | + $scope.seleccionarChofer = function() { | |
| 284 | 221 | var modalInstance = $uibModal.open( |
| 285 | 222 | { |
| 286 | - ariaLabelledBy: 'Busqueda de Cliente', | |
| 287 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 288 | - controller: 'focaBusquedaClienteModalController', | |
| 223 | + ariaLabelledBy: 'Busqueda de Chofer', | |
| 224 | + templateUrl: 'modal-chofer.html', | |
| 225 | + controller: 'focaModalChoferController', | |
| 289 | 226 | size: 'lg' |
| 290 | 227 | } |
| 291 | 228 | ); |
| 292 | - modalInstance.result.then( | |
| 293 | - function(cliente) { | |
| 294 | - $scope.abrirModalDomicilios(cliente); | |
| 295 | - }, function() { | |
| 296 | - | |
| 297 | - } | |
| 298 | - ); | |
| 299 | - }; | |
| 300 | 229 | |
| 301 | - $scope.seleccionarRemito = function() { | |
| 302 | - var modalInstance = $uibModal.open( | |
| 303 | - { | |
| 304 | - ariaLabelledBy: 'Busqueda de Remito', | |
| 305 | - templateUrl: 'foca-modal-remito.html', | |
| 306 | - controller: 'focaModalRemitoController', | |
| 307 | - size: 'lg' | |
| 308 | - } | |
| 309 | - ); | |
| 310 | 230 | modalInstance.result.then( |
| 311 | - function(remito) { | |
| 312 | - var litros = 0; | |
| 313 | - for (var i = remito.articulosRemito.length - 1; i >= 0; i--) { | |
| 314 | - litros =+ remito.articulosRemito[i].cantidad; | |
| 315 | - } | |
| 316 | - | |
| 317 | - remito.litros = litros; | |
| 318 | - $scope.remitosTabla.push(remito); | |
| 319 | - console.info($scope.remitosTabla); | |
| 320 | - | |
| 321 | - | |
| 322 | - // TODO: Implementar carga remito | |
| 231 | + function(chofer) { | |
| 232 | + $scope.hojaRuta.chofer = chofer; | |
| 233 | + addCabecera('Chofer: ' + chofer.nombre); | |
| 323 | 234 | }, function() { |
| 324 | 235 | // funcion ejecutada cuando se cancela el modal |
| 325 | 236 | } |
| 326 | 237 | ); |
| 327 | 238 | }; |
| 328 | 239 | |
| 329 | - $scope.abrirModalDomicilios = function(cliente) { | |
| 330 | - var modalInstanceDomicilio = $uibModal.open( | |
| 331 | - { | |
| 332 | - ariaLabelledBy: 'Busqueda de Domicilios', | |
| 333 | - templateUrl: 'modal-domicilio.html', | |
| 334 | - controller: 'focaModalDomicilioController', | |
| 335 | - resolve: { idCliente: function() { return cliente.cod; }}, | |
| 336 | - size: 'lg', | |
| 337 | - } | |
| 338 | - ); | |
| 339 | - modalInstanceDomicilio.result.then( | |
| 340 | - function(domicilio) { | |
| 341 | - $scope.hojaRuta.domicilio.id = domicilio.nivel2; | |
| 342 | - $scope.hojaRuta.cliente = cliente; | |
| 343 | - | |
| 344 | - addCabecera('Cliente:', cliente.nom); | |
| 345 | - addCabecera('Domicilio:', domicilio.Calle + ' ' + domicilio.Numero); | |
| 346 | - }, function() { | |
| 347 | - $scope.seleccionarCliente(); | |
| 348 | - return; | |
| 349 | - } | |
| 350 | - ); | |
| 351 | - }; | |
| 352 | - | |
| 353 | - $scope.mostrarFichaCliente = function() { | |
| 354 | - $uibModal.open( | |
| 355 | - { | |
| 356 | - ariaLabelledBy: 'Datos del Cliente', | |
| 357 | - templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | |
| 358 | - controller: 'focaCrearHojaRutaFichaClienteController', | |
| 359 | - size: 'lg' | |
| 360 | - } | |
| 361 | - ); | |
| 362 | - }; | |
| 363 | - | |
| 364 | - $scope.getTotal = function() { | |
| 365 | - var total = 0; | |
| 366 | - var arrayTempArticulos = $scope.remitosTabla; | |
| 367 | - for (var i = 0; i < arrayTempArticulos.length; i++) { | |
| 368 | - total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
| 369 | - } | |
| 370 | - return parseFloat(total.toFixed(2)); | |
| 371 | - }; | |
| 372 | - | |
| 373 | - $scope.getSubTotal = function() { | |
| 374 | - if($scope.articuloACargar) { | |
| 375 | - return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | |
| 376 | - } | |
| 377 | - }; | |
| 378 | - | |
| 379 | - $scope.abrirModalListaPrecio = function() { | |
| 240 | + $scope.seleccionarVehiculo = function() { | |
| 380 | 241 | var modalInstance = $uibModal.open( |
| 381 | 242 | { |
| 382 | - ariaLabelledBy: 'Busqueda de Precio Condición', | |
| 383 | - templateUrl: 'modal-precio-condicion.html', | |
| 384 | - controller: 'focaModalPrecioCondicionController', | |
| 243 | + ariaLabelledBy: 'Busqueda de Vehiculo', | |
| 244 | + templateUrl: 'modal-vehiculo.html', | |
| 245 | + controller: 'focaModalVehiculoController', | |
| 385 | 246 | size: 'lg' |
| 386 | 247 | } |
| 387 | 248 | ); |
| 249 | + | |
| 388 | 250 | modalInstance.result.then( |
| 389 | - function(precioCondicion) { | |
| 390 | - var cabecera = ''; | |
| 391 | - var plazosConcat = ''; | |
| 392 | - if(!Array.isArray(precioCondicion)) { | |
| 393 | - $scope.plazosPagos = precioCondicion.plazoPago; | |
| 394 | - $scope.idLista = precioCondicion.idListaPrecio; | |
| 395 | - for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
| 396 | - plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | |
| 397 | - } | |
| 398 | - cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | |
| 399 | - } else { //Cuando se ingresan los plazos manualmente | |
| 400 | - $scope.idLista = -1; //-1, el modal productos busca todos los productos | |
| 401 | - $scope.plazosPagos = precioCondicion; | |
| 402 | - for(var j = 0; j < precioCondicion.length; j++) { | |
| 403 | - plazosConcat += precioCondicion[j].dias + ' '; | |
| 404 | - } | |
| 405 | - cabecera = 'Ingreso manual ' + plazosConcat.trim(); | |
| 406 | - } | |
| 407 | - $scope.remitosTabla = []; | |
| 408 | - addCabecera('Precios y condiciones:', cabecera); | |
| 251 | + function(vehiculo) { | |
| 252 | + $scope.hojaRuta.vehiculo = vehiculo; | |
| 253 | + addCabecera('Tractor: ' + vehiculo.tractor); | |
| 254 | + addCabecera('Semi: ' + vehiculo.semi); | |
| 255 | + addCabecera('Capacidad: ' + vehiculo.capacidad); | |
| 409 | 256 | }, function() { |
| 410 | - | |
| 257 | + // funcion ejecutada cuando se cancela el modal | |
| 411 | 258 | } |
| 412 | 259 | ); |
| 413 | 260 | }; |
| 414 | 261 | |
| 415 | - $scope.abrirModalFlete = function() { | |
| 262 | + $scope.seleccionarTarifario = function() { | |
| 416 | 263 | var modalInstance = $uibModal.open( |
| 417 | 264 | { |
| 418 | - ariaLabelledBy: 'Busqueda de Flete', | |
| 419 | - templateUrl: 'modal-flete.html', | |
| 420 | - controller: 'focaModalFleteController', | |
| 265 | + ariaLabelledBy: 'Busqueda de Tarifario', | |
| 266 | + templateUrl: 'modal-tarifa-flete.html', | |
| 267 | + controller: 'focaModalTarifaFleteController', | |
| 421 | 268 | size: 'lg', |
| 422 | 269 | resolve: { |
| 423 | - parametrosFlete: | |
| 424 | - function() { | |
| 425 | - return { | |
| 426 | - flete: $scope.hojaRuta.flete ? '1' : | |
| 427 | - ($scope.hojaRuta.fob ? 'FOB' : | |
| 428 | - ($scope.hojaRuta.flete === undefined ? null : '0')), | |
| 429 | - bomba: $scope.hojaRuta.bomba ? '1' : | |
| 430 | - ($scope.hojaRuta.bomba === undefined ? null : '0'), | |
| 431 | - kilometros: $scope.hojaRuta.kilometros | |
| 432 | - }; | |
| 433 | - } | |
| 434 | - } | |
| 435 | - } | |
| 436 | - ); | |
| 437 | - modalInstance.result.then( | |
| 438 | - function(datos) { | |
| 439 | - $scope.hojaRuta.flete = datos.flete; | |
| 440 | - $scope.hojaRuta.fob = datos.FOB; | |
| 441 | - $scope.hojaRuta.bomba = datos.bomba; | |
| 442 | - $scope.hojaRuta.kilometros = datos.kilometros; | |
| 443 | - | |
| 444 | - addCabecera('Flete:', datos.flete ? 'Si' : | |
| 445 | - ($scope.hojaRuta.fob ? 'FOB' : 'No')); | |
| 446 | - if(datos.flete) { | |
| 447 | - addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | |
| 448 | - addCabecera('Kilometros:', datos.kilometros); | |
| 449 | - } else { | |
| 450 | - removeCabecera('Bomba:'); | |
| 451 | - removeCabecera('Kilometros:'); | |
| 452 | - $scope.hojaRuta.fob = false; | |
| 453 | - $scope.hojaRuta.bomba = false; | |
| 454 | - $scope.hojaRuta.kilometros = null; | |
| 270 | + parametrosTarifaFlete: function() { | |
| 271 | + return $scope.hojaRuta.tarifario.costo; | |
| 272 | + } | |
| 455 | 273 | } |
| 456 | - }, function() { | |
| 457 | - | |
| 458 | 274 | } |
| 459 | 275 | ); |
| 460 | - }; | |
| 461 | 276 | |
| 462 | - $scope.abrirModalMoneda = function() { | |
| 463 | - var modalInstance = $uibModal.open( | |
| 464 | - { | |
| 465 | - ariaLabelledBy: 'Busqueda de Moneda', | |
| 466 | - templateUrl: 'modal-moneda.html', | |
| 467 | - controller: 'focaModalMonedaController', | |
| 468 | - size: 'lg' | |
| 469 | - } | |
| 470 | - ); | |
| 471 | 277 | modalInstance.result.then( |
| 472 | - function(moneda) { | |
| 473 | - $scope.abrirModalCotizacion(moneda); | |
| 278 | + function(tarifario) { | |
| 279 | + $scope.hojaRuta.tarifario = tarifario; | |
| 280 | + addCabecera('Tarifario: ' + tarifario.costo); | |
| 474 | 281 | }, function() { |
| 475 | - | |
| 282 | + // funcion ejecutada cuando se cancela el modal | |
| 476 | 283 | } |
| 477 | 284 | ); |
| 478 | - }; | |
| 285 | + } | |
| 479 | 286 | |
| 480 | - $scope.abrirModalCotizacion = function(moneda) { | |
| 287 | + $scope.seleccionarRemito = function() { | |
| 481 | 288 | var modalInstance = $uibModal.open( |
| 482 | 289 | { |
| 483 | - ariaLabelledBy: 'Busqueda de Cotización', | |
| 484 | - templateUrl: 'modal-cotizacion.html', | |
| 485 | - controller: 'focaModalCotizacionController', | |
| 486 | - size: 'lg', | |
| 487 | - resolve: {idMoneda: function() {return moneda.ID;}} | |
| 290 | + ariaLabelledBy: 'Busqueda de Remito', | |
| 291 | + templateUrl: 'foca-modal-remito.html', | |
| 292 | + controller: 'focaModalRemitoController', | |
| 293 | + size: 'lg' | |
| 488 | 294 | } |
| 489 | 295 | ); |
| 490 | 296 | modalInstance.result.then( |
| 491 | - function(cotizacion) { | |
| 492 | - var remitosTablaTemp = $scope.remitosTabla; | |
| 493 | - for(var i = 0; i < remitosTablaTemp.length; i++) { | |
| 494 | - remitosTablaTemp[i].precio = remitosTablaTemp[i].precio * | |
| 495 | - $scope.hojaRuta.cotizacion.COTIZACION; | |
| 496 | - remitosTablaTemp[i].precio = remitosTablaTemp[i].precio / | |
| 497 | - cotizacion.COTIZACION; | |
| 297 | + function(remito) { | |
| 298 | + for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { | |
| 299 | + if ($scope.remitosTabla[i].id == remito.id) { | |
| 300 | + focaModalService.alert('Remito ya incluido'); | |
| 301 | + return; | |
| 302 | + } | |
| 498 | 303 | } |
| 499 | - $scope.remitosTabla = remitosTablaTemp; | |
| 500 | - $scope.hojaRuta.moneda = { | |
| 501 | - id: moneda.ID, | |
| 502 | - detalle: moneda.DETALLE, | |
| 503 | - simbolo: moneda.SIMBOLO | |
| 504 | - }; | |
| 505 | - $scope.hojaRuta.cotizacion = { | |
| 506 | - ID: cotizacion.ID, | |
| 507 | - COTIZACION: cotizacion.COTIZACION, | |
| 508 | - FECHA: cotizacion.FECHA | |
| 509 | - }; | |
| 510 | - addCabecera('Moneda:', moneda.DETALLE); | |
| 511 | - addCabecera( | |
| 512 | - 'Fecha cotizacion:', | |
| 513 | - $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | |
| 514 | - ); | |
| 515 | - addCabecera('Cotizacion:', cotizacion.COTIZACION); | |
| 516 | - }, function() { | |
| 517 | 304 | |
| 518 | - } | |
| 519 | - ); | |
| 520 | - }; | |
| 305 | + var litros = 0; | |
| 306 | + for (var i = remito.articulosRemito.length - 1; i >= 0; i--) { | |
| 307 | + litros = litros + parseFloat(remito.articulosRemito[i].cantidad); | |
| 308 | + } | |
| 521 | 309 | |
| 522 | - $scope.agregarATabla = function(key) { | |
| 523 | - if(key === 13) { | |
| 524 | - if($scope.articuloACargar.cantidad === undefined || | |
| 525 | - $scope.articuloACargar.cantidad === 0 || | |
| 526 | - $scope.articuloACargar.cantidad === null ){ | |
| 527 | - focaModalService.alert('El valor debe ser al menos 1'); | |
| 310 | + if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | |
| 311 | + focaModalService.alert( | |
| 312 | + 'No se puede agregar mas recibos porque la ' + | |
| 313 | + 'capacidad del vehiculo esta llena o no esta definida' | |
| 314 | + ); | |
| 528 | 315 | return; |
| 529 | - } | |
| 530 | - delete $scope.articuloACargar.sectorCodigo; | |
| 531 | - console.info($scope.articuloACargar); | |
| 532 | - $scope.remitosTabla.push($scope.articuloACargar); | |
| 533 | - $scope.cargando = true; | |
| 534 | - } | |
| 535 | - }; | |
| 316 | + } | |
| 536 | 317 | |
| 537 | - $scope.quitarArticulo = function(key) { | |
| 538 | - $scope.remitosTabla.splice(key, 1); | |
| 539 | - }; | |
| 318 | + if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | |
| 319 | + { | |
| 320 | + var litrostotales = litros; | |
| 321 | + litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | |
| 322 | + focaModalService.alert( | |
| 323 | + 'La carga excede la capacidad disponible del vehiculo. ' + | |
| 324 | + 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | |
| 325 | + ); | |
| 326 | + } | |
| 540 | 327 | |
| 541 | - $scope.editarArticulo = function(key, articulo) { | |
| 542 | - if(key === 13) { | |
| 543 | - if(articulo.cantidad === null || articulo.cantidad === 0 || | |
| 544 | - articulo.cantidad === undefined){ | |
| 545 | - focaModalService.alert('El valor debe ser al menos 1'); | |
| 546 | - return; | |
| 328 | + remito.litros = litros; | |
| 329 | + $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | |
| 330 | + $scope.remitosTabla.push(remito); | |
| 331 | + }, function() { | |
| 332 | + // funcion ejecutada cuando se cancela el modal | |
| 547 | 333 | } |
| 548 | - articulo.editCantidad = false; | |
| 549 | - articulo.editPrecio = false; | |
| 550 | - } | |
| 334 | + ); | |
| 551 | 335 | }; |
| 552 | 336 | |
| 553 | - $scope.cambioEdit = function(articulo, propiedad) { | |
| 554 | - if(propiedad === 'cantidad') { | |
| 555 | - articulo.editCantidad = true; | |
| 556 | - } else if(propiedad === 'precio') { | |
| 557 | - articulo.editPrecio = true; | |
| 337 | + $scope.getTotal = function() { | |
| 338 | + var total = 0; | |
| 339 | + var arrayTempArticulos = $scope.remitosTabla; | |
| 340 | + for (var i = 0; i < arrayTempArticulos.length; i++) { | |
| 341 | + total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
| 558 | 342 | } |
| 343 | + return parseFloat(total.toFixed(2)); | |
| 559 | 344 | }; |
| 560 | 345 | |
| 561 | - $scope.limpiarFlete = function() { | |
| 562 | - $scope.hojaRuta.fleteNombre = ''; | |
| 563 | - $scope.hojaRuta.chofer = ''; | |
| 564 | - $scope.hojaRuta.vehiculo = ''; | |
| 565 | - $scope.hojaRuta.kilometros = ''; | |
| 566 | - $scope.hojaRuta.costoUnitarioKmFlete = ''; | |
| 567 | - $scope.choferes = ''; | |
| 568 | - $scope.vehiculos = ''; | |
| 346 | + $scope.getSubTotal = function() { | |
| 347 | + if($scope.articuloACargar) { | |
| 348 | + return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | |
| 349 | + } | |
| 569 | 350 | }; |
| 570 | 351 | |
| 571 | 352 | $scope.limpiarPantalla = function() { |
| ... | ... | @@ -577,13 +358,9 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 577 | 358 | $scope.hojaRuta.vendedor.nombre = ''; |
| 578 | 359 | $scope.hojaRuta.cliente = {nombre: ''}; |
| 579 | 360 | $scope.hojaRuta.domicilio = {dom: ''}; |
| 361 | + $scope.hojaRuta.litros = 0; | |
| 580 | 362 | $scope.domiciliosCliente = []; |
| 581 | 363 | }; |
| 582 | - | |
| 583 | - $scope.resetFilter = function() { | |
| 584 | - $scope.articuloACargar = {}; | |
| 585 | - $scope.cargando = true; | |
| 586 | - }; | |
| 587 | 364 | //Recibe aviso si el teclado está en uso |
| 588 | 365 | // $rootScope.$on('usarTeclado', function(event, data) { |
| 589 | 366 | // if(data) { |
| ... | ... | @@ -618,6 +395,18 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 618 | 395 | return relleno; |
| 619 | 396 | } |
| 620 | 397 | |
| 398 | + $scope.quitarArticulo = function(key) { | |
| 399 | + $scope.remitosTabla.splice(key, 1); | |
| 400 | + var litros = 0; | |
| 401 | + | |
| 402 | + for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { | |
| 403 | + litros += parseFloat($scope.remitosTabla[i].litros); | |
| 404 | + } | |
| 405 | + | |
| 406 | + $scope.hojaRuta.litros = litros; | |
| 407 | + | |
| 408 | + }; | |
| 409 | + | |
| 621 | 410 | function addCabecera(label, valor) { |
| 622 | 411 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 623 | 412 | if(propiedad.length === 1) { |
src/views/hoja-ruta.html
| ... | ... | @@ -91,7 +91,7 @@ |
| 91 | 91 | <th class="col-2">Remito</th> |
| 92 | 92 | <th class="col">Cliente</th> |
| 93 | 93 | <th class="col">Dirección</th> |
| 94 | - <th class="col-1">Litros</th> | |
| 94 | + <th class="col-1 text-right">Litros</th> | |
| 95 | 95 | <th class="col-auto"> |
| 96 | 96 | <button |
| 97 | 97 | class="btn btn-outline-secondary selectable" |
| ... | ... | @@ -117,7 +117,7 @@ |
| 117 | 117 | <tr |
| 118 | 118 | ng-repeat="(key, remito) in remitosTabla" |
| 119 | 119 | class="d-flex" |
| 120 | - ng-show="show || key == 0" | |
| 120 | + ng-show="show || key == remitosTabla.length - 1" | |
| 121 | 121 | > |
| 122 | 122 | <td ng-bind="key + 1" class="col-auto"></td> |
| 123 | 123 | <td |
| ... | ... | @@ -125,8 +125,8 @@ |
| 125 | 125 | ng-bind="rellenar(remito.sucursal, 4) + '-' + rellenar(remito.numeroRemito, 8)" |
| 126 | 126 | ></td> |
| 127 | 127 | <th class="col" ng-bind="remito.cliente[0].NOM"></th> |
| 128 | - <th class="col" ng-bind="remito.direccionStamp"></th> | |
| 129 | - <th class="col-1" ng-bind="remito.litros"></th> | |
| 128 | + <th class="col" ng-bind="remito.domicilioStamp"></th> | |
| 129 | + <th class="col-1 text-right" ng-bind="remito.litros"></th> | |
| 130 | 130 | <td class="text-center col-auto"> |
| 131 | 131 | <button |
| 132 | 132 | class="btn btn-outline-secondary" |
| ... | ... | @@ -139,10 +139,15 @@ |
| 139 | 139 | </tbody> |
| 140 | 140 | <tfoot> |
| 141 | 141 | <tr class="d-flex"> |
| 142 | - <td colspan="4" class="no-border-top"> | |
| 142 | + <td class="col-auto px-1"> | |
| 143 | 143 | <strong>Remitos:</strong> |
| 144 | 144 | <a ng-bind="remitosTabla.length"></a> |
| 145 | 145 | </td> |
| 146 | + <td class="col"></td> | |
| 147 | + <td class="col-auto px-1"> | |
| 148 | + <strong>Litros:</strong> | |
| 149 | + <a ng-bind="hojaRuta.litros"></a> | |
| 150 | + </td> | |
| 146 | 151 | </tr> |
| 147 | 152 | </tfoot> |
| 148 | 153 | </table> |