[update] `historyDefault/search` and `history/search` (using username and machine name)
This commit is contained in:
parent
601d331348
commit
80e0fcc0c1
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace database\repo;
|
namespace database\repo;
|
||||||
use \database\core\DatabaseDriver;
|
use \database\core\DatabaseDriver;
|
||||||
|
use \database\core\Repo;
|
||||||
|
use \error\core\Err;
|
||||||
use \orm\core\Table;
|
use \orm\core\Table;
|
||||||
use \orm\core\Rows;
|
use \orm\core\Rows;
|
||||||
|
|
||||||
|
@ -189,6 +191,56 @@
|
||||||
return $history->fetch();
|
return $history->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RENVOIE UNE LISTE DE LOGS EN FONCTION D'UN MOT CLE
|
||||||
|
*
|
||||||
|
* @id_warehouse<int> UID de l'entrepot
|
||||||
|
* @keyword<String> Element de recherche
|
||||||
|
*
|
||||||
|
* @return logs<Array> Retourne les logs trouvees
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function search($id_warehouse, $keyword){
|
||||||
|
|
||||||
|
$machine_ids = [];
|
||||||
|
$user_ids = [];
|
||||||
|
|
||||||
|
/* [1] Recherche dans les relations 'machines'
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On exécute la requête */
|
||||||
|
$machines_r = new Repo('machine/search', [$id_warehouse, $keyword]);
|
||||||
|
|
||||||
|
/* (2) Gestion succès */
|
||||||
|
if( $machines_r->error->get() == Err::Success )
|
||||||
|
foreach($machines_r->answer() as $row)
|
||||||
|
$machine_ids[] = $row['id_machine'];
|
||||||
|
|
||||||
|
/* [2] Recherche dans les relations 'users'
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On cherche dans les utilisateurs */
|
||||||
|
$users_r = new Repo('user/search', [$id_warehouse, $keyword]);
|
||||||
|
|
||||||
|
/* (2) Gestion succès */
|
||||||
|
if( $users_r->error->get() == Err::Success )
|
||||||
|
foreach($users_r->answer() as $row)
|
||||||
|
$user_ids[] = $row['id_user'];
|
||||||
|
|
||||||
|
|
||||||
|
/* [3] On rédige/execute la requête
|
||||||
|
=========================================================*/
|
||||||
|
$history_r = DatabaseDriver::getPDO()->prepare("SELECT id_history FROM history
|
||||||
|
WHERE id_user IN (SELECT id_user FROM user WHERE username LIKE '%$keyword%')
|
||||||
|
or id_machine IN (SELECT id_machine FROM machine WHERE name LIKE '%$keyword%')
|
||||||
|
ORDER BY id_history ASC;");
|
||||||
|
|
||||||
|
$history_r->execute();
|
||||||
|
|
||||||
|
return DatabaseDriver::delNumeric( $history_r->fetchAll() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,19 @@
|
||||||
"output": {
|
"output": {
|
||||||
"history": { "description": "Données de l'historique", "type": "array" }
|
"history": { "description": "Données de l'historique", "type": "array" }
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"POST::search": {
|
||||||
|
"description": "Recherche une entrée historique par mots-clés.",
|
||||||
|
"permissions": [["admin"]],
|
||||||
|
"parameters": {
|
||||||
|
"keywords": { "description": "Mots-clés de recherche d'entrée historique", "type": "text" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"history": { "description": "Liste des logs correspondant à la recherche.", "type": "array<array<mixed>>" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
<span>Tout afficher</span>
|
<span>Tout afficher</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span data-sublink='filter' >
|
<span data-sublink='details' >
|
||||||
<span class='svg'><?php echo file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/filter.svg' ); ?></span>
|
<span class='svg'><?php echo file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/filter.svg' ); ?></span>
|
||||||
<span>Détails</span>
|
<span>Détails</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span data-sublink='remove' >
|
<span data-sublink='archive' >
|
||||||
<span class='svg'><?php echo file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/archive.svg' ); ?></span>
|
<span class='svg'><?php echo file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/archive.svg' ); ?></span>
|
||||||
<span>Archiver</span>
|
<span>Archiver</span>
|
||||||
</span>
|
</span>
|
||||||
|
@ -49,3 +49,21 @@
|
||||||
$view->view();
|
$view->view();
|
||||||
|
|
||||||
echo '</section>';
|
echo '</section>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [1] VIEW -> Liste des acces
|
||||||
|
=========================================================*/
|
||||||
|
if( isset($post[1]) && is_numeric($post[1]) ){
|
||||||
|
|
||||||
|
echo "<section data-sublink='details' class='list fstart'>";
|
||||||
|
|
||||||
|
echo "details";
|
||||||
|
$view = new Viewer('history.details', []);
|
||||||
|
$view->view();
|
||||||
|
|
||||||
|
echo '</section>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue