Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16766 | | Comparar con el anterior | 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 LeadersLinked\Mapper\UserMapper;
10
 
11
class PlanningTaskForm extends Form
12
{
16785 efrain 13
 
14
    /**
15
     *
16
     * @param AdapterInterface $adapter
17
     * @param int $company_id
18
     */
19
    public function __construct($adapter, $company_id)
20
    {
16766 efrain 21
        parent::__construct();
16785 efrain 22
 
23
        $this->setInputFilter(new PlanningTaskFilter());
24
 
16766 efrain 25
        $this->add([
26
            'name' => 'title',
27
            'type' => \Laminas\Form\Element\Text::class,
28
            'attributes' => [
16785 efrain 29
                'maxlength' 	=> 128,
16766 efrain 30
                'id' 			=> 'title',
31
            ]
32
        ]);
33
 
34
        $this->add([
35
            'name' => 'description',
16785 efrain 36
            'type' => \Laminas\Form\Element\Textarea::class,
16766 efrain 37
            'attributes' => [
38
                'id'    => 'description',
16785 efrain 39
                'maxlength' 	=> 1024,
40
                'rows' => 5,
16766 efrain 41
            ]
42
        ]);
43
 
44
        $this->add([
16785 efrain 45
            'name' => 'place',
46
            'type' => \Laminas\Form\Element\Textarea::class,
16766 efrain 47
            'attributes' => [
16785 efrain 48
                'id'    => 'place',
16766 efrain 49
                'maxlength' 	=> 254,
16785 efrain 50
                'rows' => 5,
16766 efrain 51
            ]
52
        ]);
16785 efrain 53
 
16766 efrain 54
        $this->add([
16785 efrain 55
            'name' => 'how',
56
            'type' => \Laminas\Form\Element\Textarea::class,
16766 efrain 57
            'attributes' => [
16785 efrain 58
                'id'    => 'how',
59
                'maxlength' 	=> 1024,
60
                'rows' => 5,
16766 efrain 61
            ]
62
        ]);
63
 
64
        $this->add([
16785 efrain 65
            'name' => 'detour',
66
            'type' => \Laminas\Form\Element\Textarea::class,
67
            'attributes' => [
68
                'id'    => 'detour',
69
                'maxlength' 	=> 1024,
70
                'rows' => 5,
71
            ]
72
        ]);
73
 
74
        $this->add([
75
            'name' => 'evaluation',
76
            'type' => \Laminas\Form\Element\Textarea::class,
77
            'attributes' => [
78
                'id'    => 'evaluation',
79
                'maxlength' 	=> 1024,
80
                'rows' => 5,
81
            ]
82
        ]);
83
 
84
 
85
        $this->add([
86
            'name' => 'user_id',
16766 efrain 87
            'type' => \Laminas\Form\Element\Select::class,
88
            'attributes' => [
89
                'required'=> true,
90
                'multiple' 	=> 'yes',
16785 efrain 91
                'id' => 'user_id'
16766 efrain 92
            ],
93
            'options' => [
94
                'disable_inarray_validator' => true,
95
                'value_options' => $this->getSelectOptions($adapter,$company_id)
96
            ]
97
        ]);
16785 efrain 98
 
16766 efrain 99
        $this->add([
16785 efrain 100
            'name' => 'progress',
16766 efrain 101
            'type' => \Laminas\Form\Element\Number::class,
102
            'attributes' => [
16785 efrain 103
                'min' => 0,
104
                'max' => 100,
105
                'step' => 1,
106
                'id' => 'progress',
16766 efrain 107
            ]
108
        ]);
16785 efrain 109
 
110
 
16766 efrain 111
        $this->add([
16785 efrain 112
            'name' => 'status',
113
            'type' => \Laminas\Form\Element\Checkbox::class,
16766 efrain 114
            'attributes' => [
16785 efrain 115
                'id' 			=> 'status',
116
            ],
117
            'options' => [
118
                'use_hidden_element' => false,
119
                'unchecked_value' => \LeadersLinked\Model\PlanningGoal::STATUS_INACTIVE,
120
                'checked_value'=> \LeadersLinked\Model\PlanningGoal::STATUS_ACTIVE,
16766 efrain 121
            ]
122
        ]);
16785 efrain 123
 
16766 efrain 124
        $this->add([
16785 efrain 125
            'name' => 'priority',
126
            'type' => \Laminas\Form\Element\Checkbox::class,
16766 efrain 127
            'attributes' => [
16785 efrain 128
                'id' 			=> 'priority',
129
            ],
130
            'options' => [
131
                'use_hidden_element' => false,
132
                'unchecked_value' => \LeadersLinked\Model\PlanningTask::NO,
133
                'checked_value'=> \LeadersLinked\Model\PlanningTask::YES,
16766 efrain 134
            ]
135
        ]);
16785 efrain 136
 
137
 
16766 efrain 138
        $this->add([
16785 efrain 139
            'name' => 'urgent',
140
            'type' => \Laminas\Form\Element\Checkbox::class,
141
            'attributes' => [
142
                'id' 			=> 'urgent',
143
            ],
144
            'options' => [
145
                'use_hidden_element' => false,
146
                'unchecked_value' => \LeadersLinked\Model\PlanningTask::NO,
147
                'checked_value'=> \LeadersLinked\Model\PlanningTask::YES,
148
            ]
149
        ]);
150
 
151
 
152
        $this->add([
153
            'name' => 'date_range',
16766 efrain 154
            'type' => \Laminas\Form\Element\Text::class,
155
            'attributes' => [
16785 efrain 156
                'id'    => 'date_range',
16766 efrain 157
            ]
158
        ]);
16785 efrain 159
 
16766 efrain 160
        $this->add([
16785 efrain 161
            'name' => 'start',
162
            'type' => \Laminas\Form\Element\Hidden::class,
16766 efrain 163
            'attributes' => [
16785 efrain 164
                'id'    => 'start',
16766 efrain 165
            ],
166
        ]);
16785 efrain 167
 
16766 efrain 168
        $this->add([
16785 efrain 169
            'name' => 'end',
170
            'type' => \Laminas\Form\Element\Hidden::class,
171
            'attributes' => [
172
                'id'    => 'end',
173
            ],
174
        ]);
175
 
176
        $this->add([
16766 efrain 177
            'name' => 'cost',
178
            'type' => \Laminas\Form\Element\Number::class,
179
            'attributes' => [
16785 efrain 180
                'id'    => 'cost',
181
                'step' => 0.01,
182
                'min' => 0,
183
                'max' => 999999999999.99
184
            ],
16766 efrain 185
        ]);
186
 
187
        $this->add([
16785 efrain 188
            'name' => 'hours',
189
            'type' => \Laminas\Form\Element\Number::class,
16766 efrain 190
            'attributes' => [
16785 efrain 191
                'id'    => 'hours',
192
                'step' => 0.01,
193
                'min' => 0,
194
                'max' => 9999
16766 efrain 195
            ],
196
        ]);
16785 efrain 197
 
16766 efrain 198
    }
16785 efrain 199
 
200
    private function getSelectOptions($adapter, $company_id)
16766 efrain 201
    {
16785 efrain 202
        $items = [];
203
        $mapper = UserMapper::getInstance($adapter);
204
        $records = $mapper->fetchAllByCompanyId( $company_id );
205
 
206
        foreach($records as $record)
207
        {
208
            $items[ $record->uuid ] = trim($record->first_name . ' ' . $record->last_name) . ' (' . $record->email . ')';
209
        }
16766 efrain 210
 
16785 efrain 211
        return $items;
16766 efrain 212
    }
213
 
214
}