2016-07-02 15:10:41 +00:00
|
|
|
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
2016-02-04 18:23:16 +00:00
|
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
|
|
|
|
2016-02-14 11:37:19 +00:00
|
|
|
use \manager\ModuleRequest;
|
2016-07-06 15:36:26 +00:00
|
|
|
use \manager\sessionManager;
|
2016-02-14 11:37:19 +00:00
|
|
|
use \manager\ResourceDispatcher;
|
|
|
|
use \manager\ManagerError;
|
|
|
|
use \manager\Repo;
|
2016-07-02 15:46:59 +00:00
|
|
|
use \manager\Database;
|
2016-07-11 15:44:18 +00:00
|
|
|
use \manager\View;
|
2016-02-14 11:37:19 +00:00
|
|
|
|
2016-02-13 17:41:19 +00:00
|
|
|
debug();
|
2016-02-04 18:23:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-04 09:04:49 +00:00
|
|
|
/* INSERTION DES UTILISATEURS DANS LA BDD DEPUIS JSON
|
2016-02-04 18:23:16 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function insertUsersFromJSON(){
|
2016-07-09 13:06:59 +00:00
|
|
|
$json = file_get_contents(__ROOT__.'/config/generated_users.json');
|
2016-02-04 18:23:16 +00:00
|
|
|
$json = json_decode( $json, true );
|
|
|
|
|
|
|
|
// Pour chaque entree
|
|
|
|
foreach( $json as $user ){
|
|
|
|
|
2016-02-14 12:55:06 +00:00
|
|
|
// Creation de la requete
|
2016-07-04 13:45:29 +00:00
|
|
|
$request = new ModuleRequest('userDefault/create', [
|
2016-07-09 13:06:59 +00:00
|
|
|
'code' => $user['code'],
|
|
|
|
'username' => $user['username'],
|
|
|
|
'firstname' => $user['firstname'],
|
|
|
|
'lastname' => $user['lastname'],
|
|
|
|
'mail' => $user['email'],
|
|
|
|
'password' => $user['password'],
|
|
|
|
'status' => $user['status']
|
2016-07-04 13:45:29 +00:00
|
|
|
]);
|
2016-02-14 12:55:06 +00:00
|
|
|
$answer = $request->dispatch();
|
2016-07-09 13:06:59 +00:00
|
|
|
|
2016-02-14 12:55:06 +00:00
|
|
|
// Debug error
|
2016-07-09 13:06:59 +00:00
|
|
|
if( $answer->error != ManagerError::Success )
|
|
|
|
var_dump( $answer->error );
|
2016-02-04 18:23:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-14 13:16:47 +00:00
|
|
|
}//insertUsersFromJSON();
|
2016-02-04 18:23:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(){
|
2016-07-09 13:06:59 +00:00
|
|
|
$json = file_get_contents(__ROOT__.'/config/generated_machines.json');
|
2016-02-10 07:54:23 +00:00
|
|
|
$json = json_decode( $json, true );
|
|
|
|
|
|
|
|
// Pour chaque entree
|
|
|
|
foreach( $json as $machine ){
|
|
|
|
|
2016-02-14 13:16:47 +00:00
|
|
|
// Creation de la requete
|
2016-07-04 13:45:29 +00:00
|
|
|
$request = new ModuleRequest('machineDefault/create', [
|
2016-07-09 13:06:59 +00:00
|
|
|
'name' => $machine['name']
|
2016-07-04 13:45:29 +00:00
|
|
|
]);
|
2016-02-14 13:16:47 +00:00
|
|
|
$answer = $request->dispatch();
|
2016-07-09 13:06:59 +00:00
|
|
|
|
2016-02-14 13:16:47 +00:00
|
|
|
// Debug error
|
2016-07-09 13:06:59 +00:00
|
|
|
if( $answer->error != ManagerError::Success )
|
|
|
|
var_dump( $answer->error );
|
2016-02-10 07:54:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-14 14:17:26 +00:00
|
|
|
}//insertMachinesFromJSON();
|
2016-02-10 07:54:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-14 11:37:19 +00:00
|
|
|
$requete = new ModuleRequest('userDefault/getAll');
|
2016-02-04 23:07:03 +00:00
|
|
|
$answer = $requete->dispatch();
|
2016-02-04 19:21:01 +00:00
|
|
|
|
2016-02-14 11:37:19 +00:00
|
|
|
var_dump( 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-14 11:37:19 +00:00
|
|
|
$requete = new ModuleRequest('machineDefault/getAll');
|
2016-02-10 07:54:23 +00:00
|
|
|
$answer = $requete->dispatch();
|
|
|
|
|
2016-02-14 11:37:19 +00:00
|
|
|
var_dump( ManagerError::explicit($answer->error) );
|
2016-02-10 07:54:23 +00:00
|
|
|
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-14 11:37:19 +00:00
|
|
|
$request = new 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
|
2016-02-14 11:37:19 +00:00
|
|
|
if( $answer->error != ManagerError::Success )
|
|
|
|
var_dump( 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
|
2016-07-02 15:10:41 +00:00
|
|
|
|
2016-02-04 18:23:16 +00:00
|
|
|
*/
|
|
|
|
function testModuleDispatcher(){
|
|
|
|
|
2016-02-04 19:21:01 +00:00
|
|
|
// Creation d'une requete en objet
|
2016-07-04 13:45:29 +00:00
|
|
|
$req1 = new ModuleRequest('firstModule/returnvar', ['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>
|
2016-02-14 11:37:19 +00:00
|
|
|
$req2 = 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
|
2016-07-02 15:10:41 +00:00
|
|
|
|
2016-02-11 09:34:26 +00:00
|
|
|
*/
|
|
|
|
function testRepoDispatcher(){
|
|
|
|
|
|
|
|
// Creation d'une requete en objet
|
2016-07-04 13:45:29 +00:00
|
|
|
$req1 = new Repo('user/getById', ['19']);
|
2016-02-14 11:37:19 +00:00
|
|
|
// $req1 = new Repo('user/getByCode', array('92-55-B9-B3'));
|
2016-02-11 09:34:26 +00:00
|
|
|
var_dump( $req1->answer() );
|
|
|
|
|
2016-02-14 11:37:19 +00:00
|
|
|
if( $req1->error != ManagerError::Success )
|
|
|
|
var_dump( ManagerError::explicit($req1->error) );
|
2016-02-11 09:34:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
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-07-04 13:45:29 +00:00
|
|
|
$request = new ModuleRequest('userDefault/create', ['92-55-B9-B1', 'b', 'bla', 'bla', 'bla@test.com', 'sadas', '1'] );
|
2016-02-11 15:00:41 +00:00
|
|
|
$answer = $request->dispatch();
|
|
|
|
// Debug error
|
2016-02-14 11:37:19 +00:00
|
|
|
if( $answer->error != ManagerError::Success )
|
|
|
|
var_dump( ManagerError::explicit($answer->error) );
|
2016-02-11 15:00:41 +00:00
|
|
|
|
|
|
|
var_dump( $answer->getAll() );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-14 12:28:35 +00:00
|
|
|
}//insertUsersComposite();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* RETOURNE LES GROUPES D'UN UTILISATEUR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function getUserClusters(){
|
|
|
|
$id_user = 115;
|
|
|
|
|
|
|
|
// Groupes de l'utilisateur 'a'
|
2016-07-04 13:45:29 +00:00
|
|
|
$getUser1Clusters = new Repo('user/getClusters', [$id_user]);
|
2016-02-14 12:28:35 +00:00
|
|
|
$user1Clusters = $getUser1Clusters->answer();
|
|
|
|
var_dump( $user1Clusters );
|
|
|
|
|
|
|
|
// On ajoute un groupe a l'utilisateur 100
|
|
|
|
$linkA = new Repo('cluster/link', array($user1Clusters[0]['id_cluster'], 100) );
|
|
|
|
var_dump( $linkA->answer() );
|
|
|
|
$getUser2Clusters = new Repo('user/getClusters', array(100));
|
|
|
|
var_dump( $getUser2Clusters->answer() );
|
|
|
|
|
|
|
|
// On retire un groupe a l'utilisateur 100
|
|
|
|
$unlinkA = new Repo('cluster/unlink', array($user1Clusters[0]['id_cluster'], 100) );
|
|
|
|
var_dump( $linkA->answer() );
|
|
|
|
$getUser2Clusters = new Repo('user/getClusters', array(100));
|
|
|
|
var_dump( $getUser2Clusters->answer() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}//getUserClusters();
|
2016-02-14 14:53:59 +00:00
|
|
|
|
|
|
|
|
2016-02-16 08:03:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* MODIFICATION D'UN UTILISATEUR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function editUser(){
|
|
|
|
$id_user = 48;
|
|
|
|
|
|
|
|
$request = new ModuleRequest('userDefault/edit', array(
|
|
|
|
'B1-87-EA-BF',
|
|
|
|
'Abigail',
|
|
|
|
'Mcmillan',
|
|
|
|
'Savage',
|
|
|
|
'mcmillansavage@corecom.com',
|
|
|
|
'password',
|
|
|
|
0
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
// ["B1-87-EA-BF","Abigail01","Mcmillan","Savage","mcmillansavage@corecom.com","password",0]
|
|
|
|
|
|
|
|
var_dump( $request->dispatch() );
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2016-02-16 08:35:37 +00:00
|
|
|
}//editUser();
|
2016-02-16 08:03:12 +00:00
|
|
|
|
2016-07-02 15:46:59 +00:00
|
|
|
|
2016-02-16 23:15:47 +00:00
|
|
|
// new ResourceDispatcher('f/svg/search/st/sub-menu-side/ff0000', true);
|
2016-02-16 22:42:07 +00:00
|
|
|
|
2016-07-02 15:46:59 +00:00
|
|
|
|
|
|
|
|
2016-07-04 12:39:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
function createWarehouse(){
|
|
|
|
|
2016-07-04 15:44:21 +00:00
|
|
|
$insert = new Repo('admin/create', [
|
|
|
|
'FirstAdmin',
|
|
|
|
'adminmail@gmail.com',
|
|
|
|
'AdminPassword'
|
|
|
|
]);
|
2016-07-04 12:39:27 +00:00
|
|
|
var_dump( $insert->answer() );
|
|
|
|
|
|
|
|
|
2016-07-04 15:44:21 +00:00
|
|
|
$getAll = new Repo('admin/getAll');
|
2016-07-06 15:36:26 +00:00
|
|
|
}//createWarehouse();
|
2016-07-02 15:46:59 +00:00
|
|
|
|
2016-07-11 15:44:18 +00:00
|
|
|
debug();
|
|
|
|
$myView = new View('users.aaa', ['var1'=>'coucou']);
|
|
|
|
$myView->view();
|
|
|
|
|
2016-07-02 15:46:59 +00:00
|
|
|
|
2016-07-02 15:10:41 +00:00
|
|
|
?>
|