[update] EXPORT available (but removal to do next)
This commit is contained in:
parent
c9da8708ae
commit
16f1464af7
|
@ -257,11 +257,11 @@
|
|||
if( $fromAjax ){
|
||||
|
||||
|
||||
$tmpfname = '/tmp/download_'.uniqid().'.php';
|
||||
$tmpfname = '/tmp/download_'.uniqid().'.php';
|
||||
$bodyfname = __ROOT__.'/tmp/content_'.uniqid().'.php';
|
||||
|
||||
/* (1) On crée le fichier temporaire */
|
||||
$tmpfnameroot = __ROOT__.$tmpfname;
|
||||
$tmpfnameroot = __PUBLIC__.$tmpfname;
|
||||
$tmpfile = fopen($tmpfnameroot, 'w');
|
||||
|
||||
fwrite($tmpfile, '<?php'.PHP_EOL);
|
||||
|
|
|
@ -111,6 +111,45 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ARCHIVE L'HISTORIQUE D'UN ENTREPOT
|
||||
*
|
||||
* @return archive<File> Fichier de l'archive (.csv format)
|
||||
*
|
||||
*/
|
||||
public function archive($params){
|
||||
extract($params);
|
||||
|
||||
/* [1] Récupération des logs
|
||||
=========================================================*/
|
||||
/* (1) Requête */
|
||||
$logs = new Repo('history/getAll', [$_SESSION['WAREHOUSE']['id']]);
|
||||
|
||||
/* (2) Gestion erreur */
|
||||
if( $logs->error->get() != Err::Success )
|
||||
return [ 'error' => $logs->error ];
|
||||
|
||||
|
||||
/* [2] Création du contenu fichier
|
||||
=========================================================*/
|
||||
$BODY = "TIMESTAMP,MACHINE,UTILISATEUR,ACTION\n";
|
||||
|
||||
foreach($logs->answer() as $log)
|
||||
$BODY .= $log['timestamp'].','.$log['machine_name'].','.$log['user_name'].','.$log['action_name']."\n";
|
||||
|
||||
|
||||
/* [3] Renvoi du fichier
|
||||
=========================================================*/
|
||||
return [
|
||||
'headers' => [
|
||||
'Content-Type' => 'text/csv',
|
||||
'Content-Disposition' => 'attachment; filename=archive-'.date('dmY').'.csv'
|
||||
],
|
||||
'body' => $BODY
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -537,6 +537,14 @@
|
|||
"output": {
|
||||
"history": { "description": "Liste des logs correspondant à la recherche.", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"POST::archive": {
|
||||
"description": "Archive de l'historique complet.",
|
||||
"permissions": [["admin"]],
|
||||
"options": { "download": true },
|
||||
"parameters": {},
|
||||
"output": {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
|
||||
|
||||
/* [1] VIEW -> Liste des acces
|
||||
/* [2] DETAILS -> Détails d'un log
|
||||
=========================================================*/
|
||||
if( isset($post[1]) && is_numeric($post[1]) ){
|
||||
|
||||
|
@ -67,3 +67,23 @@
|
|||
echo '</section>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [3] Archive -> Archivage des logs
|
||||
=========================================================*/
|
||||
|
||||
echo "<section data-sublink='archive' class='list fstart'>";
|
||||
|
||||
echo "<form class='search'>";
|
||||
echo "Le téléchargement de l'archive supprimera toutes les entrées de l'historique.";
|
||||
echo "<br>";
|
||||
echo "<center>Etes-vous sur de vouloir procéder ?</center>";
|
||||
echo "<br>";
|
||||
echo "<button id='archive_clean'>Archiver l'historique</button>";
|
||||
echo "</form>";
|
||||
|
||||
echo '</section>';
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ var section = {
|
|||
|
||||
archive: {
|
||||
text: '#CONTAINER > section[data-sublink="archive"] ',
|
||||
element: document.querySelector('#CONTAINER > section[data-sublink="archive"]')
|
||||
element: document.querySelector('#CONTAINER > section[data-sublink="archive"] #archive_clean')
|
||||
},
|
||||
|
||||
};
|
||||
|
@ -99,3 +99,36 @@ if( section.view.element != null ){
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* GESTION DE L'ARCHIVAGE
|
||||
*
|
||||
*/
|
||||
if( section.archive.element != null ){
|
||||
|
||||
/* (1) Gestion du clic pour archivage */
|
||||
section.archive.element.addEventListener('click', function(e){
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
api.send({path: 'historyDefault/archive'}, function(result){
|
||||
if( result.error == 0 ){
|
||||
|
||||
document.location = result.link;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue