Skip to content

Commit

Permalink
- Email user is now required.
Browse files Browse the repository at this point in the history
- Hide company and warehouse filters on user list when there is only one element.
  • Loading branch information
NeoRazorX committed Nov 22, 2020
1 parent a09616c commit 8925d72
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
56 changes: 30 additions & 26 deletions Core/Controller/ListUser.php
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
Expand Down Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion Core/XMLView/EditUser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<widget type="text" fieldname="nick" icon="fas fa-hashtag" maxlength="50" required="true" readonly="dinamic" />
</column>
<column name="email" order="110">
<widget type="email" fieldname="email" icon="fas fa-envelope" />
<widget type="email" fieldname="email" icon="fas fa-envelope" required="true" />
</column>
<column name="new-password" order="120">
<widget type="password" fieldname="newPassword" icon="fas fa-key" />
Expand Down

0 comments on commit 8925d72

Please sign in to comment.