diff --git a/automate.php b/automate.php index b69448e..2077fdf 100755 --- a/automate.php +++ b/automate.php @@ -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 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 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(); diff --git a/config/database.json b/config/database.json index fe15446..e8b8c69 100755 --- a/config/database.json +++ b/config/database.json @@ -1,6 +1,6 @@ { - "host" : "sql31.free-h.org", + "host" : "xdrm.io", "dbname" : "stefproject", "user" : "php", - "password" : "Hx2c#e77" + "password" : "QbzjZACndQM6NmuD" } \ No newline at end of file diff --git a/config/jsongenerator_machines.js b/config/jsongenerator_machines.js new file mode 100755 index 0000000..de17976 --- /dev/null +++ b/config/jsongenerator_machines.js @@ -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(); + } + + + } + } +] \ No newline at end of file diff --git a/config/jsongenerator_users.js b/config/jsongenerator_users.js index 349ae78..72cad88 100755 --- a/config/jsongenerator_users.js +++ b/config/jsongenerator_users.js @@ -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)}}' + + + } } ] \ No newline at end of file diff --git a/config/modules.json b/config/modules.json index 2f12cf6..ab4dbd4 100755 --- a/config/modules.json +++ b/config/modules.json @@ -3,25 +3,8 @@ "getAll" ], - "firstModule" : [ - "getUsers", - "returnvar", - "printvar" - ], - - "secondModule" : [ - "f", - "g", - "h", - "i", - "j" - ], - - "thirdModule" : [ - "k", - "l", - "m", - "n", - "o" + "machineDefaultModule" :[ + "getAll" ] + } \ No newline at end of file diff --git a/manager/Database.php b/manager/Database.php index 7adf270..088da3d 100755 --- a/manager/Database.php +++ b/manager/Database.php @@ -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 ); diff --git a/manager/module/firstModule.php b/manager/module/firstModule.php deleted file mode 100755 index 09dabb0..0000000 --- a/manager/module/firstModule.php +++ /dev/null @@ -1,39 +0,0 @@ -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); - } - - - - - - - } - - -?> \ No newline at end of file diff --git a/manager/module/machineDefaultModule.php b/manager/module/machineDefaultModule.php new file mode 100644 index 0000000..aae366f --- /dev/null +++ b/manager/module/machineDefaultModule.php @@ -0,0 +1,21 @@ + \manager\Database::delNumeric( \manager\Database::getPDO()->query("SELECT * FROM machine ORDER BY id_machine")->fetchAll() ) + ); + } + + + + + + } + + +?> \ No newline at end of file diff --git a/manager/module/userDefaultModule.php b/manager/module/userDefaultModule.php index 9455b8a..be7ffcc 100755 --- a/manager/module/userDefaultModule.php +++ b/manager/module/userDefaultModule.php @@ -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); - } - - - - - - } diff --git a/todo.md b/todo.md index 1060517..cd2eb89 100755 --- a/todo.md +++ b/todo.md @@ -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 diff --git a/view/machines.php b/view/machines.php index 49c95da..c8ea6ac 100755 --- a/view/machines.php +++ b/view/machines.php @@ -5,7 +5,7 @@