Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15457 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\RecruitmentSelection;
6
use LeadersLinked\Mapper\IndustryMapper;
7
use LeadersLinked\Mapper\JobDescriptionMapper;
8
use LeadersLinked\Mapper\JobCategoryMapper;
9
use LeadersLinked\Mapper\CompanyMapper;
10
use Laminas\Form\Form;
11
use Laminas\Db\Adapter\AdapterInterface;
12
 
13
 
14
class RecruitmentSelectionVacancyForm extends Form
15
{
16
 
17
    public function __construct($adapter, $company_id)
18
    {
19
        parent::__construct();
20
        $this->setInputFilter(new RecruitmentSelectionVacancyFilter($adapter));
21
 
22
        $this->add([
23
            'name' => 'name',
24
            'type' => \Laminas\Form\Element\Text::class,
25
             'attributes' => [
26
                'maxlength' 	=> 128,
27
                'id' 			=> 'name',
28
            ]
29
        ]);
30
 
31
        $this->add([
32
            'name' => 'job_description_id',
33
            'type' => \Laminas\Form\Element\Select::class,
34
             'attributes' => [
35
                'id' 			=> 'job_description_id',
36
             ],
37
             'options' => [
38
                'value_options' => $this->getDescriptionSelectOptions($adapter, $company_id)
39
            ]
40
        ]);
41
 
42
        $this->add([
43
            'name' => 'job_category_id',
44
            'type' => \Laminas\Form\Element\Select::class,
45
             'attributes' => [
46
                'id' 			=> 'job_category_id',
47
             ],
48
             'options' => [
49
                'value_options' => $this->getCategorySelectOptions($adapter, $company_id)
50
            ]
51
        ]);
52
 
53
        $this->add([
54
            'name' => 'description',
55
            'type' => \Laminas\Form\Element\Textarea::class,
56
             'attributes' => [
57
                'id' 			=> 'description',
58
             ],
59
        ]);
60
 
61
        $this->add([
62
            'name' => 'location_search',
63
            'type' => \Laminas\Form\Element\Text::class,
64
             'attributes' => [
65
                'id' 			=> 'location_search',
66
             ],
67
        ]);
68
 
69
        $this->add([
70
            'name' => 'last_date',
71
            'type' => \Laminas\Form\Element\Text::class,
72
             'attributes' => [
73
                'id' 			=> 'last_date',
74
             ],
75
        ]);
76
 
77
        $this->add([
78
            'name' => 'location_search',
79
            'type' => \Laminas\Form\Element\Text::class,
80
            'attributes' => [
81
                'maxlength' 	=> 250,
82
                'id' 			=> 'location_search',
83
            ]
84
        ]);
85
 
86
 
87
        $this->add([
88
            'name' => 'formatted_address',
89
            'type' => \Laminas\Form\Element\Hidden::class,
90
            'attributes' => [
91
                'id'    => 'formatted_address',
92
            ]
93
        ]);
94
 
95
        $this->add([
96
            'name' => 'address1',
97
            'type' => \Laminas\Form\Element\Hidden::class,
98
            'attributes' => [
99
                'id'    => 'address1',
100
            ]
101
        ]);
102
 
103
        $this->add([
104
            'name' => 'address2',
105
            'type' => \Laminas\Form\Element\Hidden::class,
106
            'attributes' => [
107
                'id'    => 'address2',
108
            ]
109
        ]);
110
 
111
        $this->add([
112
            'name' => 'country',
113
            'type' => \Laminas\Form\Element\Hidden::class,
114
            'attributes' => [
115
                'id'    => 'country',
116
            ]
117
        ]);
118
 
119
        $this->add([
120
            'name' => 'state',
121
            'type' => \Laminas\Form\Element\Hidden::class,
122
            'attributes' => [
123
                'id'    => 'state',
124
            ]
125
        ]);
126
 
127
        $this->add([
128
            'name' => 'city1',
129
            'type' => \Laminas\Form\Element\Hidden::class,
130
            'attributes' => [
131
                'id'    => 'city1',
132
            ]
133
        ]);
134
 
135
        $this->add([
136
            'name' => 'city2',
137
            'type' => \Laminas\Form\Element\Hidden::class,
138
            'attributes' => [
139
                'id'    => 'city2',
140
            ]
141
        ]);
142
 
143
        $this->add([
144
            'name' => 'postal_code',
145
            'type' => \Laminas\Form\Element\Hidden::class,
146
            'attributes' => [
147
                'id'    => 'postal_code',
148
            ]
149
        ]);
150
 
151
        $this->add([
152
            'name' => 'latitude',
153
            'type' => \Laminas\Form\Element\Hidden::class,
154
            'attributes' => [
155
                'id'    => 'latitude',
156
            ]
157
        ]);
158
 
159
        $this->add([
160
            'name' => 'longitude',
161
            'type' => \Laminas\Form\Element\Hidden::class,
162
            'attributes' => [
163
                'id'    => 'longitude',
164
            ]
165
        ]);
166
 
167
 
168
        $this->add([
169
            'name' => 'industry_id',
170
            'type' => \Laminas\Form\Element\Select::class,
171
             'attributes' => [
172
                'id' 			=> 'industry_id',
173
             ],
174
             'options' => [
175
                'value_options' => $this->getIndustrySelectOptions($adapter)
176
            ]
177
        ]);
178
 
179
        $this->add([
180
            'name' => 'status',
181
            'type' => \Laminas\Form\Element\Checkbox::class,
182
            'attributes' => [
183
                'id' 			=> 'status',
184
            ],
185
            'options' => [
16766 efrain 186
                'use_hidden_element' => false,
15457 efrain 187
                'unchecked_value' => \LeadersLinked\Model\RecruitmentSelectionVacancy::STATUS_INACTIVE,
188
                'checked_value'=> \LeadersLinked\Model\RecruitmentSelectionVacancy::STATUS_ACTIVE,
189
            ]
190
        ]);
191
 
192
    }
193
 
194
    /**
195
     *
196
     * @param AdapterInterface $adapter
197
     */
198
    private function getDescriptionSelectOptions($adapter, $company_id)
199
    {
200
        $options = [];
201
 
202
        $mapper = JobDescriptionMapper::getInstance($adapter);
203
        $records = $mapper->fetchAllActiveByCompanyId($company_id);
204
 
205
 
206
        foreach($records as $record)
207
        {
208
            $options[$record->uuid] = $record->name;
209
        }
210
        return $options;
211
    }
212
 
213
    function getCategorySelectOptions($adapter)
214
    {
215
        $options = [];
216
 
217
        $mapper = JobCategoryMapper::getInstance($adapter);
218
        $records = $mapper->fetchAllActive();
219
 
220
        foreach($records as $record)
221
        {
222
            $options[$record->uuid] = $record->name;
223
        }
224
        return $options;
225
    }
226
 
227
    function getIndustrySelectOptions($adapter)
228
    {
229
        $options = [];
230
 
231
        $mapper = IndustryMapper::getInstance($adapter);
232
        $records = $mapper->fetchAllActive();
233
 
234
        foreach($records as $record)
235
        {
236
            $options[$record->uuid] = $record->name;
237
        }
238
        return $options;
239
    }
240
 
241
}