Commit c68650426560e0257fe4f69305718141a9814b0f

Authored by Nicolás Guarnieri
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master

See merge request modulos-npm/foca-admin-seguimiento!9
src/js/controller.js
1 angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [ 1 angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [
2 '$scope', 'focaAdminSeguimientoService', '$location', '$routeParams', 2 '$scope', 'focaAdminSeguimientoService', '$location', '$routeParams',
3 function($scope, focaAdminSeguimientoService, $location, $routeParams) { 3 function($scope, focaAdminSeguimientoService, $location, $routeParams) {
4 $scope.actividad = ''; 4 $scope.actividad = '';
5 5
6 $scope.now = new Date(); 6 $scope.now = new Date();
7 7
8 if ($routeParams.parametro === 'nota-pedido') { 8 if ($routeParams.parametro === 'nota-pedido') {
9 $scope.actividad = 'Nota de pedido'; 9 $scope.actividad = 'Nota de pedido';
10 } 10 }
11 11
12 if ($routeParams.parametro === 'hoja-ruta') { 12 if ($routeParams.parametro === 'hoja-ruta') {
13 $scope.actividad = 'Entrega de producto'; 13 $scope.actividad = 'Entrega de producto';
14 } 14 }
15 15
16 $scope.idUsuario = 0; 16 $scope.idUsuario = 0;
17 $scope.marcadores = []; 17 $scope.marcadores = [];
18 getSeguimiento(); 18 getSeguimiento();
19 19
20 $scope.general = function() { 20 $scope.general = function() {
21 $scope.idUsuario = 0; 21 $scope.idUsuario = 0;
22 getSeguimiento(); 22 getSeguimiento();
23 }; 23 };
24 24
25 $scope.individual = function() { 25 $scope.individual = function() {
26 $scope.idUsuario = -1; 26 $scope.idUsuario = -1;
27 }; 27 };
28 28
29 $scope.salir = function() { 29 $scope.salir = function() {
30 $location.path('/'); 30 $location.path('/');
31 }; 31 };
32 32
33 $scope.search = function(key) { 33 $scope.search = function(key) {
34 if (key === 13) { 34 if (key === 13) {
35 $scope.idUsuario = $scope.idUsuarioInput; 35 $scope.idUsuario = $scope.idUsuarioInput;
36 getSeguimiento(); 36 getSeguimiento();
37 } 37 }
38 }; 38 };
39 39
40 $scope.fecha = function() { 40 $scope.fecha = function() {
41 getSeguimiento(); 41 getSeguimiento();
42 }; 42 };
43 43
44 function getSeguimiento () { 44 function getSeguimiento () {
45 var now = $scope.now; 45 var now = $scope.now;
46 var desde = new Date(new Date(now.setHours(0)).setMinutes(0));
47 desde = desde.setDate(desde.getDate() - 1);
48 desde = new Date(desde);
46 var datos = { 49 var datos = {
47 actividad: $scope.actividad, 50 actividad: $scope.actividad,
48 idUsuario: $scope.idUsuario, 51 idUsuario: $scope.idUsuario,
49 fechaDesde: new Date(new Date(now.setHours(0)).setMinutes(0)), 52 fechaDesde: desde,
50 fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) 53 fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59))
51 }; 54 };
52 55
53 $scope.datosBuscados = { 56 $scope.datosBuscados = {
54 actividad: $scope.actividad, 57 actividad: $scope.actividad,
55 individual: $scope.idUsuario !== 0 ? true : false 58 individual: $scope.idUsuario !== 0 ? true : false
56 }; 59 };
57 60
58 focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) { 61 focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) {
59 62
60 $scope.marcadores = datos.data; 63 $scope.marcadores = datos.data;
61 }); 64 });
62 } 65 }
63 } 66 }
64 ]); 67 ]);
65 68