Commit aaf537312e716c14814cbf52b3e0f894ca044c17

Authored by Eric Fernandez
1 parent c7154c2464
Exists in master

boton fecha, nombre unidad

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