Commit a0b90d78c5ba3b356b245d68859e5f46712aa53a
Exists in
master
Merge branch 'master' into 'master'
Master See merge request !7
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearLogin') | 1 | angular.module('focaCrearLogin') |
2 | .controller('focaCrearLoginController', [ | 2 | .controller('focaCrearLoginController', [ |
3 | '$scope', '$timeout', '$uibModal', 'focaCrearLoginService','focaBotoneraLateralService', | 3 | '$scope', '$timeout', '$uibModal', 'focaCrearLoginService','focaBotoneraLateralService', |
4 | function($scope, $timeout, $uibModal, focaCrearLoginService, focaBotoneraLateralService) { | 4 | function($scope, $timeout, $uibModal, focaCrearLoginService, focaBotoneraLateralService) { |
5 | config(); | 5 | config(); |
6 | 6 | ||
7 | //METODOS | 7 | //METODOS |
8 | function init() { | 8 | function init() { |
9 | $scope.numPerPage = 9; | 9 | $scope.numPerPage = 9; |
10 | $scope.now = new Date(); | 10 | $scope.now = new Date(); |
11 | $scope.seleccionado = ''; | 11 | $scope.seleccionado = ''; |
12 | $scope.cuentas = []; | 12 | $scope.cuentas = []; |
13 | $scope.$broadcast('removeCabecera', { | 13 | $scope.$broadcast('removeCabecera', { |
14 | label: 'Selección:', | 14 | label: 'Selección:', |
15 | valor: $scope.seleccionado | 15 | valor: $scope.seleccionado |
16 | }); | 16 | }); |
17 | } | 17 | } |
18 | 18 | ||
19 | function config() { | 19 | function config() { |
20 | $scope.botonera = [ | 20 | $scope.botonera = [ |
21 | { | 21 | { |
22 | label: 'Transportista', | 22 | label: 'Transportista', |
23 | image: 'cliente.png' | 23 | image: 'cliente.png' |
24 | }, | 24 | }, |
25 | { | 25 | { |
26 | label: 'Cobrador', | 26 | label: 'Cobrador', |
27 | image: 'cliente.png' | 27 | image: 'cliente.png' |
28 | }, | 28 | }, |
29 | { | 29 | { |
30 | label: 'Vendedor', | 30 | label: 'Vendedor', |
31 | image: 'cliente.png' | 31 | image: 'cliente.png' |
32 | } | 32 | } |
33 | ]; | 33 | ]; |
34 | 34 | ||
35 | $timeout(function() { | 35 | $timeout(function() { |
36 | focaBotoneraLateralService.showSalir(true); | 36 | focaBotoneraLateralService.showSalir(true); |
37 | focaBotoneraLateralService.showPausar(false); | 37 | focaBotoneraLateralService.showPausar(false); |
38 | focaBotoneraLateralService.showCancelar(false); | 38 | focaBotoneraLateralService.showCancelar(false); |
39 | focaBotoneraLateralService.showGuardar(false); | 39 | focaBotoneraLateralService.showGuardar(false); |
40 | }); | 40 | }); |
41 | 41 | ||
42 | init(); | 42 | init(); |
43 | } | 43 | } |
44 | 44 | ||
45 | $scope.seleccionarTransportista = function() { | 45 | $scope.seleccionarTransportista = function() { |
46 | $scope.seleccionado = 'Transportistas'; | 46 | $scope.seleccionado = 'Transportistas'; |
47 | 47 | ||
48 | focaCrearLoginService.getListaChoferes().then(setearTabla); | 48 | focaCrearLoginService.getListaChoferes().then(setearTabla); |
49 | }; | 49 | }; |
50 | 50 | ||
51 | $scope.seleccionarCobrador = function() { | 51 | $scope.seleccionarCobrador = function() { |
52 | $scope.seleccionado = 'Cobradores'; | 52 | $scope.seleccionado = 'Cobradores'; |
53 | 53 | ||
54 | focaCrearLoginService.getListaCobradores().then(setearTabla); | 54 | focaCrearLoginService.getListaCobradores().then(setearTabla); |
55 | }; | 55 | }; |
56 | 56 | ||
57 | $scope.seleccionarVendedor = function() { | 57 | $scope.seleccionarVendedor = function() { |
58 | $scope.seleccionado = 'Vendedores'; | 58 | $scope.seleccionado = 'Vendedores'; |
59 | 59 | ||
60 | focaCrearLoginService.getListaVendedores().then(setearTabla); | 60 | focaCrearLoginService.getListaVendedores().then(setearTabla); |
61 | }; | 61 | }; |
62 | 62 | ||
63 | $scope.openModalAcceso = function(cuenta) { | 63 | $scope.openModalAcceso = function(cuenta) { |
64 | var parametros = { | 64 | var parametros = { |
65 | cuenta: cuenta, | 65 | cuenta: cuenta, |
66 | tipo: $scope.seleccionado | 66 | tipo: $scope.seleccionado |
67 | }; | 67 | }; |
68 | 68 | ||
69 | var modalInstance = $uibModal.open( | 69 | var modalInstance = $uibModal.open( |
70 | { | 70 | { |
71 | ariaLabelledBy: 'Configuracion de Logueo', | 71 | ariaLabelledBy: 'Configuracion de Logueo', |
72 | templateUrl: 'modal-login.html', | 72 | templateUrl: 'modal-login.html', |
73 | controller: 'focaModalLoginController', | 73 | controller: 'focaModalLoginController', |
74 | size: 'md', | 74 | size: 'md', |
75 | resolve: { | 75 | resolve: { |
76 | parametros: function() { | 76 | parametros: function() { |
77 | return parametros; | 77 | return parametros; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | } | 80 | } |
81 | ); | 81 | ); |
82 | 82 | ||
83 | modalInstance.result.then( | 83 | modalInstance.result.then( |
84 | function(result) { | 84 | function(result) { |
85 | init(); | 85 | init(); |
86 | }, function() {} | 86 | }, function() {} |
87 | ); | 87 | ); |
88 | }; | 88 | }; |
89 | 89 | ||
90 | $scope.selectPage = function(page) { | 90 | $scope.selectPage = function(page) { |
91 | var start = (page - 1) * $scope.numPerPage; | 91 | var start = (page - 1) * $scope.numPerPage; |
92 | var end = start + $scope.numPerPage; | 92 | var end = start + $scope.numPerPage; |
93 | $scope.paginas = []; | 93 | $scope.paginas = []; |
94 | $scope.paginas = calcularPages(page); | 94 | $scope.paginas = calcularPages(page); |
95 | $scope.currentPageUsuarios = | 95 | $scope.currentPageUsuarios = |
96 | $scope.cuentas.slice(start, end); | 96 | $scope.cuentas.slice(start, end); |
97 | $scope.currentPage = page; | 97 | $scope.currentPage = page; |
98 | }; | 98 | }; |
99 | 99 | ||
100 | $scope.resetPage = function() { | 100 | $scope.resetPage = function() { |
101 | $scope.currentPage = 1; | 101 | $scope.currentPage = 1; |
102 | $scope.selectPage(1); | 102 | $scope.selectPage(1); |
103 | }; | 103 | }; |
104 | 104 | ||
105 | function setearTabla(datos) { | 105 | function setearTabla(datos) { |
106 | $scope.cuentas = datos.data; | 106 | $scope.cuentas = datos.data; |
107 | 107 | ||
108 | $scope.lastPage = Math.ceil( | 108 | $scope.lastPage = Math.ceil( |
109 | $scope.cuentas.length / $scope.numPerPage | 109 | $scope.cuentas.length / $scope.numPerPage |
110 | ); | 110 | ); |
111 | $scope.resetPage(); | 111 | $scope.resetPage(); |
112 | 112 | ||
113 | if ($scope.seleccionado == 'Cobradores' || | 113 | if ($scope.seleccionado == 'Cobradores' || |
114 | $scope.seleccionado == 'Vendedores' | 114 | $scope.seleccionado == 'Vendedores' |
115 | ) { | 115 | ) { |
116 | for (var i = $scope.cuentas.length - 1; i >= 0; i--) { | 116 | for (var i = $scope.cuentas.length - 1; i >= 0; i--) { |
117 | $scope.cuentas[i].id = $scope.cuentas[i].CodVen; | 117 | $scope.cuentas[i].codigo = $scope.cuentas[i].NUM; |
118 | $scope.cuentas[i].nombre = $scope.cuentas[i].NomVen; | 118 | $scope.cuentas[i].nombre = $scope.cuentas[i].NOM; |
119 | $scope.cuentas[i].dni = $scope.cuentas[i].DNI; | 119 | $scope.cuentas[i].dni = $scope.cuentas[i].dni; |
120 | $scope.cuentas[i].telefono = $scope.cuentas[i].TelVen; | ||
121 | } | 120 | } |
121 | } else { | ||
122 | for (var i = $scope.cuentas.length - 1; i >= 0; i--) { | ||
123 | $scope.cuentas[i].codigo = $scope.cuentas[i].id; | ||
124 | } | ||
122 | } | 125 | } |
123 | 126 | ||
124 | $scope.$broadcast('removeCabecera', { | 127 | $scope.$broadcast('removeCabecera', { |
125 | label: 'Selección:', | 128 | label: 'Selección:', |
126 | valor: $scope.seleccionado | 129 | valor: $scope.seleccionado |
127 | }); | 130 | }); |
128 | } | 131 | } |
129 | 132 | ||
130 | function calcularPages(paginaActual) { | 133 | function calcularPages(paginaActual) { |
131 | var paginas = []; | 134 | var paginas = []; |
132 | paginas.push(paginaActual); | 135 | paginas.push(paginaActual); |
133 | 136 | ||
134 | if(paginaActual - 1 > 1) { | 137 | if(paginaActual - 1 > 1) { |
135 | 138 | ||
136 | paginas.unshift(paginaActual - 1); | 139 | paginas.unshift(paginaActual - 1); |
137 | if(paginaActual - 2 > 1) { | 140 | if(paginaActual - 2 > 1) { |
138 | paginas.unshift(paginaActual - 2); | 141 | paginas.unshift(paginaActual - 2); |
139 | } | 142 | } |
140 | } | 143 | } |
141 | 144 | ||
142 | if(paginaActual + 1 < $scope.lastPage) { | 145 | if(paginaActual + 1 < $scope.lastPage) { |
143 | paginas.push(paginaActual + 1); | 146 | paginas.push(paginaActual + 1); |
144 | if(paginaActual + 2 < $scope.lastPage) { | 147 | if(paginaActual + 2 < $scope.lastPage) { |
145 | paginas.push(paginaActual + 2); | 148 | paginas.push(paginaActual + 2); |
146 | } | 149 | } |
147 | } | 150 | } |
148 | 151 | ||
149 | if(paginaActual !== 1) { | 152 | if(paginaActual !== 1) { |
150 | paginas.unshift(1); | 153 | paginas.unshift(1); |
151 | } | 154 | } |
152 | 155 | ||
153 | if(paginaActual !== $scope.lastPage) { | 156 | if(paginaActual !== $scope.lastPage) { |
154 | paginas.push($scope.lastPage); | 157 | paginas.push($scope.lastPage); |
155 | } | 158 | } |
156 | 159 | ||
157 | return paginas; | 160 | return paginas; |
158 | } | 161 | } |
159 | 162 | ||
160 | function primera() { | 163 | function primera() { |
161 | $scope.selectedUsuarios = 0; | 164 | $scope.selectedUsuarios = 0; |
162 | } | 165 | } |
163 | 166 | ||
164 | function anterior() { | 167 | function anterior() { |
165 | if ($scope.selectedUsuarios === 0 && $scope.currentPage > 1) { | 168 | if ($scope.selectedUsuarios === 0 && $scope.currentPage > 1) { |
166 | retrocederPagina(); | 169 | retrocederPagina(); |
167 | } else { | 170 | } else { |
168 | $scope.selectedUsuarios--; | 171 | $scope.selectedUsuarios--; |
169 | } | 172 | } |
170 | } | 173 | } |
171 | 174 | ||
172 | function siguiente() { | 175 | function siguiente() { |
173 | if ($scope.selectedUsuarios < $scope.currentPageUsuarios.length - 1 ) { | 176 | if ($scope.selectedUsuarios < $scope.currentPageUsuarios.length - 1 ) { |
174 | $scope.selectedUsuarios++; | 177 | $scope.selectedUsuarios++; |
175 | } else { | 178 | } else { |
176 | avanzarPagina(); | 179 | avanzarPagina(); |
177 | } | 180 | } |
178 | } | 181 | } |
179 | 182 | ||
180 | function retrocederPagina() { | 183 | function retrocederPagina() { |
181 | if ($scope.currentPage > 1) { | 184 | if ($scope.currentPage > 1) { |
182 | $scope.selectPage($scope.currentPage - 1); | 185 | $scope.selectPage($scope.currentPage - 1); |
183 | $scope.selectedUsuarios = $scope.numPerPage - 1; | 186 | $scope.selectedUsuarios = $scope.numPerPage - 1; |
184 | } | 187 | } |
185 | } | 188 | } |
186 | 189 | ||
187 | function avanzarPagina() { | 190 | function avanzarPagina() { |
188 | if ($scope.currentPage < $scope.lastPage) { | 191 | if ($scope.currentPage < $scope.lastPage) { |
189 | $scope.selectPage($scope.currentPage + 1); | 192 | $scope.selectPage($scope.currentPage + 1); |
190 | $scope.selectedUsuarios = 0; | 193 | $scope.selectedUsuarios = 0; |
191 | } | 194 | } |
192 | } | 195 | } |
193 | } | 196 | } |
194 | ]); | 197 | ]); |
src/views/foca-crear-login.html
1 | <div class="row"> | 1 | <div class="row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Administración de Ingreso'" | 3 | titulo="'Administración de Ingreso'" |
4 | fecha="now" | 4 | fecha="now" |
5 | class="mb-0 col-12" | 5 | class="mb-0 col-12" |
6 | ></foca-cabecera-facturador> | 6 | ></foca-cabecera-facturador> |
7 | </div> | 7 | </div> |
8 | <div class="row"> | 8 | <div class="row"> |
9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> |
10 | <div class="row px-5 py-2 botonera-secundaria"> | 10 | <div class="row px-5 py-2 botonera-secundaria"> |
11 | <div class="col-12"> | 11 | <div class="col-12"> |
12 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | 12 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> |
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
15 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | 15 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> |
16 | <thead> | 16 | <thead> |
17 | <tr> | 17 | <tr> |
18 | <th>Código</th> | 18 | <th>Código</th> |
19 | <th>Nombre</th> | 19 | <th>Nombre</th> |
20 | <th>DNI</th> | 20 | <th>DNI</th> |
21 | <th>Teléfono</th> | 21 | <th>Teléfono</th> |
22 | <th class="text-center"> | 22 | <th class="text-center"> |
23 | </th> | 23 | </th> |
24 | </tr> | 24 | </tr> |
25 | </thead> | 25 | </thead> |
26 | <tbody> | 26 | <tbody> |
27 | <tr ng-repeat="cuenta in currentPageUsuarios"> | 27 | <tr ng-repeat="cuenta in currentPageUsuarios"> |
28 | <td ng-bind="cuenta.id"></td> | 28 | <td ng-bind="cuenta.codigo"></td> |
29 | <td ng-bind="cuenta.nombre"></td> | 29 | <td ng-bind="cuenta.nombre"></td> |
30 | <td ng-bind="cuenta.dni"></td> | 30 | <td ng-bind="cuenta.dni"></td> |
31 | <td ng-bind="cuenta.telefono"></td> | 31 | <td ng-bind="cuenta.telefono"></td> |
32 | <td class="text-center"> | 32 | <td class="text-center"> |
33 | <button | 33 | <button |
34 | class="btn btn-outline-dark boton-accion" | 34 | class="btn btn-outline-dark boton-accion" |
35 | title="Editar acceso" | 35 | title="Editar acceso" |
36 | ng-click="openModalAcceso(cuenta)" | 36 | ng-click="openModalAcceso(cuenta)" |
37 | > | 37 | > |
38 | <i class="fa fa-lock"></i> | 38 | <i class="fa fa-lock"></i> |
39 | </button> | 39 | </button> |
40 | </td> | 40 | </td> |
41 | </tr> | 41 | </tr> |
42 | </body> | 42 | </body> |
43 | </table> | 43 | </table> |
44 | </div> | 44 | </div> |
45 | </div> | 45 | </div> |
46 | <div class="row"> | 46 | <div class="row"> |
47 | <nav ng-show="currentPageUsuarios.length > 0" class="mr-auto paginador-abm"> | 47 | <nav ng-show="currentPageUsuarios.length > 0" class="mr-auto paginador-abm"> |
48 | <ul class="pagination pagination-sm mb-0"> | 48 | <ul class="pagination pagination-sm mb-0"> |
49 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | 49 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |
50 | <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage - 1)"> | 50 | <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage - 1)"> |
51 | <span aria-hidden="true">«</span> | 51 | <span aria-hidden="true">«</span> |
52 | <span class="sr-only">Anterior</span> | 52 | <span class="sr-only">Anterior</span> |
53 | </a> | 53 | </a> |
54 | </li> | 54 | </li> |
55 | <li | 55 | <li |
56 | class="page-item" | 56 | class="page-item" |
57 | ng-repeat="pagina in paginas" | 57 | ng-repeat="pagina in paginas" |
58 | ng-class="{'active': pagina == currentPage}" | 58 | ng-class="{'active': pagina == currentPage}" |
59 | > | 59 | > |
60 | <a | 60 | <a |
61 | class="page-link" | 61 | class="page-link" |
62 | href="javascript:void()" | 62 | href="javascript:void()" |
63 | ng-click="selectPage(pagina)" | 63 | ng-click="selectPage(pagina)" |
64 | ng-bind="pagina" | 64 | ng-bind="pagina" |
65 | ></a> | 65 | ></a> |
66 | </li> | 66 | </li> |
67 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | 67 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> |
68 | <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage + 1)"> | 68 | <a class="page-link" href="javascript:void()" ng-click="selectPage(currentPage + 1)"> |
69 | <span aria-hidden="true">»</span> | 69 | <span aria-hidden="true">»</span> |
70 | <span class="sr-only">Siguiente</span> | 70 | <span class="sr-only">Siguiente</span> |
71 | </a> | 71 | </a> |
72 | </li> | 72 | </li> |
73 | </ul> | 73 | </ul> |
74 | </nav> | 74 | </nav> |
75 | </div> | 75 | </div> |
76 | 76 |