diff --git a/config/modules.json b/config/modules.json index bbe7b3b..3ade3bc 100755 --- a/config/modules.json +++ b/config/modules.json @@ -94,13 +94,10 @@ "username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)" }, "firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,letters)" }, "lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,letters)" }, - "mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail" }, - "password": { "description": "Mot de passe de l'utilisateur.", "type": "text" }, - "status": { "description": "Status de l'utilisateur.", "type": "status" } + "mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail" } }, "output": { - "id_user": { "description": "UID de l'utilisateur créé.", "type": "id" }, - "id_group": { "description": "UID du groupe de l'utilisateur.", "type": "id" } + "id_user": { "description": "UID de l'utilisateur créé.", "type": "id" } } }, @@ -255,8 +252,7 @@ "name": { "description": "Nom de la machine.", "type": "varchar(1,30,alphanumeric)" } }, "output": { - "id_machine": { "description": "UID de la machine.", "type": "id" }, - "id_cluster": { "description": "UID du groupe de la machine.", "type": "id" } + "id_machine": { "description": "UID de la machine.", "type": "id" } } }, diff --git a/manager/module/machineDefault.php b/manager/module/machineDefault.php index 1708fd0..1a538ae 100755 --- a/manager/module/machineDefault.php +++ b/manager/module/machineDefault.php @@ -34,26 +34,10 @@ - /* [2] Creation du groupe de meme nom que la machine - =========================================================*/ - $create_group = new Repo('cluster/create', [ - $_SESSION['WAREHOUSE']['id'], - $name, - clusterRepo::MACHINE_CLASS, - $id_machine - ]); - $id_group = $create_group->answer(); - - // Si une erreur est retournee, on retourne une erreur - if( $id_group === false ) - return ['ModuleError' => ManagerError::ModuleError]; - - - /* [3] Gestion du retour + /* [2] Gestion du retour =========================================================*/ return [ - 'id_machine' => $id_machine, - 'id_cluster' => $id_group + 'id_machine' => $id_machine ]; } diff --git a/manager/module/userDefault.php b/manager/module/userDefault.php index 085bb9b..6a9e8a1 100755 --- a/manager/module/userDefault.php +++ b/manager/module/userDefault.php @@ -44,7 +44,7 @@ /* [2] Gestion du retour =========================================================*/ return [ - 'id_user' => $id_user, + 'id_user' => $id_user ]; } diff --git a/manager/repo/user.php b/manager/repo/user.php index ac7b3f9..091b63c 100755 --- a/manager/repo/user.php +++ b/manager/repo/user.php @@ -31,11 +31,12 @@ if( !$check_unique ) return false; + /* [2] Creation de l'utilisateur =========================================================*/ $insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, id_warehouse, code, username, firstname, lastname, mail) VALUES(DEFAULT, :id_warehouse, :code, :username, :firstname, :lastname, :mail)"); - $insert_user->execute([ + $inserted = $insert_user->execute([ ':id_warehouse' => $id_warehouse, ':code' => $code, ':username' => $username, @@ -49,7 +50,7 @@ $check_user = self::getByCode($id_warehouse, $code); // Si n'existe pas on retourne FALSE - if( $check_user === false ) + if( !$inserted || $check_user === false ) return false; // Sinon, on retourne son id @@ -285,7 +286,7 @@ public static function getByCode($id_warehouse, $code){ /* [1] On rédige/execute la requête =========================================================*/ - $get = Database::getPDO()->prepare("SELECT u.id_user, u.code, u.username, u.firstname, u.lastname, u.mail, u.status + $get = Database::getPDO()->prepare("SELECT u.id_user, u.code, u.username, u.firstname, u.lastname, u.mail FROM user as u WHERE u.id_warehouse = :id_warehouse AND u.code = :code"); diff --git a/view/js/users-min.js b/view/js/users-min.js index 282d3a3..2ffa815 100644 --- a/view/js/users-min.js +++ b/view/js/users-min.js @@ -6,7 +6,7 @@ function(a){pageManager.vars[1]=a.target.getData("user");navSubMenu("edit");docu api.send(c,function(c){if(0!=c.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1)} if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),username:document.querySelector(section.create.text+"#create_username"),firstname:document.querySelector(section.create.text+"#create_firstname"),lastname:document.querySelector(section.create.text+"#create_lastname"),mail:document.querySelector(section.create.text+"#create_mail"),submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker; createChecker.append(section.create.input.code,format_code,"01-AB-CD-23");section.create.input.code.addEventListener("keyup",function(a){a.target.value=a.target.value.toUpperCase();createChecker.check(a.target)||createChecker.correct(a.target,!1)},!1);section.create.input.submit.addEventListener("click",function(a){a.preventDefault();api.send({path:"userDefault/create",code:section.create.input.code.value,username:section.create.input.username.value,firstname:section.create.input.firstname.value, -lastname:section.create.input.lastname.value,mail:section.create.input.mail.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},!1)} +lastname:section.create.input.lastname.value,mail:section.create.input.mail.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500),document.location=""):console.error("ModuleError::"+a.ModuleError)})},!1)} if(null!=section.remove.element){var autofill_remove=function(){var a="",c="",d="",b=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_user,c=found_remove[searchindex_remove].username,d=found_remove[searchindex_remove].code,b=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.username.value=c;section.remove.input.code.value=d;section.remove.input.submit.disabled= b};section.remove.input={search:{view:document.querySelector(section.remove.text+".remove_search_view"),num:document.querySelector(section.remove.text+".remove_search_num"),sum:document.querySelector(section.remove.text+".remove_search_sum"),keyword:document.querySelector(section.remove.text+"#remove_search_keyword"),id:document.querySelector(section.remove.text+"#remove_search_id"),submit:document.querySelector(section.remove.text+"#remove_search_submit")},code:document.querySelector(section.remove.text+ "#remove_code"),username:document.querySelector(section.remove.text+"#remove_username"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove="",found_remove=[],searchindex_remove=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"userDefault/getById",id_user:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_remove=[a.user],searchindex_remove=0,autofill_remove())});section.remove.input.search.submit.addEventListener("click",function(a){a.preventDefault(); diff --git a/view/js/users.js b/view/js/users.js index 388d797..87b0f63 100755 --- a/view/js/users.js +++ b/view/js/users.js @@ -206,6 +206,8 @@ if( section.create.element != null ){ console.log('Utilisateur cree!'); section.create.input.submit.anim('active', 1500); + + document.location = ''; }else // Erreur console.error('ModuleError::'+answer.ModuleError);