1 |
www |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Controller;
|
|
|
5 |
|
|
|
6 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
7 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
8 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
9 |
use Laminas\Log\LoggerInterface;
|
|
|
10 |
use Laminas\View\Model\ViewModel;
|
|
|
11 |
use Laminas\View\Model\JsonModel;
|
|
|
12 |
use LeadersLinked\Form\ExtendUserMicrolearningForm;
|
|
|
13 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
14 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
15 |
use Laminas\Db\Sql\Expression;
|
|
|
16 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleUserMapper;
|
|
|
17 |
use LeadersLinked\Model\CompanyMicrolearningCapsuleUser;
|
|
|
18 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleMapper;
|
|
|
19 |
use LeadersLinked\Mapper\CompanyMicrolearningUserProgressMapper;
|
|
|
20 |
use LeadersLinked\Mapper\CompanyMicrolearningSlideMapper;
|
|
|
21 |
use LeadersLinked\Mapper\CompanyMicrolearningUserLogMapper;
|
|
|
22 |
use Google\Service\Classroom\Student;
|
|
|
23 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserCompanyMapper;
|
|
|
24 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserFunctionMapper;
|
|
|
25 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserGroupMapper;
|
|
|
26 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserInstitutionMapper;
|
|
|
27 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserProgramMapper;
|
|
|
28 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserPartnerMapper;
|
|
|
29 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserSectorMapper;
|
|
|
30 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserStudentTypeMapper;
|
|
|
31 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserMapper;
|
187 |
efrain |
32 |
use LeadersLinked\Mapper\CompanyMicrolearningTopicMapper;
|
2 |
efrain |
33 |
use LeadersLinked\Mapper\DeviceMapper;
|
|
|
34 |
use LeadersLinked\Model\Application;
|
129 |
efrain |
35 |
use LeadersLinked\Mapper\CompanyMicrolearningUserMapper;
|
|
|
36 |
use LeadersLinked\Model\CompanyMicrolearningExtendUser;
|
187 |
efrain |
37 |
use LeadersLinked\Form\TopicCapsuleForm;
|
|
|
38 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleCommentMapper;
|
|
|
39 |
use Laminas\Hydrator\ArraySerializableHydrator;
|
|
|
40 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
41 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
42 |
use Laminas\Paginator\Paginator;
|
14612 |
efrain |
43 |
use LeadersLinked\Model\CompanyMicrolearningUserProgress;
|
1 |
www |
44 |
|
|
|
45 |
|
|
|
46 |
class MicrolearningReportsController extends AbstractActionController
|
|
|
47 |
{
|
|
|
48 |
/**
|
|
|
49 |
*
|
|
|
50 |
* @var AdapterInterface
|
|
|
51 |
*/
|
|
|
52 |
private $adapter;
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
*
|
|
|
57 |
* @var AbstractAdapter
|
|
|
58 |
*/
|
|
|
59 |
private $cache;
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
*
|
|
|
63 |
* @var LoggerInterface
|
|
|
64 |
*/
|
|
|
65 |
private $logger;
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
*
|
|
|
70 |
* @param AdapterInterface $adapter
|
|
|
71 |
* @param AbstractAdapter $cache
|
|
|
72 |
* @param LoggerInterface $logger
|
|
|
73 |
* @param array $config
|
|
|
74 |
*/
|
|
|
75 |
public function __construct($adapter, $cache , $logger, $config)
|
|
|
76 |
{
|
|
|
77 |
$this->adapter = $adapter;
|
|
|
78 |
$this->cache = $cache;
|
|
|
79 |
$this->logger = $logger;
|
|
|
80 |
$this->config = $config;
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
}
|
|
|
84 |
|
2 |
efrain |
85 |
|
|
|
86 |
public function indexAction()
|
|
|
87 |
{
|
|
|
88 |
|
|
|
89 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
90 |
$viewModel = new ViewModel();
|
|
|
91 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/index.phtml');
|
|
|
92 |
return $viewModel ;
|
|
|
93 |
}
|
|
|
94 |
|
1 |
www |
95 |
|
|
|
96 |
public function overviewAction()
|
|
|
97 |
{
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
101 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
102 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
$request = $this->getRequest();
|
|
|
106 |
if($request->isGet()) {
|
|
|
107 |
$reportsLastWeek = [];
|
|
|
108 |
$reportsCapsuleResume = [];
|
|
|
109 |
$reportsStudentsTotal = [];
|
|
|
110 |
|
|
|
111 |
$companyMicrolearningExtendUserCompanyMapper = CompanyMicrolearningExtendUserCompanyMapper::getInstance($this->adapter);
|
|
|
112 |
$extendCompanies = $companyMicrolearningExtendUserCompanyMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
113 |
|
|
|
114 |
foreach($extendCompanies as $extendCompany)
|
|
|
115 |
{
|
|
|
116 |
$reportsLastWeek['companies'][$extendCompany->id] = [
|
|
|
117 |
'name' => $extendCompany->name,
|
|
|
118 |
'total' => 0,
|
|
|
119 |
'value' => 0
|
|
|
120 |
] ;
|
|
|
121 |
|
|
|
122 |
$reportsCapsuleResume['companies'][$extendCompany->id] = [
|
|
|
123 |
'name' => $extendCompany->name,
|
|
|
124 |
'total' => 0,
|
|
|
125 |
'value' => 0
|
|
|
126 |
] ;
|
|
|
127 |
|
|
|
128 |
$reportsStudentsTotal['companies'][$extendCompany->id] = [
|
|
|
129 |
'name' => $extendCompany->name,
|
|
|
130 |
'total' => 0,
|
|
|
131 |
] ;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
$companyMicrolearningExtendUserFunctionMapper = CompanyMicrolearningExtendUserFunctionMapper::getInstance($this->adapter);
|
|
|
136 |
$extendFunctions = $companyMicrolearningExtendUserFunctionMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
137 |
|
|
|
138 |
foreach($extendFunctions as $extendFunction)
|
|
|
139 |
{
|
|
|
140 |
$reportsLastWeek['functions'][$extendFunction->id] = [
|
|
|
141 |
'name' => $extendFunction->name,
|
|
|
142 |
'total' => 0,
|
|
|
143 |
'value' => 0
|
|
|
144 |
] ;
|
|
|
145 |
|
|
|
146 |
$reportsCapsuleResume['functions'][$extendFunction->id] = [
|
|
|
147 |
'name' => $extendFunction->name,
|
|
|
148 |
'total' => 0,
|
|
|
149 |
'value' => 0
|
|
|
150 |
] ;
|
|
|
151 |
|
|
|
152 |
$reportsStudentsTotal['functions'][$extendFunction->id] = [
|
|
|
153 |
'name' => $extendFunction->name,
|
|
|
154 |
'total' => 0,
|
|
|
155 |
] ;
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
$companyMicrolearningExtendUserGroupMapper = CompanyMicrolearningExtendUserGroupMapper::getInstance($this->adapter);
|
|
|
159 |
$extendGroups = $companyMicrolearningExtendUserGroupMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
160 |
|
|
|
161 |
foreach($extendGroups as $extendGroup)
|
|
|
162 |
{
|
|
|
163 |
$reportsLastWeek['groups'][$extendGroup->id] = [
|
|
|
164 |
'name' => $extendGroup->name,
|
|
|
165 |
'total' => 0,
|
|
|
166 |
'value' => 0
|
|
|
167 |
];
|
|
|
168 |
|
|
|
169 |
$reportsCapsuleResume['groups'][$extendGroup->id] = [
|
|
|
170 |
'name' => $extendFunction->name,
|
|
|
171 |
'total' => 0,
|
|
|
172 |
'value' => 0
|
|
|
173 |
] ;
|
|
|
174 |
|
|
|
175 |
$reportsStudentsTotal['groups'][$extendGroup->id] = [
|
|
|
176 |
'name' => $extendGroup->name,
|
|
|
177 |
'total' => 0,
|
|
|
178 |
];
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
$companyMicrolearningExtendUserInstitutionMapper = CompanyMicrolearningExtendUserInstitutionMapper::getInstance($this->adapter);
|
|
|
185 |
$extendInstitutions = $companyMicrolearningExtendUserInstitutionMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
186 |
|
|
|
187 |
foreach($extendInstitutions as $extendInstitution)
|
|
|
188 |
{
|
|
|
189 |
$reportsLastWeek['institutions'][$extendInstitution->id] = [
|
|
|
190 |
'name' => $extendInstitution->name,
|
|
|
191 |
'total' => 0,
|
|
|
192 |
'value' => 0
|
|
|
193 |
] ;
|
|
|
194 |
|
|
|
195 |
$reportsCapsuleResume['institutions'][$extendInstitution->id] = [
|
|
|
196 |
'name' => $extendInstitution->name,
|
|
|
197 |
'total' => 0,
|
|
|
198 |
'value' => 0
|
|
|
199 |
] ;
|
|
|
200 |
|
|
|
201 |
$reportsStudentsTotal['institutions'][$extendInstitution->id] = [
|
|
|
202 |
'name' => $extendInstitution->name,
|
|
|
203 |
'total' => 0,
|
|
|
204 |
] ;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
$companyMicrolearningExtendUserProgramMapper = CompanyMicrolearningExtendUserProgramMapper::getInstance($this->adapter);
|
|
|
209 |
$extendPrograms = $companyMicrolearningExtendUserProgramMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
210 |
|
|
|
211 |
foreach($extendPrograms as $extendProgram)
|
|
|
212 |
{
|
|
|
213 |
$reportsLastWeek['programs'][$extendProgram->id] = [
|
|
|
214 |
'name' => $extendProgram->name,
|
|
|
215 |
'total' => 0,
|
|
|
216 |
'value' => 0
|
|
|
217 |
] ;
|
|
|
218 |
|
|
|
219 |
$reportsCapsuleResume['programs'][$extendProgram->id] = [
|
|
|
220 |
'name' => $extendProgram->name,
|
|
|
221 |
'total' => 0,
|
|
|
222 |
'value' => 0
|
|
|
223 |
] ;
|
|
|
224 |
|
|
|
225 |
$reportsStudentsTotal['programs'][$extendProgram->id] = [
|
|
|
226 |
'name' => $extendProgram->name,
|
|
|
227 |
'total' => 0,
|
|
|
228 |
|
|
|
229 |
] ;
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
$companyMicrolearningExtendUserPartnerMapper = CompanyMicrolearningExtendUserPartnerMapper::getInstance($this->adapter);
|
|
|
234 |
$extendPartners = $companyMicrolearningExtendUserPartnerMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
235 |
|
|
|
236 |
foreach($extendPartners as $extendPartner)
|
|
|
237 |
{
|
|
|
238 |
$reportsLastWeek['partners'][$extendPartner->id] = [
|
|
|
239 |
'name' => $extendPartner->name,
|
|
|
240 |
'total' => 0,
|
|
|
241 |
'value' => 0
|
|
|
242 |
] ;
|
|
|
243 |
|
|
|
244 |
$reportsCapsuleResume['partners'][$extendPartner->id] = [
|
|
|
245 |
'name' => $extendPartner->name,
|
|
|
246 |
'total' => 0,
|
|
|
247 |
'value' => 0
|
|
|
248 |
] ;
|
|
|
249 |
|
|
|
250 |
$reportsStudentsTotal['partners'][$extendPartner->id] = [
|
|
|
251 |
'name' => $extendPartner->name,
|
|
|
252 |
'total' => 0,
|
|
|
253 |
] ;
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
$companyMicrolearningExtendUserSectorMapper = CompanyMicrolearningExtendUserSectorMapper::getInstance($this->adapter);
|
|
|
258 |
$extendSectors = $companyMicrolearningExtendUserSectorMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
259 |
|
|
|
260 |
foreach($extendSectors as $extendSector)
|
|
|
261 |
{
|
|
|
262 |
$reportsLastWeek['sectors'][$extendSector->id] = [
|
|
|
263 |
'name' => $extendSector->name,
|
|
|
264 |
'total' => 0,
|
|
|
265 |
'value' => 0
|
|
|
266 |
] ;
|
|
|
267 |
|
|
|
268 |
$reportsCapsuleResume['sectors'][$extendSector->id] = [
|
|
|
269 |
'name' => $extendSector->name,
|
|
|
270 |
'total' => 0,
|
|
|
271 |
'value' => 0
|
|
|
272 |
] ;
|
|
|
273 |
|
|
|
274 |
$reportsStudentsTotal['sectors'][$extendSector->id] = [
|
|
|
275 |
'name' => $extendSector->name,
|
|
|
276 |
'total' => 0,
|
|
|
277 |
] ;
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
$companyMicrolearningExtendUserStudentTypeMapper = CompanyMicrolearningExtendUserStudentTypeMapper::getInstance($this->adapter);
|
|
|
281 |
$extendStudentTypes = $companyMicrolearningExtendUserStudentTypeMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
282 |
|
|
|
283 |
foreach($extendStudentTypes as $extendStudentType)
|
|
|
284 |
{
|
|
|
285 |
$reportsLastWeek['student_types'][$extendStudentType->id] = [
|
|
|
286 |
'name' => $extendStudentType->name,
|
|
|
287 |
'total' => 0,
|
|
|
288 |
'value' => 0
|
|
|
289 |
] ;
|
|
|
290 |
|
|
|
291 |
$reportsCapsuleResume['student_types'][$extendStudentType->id] = [
|
|
|
292 |
'name' => $extendStudentType->name,
|
|
|
293 |
'total' => 0,
|
|
|
294 |
'value' => 0
|
|
|
295 |
] ;
|
|
|
296 |
|
|
|
297 |
$reportsStudentsTotal['student_types'][$extendStudentType->id] = [
|
|
|
298 |
'name' => $extendStudentType->name,
|
|
|
299 |
'total' => 0,
|
|
|
300 |
] ;
|
|
|
301 |
}
|
|
|
302 |
|
|
|
303 |
$companyMicrolearningUserProgressMapper = CompanyMicrolearningUserProgressMapper::getInstance($this->adapter);
|
|
|
304 |
|
|
|
305 |
$minLastWeek = date('Y-m-d', strtotime(' -180 days'));
|
|
|
306 |
$maxLastWeek = date('Y-m-d');
|
|
|
307 |
$companyMicrolearningUserLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
|
|
|
308 |
$companyUsersLogWithActivityLastWeek = $companyMicrolearningUserLogMapper->fetchAllUserIdsLastWeekByCompanyId($currentCompany->id, $minLastWeek, $maxLastWeek);
|
|
|
309 |
|
|
|
310 |
//header('Content-type: text/plain');
|
|
|
311 |
// print_r($companyUsersLogWithActivityLastWeek);
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
$date = date('Y-m-d');
|
|
|
317 |
|
|
|
318 |
$companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
|
|
|
319 |
$user_ids = $companyMicrolearningCapsuleUserMapper->fetchAllDistinctUserIdActiveByCompanyIdAndDate($currentCompany->id, $date);
|
|
|
320 |
|
|
|
321 |
$studentsTotal = count($user_ids);
|
|
|
322 |
$studentsStarted = 0;
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
$userIdsWithAllCapsulesCompleted = [];
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
foreach($user_ids as $user_id)
|
|
|
329 |
{
|
|
|
330 |
$countSlides = $companyMicrolearningUserProgressMapper->fetchCountAllSlideCompletedByCompanyIdAndUserId($currentCompany->id, $user_id);
|
|
|
331 |
if($countSlides) {
|
|
|
332 |
$studentsStarted++;
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
$incompleted = false;
|
|
|
336 |
|
|
|
337 |
$capsuleUsers = $companyMicrolearningCapsuleUserMapper->fetchAllActiveByUserId($user_id);
|
|
|
338 |
foreach($capsuleUsers as $capsuleUser)
|
|
|
339 |
{
|
|
|
340 |
$userProgress = $companyMicrolearningUserProgressMapper->fetchOneByUseridAndCapsuleId($capsuleUser->user_id, $capsuleUser->capsule_id);
|
|
|
341 |
if($userProgress) {
|
|
|
342 |
if(!$userProgress->completed) {
|
|
|
343 |
$incompleted = true;
|
|
|
344 |
break;
|
|
|
345 |
}
|
|
|
346 |
} else {
|
|
|
347 |
$incompleted = true;
|
|
|
348 |
break;
|
|
|
349 |
}
|
|
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
if(!$incompleted) {
|
|
|
356 |
array_push($userIdsWithAllCapsulesCompleted, $user_id);
|
|
|
357 |
}
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
$studentsWithoutStarting = $studentsTotal - $studentsStarted;
|
|
|
362 |
$reportsLastWeek['general'] = ['total' => $studentsTotal, 'value' => count($companyUsersLogWithActivityLastWeek) ];
|
|
|
363 |
|
|
|
364 |
$reportsCapsuleResume['general'] = ['total' => $studentsTotal, 'value' => count($userIdsWithAllCapsulesCompleted) ];
|
|
|
365 |
|
|
|
366 |
|
|
|
367 |
$companyMicrolearningExtendUserMapper = CompanyMicrolearningExtendUserMapper::getInstance($this->adapter);
|
|
|
368 |
$records = $companyMicrolearningExtendUserMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
369 |
foreach($records as $record)
|
|
|
370 |
{
|
|
|
371 |
|
|
|
372 |
if($record->extend_company_id) {
|
|
|
373 |
$reportsLastWeek['companies'][$record->extend_company_id]['total'] += 1;
|
|
|
374 |
$reportsStudentsTotal['companies'][$record->extend_company_id]['total'] += 1;
|
|
|
375 |
|
|
|
376 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
377 |
$reportsLastWeek['companies'][$record->extend_company_id]['value'] += 1;
|
|
|
378 |
}
|
|
|
379 |
|
|
|
380 |
$reportsCapsuleResume['companies'][$record->extend_company_id]['total'] += 1;
|
|
|
381 |
|
|
|
382 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
383 |
$reportsCapsuleResume['companies'][$record->extend_company_id]['value'] += 1;
|
|
|
384 |
}
|
|
|
385 |
|
|
|
386 |
}
|
|
|
387 |
|
|
|
388 |
if($record->extend_function_id) {
|
|
|
389 |
$reportsLastWeek['functions'][$record->extend_function_id]['total'] += 1;
|
|
|
390 |
$reportsStudentsTotal['functions'][$record->extend_function_id]['total'] += 1;
|
|
|
391 |
|
|
|
392 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
393 |
$reportsLastWeek['functions'][$record->extend_function_id]['value'] += 1;
|
|
|
394 |
}
|
|
|
395 |
|
|
|
396 |
$reportsCapsuleResume['functions'][$record->extend_function_id]['total'] += 1;
|
|
|
397 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
398 |
$reportsCapsuleResume['functions'][$record->extend_function_id]['value'] += 1;
|
|
|
399 |
}
|
|
|
400 |
}
|
|
|
401 |
|
|
|
402 |
if($record->extend_group_id) {
|
|
|
403 |
$reportsLastWeek['groups'][$record->extend_group_id]['total'] += 1;
|
|
|
404 |
$reportsStudentsTotal['groups'][$record->extend_group_id]['total'] += 1;
|
|
|
405 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
406 |
$reportsLastWeek['groups'][$record->extend_group_id]['value'] += 1;
|
|
|
407 |
}
|
|
|
408 |
|
|
|
409 |
$reportsCapsuleResume['groups'][$record->extend_group_id]['total'] += 1;
|
|
|
410 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
411 |
$reportsCapsuleResume['groups'][$record->extend_group_id]['value'] += 1;
|
|
|
412 |
}
|
|
|
413 |
}
|
|
|
414 |
|
|
|
415 |
if($record->extend_institution_id) {
|
|
|
416 |
$reportsLastWeek['institutions'][$record->extend_institution_id]['total'] += 1;
|
|
|
417 |
$reportsStudentsTotal['institutions'][$record->extend_institution_id]['total'] += 1;
|
|
|
418 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
419 |
$reportsLastWeek['institutions'][$record->extend_institution_id]['value'] += 1;
|
|
|
420 |
}
|
|
|
421 |
|
|
|
422 |
$reportsCapsuleResume['institutions'][$record->extend_institution_id]['total'] += 1;
|
|
|
423 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
424 |
$reportsCapsuleResume['institutions'][$record->extend_institution_id]['value'] += 1;
|
|
|
425 |
}
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
if($record->extend_program_id) {
|
|
|
429 |
$reportsLastWeek['programs'][$record->extend_program_id]['total'] += 1;
|
|
|
430 |
$reportsStudentsTotal['programs'][$record->extend_program_id]['total'] += 1;
|
|
|
431 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
432 |
$reportsLastWeek['programs'][$record->extend_program_id]['value'] += 1;
|
|
|
433 |
}
|
|
|
434 |
|
|
|
435 |
$reportsCapsuleResume['programs'][$record->extend_program_id]['total'] += 1;
|
|
|
436 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
437 |
$reportsCapsuleResume['programs'][$record->extend_program_id]['value'] += 1;
|
|
|
438 |
}
|
|
|
439 |
}
|
|
|
440 |
|
|
|
441 |
if($record->extend_partner_id) {
|
|
|
442 |
$reportsLastWeek['partners'][$record->extend_partner_id]['total'] += 1;
|
|
|
443 |
$reportsStudentsTotal['partners'][$record->extend_partner_id]['total'] += 1;
|
|
|
444 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
445 |
$reportsLastWeek['partners'][$record->extend_partner_id]['value'] += 1;
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
$reportsCapsuleResume['partners'][$record->extend_partner_id]['total'] += 1;
|
|
|
449 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
450 |
$reportsCapsuleResume['partners'][$record->extend_partner_id]['value'] += 1;
|
|
|
451 |
}
|
|
|
452 |
}
|
|
|
453 |
|
|
|
454 |
if($record->extend_sector_id) {
|
|
|
455 |
$reportsLastWeek['sectors'][$record->extend_sector_id]['total'] += 1;
|
|
|
456 |
$reportsStudentsTotal['sectors'][$record->extend_sector_id]['total'] += 1;
|
|
|
457 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
458 |
$reportsLastWeek['sectors'][$record->extend_sector_id]['value'] += 1;
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
$reportsCapsuleResume['sectors'][$record->extend_sector_id]['total'] += 1;
|
|
|
462 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
463 |
$reportsCapsuleResume['sectors'][$record->extend_sector_id]['value'] += 1;
|
|
|
464 |
}
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
if($record->extend_student_type_id) {
|
|
|
468 |
$reportsLastWeek['student_types'][$record->extend_student_type_id]['total'] += 1;
|
|
|
469 |
$reportsStudentsTotal['student_types'][$record->extend_student_type_id]['total'] += 1;
|
|
|
470 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
471 |
$reportsLastWeek['student_types'][$record->extend_student_type_id]['value'] += 1;
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
$reportsCapsuleResume['student_types'][$record->extend_student_type_id]['total'] += 1;
|
|
|
475 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
476 |
$reportsCapsuleResume['student_types'][$record->extend_student_type_id]['value'] += 1;
|
|
|
477 |
}
|
|
|
478 |
}
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
|
|
|
482 |
/*
|
|
|
483 |
header('Content-type: text/plain');
|
|
|
484 |
print_r($reportsStudentsTotal); exit;
|
|
|
485 |
*/
|
|
|
486 |
|
|
|
487 |
|
|
|
488 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
489 |
$viewModel = new ViewModel();
|
|
|
490 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/overview.phtml');
|
|
|
491 |
$viewModel->setVariables([
|
|
|
492 |
'reportsLastWeek' => $reportsLastWeek,
|
|
|
493 |
'reportsCapsuleResume' => $reportsCapsuleResume,
|
|
|
494 |
'reportsStudentsTotal' => $reportsStudentsTotal,
|
|
|
495 |
'reportStudents' => [
|
|
|
496 |
'total' => $studentsTotal,
|
|
|
497 |
'started' => $studentsStarted,
|
|
|
498 |
'withoutStarting' => $studentsWithoutStarting,
|
|
|
499 |
]
|
|
|
500 |
|
|
|
501 |
]);
|
|
|
502 |
return $viewModel ;
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
return new JsonModel([
|
|
|
506 |
'success' => false,
|
|
|
507 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
508 |
]);
|
|
|
509 |
}
|
2126 |
efrain |
510 |
|
1 |
www |
511 |
|
187 |
efrain |
512 |
|
2 |
efrain |
513 |
public function progressAction()
|
1 |
www |
514 |
{
|
|
|
515 |
|
|
|
516 |
|
|
|
517 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
518 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
519 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
520 |
|
|
|
521 |
|
|
|
522 |
$request = $this->getRequest();
|
|
|
523 |
if($request->isGet()) {
|
|
|
524 |
|
|
|
525 |
|
|
|
526 |
$headers = $request->getHeaders();
|
|
|
527 |
|
|
|
528 |
$isJson = false;
|
|
|
529 |
if($headers->has('Accept')) {
|
|
|
530 |
$accept = $headers->get('Accept');
|
|
|
531 |
|
|
|
532 |
$prioritized = $accept->getPrioritized();
|
|
|
533 |
|
|
|
534 |
foreach($prioritized as $key => $value) {
|
|
|
535 |
$raw = trim($value->getRaw());
|
|
|
536 |
|
|
|
537 |
if(!$isJson) {
|
|
|
538 |
$isJson = strpos($raw, 'json');
|
|
|
539 |
}
|
|
|
540 |
|
|
|
541 |
}
|
|
|
542 |
}
|
|
|
543 |
|
187 |
efrain |
544 |
|
2126 |
efrain |
545 |
|
1 |
www |
546 |
if($isJson) {
|
483 |
efrain |
547 |
|
1 |
www |
548 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
549 |
|
187 |
efrain |
550 |
$selectUsers = $queryMapper->getSql()->select();
|
|
|
551 |
$selectUsers->columns(['user_id' => new Expression('DISTINCT(user_id)')]);
|
|
|
552 |
$selectUsers->from(CompanyMicrolearningCapsuleUserMapper::_TABLE);
|
|
|
553 |
$selectUsers->where->equalTo('company_id', $currentCompany->id);
|
1 |
www |
554 |
|
187 |
efrain |
555 |
|
1 |
www |
556 |
|
187 |
efrain |
557 |
|
|
|
558 |
|
1 |
www |
559 |
$select = $queryMapper->getSql()->select();
|
|
|
560 |
$select->columns(['id' , 'uuid', 'first_name', 'last_name', 'email']);
|
187 |
efrain |
561 |
$select->from([ 'u' => UserMapper::_TABLE]);
|
1 |
www |
562 |
|
|
|
563 |
|
|
|
564 |
|
187 |
efrain |
565 |
$select->where->in('u.id', $selectUsers);
|
483 |
efrain |
566 |
|
187 |
efrain |
567 |
$select->order(['u.first_name', 'u.last_name']);
|
|
|
568 |
|
|
|
569 |
// echo $select->getSqlString($this->adapter->platform); exit;
|
483 |
efrain |
570 |
|
187 |
efrain |
571 |
|
|
|
572 |
|
|
|
573 |
|
|
|
574 |
$companyMicrolearningProgressMapper = CompanyMicrolearningUserProgressMapper::getInstance($this->adapter);
|
|
|
575 |
$companyMicrolearningUserLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
|
|
|
576 |
|
|
|
577 |
$companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
|
|
|
578 |
|
|
|
579 |
// $companyMicrolearningSlideMapper = CompanyMicrolearningSlideMapper::getInstance($this->adapter);
|
|
|
580 |
|
|
|
581 |
|
|
|
582 |
|
|
|
583 |
$students = [];
|
|
|
584 |
|
1 |
www |
585 |
$records = $queryMapper->fetchAll($select);
|
187 |
efrain |
586 |
|
|
|
587 |
|
1 |
www |
588 |
foreach($records as $record)
|
|
|
589 |
{
|
187 |
efrain |
590 |
|
|
|
591 |
|
1 |
www |
592 |
$capsules = $companyMicrolearningCapsuleUserMapper->fetchAllActiveByUserId($record['id']);
|
187 |
efrain |
593 |
|
|
|
594 |
|
|
|
595 |
|
1 |
www |
596 |
$totalCapsules = count($capsules);
|
|
|
597 |
$totalCapsulesStarted = 0;
|
|
|
598 |
$totalCapsulesCompleted = 0;
|
|
|
599 |
|
|
|
600 |
|
187 |
efrain |
601 |
|
|
|
602 |
|
|
|
603 |
|
|
|
604 |
|
|
|
605 |
|
1 |
www |
606 |
foreach($capsules as $capsule)
|
|
|
607 |
{
|
|
|
608 |
$userProgress = $companyMicrolearningProgressMapper->fetchOneByUseridAndCapsuleId($capsule->user_id, $capsule->capsule_id);
|
187 |
efrain |
609 |
|
|
|
610 |
|
1 |
www |
611 |
if($userProgress) {
|
|
|
612 |
$totalCapsulesStarted++;
|
|
|
613 |
if($userProgress->completed) {
|
|
|
614 |
$totalCapsulesCompleted++;
|
187 |
efrain |
615 |
}
|
1 |
www |
616 |
}
|
187 |
efrain |
617 |
|
1 |
www |
618 |
|
|
|
619 |
|
|
|
620 |
}
|
|
|
621 |
|
187 |
efrain |
622 |
|
|
|
623 |
|
|
|
624 |
|
|
|
625 |
if($totalCapsulesCompleted > 0 && $totalCapsules > 0) {
|
|
|
626 |
$total_capsules_percentaje = intval ( ($totalCapsulesCompleted * 100 ) / $totalCapsules);
|
|
|
627 |
} else {
|
|
|
628 |
$total_capsules_percentaje = 0;
|
|
|
629 |
}
|
|
|
630 |
|
1 |
www |
631 |
|
187 |
efrain |
632 |
|
1 |
www |
633 |
$student = [
|
|
|
634 |
'uuid' => $record['uuid'],
|
|
|
635 |
'first_name' => $record['first_name'],
|
|
|
636 |
'last_name' => $record['last_name'],
|
187 |
efrain |
637 |
'email' => $record['email'],
|
|
|
638 |
|
1 |
www |
639 |
'total_capsules' => $totalCapsules,
|
187 |
efrain |
640 |
'total_capsules_incomplete' => ( $totalCapsules - $totalCapsulesCompleted ),
|
1 |
www |
641 |
'total_capsules_started' => $totalCapsulesStarted,
|
|
|
642 |
'total_capsules_completed' => $totalCapsulesCompleted,
|
187 |
efrain |
643 |
'total_capsules_percentaje' => $total_capsules_percentaje,
|
|
|
644 |
|
1 |
www |
645 |
'first_date' => '',
|
|
|
646 |
'first_time' => '',
|
|
|
647 |
'last_date' => '',
|
|
|
648 |
'last_time' => '',
|
|
|
649 |
];
|
187 |
efrain |
650 |
|
1 |
www |
651 |
$first_added_on = $companyMicrolearningUserLogMapper->fetchFirstDateByCompanyIdAndUserId($currentCompany->id, $record['id']);
|
|
|
652 |
if($first_added_on) {
|
|
|
653 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $first_added_on);
|
|
|
654 |
if($dt) {
|
|
|
655 |
$student['first_date'] = $dt->format('d/m/Y');
|
|
|
656 |
$student['first_time'] = $dt->format('h:i a');
|
|
|
657 |
}
|
|
|
658 |
}
|
|
|
659 |
|
|
|
660 |
$last_added_on = $companyMicrolearningUserLogMapper->fetchLastDateByCompanyIdAndUserId($currentCompany->id, $record['id']);
|
|
|
661 |
if($last_added_on) {
|
|
|
662 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $last_added_on);
|
|
|
663 |
if($dt) {
|
|
|
664 |
$student['last_date'] = $dt->format('d/m/Y');
|
|
|
665 |
$student['last_time'] = $dt->format('h:i a');
|
187 |
efrain |
666 |
}
|
1 |
www |
667 |
}
|
187 |
efrain |
668 |
|
1 |
www |
669 |
array_push($students, $student);
|
187 |
efrain |
670 |
|
1 |
www |
671 |
|
|
|
672 |
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
|
187 |
efrain |
676 |
//print_r($students);
|
1 |
www |
677 |
|
|
|
678 |
|
187 |
efrain |
679 |
|
1 |
www |
680 |
return new JsonModel([
|
187 |
efrain |
681 |
'success' => true,
|
1 |
www |
682 |
'data' => $students
|
|
|
683 |
|
187 |
efrain |
684 |
]);
|
1 |
www |
685 |
|
187 |
efrain |
686 |
} else {
|
1 |
www |
687 |
|
|
|
688 |
|
|
|
689 |
|
2126 |
efrain |
690 |
// $form = new ExtendUserMicrolearningForm($this->adapter, $currentCompany->id);
|
|
|
691 |
$form = new TopicCapsuleForm($this->adapter, $currentCompany->id, $topic_id = 0);
|
1 |
www |
692 |
|
|
|
693 |
|
|
|
694 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
695 |
$viewModel = new ViewModel();
|
483 |
efrain |
696 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/progress-for-capsule.phtml');
|
1 |
www |
697 |
$viewModel->setVariables([
|
|
|
698 |
'form' => $form
|
187 |
efrain |
699 |
]);
|
1 |
www |
700 |
return $viewModel ;
|
|
|
701 |
}
|
|
|
702 |
}
|
|
|
703 |
|
|
|
704 |
return new JsonModel([
|
|
|
705 |
'success' => false,
|
|
|
706 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
707 |
]);
|
|
|
708 |
}
|
2 |
efrain |
709 |
|
187 |
efrain |
710 |
|
2 |
efrain |
711 |
public function devicesAction()
|
|
|
712 |
{
|
|
|
713 |
|
|
|
714 |
|
|
|
715 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
716 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
717 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
718 |
|
|
|
719 |
|
|
|
720 |
$request = $this->getRequest();
|
|
|
721 |
if($request->isGet()) {
|
|
|
722 |
|
|
|
723 |
|
|
|
724 |
$headers = $request->getHeaders();
|
|
|
725 |
|
|
|
726 |
$isJson = false;
|
|
|
727 |
if($headers->has('Accept')) {
|
|
|
728 |
$accept = $headers->get('Accept');
|
|
|
729 |
|
|
|
730 |
$prioritized = $accept->getPrioritized();
|
|
|
731 |
|
|
|
732 |
foreach($prioritized as $key => $value) {
|
|
|
733 |
$raw = trim($value->getRaw());
|
|
|
734 |
|
|
|
735 |
if(!$isJson) {
|
|
|
736 |
$isJson = strpos($raw, 'json');
|
|
|
737 |
}
|
|
|
738 |
|
|
|
739 |
}
|
|
|
740 |
}
|
|
|
741 |
|
|
|
742 |
if($isJson) {
|
|
|
743 |
|
129 |
efrain |
744 |
|
|
|
745 |
$company_id = filter_var($this->params()->fromQuery('company_id', ''), FILTER_SANITIZE_STRING);
|
|
|
746 |
$function_id = filter_var($this->params()->fromQuery('function_id', ''), FILTER_SANITIZE_STRING);
|
|
|
747 |
$group_id = filter_var($this->params()->fromQuery('group_id', ''), FILTER_SANITIZE_STRING);
|
|
|
748 |
$institution_id = filter_var($this->params()->fromQuery('institution_id', ''), FILTER_SANITIZE_STRING);
|
|
|
749 |
$program_id = filter_var($this->params()->fromQuery('program_id', ''), FILTER_SANITIZE_STRING);
|
|
|
750 |
$partner_id = filter_var($this->params()->fromQuery('partner_id', ''), FILTER_SANITIZE_STRING);
|
|
|
751 |
$sector_id = filter_var($this->params()->fromQuery('sector_id', ''), FILTER_SANITIZE_STRING);
|
|
|
752 |
$student_type_id = filter_var($this->params()->fromQuery('student_type_id', ''), FILTER_SANITIZE_STRING);
|
|
|
753 |
|
|
|
754 |
|
|
|
755 |
if($company_id) {
|
|
|
756 |
$extendUserCompanyMapper = CompanyMicrolearningExtendUserCompanyMapper::getInstance($this->adapter);
|
|
|
757 |
$extendUserCompany = $extendUserCompanyMapper->fetchOneByUuid($company_id);
|
|
|
758 |
|
|
|
759 |
if($extendUserCompany) {
|
|
|
760 |
$company_id = $extendUserCompany->id;
|
|
|
761 |
} else {
|
|
|
762 |
$company_id = 0;
|
|
|
763 |
}
|
|
|
764 |
}
|
|
|
765 |
|
|
|
766 |
if($function_id) {
|
|
|
767 |
$extendUserFunctionMapper = CompanyMicrolearningExtendUserFunctionMapper::getInstance($this->adapter);
|
|
|
768 |
$extendUserFunction = $extendUserFunctionMapper->fetchOneByUuid($function_id);
|
|
|
769 |
|
|
|
770 |
if($extendUserFunction) {
|
|
|
771 |
$function_id = $extendUserFunction->id;
|
|
|
772 |
} else {
|
|
|
773 |
$function_id = 0;
|
|
|
774 |
}
|
|
|
775 |
}
|
|
|
776 |
|
|
|
777 |
if($group_id) {
|
|
|
778 |
$extendUserGroupMapper = CompanyMicrolearningExtendUserGroupMapper::getInstance($this->adapter);
|
|
|
779 |
$extendUserGroup = $extendUserGroupMapper->fetchOneByUuid($group_id);
|
|
|
780 |
|
|
|
781 |
if($extendUserGroup) {
|
|
|
782 |
$group_id = $extendUserGroup->id;
|
|
|
783 |
} else {
|
|
|
784 |
$group_id = 0;
|
|
|
785 |
}
|
|
|
786 |
}
|
|
|
787 |
|
|
|
788 |
if($institution_id) {
|
|
|
789 |
$extendUserInstitutionMapper = CompanyMicrolearningExtendUserInstitutionMapper::getInstance($this->adapter);
|
|
|
790 |
$extendUserInstitution = $extendUserInstitutionMapper->fetchOneByUuid($institution_id);
|
|
|
791 |
if($extendUserInstitution) {
|
|
|
792 |
$institution_id = $extendUserInstitution->id;
|
|
|
793 |
} else {
|
|
|
794 |
$institution_id = 0;
|
|
|
795 |
}
|
|
|
796 |
}
|
|
|
797 |
|
|
|
798 |
if($program_id) {
|
|
|
799 |
$extendUserProgramMapper = CompanyMicrolearningExtendUserProgramMapper::getInstance($this->adapter);
|
|
|
800 |
$extendUserProgram = $extendUserProgramMapper->fetchOneByUuid($program_id);
|
|
|
801 |
|
|
|
802 |
if($extendUserProgram) {
|
|
|
803 |
$program_id = $extendUserProgram->id;
|
|
|
804 |
} else {
|
|
|
805 |
$program_id = 0;
|
|
|
806 |
}
|
|
|
807 |
|
|
|
808 |
|
|
|
809 |
}
|
|
|
810 |
|
|
|
811 |
if($partner_id) {
|
|
|
812 |
$extendUserPartnerMapper = CompanyMicrolearningExtendUserPartnerMapper::getInstance($this->adapter);
|
|
|
813 |
$extendUserPartner = $extendUserPartnerMapper->fetchOneByUuid($partner_id);
|
|
|
814 |
if($extendUserPartner) {
|
|
|
815 |
$partner_id = $extendUserPartner;
|
|
|
816 |
} else {
|
|
|
817 |
$partner_id = 0;
|
|
|
818 |
}
|
|
|
819 |
}
|
|
|
820 |
|
|
|
821 |
if($sector_id) {
|
|
|
822 |
$extendUserSectorMapper = CompanyMicrolearningExtendUserSectorMapper::getInstance($this->adapter);
|
|
|
823 |
$extendUserSector = $extendUserSectorMapper->fetchOneByUuid($sector_id);
|
|
|
824 |
if($extendUserSector) {
|
|
|
825 |
$sector_id = $extendUserSector->id;
|
|
|
826 |
} else {
|
|
|
827 |
$sector_id = 0;
|
|
|
828 |
}
|
|
|
829 |
}
|
|
|
830 |
|
|
|
831 |
if($student_type_id) {
|
|
|
832 |
$extendUserStudentTypeMapper = CompanyMicrolearningExtendUserStudentTypeMapper::getInstance($this->adapter);
|
|
|
833 |
$extendUserStudentType = $extendUserStudentTypeMapper->fetchOneByUuid($student_type_id);
|
|
|
834 |
|
|
|
835 |
if($extendUserStudentType) {
|
|
|
836 |
$student_type_id = $extendUserStudentType->id;
|
|
|
837 |
} else {
|
|
|
838 |
$student_type_id = 0;
|
|
|
839 |
}
|
|
|
840 |
}
|
|
|
841 |
|
|
|
842 |
|
|
|
843 |
|
|
|
844 |
/*
|
|
|
845 |
echo 'company_id 1 = '. $company_id . PHP_EOL;
|
|
|
846 |
echo 'function_id 1 = '. $function_id . PHP_EOL;
|
|
|
847 |
echo 'group_id 1 = '. $group_id . PHP_EOL;
|
|
|
848 |
echo 'institution_id 1 = '. $institution_id . PHP_EOL;
|
|
|
849 |
echo 'program_id 1 = '. $program_id . PHP_EOL;
|
|
|
850 |
echo 'partner_id 1 = '. $partner_id . PHP_EOL;
|
|
|
851 |
echo 'sector_id 1 = '. $sector_id . PHP_EOL;
|
|
|
852 |
echo 'student_type_id 1 = '. $student_type_id . PHP_EOL;
|
|
|
853 |
exit;
|
|
|
854 |
*/
|
|
|
855 |
|
|
|
856 |
|
2 |
efrain |
857 |
$date = date('Y-m-d');
|
|
|
858 |
$deviceMapper = DeviceMapper::getInstance($this->adapter);
|
|
|
859 |
|
|
|
860 |
|
|
|
861 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
862 |
|
|
|
863 |
$selectCapsuleUser = $queryMapper->getSql()->select();
|
|
|
864 |
$selectCapsuleUser->columns(['user_id' => new Expression('DISTINCT(user_id)') ]);
|
|
|
865 |
$selectCapsuleUser->from(CompanyMicrolearningCapsuleUserMapper::_TABLE);
|
|
|
866 |
$selectCapsuleUser->where->equalTo('company_id', $currentCompany->id);
|
|
|
867 |
$selectCapsuleUser->where->nest->equalTo('access', CompanyMicrolearningCapsuleUser::ACCESS_UNLIMITED)->or->nest()
|
|
|
868 |
->equalTo('access', CompanyMicrolearningCapsuleUser::ACCESS_PAY_PERIOD)
|
|
|
869 |
->and->lessThanOrEqualTo(new Expression('DATE(paid_from)'), $date)
|
|
|
870 |
->and->greaterThanOrEqualTo(new Expression('DATE(paid_to)'), $date )->unnest()->unnest();
|
|
|
871 |
|
|
|
872 |
//echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
873 |
|
|
|
874 |
$select = $queryMapper->getSql()->select();
|
|
|
875 |
$select->columns(['id' , 'uuid', 'first_name', 'last_name', 'email']);
|
129 |
efrain |
876 |
$select->from([ 'u' => UserMapper::_TABLE]);
|
|
|
877 |
if( $company_id || $function_id || $group_id || $institution_id || $program_id || $partner_id || $sector_id || $student_type_id ) {
|
|
|
878 |
|
187 |
efrain |
879 |
$select->join(['e' => CompanyMicrolearningExtendUserMapper::_TABLE], 'e.user_id = u.id', []);
|
129 |
efrain |
880 |
|
|
|
881 |
}
|
2 |
efrain |
882 |
|
129 |
efrain |
883 |
$select->where->in('u.id', $selectCapsuleUser);
|
|
|
884 |
if($company_id) {
|
|
|
885 |
$select->where->equalTo('e.extend_company_id', $company_id);
|
|
|
886 |
}
|
2 |
efrain |
887 |
|
129 |
efrain |
888 |
if($function_id) {
|
|
|
889 |
$select->where->equalTo('e.extend_function_id', $function_id);
|
|
|
890 |
|
|
|
891 |
}
|
|
|
892 |
if($group_id) {
|
|
|
893 |
$select->where->equalTo('e.extend_group_id', $group_id);
|
|
|
894 |
}
|
2 |
efrain |
895 |
|
129 |
efrain |
896 |
if($institution_id) {
|
|
|
897 |
$select->where->equalTo('e.extend_institution_id', $institution_id);
|
|
|
898 |
}
|
|
|
899 |
|
|
|
900 |
if($program_id) {
|
|
|
901 |
$select->where->equalTo('e.extend_program_id', $program_id);
|
|
|
902 |
}
|
|
|
903 |
|
|
|
904 |
if($partner_id) {
|
|
|
905 |
$select->where->equalTo('e.extend_partner_id', $partner_id);
|
|
|
906 |
}
|
|
|
907 |
|
|
|
908 |
if($sector_id) {
|
|
|
909 |
$select->where->equalTo('e.extend_sector_id', $sector_id);
|
|
|
910 |
}
|
|
|
911 |
|
|
|
912 |
if($student_type_id) {
|
|
|
913 |
$select->where->equalTo('e.extend_student_type_id', $student_type_id);
|
|
|
914 |
}
|
|
|
915 |
$select->order(['u.first_name', 'u.last_name']);
|
|
|
916 |
|
|
|
917 |
|
|
|
918 |
|
2 |
efrain |
919 |
$students = [];
|
|
|
920 |
$records = $queryMapper->fetchAll($select);
|
|
|
921 |
foreach($records as $record)
|
|
|
922 |
{
|
|
|
923 |
|
|
|
924 |
|
|
|
925 |
$record_devices = $deviceMapper->fetchAllByUserId($record['id']);
|
|
|
926 |
|
|
|
927 |
$devices = [];
|
|
|
928 |
foreach($record_devices as $device)
|
|
|
929 |
{
|
|
|
930 |
/*if($device->application_id != Application::LEADERSLINKED) {
|
|
|
931 |
continue;
|
|
|
932 |
}*/
|
|
|
933 |
|
|
|
934 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $device->updated_on);
|
|
|
935 |
|
|
|
936 |
array_push($devices, [
|
|
|
937 |
'brand' => $device->brand,
|
|
|
938 |
'manufacturer' => $device->manufacturer,
|
|
|
939 |
'model' => $device->model,
|
|
|
940 |
'platform' => $device->platform,
|
|
|
941 |
'version' => $device->version,
|
|
|
942 |
'token' => $device->token ? 'LABEL_YES' : 'LABEL_NO',
|
|
|
943 |
'updated_on' => $dt->format('d/m/Y h:i a')
|
|
|
944 |
]);
|
|
|
945 |
}
|
|
|
946 |
|
187 |
efrain |
947 |
if(empty($devices)) {
|
|
|
948 |
continue;
|
|
|
949 |
|
|
|
950 |
}
|
|
|
951 |
|
2 |
efrain |
952 |
|
|
|
953 |
$student = [
|
|
|
954 |
'uuid' => $record['uuid'],
|
|
|
955 |
'first_name' => $record['first_name'],
|
|
|
956 |
'last_name' => $record['last_name'],
|
|
|
957 |
'email' => $record['email'],
|
|
|
958 |
'devices' => $devices
|
|
|
959 |
];
|
|
|
960 |
|
|
|
961 |
array_push($students, $student);
|
|
|
962 |
|
|
|
963 |
|
|
|
964 |
}
|
|
|
965 |
|
|
|
966 |
|
|
|
967 |
|
|
|
968 |
|
|
|
969 |
return new JsonModel([
|
|
|
970 |
'success' => true,
|
129 |
efrain |
971 |
'data' => $students,
|
|
|
972 |
'sql' => $select->getSqlString($this->adapter->platform),
|
2 |
efrain |
973 |
|
|
|
974 |
]);
|
|
|
975 |
|
|
|
976 |
} else {
|
|
|
977 |
|
|
|
978 |
|
|
|
979 |
|
|
|
980 |
$form = new ExtendUserMicrolearningForm($this->adapter, $currentCompany->id);
|
|
|
981 |
|
|
|
982 |
|
|
|
983 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
984 |
$viewModel = new ViewModel();
|
|
|
985 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/devices.phtml');
|
|
|
986 |
$viewModel->setVariables([
|
|
|
987 |
'form' => $form
|
|
|
988 |
]);
|
|
|
989 |
return $viewModel ;
|
|
|
990 |
}
|
|
|
991 |
}
|
|
|
992 |
|
|
|
993 |
return new JsonModel([
|
|
|
994 |
'success' => false,
|
|
|
995 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
996 |
]);
|
|
|
997 |
}
|
187 |
efrain |
998 |
|
|
|
999 |
|
|
|
1000 |
public function comentsForCapsulesAction()
|
|
|
1001 |
{
|
|
|
1002 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1003 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1004 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1005 |
|
|
|
1006 |
$request = $this->getRequest();
|
|
|
1007 |
|
|
|
1008 |
if($request->isGet())
|
|
|
1009 |
{
|
|
|
1010 |
|
|
|
1011 |
$headers = $request->getHeaders();
|
|
|
1012 |
|
|
|
1013 |
$isJson = false;
|
|
|
1014 |
if($headers->has('Accept')) {
|
|
|
1015 |
$accept = $headers->get('Accept');
|
|
|
1016 |
|
|
|
1017 |
$prioritized = $accept->getPrioritized();
|
|
|
1018 |
|
|
|
1019 |
foreach($prioritized as $key => $value) {
|
|
|
1020 |
$raw = trim($value->getRaw());
|
|
|
1021 |
|
|
|
1022 |
if(!$isJson) {
|
|
|
1023 |
$isJson = strpos($raw, 'json');
|
|
|
1024 |
}
|
|
|
1025 |
|
|
|
1026 |
}
|
|
|
1027 |
}
|
|
|
1028 |
|
|
|
1029 |
if($isJson) {
|
|
|
1030 |
$topic_uuid = filter_var($this->params()->fromQuery('topic_uuid'), FILTER_SANITIZE_STRING);
|
|
|
1031 |
$capsule_uuid = filter_var($this->params()->fromQuery('capsule_uuid'), FILTER_SANITIZE_STRING);
|
|
|
1032 |
|
|
|
1033 |
$data = [
|
|
|
1034 |
'items' => [] ,
|
|
|
1035 |
'total' => 0,
|
|
|
1036 |
|
|
|
1037 |
];
|
|
|
1038 |
|
|
|
1039 |
|
|
|
1040 |
if(!$topic_uuid) {
|
|
|
1041 |
return new JsonModel([
|
|
|
1042 |
'success' => true,
|
|
|
1043 |
'data' => $data
|
|
|
1044 |
]);
|
|
|
1045 |
|
|
|
1046 |
}
|
|
|
1047 |
|
|
|
1048 |
|
|
|
1049 |
$topicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
|
|
|
1050 |
$topic = $topicMapper->fetchOneByUuid($topic_uuid);
|
|
|
1051 |
if(!$topic) {
|
|
|
1052 |
return new JsonModel([
|
|
|
1053 |
'success' => true,
|
|
|
1054 |
'data' => 'ERROR_TOPIC_NOT_FOUND'
|
|
|
1055 |
]);
|
|
|
1056 |
}
|
|
|
1057 |
|
|
|
1058 |
if($topic->company_id != $currentCompany->id) {
|
|
|
1059 |
return new JsonModel([
|
|
|
1060 |
'success' => true,
|
|
|
1061 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1062 |
]);
|
|
|
1063 |
}
|
|
|
1064 |
|
|
|
1065 |
|
|
|
1066 |
|
|
|
1067 |
if(!$capsule_uuid) {
|
|
|
1068 |
$capsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
|
|
|
1069 |
$records = $capsuleMapper->fetchAllByCompanyIdAndTopicId($topic->company_id, $topic->id);
|
|
|
1070 |
|
|
|
1071 |
$capsules = [];
|
|
|
1072 |
foreach($records as $record)
|
|
|
1073 |
{
|
|
|
1074 |
if(!$capsule_uuid) {
|
|
|
1075 |
$capsule_uuid = $record->uuid;
|
|
|
1076 |
}
|
|
|
1077 |
|
|
|
1078 |
$capsules[ $record->uuid ] = $record->name;
|
|
|
1079 |
}
|
|
|
1080 |
|
|
|
1081 |
$data['capsules'] = $capsules;
|
|
|
1082 |
}
|
|
|
1083 |
|
|
|
1084 |
if(!$capsule_uuid) {
|
|
|
1085 |
return new JsonModel([
|
|
|
1086 |
'success' => true,
|
|
|
1087 |
'data' => $data
|
|
|
1088 |
]);
|
|
|
1089 |
|
|
|
1090 |
}
|
|
|
1091 |
|
|
|
1092 |
$capsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
|
|
|
1093 |
$capsule = $capsuleMapper->fetchOneByUuid($capsule_uuid);
|
|
|
1094 |
|
|
|
1095 |
|
|
|
1096 |
|
|
|
1097 |
if(!$capsule) {
|
|
|
1098 |
return new JsonModel([
|
|
|
1099 |
'success' => true,
|
|
|
1100 |
'data' => 'ERROR_CAPSULE_NOT_FOUND'
|
|
|
1101 |
]);
|
|
|
1102 |
}
|
|
|
1103 |
|
|
|
1104 |
if($capsule->topic_id != $topic->id) {
|
|
|
1105 |
return new JsonModel([
|
|
|
1106 |
'success' => true,
|
|
|
1107 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1108 |
]);
|
|
|
1109 |
}
|
|
|
1110 |
|
|
|
1111 |
|
|
|
1112 |
$search = $this->params()->fromQuery('search', []);
|
|
|
1113 |
$search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
|
|
|
1114 |
|
|
|
1115 |
$page = intval($this->params()->fromQuery('start', 1), 10);
|
|
|
1116 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
1117 |
$order = $this->params()->fromQuery('order', []);
|
|
|
1118 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
1119 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var( $order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
1120 |
|
|
|
1121 |
$fields = ['uuid', 'first_name', 'last_name', 'email', 'rating', 'comment', 'added_on'];
|
|
|
1122 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'added_on';
|
|
|
1123 |
|
|
|
1124 |
if(!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
1125 |
$order_direction = 'DESC';
|
|
|
1126 |
}
|
|
|
1127 |
|
|
|
1128 |
|
|
|
1129 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
1130 |
$sql = $queryMapper->getSql();
|
|
|
1131 |
$select = $sql->select();
|
|
|
1132 |
$select->columns(['access', 'paid_from', 'paid_to', 'added_on', 'updated_on']);
|
|
|
1133 |
$select->from(['tb1' => CompanyMicrolearningCapsuleCommentMapper::_TABLE] );
|
|
|
1134 |
$select->join(['tb2' => UserMapper::_TABLE], 'tb1.user_id = tb2.id', ['uuid', 'first_name', 'last_name', 'email']);
|
|
|
1135 |
$select->where->equalTo('tb1.company_id', $capsule->company_id);
|
|
|
1136 |
$select->where->equalTo('tb1.topic_id', $capsule->topic_id);
|
|
|
1137 |
$select->where->equalTo('tb1.capsule_id', $capsule->id);
|
|
|
1138 |
|
|
|
1139 |
if($search) {
|
|
|
1140 |
$select->where->nest()
|
|
|
1141 |
->like('first_name', '%' . $search . '%')
|
|
|
1142 |
->or->like('last_name', '%' . $search . '%')
|
|
|
1143 |
->or->like('email', '%' . $search . '%')
|
|
|
1144 |
->unnest();
|
|
|
1145 |
|
|
|
1146 |
}
|
|
|
1147 |
|
|
|
1148 |
|
|
|
1149 |
$select->order($order_field . ' ' . $order_direction);
|
|
|
1150 |
|
|
|
1151 |
$hydrator = new ArraySerializableHydrator();
|
|
|
1152 |
$resultset = new HydratingResultSet($hydrator);
|
|
|
1153 |
|
|
|
1154 |
$adapter = new DbSelect($select, $sql, $resultset);
|
|
|
1155 |
$paginator = new Paginator($adapter);
|
|
|
1156 |
$paginator->setItemCountPerPage($records_x_page);
|
|
|
1157 |
$paginator->setCurrentPageNumber($page);
|
|
|
1158 |
|
|
|
1159 |
|
|
|
1160 |
$items = [ ];
|
|
|
1161 |
$records = $paginator->getCurrentItems();
|
|
|
1162 |
foreach($records as $record)
|
|
|
1163 |
{
|
|
|
1164 |
|
|
|
1165 |
|
|
|
1166 |
|
|
|
1167 |
$dt_added_on = \DateTime::createFromFormat('Y-m-d H:i:s', $record['added_on']);
|
|
|
1168 |
$added_on = $dt_added_on->format('d/m/Y h:i a');
|
|
|
1169 |
|
|
|
1170 |
|
|
|
1171 |
$item = [
|
|
|
1172 |
'uuid' => $record['uuid'],
|
|
|
1173 |
'first_name' => $record['first_name'],
|
|
|
1174 |
'last_name' => $record['last_name'],
|
|
|
1175 |
'email' => $record['email'],
|
|
|
1176 |
'rating' => $record['rating'],
|
|
|
1177 |
'text' => $record['text'],
|
|
|
1178 |
'added_on' => $added_on,
|
|
|
1179 |
];
|
|
|
1180 |
|
|
|
1181 |
|
|
|
1182 |
array_push($items, $item);
|
|
|
1183 |
|
|
|
1184 |
|
|
|
1185 |
}
|
|
|
1186 |
|
|
|
1187 |
$data['items'] = $items;
|
|
|
1188 |
$data['total'] = $paginator->getTotalItemCount();
|
|
|
1189 |
|
|
|
1190 |
|
|
|
1191 |
return new JsonModel([
|
|
|
1192 |
'success' => true,
|
|
|
1193 |
'data' => $data
|
|
|
1194 |
]);
|
|
|
1195 |
} else {
|
|
|
1196 |
$topicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
|
|
|
1197 |
$topics = $topicMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
1198 |
|
|
|
1199 |
if($topics) {
|
|
|
1200 |
$topic_id = $topics[0]->id;
|
|
|
1201 |
} else {
|
|
|
1202 |
$topic_id = 0;
|
|
|
1203 |
}
|
|
|
1204 |
|
|
|
1205 |
|
|
|
1206 |
$form = new TopicCapsuleForm($this->adapter, $currentCompany->id, $topic_id);
|
|
|
1207 |
|
|
|
1208 |
|
|
|
1209 |
|
|
|
1210 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
1211 |
$viewModel = new ViewModel();
|
|
|
1212 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/comments-for-capsule.phtml');
|
|
|
1213 |
$viewModel->setVariables([
|
|
|
1214 |
'form' => $form,
|
|
|
1215 |
]);
|
|
|
1216 |
|
|
|
1217 |
return $viewModel ;
|
|
|
1218 |
}
|
|
|
1219 |
|
|
|
1220 |
} else {
|
|
|
1221 |
return new JsonModel([
|
|
|
1222 |
'success' => false,
|
|
|
1223 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1224 |
]);
|
|
|
1225 |
}
|
|
|
1226 |
}
|
|
|
1227 |
|
|
|
1228 |
|
|
|
1229 |
|
14612 |
efrain |
1230 |
public function progressForCapsuleAction()
|
483 |
efrain |
1231 |
{
|
|
|
1232 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1233 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1234 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
1235 |
|
|
|
1236 |
$request = $this->getRequest();
|
|
|
1237 |
|
|
|
1238 |
if($request->isGet())
|
|
|
1239 |
{
|
|
|
1240 |
|
|
|
1241 |
$headers = $request->getHeaders();
|
|
|
1242 |
|
|
|
1243 |
$isJson = false;
|
|
|
1244 |
if($headers->has('Accept')) {
|
|
|
1245 |
$accept = $headers->get('Accept');
|
|
|
1246 |
|
|
|
1247 |
$prioritized = $accept->getPrioritized();
|
|
|
1248 |
|
|
|
1249 |
foreach($prioritized as $key => $value) {
|
|
|
1250 |
$raw = trim($value->getRaw());
|
|
|
1251 |
|
|
|
1252 |
if(!$isJson) {
|
|
|
1253 |
$isJson = strpos($raw, 'json');
|
|
|
1254 |
}
|
|
|
1255 |
|
|
|
1256 |
}
|
|
|
1257 |
}
|
14612 |
efrain |
1258 |
|
|
|
1259 |
|
483 |
efrain |
1260 |
if($isJson) {
|
14612 |
efrain |
1261 |
|
|
|
1262 |
|
483 |
efrain |
1263 |
$topic_uuid = filter_var($this->params()->fromQuery('topic_uuid'), FILTER_SANITIZE_STRING);
|
|
|
1264 |
$capsule_uuid = filter_var($this->params()->fromQuery('capsule_uuid'), FILTER_SANITIZE_STRING);
|
|
|
1265 |
|
|
|
1266 |
$data = [
|
|
|
1267 |
];
|
|
|
1268 |
|
|
|
1269 |
|
|
|
1270 |
if(!$topic_uuid) {
|
|
|
1271 |
return new JsonModel([
|
|
|
1272 |
'success' => true,
|
|
|
1273 |
'data' => $data
|
|
|
1274 |
]);
|
|
|
1275 |
|
|
|
1276 |
}
|
|
|
1277 |
|
|
|
1278 |
|
|
|
1279 |
$topicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
|
|
|
1280 |
$topic = $topicMapper->fetchOneByUuid($topic_uuid);
|
|
|
1281 |
if(!$topic) {
|
|
|
1282 |
return new JsonModel([
|
|
|
1283 |
'success' => true,
|
|
|
1284 |
'data' => 'ERROR_TOPIC_NOT_FOUND'
|
|
|
1285 |
]);
|
|
|
1286 |
}
|
|
|
1287 |
|
|
|
1288 |
if($topic->company_id != $currentCompany->id) {
|
|
|
1289 |
return new JsonModel([
|
|
|
1290 |
'success' => true,
|
|
|
1291 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1292 |
]);
|
|
|
1293 |
}
|
|
|
1294 |
|
14612 |
efrain |
1295 |
|
483 |
efrain |
1296 |
|
|
|
1297 |
if(!$capsule_uuid) {
|
|
|
1298 |
$capsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
|
|
|
1299 |
$records = $capsuleMapper->fetchAllByCompanyIdAndTopicId($topic->company_id, $topic->id);
|
|
|
1300 |
|
|
|
1301 |
$capsules = [];
|
|
|
1302 |
foreach($records as $record)
|
|
|
1303 |
{
|
|
|
1304 |
if(!$capsule_uuid) {
|
|
|
1305 |
$capsule_uuid = $record->uuid;
|
|
|
1306 |
}
|
|
|
1307 |
|
|
|
1308 |
$capsules[ $record->uuid ] = $record->name;
|
|
|
1309 |
}
|
|
|
1310 |
|
|
|
1311 |
$data['capsules'] = $capsules;
|
|
|
1312 |
}
|
14612 |
efrain |
1313 |
|
|
|
1314 |
|
483 |
efrain |
1315 |
|
|
|
1316 |
$capsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
|
|
|
1317 |
$capsule = $capsuleMapper->fetchOneByUuid($capsule_uuid);
|
|
|
1318 |
|
|
|
1319 |
|
|
|
1320 |
|
|
|
1321 |
if(!$capsule) {
|
|
|
1322 |
return new JsonModel([
|
|
|
1323 |
'success' => true,
|
|
|
1324 |
'data' => 'ERROR_CAPSULE_NOT_FOUND'
|
|
|
1325 |
]);
|
|
|
1326 |
}
|
|
|
1327 |
|
|
|
1328 |
if($capsule->topic_id != $topic->id) {
|
|
|
1329 |
return new JsonModel([
|
|
|
1330 |
'success' => true,
|
|
|
1331 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
1332 |
]);
|
|
|
1333 |
}
|
|
|
1334 |
|
14612 |
efrain |
1335 |
|
483 |
efrain |
1336 |
|
|
|
1337 |
|
|
|
1338 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
1339 |
$sql = $queryMapper->getSql();
|
|
|
1340 |
$select = $sql->select();
|
14612 |
efrain |
1341 |
$select->columns(['progress', 'total_slides', 'view_slides', 'completed', 'returning_after_completed', 'added_on', 'updated_on']);
|
|
|
1342 |
$select->from(['tb1' => CompanyMicrolearningUserProgressMapper::_TABLE] );
|
483 |
efrain |
1343 |
$select->join(['tb2' => UserMapper::_TABLE], 'tb1.user_id = tb2.id', ['uuid', 'first_name', 'last_name', 'email']);
|
|
|
1344 |
$select->where->equalTo('tb1.company_id', $capsule->company_id);
|
14612 |
efrain |
1345 |
$select->where->equalTo('tb1.type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
483 |
efrain |
1346 |
$select->where->equalTo('tb1.topic_id', $capsule->topic_id);
|
|
|
1347 |
$select->where->equalTo('tb1.capsule_id', $capsule->id);
|
14612 |
efrain |
1348 |
$select->order('first_name ASC, last_name ASC');
|
483 |
efrain |
1349 |
|
14612 |
efrain |
1350 |
|
|
|
1351 |
|
|
|
1352 |
$items = [];
|
|
|
1353 |
$records = $queryMapper->fetchAll($select);
|
483 |
efrain |
1354 |
foreach($records as $record)
|
|
|
1355 |
{
|
|
|
1356 |
|
|
|
1357 |
|
|
|
1358 |
|
|
|
1359 |
$dt_added_on = \DateTime::createFromFormat('Y-m-d H:i:s', $record['added_on']);
|
|
|
1360 |
$added_on = $dt_added_on->format('d/m/Y h:i a');
|
|
|
1361 |
|
14612 |
efrain |
1362 |
$dt_updated_on = \DateTime::createFromFormat('Y-m-d H:i:s', $record['updated_on']);
|
|
|
1363 |
$updated_on = $dt_updated_on->format('d/m/Y h:i a');
|
483 |
efrain |
1364 |
|
14612 |
efrain |
1365 |
|
483 |
efrain |
1366 |
$item = [
|
|
|
1367 |
'uuid' => $record['uuid'],
|
|
|
1368 |
'first_name' => $record['first_name'],
|
|
|
1369 |
'last_name' => $record['last_name'],
|
|
|
1370 |
'email' => $record['email'],
|
14612 |
efrain |
1371 |
'completed' => $record['completed'],
|
|
|
1372 |
'progress' => $record['progress'],
|
|
|
1373 |
'total_slides' => $record['total_slides'],
|
|
|
1374 |
'view_slides' => $record['view_slides'],
|
|
|
1375 |
'returning_after_completed' => $record['returning_after_completed'],
|
483 |
efrain |
1376 |
'added_on' => $added_on,
|
14612 |
efrain |
1377 |
'updated_on' => $updated_on,
|
483 |
efrain |
1378 |
];
|
|
|
1379 |
|
|
|
1380 |
|
|
|
1381 |
array_push($items, $item);
|
|
|
1382 |
|
|
|
1383 |
|
|
|
1384 |
}
|
|
|
1385 |
|
|
|
1386 |
$data['items'] = $items;
|
14612 |
efrain |
1387 |
|
483 |
efrain |
1388 |
|
|
|
1389 |
|
|
|
1390 |
return new JsonModel([
|
|
|
1391 |
'success' => true,
|
|
|
1392 |
'data' => $data
|
|
|
1393 |
]);
|
|
|
1394 |
} else {
|
|
|
1395 |
$topicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
|
|
|
1396 |
$topics = $topicMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
1397 |
|
|
|
1398 |
if($topics) {
|
|
|
1399 |
$topic_id = $topics[0]->id;
|
|
|
1400 |
} else {
|
|
|
1401 |
$topic_id = 0;
|
|
|
1402 |
}
|
|
|
1403 |
|
|
|
1404 |
|
|
|
1405 |
$form = new TopicCapsuleForm($this->adapter, $currentCompany->id, $topic_id);
|
|
|
1406 |
|
|
|
1407 |
|
|
|
1408 |
|
|
|
1409 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
1410 |
$viewModel = new ViewModel();
|
14612 |
efrain |
1411 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/progress-for-capsule.phtml');
|
483 |
efrain |
1412 |
$viewModel->setVariables([
|
|
|
1413 |
'form' => $form,
|
|
|
1414 |
]);
|
|
|
1415 |
|
|
|
1416 |
return $viewModel ;
|
|
|
1417 |
}
|
|
|
1418 |
|
|
|
1419 |
} else {
|
|
|
1420 |
return new JsonModel([
|
|
|
1421 |
'success' => false,
|
|
|
1422 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1423 |
]);
|
|
|
1424 |
}
|
|
|
1425 |
}
|
|
|
1426 |
|
|
|
1427 |
|
|
|
1428 |
|
|
|
1429 |
|
1 |
www |
1430 |
|
|
|
1431 |
}
|