Commit c7154c2464d3772cbe9e174ddbb9aa77cfe24f01

Authored by Eric Fernandez
1 parent ebe4fe357b
Exists in master

nueva botonera

Showing 1 changed file with 5 additions and 1 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', '$interval', 3 'focaModalService', 'focaBotoneraLateralService', '$interval',
4 function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, 4 function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter,
5 focaModalService, focaBotoneraLateralService, $interval 5 focaModalService, focaBotoneraLateralService, $interval
6 ) { 6 ) {
7 $scope.actividad = 'Logistica'; 7 $scope.actividad = 'Logistica';
8 8
9 //Datos Pantalla 9 //Datos Pantalla
10 $scope.titulo = 'Logistica de Pedidos'; 10 $scope.titulo = 'Logistica de Pedidos';
11 $scope.botonera = ['Transportista']; 11 var transportista = {
12 label: 'transportista',
13 image: 'abmChofer.png'
14 };
15 $scope.botonera = [transportista];
12 var cabecera = ''; 16 var cabecera = '';
13 $scope.now = new Date(); 17 $scope.now = new Date();
14 $scope.idVendedor = 0; 18 $scope.idVendedor = 0;
15 $scope.marcadores = []; 19 $scope.marcadores = [];
16 $scope.vehiculos = []; 20 $scope.vehiculos = [];
17 getSeguimiento(); 21 getSeguimiento();
18 $scope.arrastrando = false; 22 $scope.arrastrando = false;
19 $scope.general = function() { 23 $scope.general = function() {
20 $scope.idVendedor = 0; 24 $scope.idVendedor = 0;
21 getSeguimiento(); 25 getSeguimiento();
22 }; 26 };
23 27
24 //SETEO BOTONERA LATERAL 28 //SETEO BOTONERA LATERAL
25 focaBotoneraLateralService.showSalir(true); 29 focaBotoneraLateralService.showSalir(true);
26 focaBotoneraLateralService.showPausar(false); 30 focaBotoneraLateralService.showPausar(false);
27 focaBotoneraLateralService.showGuardar(false); 31 focaBotoneraLateralService.showGuardar(false);
28 32
29 focaLogisticaPedidoRutaService.getVehiculosByIdUsuario().then(function(res) { 33 focaLogisticaPedidoRutaService.getVehiculosByIdUsuario().then(function(res) {
30 $scope.vehiculos = res.data; 34 $scope.vehiculos = res.data;
31 }); 35 });
32 36
33 $scope.general = function() { 37 $scope.general = function() {
34 $scope.idVendedor = 0; 38 $scope.idVendedor = 0;
35 getSeguimiento(); 39 getSeguimiento();
36 $scope.$broadcast('removeCabecera', cabecera); 40 $scope.$broadcast('removeCabecera', cabecera);
37 $scope.$broadcast('addCabecera',{ 41 $scope.$broadcast('addCabecera',{
38 label: 'General', 42 label: 'General',
39 valor: '' 43 valor: ''
40 }); 44 });
41 }; 45 };
42 46
43 $scope.cargar = function(idVehiculo, punto) { 47 $scope.cargar = function(idVehiculo, punto) {
44 var idRemito; 48 var idRemito;
45 if(punto === -1) { 49 if(punto === -1) {
46 idRemito = -1; 50 idRemito = -1;
47 }else { 51 }else {
48 idRemito = JSON.parse(punto).notaPedido.remito.id; 52 idRemito = JSON.parse(punto).notaPedido.remito.id;
49 } 53 }
50 var modalInstance = $uibModal.open( 54 var modalInstance = $uibModal.open(
51 { 55 {
52 ariaLabelledBy: 'Busqueda de Vehiculo', 56 ariaLabelledBy: 'Busqueda de Vehiculo',
53 templateUrl: 'foca-detalle-vehiculo.html', 57 templateUrl: 'foca-detalle-vehiculo.html',
54 controller: 'focaDetalleVehiculo', 58 controller: 'focaDetalleVehiculo',
55 size: 'lg', 59 size: 'lg',
56 resolve: { 60 resolve: {
57 idVehiculo: function() {return idVehiculo;}, 61 idVehiculo: function() {return idVehiculo;},
58 idRemito: function() {return idRemito;} 62 idRemito: function() {return idRemito;}
59 } 63 }
60 } 64 }
61 ); 65 );
62 modalInstance.result.then(function() { 66 modalInstance.result.then(function() {
63 }, function() { 67 }, function() {
64 }); 68 });
65 }; 69 };
66 70
67 $scope.quitarVehiculo = function(vehiculo) { 71 $scope.quitarVehiculo = function(vehiculo) {
68 focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + 72 focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' +
69 vehiculo.codigo + '?').then(function() { 73 vehiculo.codigo + '?').then(function() {
70 eliminarVehiculo(vehiculo); 74 eliminarVehiculo(vehiculo);
71 }); 75 });
72 }; 76 };
73 77
74 $scope.hacerHojaRuta = function(vehiculo) { 78 $scope.hacerHojaRuta = function(vehiculo) {
75 var modalInstance = $uibModal.open( 79 var modalInstance = $uibModal.open(
76 { 80 {
77 ariaLabelledBy: 'Creación hoja ruta', 81 ariaLabelledBy: 'Creación hoja ruta',
78 templateUrl: 'foca-modal-crear-hoja-ruta.html', 82 templateUrl: 'foca-modal-crear-hoja-ruta.html',
79 controller: 'focaModalCrearHojaRuta', 83 controller: 'focaModalCrearHojaRuta',
80 size: 'lg', 84 size: 'lg',
81 resolve: { 85 resolve: {
82 idVehiculo: function() {return vehiculo.id;} 86 idVehiculo: function() {return vehiculo.id;}
83 } 87 }
84 } 88 }
85 ); 89 );
86 modalInstance.result.then(function() { 90 modalInstance.result.then(function() {
87 91
88 }, function() { 92 }, function() {
89 //usar cuando se cancela el modal 93 //usar cuando se cancela el modal
90 }); 94 });
91 }; 95 };
92 96
93 $scope.arrastra = function() { 97 $scope.arrastra = function() {
94 $scope.arrastrando = true; 98 $scope.arrastrando = true;
95 $scope.$digest(); 99 $scope.$digest();
96 }; 100 };
97 101
98 $scope.noArrastra = function() { 102 $scope.noArrastra = function() {
99 $scope.arrastrando = false; 103 $scope.arrastrando = false;
100 $scope.$digest(); 104 $scope.$digest();
101 }; 105 };
102 106
103 $scope.individual = function() { 107 $scope.individual = function() {
104 $scope.idVendedor = -1; 108 $scope.idVendedor = -1;
105 }; 109 };
106 110
107 $scope.mostrarDetalle = function() { 111 $scope.mostrarDetalle = function() {
108 $scope.detalle = true; 112 $scope.detalle = true;
109 }; 113 };
110 114
111 $scope.salir = function() { 115 $scope.salir = function() {
112 $location.path('/'); 116 $location.path('/');
113 }; 117 };
114 118
115 $scope.search = function() { 119 $scope.search = function() {
116 getSeguimiento(); 120 getSeguimiento();
117 }; 121 };
118 122
119 $scope.fecha = function() { 123 $scope.fecha = function() {
120 getSeguimiento(); 124 getSeguimiento();
121 }; 125 };
122 126
123 $scope.seleccionarTransportista = function() { 127 $scope.seleccionarTransportista = function() {
124 var modalInstance = $uibModal.open( 128 var modalInstance = $uibModal.open(
125 { 129 {
126 ariaLabelledBy: 'Busqueda de Transportista', 130 ariaLabelledBy: 'Busqueda de Transportista',
127 templateUrl: 'modal-proveedor.html', 131 templateUrl: 'modal-proveedor.html',
128 controller: 'focaModalProveedorCtrl', 132 controller: 'focaModalProveedorCtrl',
129 size: 'lg', 133 size: 'lg',
130 resolve: { 134 resolve: {
131 transportista: function() { 135 transportista: function() {
132 return true; 136 return true;
133 } 137 }
134 } 138 }
135 } 139 }
136 ); 140 );
137 modalInstance.result.then(function(transportista) { 141 modalInstance.result.then(function(transportista) {
138 $scope.seleccionarVehiculo(transportista.COD); 142 $scope.seleccionarVehiculo(transportista.COD);
139 }); 143 });
140 }; 144 };
141 145
142 $scope.seleccionarVehiculo = function(idTransportista) { 146 $scope.seleccionarVehiculo = function(idTransportista) {
143 var query = '/vehiculo/transportista/' + idTransportista; 147 var query = '/vehiculo/transportista/' + idTransportista;
144 var columnas = { 148 var columnas = {
145 nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], 149 nombre: ['Código', 'tractor', 'Semi', 'Capacidad'],
146 propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] 150 propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas']
147 }; 151 };
148 var titulo = 'Búsqueda de vehiculos'; 152 var titulo = 'Búsqueda de vehiculos';
149 focaModalService.modal(columnas, query, titulo).then( 153 focaModalService.modal(columnas, query, titulo).then(
150 function(vehiculo) { 154 function(vehiculo) {
151 var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); 155 var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id});
152 if(existe.length) { 156 if(existe.length) {
153 focaModalService.alert('El vehiculo ya ha sido cargado'); 157 focaModalService.alert('El vehiculo ya ha sido cargado');
154 return; 158 return;
155 } 159 }
156 if(!vehiculo.cisternas.length) { 160 if(!vehiculo.cisternas.length) {
157 focaModalService.alert('El vehiculo no tiene cisternas'); 161 focaModalService.alert('El vehiculo no tiene cisternas');
158 return; 162 return;
159 } 163 }
160 $scope.vehiculos.push(vehiculo); 164 $scope.vehiculos.push(vehiculo);
161 }, function() { 165 }, function() {
162 // funcion ejecutada cuando se cancela el modal 166 // funcion ejecutada cuando se cancela el modal
163 }); 167 });
164 }; 168 };
165 169
166 function getSeguimiento() { 170 function getSeguimiento() {
167 var desde = new Date('1900/01/01'); 171 var desde = new Date('1900/01/01');
168 var hasta = new Date('2099/01/01'); 172 var hasta = new Date('2099/01/01');
169 if($scope.fechaDesde) { 173 if($scope.fechaDesde) {
170 var fechaDesde = $scope.fechaDesde; 174 var fechaDesde = $scope.fechaDesde;
171 desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); 175 desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0));
172 desde = new Date(desde); 176 desde = new Date(desde);
173 } 177 }
174 if($scope.fechaHasta) { 178 if($scope.fechaHasta) {
175 var fechaHasta = $scope.fechaHasta; 179 var fechaHasta = $scope.fechaHasta;
176 hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); 180 hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0));
177 hasta = hasta.setDate(hasta.getDate() + 1); 181 hasta = hasta.setDate(hasta.getDate() + 1);
178 hasta = new Date(hasta); 182 hasta = new Date(hasta);
179 } 183 }
180 var datos = { 184 var datos = {
181 actividad: $scope.actividad, 185 actividad: $scope.actividad,
182 idUsuario: $scope.idVendedor, 186 idUsuario: $scope.idVendedor,
183 fechaDesde: desde, 187 fechaDesde: desde,
184 fechaHasta: hasta, 188 fechaHasta: hasta,
185 asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? 189 asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ?
186 false : undefined) 190 false : undefined)
187 }; 191 };
188 192
189 $scope.datosBuscados = { 193 $scope.datosBuscados = {
190 actividad: $scope.actividad, 194 actividad: $scope.actividad,
191 individual: $scope.idVendedor ? true : false 195 individual: $scope.idVendedor ? true : false
192 }; 196 };
193 197
194 focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { 198 focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) {
195 if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { 199 if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) {
196 $scope.marcadores = datos.data; 200 $scope.marcadores = datos.data;
197 } 201 }
198 }); 202 });
199 } 203 }
200 204
201 function eliminarVehiculo(vehiculo) { 205 function eliminarVehiculo(vehiculo) {
202 focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { 206 focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) {
203 if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { 207 if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) {
204 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); 208 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
205 }else { 209 }else {
206 focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + 210 focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' +
207 'tiene remitos asociados').then(function() { 211 'tiene remitos asociados').then(function() {
208 $scope.hacerHojaRuta(vehiculo); 212 $scope.hacerHojaRuta(vehiculo);
209 }); 213 });
210 } 214 }
211 }); 215 });
212 } 216 }
213 $interval(function() { 217 $interval(function() {
214 getSeguimiento(); 218 getSeguimiento();
215 }, 5000); 219 }, 5000);
216 } 220 }
217 ]); 221 ]);
218 222