Proyectos de Subversion LeadersLinked - Services

Rev

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

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