Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16766 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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