Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15831 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15831 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\MyCoach;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Model\Topic;
11
use Laminas\Form\Element;
12
 
13
use LeadersLinked\Mapper\UserMapper;
14
use LeadersLinked\Mapper\MyCoachQuestionCategoryMapper;
15
use LeadersLinked\Mapper\MyCoachCategoryMapper;
16
use LeadersLinked\Model\MyCoachCategoryUser;
17
use LeadersLinked\Model\MyCoachCategory;
18
 
19
 
20
class MyCoachCategoryUserForm extends Form
21
{
22
 
23
    /**
24
     *
25
     * @param AdapterInterface $adapter
26
     * @param int $company_id
27
     * @param string $privacy
28
     */
29
    public function __construct($adapter, $company_id, $privacy) {
30
        parent::__construct();
31
        $this->setInputFilter(new MyCoachCategoryUserFilter());
32
 
33
 
34
        if($privacy == MyCoachCategory::PRIVACY_COMPANY) {
35
            $roles = [
36
                MyCoachCategoryUser::ROLE_USER => 'LABEL_USER',
37
                MyCoachCategoryUser::ROLE_EDITOR => 'LABEL_EDITOR',
38
                MyCoachCategoryUser::ROLE_ADMINISTRATOR => 'LABEL_ADMINISTRATOR',
39
            ];
40
        } else {
41
            $roles = [
42
                MyCoachCategoryUser::ROLE_EDITOR => 'LABEL_EDITOR',
43
                MyCoachCategoryUser::ROLE_ADMINISTRATOR => 'LABEL_ADMINISTRATOR',
44
            ];
45
        }
46
 
47
 
16940 efrain 48
 
15831 efrain 49
 
50
 
51
        $this->add([
52
            'name' => 'user_id',
53
            'type' => \Laminas\Form\Element\Select::class,
54
            'attributes' => [
55
                'id' =>  'user_id',
56
            ],
57
            'options' => [
58
                //'disable_inarray_validator' => true,
59
                'value_options' =>  $this->getUsers($adapter, $company_id)
60
            ]
61
        ]);
62
 
63
 
64
 
65
        $this->add([
66
            'name' => 'role',
67
            'type' => \Laminas\Form\Element\Select::class,
68
            'attributes' => [
69
                'id' =>  'role',
70
            ],
71
            'options' => [
72
                //'disable_inarray_validator' => true,
73
                'value_options' => $roles
74
            ]
75
        ]);
76
 
77
 
78
 
79
    }
80
 
81
    private function getUsers($adapter, $company_id)
82
    {
83
        $items = [];
84
        $userMapper = UserMapper::getInstance($adapter);
85
        $records = $userMapper->fetchAllByCompanyId($company_id);
86
 
87
        foreach($records as $record)
88
        {
89
            $items[ $record->uuid ] = $record->first_name . ' ' . $record->last_name . ' (' . $record->email . ')';
90
        }
91
 
92
        return $items;
93
    }
94
 
95
 
96
}
97