- [x] [users.js][userDefault][userRepo] Gestion de la nouvelle modification (avec recherche)
This commit is contained in:
parent
0496fc33f6
commit
507bb6488f
|
@ -297,6 +297,7 @@
|
|||
|
||||
/* MODIFIE UN UTILISATEUR DONNEE
|
||||
*
|
||||
* @id_user<int> UID de l'utilisateur
|
||||
* @code<String> Code RFID de l'utilisateur
|
||||
* @username<String> Identifiant l'utilisateur
|
||||
* @firstname<String> Prenom de l'utilisateur
|
||||
|
@ -308,12 +309,13 @@
|
|||
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
||||
*
|
||||
*/
|
||||
public static function edit($code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||
public static function edit($id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||
/* [1] Normalisation + verification des donnees
|
||||
=========================================================*/
|
||||
$password_hash = sessionManager::secure_sha1($password);
|
||||
|
||||
$correct_param = Database::check('user.code', $code);
|
||||
$correct_param = Database::check('auto_increment_id', $id_user);
|
||||
$correct_param = $correct_param && Database::check('user.code', $code);
|
||||
$correct_param = $correct_param && Database::check('user.username', $username);
|
||||
$correct_param = $correct_param && Database::check('user.firstname', $firstname);
|
||||
$correct_param = $correct_param && Database::check('user.lastname', $lastname);
|
||||
|
@ -326,27 +328,19 @@
|
|||
return array('ModuleError' => ManagerError::ParamError);
|
||||
|
||||
|
||||
/* [2] Recuperation de l'UID de l'utilisateur
|
||||
/* [2] On verifie l'existence de l'utilisateur
|
||||
=========================================================*/
|
||||
$getByCode = new Repo('user/getByCode', array($code));
|
||||
$getByUsername = new Repo('user/getByUsername', array($username));
|
||||
|
||||
// On recupere les resultats
|
||||
$uidbycode = $getByCode->answer();
|
||||
$uidbyusername = $getByUsername->answer();
|
||||
|
||||
// On recupere l'utilisateur (si recupere avec code OU username)
|
||||
$user = (is_array($uidbyusername)) ? $uidbyusername : null;
|
||||
$user = (is_array($uidbycode)) ? $uidbycode : $user;
|
||||
$user_exists = new Repo('user/getById', array($id_user));
|
||||
$user_exists = $user_exists->answer();
|
||||
|
||||
// Si on a recupere aucun utilisateur, on retourne une erreur
|
||||
if( !is_array($user) )
|
||||
if( !is_array($user_exists) )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
|
||||
|
||||
/* [3] Modification de l'utilisateur
|
||||
=========================================================*/
|
||||
$request = new Repo('user/edit', array($user['id_user'], $code, $username, $firstname, $lastname, $mail, $password_hash, $status));
|
||||
$request = new Repo('user/edit', array($id_user, $code, $username, $firstname, $lastname, $mail, $password_hash, $status));
|
||||
$answer = $request->answer();
|
||||
|
||||
return array(
|
||||
|
|
|
@ -340,8 +340,6 @@
|
|||
$checker = $check_user['id_user'] == $id_user;
|
||||
$checker = $checker && $check_user['code'] == $code;
|
||||
$checker = $checker && $check_user['username'] == $username;
|
||||
var_dump($check_user['username']);
|
||||
var_dump($username);
|
||||
$checker = $checker && $check_user['firstname'] == $firstname;
|
||||
$checker = $checker && $check_user['lastname'] == $lastname;
|
||||
$checker = $checker && $check_user['mail'] == $mail;
|
||||
|
|
5
todo.md
5
todo.md
|
@ -7,7 +7,8 @@
|
|||
############
|
||||
# EN COURS #
|
||||
############
|
||||
- [ ] [users.js][userDefault][userRepo] Gestion de la nouvelle modification (avec recherche)
|
||||
|
||||
- [ ] [machineDefault] Implementer la modification
|
||||
|
||||
- [ ] [view/js/machines] Recherche instantanee
|
||||
- [ ] [view/js/users] Recherche instantanee
|
||||
|
@ -17,8 +18,8 @@
|
|||
########
|
||||
# FAIT #
|
||||
########
|
||||
- [x] [users.js][userDefault][userRepo] Gestion de la nouvelle modification (avec recherche)
|
||||
- [x] [view/js/machines] Modification de machine
|
||||
- [x] [machineDefault] Implementer la modification
|
||||
- [x] [userDefault] Implementer la modification
|
||||
- [x] [userRepo] Gestion des parametres optionnels
|
||||
- [x] [view/users] Gestion des parametres optionnels physiques -> separer la selection et modification
|
||||
|
|
|
@ -342,9 +342,13 @@ if( section.edit.element != null ){
|
|||
// On annule l'envoi de base (PHP)
|
||||
e.preventDefault();
|
||||
|
||||
// Si l'id est defini
|
||||
if( section.edit.input.search.id.value != '' ){
|
||||
|
||||
var request = {
|
||||
path: 'userDefault/edit', // On veut creer un utilisateur
|
||||
data: [
|
||||
section.edit.input.search.id.value,
|
||||
section.edit.input.code.value,
|
||||
section.edit.input.username.value,
|
||||
section.edit.input.firstname.value,
|
||||
|
@ -360,9 +364,10 @@ if( section.edit.element != null ){
|
|||
console.log('Utilisateur modifie!');
|
||||
else // Erreur
|
||||
console.error('ModuleError::'+answer.ModuleError);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}, false);
|
||||
|
||||
}
|
Loading…
Reference in New Issue