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