Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

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