Page 'users/view', 'users/remove', 'users/edit' DONE + les repos/modules utiles à leur fonctionnement DONE + les liens entre les pages (excepté la page 'users/groups' vers les pages 'groups/...') DONE
This commit is contained in:
parent
eeee5be121
commit
20ca00c1e1
|
@ -17,8 +17,6 @@
|
|||
* @firstname<String> Prenom de l'utilisateur
|
||||
* @lastcode<String> Nom de l'utilisateur
|
||||
* @mail<String> Adresse email de l'utilisateur
|
||||
* @password<String> Mot de passe de l'utilisateur
|
||||
* @status<String> Status de l'utilisateur
|
||||
*
|
||||
* @return status<Boolean> Retourne si oui ou non, tout s'est bien passe
|
||||
*
|
||||
|
@ -26,11 +24,7 @@
|
|||
public static function create($params){
|
||||
extract($params);
|
||||
|
||||
/* [1] Normalisation + verification des donnees
|
||||
=========================================================*/
|
||||
$password_hash = sessionManager::secure_hash($password);
|
||||
|
||||
/* [2] Creation de l'utilisateur
|
||||
/* [1] Creation de l'utilisateur
|
||||
=========================================================*/
|
||||
$create_user = new Repo('user/create', [
|
||||
$_SESSION['WAREHOUSE']['id'],
|
||||
|
@ -38,9 +32,7 @@
|
|||
$username,
|
||||
$firstname,
|
||||
$lastname,
|
||||
$mail,
|
||||
$password_hash,
|
||||
$status
|
||||
$mail
|
||||
]);
|
||||
$id_user = $create_user->answer();
|
||||
|
||||
|
@ -49,28 +41,10 @@
|
|||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
/* [3] Creation du groupe de meme nom que l'username
|
||||
=========================================================*/
|
||||
$create_cluster = new Repo('user_cluster/create', [
|
||||
$_SESSION['WAREHOUSE']['id'],
|
||||
$username,
|
||||
clusterRepo::USER_CLASS,
|
||||
$id_user
|
||||
]);
|
||||
$id_cluster = $create_cluster->answer();
|
||||
|
||||
// Si une erreur est retournee, on retourne une erreur
|
||||
if( $id_cluster === false )
|
||||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
/* [4] Gestion du retour
|
||||
/* [2] Gestion du retour
|
||||
=========================================================*/
|
||||
return [
|
||||
'id_user' => $id_user,
|
||||
'id_cluster' => $id_cluster
|
||||
'id_user' => $id_user,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -299,8 +273,6 @@
|
|||
* @firstname<String> Prenom de l'utilisateur
|
||||
* @lastcode<String> Nom de l'utilisateur
|
||||
* @mail<String> Adresse email de l'utilisateur
|
||||
* @password<String> Mot de passe de l'utilisateur
|
||||
* @status<String> Status de l'utilisateur
|
||||
*
|
||||
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
||||
*
|
||||
|
@ -314,7 +286,7 @@
|
|||
$_SESSION['WAREHOUSE']['id'],
|
||||
$id_user
|
||||
]);
|
||||
$user_data = $user_exists->answer();
|
||||
$user_data = $user_exists->answer();
|
||||
|
||||
// Si on a recupere aucun utilisateur, on retourne une erreur
|
||||
if( !is_array($user_data) )
|
||||
|
@ -324,17 +296,13 @@
|
|||
|
||||
/* [2] Normalisation + verification des donnees
|
||||
=========================================================*/
|
||||
$password_hash = sessionManager::secure_hash($password);
|
||||
|
||||
/* (1) Verification des parametres (si non nul + differents)*/
|
||||
$diff_param = [
|
||||
'code' => !is_null($code) && $user_data['code'] != $code,
|
||||
'username' => !is_null($username) && $user_data['username'] != $username,
|
||||
'firstname' => !is_null($firstname) && $user_data['firstname'] != $firstname,
|
||||
'lastname' => !is_null($lastname) && $user_data['lastname'] != $lastname,
|
||||
'mail' => !is_null($mail) && $user_data['mail'] != $mail,
|
||||
'password' => !is_null($password) && $user_data['password'] != $password_hash,
|
||||
'status' => !is_null($status) && $user_data['status'] != $status
|
||||
'mail' => !is_null($mail) && $user_data['mail'] != $mail
|
||||
];
|
||||
|
||||
/* (2) Gestion des parametres optionnels */
|
||||
|
@ -343,9 +311,7 @@
|
|||
'username' => ($diff_param['username']) ? $username : $user_data['username'],
|
||||
'firstname' => ($diff_param['firstname']) ? $firstname : $user_data['firstname'],
|
||||
'lastname' => ($diff_param['lastname']) ? $lastname : $user_data['lastname'],
|
||||
'mail' => ($diff_param['mail']) ? $mail : $user_data['mail'],
|
||||
'password' => ($diff_param['password']) ? $password : $user_data['password'],
|
||||
'status' => ($diff_param['status']) ? $status : $user_data['status'],
|
||||
'mail' => ($diff_param['mail']) ? $mail : $user_data['mail']
|
||||
];
|
||||
|
||||
|
||||
|
@ -360,9 +326,7 @@
|
|||
$opt_data['username'],
|
||||
$opt_data['firstname'],
|
||||
$opt_data['lastname'],
|
||||
$opt_data['mail'],
|
||||
$opt_data['password'],
|
||||
$opt_data['status']
|
||||
$opt_data['mail']
|
||||
]);
|
||||
|
||||
|
||||
|
@ -391,36 +355,8 @@
|
|||
]);
|
||||
$deleted_user = $del_user->answer();
|
||||
|
||||
if( !$deleted_user )
|
||||
return [ 'status' => false ];
|
||||
|
||||
|
||||
/* [2] On récupère le groupe personnel
|
||||
=========================================================*/
|
||||
$get_personal_cluster = new Repo('user_cluster/getPersonal', [
|
||||
$id_warehouse,
|
||||
$id_user,
|
||||
clusterRepo::USER_CLASS
|
||||
]);
|
||||
|
||||
$personal_cluster = $get_personal_cluster->answer();
|
||||
|
||||
// si erreur
|
||||
if( $personal_cluster === false )
|
||||
return [ 'status' => false ];
|
||||
|
||||
|
||||
/* [3] On supprime le groupe personnel
|
||||
=========================================================*/
|
||||
$del_cluster = new Repo('user_cluster/delete', [
|
||||
$id_warehouse,
|
||||
$personal_cluster['id_cluster']
|
||||
]);
|
||||
|
||||
$deleted = $del_cluster->answer();
|
||||
|
||||
|
||||
return [ 'status' => $deleted ];
|
||||
return [ 'status' => $deleted_user ];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,14 +16,12 @@
|
|||
* @firstname<String> Prenom de l'utilisateur
|
||||
* @lastcode<String> Nom de l'utilisateur
|
||||
* @mail<String> Adresse email de l'utilisateur
|
||||
* @password<String> Mot de passe de l'utilisateur
|
||||
* @status<String> Status de l'utilisateur
|
||||
*
|
||||
* @return id_user<int> Renvoie l'UID de l'utilisateur cree
|
||||
* Renvoie FALSE si une erreur occure
|
||||
*
|
||||
*/
|
||||
public static function create($id_warehouse, $code, $username, $firstname, $lastname, $mail, $password, $status){
|
||||
public static function create($id_warehouse, $code, $username, $firstname, $lastname, $mail){
|
||||
/* [1] Verification de l'unicite de code+username
|
||||
=========================================================*/
|
||||
$check_unique = !is_array(self::getByCode($id_warehouse, $code));
|
||||
|
@ -35,17 +33,15 @@
|
|||
|
||||
/* [2] Creation de l'utilisateur
|
||||
=========================================================*/
|
||||
$insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, id_warehouse, code, username, firstname, lastname, mail, password, status)
|
||||
VALUES(DEFAULT, :id_warehouse, :code, :username, :firstname, :lastname, :mail, :password, :status)");
|
||||
$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([
|
||||
':id_warehouse' => $id_warehouse,
|
||||
':code' => $code,
|
||||
':username' => $username,
|
||||
':firstname' => $firstname,
|
||||
':lastname' => $lastname,
|
||||
':mail' => $mail,
|
||||
':password' => $password,
|
||||
':status' => $status
|
||||
':mail' => $mail
|
||||
]);
|
||||
|
||||
/* [3] On retourne l'id_user ou FALSE si erreur
|
||||
|
@ -144,13 +140,11 @@
|
|||
* @firstname<String> Prenom de l'utilisateur
|
||||
* @lastcode<String> Nom de l'utilisateur
|
||||
* @mail<String> Adresse email de l'utilisateur
|
||||
* @password<String> Mot de passe de l'utilisateur
|
||||
* @status<String> Status de l'utilisateur
|
||||
*
|
||||
* @return status<Boolean> Renvoie si oui ou non tout s'est bien passe
|
||||
*
|
||||
*/
|
||||
public static function edit($id_warehouse, $id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||
public static function edit($id_warehouse, $id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null){
|
||||
/* [1] Verification de l'unicite de code+username (si differents)
|
||||
=========================================================*/
|
||||
// On recupere les utilisateurs ayant le meme code ou username (si existent)
|
||||
|
@ -172,9 +166,7 @@
|
|||
username = :username,
|
||||
firstname = :firstname,
|
||||
lastname = :lastname,
|
||||
mail = :mail,
|
||||
password = :password,
|
||||
status = :status
|
||||
mail = :mail
|
||||
WHERE id_user = :id_user
|
||||
AND id_warehouse = :id_warehouse");
|
||||
$edit_user->execute([
|
||||
|
@ -183,8 +175,6 @@
|
|||
':firstname' => $firstname,
|
||||
':lastname' => $lastname,
|
||||
':mail' => $mail,
|
||||
':password' => $password,
|
||||
':status' => $status,
|
||||
':id_user' => $id_user,
|
||||
':id_warehouse' => $id_warehouse
|
||||
]);
|
||||
|
@ -201,8 +191,6 @@
|
|||
$checker = $checker && $check_user['firstname'] == $firstname;
|
||||
$checker = $checker && $check_user['lastname'] == $lastname;
|
||||
$checker = $checker && $check_user['mail'] == $mail;
|
||||
$checker = $checker && $check_user['password'] == $password;
|
||||
$checker = $checker && $check_user['status'] == $status;
|
||||
|
||||
// On retourne l'etat de la modification
|
||||
return $checker;
|
||||
|
|
|
@ -2,20 +2,20 @@ var section={view:{text:'#CONTAINER > section[data-sublink="view"] ',element:doc
|
|||
edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')}};
|
||||
if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],document.getElementById(pageManager.vars[1]).addClass("selected"));section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-user]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-user]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-user][data-group]"),add:document.querySelectorAll(section.view.text+
|
||||
".add-group[data-user]")};section.view.searchbar.addEventListener("keyup",function(a){api.send({path:"userDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError&&(console.log(a.users.length),0==a.ModuleError)){for(var d=[],c=0;c<a.users.length;c++)d.push(a.users[c].id_user);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<d.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
|
||||
function(a){pageManager.vars[1]=a.target.getData("user");autofill_edit(pageManager.vars[1]);navSubMenu("edit")},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("user");autofill_remove(pageManager.vars[1]);navSubMenu("remove")},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(a){var b={path:"userDefault/unlink",id_user:a.target.getData("user"),
|
||||
id_cluster:a.target.getData("group")};api.send(b,function(b){if(0!=b.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"),password:document.querySelector(section.create.text+"#create_password"),status:document.querySelector(section.create.text+
|
||||
"#create_status"),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,password:section.create.input.password.value,status:section.create.input.status.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
function(a){pageManager.vars[1]=a.target.getData("user");navSubMenu("edit");document.location=""},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("user");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(a){var b={path:"userDefault/unlink",id_user:a.target.getData("user"),id_cluster:a.target.getData("group")};
|
||||
api.send(b,function(b){if(0!=b.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)}
|
||||
if(null!=section.remove.element){var autofill_remove=function(){var a="",b="",d="",c=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_user,b=found_remove[searchindex_remove].username,d=found_remove[searchindex_remove].code,c=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.username.value=b;section.remove.input.code.value=d;section.remove.input.submit.disabled=
|
||||
c};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();
|
||||
if(""!=section.remove.input.search.keyword.value)if(section.remove.input.search.keyword.value==lastkeywords_remove)searchindex_remove=(searchindex_remove+1)%found_remove.length,autofill_remove();else{var b={path:"userDefault/search",keywords:section.remove.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.remove.input.search.submit.anim("active",1E3),searchindex_remove=0,found_remove=a.users,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove());
|
||||
lastkeywords_remove=b.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&api.send({path:"userDefault/delete",id_user:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Utilisateur supprime!"),section.remove.input.submit.anim("active",1500),autofill_remove(null)):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
lastkeywords_remove=b.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&api.send({path:"userDefault/delete",id_user:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Utilisateur supprime!"),section.remove.input.submit.anim("active",1500),pageManager.vars[1]="",navSubMenu("view"),document.location=""):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
if(null!=section.edit.element){var autofill_edit=function(){var a="",b="",d="",c="",e="",f="",g=!0;null==found_edit[searchindex_edit]?searchindex_edit=section.edit.input.search.num.innerHTML=0:(a=found_edit[searchindex_edit].id_user,b=found_edit[searchindex_edit].code,d=found_edit[searchindex_edit].username,c=found_edit[searchindex_edit].firstname,e=found_edit[searchindex_edit].lastname,f=found_edit[searchindex_edit].mail,g=!1,section.edit.input.search.num.innerHTML=searchindex_edit+1);section.edit.input.search.id.value=
|
||||
a;section.edit.input.code.value=b;section.edit.input.username.value=d;section.edit.input.firstname.value=c;section.edit.input.lastname.value=e;section.edit.input.mail.value=f;section.edit.input.submit.disabled=g};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),num:document.querySelector(section.edit.text+".edit_search_num"),sum:document.querySelector(section.edit.text+".edit_search_sum"),keyword:document.querySelector(section.edit.text+"#edit_search_keyword"),
|
||||
id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+"#edit_search_submit")},code:document.querySelector(section.edit.text+"#edit_code"),username:document.querySelector(section.edit.text+"#edit_username"),firstname:document.querySelector(section.edit.text+"#edit_firstname"),lastname:document.querySelector(section.edit.text+"#edit_lastname"),mail:document.querySelector(section.edit.text+"#edit_mail"),password:document.querySelector(section.edit.text+
|
||||
"#edit_password"),submit:document.querySelector(section.edit.text+"#edit_submit")};var lastkeywords_edit="",found_edit=[],searchindex_edit=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_edit=[a.user],searchindex_edit=0,autofill_edit())});section.edit.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.keyword.value)if(section.edit.input.search.keyword.value==
|
||||
lastkeywords_edit)searchindex_edit=(searchindex_edit+1)%found_edit.length,autofill_edit();else{var b={path:"userDefault/search",keywords:section.edit.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.edit.input.search.submit.anim("active",1E3),searchindex_edit=0,found_edit=a.users,section.edit.input.search.sum.innerHTML=found_edit.length,autofill_edit());lastkeywords_edit=b.keywords})}},!1);section.edit.input.submit.addEventListener("click",function(a){a.preventDefault();
|
||||
if(""!=section.edit.input.search.id.value){var b={path:"userDefault/edit",id_user:parseInt(section.edit.input.search.id.value),code:section.edit.input.code.value,username:section.edit.input.username.value,firstname:section.edit.input.firstname.value,lastname:section.edit.input.lastname.value,mail:section.edit.input.mail.value,password:section.edit.input.password.value,status:section.edit.input.status.value};api.send(b,function(a){console.log(a);0==a.ModuleError&&1==a.status?(console.log("Utilisateur modifie!"),
|
||||
section.edit.input.submit.anim("active",1500),pageManager.vars[1]=b.id_user,navSubMenu("view"),document.location=""):console.error("ModuleError::"+a.ModuleError)})}},!1)};
|
||||
id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+"#edit_search_submit")},code:document.querySelector(section.edit.text+"#edit_code"),username:document.querySelector(section.edit.text+"#edit_username"),firstname:document.querySelector(section.edit.text+"#edit_firstname"),lastname:document.querySelector(section.edit.text+"#edit_lastname"),mail:document.querySelector(section.edit.text+"#edit_mail"),submit:document.querySelector(section.edit.text+
|
||||
"#edit_submit")};var lastkeywords_edit="",found_edit=[],searchindex_edit=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_edit=[a.user],searchindex_edit=0,autofill_edit())});section.edit.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.keyword.value)if(section.edit.input.search.keyword.value==lastkeywords_edit)searchindex_edit=
|
||||
(searchindex_edit+1)%found_edit.length,autofill_edit();else{var b={path:"userDefault/search",keywords:section.edit.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.edit.input.search.submit.anim("active",1E3),searchindex_edit=0,found_edit=a.users,section.edit.input.search.sum.innerHTML=found_edit.length,autofill_edit());lastkeywords_edit=b.keywords})}},!1);section.edit.input.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.id.value){var b=
|
||||
{path:"userDefault/edit",id_user:parseInt(section.edit.input.search.id.value),code:section.edit.input.code.value,username:section.edit.input.username.value,firstname:section.edit.input.firstname.value,lastname:section.edit.input.lastname.value,mail:section.edit.input.mail.value};api.send(b,function(a){console.log(a);0==a.ModuleError&&1==a.status?(console.log("Utilisateur modifie!"),section.edit.input.submit.anim("active",1500),pageManager.vars[1]=b.id_user,navSubMenu("view"),document.location=""):
|
||||
console.error("ModuleError::"+a.ModuleError)})}},!1)};
|
||||
|
|
|
@ -96,8 +96,8 @@ if( section.view.element != null ){
|
|||
|
||||
section.view.link.edit[i].addEventListener('click', function(e){
|
||||
pageManager.vars[1] = e.target.getData('user');
|
||||
autofill_edit(pageManager.vars[1]);
|
||||
navSubMenu('edit');
|
||||
document.location = '';
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ if( section.view.element != null ){
|
|||
|
||||
section.view.link.remove[i].addEventListener('click', function(e){
|
||||
pageManager.vars[1] = e.target.getData('user');
|
||||
autofill_remove(pageManager.vars[1]);
|
||||
navSubMenu('remove');
|
||||
document.location = '';
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
@ -163,8 +163,6 @@ if( section.create.element != null ){
|
|||
firstname: document.querySelector(section.create.text + '#create_firstname'),
|
||||
lastname: document.querySelector(section.create.text + '#create_lastname'),
|
||||
mail: document.querySelector(section.create.text + '#create_mail'),
|
||||
password: document.querySelector(section.create.text + '#create_password'),
|
||||
status: document.querySelector(section.create.text + '#create_status'),
|
||||
|
||||
submit: document.querySelector(section.create.text + '#create_submit')
|
||||
}
|
||||
|
@ -194,9 +192,7 @@ if( section.create.element != null ){
|
|||
username: section.create.input.username.value,
|
||||
firstname: section.create.input.firstname.value,
|
||||
lastname: section.create.input.lastname.value,
|
||||
mail: section.create.input.mail.value,
|
||||
password: section.create.input.password.value,
|
||||
status: section.create.input.status.value
|
||||
mail: section.create.input.mail.value
|
||||
};
|
||||
|
||||
api.send(request, function(answer){
|
||||
|
@ -400,8 +396,10 @@ if( section.remove.element != null ){
|
|||
console.log('Utilisateur supprime!');
|
||||
|
||||
section.remove.input.submit.anim('active', 1500);
|
||||
// On vide le formulaire
|
||||
autofill_remove(null);
|
||||
|
||||
pageManager.vars[1] = '';
|
||||
navSubMenu('view');
|
||||
document.location = '';
|
||||
}else // Erreur
|
||||
console.error('ModuleError::'+answer.ModuleError);
|
||||
});
|
||||
|
@ -441,7 +439,6 @@ if( section.edit.element != null ){
|
|||
firstname: document.querySelector(section.edit.text + '#edit_firstname'),
|
||||
lastname: document.querySelector(section.edit.text + '#edit_lastname'),
|
||||
mail: document.querySelector(section.edit.text + '#edit_mail'),
|
||||
password: document.querySelector(section.edit.text + '#edit_password'),
|
||||
|
||||
submit: document.querySelector(section.edit.text + '#edit_submit')
|
||||
};
|
||||
|
@ -602,9 +599,7 @@ if( section.edit.element != null ){
|
|||
username: section.edit.input.username.value,
|
||||
firstname: section.edit.input.firstname.value,
|
||||
lastname: section.edit.input.lastname.value,
|
||||
mail: section.edit.input.mail.value,
|
||||
password: section.edit.input.password.value,
|
||||
status: section.edit.input.status.value
|
||||
mail: section.edit.input.mail.value
|
||||
};
|
||||
|
||||
api.send(request, function(answer){
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
echo "<input id='create_firstname' type='text' placeholder='Firstname'><br>";
|
||||
echo "<input id='create_lastname' type='text' placeholder='Lastname'><br>";
|
||||
echo "<input id='create_mail' type='text' placeholder='Mail'><br>";
|
||||
echo "<input id='create_password' type='password' placeholder='Password'><br>";
|
||||
echo "<button id='create_submit'>Créer</button>";
|
||||
echo "</form>";
|
||||
|
||||
|
@ -147,7 +146,6 @@
|
|||
echo "<input id='edit_firstname' type='text' placeholder='Firstname'><br>";
|
||||
echo "<input id='edit_lastname' type='text' placeholder='Lastname'><br>";
|
||||
echo "<input id='edit_mail' type='text' placeholder='Mail'><br>";
|
||||
echo "<input id='edit_password' type='password' placeholder='Password'><br>";
|
||||
echo "<button id='edit_submit' disabled>Modifier</button>";
|
||||
echo "</form>";
|
||||
|
||||
|
|
Loading…
Reference in New Issue