Commit 04fb825f720ca9b65ece196c22ba6e058470f9dc
Exists in
master
and in
2 other branches
Merge branch 'master' into 'develop'
Master See merge request !7
Showing
4 changed files
 
Show diff stats
src/js/controller.js
| 1 | angular.module('focaActivarHojaRuta') | 1 | angular.module('focaActivarHojaRuta') | 
| 2 | .controller('focaActivarHojaRutaController', [ | 2 | .controller('focaActivarHojaRutaController', [ | 
| 3 | '$scope', 'focaActivarHojaRutaService', 'focaModalService', 'focaBotoneraLateralService', | 3 | '$scope', 'focaActivarHojaRutaService', 'focaModalService', 'focaBotoneraLateralService', | 
| 4 | '$filter', | 4 | '$filter','$uibModal', | 
| 5 | function($scope, focaActivarHojaRutaService, focaModalService, focaBotoneraLateralService, | 5 | function($scope, focaActivarHojaRutaService, focaModalService, focaBotoneraLateralService, | 
| 6 | $filter) { | 6 | $filter, $uibModal) { | 
| 7 | config(); | 7 | config(); | 
| 8 | 8 | ||
| 9 | //METODOS | 9 | //METODOS | 
| 10 | function config() { | 10 | function config() { | 
| 11 | $scope.botonera = [{ | 11 | $scope.botonera = [{ | 
| 12 | label: 'Chofer', | 12 | label: 'Chofer', | 
| 13 | image: 'cliente.png' | 13 | image: 'cliente.png' | 
| 14 | }]; | 14 | }]; | 
| 15 | //SETEO BOTONERA LATERAL | 15 | //SETEO BOTONERA LATERAL | 
| 16 | focaBotoneraLateralService.showSalir(true); | 16 | focaBotoneraLateralService.showSalir(true); | 
| 17 | focaBotoneraLateralService.showPausar(false); | 17 | focaBotoneraLateralService.showPausar(false); | 
| 18 | focaBotoneraLateralService.showCancelar(false); | 18 | focaBotoneraLateralService.showCancelar(false); | 
| 19 | focaBotoneraLateralService.showGuardar(false); | 19 | focaBotoneraLateralService.showGuardar(false); | 
| 20 | 20 | ||
| 21 | init(); | 21 | init(); | 
| 22 | } | 22 | } | 
| 23 | 23 | ||
| 24 | function init() { | 24 | function init() { | 
| 25 | $scope.now = new Date(); | 25 | $scope.now = new Date(); | 
| 26 | $scope.hojasRuta = []; | 26 | $scope.hojasRuta = []; | 
| 27 | $scope.$broadcast('removeCabecera', 'Chofer:'); | 27 | $scope.$broadcast('removeCabecera', 'Chofer:'); | 
| 28 | } | 28 | } | 
| 29 | 29 | ||
| 30 | $scope.seleccionarChofer = function() { | 30 | $scope.seleccionarChofer = function() { | 
| 31 | var parametrosModal = { | 31 | var parametrosModal = { | 
| 32 | titulo: 'Búsqueda de Chofer', | 32 | titulo: 'Búsqueda de Chofer', | 
| 33 | query: '/chofer', | 33 | query: '/chofer', | 
| 34 | columnas: [ | 34 | columnas: [ | 
| 35 | { | 35 | { | 
| 36 | propiedad: 'id', | 36 | propiedad: 'id', | 
| 37 | nombre: 'Código', | 37 | nombre: 'Código', | 
| 38 | filtro: { | 38 | filtro: { | 
| 39 | nombre: 'rellenarDigitos', | 39 | nombre: 'rellenarDigitos', | 
| 40 | parametro: 3 | 40 | parametro: 3 | 
| 41 | } | 41 | } | 
| 42 | }, | 42 | }, | 
| 43 | { | 43 | { | 
| 44 | propiedad: 'nombre', | 44 | propiedad: 'nombre', | 
| 45 | nombre: 'Nombre' | 45 | nombre: 'Nombre' | 
| 46 | }, | 46 | }, | 
| 47 | { | 47 | { | 
| 48 | propiedad: 'dni', | 48 | propiedad: 'dni', | 
| 49 | nombre: 'DNI' | 49 | nombre: 'DNI' | 
| 50 | }, | 50 | }, | 
| 51 | { | 51 | { | 
| 52 | propiedad: 'telefono', | 52 | propiedad: 'telefono', | 
| 53 | nombre: 'Teléfono' | 53 | nombre: 'Teléfono' | 
| 54 | } | 54 | } | 
| 55 | ] | 55 | ] | 
| 56 | }; | 56 | }; | 
| 57 | focaModalService.modal(parametrosModal).then( | 57 | focaModalService.modal(parametrosModal).then( | 
| 58 | function(chofer) { | 58 | function(chofer) { | 
| 59 | $scope.chofer = chofer.id; | 59 | $scope.chofer = chofer.id; | 
| 60 | focaActivarHojaRutaService.getHojasRutas($scope.chofer) | 60 | focaActivarHojaRutaService.getHojasRutas($scope.chofer) | 
| 61 | .then(function(hojasRutas) { | 61 | .then(function(hojasRutas) { | 
| 62 | $scope.$broadcast('addCabecera', { | 62 | $scope.$broadcast('addCabecera', { | 
| 63 | label: 'Chofer:', | 63 | label: 'Chofer:', | 
| 64 | valor: $scope.chofer + ' - ' + chofer.nombre | 64 | valor: $scope.chofer + ' - ' + chofer.nombre | 
| 65 | }); | 65 | }); | 
| 66 | 66 | ||
| 67 | $scope.hojasRuta = hojasRutas.data; | 67 | $scope.hojasRuta = hojasRutas.data; | 
| 68 | }); | 68 | }); | 
| 69 | }, function() {} | 69 | }, function() {} | 
| 70 | ); | 70 | ); | 
| 71 | }; | 71 | }; | 
| 72 | 72 | ||
| 73 | $scope.mostrarRemitos = function (hojasRutas) { | ||
| 74 | $uibModal.open( | ||
| 75 | { | ||
| 76 | ariaLabelledBy: '', | ||
| 77 | templateUrl: 'modal-remitos.html', | ||
| 78 | controller: 'focaModalDetalleController', | ||
| 79 | resolve: { | ||
| 80 | hojasRutas: function () { return hojasRutas; }, | ||
| 81 | }, | ||
| 82 | size: 'lg', | ||
| 83 | } | ||
| 84 | ); | ||
| 85 | }; | ||
| 86 | |||
| 87 | $scope.setearEstado = function (estado) { | ||
| 88 | var texto = ''; | ||
| 89 | switch (estado) { | ||
| 90 | case 0: | ||
| 91 | texto = 'Disponible'; | ||
| 92 | break; | ||
| 93 | case 1: | ||
| 94 | texto = 'Asignada'; | ||
| 95 | break; | ||
| 96 | case 2: | ||
| 97 | texto = 'Terminada'; | ||
| 98 | break; | ||
| 99 | default: | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | return texto; | ||
| 103 | }; | ||
| 104 | |||
| 73 | $scope.activarHojaRuta = function(hojaRuta) { | 105 | $scope.activarHojaRuta = function(hojaRuta) { | 
| 74 | validarChoferDisponible().then(function(hojaRutaAsignada) { | 106 | validarChoferDisponible().then(function(hojaRutaAsignada) { | 
| 75 | |||
| 76 | if (hojaRutaAsignada) { | 107 | if (hojaRutaAsignada) { | 
| 77 | var texto = 'El chofer tiene asignada la Hoja de Ruta Nº ' + | 108 | var texto = 'El chofer tiene asignada la Hoja de Ruta Nº ' + | 
| 78 | $filter('comprobante')([hojaRutaAsignada.sucursal, | 109 | $filter('comprobante')([hojaRutaAsignada.sucursal, | 
| 79 | hojaRutaAsignada.numeroHojaRuta]) + | 110 | hojaRutaAsignada.numeroHojaRuta]) + | 
| 80 | ', ¿desea reemplazarla por esta?'; | 111 | ', ¿desea reemplazarla por esta?'; | 
| 81 | 112 | ||
| 82 | focaModalService | 113 | focaModalService | 
| 83 | .confirm(texto) | 114 | .confirm(texto) | 
| 84 | .then(function(res) { | 115 | .then(function(res) { | 
| 85 | if (res) activar(); | 116 | if (res) activar(); | 
| 86 | }); | 117 | }); | 
| 87 | } else { | 118 | } else { | 
| 88 | activar(); | 119 | activar(); | 
| 89 | } | 120 | } | 
| 90 | 121 | ||
| 91 | function activar() { | 122 | function activar() { | 
| 92 | focaActivarHojaRutaService | 123 | focaActivarHojaRutaService | 
| 93 | .activarHojaRuta(hojaRuta.id, $scope.chofer) | 124 | .activarHojaRuta(hojaRuta.id, $scope.chofer) | 
| 94 | .then(function() { | 125 | .then(function() { | 
| 126 | hojaRuta.estado = 1; | ||
| 95 | init(); | 127 | init(); | 
| 96 | focaModalService.alert('Hoja de ruta activada'); | 128 | focaModalService.alert('Hoja de ruta activada'); | 
| 97 | }); | 129 | }); | 
| 98 | } | 130 | } | 
| 99 | |||
| 100 | }); | 131 | }); | 
| 101 | }; | 132 | }; | 
| 102 | 133 | ||
| 103 | function validarChoferDisponible() { | 134 | function validarChoferDisponible() { | 
| 104 | return new Promise(function(resolve, reject) { | 135 | return new Promise(function(resolve, reject) { | 
| 105 | focaActivarHojaRutaService | 136 | focaActivarHojaRutaService | 
| 106 | .getHojaRutaByIdChofer($scope.chofer) | 137 | .getHojaRutaByIdChofer($scope.chofer) | 
| 107 | .then(function(res) { | 138 | .then(function(res) { | 
| 108 | resolve(res.data); | 139 | resolve(res.data); | 
| 109 | }) | 140 | }) | 
| 110 | .catch(reject); | 141 | .catch(reject); | 
| 111 | }); | 142 | }); | 
| 112 | } | 143 | } | 
| 113 | 144 | ||
| 114 | 145 | ||
| 115 | /* | 146 | /* | 
| 116 | 147 | ||
| 117 | if(focaActivarHojaRutaService.transportistaSeleccionado.COD) { | 148 | if(focaActivarHojaRutaService.transportistaSeleccionado.COD) { | 
| 118 | elegirTransportista(focaActivarHojaRutaService.transportistaSeleccionado); | 149 | elegirTransportista(focaActivarHojaRutaService.transportistaSeleccionado); | 
| 119 | } | 150 | } | 
| 120 | focaActivarHojaRutaService.cleanCisternasLocal(); | 151 | focaActivarHojaRutaService.cleanCisternasLocal(); | 
| 121 | $scope.editar = function(id) { | 152 | $scope.editar = function(id) { | 
| 122 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); | 153 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); | 
| 123 | }; | 154 | }; | 
| 124 | $scope.solicitarConfirmacion = function(vehiculo) { | 155 | $scope.solicitarConfirmacion = function(vehiculo) { | 
| 125 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 156 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 
| 126 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 157 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 
| 127 | function(data) { | 158 | function(data) { | 
| 128 | if(data) { | 159 | if(data) { | 
| 129 | focaActivarHojaRutaService.deleteVehiculo(vehiculo.id); | 160 | focaActivarHojaRutaService.deleteVehiculo(vehiculo.id); | 
| 130 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 161 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 
| 131 | } | 162 | } | 
| 132 | } | 163 | } | 
| 133 | ); | 164 | ); | 
| 134 | }; | 165 | }; | 
| 135 | 166 | ||
| 136 | function elegirTransportista(transportista) { | 167 | function elegirTransportista(transportista) { | 
| 137 | var codigo = ('00000' + transportista.COD).slice(-5); | 168 | var codigo = ('00000' + transportista.COD).slice(-5); | 
| 138 | $scope.idTransportista = transportista.COD; | 169 | $scope.idTransportista = transportista.COD; | 
| 139 | $scope.filtros = transportista.NOM.trim(); | 170 | $scope.filtros = transportista.NOM.trim(); | 
| 140 | $timeout(function() { | 171 | $timeout(function() { | 
| 141 | $scope.$broadcast('addCabecera', { | 172 | $scope.$broadcast('addCabecera', { | 
| 142 | label: 'Transportista:', | 173 | label: 'Transportista:', | 
| 143 | valor: codigo + ' - ' + transportista.NOM | 174 | valor: codigo + ' - ' + transportista.NOM | 
| 144 | }); | 175 | }); | 
| 145 | }); | 176 | }); | 
| 146 | buscar(transportista.COD); | 177 | buscar(transportista.COD); | 
| 147 | } | 178 | } | 
| 148 | 179 | ||
| 149 | function buscar(idTransportista) { | 180 | function buscar(idTransportista) { | 
| 150 | focaActivarHojaRutaService | 181 | focaActivarHojaRutaService | 
| 151 | .getVehiculosPorTransportista(idTransportista) | 182 | .getVehiculosPorTransportista(idTransportista) | 
| 152 | .then(function(datos) { | 183 | .then(function(datos) { | 
| 153 | $scope.vehiculos = datos.data; | 184 | $scope.vehiculos = datos.data; | 
| 154 | }); | 185 | }); | 
| 155 | }*/ | 186 | }*/ | 
| 156 | } | 187 | } | 
src/js/controllerDetalle.js
| File was created | 1 | angular.module('focaActivarHojaRuta') | |
| 2 | .controller('focaModalDetalleController', [ | ||
| 3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | ||
| 4 | 'focaActivarHojaRutaService','hojasRutas', | ||
| 5 | function ($scope, $timeout, $uibModalInstance, focaModalService, | ||
| 6 | focaActivarHojaRutaService, hojasRutas) { | ||
| 7 | |||
| 8 | $scope.mostrar = false; | ||
| 9 | $scope.hojasRutas = hojasRutas; | ||
| 10 | |||
| 11 | $scope.cancel = function () { | ||
| 12 | $uibModalInstance.close(hojasRutas); | ||
| 13 | }; | ||
| 14 | } | ||
| 15 | ]); | ||
| 16 | 
src/views/activar-hoja-ruta.html
| 1 | <div class="row"> | 1 | <div class="row"> | 
| 2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador | 
| 3 | titulo="'Activar Hoja de Ruta'" | 3 | titulo="'Activar Hoja de Ruta'" | 
| 4 | fecha="now" | 4 | fecha="now" | 
| 5 | class="mb-0 col-lg-12" | 5 | class="mb-0 col-lg-12" | 
| 6 | ></foca-cabecera-facturador> | 6 | ></foca-cabecera-facturador> | 
| 7 | </div> | 7 | </div> | 
| 8 | <div class="row"> | 8 | <div class="row"> | 
| 9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 
| 10 | <div class="row px-5 py-2 botonera-secundaria"> | 10 | <div class="row px-5 py-2 botonera-secundaria"> | 
| 11 | <div class="col-12"> | 11 | <div class="col-12"> | 
| 12 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | 12 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | 
| 13 | </div> | 13 | </div> | 
| 14 | </div> | 14 | </div> | 
| 15 | <!-- <div class="col-6 form-group"> | 15 | <!-- <div class="col-6 form-group"> | 
| 16 | <input seleccionarTransportista() | 16 | <input seleccionarTransportista() | 
| 17 | type="text" | 17 | type="text" | 
| 18 | teclado-virtual | 18 | teclado-virtual | 
| 19 | class="form-control form-control-sm" | 19 | class="form-control form-control-sm" | 
| 20 | placeholder="Búsqueda" | 20 | placeholder="Búsqueda" | 
| 21 | ng-model="filtros" | 21 | ng-model="filtros" | 
| 22 | /> | 22 | /> | 
| 23 | </div> --> | 23 | </div> --> | 
| 24 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | 24 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | 
| 25 | <thead> | 25 | <thead> | 
| 26 | <tr> | 26 | <tr> | 
| 27 | <th>Número</th> | 27 | <th>Número</th> | 
| 28 | <th>Fecha</th> | 28 | <th>Fecha</th> | 
| 29 | <th>Remitos</th> | 29 | <th>Remitos</th> | 
| 30 | <th>Estados</th> | ||
| 31 | <th></th> | ||
| 30 | <th class="text-center"> | 32 | <th class="text-center"> | 
| 31 | </th> | 33 | </th> | 
| 32 | </tr> | 34 | </tr> | 
| 33 | </thead> | 35 | </thead> | 
| 34 | <tbody> | 36 | <tbody> | 
| 35 | <tr ng-repeat="hojaRuta in hojasRuta | filter:filtros"> | 37 | <tr ng-repeat="hojaRuta in hojasRuta | filter:filtros"> | 
| 36 | <td ng-bind="[hojaRuta.sucursal, hojaRuta.numeroHojaRuta] | comprobante"></td> | 38 | <td ng-bind="[hojaRuta.sucursal, hojaRuta.numeroHojaRuta] | comprobante"></td> | 
| 37 | <td ng-bind="hojaRuta.fechaReparto | date:'yyyy-MM-dd':'-0300'"></td> | 39 | <td ng-bind="hojaRuta.fechaReparto | date:'yyyy-MM-dd':'-0300'"></td> | 
| 38 | <td ng-bind="hojaRuta.remitos.length"></td> | 40 | <td> | 
| 41 | <div ng-bind="hojaRuta.remitos.length" class="d-inline-block"></div> | ||
| 42 | <button class="btn btn-outline-dark boton-accion" ng-click="mostrarRemitos(hojaRuta)"> | ||
| 43 | <i class="fa fa-eye"></i> | ||
| 44 | </button> | ||
| 45 | </td> | ||
| 46 | <td | ||
| 47 | ng-bind="setearEstado(hojaRuta.estado)" | ||
| 48 | ng-class="{'text-white':hojaRuta.estado == 0, | ||
| 49 | 'text-danger':hojaRuta.estado == 1, | ||
| 50 | 'text-dark': hojaRuta.estado == 2 | ||
| 51 | }" | ||
| 52 | ></td> | ||
| 53 | <td></td> | ||
| 39 | <td class="text-center"> | 54 | <td class="text-center"> | 
| 40 | <button | 55 | <button | 
| 41 | class="btn btn-outline-dark boton-accion" | 56 | class="btn btn-outline-dark boton-accion" | 
| 42 | title="Activar" | 57 | title="Activar" | 
| 43 | ng-click="activarHojaRuta(hojaRuta)" | 58 | ng-click="activarHojaRuta(hojaRuta)" | 
| 44 | > | 59 | > | 
| 45 | <i class="fa fa-check"></i> | 60 | <i class="fa fa-check"></i> | 
| 46 | </button> | 61 | </button> | 
| 47 | </td> | 62 | </td> | 
| 48 | </tr> | 63 | </tr> | 
| 49 | </body> | 64 | </body> | 
| 50 | </table> | 65 | </table> | 
| 51 | </div> | 66 | </div> | 
| 52 | </div> | 67 | </div> | 
| 53 | 68 | 
src/views/modal-remitos.html
| File was created | 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">Hoja 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 | 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.fechaCreacion | 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>Remito</th> | ||
| 27 | <th>Cliente</th> | ||
| 28 | <th>Domicilio</th> | ||
| 29 | </tr> | ||
| 30 | </thead> | ||
| 31 | <tbody> | ||
| 32 | <tr | ||
| 33 | ng-repeat="remito in hojasRutas.remitos" | ||
| 34 | > | ||
| 35 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> | ||
| 36 | <td ng-bind="remito.nombreCliente"></td> | ||
| 37 | <td ng-bind="remito.domicilioStamp"></td> | ||
| 38 | </tr> | ||
| 39 | </tbody> | ||
| 40 | </table> | ||
| 41 | </div> | ||
| 42 | <div class="modal-footer py-1"> | ||
| 43 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
| 44 | </div> | ||
| 45 | </div> | ||
| 46 |