chg: [inboxes:filtering] Populate username with eligible users in filtering modal
parent
cadb56eb07
commit
eefe6b22cc
|
@ -16,7 +16,7 @@ use Cake\Http\Exception\ForbiddenException;
|
||||||
|
|
||||||
class InboxController extends AppController
|
class InboxController extends AppController
|
||||||
{
|
{
|
||||||
public $filterFields = ['scope', 'action', 'Inbox.created', 'severity', 'title', 'origin', 'message', 'Users.id', 'Users.username',];
|
public $filterFields = ['scope', 'action', 'Inbox.created', 'severity', 'title', 'origin', 'message', 'Users.id', ['name' => 'Users.username', 'multiple' => true, 'options' => 'getAllUsername', 'select2' => true],];
|
||||||
public $quickFilterFields = ['scope', 'action', ['title' => true], ['message' => true], 'origin'];
|
public $quickFilterFields = ['scope', 'action', ['title' => true], ['message' => true], 'origin'];
|
||||||
public $containFields = ['Users'];
|
public $containFields = ['Users'];
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
namespace App\Model\Table;
|
namespace App\Model\Table;
|
||||||
|
|
||||||
use App\Model\Table\AppTable;
|
use App\Model\Table\AppTable;
|
||||||
|
use Cake\Utility\Hash;
|
||||||
use Cake\Database\Schema\TableSchemaInterface;
|
use Cake\Database\Schema\TableSchemaInterface;
|
||||||
use Cake\Database\Type;
|
use Cake\Database\Type;
|
||||||
use Cake\ORM\Table;
|
use Cake\ORM\Table;
|
||||||
|
@ -72,6 +73,17 @@ class InboxTable extends AppTable
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAllUsername($currentUser): array
|
||||||
|
{
|
||||||
|
$this->Users = \Cake\ORM\TableRegistry::getTableLocator()->get('Users');
|
||||||
|
$conditions = [];
|
||||||
|
if (empty($currentUser['role']['perm_admin'])) {
|
||||||
|
$conditions['organisation_id IN'] = [$currentUser['organisation_id']];
|
||||||
|
}
|
||||||
|
$users = $this->Users->find()->where($conditions)->all()->extract('username')->toList();
|
||||||
|
return Hash::combine($users, '{n}', '{n}');
|
||||||
|
}
|
||||||
|
|
||||||
public function checkUserBelongsToBroodOwnerOrg($user, $entryData) {
|
public function checkUserBelongsToBroodOwnerOrg($user, $entryData) {
|
||||||
$this->Broods = \Cake\ORM\TableRegistry::getTableLocator()->get('Broods');
|
$this->Broods = \Cake\ORM\TableRegistry::getTableLocator()->get('Broods');
|
||||||
$this->Individuals = \Cake\ORM\TableRegistry::getTableLocator()->get('Individuals');
|
$this->Individuals = \Cake\ORM\TableRegistry::getTableLocator()->get('Individuals');
|
||||||
|
|
Loading…
Reference in New Issue