Proyectos de Subversion LeadersLinked - Services

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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