15387 |
efrain |
1 |
<?php
|
15547 |
anderson |
2 |
|
15387 |
efrain |
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
16768 |
efrain |
8 |
|
15387 |
efrain |
9 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
10 |
use Laminas\Log\LoggerInterface;
|
|
|
11 |
use Laminas\View\Model\ViewModel;
|
|
|
12 |
use Laminas\View\Model\JsonModel;
|
|
|
13 |
use LeadersLinked\Form\ExtendUserMicrolearningForm;
|
|
|
14 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
15 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
16 |
use Laminas\Db\Sql\Expression;
|
|
|
17 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleUserMapper;
|
|
|
18 |
use LeadersLinked\Model\CompanyMicrolearningCapsuleUser;
|
|
|
19 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleMapper;
|
|
|
20 |
use LeadersLinked\Mapper\CompanyMicrolearningUserProgressMapper;
|
|
|
21 |
use LeadersLinked\Mapper\CompanyMicrolearningSlideMapper;
|
|
|
22 |
use LeadersLinked\Mapper\CompanyMicrolearningUserLogMapper;
|
|
|
23 |
use Google\Service\Classroom\Student;
|
|
|
24 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserCompanyMapper;
|
|
|
25 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserFunctionMapper;
|
|
|
26 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserGroupMapper;
|
|
|
27 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserInstitutionMapper;
|
|
|
28 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserProgramMapper;
|
|
|
29 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserPartnerMapper;
|
|
|
30 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserSectorMapper;
|
|
|
31 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserStudentTypeMapper;
|
|
|
32 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserMapper;
|
|
|
33 |
use LeadersLinked\Mapper\CompanyMicrolearningTopicMapper;
|
|
|
34 |
use LeadersLinked\Mapper\DeviceMapper;
|
|
|
35 |
use LeadersLinked\Model\Application;
|
|
|
36 |
use LeadersLinked\Mapper\CompanyMicrolearningUserMapper;
|
|
|
37 |
use LeadersLinked\Model\CompanyMicrolearningExtendUser;
|
|
|
38 |
use LeadersLinked\Form\TopicCapsuleForm;
|
|
|
39 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleCommentMapper;
|
|
|
40 |
use Laminas\Hydrator\ArraySerializableHydrator;
|
|
|
41 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
42 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
43 |
use Laminas\Paginator\Paginator;
|
|
|
44 |
use LeadersLinked\Model\CompanyMicrolearningUserProgress;
|
|
|
45 |
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
|
46 |
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
47 |
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
48 |
use PhpOffice\PhpSpreadsheet\Calculation\TextData\Replace;
|
|
|
49 |
use LeadersLinked\Form\TopicReportForm;
|
|
|
50 |
use LeadersLinked\Model\User;
|
|
|
51 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
|
|
52 |
use Laminas\Db\Sql\Select;
|
|
|
53 |
use LeadersLinked\Form\StudentReportForm;
|
|
|
54 |
use LeadersLinked\Model\UserType;
|
15388 |
efrain |
55 |
use LeadersLinked\Model\CompanyUser;
|
15387 |
efrain |
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
class ReportController extends AbstractActionController
|
|
|
60 |
{
|
|
|
61 |
/**
|
|
|
62 |
*
|
16769 |
efrain |
63 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
15387 |
efrain |
64 |
*/
|
|
|
65 |
private $adapter;
|
16768 |
efrain |
66 |
|
15387 |
efrain |
67 |
/**
|
|
|
68 |
*
|
16769 |
efrain |
69 |
* @var \LeadersLinked\Cache\CacheInterface
|
15387 |
efrain |
70 |
*/
|
16769 |
efrain |
71 |
private $cache;
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
/**
|
|
|
75 |
*
|
|
|
76 |
* @var \Laminas\Log\LoggerInterface
|
|
|
77 |
*/
|
16768 |
efrain |
78 |
private $logger;
|
|
|
79 |
|
15387 |
efrain |
80 |
/**
|
|
|
81 |
*
|
16768 |
efrain |
82 |
* @var array
|
15387 |
efrain |
83 |
*/
|
16768 |
efrain |
84 |
private $config;
|
|
|
85 |
|
16769 |
efrain |
86 |
|
15387 |
efrain |
87 |
/**
|
|
|
88 |
*
|
16769 |
efrain |
89 |
* @var \Laminas\Mvc\I18n\Translator
|
|
|
90 |
*/
|
|
|
91 |
private $translator;
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
*
|
|
|
96 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
97 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
98 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
15387 |
efrain |
99 |
* @param array $config
|
16769 |
efrain |
100 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
15387 |
efrain |
101 |
*/
|
16769 |
efrain |
102 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
15387 |
efrain |
103 |
{
|
16769 |
efrain |
104 |
$this->adapter = $adapter;
|
|
|
105 |
$this->cache = $cache;
|
|
|
106 |
$this->logger = $logger;
|
|
|
107 |
$this->config = $config;
|
|
|
108 |
$this->translator = $translator;
|
15387 |
efrain |
109 |
}
|
15547 |
anderson |
110 |
|
|
|
111 |
|
|
|
112 |
public function indexAction()
|
15387 |
efrain |
113 |
{
|
15547 |
anderson |
114 |
|
15387 |
efrain |
115 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
116 |
$viewModel = new ViewModel();
|
|
|
117 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/index.phtml');
|
15547 |
anderson |
118 |
return $viewModel;
|
15387 |
efrain |
119 |
}
|
15547 |
anderson |
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
15387 |
efrain |
124 |
public function usersBlockedAction()
|
|
|
125 |
{
|
15548 |
anderson |
126 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
127 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
128 |
$currentCompany = $currentUserPlugin->getCompany();
|
15387 |
efrain |
129 |
|
15548 |
anderson |
130 |
$request = $this->getRequest();
|
15387 |
efrain |
131 |
|
15548 |
anderson |
132 |
if ($request->isGet()) {
|
15387 |
efrain |
133 |
|
15548 |
anderson |
134 |
$headers = $request->getHeaders();
|
15387 |
efrain |
135 |
|
15548 |
anderson |
136 |
$isJson = false;
|
|
|
137 |
if ($headers->has('Accept')) {
|
|
|
138 |
$accept = $headers->get('Accept');
|
15547 |
anderson |
139 |
|
15548 |
anderson |
140 |
$prioritized = $accept->getPrioritized();
|
15547 |
anderson |
141 |
|
15548 |
anderson |
142 |
foreach ($prioritized as $key => $value) {
|
|
|
143 |
$raw = trim($value->getRaw());
|
15547 |
anderson |
144 |
|
15548 |
anderson |
145 |
if (!$isJson) {
|
|
|
146 |
$isJson = strpos($raw, 'json');
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
15547 |
anderson |
150 |
|
|
|
151 |
|
15548 |
anderson |
152 |
if ($isJson) {
|
|
|
153 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
16932 |
efrain |
154 |
$allowDownload = $acl->isAllowed($currentUser->usertype_id, 'reports/users-blocked/download');
|
16747 |
efrain |
155 |
//$allowEdit = $acl->isAllowed($currentUser->usertype_id, 'reports/users-blocked/edit');
|
|
|
156 |
//$allowDelete = $acl->isAllowed($currentUser->usertype_id, 'reports/users-blocked/delete');
|
15547 |
anderson |
157 |
|
15548 |
anderson |
158 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
15547 |
anderson |
159 |
|
15548 |
anderson |
160 |
if ($currentCompany) {
|
15547 |
anderson |
161 |
|
15548 |
anderson |
162 |
$user_ids = [];
|
15547 |
anderson |
163 |
|
15548 |
anderson |
164 |
$select = $queryMapper->getSql()->select(CompanyUserMapper::_TABLE);
|
|
|
165 |
$select->columns(['user_id']);
|
|
|
166 |
$select->where->equalTo('company_id', $currentCompany->id);
|
|
|
167 |
$select->where->equalTo('status', CompanyUser::STATUS_ACCEPTED);
|
15547 |
anderson |
168 |
|
15548 |
anderson |
169 |
$records = $queryMapper->fetchAll($select);
|
|
|
170 |
foreach ($records as $record) {
|
|
|
171 |
if (!in_array($record['user_id'], $user_ids)) {
|
|
|
172 |
array_push($user_ids, $record['user_id']);
|
|
|
173 |
}
|
|
|
174 |
}
|
15547 |
anderson |
175 |
|
|
|
176 |
|
15548 |
anderson |
177 |
$select = $queryMapper->getSql()->select(CompanyMicrolearningCapsuleUserMapper::_TABLE);
|
|
|
178 |
$select->columns(['user_id']);
|
|
|
179 |
$select->where->equalTo('company_id', $currentCompany->id);
|
|
|
180 |
$select->where->in('access', [CompanyMicrolearningCapsuleUser::ACCESS_UNLIMITED, CompanyMicrolearningCapsuleUser::ACCESS_PAY_PERIOD]);
|
|
|
181 |
$records = $queryMapper->fetchAll($select);
|
|
|
182 |
foreach ($records as $record) {
|
|
|
183 |
if (!in_array($record['user_id'], $user_ids)) {
|
|
|
184 |
array_push($user_ids, $record['user_id']);
|
|
|
185 |
}
|
|
|
186 |
}
|
15547 |
anderson |
187 |
|
|
|
188 |
|
15548 |
anderson |
189 |
$select = $queryMapper->getSql()->select(UserMapper::_TABLE);
|
|
|
190 |
$select->columns([
|
|
|
191 |
'id', 'uuid', 'first_name', 'last_name', 'email', 'last_activity_on', 'image',
|
|
|
192 |
'blocked', 'login_attempt', 'email_verified'
|
|
|
193 |
]);
|
15547 |
anderson |
194 |
|
15548 |
anderson |
195 |
$select->where->in('id', $user_ids);
|
|
|
196 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
197 |
$select->where->equalTo('blocked', User::BLOCKED_YES);
|
|
|
198 |
$select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
|
|
|
199 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
200 |
$select->where->in('usertype_id', [UserType::ADMIN, UserType::USER]);
|
|
|
201 |
$select->order('first_name ASC, last_name ASC');
|
|
|
202 |
} else {
|
|
|
203 |
$select = $queryMapper->getSql()->select(UserMapper::_TABLE);
|
|
|
204 |
$select->columns([
|
|
|
205 |
'id', 'uuid', 'first_name', 'last_name', 'email', 'last_activity_on', 'image',
|
|
|
206 |
'blocked', 'login_attempt', 'email_verified'
|
|
|
207 |
]);
|
15547 |
anderson |
208 |
|
15548 |
anderson |
209 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
210 |
$select->where->equalTo('blocked', User::BLOCKED_YES);
|
|
|
211 |
$select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
|
|
|
212 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
213 |
$select->where->in('usertype_id', [UserType::ADMIN, UserType::USER]);
|
|
|
214 |
$select->order('first_name ASC, last_name ASC');
|
|
|
215 |
}
|
15547 |
anderson |
216 |
|
15548 |
anderson |
217 |
$items = [];
|
15569 |
anderson |
218 |
$records = $queryMapper->fetchAll($select);
|
15547 |
anderson |
219 |
|
15565 |
anderson |
220 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
221 |
$page = (intval($this->params()->fromQuery('start', 1), 10) / $records_x_page) + 1;
|
15561 |
anderson |
222 |
|
15568 |
anderson |
223 |
$adapter = new DbSelect($select, $queryMapper->getSql());
|
15565 |
anderson |
224 |
$paginator = new Paginator($adapter);
|
|
|
225 |
$paginator->setItemCountPerPage($records_x_page);
|
|
|
226 |
$paginator->setCurrentPageNumber($page);
|
15561 |
anderson |
227 |
|
15548 |
anderson |
228 |
foreach ($records as $record) {
|
|
|
229 |
if ($record['last_activity_on']) {
|
15547 |
anderson |
230 |
|
15548 |
anderson |
231 |
$dt_last_activity_on = \DateTime::createFromFormat('Y-m-d H:i:s', $record['last_activity_on']);
|
|
|
232 |
$last_activity_on = $dt_last_activity_on->format('d/m/Y h:i a');
|
|
|
233 |
} else {
|
|
|
234 |
$last_activity_on = '';
|
|
|
235 |
}
|
15547 |
anderson |
236 |
|
15548 |
anderson |
237 |
$item = [
|
|
|
238 |
'uuid' => $record['uuid'],
|
|
|
239 |
'first_name' => ucwords(strtolower($record['first_name'])),
|
|
|
240 |
'last_name' => ucwords(strtolower($record['last_name'])),
|
|
|
241 |
'email' => strtolower($record['email']),
|
15598 |
anderson |
242 |
'last_activity_on' => $last_activity_on,
|
|
|
243 |
'actions' => [
|
16747 |
efrain |
244 |
// 'link_edit' => $allowEdit ? $this->url()->fromRoute('reports/users-blocked/edit', ['id' => $record['uuid']]) : '',
|
|
|
245 |
// 'link_delete' => $allowDelete ? $this->url()->fromRoute('reports/users-blocked/delete', ['id' => $record['uuid']]) : '',
|
15598 |
anderson |
246 |
]
|
15547 |
anderson |
247 |
|
15548 |
anderson |
248 |
];
|
15547 |
anderson |
249 |
|
15548 |
anderson |
250 |
array_push($items, $item);
|
|
|
251 |
}
|
15547 |
anderson |
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
15548 |
anderson |
256 |
$data = [
|
16932 |
efrain |
257 |
'items' => $items,
|
|
|
258 |
'total' => $paginator->getTotalItemCount(),
|
15547 |
anderson |
259 |
|
15548 |
anderson |
260 |
];
|
15547 |
anderson |
261 |
|
15548 |
anderson |
262 |
if ($allowDownload) {
|
16932 |
efrain |
263 |
$data['link_download'] = $this->url()->fromRoute('reports/users-blocked/download');
|
15548 |
anderson |
264 |
} else {
|
|
|
265 |
$data['link_download'] = '';
|
|
|
266 |
}
|
15547 |
anderson |
267 |
|
|
|
268 |
|
|
|
269 |
|
15548 |
anderson |
270 |
return new JsonModel([
|
|
|
271 |
'success' => true,
|
15562 |
anderson |
272 |
'data' => $data,
|
16932 |
efrain |
273 |
|
15548 |
anderson |
274 |
]);
|
|
|
275 |
} else {
|
15547 |
anderson |
276 |
|
15548 |
anderson |
277 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
278 |
$viewModel = new ViewModel();
|
|
|
279 |
$viewModel->setTemplate('leaders-linked/reports/users-blocked.phtml');
|
15547 |
anderson |
280 |
|
|
|
281 |
|
15548 |
anderson |
282 |
return $viewModel;
|
|
|
283 |
}
|
|
|
284 |
} else {
|
|
|
285 |
return new JsonModel([
|
|
|
286 |
'success' => false,
|
|
|
287 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
288 |
]);
|
|
|
289 |
}
|
15387 |
efrain |
290 |
}
|
15547 |
anderson |
291 |
|
15387 |
efrain |
292 |
public function usersBlockedExcelAction()
|
|
|
293 |
{
|
|
|
294 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
295 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
296 |
$currentCompany = $currentUserPlugin->getCompany();
|
15547 |
anderson |
297 |
|
15387 |
efrain |
298 |
$request = $this->getRequest();
|
15547 |
anderson |
299 |
|
|
|
300 |
if ($request->isGet()) {
|
|
|
301 |
|
15387 |
efrain |
302 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
15547 |
anderson |
303 |
|
|
|
304 |
if ($currentCompany) {
|
|
|
305 |
|
15388 |
efrain |
306 |
$user_ids = [];
|
15547 |
anderson |
307 |
|
15388 |
efrain |
308 |
$select = $queryMapper->getSql()->select(CompanyUserMapper::_TABLE);
|
|
|
309 |
$select->columns(['user_id']);
|
|
|
310 |
$select->where->equalTo('company_id', $currentCompany->id);
|
|
|
311 |
$select->where->equalTo('status', CompanyUser::STATUS_ACCEPTED);
|
15547 |
anderson |
312 |
|
15388 |
efrain |
313 |
$records = $queryMapper->fetchAll($select);
|
15547 |
anderson |
314 |
foreach ($records as $record) {
|
|
|
315 |
if (!in_array($record['user_id'], $user_ids)) {
|
|
|
316 |
array_push($user_ids, $record['user_id']);
|
15388 |
efrain |
317 |
}
|
|
|
318 |
}
|
15547 |
anderson |
319 |
|
|
|
320 |
|
15388 |
efrain |
321 |
$select = $queryMapper->getSql()->select(CompanyMicrolearningCapsuleUserMapper::_TABLE);
|
|
|
322 |
$select->columns(['user_id']);
|
|
|
323 |
$select->where->equalTo('company_id', $currentCompany->id);
|
|
|
324 |
$select->where->in('access', [CompanyMicrolearningCapsuleUser::ACCESS_UNLIMITED, CompanyMicrolearningCapsuleUser::ACCESS_PAY_PERIOD]);
|
|
|
325 |
$records = $queryMapper->fetchAll($select);
|
15547 |
anderson |
326 |
foreach ($records as $record) {
|
|
|
327 |
if (!in_array($record['user_id'], $user_ids)) {
|
|
|
328 |
array_push($user_ids, $record['user_id']);
|
15388 |
efrain |
329 |
}
|
|
|
330 |
}
|
15547 |
anderson |
331 |
|
|
|
332 |
|
15388 |
efrain |
333 |
$select = $queryMapper->getSql()->select(UserMapper::_TABLE);
|
|
|
334 |
$select->columns([
|
15387 |
efrain |
335 |
'id', 'uuid', 'first_name', 'last_name', 'email', 'last_activity_on', 'image',
|
|
|
336 |
'blocked', 'login_attempt', 'email_verified'
|
|
|
337 |
]);
|
15547 |
anderson |
338 |
|
15388 |
efrain |
339 |
$select->where->in('id', $user_ids);
|
|
|
340 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
341 |
$select->where->equalTo('blocked', User::BLOCKED_YES);
|
15547 |
anderson |
342 |
$select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
|
15388 |
efrain |
343 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
344 |
$select->where->in('usertype_id', [UserType::ADMIN, UserType::USER]);
|
15387 |
efrain |
345 |
$select->order('first_name ASC, last_name ASC');
|
|
|
346 |
} else {
|
|
|
347 |
$select = $queryMapper->getSql()->select(UserMapper::_TABLE);
|
15547 |
anderson |
348 |
$select->columns([
|
|
|
349 |
'id', 'uuid', 'first_name', 'last_name', 'email', 'last_activity_on', 'image',
|
|
|
350 |
'blocked', 'login_attempt', 'email_verified'
|
|
|
351 |
]);
|
|
|
352 |
|
15387 |
efrain |
353 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
354 |
$select->where->equalTo('blocked', User::BLOCKED_YES);
|
15547 |
anderson |
355 |
$select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
|
15387 |
efrain |
356 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
357 |
$select->where->in('usertype_id', [UserType::ADMIN, UserType::USER]);
|
|
|
358 |
$select->order('first_name ASC, last_name ASC');
|
|
|
359 |
}
|
15547 |
anderson |
360 |
|
15387 |
efrain |
361 |
$items = [];
|
|
|
362 |
$records = $queryMapper->fetchAll($select);
|
15547 |
anderson |
363 |
|
|
|
364 |
foreach ($records as $record) {
|
|
|
365 |
if ($record['last_activity_on']) {
|
|
|
366 |
|
15387 |
efrain |
367 |
$dt_last_activity_on = \DateTime::createFromFormat('Y-m-d H:i:s', $record['last_activity_on']);
|
|
|
368 |
$last_activity_on = $dt_last_activity_on->format('d/m/Y h:i a');
|
|
|
369 |
} else {
|
|
|
370 |
$last_activity_on = '';
|
|
|
371 |
}
|
15547 |
anderson |
372 |
|
15387 |
efrain |
373 |
$item = [
|
|
|
374 |
'uuid' => $record['uuid'],
|
|
|
375 |
'first_name' => $record['first_name'],
|
|
|
376 |
'last_name' => $record['last_name'],
|
|
|
377 |
'email' => $record['email'],
|
|
|
378 |
'last_activity_on' => $last_activity_on
|
15547 |
anderson |
379 |
|
15387 |
efrain |
380 |
];
|
15547 |
anderson |
381 |
|
15387 |
efrain |
382 |
array_push($items, $item);
|
|
|
383 |
}
|
15547 |
anderson |
384 |
|
15387 |
efrain |
385 |
$spreadsheet = new Spreadsheet();
|
|
|
386 |
$spreadsheet->getProperties()->setTitle("Usuarios Bloqueados");
|
15547 |
anderson |
387 |
|
|
|
388 |
|
|
|
389 |
|
15387 |
efrain |
390 |
$spreadsheet->setActiveSheetIndex(0);
|
|
|
391 |
$spreadsheet->getActiveSheet()->SetCellValue('A1', 'Fecha:');
|
|
|
392 |
$spreadsheet->getActiveSheet()->SetCellValue('B1', date('d/m/Y h:i a'));
|
|
|
393 |
|
15547 |
anderson |
394 |
|
|
|
395 |
|
15387 |
efrain |
396 |
$spreadsheet->getActiveSheet()->SetCellValue('A3', 'Nombre');
|
|
|
397 |
$spreadsheet->getActiveSheet()->SetCellValue('B3', 'Apellido');
|
|
|
398 |
$spreadsheet->getActiveSheet()->SetCellValue('C3', 'Correo electrónico');
|
|
|
399 |
$spreadsheet->getActiveSheet()->SetCellValue('D3', 'Ultima actividad');
|
|
|
400 |
|
|
|
401 |
|
15547 |
anderson |
402 |
|
15387 |
efrain |
403 |
$i = 4;
|
15547 |
anderson |
404 |
foreach ($records as $record) {
|
15387 |
efrain |
405 |
$spreadsheet->getActiveSheet()->SetCellValue('A' . $i, ucwords(strtolower(trim($record['first_name']))));
|
|
|
406 |
$spreadsheet->getActiveSheet()->SetCellValue('B' . $i, ucwords(strtolower(trim($record['last_name']))));
|
|
|
407 |
$spreadsheet->getActiveSheet()->SetCellValue('C' . $i, strtolower(trim($record['email'])));
|
|
|
408 |
$spreadsheet->getActiveSheet()->SetCellValue('D' . $i, $record['last_activity_on']);
|
|
|
409 |
|
|
|
410 |
$i++;
|
|
|
411 |
}
|
|
|
412 |
|
15547 |
anderson |
413 |
|
15387 |
efrain |
414 |
$fileName = 'reporte_usuarios_bloqueados_' . time() . '.xls';
|
15547 |
anderson |
415 |
|
15387 |
efrain |
416 |
$tempFilename = tempnam(sys_get_temp_dir(), 'reporte_usuarios_bloqueados_' . time());
|
15547 |
anderson |
417 |
|
|
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
|
15387 |
efrain |
422 |
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
|
|
|
423 |
$writer->save($tempFilename);
|
15547 |
anderson |
424 |
|
15387 |
efrain |
425 |
$content = file_get_contents($tempFilename);
|
|
|
426 |
@unlink($tempFilename);
|
15547 |
anderson |
427 |
|
15387 |
efrain |
428 |
return new JsonModel([
|
|
|
429 |
'success' => true,
|
|
|
430 |
'data' => [
|
|
|
431 |
'content' => base64_encode($content),
|
|
|
432 |
'basename' => $fileName
|
15547 |
anderson |
433 |
|
15387 |
efrain |
434 |
]
|
|
|
435 |
]);
|
|
|
436 |
} else {
|
|
|
437 |
return new JsonModel([
|
|
|
438 |
'success' => false,
|
|
|
439 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
440 |
]);
|
|
|
441 |
}
|
|
|
442 |
}
|
15547 |
anderson |
443 |
}
|