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;
Línea 9... Línea 7...
9
use LeadersLinked\Mapper\DegreeMapper;
7
use LeadersLinked\Mapper\DegreeMapper;
10
 
8
 
-
 
9
class EducationForm extends Form
11
class EducationForm extends Form
10
{
12
{
11
 
13
    /**
12
    /**
14
     * 
13
     *
15
     * @param AdapterInterface $adapter
14
     * @param AdapterInterface $adapter
16
     */
15
     */
17
    public function __construct($adapter) 
16
    public function __construct($adapter)
18
    {
17
    {
19
        parent::__construct();
18
        parent::__construct();
Línea 20... Línea 19...
20
        
19
 
21
        $this->setInputFilter(new EducationFilter($adapter));
20
        $this->setInputFilter(new EducationFilter($adapter));
22
 
21
 
23
        $this->add([
22
        $this->add([
24
            'name' => 'degree_id',
23
            'name' => 'degree_id',
25
            'type' => \Laminas\Form\Element\Select::class,
24
            'type' => \Laminas\Form\Element\Select::class,
26
            'options' => [
25
            'options' => [
27
                'value_options' => $this->optionsDegree($adapter)
26
                'value_options' => $this->optionsDegree($adapter)
28
            ],
27
            ],
29
            'attributes' => [
28
            'attributes' => [
30
                'id' => 'degree_id',
29
                'id' => 'degree_id'
31
            ]
30
            ]
32
        ]);
31
        ]);
33
        
32
 
34
        $this->add([
33
        $this->add([
35
            'name' => 'university',
34
            'name' => 'university',
36
            'type' => \Laminas\Form\Element\Text::class,
35
            'type' => \Laminas\Form\Element\Text::class,
37
            'attributes' => [
36
            'attributes' => [
38
                'maxlength' 	=> 128,
37
                'maxlength' => 128,
39
                'id' 			=> 'university',
38
                'id' => 'university'
40
            ]
39
            ]
41
        ]);
40
        ]);
42
        
41
 
43
        $this->add([
42
        $this->add([
44
            'name' => 'field_of_study',
43
            'name' => 'field_of_study',
45
            'type' => \Laminas\Form\Element\Text::class,
44
            'type' => \Laminas\Form\Element\Text::class,
46
            'attributes' => [
45
            'attributes' => [
47
                'maxlength' 	=> 128,
46
                'maxlength' => 128,
Línea 48... Línea 47...
48
                'id' 			=> 'field_of_study',
47
                'id' => 'field_of_study'
49
            ]
48
            ]
50
        ]);
49
        ]);
51
 
50
 
52
        $this->add([
51
        $this->add([
53
            'name' => 'from_year',
52
            'name' => 'from_year',
54
            'type' => \Laminas\Form\Element\Select::class,
53
            'type' => \Laminas\Form\Element\Select::class,
55
            'attributes' => [
54
            'attributes' => [
56
                'id'=> 'from_year',
55
                'id' => 'from_year'
57
            ],
56
            ],
58
            'options' => [
57
            'options' => [
59
                'value_options' => $this->optionsYears()
58
                'value_options' => $this->optionsYears()
60
            ],
59
            ]
61
        ]);
60
        ]);
62
        
61
 
63
        $this->add([
62
        $this->add([
64
            'name' => 'to_year',
63
            'name' => 'to_year',
65
            'type' => \Laminas\Form\Element\Select::class,
64
            'type' => \Laminas\Form\Element\Select::class,
66
            'attributes' => [
65
            'attributes' => [
67
                'id' => 'to_year',
66
                'id' => 'to_year'
68
            ],
67
            ],
69
            'options' => [
68
            'options' => [
70
                'value_options' => $this->optionsYears()
69
                'value_options' => $this->optionsYears()
71
            ],
70
            ]
72
        ]);
71
        ]);
73
        
72
 
74
        $this->add([
73
        $this->add([
75
            'name' => 'grade_or_percentage',
74
            'name' => 'grade_or_percentage',
76
            'type' => \Laminas\Form\Element\Text::class,
75
            'type' => \Laminas\Form\Element\Text::class,
77
            'attributes' => [
76
            'attributes' => [
78
                'maxlength' 	=> 3,
77
                'maxlength' => 3,
79
                'id' 			=> 'grade_or_percentage',
78
                'id' => 'grade_or_percentage'
80
            ]
79
            ]
81
        ]);
80
        ]);
82
        
81
 
83
        $this->add([
82
        $this->add([
84
            'name' => 'description',
83
            'name' => 'description',
85
            'type' => \Laminas\Form\Element\Textarea::class,
84
            'type' => \Laminas\Form\Element\Textarea::class,
Línea 86... Línea -...
86
            'attributes' => [
-
 
87
                'id' 			=> 'description',
85
            'attributes' => [
88
            ]
86
                'id' => 'description'
89
        ]);
87
            ]
90
 
88
        ]);
91
        
89
 
92
        $this->add([
90
        $this->add([
93
            'name' => 'education_location_search',
91
            'name' => 'education_location_search',
94
            'type' => \Laminas\Form\Element\Text::class,
92
            'type' => \Laminas\Form\Element\Text::class,
95
            'attributes' => [
-
 
96
                'maxlength' 	=> 250,
93
            'attributes' => [
97
                'id' 			=> 'education_location_search',
94
                'maxlength' => 250,
98
            ]
95
                'id' => 'education_location_search'
99
        ]);
96
            ]
100
        
97
        ]);
101
        
98
 
102
        $this->add([
99
        $this->add([
103
            'name' => 'formatted_address',
100
            'name' => 'formatted_address',
104
            'type' => \Laminas\Form\Element\Hidden::class,
101
            'type' => \Laminas\Form\Element\Hidden::class,
105
            'attributes' => [
102
            'attributes' => [
106
                'id'    => 'formatted_address',
103
                'id' => 'formatted_address'
107
            ]
104
            ]
108
        ]);
105
        ]);
109
        
106
 
110
        $this->add([
107
        $this->add([
111
            'name' => 'address1',
108
            'name' => 'address1',
112
            'type' => \Laminas\Form\Element\Hidden::class,
109
            'type' => \Laminas\Form\Element\Hidden::class,
113
            'attributes' => [
110
            'attributes' => [
114
                'id'    => 'address1',
111
                'id' => 'address1'
115
            ]
112
            ]
116
        ]);
113
        ]);
117
        
114
 
118
        $this->add([
115
        $this->add([
119
            'name' => 'address2',
116
            'name' => 'address2',
120
            'type' => \Laminas\Form\Element\Hidden::class,
117
            'type' => \Laminas\Form\Element\Hidden::class,
121
            'attributes' => [
118
            'attributes' => [
122
                'id'    => 'address2',
119
                'id' => 'address2'
123
            ]
120
            ]
124
        ]);
121
        ]);
125
        
122
 
126
        $this->add([
123
        $this->add([
127
            'name' => 'country',
124
            'name' => 'country',
128
            'type' => \Laminas\Form\Element\Hidden::class,
125
            'type' => \Laminas\Form\Element\Hidden::class,
129
            'attributes' => [
126
            'attributes' => [
130
                'id'    => 'country',
127
                'id' => 'country'
131
            ]
128
            ]
132
        ]);
129
        ]);
133
        
130
 
134
        $this->add([
131
        $this->add([
135
            'name' => 'state',
132
            'name' => 'state',
136
            'type' => \Laminas\Form\Element\Hidden::class,
133
            'type' => \Laminas\Form\Element\Hidden::class,
137
            'attributes' => [
134
            'attributes' => [
138
                'id'    => 'state',
135
                'id' => 'state'
139
            ]
136
            ]
140
        ]);
137
        ]);
141
        
138
 
142
        $this->add([
139
        $this->add([
143
            'name' => 'city1',
140
            'name' => 'city1',
144
            'type' => \Laminas\Form\Element\Hidden::class,
141
            'type' => \Laminas\Form\Element\Hidden::class,
145
            'attributes' => [
142
            'attributes' => [
146
                'id'    => 'city1',
143
                'id' => 'city1'
147
            ]
144
            ]
148
        ]);
145
        ]);
149
        
146
 
150
        $this->add([
147
        $this->add([
151
            'name' => 'city2',
148
            'name' => 'city2',
152
            'type' => \Laminas\Form\Element\Hidden::class,
149
            'type' => \Laminas\Form\Element\Hidden::class,
153
            'attributes' => [
150
            'attributes' => [
154
                'id'    => 'city2',
151
                'id' => 'city2'
155
            ]
152
            ]
156
        ]);
153
        ]);
157
        
154
 
158
        $this->add([
155
        $this->add([
159
            'name' => 'postal_code',
156
            'name' => 'postal_code',
160
            'type' => \Laminas\Form\Element\Hidden::class,
157
            'type' => \Laminas\Form\Element\Hidden::class,
161
            'attributes' => [
158
            'attributes' => [
162
                'id'    => 'postal_code',
159
                'id' => 'postal_code'
163
            ]
160
            ]
164
        ]);
161
        ]);
165
        
162
 
166
        $this->add([
163
        $this->add([
167
            'name' => 'latitude',
164
            'name' => 'latitude',
168
            'type' => \Laminas\Form\Element\Hidden::class,
165
            'type' => \Laminas\Form\Element\Hidden::class,
169
            'attributes' => [
166
            'attributes' => [
170
                'id'    => 'latitude',
167
                'id' => 'latitude'
171
            ]
168
            ]
172
        ]);
169
        ]);
173
        
170
 
174
        $this->add([
171
        $this->add([
175
            'name' => 'longitude',
172
            'name' => 'longitude',
176
            'type' => \Laminas\Form\Element\Hidden::class,
-
 
177
            'attributes' => [
-
 
178
                'id'    => 'longitude',
-
 
179
            ]
-
 
180
        ]);
-
 
181
 
173
            'type' => \Laminas\Form\Element\Hidden::class,
182
 
174
            'attributes' => [
183
        
175
                'id' => 'longitude'
184
 
176
            ]
185
        
177
        ]);
186
    }
178
    }
187
    
179
 
188
    /**
180
    /**
189
     * 
181
     *
190
     * @param AdapterInterface $adapter
182
     * @param AdapterInterface $adapter
191
     * @return array
183
     * @return array
192
     */
184
     */
193
    private function optionsDegree($adapter)
185
    private function optionsDegree($adapter)
194
    {
186
    {
195
        $mapper = DegreeMapper::getInstance($adapter);
-
 
196
        $records = $mapper->fetchAllActive();
187
        $mapper = DegreeMapper::getInstance($adapter);
197
        
188
        $records = $mapper->fetchAllActive();
198
        $items = [];
189
 
199
        foreach($records as $record)
190
        $items = [];
200
        {
191
        foreach ($records as $record) {
201
            $items[$record->uuid] = $record->name;
192
            $items[$record->uuid] = $record->name;
202
        }
193
        }
203
        
194
 
204
        return $items;
195
        return $items;
205
    }
196
    }
206
    
197
 
207
    /**
198
    /**
208
     *
199
     *
209
     * @return array
200
     * @return array
210
     */
201
     */
211
    private function optionsYears()
-
 
212
    {
202
    private function optionsYears()
213
        $y = date('Y');
203
    {
214
        $options = [];
204
        $y = date('Y');
215
        for($i = 0 ; $i < 100; $i++)
205
        $options = [];
216
        {
206
        for ($i = 0; $i < 100; $i ++) {
217
            $options[$y - $i] = $y - $i;
-
 
218
        }
207
            $options[$y - $i] = $y - $i;
219
        
208
        }