Proyectos de Subversion LeadersLinked - Backend

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
16766 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\Planning;
6
 
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Log\LoggerInterface;
10
use LeadersLinked\Model\PlanningTask;
11
use Laminas\Form\Element;
12
use LeadersLinked\Mapper\UserMapper;
13
 
14
use LeadersLinked\Mapper\CompanyUserMapper;
15
 
16
class PlanningTaskForm extends Form
17
{
18
 
19
    public function __construct($adapter, $company_id){
20
        parent::__construct();
21
        $this->setInputFilter(new PlanningTaskFilter($adapter));
22
 
23
        $this->add([
24
            'name' => 'title',
25
            'type' => \Laminas\Form\Element\Text::class,
26
            'attributes' => [
27
                'maxlength' 	=> 254,
28
                'id' 			=> 'title',
29
            ]
30
        ]);
31
 
32
 
33
        $this->add([
34
            'name' => 'description',
35
            'type' => \Laminas\Form\Element\Text::class,
36
            'attributes' => [
37
                'maxlength' 	=> 254,
38
                'id'    => 'description',
39
            ]
40
        ]);
41
 
42
        $this->add([
43
            'name' => 'how',
44
            'type' => \Laminas\Form\Element\Text::class,
45
            'attributes' => [
46
                'maxlength' 	=> 254,
47
                'id' 			=> 'how',
48
            ]
49
        ]);
50
 
51
        $this->add([
52
            'name' => 'place',
53
            'type' => \Laminas\Form\Element\Text::class,
54
            'attributes' => [
55
                'maxlength' 	=> 254,
56
                'id' 			=> 'place',
57
            ]
58
        ]);
59
 
60
 
61
 
62
        $this->add([
63
            'name' => 'who',
64
            'type' => \Laminas\Form\Element\Select::class,
65
            'attributes' => [
66
                'required'=> true,
67
                'multiple' 	=> 'yes',
68
                'id' => 'who'
69
            ],
70
            'options' => [
71
                'disable_inarray_validator' => true,
72
                'value_options' => $this->getSelectOptions($adapter,$company_id)
73
            ]
74
        ]);
75
 
76
        $this->add([
77
            'name' => 'time',
78
            'type' => \Laminas\Form\Element\Number::class,
79
            'attributes' => [
80
                'min' => '0',
81
                'step' => '1',
82
                'id' => 'time',
83
            ]
84
        ]);
85
        $this->add([
86
            'name' => 'date',
87
            'type' => Element\Date::class,
88
            'attributes' => [
89
                'maxlength' 	=> 15,
90
                'id' 			=> 'date',
91
            ]
92
        ]);
93
        $this->add([
94
            'name' => 'detour',
95
            'type' => \Laminas\Form\Element\Text::class,
96
            'attributes' => [
97
                'maxlength' 	=> 254,
98
                'id' 			=> 'detour',
99
            ]
100
        ]);
101
        $this->add([
102
            'name' => 'evaluation',
103
            'type' => \Laminas\Form\Element\Text::class,
104
            'attributes' => [
105
                'maxlength' 	=> 254,
106
                'id' 			=> 'evaluation',
107
            ]
108
        ]);
109
        $this->add([
110
            'type' => Element\Range::class,
111
            'name' => 'indicator',
112
            'attributes' => [
113
                'min'=> 1,
114
                'max' => 100, // default maximum is 100
115
                'id' => 'indicator',
116
            ],
117
        ]);
118
 
119
        $this->add([
120
            'name' => 'cost',
121
            'type' => \Laminas\Form\Element\Number::class,
122
            'attributes' => [
123
                'min' => '0',
124
                'step' => '1',
125
                'id' => 'cost',
126
            ]
127
        ]);
128
 
129
 
130
        $this->add([
131
            'type' => Element\Select::class,
132
            'name' => 'priority',
133
            'options' =>  [
134
                'empty_option' => 'LABEL_SELECT',
135
                'value_options' =>[
136
                    'i' => 'LABEL_IMPORTANT',
137
                    'ni' => 'LABEL_NOT_IMPORTANT',
138
                ],
139
            ],
140
            'attributes'=> [
141
                'required'=> true,
142
                 'class' => 'Custom-select',
143
                'id' => 'priority',
144
                  ]
145
            ]);
146
            $this->add([
147
                'type' => Element\Select::class,
148
                'name' => 'urgent',
149
                'options' =>  [
150
                    'empty_option' => 'LABEL_SELECT',
151
                    'value_options' =>[
152
                        'u' => 'LABEL_URGENT',
153
                        'nu' => 'LABEL_NOT_URGENT'
154
                    ],
155
                ],
156
                'attributes'=> [
157
                    'required'=> true,
158
                     'class' => 'Custom-select',
159
                    'id' => 'urgent',
160
                      ]
161
                ]);
162
 
163
        $this->add([
164
            'name' => 'status',
165
            'type' => \Laminas\Form\Element\Checkbox::class,
166
            'attributes' => [
167
                'id' 			=> 'status',
168
            ],
169
            'options' => [
170
                'use_hidden_element' => false,
171
                'unchecked_value' => \LeadersLinked\Model\PlanningTask::STATUS_INACTIVE,
172
                'checked_value'=> \LeadersLinked\Model\PlanningTask::STATUS_ACTIVE,
173
            ]
174
        ]);
175
 
176
    }
177
 
178
    private function getSelectOptions($adapter,$company_id)
179
    {
180
            $companyUserMapper = CompanyUserMapper::getInstance($adapter);
181
            $userMapper = UserMapper::getInstance($adapter);
182
            $datosCompanyUser = $companyUserMapper->fetchAllByCompanyId($company_id);
183
            $users=[];
184
 
185
            foreach($datosCompanyUser as $record){
186
                $datosUser = $userMapper->fetchOne($record->user_id);
187
                $users[$datosUser->uuid] = $datosUser->uuid;
188
            }
189
 
190
        return $users;
191
    }
192
 
193
}