- [.] [/users/view] Affichage basique de liste d'elements complexes (users/machines/journal, ...)

- [.] [/machines/view] Idem
+ Corrections mineures
This commit is contained in:
xdrm-brackets 2016-02-10 08:54:23 +01:00
parent 8f5d4c2fc2
commit 135b479695
11 changed files with 189 additions and 111 deletions

View File

@ -20,13 +20,13 @@
*
*/
function insertUsersFromJSON(){
$json = manager\ResourcesDispatcher::getRessource('/f/json/generated_users/conf');
$json = \manager\ResourceDispatcher::getResource('f/json/generated_users/conf');
$json = json_decode( $json, true );
// Pour chaque entree
foreach( $json as $user ){
$insertRequest = manager\Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status)
$insertRequest = \manager\Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status)
VALUES(
DEFAULT,
:code,
@ -58,6 +58,41 @@
/* NSERTION DES MACHINES DANS LA BDD DEPUIS JSON
*
*
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
*
*/
function insertMachinesFromJSON(){
$json = \manager\ResourceDispatcher::getResource('f/json/generated_machines/conf');
$json = json_decode( $json, true );
// Pour chaque entree
foreach( $json as $machine ){
$insertRequest = \manager\Database::getPDO()->prepare("INSERT INTO machine(id_machine, code, name)
VALUES(
DEFAULT,
:code,
:name
)");
$status = $insertRequest->execute(array(
':code' => $machine['code'],
':name' => $machine['name']
));
var_dump( $status );
}
return true;
}//insertMachinesFromJSON();
@ -81,7 +116,31 @@
return true;
}selectUsers();
}//selectUsers();
/* AFFICHAGE DES MACHINES DE LA BDD
*
*
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
*
*/
function selectMachines(){
// Creation de la requete
$requete = new manager\ModuleRequest('machineDefaultModule/getAll');
$answer = $requete->dispatch();
var_dump( \manager\ManagerError::explicit($answer->error) );
var_dump( $answer->get('machines') );
return true;
}selectMachines();

View File

@ -1,6 +1,6 @@
{
"host" : "sql31.free-h.org",
"host" : "xdrm.io",
"dbname" : "stefproject",
"user" : "php",
"password" : "Hx2c#e77"
"password" : "QbzjZACndQM6NmuD"
}

View File

@ -0,0 +1,24 @@
[
{
'repeat:100': {
code: function(tags){
function randHex(){ return ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'][Math.floor(Math.random()*16)]; }
return randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex();
},
name: function(tags){
function randLet(){ return String.fromCharCode(65+Math.floor(Math.random()*26)); }
return randLet()+randLet()+randLet()+randLet()+randLet();
}
}
}
]

View File

@ -1,24 +1,31 @@
[
'{{repeat(100)}}',
{
code: function(tags){
'repeat:100': {
function randHex(){ return ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'][Math.floor(Math.random()*16)]; }
code: function(tags){
function randHex(){ return ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'][Math.floor(Math.random()*16)]; }
return randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex();
},
return randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex();
},
username: '{{firstName()}}',
firstname: '{{firstName()}}',
lastname: '{{surname()}}',
email: '{{email()}}',
password: function(tags){
var result = '';
for(var i = 0 ; i < 40 ; i++ )
result += ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][Math.floor(Math.random()*16)];
return result;
},
status: '{{integer(0,1)}}'
username: '{{firstName()}}',
firstname: '{{firstName()}}',
lastname: '{{surname()}}',
email: function (tags) {
// Email tag is deprecated, because now you can produce an email as simple as this:
return this.firstname + '.' + this.lastname + '@gmail.com';
},
password: function(tags){
var result = '';
for(var i = 0 ; i < 40 ; i++ )
result += ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][Math.floor(Math.random()*16)];
return result;
},
status: '{{integer(0,1)}}'
}
}
]

View File

@ -3,25 +3,8 @@
"getAll"
],
"firstModule" : [
"getUsers",
"returnvar",
"printvar"
],
"secondModule" : [
"f",
"g",
"h",
"i",
"j"
],
"thirdModule" : [
"k",
"l",
"m",
"n",
"o"
"machineDefaultModule" :[
"getAll"
]
}

