Proyectos de Subversion LeadersLinked - Backend

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
17002 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Company;
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
     */
21
    public function __construct($adapter)
22
    {
23
        parent::__construct();
24
        $this->setInputFilter(new JobCreateFilter($adapter));
25
 
26
        $this->add([
27
            'name' => 'title',
28
            'type' => \Laminas\Form\Element\Text::class,
29
             'attributes' => [
30
                'maxlength' 	=> 128,
31
                'id' 			=> 'title',
32
            ]
33
         ]);
34
 
35
        $this->add([
36
            'name' => 'last_date_of_application',
37
            'type' => \Laminas\Form\Element\Text::class,
38
            'attributes' => [
39
                'maxlength' 	=> 10,
40
                'id' 			=> 'last_date_of_application',
41
            ]
42
        ]);
43
 
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
        ]);
54
 
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',
64
                ]
65
            ],
66
            'attributes' => [
67
                'id' => 'employment_type',
68
            ]
69
        ]);
70
 
71
        $this->add([
72
            'name' => 'location_search',
73
            'type' => \Laminas\Form\Element\Text::class,
74
            'attributes' => [
75
                'maxlength' 	=> 250,
76
                'id' 			=> 'location_search',
77
            ]
78
        ]);
79
 
80
 
81
        $this->add([
82
            'name' => 'formatted_address',
83
            'type' => \Laminas\Form\Element\Hidden::class,
84
            'attributes' => [
85
                'id'    => 'formatted_address',
86
            ]
87
        ]);
88
 
89
        $this->add([
90
            'name' => 'address1',
91
            'type' => \Laminas\Form\Element\Hidden::class,
92
            'attributes' => [
93
                'id'    => 'address1',
94
            ]
95
        ]);
96
 
97
        $this->add([
98
            'name' => 'address2',
99
            'type' => \Laminas\Form\Element\Hidden::class,
100
            'attributes' => [
101
                'id'    => 'address2',
102
            ]
103
        ]);
104
 
105
        $this->add([
106
            'name' => 'country',
107
            'type' => \Laminas\Form\Element\Hidden::class,
108
            'attributes' => [
109
                'id'    => 'country',
110
            ]
111
        ]);
112
 
113
        $this->add([
114
            'name' => 'state',
115
            'type' => \Laminas\Form\Element\Hidden::class,
116
            'attributes' => [
117
                'id'    => 'state',
118
            ]
119
        ]);
120
 
121
        $this->add([
122
            'name' => 'city1',
123
            'type' => \Laminas\Form\Element\Hidden::class,
124
            'attributes' => [
125
                'id'    => 'city1',
126
            ]
127
        ]);
128
 
129
        $this->add([
130
            'name' => 'city2',
131
            'type' => \Laminas\Form\Element\Hidden::class,
132
            'attributes' => [
133
                'id'    => 'city2',
134
            ]
135
        ]);
136
 
137
        $this->add([
138
            'name' => 'postal_code',
139
            'type' => \Laminas\Form\Element\Hidden::class,
140
            'attributes' => [
141
                'id'    => 'postal_code',
142
            ]
143
        ]);
144
 
145
        $this->add([
146
            'name' => 'latitude',
147
            'type' => \Laminas\Form\Element\Hidden::class,
148
            'attributes' => [
149
                'id'    => 'latitude',
150
            ]
151
        ]);
152
 
153
        $this->add([
154
            'name' => 'longitude',
155
            'type' => \Laminas\Form\Element\Hidden::class,
156
            'attributes' => [
157
                'id'    => 'longitude',
158
            ]
159
        ]);
160
 
161
 
162
    }
163
 
164
    /**
165
     *
166
     * @param AdapterInterface $adapter
167
     * @param LoggerInterface $logger
168
     * @return array
169
     */
170
    private function optionsJobCategory($adapter)
171
    {
172
        $jobCategoryMapper = JobCategoryMapper::getInstance($adapter);
173
        $jobCategories = $jobCategoryMapper->fetchAllActive();
174
 
175
        $options = [];
176
        foreach($jobCategories as $jobCategory)
177
        {
178
            $options[$jobCategory->uuid] = $jobCategory->name;
179
        }
180
 
181
        return $options;
182
    }
183
 
184
 
185
}