Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\UserProfile;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use LeadersLinked\Mapper\IndustryMapper;
10
use LeadersLinked\Mapper\CompanySizeMapper;
11
 
12
class ExperienceForm extends Form
13
{
14
    /**
15
     *
16
     * @param AdapterInterface $adapter
17
     */
18
    public function __construct($adapter)
19
    {
20
        parent::__construct();
21
 
22
        $this->setInputFilter(new ExperienceFilter($adapter));
23
 
24
        $this->add([
25
            'name' => 'industry_id',
26
            'type' => \Laminas\Form\Element\Select::class,
27
            'options' => [
28
                'value_options' => $this->optionsIndustry($adapter)
29
            ],
30
            'attributes' => [
31
                'id' => 'industry_id',
32
            ]
33
        ]);
34
 
35
        $this->add([
36
            'name' => 'company_size_id',
37
            'type' => \Laminas\Form\Element\Select::class,
38
            'options' => [
39
                'value_options' => $this->optionsCompanySize($adapter)
40
            ],
41
            'attributes' => [
42
                'id' => 'company_size_id',
43
            ]
44
        ]);
45
 
46
 
47
        $this->add([
48
            'name' => 'company',
49
            'type' => \Laminas\Form\Element\Text::class,
50
            'attributes' => [
51
                'maxlength' 	=> 128,
52
                'id' 			=> 'company',
53
            ]
54
        ]);
55
 
56
        $this->add([
57
            'name' => 'title',
58
            'type' => \Laminas\Form\Element\Text::class,
59
            'attributes' => [
60
                'maxlength' 	=> 128,
61
                'id' 			=> 'title',
62
            ]
63
        ]);
64
 
65
        $this->add([
66
            'name' => 'from_month',
67
            'type' => \Laminas\Form\Element\Select::class,
68
            'attributes' => [
69
                'id' => 'from_month',
70
            ],
71
            'options' => [
72
                'value_options' => $this->optionsMonths()
73
            ],
74
 
75
        ]);
76
 
77
        $this->add([
78
            'name' => 'from_year',
79
            'type' => \Laminas\Form\Element\Select::class,
80
            'attributes' => [
81
                'id' => 'from_year',
82
            ],
83
            'options' => [
84
                'value_options' => $this->optionsYears()
85
            ],
86
        ]);
87
 
88
        $this->add([
89
            'name' => 'to_month',
90
            'type' => \Laminas\Form\Element\Select::class,
91
            'attributes' => [
92
                'id' => 'to_month',
93
            ],
94
            'options' => [
95
                'value_options' => $this->optionsMonths()
96
            ],
97
 
98
        ]);
99
 
100
        $this->add([
101
            'name' => 'to_year',
102
            'type' => \Laminas\Form\Element\Select::class,
103
            'attributes' => [
104
                'id' => 'to_year',
105
            ],
106
            'options' => [
107
                'value_options' => $this->optionsYears()
108
            ],
109
        ]);
110
 
111
 
112
        $this->add([
113
            'name' => 'is_current',
114
            'type' => \Laminas\Form\Element\Checkbox::class,
115
            'attributes' => [
116
                'id' 			=> 'is_current',
117
            ],
118
            'options' => [
6752 efrain 119
                'use_hidden_element' => false,
1 www 120
                'unchecked_value' => \LeadersLinked\Model\UserExperience::IS_CURRENT_NO,
121
                'checked_value'=>  \LeadersLinked\Model\UserExperience::IS_CURRENT_YES,
122
            ]
123
        ]);
124
 
125
        $this->add([
126
            'name' => 'description',
127
            'type' => \Laminas\Form\Element\Textarea::class,
128
            'attributes' => [
129
                'id' 			=> 'description',
130
            ]
131
        ]);
132
 
133
 
134
        $this->add([
135
            'name' => 'experience_location_search',
136
            'type' => \Laminas\Form\Element\Text::class,
137
            'attributes' => [
138
                'maxlength' 	=> 250,
139
                'id' 			=> 'experience_location_search',
140
            ]
141
        ]);
142
 
143
 
144
        $this->add([
145
            'name' => 'formatted_address',
146
            'type' => \Laminas\Form\Element\Hidden::class,
147
            'attributes' => [
148
                'id'    => 'formatted_address',
149
            ]
150
        ]);
151
 
152
        $this->add([
153
            'name' => 'address1',
154
            'type' => \Laminas\Form\Element\Hidden::class,
155
            'attributes' => [
156
                'id'    => 'address1',
157
            ]
158
        ]);
159
 
160
        $this->add([
161
            'name' => 'address2',
162
            'type' => \Laminas\Form\Element\Hidden::class,
163
            'attributes' => [
164
                'id'    => 'address2',
165
            ]
166
        ]);
167
 
168
        $this->add([
169
            'name' => 'country',
170
            'type' => \Laminas\Form\Element\Hidden::class,
171
            'attributes' => [
172
                'id'    => 'country',
173
            ]
174
        ]);
175
 
176
        $this->add([
177
            'name' => 'state',
178
            'type' => \Laminas\Form\Element\Hidden::class,
179
            'attributes' => [
180
                'id'    => 'state',
181
            ]
182
        ]);
183
 
184
        $this->add([
185
            'name' => 'city1',
186
            'type' => \Laminas\Form\Element\Hidden::class,
187
            'attributes' => [
188
                'id'    => 'city1',
189
            ]
190
        ]);
191
 
192
        $this->add([
193
            'name' => 'city2',
194
            'type' => \Laminas\Form\Element\Hidden::class,
195
            'attributes' => [
196
                'id'    => 'city2',
197
            ]
198
        ]);
199
 
200
        $this->add([
201
            'name' => 'postal_code',
202
            'type' => \Laminas\Form\Element\Hidden::class,
203
            'attributes' => [
204
                'id'    => 'postal_code',
205
            ]
206
        ]);
207
 
208
        $this->add([
209
            'name' => 'latitude',
210
            'type' => \Laminas\Form\Element\Hidden::class,
211
            'attributes' => [
212
                'id'    => 'latitude',
213
            ]
214
        ]);
215
 
216
        $this->add([
217
            'name' => 'longitude',
218
            'type' => \Laminas\Form\Element\Hidden::class,
219
            'attributes' => [
220
                'id'    => 'longitude',
221
            ]
222
        ]);
223
 
224
 
225
 
226
 
227
 
228
    }
229
 
230
    /**
231
     *
232
     * @param AdapterInterface $adapter
233
     * @return array
234
     */
235
    private function optionsIndustry($adapter)
236
    {
237
        $mapper = IndustryMapper::getInstance($adapter);
3454 efrain 238
        $records = $mapper->fetchAllActive();
1 www 239
 
240
        $items = [];
241
        foreach($records as $record)
242
        {
243
            $items[$record->uuid] = $record->name;
244
        }
245
 
246
        return $items;
247
    }
248
 
249
 
250
    /**
251
     *
252
     * @param AdapterInterface $adapter
253
     * @return array
254
     */
255
    private function optionsCompanySize($adapter)
256
    {
257
        $mapper = CompanySizeMapper::getInstance($adapter);
3454 efrain 258
        $records = $mapper->fetchAllActive();
1 www 259
 
260
        $items = [];
261
        foreach($records as $record)
262
        {
263
            $items[$record->uuid] = $record->name . ' (' . $record->minimum_no_of_employee . '-' . $record->maximum_no_of_employee . ') ';
264
        }
265
 
266
        return $items;
267
    }
268
 
269
    /**
270
     *
271
     * @return array
272
     */
273
    private function optionsMonths()
274
    {
275
        $options = [];
276
        $options[0] = 'LABEL_MONTH_JANUARY';
277
        $options[1] = 'LABEL_MONTH_JANUARY';
278
        $options[2] = 'LABEL_MONTH_FEBRUARY';
279
        $options[3] = 'LABEL_MONTH_MARCH';
280
        $options[4] = 'LABEL_MONTH_APRIL';
281
        $options[5] = 'LABEL_MONTH_MAY';
282
        $options[6] = 'LABEL_MONTH_JUNE';
283
        $options[7] = 'LABEL_MONTH_JULY';
284
        $options[8] = 'LABEL_MONTH_AUGUST';
285
        $options[9] = 'LABEL_MONTH_SEPTEMBER';
286
        $options[10] = 'LABEL_MONTH_OCTOBER';
287
        $options[11] = 'LABEL_MONTH_NOVEMBER';
288
        $options[12] = 'LABEL_MONTH_DECEMBER';
289
 
290
        return $options;
291
 
292
    }
293
 
294
    /**
295
     *
296
     * @return array
297
     */
298
    private function optionsYears()
299
    {
300
        $y = date('Y');
301
        $options = [];
302
        for($i = 0 ; $i < 100; $i++)
303
        {
304
            $options[$y - $i] = $y - $i;
305
        }
306
 
307
        return $options;
308
    }
309
 
310
}