-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Hide company and warehouse filters on user list when there is only one element.
- Loading branch information
Showing
2 changed files
with
31 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
/** | ||
* This file is part of FacturaScripts | ||
* Copyright (C) 2017-2019 Carlos Garcia Gomez <[email protected]> | ||
* Copyright (C) 2017-2020 Carlos Garcia Gomez <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
|
@@ -43,50 +43,54 @@ public function getPageData() | |
} | ||
|
||
/** | ||
* | ||
* @param string $name | ||
* Load views | ||
*/ | ||
protected function createViewRoles($name = 'ListRole') | ||
protected function createViews() | ||
{ | ||
$this->addView($name, 'Role', 'roles', 'fas fa-address-card'); | ||
$this->addSearchFields($name, ['codrole', 'descripcion']); | ||
$this->addOrderBy($name, ['descripcion'], 'description'); | ||
$this->addOrderBy($name, ['codrole'], 'code'); | ||
$this->createViewsUsers(); | ||
$this->createViewsRoles(); | ||
} | ||
|
||
/** | ||
* Load views | ||
* | ||
* @param string $viewName | ||
*/ | ||
protected function createViews() | ||
protected function createViewsRoles(string $viewName = 'ListRole') | ||
{ | ||
$this->createViewUsers(); | ||
$this->createViewRoles(); | ||
$this->addView($viewName, 'Role', 'roles', 'fas fa-address-card'); | ||
$this->addSearchFields($viewName, ['codrole', 'descripcion']); | ||
$this->addOrderBy($viewName, ['descripcion'], 'description'); | ||
$this->addOrderBy($viewName, ['codrole'], 'code'); | ||
} | ||
|
||
/** | ||
* | ||
* @param string $name | ||
* @param string $viewName | ||
*/ | ||
protected function createViewUsers($name = 'ListUser') | ||
protected function createViewsUsers(string $viewName = 'ListUser') | ||
{ | ||
$this->addView($name, 'User', 'users', 'fas fa-users'); | ||
$this->addSearchFields($name, ['nick', 'email']); | ||
$this->addOrderBy($name, ['nick'], 'nick', 1); | ||
$this->addOrderBy($name, ['email'], 'email'); | ||
$this->addOrderBy($name, ['level'], 'level'); | ||
$this->addOrderBy($name, ['lastactivity'], 'last-activity'); | ||
$this->addView($viewName, 'User', 'users', 'fas fa-users'); | ||
$this->addSearchFields($viewName, ['nick', 'email']); | ||
$this->addOrderBy($viewName, ['nick'], 'nick', 1); | ||
$this->addOrderBy($viewName, ['email'], 'email'); | ||
$this->addOrderBy($viewName, ['level'], 'level'); | ||
$this->addOrderBy($viewName, ['lastactivity'], 'last-activity'); | ||
|
||
/// filters | ||
$levels = $this->codeModel->all('users', 'level', 'level'); | ||
$this->addFilterSelect($name, 'level', 'level', 'level', $levels); | ||
$this->addFilterSelect($viewName, 'level', 'level', 'level', $levels); | ||
|
||
$languages = $this->codeModel->all('users', 'langcode', 'langcode'); | ||
$this->addFilterSelect($name, 'langcode', 'language', 'langcode', $languages); | ||
|
||
$warehouses = $this->codeModel->all('almacenes', 'codalmacen', 'nombre'); | ||
$this->addFilterSelect($name, 'codalmacen', 'warehouse', 'codalmacen', $warehouses); | ||
$this->addFilterSelect($viewName, 'langcode', 'language', 'langcode', $languages); | ||
|
||
$companies = $this->codeModel->all('empresas', 'idempresa', 'nombrecorto'); | ||
$this->addFilterSelect($name, 'idempresa', 'company', 'idempresa', $companies); | ||
if (\count($companies) > 2) { | ||
$this->addFilterSelect($viewName, 'idempresa', 'company', 'idempresa', $companies); | ||
} | ||
|
||
$warehouses = $this->codeModel->all('almacenes', 'codalmacen', 'nombre'); | ||
if (\count($warehouses) > 2) { | ||
$this->addFilterSelect($viewName, 'codalmacen', 'warehouse', 'codalmacen', $warehouses); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters