2016-02-04 18:23:16 +00:00
|
|
|
<?php define('__ROOT__', dirname(__FILE__) );
|
|
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
|
|
|
|
2016-02-13 17:41:19 +00:00
|
|
|
debug();
|
2016-02-04 18:23:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* NSERTION DES UTILISATEURS DANS LA BDD DEPUIS JSON
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function insertUsersFromJSON(){
|
2016-02-10 07:54:23 +00:00
|
|
|
$json = \manager\ResourceDispatcher::getResource('f/json/generated_users/conf');
|
2016-02-04 18:23:16 +00:00
|
|
|
$json = json_decode( $json, true );
|
|
|
|
|
|
|
|
// Pour chaque entree
|
|
|
|
foreach( $json as $user ){
|
|
|
|
|
2016-02-10 07:54:23 +00:00
|
|
|
$insertRequest = \manager\Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status)
|
2016-02-04 18:23:16 +00:00
|
|
|
VALUES(
|
|
|
|
DEFAULT,
|
|
|
|
:code,
|
|
|
|
:username,
|
|
|
|
:firstname,
|
|
|
|
:lastname,
|
|
|
|
:mail,
|
|
|
|
:password,
|
|
|
|
:status
|
|
|
|
)");
|
|
|
|
|
|
|
|
$status = $insertRequest->execute(array(
|
|
|
|
':code' => $user['code'],
|
|
|
|
':username' => $user['username'],
|
|
|
|
':firstname' => $user['firstname'],
|
|
|
|
':lastname' => $user['lastname'],
|
|
|
|
':mail' => $user['email'],
|
|
|
|
':password' => $user['password'],
|
|
|
|
':status' => $user['status']
|
|
|
|
));
|
|
|
|
|
|
|
|
var_dump( $status );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}// insertUsersFromJSON();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-10 07:54:23 +00:00
|
|
|
/* 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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 18:23:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 19:21:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* AFFICHAGE DES UTILISATEURS DE LA BDD
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function selectUsers(){
|
|
|
|
|
|
|
|
// Creation de la requete
|
2016-02-11 15:00:41 +00:00
|
|
|
$requete = new manager\ModuleRequest('userDefault/getAll');
|
2016-02-04 23:07:03 +00:00
|
|
|
$answer = $requete->dispatch();
|
2016-02-04 19:21:01 +00:00
|
|
|
|
2016-02-05 08:18:01 +00:00
|
|
|
var_dump( \manager\ManagerError::explicit($answer->error) );
|
2016-02-05 07:54:21 +00:00
|
|
|
var_dump( $answer->get('users') );
|
2016-02-04 20:15:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-10 07:54:23 +00:00
|
|
|
}//selectUsers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* AFFICHAGE DES MACHINES DE LA BDD
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function selectMachines(){
|
|
|
|
|
|
|
|
// Creation de la requete
|
2016-02-11 15:00:41 +00:00
|
|
|
$requete = new manager\ModuleRequest('machineDefault/getAll');
|
2016-02-10 07:54:23 +00:00
|
|
|
$answer = $requete->dispatch();
|
|
|
|
|
|
|
|
var_dump( \manager\ManagerError::explicit($answer->error) );
|
|
|
|
var_dump( $answer->get('machines') );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-11 09:34:26 +00:00
|
|
|
}//selectMachines();
|
2016-02-04 20:15:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 19:21:01 +00:00
|
|
|
|
|
|
|
|
2016-02-04 20:15:43 +00:00
|
|
|
|
|
|
|
/* AFFICHAGE DES UTILISATEURS DE LA BDD (MIS EN PAGE)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function displayUsers(){
|
|
|
|
|
|
|
|
// Creation de la requete
|
2016-02-11 15:00:41 +00:00
|
|
|
$request = new \manager\ModuleRequest('userDefault/getAll');
|
2016-02-05 08:18:01 +00:00
|
|
|
$answer = $request->dispatch();
|
2016-02-04 23:07:03 +00:00
|
|
|
|
2016-02-11 15:00:41 +00:00
|
|
|
// Debug error
|
|
|
|
if( $answer->error != \manager\ManagerError::Success )
|
|
|
|
var_dump( \manager\ManagerError::explicit($answer->error) );
|
2016-02-04 20:15:43 +00:00
|
|
|
|
2016-02-11 15:00:41 +00:00
|
|
|
// display result
|
|
|
|
var_dump( $answer->getAll() );
|
2016-02-04 19:21:01 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-04 23:07:03 +00:00
|
|
|
}//displayUsers();
|
2016-02-04 19:21:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 18:23:16 +00:00
|
|
|
/* TEST DU DISPATCHER DES MANAGERS
|
|
|
|
*
|
|
|
|
* @return nomRetour<typeRetour> Description du retour
|
|
|
|
|
|
|
|
*/
|
|
|
|
function testModuleDispatcher(){
|
|
|
|
|
2016-02-04 19:21:01 +00:00
|
|
|
// Creation d'une requete en objet
|
2016-02-04 20:15:43 +00:00
|
|
|
$req1 = new manager\ModuleRequest('firstModule/returnvar', array('id_user' => 10, 'code' => '11-22-33-44') );
|
2016-02-04 19:21:01 +00:00
|
|
|
// Creation d'une requete a partir d'un json en <String>
|
|
|
|
$req2 = manager\ModuleRequest::fromString('{"path": "firstModule/returnvar", "data": {"id_user":10, "code":"11-22-33-44"}}');
|
2016-02-04 18:23:16 +00:00
|
|
|
|
2016-02-04 20:15:43 +00:00
|
|
|
var_dump( $req1->dispatch() );
|
2016-02-04 18:23:16 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-04 20:15:43 +00:00
|
|
|
}//testModuleDispatcher();
|
2016-02-04 18:23:16 +00:00
|
|
|
|
|
|
|
|
2016-02-11 09:34:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TEST DU DISPATCHER DES REPO
|
|
|
|
*
|
|
|
|
* @return nomRetour<typeRetour> Description du retour
|
|
|
|
|
|
|
|
*/
|
|
|
|
function testRepoDispatcher(){
|
|
|
|
|
|
|
|
// Creation d'une requete en objet
|
2016-02-11 15:00:41 +00:00
|
|
|
$req1 = new manager\Repo('user/getById', array('19'));
|
|
|
|
// $req1 = new manager\Repo('user/getByCode', array('92-55-B9-B3'));
|
2016-02-11 09:34:26 +00:00
|
|
|
var_dump( $req1->answer() );
|
|
|
|
|
|
|
|
if( $req1->error != manager\ManagerError::Success )
|
|
|
|
var_dump( manager\ManagerError::explicit($req1->error) );
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-11 15:00:41 +00:00
|
|
|
}//testRepoDispatcher();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* INSERTION (COMPOSITE) DES UTILISATEURS DE LA BDD
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function insertUsersComposite(){
|
|
|
|
|
|
|
|
// Creation de la requete
|
2016-02-12 23:04:00 +00:00
|
|
|
$request = new \manager\ModuleRequest('userDefault/create', array('92-55-B9-B3', 'b', 'bla', 'bla', 'bla@test.com', 'sadas', '1') );
|
2016-02-11 15:00:41 +00:00
|
|
|
$answer = $request->dispatch();
|
|
|
|
// Debug error
|
|
|
|
var_dump( $answer->error );
|
|
|
|
var_dump( \manager\ManagerError::explicit($answer->error) );
|
|
|
|
|
|
|
|
var_dump( $answer->getAll() );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-13 17:41:19 +00:00
|
|
|
}//insertUsersComposite();
|
|
|
|
|
2016-02-12 22:22:14 +00:00
|
|
|
|
2016-02-04 18:23:16 +00:00
|
|
|
?>
|