Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1384 efrain 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\Mapper\CompanySizeMapper;
11
use LeadersLinked\Mapper\IndustryMapper;
12
use LeadersLinked\Mapper\CompetencyTypeMapper;
13
use LeadersLinked\Mapper\CompanyMicrolearningTopicMapper;
14
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleMapper;
15
use LeadersLinked\Mapper\CompanyPerformanceEvaluationFormMapper;
16
use LeadersLinked\Mapper\UserMapper;
17
 
18
class PerformanceEvaluationEvaluationForm extends Form
19
{
20
 
21
    /**
22
     *
23
     * @param AdapterInterface $adapter
24
     * @param int $company_id
25
     */
26
    public function __construct($adapter, $company_id)
27
    {
28
        parent::__construct();
29
        $this->setInputFilter(new PerformanceEvaluationEvaluationtFilter($adapter));
30
 
31
        $this->add([
32
            'name' => 'form_id',
33
            'type' => \Laminas\Form\Element\Select::class,
34
            'attributes' => [
35
                'id' => 'form_id',
36
            ],
37
            'options' => [
38
                'value_options' => $this->getSelectFormOptions($adapter, $company_id)
39
            ]
40
        ]);
8068 eleazar 41
 
42
        $this->add([
8069 eleazar 43
            'name' => 'user_id',
44
            'type' => \Laminas\Form\Element\Text::class,
45
             'attributes' => [
46
                'id' 			=> 'user_id',
47
            ]
48
        ]);
49
 
50
        $this->add([
8068 eleazar 51
           'name' => 'first_name',
52
           'type' => \Laminas\Form\Element\Text::class,
53
            'attributes' => [
54
               'maxlength' 	=> 128,
55
               'id' 			=> 'first_name',
56
           ]
57
        ]);
58
 
59
        $this->add([
60
           'name' => 'last_name',
61
           'type' => \Laminas\Form\Element\Text::class,
62
            'attributes' => [
63
               'maxlength' 	=> 128,
64
               'id' 			=> 'last_name',
65
           ]
66
        ]);
67
 
68
        $this->add([
69
           'name' => 'email',
70
           'type' => \Laminas\Form\Element\Text::class,
71
            'attributes' => [
72
               'maxlength' 	=> 128,
73
               'id' 			=> 'email',
74
           ]
75
        ]);
1384 efrain 76
 
77
        $this->add([
78
            'name' => 'supervisor_id',
79
            'type' => \Laminas\Form\Element\Select::class,
80
            'attributes' => [
81
                'id' => 'supervisor_id',
82
            ],
83
            'options' => [
84
                'value_options' => $this->getSelectUserOptions($adapter, $company_id)
85
            ]
86
        ]);
87
 
88
        $this->add([
89
            'name' => 'last_date',
12100 eleazar 90
            'type' => \Laminas\Form\Element\Date::class,
91
             'attributes' => [
1384 efrain 92
                'id' 			=> 'last_date',
12100 eleazar 93
             ],
1384 efrain 94
        ]);
95
 
96
    }
97
 
98
    /**
99
     *
100
     * @param AdapterInterface $adapter
101
     */
102
    private function getSelectFormOptions($adapter, $company_id)
103
    {
104
        $options = [];
105
 
106
        $mapper = CompanyPerformanceEvaluationFormMapper::getInstance($adapter);
107
        $records = $mapper->fetchAllByCompanyId($company_id);
108
 
109
        foreach($records as $record)
110
        {
111
            $options[$record->uuid] = $record->name;
112
        }
113
        return $options;
114
    }
115
 
116
 
117
    /**
118
     *
119
     * @param AdapterInterface $adapter
120
     */
121
    private function getSelectUserOptions($adapter, $company_id)
122
    {
123
        $options = [];
124
 
125
        $mapper = UserMapper::getInstance($adapter);
126
        $records = $mapper->fetchAllByCompanyId($company_id);
127
 
128
        foreach($records as $record)
129
        {
130
            $options[$record->uuid] = (trim($record->first_name) . ' ' . trim($record->last_name)) . ' (' . $record->email . ')';
131
        }
132
        return $options;
133
    }
134
 
135
 
136
}