Commit a21fb2beb8cd941d4fecfcd6840aa1338394c09f
Exists in
master
Merge branch 'master' into 'master'
Master See merge request modulos-npm/foca-admin-seguimiento!8
Showing
3 changed files
Show diff stats
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 datos = { | 46 | var datos = { |
| 46 | actividad: $scope.actividad, | 47 | actividad: $scope.actividad, |
| 47 | idUsuario: $scope.idUsuario, | 48 | idUsuario: $scope.idUsuario, |
| 48 | fechaDesde: $scope.now, | 49 | fechaDesde: new Date(new Date(now.setHours(0)).setMinutes(0)), |
| 49 | fechaHasta: $scope.now | 50 | fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) |
| 51 | }; | ||
| 52 | |||
| 53 | $scope.datosBuscados = { | ||
| 54 | actividad: $scope.actividad, | ||
| 55 | individual: $scope.idUsuario !== 0 ? true : false | ||
| 50 | }; | 56 | }; |
| 51 | 57 | ||
| 52 | focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) { | 58 | focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) { |
| 59 | |||
| 53 | $scope.marcadores = datos.data; | 60 | $scope.marcadores = datos.data; |
| 54 | }); | 61 | }); |
| 55 | } | 62 | } |
| 56 | } | 63 | } |
| 57 | ]); | 64 | ]); |
| 58 | 65 |
src/js/osm-directive.js
| 1 | angular.module('focaAdminSeguimiento').directive('osm', function() { | 1 | angular.module('focaAdminSeguimiento').directive('osm', 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 | 16 | ||
| 17 | $scope.markers = []; | 17 | $scope.markers = []; |
| 18 | angular.forEach($scope.marcadores, function(marcador) { | 18 | angular.forEach($scope.marcadores, function(marcador) { |
| 19 | var observacion = ''; | ||
| 20 | observacion += 'Actividad: ' + marcador.actividad + '<br/>'; | ||
| 21 | |||
| 22 | observacion += 'Fecha: ' + | ||
| 23 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | ||
| 24 | marcador.fecha.slice(11,19) + '<br/>'; | ||
| 25 | |||
| 26 | if ($scope.parametros.actividad === 'Nota de pedido') { | ||
| 27 | observacion += | ||
| 28 | 'Vendedor: ' + marcador.idUsuario + ' - ' + | ||
| 29 | ( | ||
| 30 | marcador.notaPedido.vendedor ? | ||
| 31 | marcador.notaPedido.vendedor.nombre : | ||
| 32 | '' | ||
| 33 | ) + '<br/>'; | ||
| 34 | |||
| 35 | if ($scope.parametros.individual) { | ||
| 36 | observacion += 'Nº: ' + $filter('comprobante')([ | ||
| 37 | marcador.notaPedido.sucursal, | ||
| 38 | marcador.notaPedido.numeroNotaPedido | ||
| 39 | ]) + '<br/>'; | ||
| 40 | observacion += | ||
| 41 | 'Total: ' + $filter('currency')(marcador.notaPedido.total, '$'); | ||
| 42 | } else { | ||
| 43 | observacion += 'Cantidad de nota de pedido: ' + marcador.cantidad; | ||
| 44 | observacion += 'Total Vendido: ' + | ||
| 45 | $filter('currency')(marcador.total, '$'); | ||
| 46 | } | ||
| 47 | } else { | ||
| 48 | observacion += 'Vehiculo: ' + marcador.idUsuario + '<br/>'; | ||
| 49 | if ($scope.parametros.individual) { | ||
| 50 | observacion += 'Hoja de ruta: ' + $filter('comprobante')([ | ||
| 51 | marcador.remito[0].hojaRuta[0].sucursal, | ||
| 52 | marcador.remito[0].hojaRuta[0].numeroHojaRuta | ||
| 53 | ]) + '<br/>'; | ||
| 54 | observacion += 'Remito: ' + $filter('comprobante')([ | ||
| 55 | marcador.remito[0].sucursal, | ||
| 56 | marcador.remito[0].numeroRemito | ||
| 57 | ]) + '<br/>'; | ||
| 58 | observacion += 'Producto: ' + | ||
| 59 | marcador.remito[0].articuloRemito[0].descripcion + '<br/>'; | ||
| 60 | observacion += 'Cantidad entregada: ' + | ||
| 61 | marcador.remito[0].carga + '<br/>'; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 19 | $scope.markers.push( | 65 | $scope.markers.push( |
| 20 | L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) | 66 | L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) |
| 21 | .bindPopup( | 67 | .bindPopup(observacion) |
| 22 | 'Actividad: ' + marcador.actividad + '<br/>' + | ||
| 23 | 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + | ||
| 24 | ' ' + marcador.fecha.slice(11,19) + '<br/>' + | ||
| 25 | marcador.observaciones | ||
| 26 | ).openPopup() | ||
| 27 | ); | 68 | ); |
| 69 | |||
| 70 | $scope.markers[0].openPopup(); | ||
| 28 | }); | 71 | }); |
| 29 | }); | 72 | }); |
| 30 | }], | 73 | }], |
| 31 | scope: { | 74 | scope: { |
| 32 | latitud: '=', | 75 | latitud: '=', |
| 33 | longitud: '=', | 76 | longitud: '=', |
| 34 | zoom: '=', | 77 | zoom: '=', |
| 35 | marcadores: '=' | 78 | marcadores: '=', |
src/views/foca-admin-seguimiento.html
| 1 | <div class="foca-admin-seguimiento"> | 1 | <div class="foca-admin-seguimiento"> |
| 2 | <div class="row"> | 2 | <div class="row"> |
| 3 | <div class="offset-1 col-9"> | 3 | <div class="offset-1 col-9"> |
| 4 | <osm | 4 | <osm |
| 5 | latitud="-32.89214159952345" | 5 | latitud="-32.89214159952345" |
| 6 | longitud="-68.84572999101856" | 6 | longitud="-68.84572999101856" |
| 7 | zoom="14" | 7 | zoom="14" |
| 8 | marcadores="marcadores" | 8 | marcadores="marcadores" |
| 9 | parametros= "datosBuscados" | ||
| 9 | /> | 10 | /> |
| 10 | </div> | 11 | </div> |
| 11 | <div class="col-2 pl-0"> | 12 | <div class="col-2 pl-0"> |
| 12 | <input | 13 | <input |
| 13 | type="date" | 14 | type="date" |
| 14 | ng-model="now" | 15 | ng-model="now" |
| 15 | class="btn col-12 my-1" | 16 | class="btn col-12 my-1" |
| 16 | foca-focus="true" | 17 | foca-focus="true" |
| 17 | ng-blur="fecha()" | 18 | ng-blur="fecha()" |
| 18 | hasta-hoy | 19 | hasta-hoy |
| 19 | /> | 20 | /> |
| 20 | <button | 21 | <button |
| 21 | type="button" | 22 | type="button" |
| 22 | ng-class="{'active': idUsuario == 0}" | 23 | ng-class="{'active': idUsuario == 0}" |
| 23 | class="btn col-12 my-1" | 24 | class="btn col-12 my-1" |
| 24 | ng-click="general()" | 25 | ng-click="general()" |
| 25 | >General</button> | 26 | >General</button> |
| 26 | <button | 27 | <button |
| 27 | type="button" | 28 | type="button" |
| 28 | ng-class="{'active': idUsuario != 0}" | 29 | ng-class="{'active': idUsuario != 0}" |
| 29 | class="btn col-12 my-1" | 30 | class="btn col-12 my-1" |
| 30 | ng-click="individual()" | 31 | ng-click="individual()" |
| 31 | >Individual</button> | 32 | >Individual</button> |
| 32 | <div class="form-group" ng-show="idUsuario == -1"> | 33 | <div class="form-group" ng-show="idUsuario == -1"> |
| 33 | <input | 34 | <input |
| 34 | type="text" | 35 | type="text" |
| 35 | placeholder="Vendedor" | 36 | placeholder="Vendedor" |
| 36 | class="form-control" | 37 | class="form-control" |
| 37 | ng-model="idUsuarioInput" | 38 | ng-model="idUsuarioInput" |
| 38 | ng-keypress="search($event.keyCode)" | 39 | ng-keypress="search($event.keyCode)" |
| 39 | foca-focus="idUsuario == -1" | 40 | foca-focus="idUsuario == -1" |
| 40 | ng-show="actividad == 'Nota de pedido'" | 41 | ng-show="actividad == 'Nota de pedido'" |
| 41 | > | 42 | > |
| 42 | <input | 43 | <input |
| 43 | type="text" | 44 | type="text" |
| 44 | placeholder="Vehiculo" | 45 | placeholder="Vehiculo" |
| 45 | class="form-control" | 46 | class="form-control" |
| 46 | ng-model="idUsuarioInput" | 47 | ng-model="idUsuarioInput" |
| 47 | ng-keypress="search($event.keyCode)" | 48 | ng-keypress="search($event.keyCode)" |
| 48 | foca-focus="idUsuario == -1" | 49 | foca-focus="idUsuario == -1" |
| 49 | ng-show="actividad == 'Entrega de producto'" | 50 | ng-show="actividad == 'Entrega de producto'" |
| 50 | > | 51 | > |
| 51 | </div> | 52 | </div> |
| 52 | <button | 53 | <button |
| 53 | type="button" | 54 | type="button" |
| 54 | class="btn col-12 my-1 boton-salir" | 55 | class="btn col-12 my-1 boton-salir" |
| 55 | ng-click="salir()" | 56 | ng-click="salir()" |
| 56 | > | 57 | > |
| 57 | Salir | 58 | Salir |
| 58 | </button> | 59 | </button> |
| 59 | </div> | 60 | </div> |
| 60 | </div> | 61 | </div> |
| 61 | </div> | 62 | </div> |
| 62 | 63 |