Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
16770 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Organization;
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\CompetencyTypeMapper;
17002 efrain 13
use LeadersLinked\Mapper\MicrolearningTopicMapper;
16770 efrain 14
use LeadersLinked\Model\JobDescription;
15
use LeadersLinked\Mapper\JobDescriptionMapper;
16
use LeadersLinked\Mapper\CompanyUserMapper;
17
use LeadersLinked\Mapper\UserMapper;
18
 
19
class PositionForm extends Form
20
{
21
 
22
    /**
23
     *
24
     * @param AdapterInterface $adapter
25
     * @param int $company_id
26
     */
27
    public function __construct($adapter, $company_id)
28
    {
29
        parent::__construct();
30
        $this->setInputFilter(new PositionFilter($adapter));
31
 
16791 efrain 32
        $this->add([
33
            'name' => 'job_description_id',
34
            'type' => \Laminas\Form\Element\Select::class,
35
            'attributes' => [
36
                'id' => 'job_description_id',
37
            ],
38
            'options' => [
39
                'value_options' => $this-> getJobDescriptionSelectOptions($adapter, $company_id)
40
            ]
41
        ]);
16770 efrain 42
 
16791 efrain 43
 
44
 
45
 
16770 efrain 46
        $this->add([
16791 efrain 47
            'name' => 'employee_id',
16770 efrain 48
            'type' => \Laminas\Form\Element\Select::class,
49
            'attributes' => [
16791 efrain 50
                'id' => 'employee_id',
16770 efrain 51
            ],
52
            'options' => [
16791 efrain 53
                'value_options' => $this-> getEmployeeSelectOptions($adapter, $company_id)
16770 efrain 54
            ]
55
        ]);
56
 
16791 efrain 57
        $this->add([
58
            'name' => 'boss_id',
59
            'type' => \Laminas\Form\Element\Select::class,
60
            'attributes' => [
61
                'id' => 'boss_id',
62
            ],
63
            'options' => [
64
                'value_options' => [],
65
                'disable_inarray_validator' => true,
66
            ]
67
        ]);
16770 efrain 68
 
16791 efrain 69
 
70
 
16770 efrain 71
        $this->add([
72
            'name' => 'status',
73
            'type' => \Laminas\Form\Element\Checkbox::class,
74
            'attributes' => [
75
                'id' 			=> 'status',
76
            ],
77
            'options' => [
78
                'use_hidden_element' => false,
79
                'unchecked_value' => \LeadersLinked\Model\OrganizationPosition::STATUS_INACTIVE,
80
                'checked_value'=> \LeadersLinked\Model\OrganizationPosition::STATUS_ACTIVE,
81
            ]
82
        ]);
83
 
84
 
85
    }
86
 
87
    /**
88
     *
89
     * @param AdapterInterface $adapter
90
     * @param int $company_id
91
     * @return array
92
     */
93
    private function getJobDescriptionSelectOptions($adapter, $company_id)
94
    {
95
        $options = [];
96
 
97
        $mapper = JobDescriptionMapper::getInstance($adapter);
16791 efrain 98
        $records = $mapper->fetchAllByCompanyId($company_id);
16770 efrain 99
 
100
        foreach($records as $record)
101
        {
102
            $options[$record->uuid] = $record->name;
103
        }
104
        return $options;
105
    }
106
 
107
    /**
108
     *
109
     * @param AdapterInterface $adapter
110
     * @param int $company_id
111
     * @return array
112
     */
16791 efrain 113
    private function getEmployeeSelectOptions($adapter, $company_id)
16770 efrain 114
    {
115
        $options = [];
116
 
117
        $mapper = UserMapper::getInstance($adapter);
118
        $records = $mapper->fetchAllByCompanyId($company_id);
119
 
120
        foreach($records as $record)
121
        {
122
            $options[$record->uuid] = trim($record->first_name . ' ' . $record->last_name) . ' (' . $record->email . ')';
123
        }
124
        return $options;
125
    }
126
}