- [.] [/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 269934ec27
commit 1ff26f01f7
12 changed files with 591 additions and 111 deletions

View File

@ -20,13 +20,13 @@
* *
*/ */
function insertUsersFromJSON(){ 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 ); $json = json_decode( $json, true );
// Pour chaque entree // Pour chaque entree
foreach( $json as $user ){ 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( VALUES(
DEFAULT, DEFAULT,
:code, :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; 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", "dbname" : "stefproject",
"user" : "php", "user" : "php",
"password" : "Hx2c#e77" "password" : "QbzjZACndQM6NmuD"
} }

View File

@ -0,0 +1,402 @@
[
{
"code": "CB-40-70-A0",
"name": "WNTKO"
},
{
"code": "C9-42-46-45",
"name": "RMUAY"
},
{
"code": "30-DA-23-C0",
"name": "ZSCMZ"
},
{
"code": "6B-F0-82-05",
"name": "AWCUX"
},
{
"code": "C8-67-58-0E",
"name": "HKSWO"
},
{
"code": "CB-94-1E-F3",
"name": "ASIFJ"
},
{
"code": "3F-A6-B3-5E",
"name": "CCKEV"
},
{
"code": "8E-24-B5-24",
"name": "KDVSJ"
},
{
"code": "27-15-0B-9D",
"name": "VCEWY"
},
{
"code": "FE-38-93-E9",
"name": "UKWVN"
},
{
"code": "07-6F-B6-B6",
"name": "FFJDJ"
},
{
"code": "3A-A8-8E-B1",
"name": "NHCWO"
},
{
"code": "A3-15-41-38",
"name": "IBRFK"
},
{
"code": "99-30-04-B1",
"name": "FGLXK"
},
{
"code": "80-A8-91-C8",
"name": "BUZRV"
},
{
"code": "97-F3-00-93",
"name": "WKNTM"
},
{
"code": "C6-F7-45-02",
"name": "SPQOQ"
},
{
"code": "25-11-D9-70",
"name": "SSRWE"
},
{
"code": "5B-EF-81-00",
"name": "TIBAH"
},
{
"code": "74-18-01-AE",
"name": "EKOFT"
},
{
"code": "07-27-C3-41",
"name": "GJTJW"
},
{
"code": "23-38-C6-B5",
"name": "XIPNP"
},
{
"code": "35-49-0B-88",
"name": "FDFXQ"
},
{
"code": "36-00-7F-1C",
"name": "HSCUZ"
},
{
"code": "CB-60-BB-1A",
"name": "BYKBF"
},
{
"code": "FE-5F-E7-FB",
"name": "GNOKK"
},
{
"code": "54-D1-4D-EC",
"name": "WLSUB"
},
{
"code": "9D-D8-C8-53",
"name": "DMTTJ"
},
{
"code": "32-A8-CB-08",
"name": "OCFWD"
},
{
"code": "A4-B4-FC-74",
"name": "CABWU"
},
{
"code": "9E-E7-87-A0",
"name": "BUWRJ"
},
{
"code": "3F-90-8D-56",
"name": "OULIX"
},
{
"code": "C7-95-56-96",
"name": "XCDYM"
},
{
"code": "98-5B-99-35",
"name": "LREGF"
},
{
"code": "C0-1C-52-1E",
"name": "DDLSP"
},
{
"code": "AE-01-18-81",
"name": "DTGHG"
},
{
"code": "85-46-39-94",
"name": "BZWUE"
},
{
"code": "9C-3C-45-AB",
"name": "LGDDS"
},
{
"code": "14-A5-92-CE",
"name": "ERXMY"
},
{
"code": "A4-35-C5-76",
"name": "VJGER"
},
{
"code": "69-8E-6A-11",
"name": "LOXIE"
},
{
"code": "04-73-52-C8",
"name": "IHARA"
},
{
"code": "66-48-DF-7B",
"name": "ZIQJQ"
},
{
"code": "01-D9-22-86",
"name": "ZKUEW"
},
{
"code": "B4-AC-F6-93",
"name": "BLDTO"
},
{
"code": "E3-B8-CC-D4",
"name": "OZRQF"
},
{
"code": "FF-18-3D-CB",
"name": "NWPBM"
},
{
"code": "68-2D-86-1D",
"name": "OZDYC"
},
{
"code": "65-AC-44-36",
"name": "ETUZU"
},
{
"code": "9D-3F-90-E9",
"name": "CNQAB"
},
{
"code": "8B-DE-55-B5",
"name": "OPIIW"
},
{
"code": "15-1B-34-D7",
"name": "ACARQ"
},
{
"code": "0D-E1-41-A8",
"name": "NMHYG"
},
{
"code": "19-FB-D2-82",
"name": "ASKZD"
},
{
"code": "C6-55-0A-22",
"name": "QMIJT"
},
{
"code": "61-E4-51-C7",
"name": "BBDZL"
},
{
"code": "65-78-34-50",
"name": "WKKYH"
},
{
"code": "41-9A-BF-99",
"name": "AFHJH"
},
{
"code": "05-0D-82-31",
"name": "CASXB"
},
{
"code": "0D-21-6F-00",
"name": "LOXOZ"
},
{
"code": "F7-84-53-CF",
"name": "ZTUNO"
},
{
"code": "C2-9A-2D-9A",
"name": "QGQNK"
},
{
"code": "BE-57-E3-29",
"name": "SVIBS"
},
{
"code": "13-39-5D-21",
"name": "RSVXL"
},
{
"code": "A6-3D-D3-AC",
"name": "EMESC"
},
{
"code": "F2-EF-83-5E",
"name": "BBXON"
},
{
"code": "52-F5-7D-2B",
"name": "NGLBK"
},
{
"code": "BA-30-5C-C7",
"name": "MZHBC"
},
{
"code": "B5-43-98-38",
"name": "OYEPB"
},
{
"code": "95-AC-FD-6F",
"name": "RQFNK"
},
{
"code": "E0-12-F0-7D",
"name": "MRUUS"
},
{
"code": "E2-5F-C1-1F",
"name": "DJDVW"
},
{
"code": "0B-0B-AF-49",
"name": "SOJEJ"
},
{
"code": "C1-AF-BE-FD",
"name": "YYSRC"
},
{
"code": "6B-71-12-94",
"name": "AJNMI"
},
{
"code": "E0-D3-67-BB",
"name": "IVUSU"
},
{
"code": "D7-02-23-82",
"name": "VYPUB"
},
{
"code": "3F-AA-D7-E0",
"name": "SJYUN"
},
{
"code": "CA-0E-31-E6",
"name": "QRGTG"
},
{
"code": "D4-92-6B-03",
"name": "LXIFX"
},
{
"code": "EE-0A-F5-D3",
"name": "YXWTP"
},
{
"code": "73-EB-04-C8",
"name": "SMEFT"
},
{
"code": "32-37-21-39",
"name": "HUTUW"
},
{
"code": "97-13-49-2E",
"name": "DYCLY"
},
{
"code": "EE-63-92-60",
"name": "VBJWP"
},
{
"code": "B3-88-BB-2B",
"name": "CZRPO"
},
{
"code": "F5-7D-F5-7E",
"name": "JCNSP"
},
{
"code": "AA-A9-B2-83",
"name": "EOKCA"
},
{
"code": "EA-62-F6-F9",
"name": "PZEAK"
},
{
"code": "3D-3B-BE-D9",
"name": "ERIMX"
},
{
"code": "75-57-68-54",
"name": "NGVPC"
},
{
"code": "0E-F0-AD-27",
"name": "MVONW"
},
{
"code": "84-39-68-9B",
"name": "ZUHOD"
},
{
"code": "75-E4-50-0C",
"name": "YIATG"
},
{
"code": "E8-F6-C1-CF",
"name": "WFQGC"
},
{
"code": "55-89-B7-34",
"name": "NKZQL"
},
{
"code": "B2-67-DD-0C",
"name": "EMIWA"
},
{
"code": "11-7C-2E-A4",
"name": "WOYWY"
},
{
"code": "CB-D8-B5-A2",
"name": "ZBLQG"
},
{
"code": "CE-A1-20-27",
"name": "STQYS"
}
]

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){
return randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex(); 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();
},
username: '{{firstName()}}', username: '{{firstName()}}',
firstname: '{{firstName()}}', firstname: '{{firstName()}}',
lastname: '{{surname()}}', lastname: '{{surname()}}',
email: '{{email()}}', email: function (tags) {
password: function(tags){ // Email tag is deprecated, because now you can produce an email as simple as this:
var result = ''; return this.firstname + '.' + this.lastname + '@gmail.com';
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)]; password: function(tags){
return result; var result = '';
}, for(var i = 0 ; i < 40 ; i++ )
status: '{{integer(0,1)}}' 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" "getAll"
], ],
"firstModule" : [ "machineDefaultModule" :[
"getUsers", "getAll"
"returnvar",
"printvar"
],
"secondModule" : [
"f",
"g",
"h",
"i",
"j"
],
"thirdModule" : [
"k",
"l",
"m",
"n",
"o"
] ]
} }

View File

@ -34,7 +34,7 @@
if( self::$instance == null ){ if( self::$instance == null ){
// chargement de la configuration du server SQL // 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 ); $conf = json_decode( ResourceDispatcher::getResource(self::$config_path[0]), true );
else else
$conf = json_decode( ResourceDispatcher::getResource(self::$config_path[1]), true ); $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(){ public static function getAll(){
return array( 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 # # 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, ...) - [.] [/users/view] Affichage basique de liste d'elements complexes (users/machines/journal, ...)
- [.] [/machines/view] Idem
- [x] Conception BDD + ameliorations - [x] Conception BDD + ameliorations
- [x] Liste des tables - [x] Liste des tables
- [x] Liste de attributs - [x] Liste de attributs

View File

@ -5,7 +5,7 @@
<!-- [1] Gestion du sous-menu de gauche --> <!-- [1] Gestion du sous-menu de gauche -->
<nav class='sub-menu-side'> <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 class='svg'><?php echo \manager\ResourceDispatcher::getResource( 'f/svg/view/st/sub-menu-side' ); ?></span>
<span>Tout afficher</span> <span>Tout afficher</span>
</span> </span>
@ -39,6 +39,49 @@
<section> <?php
Bienvenue sur la page de gestion des MACHINES
</section> $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>';