Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
17002 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
17020 efrain 5
namespace LeadersLinked\Form\Job;
17002 efrain 6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Mapper\CompanySizeMapper;
11
use LeadersLinked\Mapper\IndustryMapper;
12
use LeadersLinked\Mapper\JobCategoryMapper;
13
use LeadersLinked\Model\Job;
14
 
15
class JobCreateForm extends Form
16
{
17
    /**
18
     *
19
     * @param AdapterInterface $adapter
20
     */
17288 ariadna 21
    public function __construct($adapter)
17002 efrain 22
    {
23
        parent::__construct();
24
        $this->setInputFilter(new JobCreateFilter($adapter));
17288 ariadna 25
 
17002 efrain 26
        $this->add([
27
            'name' => 'title',
28
            'type' => \Laminas\Form\Element\Text::class,
17288 ariadna 29
            'attributes' => [
30
                'maxlength'     => 128,
31
                'id'             => 'title',
17002 efrain 32
            ]
17288 ariadna 33
        ]);
34
 
17002 efrain 35
        $this->add([
36
            'name' => 'last_date_of_application',
37
            'type' => \Laminas\Form\Element\Text::class,
38
            'attributes' => [
17288 ariadna 39
                'maxlength'     => 10,
40
                'id'             => 'last_date_of_application',
17002 efrain 41
            ]
42
        ]);
17288 ariadna 43
 
17002 efrain 44
        $this->add([
45
            'name' => 'job_category_id',
46
            'type' => \Laminas\Form\Element\Select::class,
47
            'options' => [
48
                'value_options' => $this->optionsJobCategory($adapter),
49
            ],
50
            'attributes' => [
51
                'id' => 'job_category_id',
52
            ]
53
        ]);
17288 ariadna 54
 
17002 efrain 55
        $this->add([
56
            'name' => 'employment_type',
57
            'type' => \Laminas\Form\Element\Select::class,
58
            'options' => [
59
                'value_options' => [
60
                    Job::EMPLOYMENT_TYPE_FULL_TIME => 'LABEL_EMPLOYMENT_TYPE_FULL_TIME',
61
                    Job::EMPLOYMENT_TYPE_PART_TIME => 'LABEL_EMPLOYMENT_TYPE_PART_TIME',
62
                    Job::EMPLOYMENT_TYPE_CONTRACT => 'LABEL_EMPLOYMENT_TYPE_CONTRACT',
63
                    Job::EMPLOYMENT_TYPE_TEMPORARY => 'LABEL_EMPLOYMENT_TYPE_TEMPORARY',
17288 ariadna 64
                    Job::EMPLOYMENT_TYPE_FREELANCE => 'LABEL_EMPLOYMENT_TYPE_FREELANCE',
17002 efrain 65
                ]
66
            ],
67
            'attributes' => [
68
                'id' => 'employment_type',
69
            ]
70
        ]);
17288 ariadna 71
 
17002 efrain 72
        $this->add([
73
            'name' => 'location_search',
74
            'type' => \Laminas\Form\Element\Text::class,
75
            'attributes' => [
17288 ariadna 76
                'maxlength'     => 250,
77
                'id'             => 'location_search',
17002 efrain 78
            ]
79
        ]);
17288 ariadna 80
 
81
 
17002 efrain 82
        $this->add([
83
            'name' => 'formatted_address',
84
            'type' => \Laminas\Form\Element\Hidden::class,
85
            'attributes' => [
86
                'id'    => 'formatted_address',
87
            ]
88
        ]);
17288 ariadna 89
 
17002 efrain 90
        $this->add([
91
            'name' => 'address1',
92
            'type' => \Laminas\Form\Element\Hidden::class,
93
            'attributes' => [
94
                'id'    => 'address1',
95
            ]
96
        ]);
17288 ariadna 97
 
17002 efrain 98
        $this->add([
99
            'name' => 'address2',
100
            'type' => \Laminas\Form\Element\Hidden::class,
101
            'attributes' => [
102
                'id'    => 'address2',
103
            ]
104
        ]);
17288 ariadna 105
 
17002 efrain 106
        $this->add([
107
            'name' => 'country',
108
            'type' => \Laminas\Form\Element\Hidden::class,
109
            'attributes' => [
110
                'id'    => 'country',
111
            ]
112
        ]);
17288 ariadna 113
 
17002 efrain 114
        $this->add([
115
            'name' => 'state',
116
            'type' => \Laminas\Form\Element\Hidden::class,
117
            'attributes' => [
118
                'id'    => 'state',
119
            ]
120
        ]);
17288 ariadna 121
 
17002 efrain 122
        $this->add([
123
            'name' => 'city1',
124
            'type' => \Laminas\Form\Element\Hidden::class,
125
            'attributes' => [
126
                'id'    => 'city1',
127
            ]
128
        ]);
17288 ariadna 129
 
17002 efrain 130
        $this->add([
131
            'name' => 'city2',
132
            'type' => \Laminas\Form\Element\Hidden::class,
133
            'attributes' => [
134
                'id'    => 'city2',
135
            ]
136
        ]);
17288 ariadna 137
 
17002 efrain 138
        $this->add([
139
            'name' => 'postal_code',
140
            'type' => \Laminas\Form\Element\Hidden::class,
141
            'attributes' => [
142
                'id'    => 'postal_code',
143
            ]
144
        ]);
17288 ariadna 145
 
17002 efrain 146
        $this->add([
147
            'name' => 'latitude',
148
            'type' => \Laminas\Form\Element\Hidden::class,
149
            'attributes' => [
150
                'id'    => 'latitude',
151
            ]
152
        ]);
17288 ariadna 153
 
17002 efrain 154
        $this->add([
155
            'name' => 'longitude',
156
            'type' => \Laminas\Form\Element\Hidden::class,
157
            'attributes' => [
158
                'id'    => 'longitude',
159
            ]
160
        ]);
161
    }
17288 ariadna 162
 
17002 efrain 163
    /**
164
     *
165
     * @param AdapterInterface $adapter
166
     * @param LoggerInterface $logger
167
     * @return array
168
     */
169
    private function optionsJobCategory($adapter)
170
    {
171
        $jobCategoryMapper = JobCategoryMapper::getInstance($adapter);
172
        $jobCategories = $jobCategoryMapper->fetchAllActive();
17288 ariadna 173
 
17002 efrain 174
        $options = [];
17288 ariadna 175
        foreach ($jobCategories as $jobCategory) {
17002 efrain 176
            $options[$jobCategory->uuid] = $jobCategory->name;
177
        }
17288 ariadna 178
 
17002 efrain 179
        return $options;
180
    }
17288 ariadna 181
}