Commit 706f795b5ff6f8565e527afc96c89cf721f09172

Authored by Eric Fernandez
1 parent bd83950814
Exists in master

redaccion mensaje

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