Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form;
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
 
14
class CompetencyForm extends Form
15
{
16
 
17
    /**
18
     *
19
     * @param AdapterInterface $adapter
20
     */
66 efrain 21
    public function __construct($adapter, $company_id = 0)
1 www 22
    {
23
        parent::__construct();
24
        $this->setInputFilter(new CompetencyFilter($adapter));
25
 
26
        $this->add([
27
            'name' => 'competency_type_id',
28
            'type' => \Laminas\Form\Element\Select::class,
29
            'attributes' => [
30
                'id' => 'competency_type_id',
31
            ],
32
            'options' => [
66 efrain 33
                'value_options' => $this->getSelectOptions($adapter, $company_id)
1 www 34
            ]
35
        ]);
36
 
37
 
38
        $this->add([
39
            'name' => 'name',
40
            'type' => \Laminas\Form\Element\Text::class,
41
             'attributes' => [
42
                'maxlength' 	=> 128,
43
                'id' 			=> 'name',
44
            ]
45
        ]);
46
 
47
        $this->add([
48
            'name' => 'description',
49
            'type' => \Laminas\Form\Element\Textarea::class,
50
            'attributes' => [
51
                'id'    => 'description',
52
            ]
53
        ]);
54
 
888 geraldo 55
        $this->add([
56
            'name' => 'behaviors',
57
            'type' => \Laminas\Form\Element\Textarea::class,
58
            'attributes' => [
59
                'id'    => 'behaviors',
60
            ]
61
        ]);
28 efrain 62
 
888 geraldo 63
 
64
 
28 efrain 65
        $this->add([
1 www 66
            'name' => 'status',
67
            'type' => \Laminas\Form\Element\Checkbox::class,
68
            'attributes' => [
69
                'id' 			=> 'status',
70
            ],
71
            'options' => [
72
                'use_hidden_element' => 0,
73
                'unchecked_value' => \LeadersLinked\Model\Competency::STATUS_INACTIVE,
74
                'checked_value'=> \LeadersLinked\Model\Competency::STATUS_ACTIVE,
75
            ]
76
        ]);
77
 
78
    }
79
 
80
    /**
81
     *
82
     * @param AdapterInterface $adapter
83
     */
66 efrain 84
    private function getSelectOptions($adapter, $company_id)
1 www 85
    {
86
        $options = [];
87
 
88
        $mapper = CompetencyTypeMapper::getInstance($adapter);
89
 
66 efrain 90
        if($company_id) {
91
            $records = $mapper->fetchAllActivesByCompanyId($company_id);
92
        } else {
93
            $records = $mapper->fetchAllActivesByDefault();
94
        }
95
 
96
 
1 www 97
        foreach($records as $record)
98
        {
99
            $options[$record->uuid] = $record->name;
100
        }
101
        return $options;
102
    }
103
}