Commit da57b3d0494da69b6e2b2fc3c583a81feea71a4c
1 parent
91feb3b0e6
Exists in
master
and in
1 other branch
no se usa
Showing
1 changed file
with
0 additions
and
18 deletions
Show diff stats
src/js/controllerCerrarVehiculo.js
| 1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
| 2 | .controller('focaModalCerrarVehiculo', [ | 2 | .controller('focaModalCerrarVehiculo', [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
| 5 | '$uibModal', | 5 | '$uibModal', |
| 6 | 'focaLogisticaPedidoRutaService', | 6 | 'focaLogisticaPedidoRutaService', |
| 7 | 'idVehiculo', | 7 | 'idVehiculo', |
| 8 | 'focaModalService', | 8 | 'focaModalService', |
| 9 | '$filter', | 9 | '$filter', |
| 10 | 'fechaReparto', | 10 | 'fechaReparto', |
| 11 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, | 11 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, |
| 12 | idVehiculo, focaModalService, $filter, fechaReparto) { | 12 | idVehiculo, focaModalService, $filter, fechaReparto) { |
| 13 | $scope.vehiculo = {}; | 13 | $scope.vehiculo = {}; |
| 14 | $scope.remitos = []; | 14 | $scope.remitos = []; |
| 15 | $scope.now = fechaReparto; | 15 | $scope.now = fechaReparto; |
| 16 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { | 16 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { |
| 17 | $scope.vehiculo = res.data; | 17 | $scope.vehiculo = res.data; |
| 18 | }); | 18 | }); |
| 19 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(idVehiculo, 1, 1).then( | 19 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(idVehiculo, 1, 1).then( |
| 20 | function(res) { | 20 | function(res) { |
| 21 | $scope.remitos = res.data; | 21 | $scope.remitos = res.data; |
| 22 | }); | 22 | }); |
| 23 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { | 23 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
| 24 | $scope.sucursal = res.data.sucursal; | 24 | $scope.sucursal = res.data.sucursal; |
| 25 | $scope.numero = res.data.numeroHojaRuta; | 25 | $scope.numero = res.data.numeroHojaRuta; |
| 26 | }); | 26 | }); |
| 27 | $scope.cancelar = function() { | 27 | $scope.cancelar = function() { |
| 28 | $uibModalInstance.close(); | 28 | $uibModalInstance.close(); |
| 29 | }; | 29 | }; |
| 30 | $scope.aceptar = function() { | 30 | $scope.aceptar = function() { |
| 31 | var idsRemito = []; | 31 | var idsRemito = []; |
| 32 | $scope.remitos.forEach(function(remito) { | 32 | $scope.remitos.forEach(function(remito) { |
| 33 | idsRemito.push(remito.id); | 33 | idsRemito.push(remito.id); |
| 34 | }); | 34 | }); |
| 35 | var cierreDistribuicion = { | 35 | var cierreDistribuicion = { |
| 36 | idsRemito: idsRemito, | 36 | idsRemito: idsRemito, |
| 37 | fechaReparto: focaLogisticaPedidoRutaService.fecha | 37 | fechaReparto: focaLogisticaPedidoRutaService.fecha |
| 38 | }; | 38 | }; |
| 39 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) | 39 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) |
| 40 | .then(function() { | 40 | .then(function() { |
| 41 | focaModalService.alert('Vehículo cerrado con éxito'); | 41 | focaModalService.alert('Vehículo cerrado con éxito'); |
| 42 | } | 42 | } |
| 43 | ); | 43 | ); |
| 44 | }; | 44 | }; |
| 45 | $scope.seleccionarChofer = function() { | ||
| 46 | var modalInstance = $uibModal.open( | ||
| 47 | { | ||
| 48 | ariaLabelledBy: 'Busqueda de Chofer', | ||
| 49 | templateUrl: 'modal-chofer.html', | ||
| 50 | controller: 'focaModalChoferController', | ||
| 51 | size: 'lg' | ||
| 52 | } | ||
| 53 | ); | ||
| 54 | |||
| 55 | modalInstance.result.then( | ||
| 56 | function(chofer) { | ||
| 57 | $scope.chofer = chofer; | ||
| 58 | }, function() { | ||
| 59 | // funcion ejecutada cuando se cancela el modal | ||
| 60 | } | ||
| 61 | ); | ||
| 62 | }; | ||
| 63 | $scope.eliminarRemitos = function() { | 45 | $scope.eliminarRemitos = function() { |
| 64 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); | 46 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); |
| 65 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') | 47 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') |
| 66 | .then(function() { | 48 | .then(function() { |
| 67 | eliminarRemitos(remitosDel); | 49 | eliminarRemitos(remitosDel); |
| 68 | } | 50 | } |
| 69 | ); | 51 | ); |
| 70 | }; | 52 | }; |
| 71 | $scope.minimoUnoChecked = function() { | 53 | $scope.minimoUnoChecked = function() { |
| 72 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); | 54 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); |
| 73 | return !remitosChequeados.length; | 55 | return !remitosChequeados.length; |
| 74 | }; | 56 | }; |
| 75 | function eliminarRemitos(remitosDel) { | 57 | function eliminarRemitos(remitosDel) { |
| 76 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); | 58 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); |
| 77 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, | 59 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, |
| 78 | nuevosRemitos ? true : false).then(function() { | 60 | nuevosRemitos ? true : false).then(function() { |
| 79 | focaModalService.alert('Remitos desasociados con éxito'); | 61 | focaModalService.alert('Remitos desasociados con éxito'); |
| 80 | $scope.remitos = nuevosRemitos; | 62 | $scope.remitos = nuevosRemitos; |
| 81 | }); | 63 | }); |
| 82 | } | 64 | } |
| 83 | }]); | 65 | }]); |
| 84 | 66 |