controller.js
3.67 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
angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [
'$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter',
function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter) {
$scope.actividad = '';
$scope.now = new Date();
$scope.actividad = 'Nota de pedido';
$scope.idUsuario = 0;
$scope.marcadores = [];
$scope.vehiculos = [];
getSeguimiento();
$scope.arrastrando = false;
$scope.general = function() {
$scope.idUsuario = 0;
getSeguimiento();
};
$scope.cargar = function(id, punto) {
var marcador = JSON.parse(punto);
var vehiculo = $filter('filter')($scope.vehiculos, {id: parseInt(id)})[0];
var modalInstance = $uibModal.open(
{
ariaLabelledBy: 'Busqueda de Vehiculo',
templateUrl: 'foca-detalle-vehiculo.html',
controller: 'focaDetalleVehiculo',
size: 'lg',
resolve: {
vehiculo: function() {return vehiculo;},
marcador: function() {return marcador;}
}
}
);
modalInstance.result.then(function() {
}, function() {
//run when cancel modal
});
};
$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.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) {
$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;
});
}
}
]);