Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 1 Rev 5223
Línea 17... Línea 17...
17
use LeadersLinked\Model\CompanyMicrolearningCapsule;
17
use LeadersLinked\Model\CompanyMicrolearningCapsule;
18
use LeadersLinked\Model\CompanyMicrolearningCapsuleUser;
18
use LeadersLinked\Model\CompanyMicrolearningCapsuleUser;
19
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleUserMapper;
19
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleUserMapper;
20
use LeadersLinked\Mapper\CompanyMicrolearningUserMapper;
20
use LeadersLinked\Mapper\CompanyMicrolearningUserMapper;
21
use LeadersLinked\Model\CompanyMicrolearningUser;
21
use LeadersLinked\Model\CompanyMicrolearningUser;
-
 
22
use LeadersLinked\Mapper\EngagementRewardMapper;
-
 
23
use LeadersLinked\Model\EngagementReward;
Línea 22... Línea 24...
22
 
24
 
23
class MarketPlaceController extends AbstractActionController
25
class MarketPlaceController extends AbstractActionController
24
{
26
{
25
    /**
27
    /**
Línea 94... Línea 96...
94
                    }
96
                    }
Línea 95... Línea 97...
95
                    
97
                    
96
                }
98
                }
Línea -... Línea 99...
-
 
99
            }
97
            }
100
            
98
            
-
 
99
            if($isJson) {
-
 
100
 
-
 
101
                
-
 
Línea 102... Línea 101...
102
                
101
            //$isJson = true;
103
                $companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
-
 
104
                
-
 
105
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
-
 
106
                $queryMapper = QueryMapper::getInstance($this->adapter);
-
 
107
                $select = $queryMapper->getSql()->select();
-
 
108
                $select->columns(['id', 'uuid', 'name', 'status',  'image', 'order', 'privacy', 'type', 'marketplace']);
-
 
109
                $select->from(['c' => CompanyMicrolearningCapsuleMapper::_TABLE]);
-
 
110
                $select->join(['t' => CompanyMicrolearningTopicMapper::_TABLE], ' c.topic_id = t.id ', ['topic_uuid' => 'uuid']);
-
 
111
                $select->join(['o' => CompanyMapper::_TABLE], ' c.company_id = o.id ', ['company_uuid' => 'uuid']);
102
            if($isJson) {
Línea 112... Línea -...
112
                $select->where->equalTo('c.privacy', CompanyMicrolearningCapsule::PRIVACY_PUBLIC);
-
 
113
                $select->where->equalTo('c.type', CompanyMicrolearningCapsule::TYPE_FREE);
-
 
114
                $select->where->equalTo('c.status', CompanyMicrolearningCapsule::STATUS_ACTIVE);
-
 
115
                
-
 
Línea 116... Línea 103...
116
                if($search) {
103
                
117
                    $select->where->like('c.name', '%' . $search . '%');
104
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
118
                }
105
                $entity = trim(filter_var($this->params()->fromQuery('entity', 'capsules'), FILTER_SANITIZE_STRING));
119
                $select->order(['name ASC']);
-
 
120
                
-
 
121
               //echo $select->getSqlString($this->adapter->platform); exit;
106
                
122
 
-
 
123
                $records = $queryMapper->fetchAll($select);
-
 
Línea -... Línea 107...
-
 
107
                
-
 
108
                if($entity == 'rewards') {
Línea 124... Línea -...
124
 
-
 
125
                $items = [];
109
        
126
                foreach($records as $record)
110
                    $currentUserPlugin = $this->plugin('currentUserPlugin');
127
                {
-
 
128
                    $capsuleUser = $companyMicrolearningCapsuleUserMapper->fetchOneByUserIdAndCapsuleId($currentUser->id, $record['id']);
-
 
Línea 129... Línea -...
129
                    
-
 
130
                    
-
 
131
                    $params = [
-
 
132
                        'company_id' => $record['company_uuid'], 
-
 
133
                        'topic_id' => $record['topic_uuid'], 
-
 
134
                        'capsule_id' => $record['uuid']
-
 
135
                    ];
-
 
136
                    
-
 
Línea -... Línea 111...
-
 
111
                    $currentUser = $currentUserPlugin->getUser();
-
 
112
                    
-
 
113
                    $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
-
 
114
                    $currentNetwork = $currentNetworkPlugin->getNetwork();
-
 
115
                    
-
 
116
                    $companyMapper = CompanyMapper::getInstance($this->adapter);
-
 
117
                    $company = $companyMapper->fetchDefaultForNetworkByNetworkId($currentNetwork->id);
-
 
118
                    
-
 
119
                    
-
 
120
                    
-
 
121
                    $queryMapper = QueryMapper::getInstance($this->adapter);
-
 
122
                    $select = $queryMapper->getSql()->select( EngagementRewardMapper::_TABLE);
-
 
123
                    $select->columns(['uuid', 'name',   'image', 'points']);
-
 
124
                    $select->where->equalTo('company_id', $company->id);
-
 
125
                    $select->where->equalTo('status', EngagementReward::STATUS_ACTIVE);
-
 
126
                    
-
 
127
                    if($search) {
-
 
128
                        $select->where->like('c.name', '%' . $search . '%');
-
 
129
                    }
Línea -... Línea 130...
-
 
130
                    
-
 
131
                    $select->order(['name ASC']);
-
 
132
                    
-
 
133
                    
-
 
134
                    $records = $queryMapper->fetchAll($select);
-
 
135
                    
-
 
136
                    $items = [];
-
 
137
                    foreach($records as $record)
-
 
138
                    {
-
 
139
 
-
 
140
                        
-
 
141
                        $item = [
-
 
142
                            
-
 
143
                            'name' => $record['name'],
-
 
144
                            'image' => $this->url()->fromRoute('storage', ['type' => 'engagement-reward', 'code' => $record['uuid'], 'filename' => $record['image']]),
-
 
145
                            'points' => $record['points'],
-
 
146
                            'link_claim' => $this->url()->fromRoute('marketplace/claim', ['id' => $record['uuid']])
-
 
147
                        ];
-
 
148
                        
-
 
149
                        
-
 
150
                        array_push($items, $item);
-
 
151
                    }
-
 
152
                    
-
 
153
                    
-
 
154
                } else if($entity == 'capsules') {
-
 
155
                
-
 
156
                    $companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
-
 
157
                    
-
 
158
                   
-
 
159
                    $queryMapper = QueryMapper::getInstance($this->adapter);
-
 
160
                    $select = $queryMapper->getSql()->select();
-
 
161
                    $select->columns(['id', 'uuid', 'name', 'status',  'image', 'order', 'privacy', 'type', 'marketplace']);
-
 
162
                    $select->from(['c' => CompanyMicrolearningCapsuleMapper::_TABLE]);
-
 
163
                    $select->join(['t' => CompanyMicrolearningTopicMapper::_TABLE], ' c.topic_id = t.id ', ['topic_uuid' => 'uuid']);
-
 
164
                    $select->join(['o' => CompanyMapper::_TABLE], ' c.company_id = o.id ', ['company_uuid' => 'uuid']);
-
 
165
                    $select->where->equalTo('c.privacy', CompanyMicrolearningCapsule::PRIVACY_PUBLIC);
-
 
166
                    $select->where->equalTo('c.type', CompanyMicrolearningCapsule::TYPE_FREE);
-
 
167
                    $select->where->equalTo('c.status', CompanyMicrolearningCapsule::STATUS_ACTIVE);
-
 
168
                    
-
 
169
                    if($search) {
-
 
170
                        $select->where->like('c.name', '%' . $search . '%');
-
 
171
                    }
-
 
172
                    $select->order(['name ASC']);
-
 
173
                    
-
 
174
                   //echo $select->getSqlString($this->adapter->platform); exit;
-
 
175
    
-
 
176
                    $records = $queryMapper->fetchAll($select);
-
 
177
    
-
 
178
                    $items = [];
-
 
179
                    foreach($records as $record)
-
 
180
                    {
-
 
181
                        $capsuleUser = $companyMicrolearningCapsuleUserMapper->fetchOneByUserIdAndCapsuleId($currentUser->id, $record['id']);
-
 
182
                        
-
 
183
                        
-
 
184
                        $params = [
-
 
185
                            'company_id' => $record['company_uuid'], 
-
 
186
                            'topic_id' => $record['topic_uuid'], 
-
 
187
                            'capsule_id' => $record['uuid']
-
 
188
                        ];
-
 
189
                        
137
 
190
    
-
 
191
                        $item = [
138
                    $item = [
192
                   
Línea 139... Línea 193...
139
               
193
                            'name' => $record['name'],
Línea 310... Línea 364...
310
            ]);
364
            ]);
311
        }
365
        }
Línea 312... Línea 366...
312
     
366
     
Línea -... Línea 367...
-
 
367
    }
-
 
368
    
-
 
369
    public function claimAction()
-
 
370
    {
-
 
371
        $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
372
        $currentUser = $currentUserPlugin->getUser();
-
 
373
        
-
 
374
      
-
 
375
        
-
 
376
        return new JsonModel([
-
 
377
            'success' => true,
-
 
378
            'data' => 'Por definirse'
-
 
379
        ]);
313
    }
380
    }
314
    
381
    
-
 
382
    public function getCategoriesAction()
-
 
383
    {
-
 
384
        $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
385
        $currentUser = $currentUserPlugin->getUser();
-
 
386
        
-
 
387
        $acl = $this->getEvent()->getViewModel()->getVariable('acl');
-
 
388
        $allowDailyPuse = $acl->isAllowed($currentUser->usertype_id, 'daily-pulse');
-
 
389
        
-
 
390
        $data = [
-
 
391
            'capsules' => 'LABEL_CAPSULES'
-
 
392
        ];
-
 
393
        
-
 
394
        if( $allowDailyPuse) {
-
 
395
            $data['rewards'] = 'LABEL_REWARDS';
-
 
396
        }
315
    public function getCategoriesAction()
397
        
316
    {
398
        
317
        return new JsonModel([
399
        return new JsonModel([
318
            'success' => true,
-
 
319
            'data' => [
-
 
320
                'capsules' => 'Cápsulas'
400
            'success' => true,
321
            ]
401
            'data' => $data
Línea 322... Línea 402...
322
        ]);
402
        ]);