Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | | Comparar con el anterior | 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\MyCompanies;
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
 
13
class CreateForm extends Form
14
{
15
    /**
16
     *
17
     * @param AdapterInterface $adapter
18
     */
19
    public function __construct($adapter)
20
    {
21
        parent::__construct();
22
        $this->setInputFilter(new CreateFilter($adapter));
23
 
24
        $this->add([
25
            'name' => 'name',
26
            'type' => \Laminas\Form\Element\Text::class,
27
             'attributes' => [
28
                'maxlength' 	=> 128,
29
                'id' 			=> 'name',
30
            ]
31
         ]);
32
        $this->add([
33
             'name' => 'industry_id',
34
             'type' => \Laminas\Form\Element\Select::class,
35
             'options' => [
36
                 'value_options' => $this->optionsIndustry($adapter),
37
             ],
38
             'attributes' => [
39
                 'id' => 'industry_id',
40
             ]
41
         ]);
42
        $this->add([
43
            'name' => 'company_size_id',
44
            'type' => \Laminas\Form\Element\Select::class,
45
            'options' => [
46
                'value_options' => $this->optionsCompanySize($adapter),
47
            ],
48
            'attributes' => [
49
                'id' => 'company_size_id',
50
            ]
51
        ]);
52
    }
53
 
54
    /**
55
     *
56
     * @param AdapterInterface $adapter
57
     * @param LoggerInterface $logger
58
     * @return array
59
     */
60
    private function optionsCompanySize($adapter)
61
    {
62
        $companySizeMapper = CompanySizeMapper::getInstance($adapter);
3454 efrain 63
        $companySizes = $companySizeMapper->fetchAllActive();
1 www 64
 
65
        $options = [];
66
        foreach($companySizes as $companySize)
67
        {
68
            $options[$companySize->uuid] = $companySize->name . ' ( ' . $companySize->minimum_no_of_employee . ' - ' . $companySize->maximum_no_of_employee . ' )';
69
        }
70
 
71
        return $options;
72
    }
73
 
74
    /**
75
     *
76
     * @param AdapterInterface $adapter
77
     * @return array
78
     */
79
    private function optionsIndustry($adapter)
80
    {
81
        $industryMapper = IndustryMapper::getInstance($adapter);
3454 efrain 82
        $industries  = $industryMapper->fetchAllActive();
1 www 83
 
84
        $options = [];
85
        foreach($industries as $industry)
86
        {
87
            $options[$industry->uuid] = $industry->name;
88
        }
89
 
90
        return $options;
91
    }
92
 
93
}