Commit dfbacd7cc26c62cda3746f9aedc2c96fbd4b10f3
1 parent
1f104c026b
Exists in
master
ok nombres plural
Showing
2 changed files
with
3 additions
and
3 deletions
Show diff stats
src/js/controller.js
| 1 | angular.module('focaEstadoCisternas') | 1 | angular.module('focaEstadoCisternas') |
| 2 | .controller('focaEstadoCisternasController', [ | 2 | .controller('focaEstadoCisternasController', [ |
| 3 | '$scope', 'focaEstadoCisternasService', '$location', 'focaModalService', | 3 | '$scope', 'focaEstadoCisternasService', '$location', 'focaModalService', |
| 4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', | 4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', |
| 5 | function($scope, focaEstadoCisternasService, $location, focaModalService, | 5 | function($scope, focaEstadoCisternasService, $location, focaModalService, |
| 6 | $uibModal, focaBotoneraLateralService, $timeout) { | 6 | $uibModal, focaBotoneraLateralService, $timeout) { |
| 7 | 7 | ||
| 8 | $scope.now = new Date(); | 8 | $scope.now = new Date(); |
| 9 | $scope.fecha = new Date(); | 9 | $scope.fecha = new Date(); |
| 10 | $scope.cisternas = []; | 10 | $scope.cisternas = []; |
| 11 | $scope.botonera = [{ | 11 | $scope.botonera = [{ |
| 12 | label: 'Transportista', | 12 | label: 'Transportista', |
| 13 | image: 'transportista.png' | 13 | image: 'transportista.png' |
| 14 | }, | 14 | }, |
| 15 | { | 15 | { |
| 16 | label: 'Vehiculo', | 16 | label: 'Vehiculo', |
| 17 | image: 'vehiculos.png' | 17 | image: 'vehiculos.png' |
| 18 | }, | 18 | }, |
| 19 | { | 19 | { |
| 20 | label: 'Fecha', | 20 | label: 'Fecha', |
| 21 | image: 'fechaDeReparto.png' | 21 | image: 'fechaDeReparto.png' |
| 22 | }]; | 22 | }]; |
| 23 | 23 | ||
| 24 | //SETEO BOTONERA LATERAL | 24 | //SETEO BOTONERA LATERAL |
| 25 | focaBotoneraLateralService.showSalir(true); | 25 | focaBotoneraLateralService.showSalir(true); |
| 26 | focaBotoneraLateralService.showPausar(false); | 26 | focaBotoneraLateralService.showPausar(false); |
| 27 | focaBotoneraLateralService.showCancelar(false); | 27 | focaBotoneraLateralService.showCancelar(false); |
| 28 | focaBotoneraLateralService.showGuardar(false); | 28 | focaBotoneraLateralService.showGuardar(false); |
| 29 | 29 | ||
| 30 | $timeout(function() { | 30 | $timeout(function() { |
| 31 | $scope.$broadcast('addCabecera',{ | 31 | $scope.$broadcast('addCabecera',{ |
| 32 | label: 'Fecha:', | 32 | label: 'Fecha:', |
| 33 | valor: $scope.fecha.toLocaleDateString() | 33 | valor: $scope.fecha.toLocaleDateString() |
| 34 | }); | 34 | }); |
| 35 | }); | 35 | }); |
| 36 | 36 | ||
| 37 | $scope.seleccionarTransportista = function() { | 37 | $scope.seleccionarTransportista = function() { |
| 38 | var modalInstance = $uibModal.open( | 38 | var modalInstance = $uibModal.open( |
| 39 | { | 39 | { |
| 40 | ariaLabelledBy: 'Busqueda de Transportista', | 40 | ariaLabelledBy: 'Busqueda de Transportista', |
| 41 | templateUrl: 'modal-proveedor.html', | 41 | templateUrl: 'modal-proveedor.html', |
| 42 | controller: 'focaModalProveedorCtrl', | 42 | controller: 'focaModalProveedorCtrl', |
| 43 | size: 'lg', | 43 | size: 'lg', |
| 44 | resolve: { | 44 | resolve: { |
| 45 | transportista: function() { | 45 | transportista: function() { |
| 46 | return true; | 46 | return true; |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | ); | 50 | ); |
| 51 | modalInstance.result.then( | 51 | modalInstance.result.then( |
| 52 | function(transportista) { | 52 | function(transportista) { |
| 53 | elegirTransportista(transportista); | 53 | elegirTransportista(transportista); |
| 54 | }, function() { | 54 | }, function() { |
| 55 | 55 | ||
| 56 | } | 56 | } |
| 57 | ); | 57 | ); |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | $scope.seleccionarVehiculo = function() { | 60 | $scope.seleccionarVehiculo = function() { |
| 61 | if(!$scope.idTransportista){ | 61 | if(!$scope.idTransportista){ |
| 62 | focaModalService.alert('Primero seleccione un transportista'); | 62 | focaModalService.alert('Primero seleccione un transportista'); |
| 63 | return; | 63 | return; |
| 64 | } | 64 | } |
| 65 | var query = '/vehiculo/transportista/' + $scope.idTransportista; | 65 | var query = '/vehiculo/transportista/' + $scope.idTransportista; |
| 66 | var columnas = { | 66 | var columnas = { |
| 67 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], | 67 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], |
| 68 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] | 68 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] |
| 69 | }; | 69 | }; |
| 70 | var titulo = 'Búsqueda de vehículos'; | 70 | var titulo = 'Búsqueda de vehículos'; |
| 71 | 71 | ||
| 72 | focaModalService.modal(columnas, query, titulo).then( | 72 | focaModalService.modal(columnas, query, titulo).then( |
| 73 | function(vehiculo) { | 73 | function(vehiculo) { |
| 74 | $scope.$broadcast('addCabecera', { | 74 | $scope.$broadcast('addCabecera', { |
| 75 | label: 'Vehículo:', | 75 | label: 'Vehículo:', |
| 76 | valor: vehiculo.codigo | 76 | valor: vehiculo.codigo |
| 77 | }); | 77 | }); |
| 78 | $scope.cisternas = vehiculo.cisternas; | 78 | $scope.cisternas = vehiculo.cisternas; |
| 79 | getEstadosCisternas($scope.cisternas); | 79 | getEstadosCisternas($scope.cisternas); |
| 80 | }, function() { | 80 | }, function() { |
| 81 | // funcion ejecutada cuando se cancela el modal | 81 | // funcion ejecutada cuando se cancela el modal |
| 82 | }); | 82 | }); |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | $scope.seleccionarFecha = function() { | 85 | $scope.seleccionarFecha = function() { |
| 86 | focaModalService.modalFecha('Fecha').then(function(fecha) { | 86 | focaModalService.modalFecha('Fecha').then(function(fecha) { |
| 87 | $scope.$broadcast('addCabecera',{ | 87 | $scope.$broadcast('addCabecera',{ |
| 88 | label: 'Fecha:', | 88 | label: 'Fecha:', |
| 89 | valor: fecha.toLocaleDateString() | 89 | valor: fecha.toLocaleDateString() |
| 90 | }); | 90 | }); |
| 91 | $scope.fecha = fecha; | 91 | $scope.fecha = fecha; |
| 92 | if($scope.cisternas) | 92 | if($scope.cisternas) |
| 93 | getEstadosCisternas($scope.cisternas); | 93 | getEstadosCisternas($scope.cisternas); |
| 94 | }); | 94 | }); |
| 95 | }; | 95 | }; |
| 96 | 96 | ||
| 97 | function elegirTransportista(transportista) { | 97 | function elegirTransportista(transportista) { |
| 98 | var codigo = ('00000' + transportista.COD).slice(-5); | 98 | var codigo = ('00000' + transportista.COD).slice(-5); |
| 99 | $scope.idTransportista = transportista.COD; | 99 | $scope.idTransportista = transportista.COD; |
| 100 | $scope.filtros = transportista.NOM.trim(); | 100 | $scope.filtros = transportista.NOM.trim(); |
| 101 | $scope.$broadcast('addCabecera', { | 101 | $scope.$broadcast('addCabecera', { |
| 102 | label: 'Transportista:', | 102 | label: 'Transportista:', |
| 103 | valor: codigo + ' - ' + transportista.NOM | 103 | valor: codigo + ' - ' + transportista.NOM |
| 104 | }); | 104 | }); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | function getEstadosCisternas(cisternas) { | 107 | function getEstadosCisternas(cisternas) { |
| 108 | cisternas.forEach(function(cisterna) { | 108 | cisternas.forEach(function(cisterna) { |
| 109 | focaEstadoCisternaService | 109 | focaEstadoCisternasService |
| 110 | .getEstadoCisterna(cisterna.id, $scope.fecha) | 110 | .getEstadoCisterna(cisterna.id, $scope.fecha) |
| 111 | .then(function(res) { | 111 | .then(function(res) { |
| 112 | cisterna.estado = res.data; | 112 | cisterna.estado = res.data; |
| 113 | }); | 113 | }); |
| 114 | }); | 114 | }); |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | ]); | 117 | ]); |
| 118 | 118 |
src/js/service.js
| 1 | angular.module('focaEstadoCisterna') | 1 | angular.module('focaEstadoCisternas') |
| 2 | .factory('focaEstadoCisternaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .factory('focaEstadoCisternasService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
| 3 | return { | 3 | return { |
| 4 | getVehiculos: function() { | 4 | getVehiculos: function() { |
| 5 | return $http.get(API_ENDPOINT.URL + '/vehiculo'); | 5 | return $http.get(API_ENDPOINT.URL + '/vehiculo'); |
| 6 | }, | 6 | }, |
| 7 | getTransportistas: function() { | 7 | getTransportistas: function() { |
| 8 | return $http.get(API_ENDPOINT.URL + '/transportista'); | 8 | return $http.get(API_ENDPOINT.URL + '/transportista'); |
| 9 | }, | 9 | }, |
| 10 | getCisternadoPorVehiculo: function(idVehiculo) { | 10 | getCisternadoPorVehiculo: function(idVehiculo) { |
| 11 | return $http.get(API_ENDPOINT.URL + '/cisterna/listar/' + idVehiculo); | 11 | return $http.get(API_ENDPOINT.URL + '/cisterna/listar/' + idVehiculo); |
| 12 | }, | 12 | }, |
| 13 | getCisterna: function(id) { | 13 | getCisterna: function(id) { |
| 14 | return $http.get(API_ENDPOINT.URL + '/cisterna/obtener/' + id); | 14 | return $http.get(API_ENDPOINT.URL + '/cisterna/obtener/' + id); |
| 15 | }, | 15 | }, |
| 16 | guardarCisterna: function(cisterna) { | 16 | guardarCisterna: function(cisterna) { |
| 17 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar', {cisterna: cisterna}); | 17 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar', {cisterna: cisterna}); |
| 18 | }, | 18 | }, |
| 19 | deleteCisterna: function(id) { | 19 | deleteCisterna: function(id) { |
| 20 | return $http.delete(API_ENDPOINT.URL + '/cisterna/borrar/' + id); | 20 | return $http.delete(API_ENDPOINT.URL + '/cisterna/borrar/' + id); |
| 21 | }, | 21 | }, |
| 22 | getVehiculosPorTransportista: function(id) { | 22 | getVehiculosPorTransportista: function(id) { |
| 23 | return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id); | 23 | return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id); |
| 24 | }, | 24 | }, |
| 25 | getEstadoCisterna: function(id, fecha) { | 25 | getEstadoCisterna: function(id, fecha) { |
| 26 | return $http.post(API_ENDPOINT.URL + '/cisterna/stock', | 26 | return $http.post(API_ENDPOINT.URL + '/cisterna/stock', |
| 27 | {idCisterna: id, fecha: fecha}); | 27 | {idCisterna: id, fecha: fecha}); |
| 28 | } | 28 | } |
| 29 | }; | 29 | }; |
| 30 | }]); | 30 | }]); |
| 31 | 31 |