Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17111 | Rev 17183 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17111 Rev 17178
Línea 3... Línea 3...
3
declare(strict_types=1);
3
declare(strict_types=1);
Línea 4... Línea 4...
4
 
4
 
Línea 5... Línea 5...
5
namespace LeadersLinked\Form\Microlearning;
5
namespace LeadersLinked\Form\Microlearning;
6
 
6
 
7
use Laminas\Form\Form;
7
use Laminas\Form\Form;
8
use Laminas\Db\Adapter\AdapterInterface;
8
use Laminas\Form\Element\Select;
9
use Laminas\Log\LoggerInterface;
9
use Laminas\Form\Element\Textarea;
10
use LeadersLinked\Mapper\CompanySizeMapper;
10
use Laminas\Form\Element\Text;
11
use LeadersLinked\Mapper\IndustryMapper;
11
use Laminas\Form\Element\Hidden;
-
 
12
use LeadersLinked\Model\Company;
-
 
13
use LeadersLinked\Model\MicrolearningTopic;
Línea 12... Línea 14...
12
use LeadersLinked\Model\Feed;
14
use LeadersLinked\Model\MicrolearningCapsule;
13
use LeadersLinked\Model\MicrolearningTopic;
15
use LeadersLinked\Mapper\MicrolearningCapsuleMapper;
Línea 14... Línea 16...
14
 
16
 
15
class TopicEditForm extends Form
17
class TopicEditForm extends Form
16
{
18
{
17
 
19
 
Línea 18... Línea -...
18
    public function __construct($adapter) 
-
 
19
    {
-
 
20
        parent::__construct();
20
    public function __construct($adapter, $company_id, $internal = Company::INTERNAL_NO) 
21
        $this->setInputFilter(new TopicEditFilter($adapter));
21
    {
22
 
22
        parent::__construct();
23
 
23
        $this->setInputFilter(new TopicEditFilter($adapter));
24
        
24
 
25
        $this->add([
25
        $this->add([
26
            'name' => 'name',
26
            'name' => 'name',
Línea 27... Línea 27...
27
            'type' => \Laminas\Form\Element\Textarea::class,
27
            'type' => Textarea::class,
28
            'attributes' => [
28
            'attributes' => [
29
                'id'    => 'name',
29
                'id'    => 'name',
30
            ]
30
            ]
31
        ]);
31
        ]);
32
        
32
        
33
        $this->add([
33
        $this->add([
Línea 34... Línea 34...
34
            'name' => 'description',
34
            'name' => 'description',
35
            'type' => \Laminas\Form\Element\Textarea::class,
35
            'type' => Textarea::class,
36
            'attributes' => [
36
            'attributes' => [
37
                'id'    => 'description',
37
                'id'    => 'description',
38
            ]
38
            ]
39
        ]);
39
        ]);
40
        
40
        
Línea 41... Línea 41...
41
        $this->add([
41
        $this->add([
42
            'name' => 'order',
42
            'name' => 'order',
43
            'type' => \Laminas\Form\Element\Text::class,
43
            'type' => Text::class,
44
            'attributes' => [
44
            'attributes' => [
45
                'id'    => 'order',
45
                'id'    => 'order',
46
            ],
46
            ],
47
        ]);
47
        ]);
48
        
-
 
Línea -... Línea 48...
-
 
48
        
-
 
49
        $this->add([
-
 
50
            'name' => 'file',
-
 
51
            'type' => Hidden::class,
-
 
52
            'attributes' => [
-
 
53
                'id' => 'file',
-
 
54
            ]
Línea 49... Línea 55...
49
        $this->add([
55
        ]);
50
            'name' => 'file',
56
 
51
            'type' => \Laminas\Form\Element\Hidden::class,
57
        $this->add([
52
            'attributes' => [
58
            'name' => 'marketplace',
53
                'id' => 'file',
59
            'type' => Hidden::class,
54
            ]
60
            'attributes' => [
55
        ]);
61
                'id' => 'marketplace',
56
        
62
            ]
Línea 68... Línea 74...
68
            ],
74
            ],
69
            'attributes' => [
75
            'attributes' => [
70
                'id' => 'status',
76
                'id' => 'status',
71
            ]
77
            ]
72
        ]);
78
        ]);
