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;
|
|
|
8 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
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 |
*
|
|
|
70 |
* @var AbstractAdapter
|
|
|
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
|
|
|
84 |
* @param AbstractAdapter $cache
|
|
|
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 |
|
15551 |
anderson |
115 |
|
|
|
116 |
|
|
|
117 |
$search = $this->params()->fromQuery('search', []);
|
|
|
118 |
$search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
|
|
|
119 |
$blockUsers = intval($this->params()->fromQuery('start', 1), 10);
|
|
|
120 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
121 |
$order = $this->params()->fromQuery('order', []);
|
|
|
122 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
123 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
124 |
|
|
|
125 |
$fields = ['title'];
|
|
|
126 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'title';
|
|
|
127 |
|
|
|
128 |
if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
129 |
$order_direction = 'ASC';
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
15548 |
anderson |
144 |
$request = $this->getRequest();
|
15387 |
efrain |
145 |
|
15548 |
anderson |
146 |
if ($request->isGet()) {
|
15387 |
efrain |
147 |
|
15548 |
anderson |
148 |
$headers = $request->getHeaders();
|
15387 |
efrain |
149 |
|
15548 |
anderson |
150 |
$isJson = false;
|
|
|
151 |
if ($headers->has('Accept')) {
|
|
|
152 |
$accept = $headers->get('Accept');
|
15547 |
anderson |
153 |
|
15548 |
anderson |
154 |
$prioritized = $accept->getPrioritized();
|
15547 |
anderson |
155 |
|
15548 |
anderson |
156 |
foreach ($prioritized as $key => $value) {
|
|
|
157 |
$raw = trim($value->getRaw());
|
15547 |
anderson |
158 |
|
15548 |
anderson |
159 |
if (!$isJson) {
|
|
|
160 |
$isJson = strpos($raw, 'json');
|
|
|
161 |
}
|
|
|
162 |
}
|
|
|
163 |
}
|
15547 |
anderson |
164 |
|
|
|
165 |
|
15548 |
anderson |
166 |
if ($isJson) {
|
|
|
167 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
|
|
168 |
$allowDownload = $acl->isAllowed($currentUser->usertype_id, 'reports/users-blocked/excel');
|
15547 |
anderson |
169 |
|
|
|
170 |
|
15548 |
anderson |
171 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
15555 |
anderson |
172 |
//$paginator = $queryMapper->fetchAllDataTable($search, $currentUser->network_id, $blockUsers, $records_x_page, $order_field, $order_direction);
|
15547 |
anderson |
173 |
|
15548 |
anderson |
174 |
if ($currentCompany) {
|
15547 |
anderson |
175 |
|
15548 |
anderson |
176 |
$user_ids = [];
|
15547 |
anderson |
177 |
|
15548 |
anderson |
178 |
$select = $queryMapper->getSql()->select(CompanyUserMapper::_TABLE);
|
|
|
179 |
$select->columns(['user_id']);
|
|
|
180 |
$select->where->equalTo('company_id', $currentCompany->id);
|
|
|
181 |
$select->where->equalTo('status', CompanyUser::STATUS_ACCEPTED);
|
15547 |
anderson |
182 |
|
15548 |
anderson |
183 |
$records = $queryMapper->fetchAll($select);
|
|
|
184 |
foreach ($records as $record) {
|
|
|
185 |
if (!in_array($record['user_id'], $user_ids)) {
|
|
|
186 |
array_push($user_ids, $record['user_id']);
|
|
|
187 |
}
|
|
|
188 |
}
|
15547 |
anderson |
189 |
|
|
|
190 |
|
15548 |
anderson |
191 |
$select = $queryMapper->getSql()->select(CompanyMicrolearningCapsuleUserMapper::_TABLE);
|
|
|
192 |
$select->columns(['user_id']);
|
|
|
193 |
$select->where->equalTo('company_id', $currentCompany->id);
|
|
|
194 |
$select->where->in('access', [CompanyMicrolearningCapsuleUser::ACCESS_UNLIMITED, CompanyMicrolearningCapsuleUser::ACCESS_PAY_PERIOD]);
|
|
|
195 |
$records = $queryMapper->fetchAll($select);
|
|
|
196 |
foreach ($records as $record) {
|
|
|
197 |
if (!in_array($record['user_id'], $user_ids)) {
|
|
|
198 |
array_push($user_ids, $record['user_id']);
|
|
|
199 |
}
|
|
|
200 |
}
|
15547 |
anderson |
201 |
|
|
|
202 |
|
15548 |
anderson |
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->in('id', $user_ids);
|
|
|
210 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
211 |
$select->where->equalTo('blocked', User::BLOCKED_YES);
|
|
|
212 |
$select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
|
|
|
213 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
214 |
$select->where->in('usertype_id', [UserType::ADMIN, UserType::USER]);
|
|
|
215 |
$select->order('first_name ASC, last_name ASC');
|
|
|
216 |
} else {
|
|
|
217 |
$select = $queryMapper->getSql()->select(UserMapper::_TABLE);
|
|
|
218 |
$select->columns([
|
|
|
219 |
'id', 'uuid', 'first_name', 'last_name', 'email', 'last_activity_on', 'image',
|
|
|
220 |
'blocked', 'login_attempt', 'email_verified'
|
|
|
221 |
]);
|
15547 |
anderson |
222 |
|
15548 |
anderson |
223 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
224 |
$select->where->equalTo('blocked', User::BLOCKED_YES);
|
|
|
225 |
$select->where->equalTo('email_verified', User::EMAIL_VERIFIED_YES);
|
|
|
226 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
227 |
$select->where->in('usertype_id', [UserType::ADMIN, UserType::USER]);
|
|
|
228 |
$select->order('first_name ASC, last_name ASC');
|
|
|
229 |
}
|
15547 |
anderson |
230 |
|
15548 |
anderson |
231 |
$items = [];
|
15554 |
anderson |
232 |
$records = $queryMapper->fetchAll($select);
|
15547 |
anderson |
233 |
|
15548 |
anderson |
234 |
foreach ($records as $record) {
|
|
|
235 |
if ($record['last_activity_on']) {
|
15547 |
anderson |
236 |
|
15548 |
anderson |
237 |
$dt_last_activity_on = \DateTime::createFromFormat('Y-m-d H:i:s', $record['last_activity_on']);
|
|
|
238 |
$last_activity_on = $dt_last_activity_on->format('d/m/Y h:i a');
|
|
|
239 |
} else {
|
|
|
240 |
$last_activity_on = '';
|
|
|
241 |
}
|
15547 |
anderson |
242 |
|
15548 |
anderson |
243 |
$item = [
|
|
|
244 |
'uuid' => $record['uuid'],
|
|
|
245 |
'first_name' => ucwords(strtolower($record['first_name'])),
|
|
|
246 |
'last_name' => ucwords(strtolower($record['last_name'])),
|
|
|
247 |
'email' => strtolower($record['email']),
|
|
|
248 |
'last_activity_on' => $last_activity_on
|
15547 |
anderson |
249 |
|
15548 |
anderson |
250 |
];
|
15547 |
anderson |
251 |
|
15548 |
anderson |
252 |
array_push($items, $item);
|
|
|
253 |
}
|
15547 |
anderson |
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
15548 |
anderson |
258 |
$data = [
|
|
|
259 |
'items' => $items
|
15547 |
anderson |
260 |
|
15548 |
anderson |
261 |
];
|
15547 |
anderson |
262 |
|
15548 |
anderson |
263 |
if ($allowDownload) {
|
|
|
264 |
$data['link_download'] = $this->url()->fromRoute('reports/users-blocked/excel');
|
|
|
265 |
} else {
|
|
|
266 |
$data['link_download'] = '';
|
|
|
267 |
}
|
15547 |
anderson |
268 |
|
|
|
269 |
|
|
|
270 |
|
15548 |
anderson |
271 |
return new JsonModel([
|
|
|
272 |
'success' => true,
|
|
|
273 |
'data' => $data
|
|
|
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 |
}
|