Commit 5fa8100a871a40c7c24e361ed22a81004ad44cbc

Authored by Eric Fernandez
1 parent ec43821953
Exists in master

ver detalle de carga

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;
42 if (punto === -1) {
43 idRemito = -1;
44 }else {
45 idRemito = JSON.parse(punto).notaPedido.remito.id;
46 }
42 var modalInstance = $uibModal.open( 47 var modalInstance = $uibModal.open(
43 { 48 {
44 ariaLabelledBy: 'Busqueda de Vehiculo', 49 ariaLabelledBy: 'Busqueda de Vehiculo',
45 templateUrl: 'foca-detalle-vehiculo.html', 50 templateUrl: 'foca-detalle-vehiculo.html',
46 controller: 'focaDetalleVehiculo', 51 controller: 'focaDetalleVehiculo',
47 size: 'lg', 52 size: 'lg',
48 resolve: { 53 resolve: {
49 idVehiculo: function() {return idVehiculo;}, 54 idVehiculo: function() {return idVehiculo;},
50 idRemito: function() {return idRemito;} 55 idRemito: function() {return idRemito;}
51 } 56 }
52 } 57 }
53 ); 58 );
54 modalInstance.result.then(function() { 59 modalInstance.result.then(function() {
55 }, function() { 60 }, function() {
56 }); 61 });
57 }; 62 };
58 63
59 $scope.quitarVehiculo = function(vehiculo) { 64 $scope.quitarVehiculo = function(vehiculo) {
60 focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + 65 focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' +
61 vehiculo.codigo + '?').then(function() { 66 vehiculo.codigo + '?').then(function() {
62 eliminarVehiculo(vehiculo); 67 eliminarVehiculo(vehiculo);
63 }); 68 });
64 }; 69 };
65 70
66 $scope.hacerHojaRuta = function(vehiculo) { 71 $scope.hacerHojaRuta = function(vehiculo) {
67 var modalInstance = $uibModal.open( 72 var modalInstance = $uibModal.open(
68 { 73 {
69 ariaLabelledBy: 'Creación hoja ruta', 74 ariaLabelledBy: 'Creación hoja ruta',
70 templateUrl: 'foca-modal-crear-hoja-ruta.html', 75 templateUrl: 'foca-modal-crear-hoja-ruta.html',
71 controller: 'focaModalCrearHojaRuta', 76 controller: 'focaModalCrearHojaRuta',
72 size: 'lg', 77 size: 'lg',
73 resolve: { 78 resolve: {
74 idVehiculo: function() {return vehiculo.id;} 79 idVehiculo: function() {return vehiculo.id;}
75 } 80 }
76 } 81 }
77 ); 82 );
78 modalInstance.result.then(function() { 83 modalInstance.result.then(function() {
79 84
80 }, function() { 85 }, function() {
81 //usar cuando se cancela el modal 86 //usar cuando se cancela el modal
82 }); 87 });
83 }; 88 };
84 89
85 $scope.arrastra = function() { 90 $scope.arrastra = function() {
86 $scope.arrastrando = true; 91 $scope.arrastrando = true;
87 $scope.$digest(); 92 $scope.$digest();
88 }; 93 };
89 94
90 $scope.noArrastra = function() { 95 $scope.noArrastra = function() {
91 $scope.arrastrando = false; 96 $scope.arrastrando = false;
92 $scope.$digest(); 97 $scope.$digest();
93 }; 98 };
94 99
95 $scope.individual = function() { 100 $scope.individual = function() {
96 $scope.idVendedor = -1; 101 $scope.idVendedor = -1;
97 }; 102 };
98 103
99 $scope.mostrarDetalle = function() { 104 $scope.mostrarDetalle = function() {
100 $scope.detalle = true; 105 $scope.detalle = true;
101 }; 106 };
102 107
103 $scope.salir = function() { 108 $scope.salir = function() {
104 $location.path('/'); 109 $location.path('/');
105 }; 110 };
106 111
107 $scope.search = function(key) { 112 $scope.search = function(key) {
108 if (key === 13) { 113 if (key === 13) {
109 $scope.idVendedor = $scope.idVendedorInput; 114 $scope.idVendedor = $scope.idVendedorInput;
110 getSeguimiento(); 115 getSeguimiento();
111 $scope.$broadcast('removeCabecera', 'General'); 116 $scope.$broadcast('removeCabecera', 'General');
112 $scope.$broadcast('addCabecera', { 117 $scope.$broadcast('addCabecera', {
113 label: cabecera, 118 label: cabecera,
114 valor: $scope.idVendedorInput 119 valor: $scope.idVendedorInput
115 }); 120 });
116 } 121 }
117 }; 122 };
118 123
119 $scope.fecha = function() { 124 $scope.fecha = function() {
120 getSeguimiento(); 125 getSeguimiento();
121 }; 126 };
122 127
123 $scope.seleccionarTransportista = function() { 128 $scope.seleccionarTransportista = function() {
124 var modalInstance = $uibModal.open( 129 var modalInstance = $uibModal.open(
125 { 130 {
126 ariaLabelledBy: 'Busqueda de Transportista', 131 ariaLabelledBy: 'Busqueda de Transportista',
127 templateUrl: 'modal-proveedor.html', 132 templateUrl: 'modal-proveedor.html',
128 controller: 'focaModalProveedorCtrl', 133 controller: 'focaModalProveedorCtrl',
129 size: 'lg', 134 size: 'lg',
130 resolve: { 135 resolve: {
131 transportista: function() { 136 transportista: function() {
132 return true; 137 return true;
133 } 138 }
134 } 139 }
135 } 140 }
136 ); 141 );
137 modalInstance.result.then(function(transportista) { 142 modalInstance.result.then(function(transportista) {
138 $scope.seleccionarVehiculo(transportista.COD); 143 $scope.seleccionarVehiculo(transportista.COD);
139 }); 144 });
140 }; 145 };
141 146
142 $scope.seleccionarVehiculo = function(idTransportista) { 147 $scope.seleccionarVehiculo = function(idTransportista) {
143 var modalInstance = $uibModal.open( 148 var modalInstance = $uibModal.open(
144 { 149 {
145 ariaLabelledBy: 'Busqueda de Vehiculo', 150 ariaLabelledBy: 'Busqueda de Vehiculo',
146 templateUrl: 'modal-vehiculo.html', 151 templateUrl: 'modal-vehiculo.html',
147 controller: 'focaModalVehiculoController', 152 controller: 'focaModalVehiculoController',
148 size: 'lg', 153 size: 'lg',
149 resolve: { 154 resolve: {
150 idTransportista: function() {return idTransportista;} 155 idTransportista: function() {return idTransportista;}
151 } 156 }
152 } 157 }
153 ); 158 );
154 159
155 modalInstance.result.then( 160 modalInstance.result.then(
156 function(vehiculo) { 161 function(vehiculo) {
157 var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); 162 var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id});
158 if(existe.length) { 163 if(existe.length) {
159 focaModalService.alert('El vehiculo ya ha sido cargado'); 164 focaModalService.alert('El vehiculo ya ha sido cargado');
160 return; 165 return;
161 } 166 }
162 if(!vehiculo.cisternas.length) { 167 if(!vehiculo.cisternas.length) {
163 focaModalService.alert('El vehiculo no tiene cisternas'); 168 focaModalService.alert('El vehiculo no tiene cisternas');
164 return; 169 return;
165 } 170 }
166 $scope.vehiculos.push(vehiculo); 171 $scope.vehiculos.push(vehiculo);
167 }, function() { 172 }, function() {
168 // funcion ejecutada cuando se cancela el modal 173 // funcion ejecutada cuando se cancela el modal
169 } 174 }
170 ); 175 );
171 }; 176 };
172 177
173 function getSeguimiento() { 178 function getSeguimiento() {
174 var desde = new Date('1900/01/01'); 179 var desde = new Date('1900/01/01');
175 var hasta = new Date('2099/01/01'); 180 var hasta = new Date('2099/01/01');
176 if ($scope.now) { 181 if ($scope.now) {
177 var now = $scope.now; 182 var now = $scope.now;
178 desde = new Date(new Date(now.setHours(0)).setMinutes(0)); 183 desde = new Date(new Date(now.setHours(0)).setMinutes(0));
179 desde = desde.setDate(desde.getDate() - 1); 184 desde = desde.setDate(desde.getDate() - 1);
180 desde = new Date(desde); 185 desde = new Date(desde);
181 } 186 }
182 var datos = { 187 var datos = {
183 actividad: $scope.actividad, 188 actividad: $scope.actividad,
184 idUsuario: $scope.idVendedor, 189 idUsuario: $scope.idVendedor,
185 fechaDesde: desde, 190 fechaDesde: desde,
186 fechaHasta: hasta 191 fechaHasta: hasta
187 }; 192 };
188 193
189 $scope.datosBuscados = { 194 $scope.datosBuscados = {
190 actividad: $scope.actividad, 195 actividad: $scope.actividad,
191 individual: $scope.idVendedor ? true : false 196 individual: $scope.idVendedor ? true : false
192 }; 197 };
193 198
194 focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { 199 focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) {
195 if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { 200 if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) {
196 $scope.marcadores = datos.data; 201 $scope.marcadores = datos.data;
197 } 202 }
198 }); 203 });
199 } 204 }
200 205
201 function eliminarVehiculo(vehiculo) { 206 function eliminarVehiculo(vehiculo) {
202 focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { 207 focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) {
203 if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { 208 if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) {
204 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); 209 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
205 }else { 210 }else {
206 focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + 211 focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' +
207 'tiene remitos asociados').then(function() { 212 'tiene remitos asociados').then(function() {
208 $scope.hacerHojaRuta(vehiculo); 213 $scope.hacerHojaRuta(vehiculo);
209 }); 214 });
210 } 215 }
211 }); 216 });
212 } 217 }
213 $interval(function() { 218 $interval(function() {
214 getSeguimiento(); 219 getSeguimiento();
215 }, 5000); 220 }, 5000);
216 } 221 }
217 ]); 222 ]);
218 223
src/js/controllerDetalleVehiculo.js
1 angular.module('focaLogisticaPedidoRuta') 1 angular.module('focaLogisticaPedidoRuta')
2 .controller('focaDetalleVehiculo', 2 .controller('focaDetalleVehiculo',
3 ['$scope', 3 ['$scope',
4 '$uibModalInstance', 4 '$uibModalInstance',
5 'idVehiculo', 5 'idVehiculo',
6 'idRemito', 6 'idRemito',
7 'focaModalService', 7 'focaModalService',
8 '$filter', 8 '$filter',
9 'focaLogisticaPedidoRutaService', 9 'focaLogisticaPedidoRutaService',
10 function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, 10 function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter,
11 focaLogisticaPedidoRutaService 11 focaLogisticaPedidoRutaService
12 ) { 12 ) {
13 //seteo variables 13 //seteo variables
14 $scope.idRemito = idRemito;
14 $scope.articulos = []; 15 $scope.articulos = [];
15 $scope.vehiculo = {}; 16 $scope.vehiculo = {};
16 $scope.remito = {}; 17 $scope.remito = {};
17 $scope.aCargar = []; 18 $scope.aCargar = [];
18 var cisternaMovimientos = []; 19 var cisternaMovimientos = [];
19 focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then( 20 focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(
20 function(res) { 21 function(res) {
21 $scope.vehiculo = res.data; 22 $scope.vehiculo = res.data;
22 } 23 }
23 ); 24 );
24 focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( 25 if (idRemito !== -1) {
25 function(res) { 26 focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then(
26 $scope.remito = res.data; 27 function(res) {
27 if($scope.remito.idUsuarioProceso) { 28 $scope.remito = res.data;
28 focaModalService.alert('El remito esta siendo cargado por otro usario'); 29 if($scope.remito.idUsuarioProceso) {
29 $uibModalInstance.close(); 30 focaModalService.alert('El remito esta siendo cargado por otro usario');
31 $uibModalInstance.close();
32 }
33 $scope.articulos = res.data.articulosRemito;
30 } 34 }
31 $scope.articulos = res.data.articulosRemito; 35 );
32 } 36 }
33 );
34 $scope.aceptar = function() { 37 $scope.aceptar = function() {
35 $scope.cargando = true; 38 $scope.cargando = true;
36 var cisternaCargas = []; 39 var cisternaCargas = [];
37 for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { 40 for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) {
38 delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo; 41 delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo;
39 cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga); 42 cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga);
40 } 43 }
41 var cisterna = { 44 var cisterna = {
42 cisternaMovimientos: cisternaMovimientos, 45 cisternaMovimientos: cisternaMovimientos,
43 cisternaCargas: cisternaCargas, 46 cisternaCargas: cisternaCargas,
44 idVehiculo: $scope.vehiculo.id 47 idVehiculo: $scope.vehiculo.id
45 }; 48 };
46 focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) 49 focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id)
47 .then(function() { 50 .then(function() {
48 focaModalService.alert('Cisternas cargadas con éxito').then(function() { 51 focaModalService.alert('Cisternas cargadas con éxito').then(function() {
49 $scope.cargando = false; 52 $scope.cargando = false;
50 $uibModalInstance.close(); 53 $uibModalInstance.close();
51 }); 54 });
52 }).catch(function(error) { 55 }).catch(function(error) {
53 $scope.cargando = false; 56 $scope.cargando = false;
54 $uibModalInstance.close(); 57 $uibModalInstance.close();
55 if (error.status === 403.1) { 58 if (error.status === 403.1) {
56 focaModalService.alert('ERROR: El vehículo esta en uso'); 59 focaModalService.alert('ERROR: El vehículo esta en uso');
57 } 60 }
58 if(error.status === 403.2) { 61 if(error.status === 403.2) {
59 focaModalService.alert('ERROR: Otro usario ya cargó este remito'); 62 focaModalService.alert('ERROR: Otro usario ya cargó este remito');
60 return; 63 return;
61 } 64 }
62 focaModalService.alert('Hubo un error al cargar las cisternas'); 65 focaModalService.alert('Hubo un error al cargar las cisternas');
63 }); 66 });
64 }; 67 };
65 68
66 $scope.cancelar = function() { 69 $scope.cancelar = function() {
67 $uibModalInstance.close(); 70 $uibModalInstance.close();
68 }; 71 };
69 72
70 $scope.cargarACisternas = function(vehiculo) { 73 $scope.cargarACisternas = function(vehiculo) {
71 for(var i = 0; i < vehiculo.cisternas.length; i++) { 74 for(var i = 0; i < vehiculo.cisternas.length; i++) {
72 var cisterna = vehiculo.cisternas[i]; 75 var cisterna = vehiculo.cisternas[i];
73 var aCargar = parseFloat($scope.aCargar[i]); 76 var aCargar = parseFloat($scope.aCargar[i]);
74 //validaciones 77 //validaciones
75 if(!aCargar) { 78 if(!aCargar) {
76 continue; 79 continue;
77 } 80 }
78 if(aCargar > cisterna.disponible) { 81 if(aCargar > cisterna.disponible) {
79 focaModalService.alert('La cantidad cargada supera la capacidad de la' + 82 focaModalService.alert('La cantidad cargada supera la capacidad de la' +
80 'cisterna ' + cisterna.codigo); 83 'cisterna ' + cisterna.codigo);
81 return; 84 return;
82 } 85 }
83 //cargar 86 //cargar
84 if(cisterna.cisternaCarga.cantidad) { 87 if(cisterna.cisternaCarga.cantidad) {
85 cisterna.cisternaCarga.cantidad += aCargar; 88 cisterna.cisternaCarga.cantidad += aCargar;
86 }else { 89 }else {
87 cisterna.cisternaCarga.cantidad = aCargar; 90 cisterna.cisternaCarga.cantidad = aCargar;
88 cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; 91 cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo;
89 } 92 }
90 cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; 93 cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad;
91 94
92 cisterna.cisternaCarga.articulo = { 95 cisterna.cisternaCarga.articulo = {
93 DetArt: $scope.articuloSeleccionado.descripcion 96 DetArt: $scope.articuloSeleccionado.descripcion
94 }; 97 };
95 $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] 98 $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0]
96 .cargado = true; 99 .cargado = true;
97 100
98 $scope.calcularPorcentaje(cisterna); 101 $scope.calcularPorcentaje(cisterna);
99 //Guardar 102 //Guardar
100 var now = new Date(); 103 var now = new Date();
101 var cisternaMovimiento = { 104 var cisternaMovimiento = {
102 fecha: now.toISOString().slice(0, 19).replace('T', ' '), 105 fecha: now.toISOString().slice(0, 19).replace('T', ' '),
103 cantidad: aCargar, 106 cantidad: aCargar,
104 metodo: 'carga', 107 metodo: 'carga',
105 idCisternaCarga: cisterna.cisternaCarga.id, 108 idCisternaCarga: cisterna.cisternaCarga.id,
106 idRemito: $scope.remito.id 109 idRemito: $scope.remito.id
107 }; 110 };
108 cisternaMovimientos.push(cisternaMovimiento); 111 cisternaMovimientos.push(cisternaMovimiento);
109 } 112 }
110 var articuloSiguiente = $scope.articulos.filter( 113 var articuloSiguiente = $scope.articulos.filter(
111 function(filter) { 114 function(filter) {
112 return filter.cargado !== true; 115 return filter.cargado !== true;
113 } 116 }
114 ); 117 );
115 if(articuloSiguiente.length > 0) { 118 if(articuloSiguiente.length > 0) {
116 $scope.cambioArticulo(articuloSiguiente[0]); 119 $scope.cambioArticulo(articuloSiguiente[0]);
117 } 120 }
118 $scope.aCargar = []; 121 $scope.aCargar = [];
119 }; 122 };
120 $scope.calcularPorcentaje = function(cisterna) { 123 $scope.calcularPorcentaje = function(cisterna) {
121 if(!cisterna.cisternaCarga.cantidad) { 124 if(!cisterna.cisternaCarga.cantidad) {
122 cisterna.cisternaCarga.cantidad = 0; 125 cisterna.cisternaCarga.cantidad = 0;
123 } 126 }
124 var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / 127 var porcentaje = (cisterna.cisternaCarga.cantidad * 100 /
125 cisterna.capacidad) + '%'; 128 cisterna.capacidad) + '%';
126 var elementHtml = document.getElementById(cisterna.id); 129 var elementHtml = document.getElementById(cisterna.id);
127 if(elementHtml) { 130 if(elementHtml) {
128 elementHtml.style.width = porcentaje; 131 elementHtml.style.width = porcentaje;
129 } 132 }
130 }; 133 };
131 $scope.cambioArticulo = function(articulo) { 134 $scope.cambioArticulo = function(articulo) {
132 articulo.checked = true; 135 articulo.checked = true;
133 $scope.articuloSeleccionado = articulo; 136 $scope.articuloSeleccionado = articulo;
134 }; 137 };
135 $scope.actualizarArticulo = function () { 138 $scope.actualizarArticulo = function () {
136 $scope.articuloSeleccionado.cantidadCargada = 0; 139 $scope.articuloSeleccionado.cantidadCargada = 0;
137 for (var i = 0; i < $scope.aCargar.length; i++) { 140 for (var i = 0; i < $scope.aCargar.length; i++) {
138 $scope.articuloSeleccionado.cantidadCargada += 141 $scope.articuloSeleccionado.cantidadCargada +=
139 parseFloat($scope.aCargar[i]) || 0; 142 parseFloat($scope.aCargar[i]) || 0;
140 } 143 }
141 }; 144 };
142 $scope.tieneArticulosPendientes = function() { 145 $scope.tieneArticulosPendientes = function() {
143 var articulosDescargados = $scope.articulos.filter(function(filter) { 146 var articulosDescargados = $scope.articulos.filter(function(filter) {
144 return filter.cargado === true; 147 return filter.cargado === true;
145 }); 148 });
146 if(articulosDescargados.length === $scope.articulos.length) { 149 if(articulosDescargados.length === $scope.articulos.length) {
147 return false; 150 return false;
148 } 151 }
149 return true; 152 return true;
150 }; 153 };
151 }]); 154 }]);
src/js/osm-directive.js
1 angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { 1 angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() {
2 return { 2 return {
3 restrict: 'E', 3 restrict: 'E',
4 link: function(scope, el, attrs) { 4 link: function(scope, el, attrs) {
5 var contenedor = document.createElement('div'); 5 var contenedor = document.createElement('div');
6 el.append(contenedor); 6 el.append(contenedor);
7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); 7 scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom);
8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); 8 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map);
9 }, 9 },
10 controller: ['$scope', '$filter', function($scope, $filter) { 10 controller: ['$scope', '$filter', function($scope, $filter) {
11 $scope.markers = []; 11 $scope.markers = [];
12 $scope.$watch('marcadores', function() { 12 $scope.$watch('marcadores', function() {
13 for(var i in $scope.markers) { 13 for(var i in $scope.markers) {
14 $scope.map.removeLayer($scope.markers[i]); 14 $scope.map.removeLayer($scope.markers[i]);
15 } 15 }
16 $scope.markers = []; 16 $scope.markers = [];
17 17
18 angular.forEach($scope.marcadores, function(marcador) { 18 angular.forEach($scope.marcadores, function(marcador) {
19 var observacion = 19 var observacion =
20 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + 20 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' +
21 ( 21 (
22 marcador.notaPedido.vendedor ? 22 marcador.notaPedido.vendedor ?
23 marcador.notaPedido.vendedor.NomVen : 23 marcador.notaPedido.vendedor.NomVen :
24 '' 24 ''
25 ) + '<br/>'; 25 ) + '<br/>';
26 observacion += 'Fecha: ' + 26 observacion += 'Fecha: ' +
27 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + 27 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
28 marcador.fecha.slice(11,19) + '<br/>'; 28 marcador.fecha.slice(11,19) + '<br/>';
29 observacion += 'Remito Nº: ' + $filter('comprobante')([ 29 observacion += 'Remito Nº: ' + $filter('comprobante')([
30 marcador.notaPedido.remito.sucursal, 30 marcador.notaPedido.remito.sucursal,
31 marcador.notaPedido.remito.numeroRemito 31 marcador.notaPedido.remito.numeroRemito
32 ]) + '<br/>'; 32 ]) + '<br/>';
33 observacion += 'Cliente: ' + 33 observacion += 'Cliente: ' +
34 marcador.notaPedido.cliente.NOM + '<br/>'; 34 marcador.notaPedido.cliente.NOM + '<br/>';
35 35
36 // if($scope.parametros.individual) { 36 // if($scope.parametros.individual) {
37 observacion += 37 observacion +=
38 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); 38 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$');
39 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; 39 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion;
40 40
41 if(marcador.distancia) { 41 if(marcador.distancia) {
42 observacion += '<br/>Distancia a casa central: ' + 42 observacion += '<br/>Distancia a casa central: ' +
43 marcador.distancia + 'km'; 43 marcador.distancia + 'km';
44 } 44 }
45 // }else {
46 // observacion += 'Cantidad de remitos: ' +
47 // marcador.cantidad + '<br/>';
48 // observacion += 'Total Vendido: ' +
49 // $filter('currency')(marcador.total, '$');
50 // }
51 observacion += '<br/>'; 45 observacion += '<br/>';
52 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ 46 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+
53 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ 47 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
54 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; 48 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)';
55 var icon; 49 var icon;
56 if(marcador.notaPedido.remito.idUsuarioProceso) { 50 if(marcador.notaPedido.remito.idUsuarioProceso) {
57 //Asignado AZUL 51 //Asignado AZUL
58 icon = new L.Icon({ 52 icon = new L.Icon({
59 iconUrl: 'img/marker-icon-2x-blue.png', 53 iconUrl: 'img/marker-icon-2x-blue.png',
60 shadowUrl: 'img/marker-shadow.png', 54 shadowUrl: 'img/marker-shadow.png',
61 iconSize: [25, 41], 55 iconSize: [25, 41],
62 iconAnchor: [12, 41], 56 iconAnchor: [12, 41],
63 popupAnchor: [1, -34], 57 popupAnchor: [1, -34],
64 shadowSize: [41, 41] 58 shadowSize: [41, 41]
65 }); 59 });
66 }else { 60 }else {
67 //Sin asignar ROJO 61 //Sin asignar ROJO
68 icon = new L.Icon({ 62 icon = new L.Icon({
69 iconUrl: 'img/marker-icon-2x-red.png', 63 iconUrl: 'img/marker-icon-2x-red.png',
70 shadowUrl: 'img/marker-shadow.png', 64 shadowUrl: 'img/marker-shadow.png',
71 iconSize: [25, 41], 65 iconSize: [25, 41],
72 iconAnchor: [12, 41], 66 iconAnchor: [12, 41],
73 popupAnchor: [1, -34], 67 popupAnchor: [1, -34],
74 shadowSize: [41, 41] 68 shadowSize: [41, 41]
75 }); 69 });
76 } 70 }
77 $scope.markers.push( 71 $scope.markers.push(
78 L.marker([marcador.latitud, marcador.longitud], {icon: icon}) 72 L.marker([marcador.latitud, marcador.longitud], {icon: icon})
79 .addTo($scope.map) 73 .addTo($scope.map)
80 .bindPopup(observacion) 74 .bindPopup(observacion)
81 ); 75 );
82 76
83 $scope.markers[0].openPopup(); 77 $scope.markers[0].openPopup();
84 }); 78 });
85 }); 79 });
86 }], 80 }],
87 scope: { 81 scope: {
88 latitud: '=', 82 latitud: '=',
89 longitud: '=', 83 longitud: '=',
90 zoom: '=', 84 zoom: '=',
91 marcadores: '=', 85 marcadores: '=',
92 parametros: '=' 86 parametros: '='
93 } 87 }
94 }; 88 };
95 }); 89 });
96 90
src/views/foca-detalle-vehiculo.html
1 <div class="modal-header"> 1 <div class="modal-header">
2 <h4>Detalle de carga</h4> 2 <h4>Detalle de carga</h4>
3 Vehículo <strong ng-bind="vehiculo.tractor"></strong> 3 Vehículo <strong ng-bind="vehiculo.tractor"></strong>
4 Transportista <strong ng-bind="vehiculo.transportista.NOM"></strong> 4 Transportista <strong ng-bind="vehiculo.transportista.NOM"></strong>
5 <br> 5 <br>
6 Remito Nº 6 <div ng-show="idRemito !== -1">
7 <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong> 7 <span>Remito Nº</span>
8 , Cliente 8 <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong>
9 <strong ng-bind="remito.nombreCliente"></strong> 9 <span>, Cliente</span>
10 , Domicilio 10 <strong ng-bind="remito.nombreCliente"></strong>
11 <strong ng-bind="remito.domicilioStamp"></strong> 11 <span>, Domicilio</span>
12 <strong ng-bind="remito.domicilioStamp"></strong>
13 </div>
12 </div> 14 </div>
13 <div class="modal-body"> 15 <div class="modal-body">
14 <div> 16 <div>
15 <table class="table table-sm"> 17 <table class="table table-sm" ng-show="idRemito !== -1">
16 <thead> 18 <thead>
17 <tr> 19 <tr>
18 <th></th> 20 <th></th>
19 <th>Articulo</th> 21 <th>Articulo</th>
20 <th>Total</th> 22 <th>Total</th>
21 <th>Cargado</th> 23 <th>Cargado</th>
22 <th>Pendiente</th> 24 <th>Pendiente</th>
23 </tr> 25 </tr>
24 </thead> 26 </thead>
25 <tbody> 27 <tbody>
26 <tr ng-repeat="(key, articulo) in articulos"> 28 <tr ng-repeat="(key, articulo) in articulos">
27 <td><input 29 <td><input
28 type="radio" 30 type="radio"
29 name="articuloRadio" 31 name="articuloRadio"
30 id="{{articulo.id}}" 32 id="{{articulo.id}}"
31 ng-checked="articulo.checked" 33 ng-checked="articulo.checked"
32 ng-disabled="articulo.cargado" 34 ng-disabled="articulo.cargado"
33 ng-click="cambioArticulo(articulo)" 35 ng-click="cambioArticulo(articulo)"
34 ></td> 36 ></td>
35 <td ng-bind="articulo.descripcion"></td> 37 <td ng-bind="articulo.descripcion"></td>
36 <td ng-bind="articulo.cantidad"></td> 38 <td ng-bind="articulo.cantidad"></td>
37 <td ng-bind="articulo.cantidadCargada || 0"></td> 39 <td ng-bind="articulo.cantidadCargada || 0"></td>
38 <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td> 40 <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td>
39 </tr> 41 </tr>
40 </tbody> 42 </tbody>
41 </table> 43 </table>
42 <table class="table table-sm"> 44 <table class="table table-sm">
43 <thead> 45 <thead>
44 <tr> 46 <tr>
45 <th>Cisterna</th> 47 <th>Cisterna</th>
46 <th>Cantidad asignada</th> 48 <th>Cantidad asignada</th>
47 <th>Estado</th> 49 <th>Estado</th>
48 <th>Articulo cargado</th> 50 <th>Articulo cargado</th>
49 </tr> 51 </tr>
50 </thead> 52 </thead>
51 <tbody> 53 <tbody>
52 <tr ng-repeat="(key, cisterna) in vehiculo.cisternas"> 54 <tr ng-repeat="(key, cisterna) in vehiculo.cisternas">
53 <td ng-bind="cisterna.codigo"></td> 55 <td ng-bind="cisterna.codigo"></td>
54 <td><input 56 <td><input
55 class="form-control" 57 class="form-control"
56 foca-tipo-input 58 foca-tipo-input
57 foca-teclado 59 foca-teclado
58 placeholder="A cargar..." 60 placeholder="A cargar..."
59 ng-model="aCargar[key]" 61 ng-model="aCargar[key]"
60 ng-disabled="(articuloSeleccionado.idArticulo !== cisterna.cisternaCarga.idProducto && 62 ng-disabled="(articuloSeleccionado.idArticulo !== cisterna.cisternaCarga.idProducto &&
61 cisterna.cisternaCarga.idProducto) || !tieneArticulosPendientes() 63 cisterna.cisternaCarga.idProducto) || !tieneArticulosPendientes()
62 || articuloSeleccionado.cantidad > cisterna.disponible" 64 || articuloSeleccionado.cantidad > cisterna.disponible"
63 ng-change="actualizarArticulo()" 65 ng-change="actualizarArticulo()"
64 > 66 >
65 </td> 67 </td>
66 <td colspan="2"><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> 68 <td colspan="2"><div class="progress foca-alto-progress pl-0 pr-0 mt-1">
67 <strong 69 <strong
68 class="mt-2 col-3 text-center position-absolute" 70 class="mt-2 col-3 text-center position-absolute"
69 ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + (cisterna.capacidad)"> 71 ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + (cisterna.capacidad)">
70 </strong> 72 </strong>
71 <div 73 <div
72 id="{{cisterna.id}}" 74 id="{{cisterna.id}}"
73 class="progress-bar" 75 class="progress-bar"
74 role="progressbar" 76 role="progressbar"
75 aria-valuemin="0" 77 aria-valuemin="0"
76 aria-valuemax="{{cisterna.capacidad}}" 78 aria-valuemax="{{cisterna.capacidad}}"
77 ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> 79 ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}">
78 </div> 80 </div>
79 </div> 81 </div>
80 </td> 82 </td>
81 <td ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin articulo'"></td> 83 <td ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin articulo'"></td>
82 </tr> 84 </tr>
83 </tbody> 85 </tbody>
84 </table> 86 </table>
85 <div class="col-12 aling-end"> 87 <div class="col-12 aling-end">
86 <button 88 <button
87 class="form-control btn btn-success" 89 class="form-control btn btn-success"
88 ladda="cargando" 90 ladda="cargando"
89 data-spinner-color="#FF0000" 91 data-spinner-color="#FF0000"
90 type="button" 92 type="button"
91 ng-disabled="!articuloSeleccionado || articuloSeleccionado.cantidad - 93 ng-disabled="!articuloSeleccionado || articuloSeleccionado.cantidad -
92 articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()" 94 articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()"
93 ng-class="{'btn-light': !articuloSeleccionado || articuloSeleccionado.cantidad - 95 ng-class="{'btn-light': !articuloSeleccionado || articuloSeleccionado.cantidad -
94 articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()}" 96 articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()}"
95 ng-click="cargarACisternas(vehiculo)"> 97 ng-click="cargarACisternas(vehiculo)">
96 Aplicar distribución de cargas 98 Aplicar distribución de cargas
97 </button> 99 </button>
98 </div> 100 </div>
99 </div> 101 </div>
100 </div> 102 </div>
101 <div class="modal-footer py-1"> 103 <div class="modal-footer py-1">
102 <button 104 <button
103 class="btn btn-sm btn-secondary" 105 class="btn btn-sm btn-secondary"
104 ladda="cargando" 106 ladda="cargando"
105 type="button" 107 type="button"
106 ng-click="cancelar()">Cancelar</button> 108 ng-click="cancelar()">Cancelar</button>
107 <button 109 <button
108 class="btn btn-sm btn-primary" 110 class="btn btn-sm btn-primary"
109 ladda="cargando" 111 ladda="cargando"
110 type="button" 112 type="button"
111 ng-click="aceptar()" 113 ng-click="aceptar()"
112 ng-disabled="tieneArticulosPendientes()">Cargar</button> 114 ng-disabled="tieneArticulosPendientes()">Cargar</button>
113 </div> 115 </div>
114 116
src/views/foca-logistica-pedido-ruta.html
1 <div class="foca-logistica-pedido-ruta" id="scope"> 1 <div class="foca-logistica-pedido-ruta" id="scope">
2 <div class="row"> 2 <div class="row">
3 <foca-cabecera-facturador 3 <foca-cabecera-facturador
4 titulo="titulo" 4 titulo="titulo"
5 fecha="now" 5 fecha="now"
6 class="mb-0 col-lg-12" 6 class="mb-0 col-lg-12"
7 ></foca-cabecera-facturador> 7 ></foca-cabecera-facturador>
8 </div> 8 </div>
9 <div class="row px-5 py-2 botonera-secundaria"> 9 <div class="row px-5 py-2 botonera-secundaria">
10 <div class="col-12"> 10 <div class="col-12">
11 <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> 11 <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador>
12 </div> 12 </div>
13 </div> 13 </div>
14 <div class="row"> 14 <div class="row">
15 <div class="offset-1 col-9"> 15 <div class="offset-1 col-9">
16 <foca-logistica 16 <foca-logistica
17 latitud="-32.89214159952345" 17 latitud="-32.89214159952345"
18 longitud="-68.84572999101856" 18 longitud="-68.84572999101856"
19 zoom="14" 19 zoom="14"
20 marcadores="marcadores" 20 marcadores="marcadores"
21 parametros= "datosBuscados" 21 parametros= "datosBuscados"
22 /> 22 />
23 </div> 23 </div>
24 <div class="col-2 pl-0"> 24 <div class="col-2 pl-0">
25 <input 25 <input
26 type="date" 26 type="date"
27 ng-model="now" 27 ng-model="now"
28 class="btn col-12 my-1" 28 class="btn col-12 my-1"
29 foca-focus="true" 29 foca-focus="true"
30 ng-blur="fecha()" 30 ng-blur="fecha()"
31 hasta-hoy 31 hasta-hoy
32 /> 32 />
33 <button 33 <button
34 type="button" 34 type="button"
35 ng-class="{'active': idVendedor == 0}" 35 ng-class="{'active': idVendedor == 0}"
36 class="btn col-12 my-1" 36 class="btn col-12 my-1"
37 ng-click="general()" 37 ng-click="general()"
38 >General</button> 38 >General</button>
39 <button 39 <button
40 type="button" 40 type="button"
41 ng-class="{'active': idVendedor != 0}" 41 ng-class="{'active': idVendedor != 0}"
42 class="btn col-12 my-1" 42 class="btn col-12 my-1"
43 ng-click="individual()" 43 ng-click="individual()"
44 >Individual</button> 44 >Individual</button>
45 <div class="form-group" ng-show="idVendedor == -1"> 45 <div class="form-group" ng-show="idVendedor == -1">
46 <input 46 <input
47 type="text" 47 type="text"
48 placeholder="Vendedor" 48 placeholder="Vendedor"
49 class="form-control" 49 class="form-control"
50 ng-model="idVendedorInput" 50 ng-model="idVendedorInput"
51 ng-keypress="search($event.keyCode)" 51 ng-keypress="search($event.keyCode)"
52 foca-focus="idVendedor == -1" 52 foca-focus="idVendedor == -1"
53 > 53 >
54 </div> 54 </div>
55 <div>
56 <img src="img/marker-icon-2x-blue.png">
57 <strong>Asignado</strong>
58 <img src="img/marker-icon-2x-red.png">
59 <strong>Sin asignar</strong>
60 </div>
55 </div> 61 </div>
56 <div class="row"> 62 <div class="row">
57 <div 63 <div
58 class="container col-auto" 64 class="container col-auto"
59 ng-repeat="vehiculo in vehiculos" 65 ng-repeat="vehiculo in vehiculos"
60 ng-click="mostrarDetalleVehiculo(vehiculo)" 66 ng-click="mostrarDetalleVehiculo(vehiculo)"
61 > 67 >
62 <div> 68 <div>
63 <div class="col-md-3 col-sm-6"> 69 <div class="col-md-3 col-sm-6">
64 <div class="progress-circle" ng-class="{'arrastrando': arrastrando}"> 70 <div class="progress-circle" ng-class="{'arrastrando': arrastrando}">
65 <span class="progress-left"> 71 <span class="progress-left">
66 <span class="progress-bar"></span> 72 <span class="progress-bar"></span>
67 </span> 73 </span>
68 <span class="progress-right"> 74 <span class="progress-right">
69 <span class="progress-bar"></span> 75 <span class="progress-bar"></span>
70 </span> 76 </span>
71 <div class="progress-value">{{vehiculo.codigo}}</div> 77 <div class="progress-value">{{vehiculo.codigo}}</div>
72 </div> 78 </div>
73 </div> 79 </div>
74 <div class="row px-4"> 80 <div class="row col-5">
75 <div class="text-left col-6 ml-1 position-absolute"> 81 <div class="col-4">
76 <img 82 <img
77 src="img/hojaRutaVolante.png" 83 src="img/hojaRutaVolante.png"
78 width="34%" 84 width="80%%"
79 uib-tooltip="Confeccionar hoja de ruta" 85 uib-tooltip="Confeccionar hoja de ruta"
80 ng-click="hacerHojaRuta(vehiculo)"> 86 ng-click="hacerHojaRuta(vehiculo)">
81 </div> 87 </div>
82 <div class="text-right ml-5 col-6 position-absolute"> 88 <div class="col-4">
89 <i
90 class="fa fa-eye fa-2x"
91 uib-tooltip="Ver cisternas"
92 ng-click="cargar(vehiculo.id, -1)">
93 </i>
94 </div>
95 <div class="col-4">
83 <i 96 <i
84 class="fa fa-trash fa-2x" 97 class="fa fa-trash fa-2x"
85 uib-tooltip="Eliminar vehiculo" 98 uib-tooltip="Eliminar vehiculo"
86 ng-click="quitarVehiculo(vehiculo)"></i> 99 ng-click="quitarVehiculo(vehiculo)"></i>
87 </div> 100 </div>
88 </div> 101 </div>
89 <div 102 <div
90 class="col-12 mt-5 border border-dark text-center" 103 class="col-4 ml-1 border border-dark text-center"
91 ng-show="arrastrando" 104 ng-show="arrastrando"
92 id="{{vehiculo.id}}" 105 id="{{vehiculo.id}}"
93 ondrop="drop(event)" 106 ondrop="drop(event)"
94 ondragover="allowDrop(event)" 107 ondragover="allowDrop(event)"
95 >Soltar acá</div> 108 >Soltar acá</div>
96 </div> 109 </div>
97 </div> 110 </div>
98 </div> 111 </div>
99 </div> 112 </div>
100 </div> 113 </div>
101 114