73
        
-
 
Línea -... Línea 79...
-
 
79
 
-
 
80
        if($internal == Company::INTERNAL_YES) {
-
 
81
            $value_options = [
-
 
82
                MicrolearningTopic::PRIVACY_PRIVATE => 'LABEL_PRIVATE',
-
 
83
                MicrolearningTopic::PRIVACY_PUBLIC => 'LABEL_PUBLIC',
-
 
84
            ];
-
 
85
        } else {
-
 
86
            $value_options = [
-
 
87
                MicrolearningTopic::PRIVACY_PRIVATE => 'LABEL_PRIVATE',
-
 
88
            ];
-
 
89
        }
-
 
90
 
-
 
91
        $this->add([
-
 
92
            'name' => 'privacy',
-
 
93
            'type' => Select::class,
-
 
94
            'options' => [
-
 
95
                'empty_option' => 'LABEL_PRIVACY',
-
 
96
                'value_options' => $value_options,
-
 
97
            ],
-
 
98
            'attributes' => [
-
 
99
                'id' => 'privacy',
-
 
100
            ]
-
 
101
        ]);
-
 
102
 
-
 
103
        if($internal == Company::INTERNAL_YES) {
-
 
104
            $value_options = [
-
 
105
                MicrolearningTopic::TYPE_FREE => 'LABEL_FREE',
-
 
106
                MicrolearningTopic::TYPE_SELLING => 'LABEL_SELLING',
-
 
107
                MicrolearningTopic::TYPE_PRIVATE => 'LABEL_PRIVATE',
-
 
108
            ];
-
 
109
        } else {
-
 
110
            $value_options = [
-
 
111
                MicrolearningCapsule::TYPE_PRIVATE => 'LABEL_PRIVATE',
-
 
112
            ];
-
 
113
        }
-
 
114
 
-
 
115
        $this->add([
-
 
116
            'name' => 'type',
-
 
117
            'type' => Select::class,
-
 
118
            'options' => [
-
 
119
                'empty_option' => 'LABEL_TYPE',
-
 
120
                'value_options' => $value_options,
-
 
121
            ],
-
 
122
            'attributes' => [
-
 
123
                'id' => 'type',
-
 
124
            ]
Línea -... Línea 125...
-
 
125
        ]);
-
 
126
        
-
 
127
        $this->add([
-
 
128
            'name' => 'cost',
-
 
129
            'type' => Text::class,
-
 
130
            'attributes' => [
-
 
131
                'id'    => 'cost',
-
 
132
            ],
-
 
133
        ]);
-
 
134
 
-
 
135
        $this->add([
-
 
136
            'name' => 'capsule_uuid',
-
 
137
            'type' => Select::class,
-
 
138
            'attributes' => [
-
 
139
                'multiple' 	=> 'yes',
-
 
140
                'id' =>  'capsule_uuid',
-
 
141
            ],
-
 
142
            'options' => [
-
 
143
                'disable_inarray_validator' => true,
-
 
144
                'value_options' => $this->getSelectOptions($adapter, $company_id)
-
 
145
            ]
-
 
146
        ]);
-
 
147
 
-
 
148
        $this->add([
-
 
149
            'name' => 'capsule_id',
-
 
150
            'type' => Select::class,
-
 
151
            'attributes' => [
-
 
152
                'multiple' 	=> 'yes',
-
 
153
                'id' =>  'capsule_uuid',
-
 
154
            ],
-
 
155
            'options' => [
-
 
156
                'disable_inarray_validator' => true,
-
 
157
                'value_options' => $this->getSelectOptions($adapter, $company_id)
-
 
158
            ]
-
 
159
        ]);
-
 
160
    }
-
 
161
 
-
 
162
    private function getSelectOptions($adapter, $company_id)
-
 
163
    {
-
 
164
        $options = [];
-
 
165
    
-
 
166
        $mapper = MicrolearningCapsuleMapper::getInstance($adapter);
-
 
167
        $records = $mapper->fetchAllActiveByCompanyId($company_id);
-
 
168
    
-
 
169
        foreach($records as $record)
-
 
170
        {
-
 
171
            $options[$record->uuid] = $record->name;
74
 
172
        }
75
        
173
        return $options;