NxTIC/view/machines.php

206 lines
5.6 KiB
PHP
Executable File

<?php define('__ROOT__', dirname(dirname(__FILE__)) );
require_once __ROOT__.'/manager/autoloader.php';
use \manager\ModuleRequest;
use \manager\ManagerError;
use \manager\ResourceDispatcher;
use \manager\Repo;
?>
<!-- [1] Gestion du sous-menu de gauche -->
<nav class='sub-menu-side'>
<span data-sublink='view'>
<span class='svg'><?php echo ResourceDispatcher::getResource( 'f/svg/view/st/sub-menu-side' ); ?></span>
<span>Tout afficher</span>
</span>
<span data-sublink='create'>
<span class='svg'><?php echo ResourceDispatcher::getResource( 'f/svg/create/st/sub-menu-side' ); ?></span>
<span>Creation</span>
</span>
<span data-sublink='remove'>
<span class='svg'><?php echo ResourceDispatcher::getResource( 'f/svg/remove/st/sub-menu-side' ); ?></span>
<span>Suppression</span>
</span>
<span data-sublink='edit'>
<span class='svg'><?php echo ResourceDispatcher::getResource( 'f/svg/edit/st/sub-menu-side' ); ?></span>
<span>Modification</span>
</span>
<span data-sublink='filter'>
<span class='svg'><?php echo ResourceDispatcher::getResource( 'f/svg/filter/st/sub-menu-side' ); ?></span>
<span>Filtrer</span>
</span>
</nav>
<?php
$post = array();
foreach($_POST as $k=>$v)
array_push($post, $k);
$sublink = $post[0];
/* [1] Affichage des machines
=========================================================*/
$request = new ModuleRequest('machineDefault/getAll'); // On utilise la methode 'getAll' du module 'machineDefault'
$answer = $request->dispatch(); // On recupere la reponse
echo "<section data-sublink='view' class='list'>";
// echo 'Liste des utilisateurs: <br>';
// si erreur, on affiche l'explicitation
if( $answer->error != ManagerError::Success ){
// var_dump( ManagerError::explicit($answer->error) );
echo "<span class='error'>Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.</span>";
}
// Si aucune erreur, on affiche les resultats
else{
// Barre de recherche
echo "<input type='text' class='searchbar' placeholder='Recherche'>";
// Liste des machines
foreach( $answer->get('machines') as $machine){
$clusters = new Repo('machine/getClusters', array($machine['id_machine']));
$clusters = $clusters->answer();
echo "<article class='inline-box' id='".$machine['id_machine']."'>";
// Nom de la machine
echo "<span class='title'>#".$machine['name']."</span>";
// Icone vers la suppression
echo "<span class='link_remove' data-machine='".$machine['id_machine']."'>";
echo ResourceDispatcher::getResource('f/svg/remove/st/sub-menu-side');
echo "</span>";
// Icone vers la modification
echo "<span class='link_edit' data-machine='".$machine['id_machine']."'>";
echo ResourceDispatcher::getResource('f/svg/edit/st/sub-menu-side');
echo "</span>";
// Code RFID
echo "<span class='code'>";
echo ResourceDispatcher::getResource('f/svg/card/st/container');
echo "<span>";
echo $machine['code'];
echo "</span>";
echo"</span>";
// Groupes de la machine
echo "<span class='groups'>";
echo ResourceDispatcher::getResource('f/svg/group/st/container');
if( $clusters != false )
foreach($clusters as $cluster)
echo "<span>".$cluster['name']."</span>";
echo"</span>";
echo "</article>";
}
}
echo '</section>';
/* [2] Creation de machine
=========================================================*/
echo "<section data-sublink='create'>";
echo "<form class='valid'>";
echo "<input id='create_code' type='text' placeholder='Code'><br>";
echo "<input id='create_name' type='text' placeholder='Name'><br>";
echo "<button id='create_submit'>Créer</button>";
echo "</form>";
echo '</section>';
/* [3] Suppression de machine
=========================================================*/
echo "<section data-sublink='remove'>";
echo "<form class='invalid'>";
echo "<input id='remove_search_keyword' type='text' class='search' placeholder='Recherche...'><br>";
echo "<input id='remove_search_id' type='hidden' value=''>";
// Indice du resultat
echo "<span class='remove_search_view'>machine <span class='remove_search_num'>0</span> sur <span class='remove_search_sum'>0</span></span><br><br>";
echo "<button id='remove_search_submit' class='search'>Trouver</button><br>";
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
echo "<input id='remove_code' type='text' placeholder='CO-DE-RF-ID'><br>";
echo "<input id='remove_name' type='text' placeholder='Name'><br>";
echo "<button id='remove_submit'>Supprimer</button>";
echo "</form>";
echo '</section>';
/* [4] Modification de machine
=========================================================*/
echo "<section data-sublink='edit'>";
echo "<form class='neutral'>";
echo "<input id='edit_search_keyword' type='text' class='search' placeholder='Recherche...'><br>";
echo "<input id='edit_search_id' type='hidden' value=''>";
// Indice du resultat
echo "<span class='edit_search_view'>machine <span class='edit_search_num'>0</span> sur <span class='edit_search_sum'>0</span></span><br><br>";
echo "<button id='edit_search_submit' class='search'>Trouver</button><br>";
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
echo "<input id='edit_code' type='text' placeholder='Code'><br>";
echo "<input id='edit_name' type='text' placeholder='Name'><br>";
echo "<button id='edit_submit' disabled>Modifier</button>";
echo "</form>";
echo '</section>';