controller.js
5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [
'$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter',
'focaModalService', 'focaBotoneraLateralService',
function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter,
focaModalService, focaBotoneraLateralService
) {
$scope.now = new Date();
$scope.actividad = 'Logistica';
//Datos Pantalla
$scope.titulo = 'Logistica de Pedidos';
$scope.botonera = ['Vehiculo'];
var cabecera = '';
$scope.idUsuario = 0;
$scope.marcadores = [];
$scope.vehiculos = [];
getSeguimiento();
$scope.arrastrando = false;
$scope.general = function() {
$scope.idUsuario = 0;
getSeguimiento();
};
//SETEO BOTONERA LATERAL
focaBotoneraLateralService.showSalir(true);
focaBotoneraLateralService.showPausar(false);
focaBotoneraLateralService.showGuardar(false);
$scope.general = function() {
$scope.idUsuario = 0;
getSeguimiento();
$scope.$broadcast('removeCabecera', cabecera);
$scope.$broadcast('addCabecera',{
label: 'General',
valor: ''
});
};
$scope.cargar = function(id, punto) {
var idRemito = JSON.parse(punto).notaPedido.remito.id;
var modalInstance = $uibModal.open(
{
ariaLabelledBy: 'Busqueda de Vehiculo',
templateUrl: 'foca-detalle-vehiculo.html',
controller: 'focaDetalleVehiculo',
size: 'lg',
resolve: {
idVehiculo: function() {return id;},
idRemito: function() {return idRemito;}
}
}
);
modalInstance.result.then(function() {
}, function() {
});
};
$scope.quitarVehiculo = function(vehiculo) {
focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' +
vehiculo.codigo + '?').then(function() {
$scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
});
};
$scope.informacionVehiculo = function(vehiculo) {
focaModalService.alert('EN DESARROLLO : \n información del vehículo ' +
JSON.stringify(vehiculo));
};
$scope.arrastra = function() {
$scope.arrastrando = true;
$scope.$digest();
};
$scope.noArrastra = function() {
$scope.arrastrando = false;
$scope.$digest();
};
$scope.individual = function() {
$scope.idUsuario = -1;
};
$scope.mostrarDetalle = function() {
$scope.detalle = true;
};
$scope.salir = function() {
$location.path('/');
};
$scope.search = function(key) {
if (key === 13) {
$scope.idUsuario = $scope.idUsuarioInput;
getSeguimiento();
$scope.$broadcast('removeCabecera', 'General');
$scope.$broadcast('addCabecera', {
label: cabecera,
valor: $scope.idUsuarioInput
});
}
};
$scope.fecha = function() {
getSeguimiento();
};
$scope.seleccionarVehiculo = function() {
var modalInstance = $uibModal.open(
{
ariaLabelledBy: 'Busqueda de Vehiculo',
templateUrl: 'modal-vehiculo.html',
controller: 'focaModalVehiculoController',
size: 'lg'
}
);
modalInstance.result.then(
function(vehiculo) {
var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id});
if(existe.length) {
focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado');
return;
}
$scope.vehiculos.push(vehiculo);
}, function() {
// funcion ejecutada cuando se cancela el modal
}
);
};
function getSeguimiento() {
var now = $scope.now;
var desde = new Date(new Date(now.setHours(0)).setMinutes(0));
desde = desde.setDate(desde.getDate() - 1);
desde = new Date(desde);
var datos = {
actividad: $scope.actividad,
idUsuario: $scope.idUsuario,
fechaDesde: desde,
fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59))
};
$scope.datosBuscados = {
actividad: $scope.actividad,
individual: $scope.idUsuario !== 0 ? true : false
};
focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) {
$scope.marcadores = datos.data;
});
}
}
]);