Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15831 | Rev 16987 | 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([
16948 efrain 122
            'name' => 'service_hostname',
123
            'type' => \Laminas\Form\Element\Text::class,
124
            'attributes' => [
125
                'maxlength' 	=> 250,
126
                'id' 			=> 'service_hostname',
127
            ]
128
        ]);
129
 
130
 
131
 
132
        $this->add([
15459 efrain 133
            'name' => 'theme_id',
134
            'type' => \Laminas\Form\Element\Select::class,
135
            'attributes' => [
136
                'id' => 'theme_id',
137
            ],
138
            'options' => [
139
                'value_options' => $this->optionsTheme($adapter)
140
            ]
141
        ]);
142
 
15831 efrain 143
        $this->add([
144
            'name' => 'moodle_name',
145
            'type' => \Laminas\Form\Element\Text::class,
146
            'attributes' => [
147
                'maxlength' 	=> 20,
148
                'id' 			=> 'moodle_name',
149
            ]
150
        ]);
15459 efrain 151
 
15831 efrain 152
 
15459 efrain 153
        $this->add([
154
            'name' => 'moodle_url',
155
            'type' => \Laminas\Form\Element\Text::class,
156
            'attributes' => [
157
                'maxlength' 	=> 250,
158
                'id' 			=> 'moodle_url',
159
            ]
160
        ]);
161
 
15831 efrain 162
        $this->add([
163
            'name' => 'microlearning_appstore',
164
            'type' => \Laminas\Form\Element\Text::class,
165
            'attributes' => [
166
                'maxlength' 	=> 250,
167
                'id' 			=> 'microlearning_appstore',
168
            ]
169
        ]);
15459 efrain 170
 
171
        $this->add([
15831 efrain 172
            'name' => 'microlearning_playstore',
173
            'type' => \Laminas\Form\Element\Text::class,
174
            'attributes' => [
175
                'maxlength' 	=> 250,
176
                'id' 			=> 'mmicrolearning_playstore',
177
            ]
178
        ]);
179
 
180
 
181
        $this->add([
15459 efrain 182
            'name' => 'relationship_user_mode',
183
            'type' => \Laminas\Form\Element\Select::class,
184
            'attributes' => [
185
                'id' => 'relationship_user_mode',
186
            ],
187
            'options' => [
188
                'value_options' => [
189
                    Network::RELATIONSHIP_USER_MODE_USER_2_USER => 'LABEL_RELATIONSHIP_USER_MODE_USER_2_USER',
190
                    Network::RELATIONSHIP_USER_MODE_ALL_2_ALL => 'LABEL_RELATIONSHIP_USER_MODE_ALL_2_ALL',
191
                ]
192
            ]
193
        ]);
194
 
195
 
196
    }
197
 
198
    /**
199
     *
200
     * @param AdapterInterface $adapter
201
     * @param LoggerInterface $logger
202
     * @return array
203
     */
204
    private function optionsCompanySize($adapter)
205
    {
206
        $companySizeMapper = CompanySizeMapper::getInstance($adapter);
207
        $companySizes = $companySizeMapper->fetchAllActive();
208
 
209
        $options = [];
210
        foreach($companySizes as $companySize)
211
        {
212
            $options[$companySize->uuid] = $companySize->name . ' ( ' . $companySize->minimum_no_of_employee . ' - ' . $companySize->maximum_no_of_employee . ' )';
213
        }
214
 
215
        return $options;
216
    }
217
 
218
    /**
219
     *
220
     * @param AdapterInterface $adapter
221
     * @return array
222
     */
223
    private function optionsIndustry($adapter)
224
    {
225
        $industryMapper = IndustryMapper::getInstance($adapter);
226
        $industries  = $industryMapper->fetchAllActive();
227
 
228
        $options = [];
229
        foreach($industries as $industry)
230
        {
231
            $options[$industry->uuid] = $industry->name;
232
        }
233
 
234
        return $options;
235
    }
236
 
237
    /**
238
     *
239
     * @param AdapterInterface $adapter
240
     */
241
    private function optionsTheme($adapter)
242
    {
243
        $options = [];
244
 
245
        $mapper = ThemeMapper::getInstance($adapter);
246
        $records = $mapper->fetchAll();
247
 
248
        foreach($records as $record)
249
        {
250
            $options[$record->uuid] = $record->name;
251
        }
252
        return $options;
253
    }
254
 
255
}