-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cria interface para verificar dados da LICC
- Loading branch information
1 parent
793e64d
commit 63a5c2a
Showing
5 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
namespace SettingsES; | ||
|
||
use DateTime; | ||
use MapasCulturais\App; | ||
use MapasCulturais\i; | ||
|
||
class Controller extends \MapasCulturais\Controllers\EntityController | ||
{ | ||
use \MapasCulturais\Traits\ControllerAPI; | ||
|
||
function __construct() | ||
{ | ||
} | ||
|
||
|
||
public function GET_liccSummary() | ||
{ | ||
$app = App::i(); | ||
|
||
$this->requireAuthentication(); | ||
|
||
if (!$app->user->is('admin')) { | ||
return; | ||
} | ||
|
||
$this->render('licc-summary', []); | ||
} | ||
|
||
|
||
public function POST_generateLiccSummary() | ||
{ | ||
$app = App::i(); | ||
|
||
$this->requireAuthentication(); | ||
|
||
if (!$app->user->is('admin')) { | ||
return; | ||
} | ||
|
||
$em = $app->em; | ||
$conn = $em->getConnection(); | ||
|
||
$request = $this->data; | ||
|
||
$errors = []; | ||
if (!isset($request['registrations']) || empty($request['registrations']) || $request['registrations'] == "") { | ||
$errors[] = "Informe o número de pelomenos uma inscrição"; | ||
} | ||
|
||
$delimiter = "\n"; | ||
if (strpos($request['registrations'], ",") !== false) { | ||
$delimiter = ","; | ||
} | ||
|
||
if (strpos($request['registrations'], ";") !== false) { | ||
$delimiter = ";"; | ||
} | ||
|
||
if (!$delimiter) { | ||
$errors[] = "As inscrições devem estar separadas por virgula, ponto e virgula ou uma em cada linha"; | ||
} | ||
|
||
|
||
if ($errors) { | ||
$this->render('licc-summary-erros', ['errors' => $errors]); | ||
} | ||
|
||
|
||
|
||
if ($numbers = explode($delimiter, $request['registrations'])) { | ||
$results = []; | ||
foreach ($numbers as $number) { | ||
$number = trim($number); | ||
$_number = preg_replace('/[^0-9]/i', '', $number); | ||
|
||
if ($revisions = $conn->fetchAll("SELECT * FROM entity_revision er WHERE er.object_type = 'MapasCulturais\Entities\Registration' AND er.object_id = '{$_number}' ORDER BY er.create_timestamp ASC")) { | ||
foreach ($revisions as $revision) { | ||
$results[$number]['revisions'][] = [ | ||
'data' => (new DateTime($revision['create_timestamp']))->format("d/m/Y H:i:s"), | ||
'action' => $revision['message'], | ||
]; | ||
} | ||
} | ||
|
||
if($files = $conn->fetchAll("SELECT * FROM file f WHERE f.object_type = 'MapasCulturais\Entities\Registration' AND f.object_id = '{$_number}' ORDER BY f.create_timestamp ASC")) { | ||
foreach ($files as $file) { | ||
$results[$number]['files'][] = [ | ||
'data' => (new DateTime($revision['create_timestamp']))->format("d/m/Y H:i:s"), | ||
'name' => $file['name'], | ||
]; | ||
} | ||
} | ||
} | ||
|
||
if($results) { | ||
$this->render('licc-summary-result', ['results' => $results, 'request' => $request]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
plugins/SettingsES/views/essettings/licc-summary-erros.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/** | ||
* @var MapasCulturais\App $app | ||
* @var MapasCulturais\Themes\BaseV2\Theme $this | ||
*/ | ||
|
||
use MapasCulturais\i; | ||
|
||
$this->import(' | ||
mc-card | ||
'); | ||
|
||
$url = $app->createUrl("essettings", "liccSummary"); | ||
?> | ||
|
||
<mc-card> | ||
<div class="field col-12"> | ||
<ul> | ||
<?php foreach ($errors as $error) : ?> | ||
<li><?= $error ?></li> | ||
<?php endforeach ?> | ||
</ul> | ||
</div> | ||
|
||
<div class="col-3"> | ||
<a href="<?= $url ?>" type="submit" class="button button--md publish publish-exit"> | ||
<?php i::_e("Voltar") ?> | ||
</a> | ||
</div> | ||
</mc-card> |
73 changes: 73 additions & 0 deletions
73
plugins/SettingsES/views/essettings/licc-summary-result.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/** | ||
* @var MapasCulturais\App $app | ||
* @var MapasCulturais\Themes\BaseV2\Theme $this | ||
*/ | ||
|
||
use MapasCulturais\i; | ||
|
||
$this->import(' | ||
mc-card | ||
'); | ||
|
||
$url = $app->createUrl("essettings", "liccSummary"); | ||
?> | ||
|
||
<mc-card> | ||
<form method="POST" action="<?= $url ?>"> | ||
<div class="field col-12"> | ||
<?php foreach ($results as $registration => $result) : ?> | ||
<h2><?= i::_e("Inscrição {$registration}") ?></h2> | ||
<?php if (isset($request['useRevision'])) : ?> | ||
<h3><?= i::_e("Histórico de alterações") ?></h3> | ||
<table style="border: 1px solid black"> | ||
<thead> | ||
<tr> | ||
<td style="border: 1px solid black"><?= i::_e("Inscrição") ?></td> | ||
<td style="border: 1px solid black"><?= i::_e("Data da alteração") ?></td> | ||
<td style="border: 1px solid black"><?= i::_e("Ação executada") ?></td> | ||
</tr> | ||
</thead> | ||
<?php foreach ($result['revisions'] as $key => $revision) : ?> | ||
<tbody> | ||
<tr> | ||
<td style="border: 1px solid black"><?= $registration ?></td> | ||
<td style="border: 1px solid black"><?= $revision['data'] ?></td> | ||
<td style="border: 1px solid black"><?= $revision['action'] ?></td> | ||
</tr> | ||
</tbody> | ||
<?php endforeach ?> | ||
</table> | ||
<?php endif ?> | ||
<h3><?= i::_e("Lista de arquivos") ?></h3> | ||
<table style="border: 1px solid black"> | ||
<thead> | ||
<tr> | ||
<td style="border: 1px solid black"><?= i::_e("Inscrição") ?></td> | ||
<td style="border: 1px solid black"><?= i::_e("Data de carregamento do arquivo") ?></td> | ||
<td style="border: 1px solid black"><?= i::_e("Nome do arquivo") ?></td> | ||
</tr> | ||
</thead> | ||
<?php foreach ($result['files'] as $key => $file) : ?> | ||
<tbody> | ||
<tr> | ||
<td style="border: 1px solid black"><?= $registration ?></td> | ||
<td style="border: 1px solid black"><?= $file['data'] ?></td> | ||
<td style="border: 1px solid black"><?= $file['name'] ?></td> | ||
</tr> | ||
</tbody> | ||
<?php endforeach ?> | ||
</table> | ||
|
||
|
||
<?php endforeach ?> | ||
</div> | ||
|
||
<div class="col-3"> | ||
<a href="<?=$url?>" class="button button--md publish publish-exit"> | ||
<?php i::_e("Voltar") ?> | ||
</a> | ||
</div> | ||
</form> | ||
</mc-card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* @var MapasCulturais\App $app | ||
* @var MapasCulturais\Themes\BaseV2\Theme $this | ||
*/ | ||
|
||
use MapasCulturais\i; | ||
|
||
$this->import(' | ||
mc-card | ||
'); | ||
|
||
$url = $app->createUrl("essettings", "generateLiccSummary"); | ||
?> | ||
|
||
<mc-card> | ||
<form method="POST" action="<?=$url?>"> | ||
<div class="field col-12"> | ||
<label><?php i::_e("Inscrições") ?></label> | ||
<textarea name="registrations" cols="30" rows="10" placeholder="<?php i::_e("Informe o número das inscrições separadas por ponto e virgula, virgula ou uma em cada linha") ?>"></textarea> | ||
</div> | ||
|
||
<div class="col-3"> | ||
<label> | ||
<input type="checkbox" name="useRevision"> | ||
<?php i::_e("Exibir historico de alterações") ?> | ||
</label> | ||
<button type="submit" class="button button--md publish publish-exit"> | ||
<?php i::_e("Solicitar dados") ?> | ||
</button> | ||
</div> | ||
</form> | ||
</mc-card> |