View File

@ -34,7 +34,7 @@
if( self::$instance == null ){
// chargement de la configuration du server SQL
if( $_SERVER['HTTP_HOST'] != 'stefprojectv2' )
if( $_SERVER['HTTP_HOST'] != 'stefproject' )
$conf = json_decode( ResourceDispatcher::getResource(self::$config_path[0]), true );
else
$conf = json_decode( ResourceDispatcher::getResource(self::$config_path[1]), true );

View File

@ -1,39 +0,0 @@
<?php
namespace manager\module;
class firstModule{
public static function getUsers(){
return \manager\Database::getPDO()->query("SELECT * FROM user ORDER BY id_user")->fetchAll();
}
public static function returnvar($var){
var_dump('return var'); return $var;
}
public static function printvar($var){
var_dump('var = '); var_dump($var);
}
}
?>

View File

@ -0,0 +1,21 @@
<?php
namespace manager\module;
class machineDefaultModule{
public static function getAll(){
return array(
'machines' => \manager\Database::delNumeric( \manager\Database::getPDO()->query("SELECT * FROM machine ORDER BY id_machine")->fetchAll() )
);
}
}
?>

View File

@ -7,34 +7,11 @@
public static function getAll(){
return array(
'users' => \manager\Database::getPDO()->query("SELECT * FROM user ORDER BY id_user")->fetchAll()
'users' => \manager\Database::delNumeric( \manager\Database::getPDO()->query("SELECT * FROM user ORDER BY id_user")->fetchAll() )
);
}
public static function returnvar($var){
var_dump('return var'); return $var;
}
public static function printvar($var){
var_dump('var = '); var_dump($var);
}
}

View File

@ -13,7 +13,10 @@
############
# EN COURS #
############
- [ ] Prendre en compte au lieu de SERVER['HTTP_HOST'] l'hote et son dossier source
- [ ] Gestion de l'erreur de chargement ou erreur de nav (page-manager)
- [.] [/users/view] Affichage basique de liste d'elements complexes (users/machines/journal, ...)
- [.] [/machines/view] Idem
- [x] Conception BDD + ameliorations
- [x] Liste des tables
- [x] Liste de attributs

View File

@ -5,7 +5,7 @@
<!-- [1] Gestion du sous-menu de gauche -->
<nav class='sub-menu-side'>
<span data-sublink='displayall'>
<span data-sublink='view'>
<span class='svg'><?php echo \manager\ResourceDispatcher::getResource( 'f/svg/view/st/sub-menu-side' ); ?></span>
<span>Tout afficher</span>
</span>
@ -39,6 +39,49 @@
<section>
Bienvenue sur la page de gestion des MACHINES
</section>
<?php
$post = array();
foreach($_POST as $k=>$v)
array_push($post, $k);
$sublink = $post[0];
// On recupere toutes les machines
debug();
$request = new \manager\ModuleRequest('machineDefaultModule/getAll'); // On utilise la methode 'getAll' du module 'machineDefaultModule'
$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 != \manager\ManagerError::Success )
var_dump( \manager\ManagerError::explicit($answer->error) );
// Si aucune erreur, on affiche les resultats
else{
foreach( $answer->get('machines') as $machine){
echo "<article class='inline-box'>";
// Prenom Nom
echo "<span class='title'>".$machine['name']."</span>";
// Code RFID
echo "<span class='code'>";
echo \manager\ResourceDispatcher::getResource('f/svg/card/st/container');
echo "<span>";
echo $machine['code'];
echo "</span>";
echo"</span>";
echo "</article>";
}
var_dump( $answer->get('machines') );
}
echo '</section>';