Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16791 | Ir a la última revisión | | 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;
13
use LeadersLinked\Mapper\CompanyMicrolearningTopicMapper;
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
 
32
 
33
        $this->add([
34
            'name' => 'user_id',
35
            'type' => \Laminas\Form\Element\Select::class,
36
            'attributes' => [
37
                'id' => 'user_id',
38
            ],
39
            'options' => [
40
                'value_options' => $this-> getUserSelectOptions($adapter, $company_id)
41
            ]
42
        ]);
43
 
44
 
45
        $this->add([
46
            'name' => 'status',
47
            'type' => \Laminas\Form\Element\Checkbox::class,
48
            'attributes' => [
49
                'id' 			=> 'status',
50
            ],
51
            'options' => [
52
                'use_hidden_element' => false,
53
                'unchecked_value' => \LeadersLinked\Model\OrganizationPosition::STATUS_INACTIVE,
54
                'checked_value'=> \LeadersLinked\Model\OrganizationPosition::STATUS_ACTIVE,
55
            ]
56
        ]);
57
 
58
 
59
    }
60
 
61
    /**
62
     *
63
     * @param AdapterInterface $adapter
64
     * @param int $company_id
65
     * @return array
66
     */
67
    private function getJobDescriptionSelectOptions($adapter, $company_id)
68
    {
69
        $options = [];
70
 
71
        $mapper = JobDescriptionMapper::getInstance($adapter);
72
        $records = $mapper->fetchAllActiveByCompanyId($company_id);
73
 
74
        foreach($records as $record)
75
        {
76
            $options[$record->uuid] = $record->name;
77
        }
78
        return $options;
79
    }
80
 
81
    /**
82
     *
83
     * @param AdapterInterface $adapter
84
     * @param int $company_id
85
     * @return array
86
     */
87
    private function getUserSelectOptions($adapter, $company_id)
88
    {
89
        $options = [];
90
 
91
        $mapper = UserMapper::getInstance($adapter);
92
        $records = $mapper->fetchAllByCompanyId($company_id);
93
 
94
        foreach($records as $record)
95
        {
96
            $options[$record->uuid] = trim($record->first_name . ' ' . $record->last_name) . ' (' . $record->email . ')';
97
        }
98
        return $options;
99
    }
100
}