Permalink
Browse files

New screen to search/view latest audit logs.

  • Loading branch information...
fmfurtado committed Dec 30, 2017
1 parent 06c9f2e commit 15f0152a396beabc241ac607411875edc96a84fe
@@ -4,4 +4,17 @@ SET names utf8;
ALTER TABLE TB_BOOK ADD `lost` TINYINT(1) NOT NULL DEFAULT 0;
ALTER TABLE TB_BOOK ADD `lost_by_username` VARCHAR(30) NULL;
ALTER TABLE TB_BOOK ADD `lost_timestamp` DATETIME NULL;
ALTER TABLE TB_BOOK ADD `lost_timestamp` DATETIME NULL;
---
--- Table 'tb_audit'
---
CREATE TABLE IF NOT EXISTS `tb_audit` (
`id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
`username` VARCHAR(30) NULL,
`timestamp` DATETIME NULL,
`operation` VARCHAR(30) NULL,
`details` LONGTEXT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC))
ENGINE = InnoDB DEFAULT CHARSET=latin1;
View
@@ -93,6 +93,10 @@
<a href="bookCoverSearch.php"><?= $t->__('menu.admin.bookCover') ?></a>
</li>
<?= strpos($_SERVER["REQUEST_URI"], 'auditSearch.php') ? "<li class='active'>" : "<li>" ?>
<a href="auditSearch.php"><?= $t->__('menu.admin.audit') ?></a>
</li>
<?= strpos($_SERVER["REQUEST_URI"], 'reportStatistics.php') ? "<li class='active'>" : "<li>" ?>
<a href="reportStatistics.php"><?= $t->__('menu.admin.statistics') ?></a>
</li>
View
@@ -0,0 +1,101 @@
<?php
include_once '_header.mandatory.php';
$fmw->checkOperator();
include '_header.php';
?>
<h1><?= $t->__('auditSearch.title') ?></h1>
<?php
$start_date = date("d/m/Y",strtotime("-1 month"));
$post_date = $_POST['start_date'];
$session_date = $_SESSION['audit_start_date'];
if (!isset($post_date) and isset($session_date)) {
$start_date = $session_date;
} else if (isset($post_date) and $fmw->verifyDate($post_date)) {
$start_date = $post_date;
}
$_SESSION['audit_start_date'] = $start_date;
$end_date = date('d/m/Y');
$post_date = $_POST['end_date'];
$session_date = $_SESSION['audit_start_end'];
if (!isset($post_date) and isset($session_date)) {
$end_date = $session_date;
} else if (isset($post_date) and $fmw->verifyDate($post_date)) {
$end_date = $post_date;
}
$_SESSION['audit_end_date'] = $end_date;
?>
<form class="navbar-form navbar-left" role="search" method="post">
<script>
$(function() {
$( "#start_date" ).datepicker({ dateFormat: "dd/mm/yy" });
$( "#end_date" ).datepicker({ dateFormat: "dd/mm/yy" });
});
</script>
<label class="control-label"><?= $t->__('auditSearch.label.start_date') ?>:</label>
<input type="text" name="start_date" size="10" class="form-control" value="<?= $start_date ?>" id="start_date"/>
<label class="control-label"><?= $t->__('auditSearch.label.end_date') ?>:</label>
<input type="text" name="end_date" size="10" class="form-control" value="<?= $end_date ?>" id="end_date"/>
<input type="submit" class="btn btn-default" value="<?= $t->__('button.search') ?>"/>
</form>
<br/>
<table class="table table-hover">
<tr>
<th><?= $t->__('db.audit.timestamp') ?></th>
<th><?= $t->__('db.audit.username') ?></th>
<th><?= $t->__('db.audit.operation') ?></th>
<th><?= $t->__('db.audit.details') ?></th>
</tr>
<?php
$query = "select * from tb_audit where STR_TO_DATE('".$start_date."','%d/%m/%Y') < timestamp and timestamp <= STR_TO_DATE('".$end_date." 23:59:59','%d/%m/%Y %H:%i:%s')";
$datas = $database->query($query)->fetchAll();
$counter = 0;
foreach($datas as $row) {
$counter++;
$fmw->escapeHtmlArray($row);
echo "<tr>";
echo "<td>";
echo $row['timestamp'];
echo "</td>";
echo "<td>";
echo $row['username'];
echo "</td>";
echo "<td>";
echo $row['operation'];
echo "</td>";
echo "<td>";
echo $row['details'];
echo "</td>";
echo "</tr>\n";
if ($counter == 100) {
echo "<tr><td colspan='100' align='center'>";
echo $t->__('message.there_are_more');
echo "</td></tr>";
break;
}
}
?>
</table>
<?php include '_footer.php' ?>
View
@@ -9,7 +9,8 @@ menu.admin.userList=Users
menu.admin.bookCategory=Book Category
menu.admin.bookType=Book Type
menu.admin.bookLanguage=Book Language
menu.admin.bookCover=Book Covers
menu.admin.bookCover=Book Covers
menu.admin.audit=Audit Logs
menu.admin.statistics=Statistics
menu.admin.backup=Database Backup
@@ -82,6 +83,12 @@ db.about.site_meta_keywords=Meta Keywords
db.about.site_logo_url=Site logo URL
db.about.site_welcome=Welcome page of your library
db.audit=Audit
db.audit.username=Username
db.audit.timestamp=Date
db.audit.operation=Operation
db.audit.details=Details
label.action=Action
label.action.return=Return
label.action.lend=Lend
@@ -92,6 +99,10 @@ label.numberOfBooks=Number of books
bookSearch.title=List of Books
personSearch.title=List of People
auditSearch.title=Audit Logs
auditSearch.label.start_date=From
auditSearch.label.end_date=To
bookSave.message.newBookSaved=New book '%1' created with ID %2
bookSave.message.bookUpdated=Book '%1' was updated.
bookSave.message.codeMandatory=The code is mandatory !
@@ -215,3 +226,4 @@ checkAuthorization.message.notAuthorized=You are not authorized to access this p
message.there_are_more_books=There are more books...
message.there_are_more_people=There are more people...
message.there_are_more=There are more elements...
View
@@ -10,6 +10,7 @@ menu.admin.bookCategory=Catégorie de Livres
menu.admin.bookType=Type de Livres
menu.admin.bookLanguage=Langue des Livres
menu.admin.bookCover=Couverture des Livres
menu.admin.audit=Audit d'activités
menu.admin.statistics=Statistiques
menu.admin.backup=Sauvegarde de la Base de Données
@@ -82,6 +83,12 @@ db.about.site_meta_keywords=Meta Mot clés
db.about.site_logo_url=Logo
db.about.site_welcome=Page de bienvenue de votre bibliothèque
db.audit=Audit
db.audit.username=Utilisateur
db.audit.timestamp=Date
db.audit.operation=Operation
db.audit.details=Details
label.action=Action
label.action.return=Rendre
label.action.lend=Emprunter
@@ -92,6 +99,10 @@ label.numberOfBooks=Nombre de livres
bookSearch.title=Liste des livres
personSearch.title=Liste des Personnes
auditSearch.title=Audit d'activités
auditSearch.label.start_date=Début
auditSearch.label.end_date=Fin
bookSave.message.newBookSaved=Nouveau livre '%1' a été enregistré avec ID %2
bookSave.message.bookUpdated=Livre '%1' a été actualisé !
bookSave.message.codeMandatory=Le code d'un livre est obligatoire !
@@ -215,3 +226,4 @@ checkAuthorization.message.notAuthorized=Vous n'êtes pas autorisé sur cette pa
message.there_are_more_books=Il y a encore d’autres résultats. Merci d’affiner votre recherche !
message.there_are_more_people=Il y a encore d’autres résultats. Merci d’affiner votre recherche !
message.there_are_more=Il y a plus d'elements. Merci d’affiner votre recherche !
@@ -10,6 +10,7 @@ menu.admin.bookCategory=Categoria de Livros
menu.admin.bookType=Tipos de Livros
menu.admin.bookLanguage=Idioma de Livros
menu.admin.bookCover=Capa dos livros
menu.admin.audit=Auditoria de atividades
menu.admin.statistics=Estatísticas
menu.admin.backup=Backup de Segurança
@@ -82,6 +83,12 @@ db.about.site_meta_keywords=Meta Palavras Chaves
db.about.site_logo_url=URL do logotipo
db.about.site_welcome=Página de boas vindas de sua biblioteca
db.audit=Auditoria
db.audit.username=Usuário
db.audit.timestamp=Data
db.audit.operation=Operação
db.audit.details=Detalhes
label.action=Ação
label.action.return=Devolver
label.action.lend=Emprestar
@@ -92,6 +99,10 @@ label.numberOfBooks=Quantidade de livros
bookSearch.title=Lista de livros
personSearch.title=Lista de pessoas
auditSearch.title=Auditoria de atividades
auditSearch.label.start_date=Início
auditSearch.label.end_date=Final
bookSave.message.newBookSaved=Novo livro '%1' criado com ID %2
bookSave.message.bookUpdated=Livro '%1' foi atualizado.
bookSave.message.codeMandatory=O código é obrigatório !
@@ -215,3 +226,4 @@ checkAuthorization.message.notAuthorized=Você não está autorizado a acessar e
message.there_are_more_books=Há mais livros...
message.there_are_more_people=Há mais pessoas...
message.there_are_more=Há mais registros...

0 comments on commit 15f0152

Please sign in to comment.