Commit 071251431046c8c36c2f48a0098950eb837dc94f
1 parent
8c790eebc0
Exists in
master
hojaruta corregido
Showing
2 changed files
with
149 additions
and
0 deletions
 
Show diff stats
src/js/controllerHojasRuta.js
| ... | ... | @@ -0,0 +1,98 @@ | 
| 1 | +angular.module('focaOrdenCarga') | |
| 2 | + .controller('focaModalHojasRutaController', [ | |
| 3 | + '$scope', '$uibModalInstance', 'focaModalService', | |
| 4 | + 'focaCrearHojaRutaService', 'parametrosModal', | |
| 5 | + function ($scope, $uibModalInstance, focaModalService, | |
| 6 | + focaCrearHojaRutaService, parametrosModal) { | |
| 7 | + | |
| 8 | + init(); | |
| 9 | + | |
| 10 | + function init() { | |
| 11 | + $scope.mostrar = false; | |
| 12 | + $scope.orden = parametrosModal.orden; | |
| 13 | + $scope.articulos = []; | |
| 14 | + $scope.cisternaMovimientos = []; | |
| 15 | + $scope.hojasRutas = parametrosModal.hojasRutas; | |
| 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.guardar = function () { | |
| 28 | + | |
| 29 | + var cisternasFilter = validarArticulos(); | |
| 30 | + | |
| 31 | + var articulos = []; | |
| 32 | + if (cisternasFilter === undefined) { | |
| 33 | + return; | |
| 34 | + } | |
| 35 | + cisternasFilter.forEach(function (cisterna) { | |
| 36 | + | |
| 37 | + var fechaReparto = $scope.hojasRutas.fechaReparto; | |
| 38 | + cisterna.cisternaCarga = { | |
| 39 | + confirmado: null, | |
| 40 | + fechaReparto: fechaReparto, | |
| 41 | + idCisterna: cisterna.id, | |
| 42 | + orden: $scope.orden | |
| 43 | + }; | |
| 44 | + | |
| 45 | + //cargar | |
| 46 | + if (cisterna.cisternaCarga.cantidad) { | |
| 47 | + cisterna.cisternaCarga.cantidad += cisterna.disponible; | |
| 48 | + } else { | |
| 49 | + cisterna.cisternaCarga.cantidad = cisterna.disponible; | |
| 50 | + cisterna.cisternaCarga.idProducto = | |
| 51 | + cisterna.articuloSeleccionado.idArticulo; | |
| 52 | + } | |
| 53 | + | |
| 54 | + //Guardar | |
| 55 | + var now = new Date(); | |
| 56 | + var cisternaMovimiento = { | |
| 57 | + fecha: now.toISOString().slice(0, 19).replace('T', ' '), | |
| 58 | + cantidad: cisterna.disponible, | |
| 59 | + metodo: 'carga', | |
| 60 | + idCisternaCarga: cisterna.cisternaCarga.id, | |
| 61 | + }; | |
| 62 | + | |
| 63 | + cisterna.cisternaCarga.fechaReparto = fechaReparto; | |
| 64 | + cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | |
| 65 | + articulos.push(cisterna.articuloSeleccionado); | |
| 66 | + $scope.cisternaMovimientos.push(cisternaMovimiento); | |
| 67 | + }); | |
| 68 | + | |
| 69 | + $uibModalInstance.close({ | |
| 70 | + cisternas: cisternasFilter, | |
| 71 | + movimientos: $scope.cisternaMovimientos, | |
| 72 | + articulos: articulos | |
| 73 | + }); | |
| 74 | + }; | |
| 75 | + | |
| 76 | + $scope.cancel = function () { | |
| 77 | + $uibModalInstance.dismiss(null); | |
| 78 | + }; | |
| 79 | + | |
| 80 | + function validarArticulos() { | |
| 81 | + var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas | |
| 82 | + .filter(function (cisterna) { | |
| 83 | + return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado; | |
| 84 | + }); | |
| 85 | + | |
| 86 | + var cisternasIncompletas = cisternasFilter.filter(function (cisterna) { | |
| 87 | + return (cisterna.articuloSeleccionado && !cisterna.disponible) || | |
| 88 | + (!cisterna.articuloSeleccionado && cisterna.disponible); | |
| 89 | + }); | |
| 90 | + | |
| 91 | + if (cisternasIncompletas.length > 0 && cisternasFilter.length > 0) { | |
| 92 | + focaModalService.alert('Ingrese todos los campos para completar el remito'); | |
| 93 | + cisternasFilter = undefined; | |
| 94 | + } | |
| 95 | + return cisternasFilter; | |
| 96 | + } | |
| 97 | + } | |
| 98 | + ]); | 
src/views/modal-hojas-ruta.html
| ... | ... | @@ -0,0 +1,51 @@ | 
| 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">Hojas de Ruta</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 | + Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> | |
| 12 | + </span> | |
| 13 | + </div> | |
| 14 | +</div> --> | |
| 15 | +<div class="modal-body" id="modal-body"> | |
| 16 | + <table class="table table-hover table-sm table-striped"> | |
| 17 | + <thead> | |
| 18 | + <tr> | |
| 19 | + <th>Fecha</th> | |
| 20 | + <th>N°</th> | |
| 21 | + <th>Ver</th> | |
| 22 | + <th></th> | |
| 23 | + </tr> | |
| 24 | + </thead> | |
| 25 | + <tbody> | |
| 26 | + <tr ng-repeat="remito in hojasRutas.remitos"> | |
| 27 | + <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> | |
| 28 | + <td ng-bind="remito.nombreCliente"></td> | |
| 29 | + <td ng-bind="remito.domicilioStamp"></td> | |
| 30 | + <td> | |
| 31 | + <button | |
| 32 | + type="button" | |
| 33 | + class="btn btn-xs p-1 float-right" | |
| 34 | + ng-class="{ | |
| 35 | + 'btn-secondary': selectedCobranza != key, | |
| 36 | + 'btn-primary': selectedCobranza == key | |
| 37 | + }" | |
| 38 | + foca-focus="selectedCobranza == {{key}}" | |
| 39 | + ng-keydown="itemCobranza($event.keyCode)" | |
| 40 | + > | |
| 41 | + <i class="fa fa-circle-thin" aria-hidden="true"></i> | |
| 42 | + </button> | |
| 43 | + </td>> | |
| 44 | + </tr> | |
| 45 | + </tbody> | |
| 46 | + </table> | |
| 47 | +</div> | |
| 48 | +<div class="modal-footer py-1"> | |
| 49 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
| 50 | +</div> | |
| 51 | +</div> | |
| 0 | 52 | \ No newline at end of file |