Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15459 | Rev 16948 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15459 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Network;
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\ThemeMapper;
13
use LeadersLinked\Model\Network;
14
 
15
class NetworkCreateForm extends Form
16
{
17
    /**
18
     *
19
     * @param AdapterInterface $adapter
20
     */
21
    public function __construct($adapter)
22
    {
23
 
24
        parent::__construct();
25
        $this->setInputFilter(new NetworkCreateFilter($adapter));
26
 
27
        $this->add([
28
            'name' => 'first_name',
29
            'type' => \Laminas\Form\Element\Text::class,
30
            'attributes' => [
31
                'maxlength' 	=> 64,
32
                'id' 			=> 'first_name',
33
            ]
34
        ]);
35
        $this->add([
36
            'name' => 'last_name',
37
            'type' => \Laminas\Form\Element\Text::class,
38
            'attributes' => [
39
                'maxlength' 	=> 64,
40
                'id' 			=> 'last_name',
41
            ]
42
        ]);
43
        $this->add([
44
            'name' => 'email',
45
            'type' => \Laminas\Form\Element\Text::class,
46
            'attributes' => [
47
                'maxlength' 	=> 64,
48
                'id' 			=> 'email',
49
            ]
50
        ]);
51
        $this->add([
52
            'name' => 'password',
53
            'type' => \Laminas\Form\Element\Text::class,
54
            'attributes' => [
55
                'maxlength' 	=> 16,
56
                'id' 			=> 'password',
57
            ]
58
        ]);
59
        $this->add([
60
            'name' => 'confirmation',
61
            'type' => \Laminas\Form\Element\Text::class,
62
            'attributes' => [
63
                'maxlength' 	=> 16,
64
                'id' 			=> 'confirmation',
65
            ]
66
        ]);
67
 
68
        $this->add([
69
            'name' => 'company',
70
            'type' => \Laminas\Form\Element\Text::class,
71
             'attributes' => [
72
                'maxlength' 	=> 128,
73
                'id' 			=> 'company',
74
            ]
75
         ]);
76
        $this->add([
77
             'name' => 'industry_id',
78
             'type' => \Laminas\Form\Element\Select::class,
79
             'options' => [
80
                 'value_options' => $this->optionsIndustry($adapter),
81
             ],
82
             'attributes' => [
83
                 'id' => 'industry_id',
84
             ]
85
         ]);
86
        $this->add([
87
            'name' => 'company_size_id',
88
            'type' => \Laminas\Form\Element\Select::class,
89
            'options' => [
90
                'value_options' => $this->optionsCompanySize($adapter),
91
            ],
92
            'attributes' => [
93
                'id' => 'company_size_id',
94
            ]
95
        ]);
96
        $this->add([
97
            'name' => 'main_hostname',
98
            'type' => \Laminas\Form\Element\Text::class,
99
            'attributes' => [
100
                'maxlength' 	=> 250,
101
                'id' 			=> 'admin_hostname',
102
            ]
103
        ]);
104
        $this->add([
105
            'name' => 'alternative_hostname',
106
            'type' => \Laminas\Form\Element\Text::class,
107
            'attributes' => [
108
                'maxlength' 	=> 250,
109
                'id' 			=> 'alternative_hostname',
110
            ]
111
        ]);
112
        $this->add([
113
            'name' => 'admin_hostname',
114
            'type' => \Laminas\Form\Element\Text::class,
115
            'attributes' => [
116
                'maxlength' 	=> 250,
117
                'id' 			=> 'admin_hostname',
118
            ]
119
        ]);
120
 
121
        $this->add([
122
            'name' => 'theme_id',
123
            'type' => \Laminas\Form\Element\Select::class,
124
            'attributes' => [
125
                'id' => 'theme_id',
126
            ],
127
            'options' => [
128
                'value_options' => $this->optionsTheme($adapter)
129
            ]
130
        ]);
131
 
15831 efrain 132
        $this->add([
133
            'name' => 'moodle_name',
134
            'type' => \Laminas\Form\Element\Text::class,
135
            'attributes' => [
136
                'maxlength' 	=> 20,
137
                'id' 			=> 'moodle_name',
138
            ]
139
        ]);
15459 efrain 140
 
15831 efrain 141
 
15459 efrain 142
        $this->add([
143
            'name' => 'moodle_url',
144
            'type' => \Laminas\Form\Element\Text::class,
145
            'attributes' => [
146
                'maxlength' 	=> 250,
147
                'id' 			=> 'moodle_url',
148
            ]
149
        ]);
150
 
15831 efrain 151
        $this->add([
152
            'name' => 'microlearning_appstore',
153
            'type' => \Laminas\Form\Element\Text::class,
154
            'attributes' => [
155
                'maxlength' 	=> 250,
156
                'id' 			=> 'microlearning_appstore',
157
            ]
158
        ]);
15459 efrain 159
 
160
        $this->add([
15831 efrain 161
            'name' => 'microlearning_playstore',
162
            'type' => \Laminas\Form\Element\Text::class,
163
            'attributes' => [
164
                'maxlength' 	=> 250,
165
                'id' 			=> 'mmicrolearning_playstore',
166
            ]
167
        ]);
168
 
169
 
170
        $this->add([
15459 efrain 171
            'name' => 'relationship_user_mode',
172
            'type' => \Laminas\Form\Element\Select::class,
173
            'attributes' => [
174
                'id' => 'relationship_user_mode',
175
            ],
176
            'options' => [
177
                'value_options' => [
178
                    Network::RELATIONSHIP_USER_MODE_USER_2_USER => 'LABEL_RELATIONSHIP_USER_MODE_USER_2_USER',
179
                    Network::RELATIONSHIP_USER_MODE_ALL_2_ALL => 'LABEL_RELATIONSHIP_USER_MODE_ALL_2_ALL',
180
                ]
181
            ]
182
        ]);
183
 
184
 
185
    }
186
 
187
    /**
188
     *
189
     * @param AdapterInterface $adapter
190
     * @param LoggerInterface $logger
191
     * @return array
192
     */
193
    private function optionsCompanySize($adapter)
194
    {
195
        $companySizeMapper = CompanySizeMapper::getInstance($adapter);
196
        $companySizes = $companySizeMapper->fetchAllActive();
197
 
198
        $options = [];
199
        foreach($companySizes as $companySize)
200
        {
201
            $options[$companySize->uuid] = $companySize->name . ' ( ' . $companySize->minimum_no_of_employee . ' - ' . $companySize->maximum_no_of_employee . ' )';
202
        }
203
 
204
        return $options;
205
    }
206
 
207
    /**
208
     *
209
     * @param AdapterInterface $adapter
210
     * @return array
211
     */
212
    private function optionsIndustry($adapter)
213
    {
214
        $industryMapper = IndustryMapper::getInstance($adapter);
215
        $industries  = $industryMapper->fetchAllActive();
216
 
217
        $options = [];
218
        foreach($industries as $industry)
219
        {
220
            $options[$industry->uuid] = $industry->name;
221
        }
222
 
223
        return $options;
224
    }
225
 
226
    /**
227
     *
228
     * @param AdapterInterface $adapter
229
     */
230
    private function optionsTheme($adapter)
231
    {
232
        $options = [];
233
 
234
        $mapper = ThemeMapper::getInstance($adapter);
235
        $records = $mapper->fetchAll();
236
 
237
        foreach($records as $record)
238
        {
239
            $options[$record->uuid] = $record->name;
240
        }
241
        return $options;
242
    }
243
 
244
}