Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
17002 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Form\DevelopmentContent;
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
use LeadersLinked\Mapper\TopicMapper;
13
use LeadersLinked\Model\Feed;
14
use Laminas\Form\Element;
15
 
16
class DevelopmentContentCreateFeedForm extends Form
17
{
18
 
19
    public function __construct($adapter)
20
    {
21
        parent::__construct();
22
        $this->setInputFilter(new DevelopmentContentCreateFeedFilter($adapter));
23
 
24
 
25
        $this->add([
26
            'name' => 'priority',
27
            'type' => \Laminas\Form\Element\Checkbox::class,
28
            'attributes' => [
29
                'id' 			=> 'priority',
30
                'class'         => 'form-control',
31
            ],
32
            'options' => [
33
                'use_hidden_element' => false,
34
                'unchecked_value' => \LeadersLinked\Model\Feed::PRIORITY_NORMAL,
35
                'checked_value'=> \LeadersLinked\Model\Feed::PRIORITY_URGENT,
36
            ]
37
        ]);
38
 
39
        $this->add([
40
            'name' => 'file_type',
41
            'type' => \Laminas\Form\Element\Hidden::class,
42
            'attributes' => [
43
                'id'    => 'file_type',
44
                'value_options' => [
45
                    Feed::TYPE_HPTG,
46
                    Feed::TYPE_MYT_ANSWER
47
                ]
48
            ]
49
        ]);
50
 
51
        $this->add([
52
            'name' => 'time',
53
            'type' => Element\Time::class,
54
            'options'=> [
55
                'format' => 'H:i',
56
            ]
57
        ]);
58
        $this->add([
59
            'name' => 'date',
60
            'type' => Element\Date::class,
61
            'attributes' => [
62
                'maxlength' 	=> 15,
63
                'id' 			=> 'date',
64
            ]
65
        ]);
66
        $this->add([
67
            'name' => 'link_name',
68
            'type' => \Laminas\Form\Element\Text::class,
69
            'attributes' => [
70
                'maxlength' 	=> 254,
71
                'id' 			=> 'link_name',
72
            ]
73
        ]);
74
        $this->add([
75
            'type' => Element\Select::class,
76
            'name' => 'link_type',
77
            'options' =>  [
78
                'empty_option' => 'LABEL_SELECT',
79
                'value_options' =>[
80
                    'skype' => 'Skype',
81
                    'zoom' => 'Zoom',
82
                    'meet'=>'Meet'
83
                ],
84
            ],
85
            'attributes'=> [
86
                'class' => 'Custom-select',
87
                'id' => 'link_type',
88
                  ]
89
            ]);
90
 
91
            $this->add([
92
                'name' => 'link_media',
93
                'type' => Element\Select::class,
94
                'options' => [
95
                    'empty_option' => 'LABEL_LINK',
96
                    'value_options' => [
97
                        'cesa' => 'CESA',
98
                        'youtube' => 'YouTube',
99
                        'spotify'=> 'Spotify',
100
                        'deezer' => 'Deezer',
101
                        'apple' => 'Apple Podcast',
102
                    ],
103
                ],
104
                'attributes' => [
105
                    'class' => 'Custom-select',
106
                    'id' => 'link_media',
107
                ]
108
            ]);
109
 
110
        $this->add([
111
                'name' => 'title',
112
                'type' => \Laminas\Form\Element\Text::class,
113
                'attributes' => [
114
                    'maxlength' 	=> 128,
115
                    'id' 			=> 'title',
116
                ]
117
        ]);
118
 
119
        $this->add([
120
            'name' => 'description',
121
            'type' => \Laminas\Form\Element\Textarea::class,
122
            'attributes' => [
123
                'id'    => 'description',
124
            ]
125
        ]);
126
 
127
        $this->add([
128
            'name' => 'file',
129
            'type' => \Laminas\Form\Element\File::class,
130
             'attributes' => [
131
                'id' => 'file',
132
            ]
133
         ]);
134
 
135
        $this->add([
136
            'name' => 'video',
137
            'type' => \Laminas\Form\Element\File::class,
138
            'attributes' => [
139
                'id' => 'video',
140
            ]
141
        ]);
142
 
143
        $this->add([
144
            'name' => 'doc',
145
            'type' => \Laminas\Form\Element\File::class,
146
            'attributes' => [
147
                'id' => 'doc',
148
            ]
149
        ]);
150
 
151
        $this->add([
152
            'name' => 'image',
153
            'type' => \Laminas\Form\Element\File::class,
154
            'attributes' => [
155
                'id' => 'image',
156
            ]
157
        ]);
158
 
159
        $this->add([
160
            'name' => 'category_id',
161
            'type' => \Laminas\Form\Element\Select::class,
162
            'attributes' => [
163
                'id' => 'category_id',
164
            ],
165
            'options' => [
166
                'value_options' => $this->getSelectFormOptions($adapter)
167
            ]
168
        ]);
169
 
170
        $this->add([
171
             'name' => 'category_content',
172
             'type' => \Laminas\Form\Element\Select::class,
173
             'attributes' => [
174
                 'id' => 'category_dc',
175
             ],
176
             'options' => [
177
                 'value_options' => $this->getDevelopmentFormOptions($adapter)
178
             ]
179
         ]);
180
 
181
 
182
    }
183
 
184
     /**
185
     *
186
     * @param AdapterInterface $adapter
187
     */
188
    private function getSelectFormOptions($adapter)
189
    {
190
        $options = [];
191
 
192
        $mapper = TopicMapper::getInstance($adapter);
193
        $records = $mapper->fetchAllMyTrainer();
194
 
195
        foreach($records as $record)
196
        {
197
            $options[$record->uuid] = $record->title;
198
        }
199
        return $options;
200
    }
201
 
202
     /**
203
     *
204
     * @param AdapterInterface $adapter
205
     */
206
    private function getDevelopmentFormOptions($adapter)
207
    {
208
        $options = [];
209
 
210
        $mapper = TopicMapper::getInstance($adapter);
211
        $records = $mapper->fetchAllDevelopment();
212
 
213
        foreach($records as $record)
214
        {
215
            $options[$record->uuid] = $record->title;
216
        }
217
        return $options;
218
    }
219
 
220
 
221
}