Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
7241 nelberth 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Model\HighPerformanceTeamsGroupsMembers;
11
use Laminas\Form\Element;
12
 
13
use LeadersLinked\Mapper\UserMapper;
14
 
15
class HighPerformanceTeamsGroupsMembersForm extends Form
16
{
17
 
18
    public function __construct(){
19
        parent::__construct();
20
        $this->setInputFilter(new HighPerformanceTeamsGroupsMembersFilter($adapter));
21
 
22
 
23
        $this->add([
24
            'name' => 'user_id',
25
            'type' => \Laminas\Form\Element\Select::class,
26
            'attributes' => [
27
                'id' => 'user_id',
28
            ],
29
            'options' => [
30
                'empty_option' => 'LABEL_NA',
31
                'value_options' => $this->getSelectOptionsUser($adapter)
32
            ]
33
        ]);
34
 
35
        $this->add([
36
            'name' => 'group_id',
37
            'type' => \Laminas\Form\Element\Number::class,
38
            'attributes' => [
39
                'id' => 'group_id',
40
            ]
41
        ]);
42
 
43
        $this->add([
44
            'name' => 'status',
45
            'type' => \Laminas\Form\Element\Checkbox::class,
46
            'attributes' => [
47
                'id' 			=> 'status',
48
            ],
49
            'options' => [
50
                'use_hidden_element' => 0,
51
                'unchecked_value' => \LeadersLinked\Model\HighPerformanceTeamsGroupsMembers::STATUS_INACTIVE,
52
                'checked_value'=> \LeadersLinked\Model\HighPerformanceTeamsGroupsMembers::STATUS_ACTIVE,
53
            ]
54
        ]);
55
    }
56
    private function getSelectOptionsUser($adapter)
57
    {
58
        $options = [];
59
 
60
        $mapper = UserMapper::getInstance($adapter);
61
        $records = $mapper->fetchAllByActives();
62
 
63
        foreach($records as $record)
64
        {
65
            $options[$record->uuid] = $record->name;
66
        }
67
        return $options;
68
    }
69
 
70
}
71