Commit de68e7e0cb6d8096f50e0a008bbde4e79128c73f
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !24
Showing
5 changed files
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaAdminSeguimiento').controller('focaAdminSeguimientoController', [ |
2 | - '$scope', '$timeout', 'focaAdminSeguimientoService', | |
2 | + '$scope', '$timeout', 'focaAdminSeguimientoService', '$uibModal', | |
3 | 3 | 'focaBotoneraLateralService','$location', '$routeParams', |
4 | - function($scope, $timeout, focaAdminSeguimientoService, | |
4 | + function($scope, $timeout, focaAdminSeguimientoService, $uibModal, | |
5 | 5 | focaBotoneraLateralService, $location, $routeParams) { |
6 | 6 | $scope.actividad = ''; |
7 | 7 | $scope.titulo = ''; |
... | ... | @@ -78,6 +78,54 @@ angular.module('focaAdminSeguimiento').controller('focaAdminSeguimientoControlle |
78 | 78 | getSeguimiento(); |
79 | 79 | }; |
80 | 80 | |
81 | + $scope.showMarcadores = function() { | |
82 | + var texto = ''; | |
83 | + | |
84 | + if ($scope.actividad === 'Nota de pedido') { | |
85 | + texto = 'Marcadores de notas de pedido'; | |
86 | + } | |
87 | + | |
88 | + if ($scope.actividad === 'Entrega de producto') { | |
89 | + texto = 'Marcadores de entregas'; | |
90 | + } | |
91 | + | |
92 | + if ($scope.actividad === 'Cobranza') { | |
93 | + texto = 'Marcadores de cobranzas'; | |
94 | + } | |
95 | + | |
96 | + | |
97 | + var modalInstance = $uibModal.open( | |
98 | + { | |
99 | + ariaLabelledBy: texto, | |
100 | + templateUrl: 'foca-modal-marcadores.html', | |
101 | + controller: 'focaModalMarcadoresController', | |
102 | + size: 'lg', | |
103 | + resolve: { | |
104 | + parametros: function() { | |
105 | + var parametros = { | |
106 | + marcadores: $scope.marcadores, | |
107 | + actividad: $scope.actividad | |
108 | + }; | |
109 | + | |
110 | + return parametros; | |
111 | + } | |
112 | + } | |
113 | + } | |
114 | + ); | |
115 | + | |
116 | + modalInstance.result.then( | |
117 | + function(localizacion) { | |
118 | + $scope.$broadcast('moveMap', { | |
119 | + latitud: localizacion.latitud, | |
120 | + longitud: localizacion.longitud, | |
121 | + indice: localizacion.indice | |
122 | + }); | |
123 | + }, function() { | |
124 | + // funcion ejecutada cuando se cancela el modal | |
125 | + } | |
126 | + ); | |
127 | + }; | |
128 | + | |
81 | 129 | function getSeguimiento() { |
82 | 130 | var now = $scope.now; |
83 | 131 | var hasta = angular.copy(now); |
... | ... | @@ -128,8 +176,8 @@ angular.module('focaAdminSeguimiento').controller('focaAdminSeguimientoControlle |
128 | 176 | break; |
129 | 177 | case 'cobranza': |
130 | 178 | if (datos.data.length) { |
131 | - valor = datos.data[0].notaPedido.vendedor.NUM + ' - ' + | |
132 | - datos.data[0].notaPedido.vendedor.NOM.trim(); | |
179 | + valor = datos.data[0].recibo.cobrador.NUM + ' - ' + | |
180 | + datos.data[0].recibo.cobrador.NOM.trim(); | |
133 | 181 | } else { |
134 | 182 | valor = $scope.idUsuario; |
135 | 183 | } |
src/js/modalController.js
... | ... | @@ -0,0 +1,110 @@ |
1 | +angular.module('focaAdminSeguimiento').controller('focaModalMarcadoresController', [ | |
2 | + '$uibModalInstance', '$scope', '$filter', 'parametros', | |
3 | + function($uibModalInstance, $scope, $filter, parametros) { | |
4 | + init(); | |
5 | + | |
6 | + $scope.selectPage = selectPage; | |
7 | + | |
8 | + $scope.select = function(marcador, indice) { | |
9 | + $uibModalInstance.close({ | |
10 | + latitud: marcador.latitud, | |
11 | + longitud: marcador.longitud, | |
12 | + indice: indice | |
13 | + }); | |
14 | + }; | |
15 | + | |
16 | + $scope.cancel = function() { | |
17 | + $uibModalInstance.dismiss('cancel'); | |
18 | + }; | |
19 | + | |
20 | + function init() { | |
21 | + $scope.numPerPage = 10; | |
22 | + $scope.currentPage = 1; | |
23 | + $scope.currentPageMarcadores = []; | |
24 | + $scope.actividad = parametros.actividad; | |
25 | + $scope.marcadores = arrayDatos(angular.copy(parametros.marcadores)); | |
26 | + | |
27 | + $scope.lastPage = Math.ceil( | |
28 | + $scope.marcadores.length / $scope.numPerPage | |
29 | + ); | |
30 | + | |
31 | + selectPage(1); | |
32 | + } | |
33 | + | |
34 | + function selectPage(page) { | |
35 | + var start = (page - 1) * $scope.numPerPage; | |
36 | + var end = start + $scope.numPerPage; | |
37 | + $scope.paginas = []; | |
38 | + $scope.paginas = calcularPages(page); | |
39 | + $scope.currentPageMarcadores = $scope.marcadores.slice(start, end); | |
40 | + $scope.currentPage = page; | |
41 | + } | |
42 | + | |
43 | + function calcularPages(paginaActual) { | |
44 | + var paginas = []; | |
45 | + paginas.push(paginaActual); | |
46 | + | |
47 | + if (paginaActual - 1 > 1) { | |
48 | + | |
49 | + paginas.unshift(paginaActual - 1); | |
50 | + if (paginaActual - 2 > 1) { | |
51 | + paginas.unshift(paginaActual - 2); | |
52 | + } | |
53 | + } | |
54 | + | |
55 | + if (paginaActual + 1 < $scope.lastPage) { | |
56 | + paginas.push(paginaActual + 1); | |
57 | + if (paginaActual + 2 < $scope.lastPage) { | |
58 | + paginas.push(paginaActual + 2); | |
59 | + } | |
60 | + } | |
61 | + | |
62 | + if (paginaActual !== 1) { | |
63 | + paginas.unshift(1); | |
64 | + } | |
65 | + | |
66 | + if (paginaActual !== $scope.lastPage) { | |
67 | + paginas.push($scope.lastPage); | |
68 | + } | |
69 | + | |
70 | + return paginas; | |
71 | + } | |
72 | + | |
73 | + function arrayDatos(marcadores) { | |
74 | + marcadores.reverse(); | |
75 | + | |
76 | + for (var i = marcadores.length - 1; i >= 0; i--) { | |
77 | + var marcador = marcadores[i]; | |
78 | + | |
79 | + if ($scope.actividad === 'Nota de pedido') { | |
80 | + marcador.numero = $filter('comprobante')([ | |
81 | + marcador.notaPedido.sucursal, | |
82 | + marcador.notaPedido.numeroNotaPedido | |
83 | + ]); | |
84 | + | |
85 | + marcador.cliente = $filter('rellenarDigitos')( | |
86 | + marcador.notaPedido.cliente.COD, 3) + ' - ' + | |
87 | + marcador.notaPedido.cliente.NOM; | |
88 | + } | |
89 | + | |
90 | + if ($scope.actividad === 'Entrega de producto') { | |
91 | + | |
92 | + } | |
93 | + | |
94 | + if ($scope.actividad === 'Cobranza') { | |
95 | + marcador.numero = $filter('comprobante')([ | |
96 | + marcador.recibo.PVE, | |
97 | + marcador.recibo.NCO | |
98 | + ]); | |
99 | + | |
100 | + marcador.cliente = $filter('rellenarDigitos')( | |
101 | + marcador.recibo.CLI, 3) + ' - ' + | |
102 | + marcador.recibo.CFE; | |
103 | + } | |
104 | + } | |
105 | + | |
106 | + return marcadores; | |
107 | + } | |
108 | + | |
109 | + } | |
110 | +]); | |
0 | 111 | \ No newline at end of file |
src/js/osm-directive.js
... | ... | @@ -121,7 +121,6 @@ angular.module('focaAdminSeguimiento').directive('osm', function() { |
121 | 121 | ]); |
122 | 122 | } |
123 | 123 | |
124 | - console.info(marcador, observacion); | |
125 | 124 | return observacion; |
126 | 125 | } |
127 | 126 | |
... | ... | @@ -231,6 +230,13 @@ angular.module('focaAdminSeguimiento').directive('osm', function() { |
231 | 230 | return resultado; |
232 | 231 | } |
233 | 232 | }); |
233 | + | |
234 | + | |
235 | + $scope.$on('moveMap', function(evt, data) { | |
236 | + var center = new L.LatLng(data.latitud, data.longitud); | |
237 | + $scope.map.flyTo(center, 11, {duration: 0.5}); | |
238 | + $scope.markers[data.indice].openPopup(); | |
239 | + }); | |
234 | 240 | }], |
235 | 241 | scope: { |
236 | 242 | latitud: '=', |
src/views/foca-admin-seguimiento.html
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | class="btn col-12 my-1" |
42 | 42 | ng-click="individual()" |
43 | 43 | >Individual</button> |
44 | - <div class="form-group" ng-show="idUsuario != 0"> | |
44 | + <div class="form-group my-1" ng-show="idUsuario != 0"> | |
45 | 45 | <input |
46 | 46 | type="text" |
47 | 47 | placeholder="Vendedor" |
... | ... | @@ -70,6 +70,12 @@ |
70 | 70 | ng-show="actividad == 'Cobranza'" |
71 | 71 | > |
72 | 72 | </div> |
73 | + <button | |
74 | + type="button" | |
75 | + class="btn col-12 my-1" | |
76 | + ng-show="marcadores.length > 0 && idUsuario > 0" | |
77 | + ng-click="showMarcadores()" | |
78 | + >Listar marcadores</button> | |
73 | 79 | <div ng-show="actividad === 'Entrega de producto' && idUsuario != 0"> |
74 | 80 | <div class="custom-control custom-radio"> |
75 | 81 | <input |
src/views/foca-modal-marcadores.html
... | ... | @@ -0,0 +1,70 @@ |
1 | +<div class="modal-header py-1"> | |
2 | + <div class="row w-100"> | |
3 | + <div class="col-lg-4 col-7"> | |
4 | + <h5 class="modal-title my-1">Lista de Marcadores</h5> | |
5 | + </div> | |
6 | + </div> | |
7 | +</div> | |
8 | +<div class="modal-body" id="modal-body"> | |
9 | + <table class="table table-striped table-sm"> | |
10 | + <thead> | |
11 | + <tr> | |
12 | + <th>Orden</th> | |
13 | + <th>Número</th> | |
14 | + <th>Cliente</th> | |
15 | + <th>Km desde la base</th> | |
16 | + <th></th> | |
17 | + </tr> | |
18 | + </thead> | |
19 | + <tbody> | |
20 | + <tr | |
21 | + ng-repeat="(key, marcador) in currentPageMarcadores" | |
22 | + > | |
23 | + <td ng-bind="marcador.orden"></td> | |
24 | + <td ng-bind="marcador.numero"></td> | |
25 | + <td ng-bind="marcador.cliente"></td> | |
26 | + <td ng-bind="marcador.distancia"></td> | |
27 | + <td> | |
28 | + <button | |
29 | + type="button" | |
30 | + class="btn btn-xs p-1 float-right btn-primary" | |
31 | + ng-click="select(marcador, (currentPageMarcadores.length - key - 1))" | |
32 | + > | |
33 | + <i class="fa fa-map-marker px-1" aria-hidden="true"></i> | |
34 | + </button> | |
35 | + </td> | |
36 | + </tr> | |
37 | + </tbody> | |
38 | + </table> | |
39 | +</div> | |
40 | +<div class="modal-footer py-1"> | |
41 | + <nav ng-show="currentPageClientes.length > 0 && primerBusqueda && !ingreso" class="mr-auto"> | |
42 | + <ul class="pagination pagination-sm mb-0"> | |
43 | + <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | |
44 | + <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage - 1)"> | |
45 | + <span aria-hidden="true">«</span> | |
46 | + <span class="sr-only">Anterior</span> | |
47 | + </a> | |
48 | + </li> | |
49 | + <li | |
50 | + class="page-item" | |
51 | + ng-repeat="pagina in paginas" | |
52 | + ng-class="{'active': pagina == currentPage}" | |
53 | + > | |
54 | + <a | |
55 | + class="page-link" | |
56 | + href="javascript:void()" | |
57 | + ng-click="selectPage(pagina)" | |
58 | + ng-bind="pagina" | |
59 | + ></a> | |
60 | + </li> | |
61 | + <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | |
62 | + <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage + 1)"> | |
63 | + <span aria-hidden="true">»</span> | |
64 | + <span class="sr-only">Siguiente</span> | |
65 | + </a> | |
66 | + </li> | |
67 | + </ul> | |
68 | + </nav> | |
69 | + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | |
70 | +</div> |