diff --git a/src/js/controller.js b/src/js/controller.js index 35df87e..5514f58 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -103,85 +103,14 @@ angular.module('focaActivarHojaRuta') }; $scope.activarHojaRuta = function (hojaRuta) { - // validarChoferDisponible().then(function (hojaRutaAsignada) { - // if (hojaRutaAsignada) { - // var texto = 'El chofer tiene asignada la Hoja de Ruta Nº ' + - // $filter('comprobante')([hojaRutaAsignada.sucursal, - // hojaRutaAsignada.numeroHojaRuta]) + - // ', ¿desea reemplazarla por esta?'; - - // focaModalService - // .confirm(texto) - // .then(function (res) { - // if (res) activar(); - // }); - // } else { - // activar(); - // } - - // function activar() { focaActivarHojaRutaService .activarHojaRuta(hojaRuta.id, $scope.chofer) .then(function () { - hojaRuta.estado = 1; - // init(); - focaModalService.alert('Hoja de ruta activada'); + hojaRuta.estado = hojaRuta.estado === 0 ? 1 : 0; + focaModalService + .alert(hojaRuta.estado === 1 ? + 'Hoja de ruta activada' : 'Hoja de ruta desactivada'); }); - // } - // }); }; - - //#region Codigo Comentado - // function validarChoferDisponible() { - // return new Promise(function (resolve, reject) { - // focaActivarHojaRutaService - // .getHojaRutaByIdChofer($scope.chofer) - // .then(function (res) { - // resolve(res.data); - // }) - // .catch(reject); - // }); - // } - - // if(focaActivarHojaRutaService.transportistaSeleccionado.COD) { - // elegirTransportista(focaActivarHojaRutaService.transportistaSeleccionado); - // } - // focaActivarHojaRutaService.cleanCisternasLocal(); - // $scope.editar = function(id) { - // $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); - // }; - // $scope.solicitarConfirmacion = function(vehiculo) { - // focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + - // vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( - // function(data) { - // if(data) { - // focaActivarHojaRutaService.deleteVehiculo(vehiculo.id); - // $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); - // } - // } - // ); - // }; - - // function elegirTransportista(transportista) { - // var codigo = ('00000' + transportista.COD).slice(-5); - // $scope.idTransportista = transportista.COD; - // $scope.filtros = transportista.NOM.trim(); - // $timeout(function() { - // $scope.$broadcast('addCabecera', { - // label: 'Transportista:', - // valor: codigo + ' - ' + transportista.NOM - // }); - // }); - // buscar(transportista.COD); - // } - - // function buscar(idTransportista) { - // focaActivarHojaRutaService - // .getVehiculosPorTransportista(idTransportista) - // .then(function(datos) { - // $scope.vehiculos = datos.data; - // }); - // } - //#endregion } ]); diff --git a/src/js/service.js b/src/js/service.js index 8850c12..230bf31 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -5,7 +5,8 @@ angular.module('focaActivarHojaRuta') return $http.get(API_ENDPOINT.URL + '/hoja-ruta/disponible/' + chofer); }, activarHojaRuta: function (hoja_ruta, chofer) { - return $http.get(API_ENDPOINT.URL + '/hoja-ruta/activar/' + hoja_ruta + '/' + chofer); + return $http.get(API_ENDPOINT.URL + '/hoja-ruta/activar/' + + hoja_ruta + '/' + chofer); }, getHojaRutaByIdChofer: function (chofer) { return $http.get(API_ENDPOINT.URL + '/hoja-ruta/chofer/' + chofer); diff --git a/src/views/activar-hoja-ruta.html b/src/views/activar-hoja-ruta.html index a894a0a..fd22258 100644 --- a/src/views/activar-hoja-ruta.html +++ b/src/views/activar-hoja-ruta.html @@ -61,8 +61,11 @@ title="Activar" ng-click="activarHojaRuta(hojaRuta)" > - - + + +