Commit 9863e8cf121cbfd09e41ccfb435e886dec7907bc
1 parent
dfec27a773
Exists in
master
and in
1 other branch
fuera boton transportista, ok boton vehiculo
Showing
3 changed files
with
24 additions
and
35 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', 'focaModalService', | 3 | '$scope', 'focaEstadoCisternasService', 'focaModalService', |
4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', | 4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', |
5 | function($scope, focaEstadoCisternasService, focaModalService, | 5 | function($scope, focaEstadoCisternasService, 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 = focaEstadoCisternasService.getBotonera(); | 11 | $scope.botonera = focaEstadoCisternasService.getBotonera(); |
12 | 12 | ||
13 | //SETEO BOTONERA LATERAL | 13 | //SETEO BOTONERA LATERAL |
14 | focaBotoneraLateralService.showSalir(true); | 14 | focaBotoneraLateralService.showSalir(true); |
15 | focaBotoneraLateralService.showPausar(false); | 15 | focaBotoneraLateralService.showPausar(false); |
16 | focaBotoneraLateralService.showCancelar(false); | 16 | focaBotoneraLateralService.showCancelar(false); |
17 | focaBotoneraLateralService.showGuardar(false); | 17 | focaBotoneraLateralService.showGuardar(false); |
18 | 18 | ||
19 | $timeout(function() { | 19 | $timeout(function() { |
20 | $scope.$broadcast('addCabecera', { | 20 | $scope.$broadcast('addCabecera', { |
21 | label: 'Fecha:', | 21 | label: 'Fecha:', |
22 | valor: $scope.fecha.toLocaleDateString() | 22 | valor: $scope.fecha.toLocaleDateString() |
23 | }); | 23 | }); |
24 | }); | 24 | }); |
25 | 25 | ||
26 | $scope.seleccionarTransportista = function() { | 26 | $scope.seleccionarTransportista = function() { |
27 | var modalInstance = $uibModal.open( | 27 | var modalInstance = $uibModal.open( |
28 | { | 28 | { |
29 | ariaLabelledBy: 'Busqueda de Transportista', | 29 | ariaLabelledBy: 'Busqueda de Transportista', |
30 | templateUrl: 'modal-proveedor.html', | 30 | templateUrl: 'modal-proveedor.html', |
31 | controller: 'focaModalProveedorCtrl', | 31 | controller: 'focaModalProveedorCtrl', |
32 | size: 'lg', | 32 | size: 'lg', |
33 | resolve: { | 33 | resolve: { |
34 | transportista: function() { | 34 | transportista: function() { |
35 | return true; | 35 | return true; |
36 | } | 36 | } |
37 | } | 37 | } |
38 | } | 38 | } |
39 | ); | 39 | ); |
40 | modalInstance.result.then( | 40 | return modalInstance.result; |
41 | function(transportista) { | ||
42 | elegirTransportista(transportista); | ||
43 | }, function() { | ||
44 | |||
45 | } | ||
46 | ); | ||
47 | }; | 41 | }; |
48 | 42 | ||
49 | $scope.seleccionarVehiculo = function() { | 43 | $scope.seleccionarVehiculo = function() { |
50 | if(!$scope.idTransportista) { | 44 | $scope.seleccionarTransportista().then( |
51 | focaModalService.alert('Primero seleccione un transportista'); | 45 | function(transportista) { |
52 | return; | 46 | elegirTransportista(transportista); |
53 | } | ||
54 | var query = '/vehiculo/transportista/' + $scope.idTransportista; | ||
55 | var columnas = { | ||
56 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], | ||
57 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] | ||
58 | }; | ||
59 | var titulo = 'Búsqueda de vehículos'; | ||
60 | 47 | ||
61 | focaModalService.modal(columnas, query, titulo).then( | 48 | var query = '/vehiculo/transportista/' + $scope.idTransportista; |
62 | function(vehiculo) { | 49 | var columnas = { |
63 | $scope.$broadcast('addCabecera', { | 50 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], |
64 | label: 'Vehículo:', | 51 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] |
65 | valor: vehiculo.codigo | 52 | }; |
66 | }); | 53 | var titulo = 'Búsqueda de vehículos'; |
67 | $scope.cisternas = vehiculo.cisternas; | 54 | |
68 | getEstadosCisternas($scope.cisternas); | 55 | focaModalService.modal(columnas, query, titulo).then( |
69 | }, function() { | 56 | function(vehiculo) { |
70 | // funcion ejecutada cuando se cancela el modal | 57 | $scope.$broadcast('addCabecera', { |
71 | }); | 58 | label: 'Vehículo:', |
59 | valor: vehiculo.codigo | ||
60 | }); | ||
61 | $scope.cisternas = vehiculo.cisternas; | ||
62 | getEstadosCisternas($scope.cisternas); | ||
63 | }, function() {}); | ||
64 | }, function() {}); | ||
72 | }; | 65 | }; |
73 | 66 | ||
74 | $scope.seleccionarFecha = function() { | 67 | $scope.seleccionarFechaEntrega = function() { |
75 | focaModalService.modalFecha('Fecha').then(function(fecha) { | 68 | focaModalService.modalFecha('Fecha').then(function(fecha) { |
76 | $scope.$broadcast('addCabecera', { | 69 | $scope.$broadcast('addCabecera', { |
77 | label: 'Fecha:', | 70 | label: 'Fecha:', |
78 | valor: fecha.toLocaleDateString() | 71 | valor: fecha.toLocaleDateString() |
79 | }); | 72 | }); |
80 | $scope.fecha = fecha; | 73 | $scope.fecha = fecha; |
81 | if($scope.cisternas) | 74 | if($scope.cisternas) |
82 | getEstadosCisternas($scope.cisternas); | 75 | getEstadosCisternas($scope.cisternas); |
83 | }); | 76 | }); |
84 | }; | 77 | }; |
85 | 78 | ||
86 | $scope.seleccionarGrafico = function() { | 79 | $scope.seleccionarGrafico = function() { |
87 | if(!$scope.cisternas.length){ | 80 | if(!$scope.cisternas.length){ |
88 | focaModalService.alert('Primero seleccione un vehículo'); | 81 | focaModalService.alert('Primero seleccione un vehículo'); |
89 | return; | 82 | return; |
90 | } | 83 | } |
91 | $uibModal.open( | 84 | $uibModal.open( |
92 | { | 85 | { |
93 | ariaLabelledBy: 'Grafico de cisternas', | 86 | ariaLabelledBy: 'Grafico de cisternas', |
94 | templateUrl: 'modal-grafico-cisternas.html', | 87 | templateUrl: 'modal-grafico-cisternas.html', |
95 | controller: 'focaModalGraficoCisternasController', | 88 | controller: 'focaModalGraficoCisternasController', |
96 | size: 'md', | 89 | size: 'md', |
97 | resolve:{ | 90 | resolve:{ |
98 | filters: { | 91 | filters: { |
99 | cisternas: $scope.cisternas | 92 | cisternas: $scope.cisternas |
100 | } | 93 | } |
101 | } | 94 | } |
102 | } | 95 | } |
103 | ); | 96 | ); |
104 | }; | 97 | }; |
105 | 98 | ||
106 | function elegirTransportista(transportista) { | 99 | function elegirTransportista(transportista) { |
107 | var codigo = ('00000' + transportista.COD).slice(-5); | 100 | var codigo = ('00000' + transportista.COD).slice(-5); |
108 | $scope.idTransportista = transportista.COD; | 101 | $scope.idTransportista = transportista.COD; |
109 | $scope.filtros = transportista.NOM.trim(); | 102 | $scope.filtros = transportista.NOM.trim(); |
110 | $scope.$broadcast('addCabecera', { | 103 | $scope.$broadcast('addCabecera', { |
111 | label: 'Transportista:', | 104 | label: 'Transportista:', |
112 | valor: codigo + ' - ' + transportista.NOM | 105 | valor: codigo + ' - ' + transportista.NOM |
113 | }); | 106 | }); |
114 | } | 107 | } |
115 | 108 | ||
116 | function getEstadosCisternas(cisternas) { | 109 | function getEstadosCisternas(cisternas) { |
117 | cisternas.forEach(function(cisterna) { | 110 | cisternas.forEach(function(cisterna) { |
118 | focaEstadoCisternasService | 111 | focaEstadoCisternasService |
119 | .getEstadoCisterna(cisterna.id, $scope.fecha) | 112 | .getEstadoCisterna(cisterna.id, $scope.fecha) |
120 | .then(function(res) { | 113 | .then(function(res) { |
121 | cisterna.estado = res.data; | 114 | cisterna.estado = res.data; |
src/js/service.js
1 | angular.module('focaEstadoCisternas') | 1 | angular.module('focaEstadoCisternas') |
2 | .factory('focaEstadoCisternasService', ['$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 | getBotonera: function() { | 29 | getBotonera: function() { |
30 | return [ | 30 | return [ |
31 | { | 31 | { |
32 | label: 'Transportista', | ||
33 | image: 'transportista.png' | ||
34 | }, | ||
35 | { | ||
36 | label: 'Vehiculo', | 32 | label: 'Vehiculo', |
37 | image: 'vehiculos.png' | 33 | image: 'vehiculos.png' |
38 | }, | 34 | }, |
39 | { | 35 | { |
40 | label: 'Fecha', | 36 | label: 'Fecha entrega', |
41 | image: 'fechaDeReparto.png' | 37 | image: 'fechaDeReparto.png' |
42 | }, | 38 | }, |
43 | { | 39 | { |
44 | label: 'Grafico', | 40 | label: 'Grafico', |
45 | image: 'fechaDeReparto.png' | 41 | image: 'fechaDeReparto.png' |
46 | } | 42 | } |
47 | ]; | 43 | ]; |
48 | } | 44 | } |
49 | }; | 45 | }; |
50 | }]); | 46 | }]); |
51 | 47 |
src/views/foca-estado-cisterna.html
1 | <div class="row"> | 1 | <div class="row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Estado de cisternas'" | 3 | titulo="'Estado de cisternas'" |
4 | fecha="now" | 4 | fecha="now" |
5 | class="mb-0 col-lg-12" | 5 | class="mb-0 col-lg-12" |
6 | ></foca-cabecera-facturador> | 6 | ></foca-cabecera-facturador> |
7 | </div> | 7 | </div> |
8 | <div class="row"> | 8 | <div class="row"> |
9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> |
10 | <div class="row px-5 py-2 botonera-secundaria"> | 10 | <div class="row px-5 py-2 botonera-secundaria"> |
11 | <div class="col-12"> | 11 | <div class="col-12"> |
12 | <foca-botonera-facturador botones="botonera" extra="2" class="row"> | 12 | <foca-botonera-facturador botones="botonera" extra="3" class="row"> |
13 | </foca-botonera-facturador> | 13 | </foca-botonera-facturador> |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | 16 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> |
17 | <thead> | 17 | <thead> |
18 | <tr> | 18 | <tr> |
19 | <th>Código</th> | 19 | <th>Código</th> |
20 | <th>Capacidad total</th> | 20 | <th>Capacidad total</th> |
21 | <th>Carga</th> | 21 | <th>Carga</th> |
22 | <th>Disponible</th> | 22 | <th>Disponible</th> |
23 | <th>Producto</th> | 23 | <th>Producto</th> |
24 | </tr> | 24 | </tr> |
25 | </thead> | 25 | </thead> |
26 | <tbody> | 26 | <tbody> |
27 | <tr ng-repeat="cisterna in cisternas"> | 27 | <tr ng-repeat="cisterna in cisternas"> |
28 | <td ng-bind="cisterna.codigo"></td> | 28 | <td ng-bind="cisterna.codigo"></td> |
29 | <td ng-bind="cisterna.capacidad + ' ' + cisterna.unidadMedida.NOM"></td> | 29 | <td ng-bind="cisterna.capacidad + ' ' + cisterna.unidadMedida.NOM"></td> |
30 | <td ng-bind="cisterna.estado.cantidad"></td> | 30 | <td ng-bind="cisterna.estado.cantidad"></td> |
31 | <td ng-bind="cisterna.capacidad - cisterna.estado.cantidad"></td> | 31 | <td ng-bind="cisterna.capacidad - cisterna.estado.cantidad"></td> |
32 | <td ng-bind="(cisterna.estado.producto) ? cisterna.estado.producto.DetArt : '-'"></td> | 32 | <td ng-bind="(cisterna.estado.producto) ? cisterna.estado.producto.DetArt : '-'"></td> |
33 | </tr> | 33 | </tr> |
34 | </body> | 34 | </body> |
35 | </table> | 35 | </table> |
36 | </div> | 36 | </div> |
37 | </div> | 37 | </div> |
38 | 38 |