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