Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15446 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\PerformanceEvaluation;
6
 
7
use LeadersLinked\Mapper\JobDescriptionMapper;
8
use Laminas\Form\Form;
9
use Laminas\Db\Adapter\AdapterInterface;
10
 
11
 
12
class PerformanceEvaluationFormForm extends Form
13
{
14
 
15
    public function __construct($adapter, $company_id = 0)
16
    {
17
        parent::__construct();
18
        $this->setInputFilter(new PerformanceEvaluationFormFilter($adapter));
19
 
20
        $this->add([
21
            'name' => 'name',
22
            'type' => \Laminas\Form\Element\Text::class,
23
             'attributes' => [
24
                'maxlength' 	=> 128,
25
                'id' 			=> 'name',
26
            ]
27
        ]);
28
 
29
        $this->add([
30
            'name' => 'description',
31
            'type' => \Laminas\Form\Element\Textarea::class,
32
            'attributes' => [
33
                'maxlength' 	=> 1024,
34
                'rows' 	=> 5,
35
                'id'    => 'description',
36
            ]
37
        ]);
38
 
39
 
40
 
41
        $this->add([
42
            'name' => 'job_description_id',
43
            'type' => \Laminas\Form\Element\Select::class,
44
             'attributes' => [
45
                'id' 			=> 'job_description_id',
46
             ],
47
             'options' => [
48
                'value_options' => $this->getSelectOptions($adapter, $company_id)
49
            ]
50
        ]);
51
 
52
       /*
53
        $this->add([
54
            'name' => 'content',
55
            'type' => \Laminas\Form\Element\Textarea::class,
56
            'attributes' => [
57
                'id'    => 'content',
58
            ]
59
        ]);*/
60
 
61
        $this->add([
62
            'name' => 'status',
63
            'type' => \Laminas\Form\Element\Checkbox::class,
64
            'attributes' => [
65
                'id' 			=> 'status',
66
            ],
67
            'options' => [
16766 efrain 68
                'use_hidden_element' => false,
15446 efrain 69
                'unchecked_value' => \LeadersLinked\Model\PerformanceEvaluationForm::STATUS_INACTIVE,
70
                'checked_value'=> \LeadersLinked\Model\PerformanceEvaluationForm::STATUS_ACTIVE,
71
            ]
72
        ]);
73
 
74
    }
75
 
76
    /**
77
     *
78
     * @param AdapterInterface $adapter
79
     */
80
    private function getSelectOptions($adapter, $company_id)
81
    {
82
        $options = [];
83
 
84
        $mapper = JobDescriptionMapper::getInstance($adapter);
85
        $records = $mapper->fetchAllActiveByCompanyId($company_id);
86
 
87
 
88
        foreach($records as $record)
89
        {
90
            $options[$record->uuid] = $record->name;
91
        }
92
        return $options;
93
    }
94
 
95
 
96
 
97
}