Commit 30faa1e57c5a7f21eb6fa71b1f5303e9cdc16c98
1 parent
41d9bb98c3
Exists in
master
code review
Showing
2 changed files
with
3 additions
and
3 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', '$cookies', |
| 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, |
| 5 | focaModalService, focaBotoneraLateralService, $cookies | 5 | focaModalService, focaBotoneraLateralService, $cookies |
| 6 | ) { | 6 | ) { |
| 7 | $scope.now = new Date(); | 7 | $scope.now = new Date(); |
| 8 | $scope.actividad = 'Logistica'; | 8 | $scope.actividad = 'Logistica'; |
| 9 | 9 | ||
| 10 | //Datos Pantalla | 10 | //Datos Pantalla |
| 11 | $scope.titulo = 'Logistica de Pedidos'; | 11 | $scope.titulo = 'Logistica de Pedidos'; |
| 12 | $scope.botonera = ['Vehiculo']; | 12 | $scope.botonera = ['Vehiculo']; |
| 13 | var cabecera = ''; | 13 | var cabecera = ''; |
| 14 | 14 | ||
| 15 | $scope.idVendedor = 0; | 15 | $scope.idVendedor = 0; |
| 16 | $scope.marcadores = []; | 16 | $scope.marcadores = []; |
| 17 | $scope.vehiculos = []; | 17 | $scope.vehiculos = []; |
| 18 | getSeguimiento(); | 18 | getSeguimiento(); |
| 19 | $scope.arrastrando = false; | 19 | $scope.arrastrando = false; |
| 20 | $scope.general = function() { | 20 | $scope.general = function() { |
| 21 | $scope.idVendedor = 0; | 21 | $scope.idVendedor = 0; |
| 22 | getSeguimiento(); | 22 | getSeguimiento(); |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | //SETEO BOTONERA LATERAL | 25 | //SETEO BOTONERA LATERAL |
| 26 | focaBotoneraLateralService.showSalir(true); | 26 | focaBotoneraLateralService.showSalir(true); |
| 27 | focaBotoneraLateralService.showPausar(false); | 27 | focaBotoneraLateralService.showPausar(false); |
| 28 | focaBotoneraLateralService.showGuardar(false); | 28 | focaBotoneraLateralService.showGuardar(false); |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | $scope.general = function() { | 31 | $scope.general = function() { |
| 32 | $scope.idVendedor = 0; | 32 | $scope.idVendedor = 0; |
| 33 | getSeguimiento(); | 33 | getSeguimiento(); |
| 34 | $scope.$broadcast('removeCabecera', cabecera); | 34 | $scope.$broadcast('removeCabecera', cabecera); |
| 35 | $scope.$broadcast('addCabecera',{ | 35 | $scope.$broadcast('addCabecera',{ |
| 36 | label: 'General', | 36 | label: 'General', |
| 37 | valor: '' | 37 | valor: '' |
| 38 | }); | 38 | }); |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | $scope.cargar = function(idVehiculo, punto) { | 41 | $scope.cargar = function(idVehiculo, punto) { |
| 42 | var idRemito = JSON.parse(punto).notaPedido.remito.id; | 42 | var idRemito = JSON.parse(punto).notaPedido.remito.id; |
| 43 | var modalInstance = $uibModal.open( | 43 | var modalInstance = $uibModal.open( |
| 44 | { | 44 | { |
| 45 | ariaLabelledBy: 'Busqueda de Vehiculo', | 45 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 46 | templateUrl: 'foca-detalle-vehiculo.html', | 46 | templateUrl: 'foca-detalle-vehiculo.html', |
| 47 | controller: 'focaDetalleVehiculo', | 47 | controller: 'focaDetalleVehiculo', |
| 48 | size: 'lg', | 48 | size: 'lg', |
| 49 | resolve: { | 49 | resolve: { |
| 50 | idVehiculo: function() {return idVehiculo;}, | 50 | idVehiculo: function() {return idVehiculo;}, |
| 51 | idRemito: function() {return idRemito;} | 51 | idRemito: function() {return idRemito;} |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | ); | 54 | ); |
| 55 | modalInstance.result.then(function() { | 55 | modalInstance.result.then(function() { |
| 56 | }, function() { | 56 | }, function() { |
| 57 | }); | 57 | }); |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | $scope.quitarVehiculo = function(vehiculo) { | 60 | $scope.quitarVehiculo = function(vehiculo) { |
| 61 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 61 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
| 62 | vehiculo.codigo + '?').then(function() { | 62 | vehiculo.codigo + '?').then(function() { |
| 63 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 63 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
| 64 | }); | 64 | }); |
| 65 | }; | 65 | }; |
| 66 | 66 | ||
| 67 | $scope.hacerHojaRuta = function(vehiculo) { | 67 | $scope.hacerHojaRuta = function(vehiculo) { |
| 68 | var modalInstance = $uibModal.open( | 68 | var modalInstance = $uibModal.open( |
| 69 | { | 69 | { |
| 70 | ariaLabelledBy: 'Creación hoja ruta', | 70 | ariaLabelledBy: 'Creación hoja ruta', |
| 71 | templateUrl: 'foca-modal-crear-hoja-ruta.html', | 71 | templateUrl: 'foca-modal-crear-hoja-ruta.html', |
| 72 | controller: 'focaModalCrearHojaRuta', | 72 | controller: 'focaModalCrearHojaRuta', |
| 73 | size: 'lg', | 73 | size: 'lg', |
| 74 | resolve: { | 74 | resolve: { |
| 75 | idVehiculo: function() {return vehiculo.id;} | 75 | idVehiculo: function() {return vehiculo.id;} |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | ); | 78 | ); |
| 79 | modalInstance.result.then(function() { | 79 | modalInstance.result.then(function() { |
| 80 | 80 | ||
| 81 | }, function() { | 81 | }, function() { |
| 82 | //usar cuando se cancela el modal | 82 | //usar cuando se cancela el modal |
| 83 | }); | 83 | }); |
| 84 | }; | 84 | }; |
| 85 | 85 | ||
| 86 | $scope.arrastra = function() { | 86 | $scope.arrastra = function() { |
| 87 | $scope.arrastrando = true; | 87 | $scope.arrastrando = true; |
| 88 | $scope.$digest(); | 88 | $scope.$digest(); |
| 89 | }; | 89 | }; |
| 90 | 90 | ||
| 91 | $scope.noArrastra = function() { | 91 | $scope.noArrastra = function() { |
| 92 | $scope.arrastrando = false; | 92 | $scope.arrastrando = false; |
| 93 | $scope.$digest(); | 93 | $scope.$digest(); |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | $scope.individual = function() { | 96 | $scope.individual = function() { |
| 97 | $scope.idVendedor = -1; | 97 | $scope.idVendedor = -1; |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | $scope.mostrarDetalle = function() { | 100 | $scope.mostrarDetalle = function() { |
| 101 | $scope.detalle = true; | 101 | $scope.detalle = true; |
| 102 | }; | 102 | }; |
| 103 | 103 | ||
| 104 | $scope.salir = function() { | 104 | $scope.salir = function() { |
| 105 | $location.path('/'); | 105 | $location.path('/'); |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | $scope.search = function(key) { | 108 | $scope.search = function(key) { |
| 109 | if (key === 13) { | 109 | if (key === 13) { |
| 110 | $scope.idVendedor = $scope.idVendedorInput; | 110 | $scope.idVendedor = $scope.idVendedorInput; |
| 111 | getSeguimiento(); | 111 | getSeguimiento(); |
| 112 | $scope.$broadcast('removeCabecera', 'General'); | 112 | $scope.$broadcast('removeCabecera', 'General'); |
| 113 | $scope.$broadcast('addCabecera', { | 113 | $scope.$broadcast('addCabecera', { |
| 114 | label: cabecera, | 114 | label: cabecera, |
| 115 | valor: $scope.idVendedorInput | 115 | valor: $scope.idVendedorInput |
| 116 | }); | 116 | }); |
| 117 | } | 117 | } |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | $scope.fecha = function() { | 120 | $scope.fecha = function() { |
| 121 | getSeguimiento(); | 121 | getSeguimiento(); |
| 122 | }; | 122 | }; |
| 123 | 123 | ||
| 124 | $scope.seleccionarVehiculo = function() { | 124 | $scope.seleccionarVehiculo = function() { |
| 125 | var modalInstance = $uibModal.open( | 125 | var modalInstance = $uibModal.open( |
| 126 | { | 126 | { |
| 127 | ariaLabelledBy: 'Busqueda de Vehiculo', | 127 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 128 | templateUrl: 'modal-vehiculo.html', | 128 | templateUrl: 'modal-vehiculo.html', |
| 129 | controller: 'focaModalVehiculoController', | 129 | controller: 'focaModalVehiculoController', |
| 130 | size: 'lg' | 130 | size: 'lg' |
| 131 | } | 131 | } |
| 132 | ); | 132 | ); |
| 133 | 133 | ||
| 134 | modalInstance.result.then( | 134 | modalInstance.result.then( |
| 135 | function(vehiculo) { | 135 | function(vehiculo) { |
| 136 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 136 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
| 137 | if(existe.length) { | 137 | if(existe.length) { |
| 138 | focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado'); | 138 | focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado'); |
| 139 | return; | 139 | return; |
| 140 | } | 140 | } |
| 141 | if(!vehiculo.cisternas.length) { | 141 | if(!vehiculo.cisternas.length) { |
| 142 | focaModalService.alert('El vehiculo no tiene cisternas'); | 142 | focaModalService.alert('El vehiculo no tiene cisternas'); |
| 143 | return; | 143 | return; |
| 144 | } | 144 | } |
| 145 | $scope.vehiculos.push(vehiculo); | 145 | $scope.vehiculos.push(vehiculo); |
| 146 | }, function() { | 146 | }, function() { |
| 147 | // funcion ejecutada cuando se cancela el modal | 147 | // funcion ejecutada cuando se cancela el modal |
| 148 | } | 148 | } |
| 149 | ); | 149 | ); |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | function getSeguimiento() { | 152 | function getSeguimiento() { |
| 153 | var now = $scope.now; | 153 | var now = $scope.now; |
| 154 | var desde = new Date(new Date(now.setHours(0)).setMinutes(0)); | 154 | var desde = new Date(new Date(now.setHours(0)).setMinutes(0)); |
| 155 | desde = desde.setDate(desde.getDate() - 1); | 155 | desde = desde.setDate(desde.getDate() - 1); |
| 156 | desde = new Date(desde); | 156 | desde = new Date(desde); |
| 157 | var datos = { | 157 | var datos = { |
| 158 | actividad: $scope.actividad, | 158 | actividad: $scope.actividad, |
| 159 | idUsuario: $scope.idVendedor, | 159 | idUsuario: $scope.idVendedor, |
| 160 | fechaDesde: desde, | 160 | fechaDesde: desde, |
| 161 | fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) | 161 | fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) |
| 162 | }; | 162 | }; |
| 163 | 163 | ||
| 164 | $scope.datosBuscados = { | 164 | $scope.datosBuscados = { |
| 165 | actividad: $scope.actividad, | 165 | actividad: $scope.actividad, |
| 166 | individual: $scope.idVendedor !== 0 ? true : false | 166 | individual: $scope.idVendedor ? true : false |
| 167 | }; | 167 | }; |
| 168 | 168 | ||
| 169 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 169 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
| 170 | $scope.marcadores = datos.data; | 170 | $scope.marcadores = datos.data; |
| 171 | }); | 171 | }); |
| 172 | } | 172 | } |
| 173 | } | 173 | } |
| 174 | ]); | 174 | ]); |
| 175 | 175 |
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 | for(var i = 0; i < res.data.cisternas.length; i++) { |
| 21 | for (var j = 0; j < res.data.cisternas[i].cisternaCarga.cisternaMovimientos.length; | 21 | for(var j = 0; j < res.data.cisternas[i].cisternaCarga.cisternaMovimientos.length; |
| 22 | j++) { | 22 | j++) { |
| 23 | if(!!res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito && | 23 | if(!!res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito && |
| 24 | !res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito | 24 | !res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito |
| 25 | .idHojaRuta) { | 25 | .idHojaRuta) { |
| 26 | var remito = res.data.cisternas[i].cisternaCarga | 26 | var remito = res.data.cisternas[i].cisternaCarga |
| 27 | .cisternaMovimientos[j].remito; | 27 | .cisternaMovimientos[j].remito; |
| 28 | var yaEstaCargado = $filter('filter')($scope.remitos, {id: remito.id}); | 28 | var yaEstaCargado = $filter('filter')($scope.remitos, {id: remito.id}); |
| 29 | if(!yaEstaCargado.length && | 29 | if(!yaEstaCargado.length && |
| 30 | res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].metodo === | 30 | res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].metodo === |
| 31 | 'carga') { | 31 | 'carga') { |
| 32 | $scope.remitos.push(remito); | 32 | $scope.remitos.push(remito); |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | } | 36 | } |
| 37 | }); | 37 | }); |
| 38 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { | 38 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
| 39 | $scope.sucursal = res.data.sucursal; | 39 | $scope.sucursal = res.data.sucursal; |
| 40 | $scope.numero = res.data.numeroHojaRuta; | 40 | $scope.numero = res.data.numeroHojaRuta; |
| 41 | }); | 41 | }); |
| 42 | $scope.cancelar = function() { | 42 | $scope.cancelar = function() { |
| 43 | $uibModalInstance.close(); | 43 | $uibModalInstance.close(); |
| 44 | }; | 44 | }; |
| 45 | $scope.aceptar = function() { | 45 | $scope.aceptar = function() { |
| 46 | var save = { | 46 | var save = { |
| 47 | hojaRuta: { | 47 | hojaRuta: { |
| 48 | id: 0, | 48 | id: 0, |
| 49 | fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 49 | fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
| 50 | idTransportista: $scope.vehiculo.idTransportista, | 50 | idTransportista: $scope.vehiculo.idTransportista, |
| 51 | idChofer: $scope.chofer.id, | 51 | idChofer: $scope.chofer.id, |
| 52 | idVehiculo: $scope.vehiculo.id, | 52 | idVehiculo: $scope.vehiculo.id, |
| 53 | tarifaFlete: $scope.tarifaFlete | 53 | tarifaFlete: $scope.tarifaFlete |
| 54 | }, | 54 | }, |
| 55 | remitos: $scope.remitos, | 55 | remitos: $scope.remitos, |
| 56 | idVehiculo: $scope.vehiculo.id | 56 | idVehiculo: $scope.vehiculo.id |
| 57 | }; | 57 | }; |
| 58 | focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { | 58 | focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { |
| 59 | $uibModalInstance.close(); | 59 | $uibModalInstance.close(); |
| 60 | focaModalService.alert('Hoja de ruta guardada con éxito'); | 60 | focaModalService.alert('Hoja de ruta guardada con éxito'); |
| 61 | }); | 61 | }); |
| 62 | }; | 62 | }; |
| 63 | $scope.seleccionarChofer = function() { | 63 | $scope.seleccionarChofer = function() { |
| 64 | var modalInstance = $uibModal.open( | 64 | var modalInstance = $uibModal.open( |
| 65 | { | 65 | { |
| 66 | ariaLabelledBy: 'Busqueda de Chofer', | 66 | ariaLabelledBy: 'Busqueda de Chofer', |
| 67 | templateUrl: 'modal-chofer.html', | 67 | templateUrl: 'modal-chofer.html', |
| 68 | controller: 'focaModalChoferController', | 68 | controller: 'focaModalChoferController', |
| 69 | size: 'lg' | 69 | size: 'lg' |
| 70 | } | 70 | } |
| 71 | ); | 71 | ); |
| 72 | 72 | ||
| 73 | modalInstance.result.then( | 73 | modalInstance.result.then( |
| 74 | function(chofer) { | 74 | function(chofer) { |
| 75 | $scope.chofer = chofer; | 75 | $scope.chofer = chofer; |
| 76 | }, function() { | 76 | }, function() { |
| 77 | // funcion ejecutada cuando se cancela el modal | 77 | // funcion ejecutada cuando se cancela el modal |
| 78 | } | 78 | } |
| 79 | ); | 79 | ); |
| 80 | }; | 80 | }; |
| 81 | }]); | 81 | }]); |
| 82 | 82 |