Commit bd83950814297e5a4e63fb222a15f906bee83757
1 parent
30faa1e57c
Exists in
master
and in
2 other branches
refactor código, fixs
Showing
6 changed files
with
90 additions
and
50 deletions
Show diff stats
src/js/controller.js
| 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ | 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ |
| 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', | 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', |
| 3 | 'focaModalService', 'focaBotoneraLateralService', '$cookies', | 3 | 'focaModalService', 'focaBotoneraLateralService', '$interval', |
| 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, |
| 5 | focaModalService, focaBotoneraLateralService, $cookies | 5 | focaModalService, focaBotoneraLateralService, $interval |
| 6 | ) { | 6 | ) { |
| 7 | $scope.now = new Date(); | ||
| 8 | $scope.actividad = 'Logistica'; | 7 | $scope.actividad = 'Logistica'; |
| 9 | 8 | ||
| 10 | //Datos Pantalla | 9 | //Datos Pantalla |
| 11 | $scope.titulo = 'Logistica de Pedidos'; | 10 | $scope.titulo = 'Logistica de Pedidos'; |
| 12 | $scope.botonera = ['Vehiculo']; | 11 | $scope.botonera = ['Transportista']; |
| 13 | var cabecera = ''; | 12 | var cabecera = ''; |
| 14 | 13 | ||
| 15 | $scope.idVendedor = 0; | 14 | $scope.idVendedor = 0; |
| 16 | $scope.marcadores = []; | 15 | $scope.marcadores = []; |
| 17 | $scope.vehiculos = []; | 16 | $scope.vehiculos = []; |
| 18 | getSeguimiento(); | 17 | getSeguimiento(); |
| 19 | $scope.arrastrando = false; | 18 | $scope.arrastrando = false; |
| 20 | $scope.general = function() { | 19 | $scope.general = function() { |
| 21 | $scope.idVendedor = 0; | 20 | $scope.idVendedor = 0; |
| 22 | getSeguimiento(); | 21 | getSeguimiento(); |
| 23 | }; | 22 | }; |
| 24 | 23 | ||
| 25 | //SETEO BOTONERA LATERAL | 24 | //SETEO BOTONERA LATERAL |
| 26 | focaBotoneraLateralService.showSalir(true); | 25 | focaBotoneraLateralService.showSalir(true); |
| 27 | focaBotoneraLateralService.showPausar(false); | 26 | focaBotoneraLateralService.showPausar(false); |
| 28 | focaBotoneraLateralService.showGuardar(false); | 27 | focaBotoneraLateralService.showGuardar(false); |
| 29 | 28 | ||
| 30 | 29 | ||
| 31 | $scope.general = function() { | 30 | $scope.general = function() { |
| 32 | $scope.idVendedor = 0; | 31 | $scope.idVendedor = 0; |
| 33 | getSeguimiento(); | 32 | getSeguimiento(); |
| 34 | $scope.$broadcast('removeCabecera', cabecera); | 33 | $scope.$broadcast('removeCabecera', cabecera); |
| 35 | $scope.$broadcast('addCabecera',{ | 34 | $scope.$broadcast('addCabecera',{ |
| 36 | label: 'General', | 35 | label: 'General', |
| 37 | valor: '' | 36 | valor: '' |
| 38 | }); | 37 | }); |
| 39 | }; | 38 | }; |
| 40 | 39 | ||
| 41 | $scope.cargar = function(idVehiculo, punto) { | 40 | $scope.cargar = function(idVehiculo, punto) { |
| 42 | var idRemito = JSON.parse(punto).notaPedido.remito.id; | 41 | var idRemito = JSON.parse(punto).notaPedido.remito.id; |
| 43 | var modalInstance = $uibModal.open( | 42 | var modalInstance = $uibModal.open( |
| 44 | { | 43 | { |
| 45 | ariaLabelledBy: 'Busqueda de Vehiculo', | 44 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 46 | templateUrl: 'foca-detalle-vehiculo.html', | 45 | templateUrl: 'foca-detalle-vehiculo.html', |
| 47 | controller: 'focaDetalleVehiculo', | 46 | controller: 'focaDetalleVehiculo', |
| 48 | size: 'lg', | 47 | size: 'lg', |
| 49 | resolve: { | 48 | resolve: { |
| 50 | idVehiculo: function() {return idVehiculo;}, | 49 | idVehiculo: function() {return idVehiculo;}, |
| 51 | idRemito: function() {return idRemito;} | 50 | idRemito: function() {return idRemito;} |
| 52 | } | 51 | } |
| 53 | } | 52 | } |
| 54 | ); | 53 | ); |
| 55 | modalInstance.result.then(function() { | 54 | modalInstance.result.then(function() { |
| 56 | }, function() { | 55 | }, function() { |
| 57 | }); | 56 | }); |
| 58 | }; | 57 | }; |
| 59 | 58 | ||
| 60 | $scope.quitarVehiculo = function(vehiculo) { | 59 | $scope.quitarVehiculo = function(vehiculo) { |
| 61 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 60 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
| 62 | vehiculo.codigo + '?').then(function() { | 61 | vehiculo.codigo + '?').then(function() { |
| 63 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 62 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
| 64 | }); | 63 | }); |
| 65 | }; | 64 | }; |
| 66 | 65 | ||
| 67 | $scope.hacerHojaRuta = function(vehiculo) { | 66 | $scope.hacerHojaRuta = function(vehiculo) { |
| 68 | var modalInstance = $uibModal.open( | 67 | var modalInstance = $uibModal.open( |
| 69 | { | 68 | { |
| 70 | ariaLabelledBy: 'Creación hoja ruta', | 69 | ariaLabelledBy: 'Creación hoja ruta', |
| 71 | templateUrl: 'foca-modal-crear-hoja-ruta.html', | 70 | templateUrl: 'foca-modal-crear-hoja-ruta.html', |
| 72 | controller: 'focaModalCrearHojaRuta', | 71 | controller: 'focaModalCrearHojaRuta', |
| 73 | size: 'lg', | 72 | size: 'lg', |
| 74 | resolve: { | 73 | resolve: { |
| 75 | idVehiculo: function() {return vehiculo.id;} | 74 | idVehiculo: function() {return vehiculo.id;} |
| 76 | } | 75 | } |
| 77 | } | 76 | } |
| 78 | ); | 77 | ); |
| 79 | modalInstance.result.then(function() { | 78 | modalInstance.result.then(function() { |
| 80 | 79 | ||
| 81 | }, function() { | 80 | }, function() { |
| 82 | //usar cuando se cancela el modal | 81 | //usar cuando se cancela el modal |
| 83 | }); | 82 | }); |
| 84 | }; | 83 | }; |
| 85 | 84 | ||
| 86 | $scope.arrastra = function() { | 85 | $scope.arrastra = function() { |
| 87 | $scope.arrastrando = true; | 86 | $scope.arrastrando = true; |
| 88 | $scope.$digest(); | 87 | $scope.$digest(); |
| 89 | }; | 88 | }; |
| 90 | 89 | ||
| 91 | $scope.noArrastra = function() { | 90 | $scope.noArrastra = function() { |
| 92 | $scope.arrastrando = false; | 91 | $scope.arrastrando = false; |
| 93 | $scope.$digest(); | 92 | $scope.$digest(); |
| 94 | }; | 93 | }; |
| 95 | 94 | ||
| 96 | $scope.individual = function() { | 95 | $scope.individual = function() { |
| 97 | $scope.idVendedor = -1; | 96 | $scope.idVendedor = -1; |
| 98 | }; | 97 | }; |
| 99 | 98 | ||
| 100 | $scope.mostrarDetalle = function() { | 99 | $scope.mostrarDetalle = function() { |
| 101 | $scope.detalle = true; | 100 | $scope.detalle = true; |
| 102 | }; | 101 | }; |
| 103 | 102 | ||
| 104 | $scope.salir = function() { | 103 | $scope.salir = function() { |
| 105 | $location.path('/'); | 104 | $location.path('/'); |
| 106 | }; | 105 | }; |
| 107 | 106 | ||
| 108 | $scope.search = function(key) { | 107 | $scope.search = function(key) { |
| 109 | if (key === 13) { | 108 | if (key === 13) { |
| 110 | $scope.idVendedor = $scope.idVendedorInput; | 109 | $scope.idVendedor = $scope.idVendedorInput; |
| 111 | getSeguimiento(); | 110 | getSeguimiento(); |
| 112 | $scope.$broadcast('removeCabecera', 'General'); | 111 | $scope.$broadcast('removeCabecera', 'General'); |
| 113 | $scope.$broadcast('addCabecera', { | 112 | $scope.$broadcast('addCabecera', { |
| 114 | label: cabecera, | 113 | label: cabecera, |
| 115 | valor: $scope.idVendedorInput | 114 | valor: $scope.idVendedorInput |
| 116 | }); | 115 | }); |
| 117 | } | 116 | } |
| 118 | }; | 117 | }; |
| 119 | 118 | ||
| 120 | $scope.fecha = function() { | 119 | $scope.fecha = function() { |
| 121 | getSeguimiento(); | 120 | getSeguimiento(); |
| 122 | }; | 121 | }; |
| 123 | 122 | ||
| 124 | $scope.seleccionarVehiculo = function() { | 123 | $scope.seleccionarTransportista = function() { |
| 124 | var modalInstance = $uibModal.open( | ||
| 125 | { | ||
| 126 | ariaLabelledBy: 'Busqueda de Transportista', | ||
| 127 | templateUrl: 'modal-proveedor.html', | ||
| 128 | controller: 'focaModalProveedorCtrl', | ||
| 129 | size: 'lg', | ||
| 130 | resolve: { | ||
| 131 | transportista: function() { | ||
| 132 | return true; | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
| 136 | ); | ||
| 137 | modalInstance.result.then(function(transportista) { | ||
| 138 | $scope.seleccionarVehiculo(transportista.COD); | ||
| 139 | }); | ||
| 140 | }; | ||
| 141 | |||
| 142 | $scope.seleccionarVehiculo = function(idTransportista) { | ||
| 125 | var modalInstance = $uibModal.open( | 143 | var modalInstance = $uibModal.open( |
| 126 | { | 144 | { |
| 127 | ariaLabelledBy: 'Busqueda de Vehiculo', | 145 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 128 | templateUrl: 'modal-vehiculo.html', | 146 | templateUrl: 'modal-vehiculo.html', |
| 129 | controller: 'focaModalVehiculoController', | 147 | controller: 'focaModalVehiculoController', |
| 130 | size: 'lg' | 148 | size: 'lg', |
| 149 | resolve: { | ||
| 150 | idTransportista: function() {return idTransportista;} | ||
| 151 | } | ||
| 131 | } | 152 | } |
| 132 | ); | 153 | ); |
| 133 | 154 | ||
| 134 | modalInstance.result.then( | 155 | modalInstance.result.then( |
| 135 | function(vehiculo) { | 156 | function(vehiculo) { |
| 136 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 157 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
| 137 | if(existe.length) { | 158 | if(existe.length) { |
| 138 | focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado'); | 159 | focaModalService.alert('El vehiculo que ya ha sido cargado'); |
| 139 | return; | 160 | return; |
| 140 | } | 161 | } |
| 141 | if(!vehiculo.cisternas.length) { | 162 | if(!vehiculo.cisternas.length) { |
| 142 | focaModalService.alert('El vehiculo no tiene cisternas'); | 163 | focaModalService.alert('El vehiculo no tiene cisternas'); |
| 143 | return; | 164 | return; |
| 144 | } | 165 | } |
| 145 | $scope.vehiculos.push(vehiculo); | 166 | $scope.vehiculos.push(vehiculo); |
| 146 | }, function() { | 167 | }, function() { |
| 147 | // funcion ejecutada cuando se cancela el modal | 168 | // funcion ejecutada cuando se cancela el modal |
| 148 | } | 169 | } |
| 149 | ); | 170 | ); |
| 150 | }; | 171 | }; |
| 151 | 172 | ||
| 152 | function getSeguimiento() { | 173 | function getSeguimiento() { |
| 153 | var now = $scope.now; | 174 | var desde = new Date('1900/01/01'); |
| 154 | var desde = new Date(new Date(now.setHours(0)).setMinutes(0)); | 175 | var hasta = new Date('2099/01/01'); |
| 155 | desde = desde.setDate(desde.getDate() - 1); | 176 | if ($scope.now) { |
| 156 | desde = new Date(desde); | 177 | var now = $scope.now; |
| 178 | desde = new Date(new Date(now.setHours(0)).setMinutes(0)); | ||
| 179 | desde = desde.setDate(desde.getDate() - 1); | ||
| 180 | desde = new Date(desde); | ||
| 181 | } | ||
| 157 | var datos = { | 182 | var datos = { |
| 158 | actividad: $scope.actividad, | 183 | actividad: $scope.actividad, |
| 159 | idUsuario: $scope.idVendedor, | 184 | idUsuario: $scope.idVendedor, |
| 160 | fechaDesde: desde, | 185 | fechaDesde: desde, |
| 161 | fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) | 186 | fechaHasta: hasta |
| 162 | }; | 187 | }; |
| 163 | 188 | ||
| 164 | $scope.datosBuscados = { | 189 | $scope.datosBuscados = { |
| 165 | actividad: $scope.actividad, | 190 | actividad: $scope.actividad, |
| 166 | individual: $scope.idVendedor ? true : false | 191 | individual: $scope.idVendedor ? true : false |
| 167 | }; | 192 | }; |
| 168 | 193 | ||
| 169 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 194 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
| 170 | $scope.marcadores = datos.data; | 195 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { |
| 196 | $scope.marcadores = datos.data; | ||
| 197 | } | ||
| 171 | }); | 198 | }); |
| 172 | } | 199 | } |
| 200 | $interval(function() { | ||
| 201 | getSeguimiento(); | ||
| 202 | }, 5000); | ||
| 173 | } | 203 | } |
| 174 | ]); | 204 | ]); |
src/js/controllerDetalleVehiculo.js
| 1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
| 2 | .controller('focaDetalleVehiculo', | 2 | .controller('focaDetalleVehiculo', |
| 3 | ['$scope', | 3 | ['$scope', |
| 4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
| 5 | 'idVehiculo', | 5 | 'idVehiculo', |
| 6 | 'idRemito', | 6 | 'idRemito', |
| 7 | 'focaModalService', | 7 | 'focaModalService', |
| 8 | '$filter', | 8 | '$filter', |
| 9 | 'focaLogisticaPedidoRutaService', | 9 | 'focaLogisticaPedidoRutaService', |
| 10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | 10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
| 11 | focaLogisticaPedidoRutaService | 11 | focaLogisticaPedidoRutaService |
| 12 | ) { | 12 | ) { |
| 13 | //seteo variables | 13 | //seteo variables |
| 14 | $scope.articulos = []; | 14 | $scope.articulos = []; |
| 15 | $scope.vehiculo = {}; | 15 | $scope.vehiculo = {}; |
| 16 | $scope.remito = {}; | 16 | $scope.remito = {}; |
| 17 | $scope.aCargar = []; | 17 | $scope.aCargar = []; |
| 18 | var cisternaMovimientos = []; | 18 | var cisternaMovimientos = []; |
| 19 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then( | 19 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then( |
| 20 | function(res) { | 20 | function(res) { |
| 21 | $scope.vehiculo = res.data; | 21 | $scope.vehiculo = res.data; |
| 22 | } | 22 | } |
| 23 | ); | 23 | ); |
| 24 | focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( | 24 | focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( |
| 25 | function(res) { | 25 | function(res) { |
| 26 | $scope.remito = res.data; | 26 | $scope.remito = res.data; |
| 27 | if($scope.remito.idUsuarioProceso !== focaLogisticaPedidoRutaService.idUsuario) | 27 | if($scope.remito.idUsuarioProceso && $scope.remito.idUsuarioProceso !== |
| 28 | focaLogisticaPedidoRutaService.idUsuario) | ||
| 28 | { | 29 | { |
| 29 | focaModalService.alert('El remito esta siendo cargado por otro usario'); | 30 | focaModalService.alert('El remito esta siendo cargado por otro usario'); |
| 30 | $uibModalInstance.close(); | 31 | $uibModalInstance.close(); |
| 31 | } | 32 | } |
| 32 | $scope.articulos = res.data.articulosRemito; | 33 | $scope.articulos = res.data.articulosRemito; |
| 33 | } | 34 | } |
| 34 | ); | 35 | ); |
| 35 | $scope.aceptar = function() { | 36 | $scope.aceptar = function() { |
| 36 | $scope.cargando = true; | 37 | $scope.cargando = true; |
| 37 | var cisternaCargas = []; | 38 | var cisternaCargas = []; |
| 38 | for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | 39 | for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { |
| 39 | delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo; | 40 | delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo; |
| 40 | cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga); | 41 | cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga); |
| 41 | } | 42 | } |
| 42 | var cisterna = { | 43 | var cisterna = { |
| 43 | cisternaMovimientos: cisternaMovimientos, | 44 | cisternaMovimientos: cisternaMovimientos, |
| 44 | cisternaCargas: cisternaCargas, | 45 | cisternaCargas: cisternaCargas, |
| 45 | idVehiculo: $scope.vehiculo.id | 46 | idVehiculo: $scope.vehiculo.id |
| 46 | }; | 47 | }; |
| 47 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) | 48 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) |
| 48 | .then(function() { | 49 | .then(function() { |
| 49 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { | 50 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { |
| 50 | $scope.cargando = false; | 51 | $scope.cargando = false; |
| 51 | $uibModalInstance.close(); | 52 | $uibModalInstance.close(); |
| 52 | }); | 53 | }); |
| 53 | }).catch(function(error) { | 54 | }).catch(function(error) { |
| 54 | $scope.cargando = false; | 55 | $scope.cargando = false; |
| 55 | $uibModalInstance.close(); | 56 | $uibModalInstance.close(); |
| 56 | if (error.status === 403.1) { | 57 | if (error.status === 403.1) { |
| 57 | focaModalService.alert('ERROR: El vehículo esta en uso'); | 58 | focaModalService.alert('ERROR: El vehículo esta en uso'); |
| 58 | } | 59 | } |
| 59 | if(error.status === 403.2) { | 60 | if(error.status === 403.2) { |
| 60 | focaModalService.alert('ERROR: Otro usario ya cargó este remito'); | 61 | focaModalService.alert('ERROR: Otro usario ya cargó este remito'); |
| 61 | return; | 62 | return; |
| 62 | } | 63 | } |
| 63 | focaModalService.alert('Hubo un error al cargar las cisternas'); | 64 | focaModalService.alert('Hubo un error al cargar las cisternas'); |
| 64 | }); | 65 | }); |
| 65 | }; | 66 | }; |
| 66 | 67 | ||
| 67 | $scope.cancelar = function() { | 68 | $scope.cancelar = function() { |
| 68 | $uibModalInstance.close(); | 69 | $uibModalInstance.close(); |
| 69 | }; | 70 | }; |
| 70 | 71 | ||
| 71 | $scope.cargarACisternas = function(vehiculo) { | 72 | $scope.cargarACisternas = function(vehiculo) { |
| 72 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 73 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
| 73 | var cisterna = vehiculo.cisternas[i]; | 74 | var cisterna = vehiculo.cisternas[i]; |
| 74 | var aCargar = parseFloat($scope.aCargar[i]); | 75 | var aCargar = parseFloat($scope.aCargar[i]); |
| 75 | //validaciones | 76 | //validaciones |
| 76 | if(!aCargar) { | 77 | if(!aCargar) { |
| 77 | continue; | 78 | continue; |
| 78 | } | 79 | } |
| 79 | if(aCargar > cisterna.disponible) { | 80 | if(aCargar > cisterna.disponible) { |
| 80 | focaModalService.alert('La cantidad cargada supera la capacidad de la' + | 81 | focaModalService.alert('La cantidad cargada supera la capacidad de la' + |
| 81 | 'cisterna ' + cisterna.codigo); | 82 | 'cisterna ' + cisterna.codigo); |
| 82 | return; | 83 | return; |
| 83 | } | 84 | } |
| 84 | //cargar | 85 | //cargar |
| 85 | if(cisterna.cisternaCarga.cantidad) { | 86 | if(cisterna.cisternaCarga.cantidad) { |
| 86 | cisterna.cisternaCarga.cantidad += aCargar; | 87 | cisterna.cisternaCarga.cantidad += aCargar; |
| 87 | }else { | 88 | }else { |
| 88 | cisterna.cisternaCarga.cantidad = aCargar; | 89 | cisterna.cisternaCarga.cantidad = aCargar; |
| 89 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | 90 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; |
| 90 | } | 91 | } |
| 91 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | 92 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; |
| 92 | 93 | ||
| 93 | cisterna.cisternaCarga.articulo = { | 94 | cisterna.cisternaCarga.articulo = { |
| 94 | DetArt: $scope.articuloSeleccionado.descripcion | 95 | DetArt: $scope.articuloSeleccionado.descripcion |
| 95 | }; | 96 | }; |
| 96 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | 97 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] |
| 97 | .cargado = true; | 98 | .cargado = true; |
| 98 | 99 | ||
| 99 | $scope.calcularPorcentaje(cisterna); | 100 | $scope.calcularPorcentaje(cisterna); |
| 100 | //Guardar | 101 | //Guardar |
| 101 | var now = new Date(); | 102 | var now = new Date(); |
| 102 | var cisternaMovimiento = { | 103 | var cisternaMovimiento = { |
| 103 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 104 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), |
| 104 | cantidad: aCargar, | 105 | cantidad: aCargar, |
| 105 | metodo: 'carga', | 106 | metodo: 'carga', |
| 106 | idCisternaCarga: cisterna.cisternaCarga.id, | 107 | idCisternaCarga: cisterna.cisternaCarga.id, |
| 107 | idRemito: $scope.remito.id | 108 | idRemito: $scope.remito.id |
| 108 | }; | 109 | }; |
| 109 | cisternaMovimientos.push(cisternaMovimiento); | 110 | cisternaMovimientos.push(cisternaMovimiento); |
| 110 | } | 111 | } |
| 111 | var articuloSiguiente = $scope.articulos.filter( | 112 | var articuloSiguiente = $scope.articulos.filter( |
| 112 | function(filter) { | 113 | function(filter) { |
| 113 | return filter.cargado !== true; | 114 | return filter.cargado !== true; |
| 114 | } | 115 | } |
| 115 | ); | 116 | ); |
| 116 | if(articuloSiguiente.length > 0) { | 117 | if(articuloSiguiente.length > 0) { |
| 117 | $scope.cambioArticulo(articuloSiguiente[0]); | 118 | $scope.cambioArticulo(articuloSiguiente[0]); |
| 118 | } | 119 | } |
| 119 | $scope.aCargar = []; | 120 | $scope.aCargar = []; |
| 120 | }; | 121 | }; |
| 121 | $scope.calcularPorcentaje = function(cisterna) { | 122 | $scope.calcularPorcentaje = function(cisterna) { |
| 122 | if(!cisterna.cisternaCarga.cantidad) { | 123 | if(!cisterna.cisternaCarga.cantidad) { |
| 123 | cisterna.cisternaCarga.cantidad = 0; | 124 | cisterna.cisternaCarga.cantidad = 0; |
| 124 | } | 125 | } |
| 125 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | 126 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / |
| 126 | cisterna.capacidad) + '%'; | 127 | cisterna.capacidad) + '%'; |
| 127 | var elementHtml = document.getElementById(cisterna.id); | 128 | var elementHtml = document.getElementById(cisterna.id); |
| 128 | if(elementHtml) { | 129 | if(elementHtml) { |
| 129 | elementHtml.style.width = porcentaje; | 130 | elementHtml.style.width = porcentaje; |
| 130 | } | 131 | } |
| 131 | }; | 132 | }; |
| 132 | $scope.cambioArticulo = function(articulo) { | 133 | $scope.cambioArticulo = function(articulo) { |
| 133 | articulo.checked = true; | 134 | articulo.checked = true; |
| 134 | $scope.articuloSeleccionado = articulo; | 135 | $scope.articuloSeleccionado = articulo; |
| 135 | }; | 136 | }; |
| 136 | $scope.actualizarArticulo = function () { | 137 | $scope.actualizarArticulo = function () { |
| 137 | $scope.articuloSeleccionado.cantidadCargada = 0; | 138 | $scope.articuloSeleccionado.cantidadCargada = 0; |
| 138 | for (var i = 0; i < $scope.aCargar.length; i++) { | 139 | for (var i = 0; i < $scope.aCargar.length; i++) { |
| 139 | $scope.articuloSeleccionado.cantidadCargada += | 140 | $scope.articuloSeleccionado.cantidadCargada += |
| 140 | parseFloat($scope.aCargar[i]) || 0; | 141 | parseFloat($scope.aCargar[i]) || 0; |
| 141 | } | 142 | } |
| 142 | }; | 143 | }; |
| 143 | $scope.tieneArticulosPendientes = function() { | 144 | $scope.tieneArticulosPendientes = function() { |
| 144 | var articulosDescargados = $scope.articulos.filter(function(filter) { | 145 | var articulosDescargados = $scope.articulos.filter(function(filter) { |
| 145 | return filter.cargado === true; | 146 | return filter.cargado === true; |
| 146 | }); | 147 | }); |
| 147 | if(articulosDescargados.length === $scope.articulos.length) { | 148 | if(articulosDescargados.length === $scope.articulos.length) { |
| 148 | return false; | 149 | return false; |
| 149 | } | 150 | } |
| 150 | return true; | 151 | return true; |
| 151 | }; | 152 | }; |
| 152 | }]); | 153 | }]); |
| 153 | 154 |
src/js/controllerHojaRuta.js
| 1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
| 2 | .controller('focaModalCrearHojaRuta', [ | 2 | .controller('focaModalCrearHojaRuta', [ |
| 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 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, | 10 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, |
| 11 | idVehiculo, focaModalService, $filter) { | 11 | idVehiculo, focaModalService, $filter) { |
| 12 | $scope.vehiculo = {}; | 12 | $scope.vehiculo = {}; |
| 13 | $scope.remitos = []; | 13 | $scope.remitos = []; |
| 14 | $scope.now = new Date(); | 14 | $scope.now = new Date(); |
| 15 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { | 15 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { |
| 16 | $scope.vehiculo = res.data; | 16 | $scope.vehiculo = res.data; |
| 17 | }); | 17 | }); |
| 18 | //TODO: refactor código esta rre feo | 18 | //TODO: refactor código esta rre feo |
| 19 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { | 19 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { |
| 20 | for(var i = 0; i < res.data.cisternas.length; i++) { | 20 | $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); |
| 21 | for(var j = 0; j < res.data.cisternas[i].cisternaCarga.cisternaMovimientos.length; | ||
| 22 | j++) { | ||
| 23 | if(!!res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito && | ||
| 24 | !res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito | ||
| 25 | .idHojaRuta) { | ||
| 26 | var remito = res.data.cisternas[i].cisternaCarga | ||
| 27 | .cisternaMovimientos[j].remito; | ||
| 28 | var yaEstaCargado = $filter('filter')($scope.remitos, {id: remito.id}); | ||
| 29 | if(!yaEstaCargado.length && | ||
| 30 | res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].metodo === | ||
| 31 | 'carga') { | ||
| 32 | $scope.remitos.push(remito); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | } | ||
| 36 | } | ||
| 37 | }); | 21 | }); |
| 22 | |||
| 38 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { | 23 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
| 39 | $scope.sucursal = res.data.sucursal; | 24 | $scope.sucursal = res.data.sucursal; |
| 40 | $scope.numero = res.data.numeroHojaRuta; | 25 | $scope.numero = res.data.numeroHojaRuta; |
| 41 | }); | 26 | }); |
| 42 | $scope.cancelar = function() { | 27 | $scope.cancelar = function() { |
| 43 | $uibModalInstance.close(); | 28 | $uibModalInstance.close(); |
| 44 | }; | 29 | }; |
| 45 | $scope.aceptar = function() { | 30 | $scope.aceptar = function() { |
| 46 | var save = { | 31 | var save = { |
| 47 | hojaRuta: { | 32 | hojaRuta: { |
| 48 | id: 0, | 33 | id: 0, |
| 49 | fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 34 | fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
| 50 | idTransportista: $scope.vehiculo.idTransportista, | 35 | idTransportista: $scope.vehiculo.idTransportista, |
| 51 | idChofer: $scope.chofer.id, | 36 | idChofer: $scope.chofer.id, |
| 52 | idVehiculo: $scope.vehiculo.id, | 37 | idVehiculo: $scope.vehiculo.id, |
| 53 | tarifaFlete: $scope.tarifaFlete | 38 | tarifaFlete: $scope.tarifaFlete |
| 54 | }, | 39 | }, |
| 55 | remitos: $scope.remitos, | 40 | remitos: $scope.remitos, |
| 56 | idVehiculo: $scope.vehiculo.id | 41 | idVehiculo: $scope.vehiculo.id |
| 57 | }; | 42 | }; |
| 58 | focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { | 43 | focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { |
| 59 | $uibModalInstance.close(); | 44 | $uibModalInstance.close(); |
| 60 | focaModalService.alert('Hoja de ruta guardada con éxito'); | 45 | focaModalService.alert('Hoja de ruta guardada con éxito'); |
| 61 | }); | 46 | }); |
| 62 | }; | 47 | }; |
| 63 | $scope.seleccionarChofer = function() { | 48 | $scope.seleccionarChofer = function() { |
| 64 | var modalInstance = $uibModal.open( | 49 | var modalInstance = $uibModal.open( |
| 65 | { | 50 | { |
| 66 | ariaLabelledBy: 'Busqueda de Chofer', | 51 | ariaLabelledBy: 'Busqueda de Chofer', |
| 67 | templateUrl: 'modal-chofer.html', | 52 | templateUrl: 'modal-chofer.html', |
| 68 | controller: 'focaModalChoferController', | 53 | controller: 'focaModalChoferController', |
| 69 | size: 'lg' | 54 | size: 'lg' |
| 70 | } | 55 | } |
| 71 | ); | 56 | ); |
| 72 | 57 | ||
| 73 | modalInstance.result.then( | 58 | modalInstance.result.then( |
| 74 | function(chofer) { | 59 | function(chofer) { |
| 75 | $scope.chofer = chofer; | 60 | $scope.chofer = chofer; |
| 76 | }, function() { | 61 | }, function() { |
| 77 | // funcion ejecutada cuando se cancela el modal | 62 | // funcion ejecutada cuando se cancela el modal |
| 78 | } | 63 | } |
| 79 | ); | 64 | ); |
| 80 | }; | 65 | }; |
| 81 | }]); | 66 | }]); |
src/js/osm-directive.js
| 1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { | 1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { |
| 2 | return { | 2 | return { |
| 3 | restrict: 'E', | 3 | restrict: 'E', |
| 4 | link: function(scope, el, attrs) { | 4 | link: function(scope, el, attrs) { |
| 5 | var contenedor = document.createElement('div'); | 5 | var contenedor = document.createElement('div'); |
| 6 | el.append(contenedor); | 6 | el.append(contenedor); |
| 7 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); | 7 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); |
| 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); | 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
| 9 | }, | 9 | }, |
| 10 | controller: ['$scope', '$filter', function($scope, $filter) { | 10 | controller: ['$scope', '$filter', function($scope, $filter) { |
| 11 | $scope.markers = []; | 11 | $scope.markers = []; |
| 12 | $scope.$watch('marcadores', function() { | 12 | $scope.$watch('marcadores', function() { |
| 13 | for(var i in $scope.markers) { | 13 | for(var i in $scope.markers) { |
| 14 | $scope.map.removeLayer($scope.markers[i]); | 14 | $scope.map.removeLayer($scope.markers[i]); |
| 15 | } | 15 | } |
| 16 | $scope.markers = []; | 16 | $scope.markers = []; |
| 17 | 17 | ||
| 18 | angular.forEach($scope.marcadores, function(marcador) { | 18 | angular.forEach($scope.marcadores, function(marcador) { |
| 19 | var observacion = | 19 | var observacion = |
| 20 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + | 20 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + |
| 21 | ( | 21 | ( |
| 22 | marcador.notaPedido.vendedor ? | 22 | marcador.notaPedido.vendedor ? |
| 23 | marcador.notaPedido.vendedor.NomVen : | 23 | marcador.notaPedido.vendedor.NomVen : |
| 24 | '' | 24 | '' |
| 25 | ) + '<br/>'; | 25 | ) + '<br/>'; |
| 26 | observacion += 'Fecha: ' + | 26 | observacion += 'Fecha: ' + |
| 27 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 27 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
| 28 | marcador.fecha.slice(11,19) + '<br/>'; | 28 | marcador.fecha.slice(11,19) + '<br/>'; |
| 29 | observacion += 'Nº: ' + $filter('comprobante')([ | 29 | observacion += 'Remito Nº: ' + $filter('comprobante')([ |
| 30 | marcador.notaPedido.remito.sucursal, | 30 | marcador.notaPedido.remito.sucursal, |
| 31 | marcador.notaPedido.remito.numeroRemito | 31 | marcador.notaPedido.remito.numeroRemito |
| 32 | ]) + '<br/>'; | 32 | ]) + '<br/>'; |
| 33 | observacion += 'Cliente: ' + | 33 | observacion += 'Cliente: ' + |
| 34 | marcador.notaPedido.cliente.NOM + '<br/>'; | 34 | marcador.notaPedido.cliente.NOM + '<br/>'; |
| 35 | 35 | ||
| 36 | if($scope.parametros.individual) { | 36 | // if($scope.parametros.individual) { |
| 37 | observacion += | 37 | observacion += |
| 38 | 'Total: ' + $filter('currency')(marcador.notaPedido.total, '$'); | 38 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); |
| 39 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | 39 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; |
| 40 | 40 | ||
| 41 | if(marcador.distancia) { | 41 | if(marcador.distancia) { |
| 42 | observacion += '<br/>Distancia a casa central: ' + | 42 | observacion += '<br/>Distancia a casa central: ' + |
| 43 | marcador.distancia + 'km'; | 43 | marcador.distancia + 'km'; |
| 44 | } | ||
| 45 | }else { | ||
| 46 | observacion += 'Cantidad de nota de remitos: ' + | ||
| 47 | marcador.cantidad + '<br/>'; | ||
| 48 | observacion += 'Total Vendido: ' + | ||
| 49 | $filter('currency')(marcador.total, '$'); | ||
| 50 | } | 44 | } |
| 45 | // }else { | ||
| 46 | // observacion += 'Cantidad de remitos: ' + | ||
| 47 | // marcador.cantidad + '<br/>'; | ||
| 48 | // observacion += 'Total Vendido: ' + | ||
| 49 | // $filter('currency')(marcador.total, '$'); | ||
| 50 | // } | ||
| 51 | observacion += '<br/>'; | 51 | observacion += '<br/>'; |
| 52 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | 52 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ |
| 53 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | 53 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ |
| 54 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | 54 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; |
| 55 | var icon; | 55 | var icon; |
| 56 | if(marcador.notaPedido.remito.idUsuarioProceso) { | 56 | if(marcador.notaPedido.remito.idUsuarioProceso) { |
| 57 | //Asignado AZUL | 57 | //Asignado AZUL |
| 58 | icon = new L.Icon({ | 58 | icon = new L.Icon({ |
| 59 | iconUrl: 'img/marker-icon-2x-blue.png', | 59 | iconUrl: 'img/marker-icon-2x-blue.png', |
| 60 | shadowUrl: 'img/marker-shadow.png', | 60 | shadowUrl: 'img/marker-shadow.png', |
| 61 | iconSize: [25, 41], | 61 | iconSize: [25, 41], |
| 62 | iconAnchor: [12, 41], | 62 | iconAnchor: [12, 41], |
| 63 | popupAnchor: [1, -34], | 63 | popupAnchor: [1, -34], |
| 64 | shadowSize: [41, 41] | 64 | shadowSize: [41, 41] |
| 65 | }); | 65 | }); |
| 66 | }else { | 66 | }else { |
| 67 | //Sin asignar ROJO | 67 | //Sin asignar ROJO |
| 68 | icon = new L.Icon({ | 68 | icon = new L.Icon({ |
| 69 | iconUrl: 'img/marker-icon-2x-red.png', | 69 | iconUrl: 'img/marker-icon-2x-red.png', |
| 70 | shadowUrl: 'img/marker-shadow.png', | 70 | shadowUrl: 'img/marker-shadow.png', |
| 71 | iconSize: [25, 41], | 71 | iconSize: [25, 41], |
| 72 | iconAnchor: [12, 41], | 72 | iconAnchor: [12, 41], |
| 73 | popupAnchor: [1, -34], | 73 | popupAnchor: [1, -34], |
| 74 | shadowSize: [41, 41] | 74 | shadowSize: [41, 41] |
| 75 | }); | 75 | }); |
| 76 | } | 76 | } |
| 77 | $scope.markers.push( | 77 | $scope.markers.push( |
| 78 | L.marker([marcador.latitud, marcador.longitud], {icon: icon}) | 78 | L.marker([marcador.latitud, marcador.longitud], {icon: icon}) |
| 79 | .addTo($scope.map) | 79 | .addTo($scope.map) |
| 80 | .bindPopup(observacion) | 80 | .bindPopup(observacion) |
| 81 | ); | 81 | ); |
| 82 | 82 | ||
| 83 | $scope.markers[0].openPopup(); | 83 | $scope.markers[0].openPopup(); |
| 84 | }); | 84 | }); |
| 85 | }); | 85 | }); |
| 86 | }], | 86 | }], |
| 87 | scope: { | 87 | scope: { |
| 88 | latitud: '=', | 88 | latitud: '=', |
| 89 | longitud: '=', | 89 | longitud: '=', |
| 90 | zoom: '=', | 90 | zoom: '=', |
src/js/service.js
| 1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
| 2 | .service( | 2 | .service( |
| 3 | 'focaLogisticaPedidoRutaService', [ | 3 | 'focaLogisticaPedidoRutaService', [ |
| 4 | '$http', | 4 | '$http', |
| 5 | '$cookies', | 5 | '$cookies', |
| 6 | 'API_ENDPOINT', | 6 | 'API_ENDPOINT', |
| 7 | function($http, $cookies, API_ENDPOINT) { | 7 | '$filter', |
| 8 | function($http, $cookies, API_ENDPOINT, $filter) { | ||
| 8 | return { | 9 | return { |
| 9 | idUsuario: $cookies.get('idUsuario'), | 10 | idUsuario: $cookies.get('idUsuario'), |
| 10 | obtenerActividad: function(parametros) { | 11 | obtenerActividad: function(parametros) { |
| 11 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); | 12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); |
| 12 | }, | 13 | }, |
| 13 | obtenerVehiculoById: function(idVehiculo) { | 14 | obtenerVehiculoById: function(idVehiculo) { |
| 14 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); | 15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); |
| 15 | }, | 16 | }, |
| 16 | obtenerRemitoById: function(idRemito) { | 17 | obtenerRemitoById: function(idRemito) { |
| 17 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); | 18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); |
| 18 | }, | 19 | }, |
| 19 | guardarCisternas: function(cisterna, idRemito) { | 20 | guardarCisternas: function(cisterna, idRemito) { |
| 20 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | 21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + |
| 21 | this.idUsuario + '/' + idRemito,cisterna); | 22 | this.idUsuario + '/' + idRemito,cisterna); |
| 22 | }, | 23 | }, |
| 23 | numeroHojaRuta: function() { | 24 | numeroHojaRuta: function() { |
| 24 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); | 25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); |
| 25 | }, | 26 | }, |
| 26 | getRemitos: function(idVehiculo) { | 27 | getRemitos: function(idVehiculo) { |
| 27 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); | 28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); |
| 28 | }, | 29 | }, |
| 29 | crearHojaRuta: function(hojaRuta) { | 30 | crearHojaRuta: function(hojaRuta) { |
| 30 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); | 31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); |
| 32 | }, | ||
| 33 | obtenerRemitosDeCarga: function(remitos) { | ||
| 34 | var remitosRes = []; | ||
| 35 | for(var i = 0; i < remitos.cisternas.length; i++) { | ||
| 36 | procesoCistena(remitos.cisternas[i]); | ||
| 37 | } | ||
| 38 | function procesoCistena(cisterna) { | ||
| 39 | for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; | ||
| 40 | j++) { | ||
| 41 | procesoMovimiento( | ||
| 42 | cisterna.cisternaCarga.cisternaMovimientos[j]); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | function procesoMovimiento(movimiento) { | ||
| 46 | if(movimiento.remito && !movimiento.remito.idHojaRuta) { | ||
| 47 | var remito = movimiento.remito; | ||
| 48 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | ||
| 49 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | ||
| 50 | remitosRes.push(remito); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
| 54 | return remitosRes; | ||
| 31 | } | 55 | } |
| 32 | }; | 56 | }; |
| 33 | }]); | 57 | }]); |
| 34 | 58 |
src/views/foca-modal-crear-hoja-ruta.html
| 1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
| 2 | <h4>-en desarrollo</h4> | 2 | <h4>-en desarrollo</h4> |
| 3 | <h4>Confeccionar hoja de ruta</h4> | 3 | <h4>Confeccionar hoja de ruta</h4> |
| 4 | Hoja de ruta Nº <strong ng-bind="[numero, sucursal] | comprobante"></strong> | 4 | Hoja de ruta Nº <strong ng-bind="[sucursal, numero] | comprobante"></strong> |
| 5 | Fecha: | 5 | Fecha: |
| 6 | <input | 6 | <input |
| 7 | type="date" | 7 | type="date" |
| 8 | ng-model="now" | 8 | ng-model="now" |
| 9 | class="form-control form-control-sm col-3 float-right" | 9 | class="form-control form-control-sm col-3 float-right" |
| 10 | /> | 10 | /> |
| 11 | <br> | 11 | <br> |
| 12 | </div> | 12 | </div> |
| 13 | <div class="modal-body"> | 13 | <div class="modal-body"> |
| 14 | <form class="row" name="formHojaRuta"> | 14 | <form class="row" name="formHojaRuta"> |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | <div class="col-2 form-group"> | 17 | <div class="col-2 form-group"> |
| 18 | <label>Vehículo</label> | 18 | <label>Vehículo</label> |
| 19 | </div> | 19 | </div> |
| 20 | <div class="col-4"> | 20 | <div class="col-4"> |
| 21 | <input | 21 | <input |
| 22 | class="form-control" | 22 | class="form-control" |
| 23 | readonly | 23 | readonly |
| 24 | ng-model="vehiculo.tractor" | 24 | ng-model="vehiculo.tractor" |
| 25 | > | 25 | > |
| 26 | </div> | 26 | </div> |
| 27 | <div class="col-2"> | 27 | <div class="col-2"> |
| 28 | <label>Transportista</label> | 28 | <label>Transportista</label> |
| 29 | </div> | 29 | </div> |
| 30 | <div class="col-4"> | 30 | <div class="col-4"> |
| 31 | <input | 31 | <input |
| 32 | class="form-control" | 32 | class="form-control" |
| 33 | readonly | 33 | readonly |
| 34 | ng-model="vehiculo.transportista.NOM" | 34 | ng-model="vehiculo.transportista.NOM" |
| 35 | > | 35 | > |
| 36 | </div> | 36 | </div> |
| 37 | <div class="col-2 form-group"> | 37 | <div class="col-2 form-group"> |
| 38 | <label>Chofer</label> | 38 | <label>Chofer</label> |
| 39 | </div> | 39 | </div> |
| 40 | <div class="col-4 input-group"> | 40 | <div class="col-4 input-group"> |
| 41 | <input | 41 | <input |
| 42 | class="form-control" | 42 | class="form-control" |
| 43 | ng-model="chofer.nombre" | 43 | ng-model="chofer.nombre" |
| 44 | ng-click="seleccionarChofer()" | 44 | ng-click="seleccionarChofer()" |
| 45 | ng-required="true" | 45 | ng-required="true" |
| 46 | > | 46 | > |
| 47 | <div class="input-group-append"> | 47 | <div class="input-group-append"> |
| 48 | <button | 48 | <button |
| 49 | class="brn btn-outline-secondary form-control" | 49 | class="brn btn-outline-secondary form-control" |
| 50 | ng-click="seleccionarChofer()" | 50 | ng-click="seleccionarChofer()" |
| 51 | ><i class="fa fa-search"></i> | 51 | ><i class="fa fa-search"></i> |
| 52 | </button> | 52 | </button> |
| 53 | </div> | 53 | </div> |
| 54 | </div> | 54 | </div> |
| 55 | <div class="col-2"> | 55 | <div class="col-2"> |
| 56 | <label>Tarifa</label> | 56 | <label>Tarifa</label> |
| 57 | </div> | 57 | </div> |
| 58 | <div class="col-4"> | 58 | <div class="col-4"> |
| 59 | <input | 59 | <input |
| 60 | class="form-control" | 60 | class="form-control" |
| 61 | ng-model="tarifaFlete" | 61 | ng-model="tarifaFlete" |
| 62 | ng-required="true" | 62 | ng-required="true" |
| 63 | foca-teclado | 63 | foca-teclado |
| 64 | foca-tipo-input | 64 | foca-tipo-input |
| 65 | > | 65 | > |
| 66 | </div> | 66 | </div> |
| 67 | </form> | 67 | </form> |
| 68 | <strong>Remitos:</strong> | 68 | <strong>Remitos:</strong> |
| 69 | <table class="table"> | 69 | <table class="table"> |
| 70 | <thead> | 70 | <thead> |
| 71 | <tr> | 71 | <tr> |
| 72 | <th>Remito Nº</th> | 72 | <th>Remito Nº</th> |
| 73 | <th>Cliente</th> | 73 | <th>Cliente</th> |
| 74 | <th>Domicilio</th> | 74 | <th>Domicilio</th> |
| 75 | </tr> | 75 | </tr> |
| 76 | </thead> | 76 | </thead> |
| 77 | <tbody> | 77 | <tbody> |
| 78 | <tr ng-show="!remitos.length"> | 78 | <tr ng-show="!remitos.length"> |
| 79 | <td colspan="3"> | 79 | <td colspan="3"> |
| 80 | No se han encontrado remitos. | 80 | No se han encontrado remitos. |
| 81 | </td> | 81 | </td> |
| 82 | </tr> | 82 | </tr> |
| 83 | <tr ng-repeat="remito in remitos"> | 83 | <tr ng-repeat="remito in remitos"> |
| 84 | <td ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante"></td> | 84 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> |
| 85 | <td ng-bind="remito.nombreCliente"></td> | 85 | <td ng-bind="remito.nombreCliente"></td> |
| 86 | <td ng-bind="remito.domicilioStamp"></td> | 86 | <td ng-bind="remito.domicilioStamp"></td> |
| 87 | </tr> | 87 | </tr> |
| 88 | </tbody> | 88 | </tbody> |
| 89 | </table> | 89 | </table> |
| 90 | </div> | 90 | </div> |
| 91 | <div class="modal-footer py-1"> | 91 | <div class="modal-footer py-1"> |
| 92 | <button | 92 | <button |
| 93 | class="btn btn-sm btn-secondary" | 93 | class="btn btn-sm btn-secondary" |
| 94 | ladda="cargando" | 94 | ladda="cargando" |
| 95 | type="button" | 95 | type="button" |
| 96 | ng-click="cancelar()">Cancelar</button> | 96 | ng-click="cancelar()">Cancelar</button> |
| 97 | <button | 97 | <button |
| 98 | class="btn btn-sm btn-primary" | 98 | class="btn btn-sm btn-primary" |
| 99 | ladda="cargando" | 99 | ladda="cargando" |
| 100 | type="button" | 100 | type="button" |
| 101 | ng-disabled="!formHojaRuta.$valid || !remitos.length" | 101 | ng-disabled="!formHojaRuta.$valid || !remitos.length" |
| 102 | ng-click="aceptar()">Crear hoja ruta</button> | 102 | ng-click="aceptar()">Crear hoja ruta</button> |
| 103 | </div> | 103 | </div> |
| 104 | 104 |