New: Ajout fonction editer groupe.
This commit is contained in:
parent
6278a051f9
commit
e496a9e8ce
@ -50,6 +50,10 @@ ShowGroup=Show group
|
||||
ShowUser=Show user
|
||||
NonAffectedUsers=Non affected users
|
||||
UserModified=User modified successfully
|
||||
GroupModified=Group modified successfully
|
||||
PhotoFile=Fichier photo
|
||||
UserWithDolibarrAccess=User with Dolibarr access
|
||||
ListOfUsersInGroup=List of users in group
|
||||
ListOfUsersInGroup=List of users in this group
|
||||
ListOfGroupsForUser=List of groups for this user
|
||||
UsersToAdd=Users to add to this group
|
||||
GroupsToAdd=Groups to add to this user
|
||||
@ -50,6 +50,10 @@ ShowGroup=Afficher groupe
|
||||
ShowUser=Afficher utilisateur
|
||||
NonAffectedUsers=Utilisateurs non affectés au groupe
|
||||
UserModified=Utilisateur modifié avec succès
|
||||
GroupModified=Groupe modifié avec succès
|
||||
PhotoFile=Fichier photo
|
||||
UserWithDolibarrAccess=Utilisateur avec accès Dolibarr
|
||||
ListOfUsersInGroup=Liste des utilisateurs dans le groupe
|
||||
ListOfUsersInGroup=Liste des utilisateurs dans ce groupe
|
||||
ListOfGroupsForUser=Liste des groupes pour cet utilisateur
|
||||
UsersToAdd=Utilisateur à ajouter à ce groupe
|
||||
GroupsToAdd=Groupes à ajouter pour cet utilisateur
|
||||
@ -22,7 +22,8 @@
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/** \file htdocs/user/fiche.php
|
||||
/**
|
||||
\file htdocs/user/fiche.php
|
||||
\brief Onglet user et permissions de la fiche utilisateur
|
||||
\version $Revision$
|
||||
*/
|
||||
@ -43,89 +44,110 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
|
||||
*/
|
||||
if ($_GET["subaction"] == 'addrights' && $user->admin)
|
||||
{
|
||||
$edituser = new User($db,$_GET["id"]);
|
||||
$edituser->addrights($_GET["rights"]);
|
||||
$edituser = new User($db,$_GET["id"]);
|
||||
$edituser->addrights($_GET["rights"]);
|
||||
}
|
||||
|
||||
if ($_GET["subaction"] == 'delrights' && $user->admin)
|
||||
{
|
||||
$edituser = new User($db,$_GET["id"]);
|
||||
$edituser->delrights($_GET["rights"]);
|
||||
$edituser = new User($db,$_GET["id"]);
|
||||
$edituser->delrights($_GET["rights"]);
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes")
|
||||
{
|
||||
if ($_GET["id"] <> $user->id)
|
||||
if ($_GET["id"] <> $user->id)
|
||||
{
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch($_GET["id"]);
|
||||
$edituser->disable();
|
||||
Header("Location: index.php");
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch($_GET["id"]);
|
||||
$edituser->disable();
|
||||
Header("Location: index.php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
|
||||
{
|
||||
if ($_GET["id"] <> $user->id)
|
||||
if ($_GET["id"] <> $user->id)
|
||||
{
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch($_GET["id"]);
|
||||
$edituser->delete();
|
||||
Header("Location: index.php");
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch($_GET["id"]);
|
||||
$edituser->delete();
|
||||
Header("Location: index.php");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action ajout user
|
||||
*/
|
||||
if ($_POST["action"] == 'add' && $user->admin)
|
||||
{
|
||||
$message="";
|
||||
if (! $_POST["nom"]) {
|
||||
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
|
||||
$action="create"; // Go back to create page
|
||||
}
|
||||
if (! $_POST["login"]) {
|
||||
$message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>';
|
||||
$action="create"; // Go back to create page
|
||||
}
|
||||
|
||||
if (! $message) {
|
||||
$edituser = new User($db,0);
|
||||
|
||||
$edituser->nom = trim($_POST["nom"]);
|
||||
$edituser->note = trim($_POST["note"]);
|
||||
$edituser->prenom = trim($_POST["prenom"]);
|
||||
$edituser->login = trim($_POST["login"]);
|
||||
$edituser->email = trim($_POST["email"]);
|
||||
$edituser->admin = trim($_POST["admin"]);
|
||||
$edituser->webcal_login = trim($_POST["webcal_login"]);
|
||||
|
||||
$db->begin();
|
||||
|
||||
$id = $edituser->create();
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if (isset($_POST['password']) && trim($_POST['password']))
|
||||
{
|
||||
$edituser->password($user,trim($_POST['password']),$conf->password_encrypted);
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
|
||||
Header("Location: fiche.php?id=$id");
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
|
||||
$message='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
|
||||
$message="";
|
||||
if (! $_POST["nom"]) {
|
||||
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
|
||||
$action="create"; // Go back to create page
|
||||
}
|
||||
if (! $_POST["login"]) {
|
||||
$message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>';
|
||||
$action="create"; // Go back to create page
|
||||
}
|
||||
|
||||
}
|
||||
if (! $message) {
|
||||
$edituser = new User($db,0);
|
||||
|
||||
$edituser->nom = trim($_POST["nom"]);
|
||||
$edituser->note = trim($_POST["note"]);
|
||||
$edituser->prenom = trim($_POST["prenom"]);
|
||||
$edituser->login = trim($_POST["login"]);
|
||||
$edituser->email = trim($_POST["email"]);
|
||||
$edituser->admin = trim($_POST["admin"]);
|
||||
$edituser->webcal_login = trim($_POST["webcal_login"]);
|
||||
|
||||
$db->begin();
|
||||
|
||||
$id = $edituser->create();
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if (isset($_POST['password']) && trim($_POST['password']))
|
||||
{
|
||||
$edituser->password($user,trim($_POST['password']),$conf->password_encrypted);
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
|
||||
Header("Location: fiche.php?id=$id");
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
|
||||
$message='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
|
||||
$action="create"; // Go back to create page
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'addgroup' && $user->admin)
|
||||
{
|
||||
if ($_POST["group"])
|
||||
{
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->SetInGroup($_POST["group"]);
|
||||
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'removegroup' && $user->admin)
|
||||
{
|
||||
if ($_GET["group"])
|
||||
{
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->RemoveFromGroup($_GET["group"]);
|
||||
|
||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'update' && $user->admin)
|
||||
@ -133,7 +155,7 @@ if ($_POST["action"] == 'update' && $user->admin)
|
||||
$message="";
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch();
|
||||
|
||||
@ -168,7 +190,7 @@ if ($_POST["action"] == 'update' && $user->admin)
|
||||
$newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";
|
||||
if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))
|
||||
{
|
||||
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
|
||||
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,310 +206,422 @@ if ($_POST["action"] == 'update' && $user->admin)
|
||||
|
||||
if ($_GET["action"] == 'password' && $user->admin)
|
||||
{
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch();
|
||||
$edituser = new User($db, $_GET["id"]);
|
||||
$edituser->fetch();
|
||||
|
||||
if ($edituser->password($user,'',$conf->password_encrypted))
|
||||
if ($edituser->password($user,'',$conf->password_encrypted))
|
||||
{
|
||||
$message = '<div class="ok">'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'</div>';
|
||||
$message = '<div class="ok">'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
llxHeader('','Fiche Utilisateur');
|
||||
llxHeader('',$langs->trans("UserCard"));
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Affichage fiche en mode création */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Affichage fiche en mode création */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print_titre($langs->trans("NewUser"));
|
||||
print_titre($langs->trans("NewUser"));
|
||||
|
||||
print "<br>";
|
||||
if ($message) { print $message."<br>"; }
|
||||
print "<br>";
|
||||
if ($message) { print $message."<br>"; }
|
||||
|
||||
print '<form action="fiche.php" method="post" name="createuser">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<form action="fiche.php" method="post" name="createuser">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="nom" value=""></td></tr>';
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="nom" value=""></td></tr>';
|
||||
|
||||
print '<tr><td valign="top" width="20%">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="prenom" value=""></td></tr>';
|
||||
print '<tr><td valign="top" width="20%">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="prenom" value=""></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td class="valeur"><input size="20" type="text" name="login" value=""></td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td class="valeur"><input size="20" type="text" name="login" value=""></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="password" value=""></td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="password" value=""></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td class="valeur"><input size="40" type="text" name="email" value=""></td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td class="valeur"><input size="40" type="text" name="email" value=""></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
print '<td class="valeur">';
|
||||
$form->selectyesnonum('admin',0);
|
||||
print "</td></tr>\n";
|
||||
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
print '<td class="valeur">';
|
||||
$form->selectyesnonum('admin',0);
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>';
|
||||
print "<textarea name=\"note\" rows=\"12\" cols=\"40\">";
|
||||
print "</textarea></td></tr>\n";
|
||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>';
|
||||
print "<textarea name=\"note\" rows=\"12\" cols=\"40\">";
|
||||
print "</textarea></td></tr>\n";
|
||||
|
||||
// Autres caractéristiques issus des autres modules
|
||||
if ($conf->webcal->enabled)
|
||||
// Autres caractéristiques issus des autres modules
|
||||
if ($conf->webcal->enabled)
|
||||
{
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="webcal_login" value=""></td></tr>';
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td class="valeur"><input size="30" type="text" name="webcal_login" value=""></td></tr>';
|
||||
}
|
||||
|
||||
print "<tr>".'<td align="center" colspan="2"><input value="'.$langs->trans("CreateUser").'" type="submit"></td></tr>';
|
||||
print "</form>";
|
||||
print "</table>\n";
|
||||
print "<tr>".'<td align="center" colspan="2"><input value="'.$langs->trans("CreateUser").'" type="submit"></td></tr>';
|
||||
print "</form>";
|
||||
print "</table>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Visu et edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($_GET["id"])
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Visu et edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$fuser = new User($db, $_GET["id"]);
|
||||
$fuser->fetch();
|
||||
$fuser->getrights();
|
||||
$fuser = new User($db, $_GET["id"]);
|
||||
$fuser->fetch();
|
||||
$fuser->getrights();
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserCard");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("UserRights");
|
||||
$h++;
|
||||
|
||||
if ($conf->bookmark4u->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$h++;
|
||||
}
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation désactivation
|
||||
*/
|
||||
if ($action == 'disable')
|
||||
{
|
||||
$html = new Form($db);
|
||||
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||
$head[$h][1] = $langs->trans("Bookmark4u");
|
||||
$h++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation suppression
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation désactivation
|
||||
*/
|
||||
if ($action == 'disable')
|
||||
{
|
||||
$html = new Form($db);
|
||||
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete");
|
||||
$html = new Form($db);
|
||||
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable");
|
||||
}
|
||||
|
||||
if ($_GET["action"] != 'edit')
|
||||
{
|
||||
/*
|
||||
* Fiche en mode visu
|
||||
*/
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="50%" class="valeur">'.$fuser->nom.'</td>';
|
||||
print '<td align="center" valign="middle" width="25%" rowspan="8">';
|
||||
if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
|
||||
{
|
||||
print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
/*
|
||||
* Confirmation suppression
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$html = new Form($db);
|
||||
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete");
|
||||
}
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td width="50%" class="valeur">'.$fuser->prenom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td width="50%" class="valeur">'.$fuser->login.'</td></tr>';
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td width="50%" class="valeur"><a href="mailto:'.$fuser->email.'">'.$fuser->email.'</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
print '<td class="valeur">'.yn($fuser->admin).'</td>';
|
||||
print "</tr>\n";
|
||||
/*
|
||||
* Fiche en mode visu
|
||||
*/
|
||||
if ($_GET["action"] != 'edit')
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("DateCreation").'</td>';
|
||||
print '<td class="valeur">'.dolibarr_print_date($fuser->datec).'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("DateModification").'</td>';
|
||||
print '<td class="valeur">'.dolibarr_print_date($fuser->datem).'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("ContactCard").'</td>';
|
||||
print '<td>';
|
||||
if ($fuser->contact_id)
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="50%" class="valeur">'.$fuser->nom.'</td>';
|
||||
print '<td align="center" valign="middle" width="25%" rowspan="8">';
|
||||
if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
|
||||
{
|
||||
print '<a href="../contact/fiche.php?id='.$fuser->contact_id.'">'.$langs->trans("ContactCard").'</a>';
|
||||
print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
print $langs->trans("NoContactCard");
|
||||
print '<img src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
|
||||
}
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($fuser->societe_id > 0)
|
||||
{
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($fuser->societe_id);
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Company").'</td>';
|
||||
print '<td colspan="2">'.$societe->nom.' </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td colspan="2" class="valeur">'.nl2br($fuser->note).' </td>';
|
||||
print "</tr>\n";
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td width="50%" class="valeur">'.$fuser->prenom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Autres caractéristiques issus des autres modules
|
||||
if ($conf->webcal->enabled)
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td width="50%" class="valeur">'.$fuser->login.'</td></tr>';
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td width="50%" class="valeur"><a href="mailto:'.$fuser->email.'">'.$fuser->email.'</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
print '<td class="valeur">'.yn($fuser->admin).'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("DateCreation").'</td>';
|
||||
print '<td class="valeur">'.dolibarr_print_date($fuser->datec).'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("DateModification").'</td>';
|
||||
print '<td class="valeur">'.dolibarr_print_date($fuser->datem).'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("ContactCard").'</td>';
|
||||
print '<td>';
|
||||
if ($fuser->contact_id)
|
||||
{
|
||||
$langs->load("other");
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td colspan="2">'.$fuser->webcal_login.' </td>';
|
||||
print "</tr>\n";
|
||||
print '<a href="../contact/fiche.php?id='.$fuser->contact_id.'">'.$langs->trans("ContactCard").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("NoContactCard");
|
||||
}
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($fuser->societe_id > 0)
|
||||
{
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($fuser->societe_id);
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Company").'</td>';
|
||||
print '<td colspan="2">'.$societe->nom.' </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
print "<br>\n";
|
||||
|
||||
print "</div>\n";
|
||||
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td colspan="2" class="valeur">'.nl2br($fuser->note).' </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($message) { print $message; }
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->admin)
|
||||
// Autres caractéristiques issus des autres modules
|
||||
if ($conf->webcal->enabled)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$fuser->id.'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
$langs->load("other");
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td colspan="2">'.$fuser->webcal_login.' </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
if ($user->id == $_GET["id"] or $user->admin)
|
||||
print "</table>\n";
|
||||
print "<br>\n";
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($message) { print $message; }
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$fuser->id.'&action=password">'.$langs->trans("SendNewPassword").'</a>';
|
||||
print '<a class="tabAction" href="fiche.php?id='.$fuser->id.'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
|
||||
if ($user->id <> $_GET["id"] && $user->admin)
|
||||
if ($user->id == $_GET["id"] or $user->admin)
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?action=disable&id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';
|
||||
print '<a class="tabAction" href="fiche.php?id='.$fuser->id.'&action=password">'.$langs->trans("SendNewPassword").'</a>';
|
||||
}
|
||||
|
||||
if ($user->id <> $_GET["id"] && $user->admin)
|
||||
if ($user->id <> $_GET["id"] && $user->admin)
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?action=delete&id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>';
|
||||
print '<a class="butDelete" href="fiche.php?action=disable&id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
print "<br>\n";
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
if ($_GET["action"] == 'edit' && $user->admin)
|
||||
if ($user->id <> $_GET["id"] && $user->admin)
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?action=delete&id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
print "<br>\n";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Liste des groupes dans lequel est l'utilisateur
|
||||
*/
|
||||
|
||||
print_titre($langs->trans("ListOfGroupsForUser"));
|
||||
print "<br>\n";
|
||||
|
||||
// On sélectionne les groups
|
||||
$uss = array();
|
||||
|
||||
$sql = "SELECT ug.rowid, ug.nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as ug ";
|
||||
# $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user";
|
||||
# $sql .= " WHERE ug.fk_usergroup IS NULL";
|
||||
$sql .= " ORDER BY ug.nom";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object();
|
||||
|
||||
$uss[$obj->rowid] = $obj->nom;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
$form = new Form($db);
|
||||
print '<form action="fiche.php?id='.$_GET["id"].'" method="post">'."\n";
|
||||
print '<input type="hidden" name="action" value="addgroup">';
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
// print '<tr class="liste_titre"><td width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
|
||||
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("GroupsToAdd").'</td>'."\n";
|
||||
print '<td>';
|
||||
print $form->select_array("group",$uss);
|
||||
print ' ';
|
||||
print '<input type="submit" class=button value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>'."\n";
|
||||
print '</table></form>'."\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Groupes affectés
|
||||
*/
|
||||
$sql = "SELECT g.rowid, g.nom ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
||||
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql .= " WHERE ug.fk_usergroup = g.rowid";
|
||||
$sql .= " AND ug.fk_user = ".$_GET["id"];
|
||||
$sql .= " ORDER BY g.nom";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="25%">'.$langs->trans("Group").'</td>';
|
||||
print "<td> </td></tr>\n";
|
||||
|
||||
if ($num) {
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/group/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.'</a>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
|
||||
print '<a href="fiche.php?id='.$_GET["id"].'&action=removegroup&group='.$obj->rowid.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
}
|
||||
else
|
||||
{
|
||||
print "-";
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan=2>'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
print "<br>";
|
||||
$db->free($result);
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
if ($_GET["action"] == 'edit' && $user->admin)
|
||||
{
|
||||
|
||||
print '<form action="fiche.php?id='.$fuser->id.'" method="post" name="updateuser" enctype="multipart/form-data">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<table width="100%" class="border">';
|
||||
print '<form action="fiche.php?id='.$fuser->id.'" method="post" name="updateuser" enctype="multipart/form-data">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="50%" class="valeur"><input size="30" type="text" name="nom" value="'.$fuser->nom.'"></td>';
|
||||
print '<td align="center" valign="middle" width="25%" rowspan="6">';
|
||||
if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
|
||||
{
|
||||
print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
|
||||
}
|
||||
print '<br><br><table class="noborder"><tr><td>'.$langs->trans("PhotoFile").'</td></tr><tr><td><input type="file" name="photo" class="flat"></td></tr></table>';
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td><input size="30" type="text" name="prenom" value="'.$fuser->prenom.'"></td></tr>';
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="50%" class="valeur"><input size="30" type="text" name="nom" value="'.$fuser->nom.'"></td>';
|
||||
print '<td align="center" valign="middle" width="25%" rowspan="6">';
|
||||
if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
|
||||
{
|
||||
print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
|
||||
}
|
||||
print '<br><br><table class="noborder"><tr><td>'.$langs->trans("PhotoFile").'</td></tr><tr><td><input type="file" name="photo" class="flat"></td></tr></table>';
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td><input size="12" maxlength="8" type="text" name="login" value="'.$fuser->login.'"></td></tr>';
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td><input size="30" type="text" name="prenom" value="'.$fuser->prenom.'"></td></tr>';
|
||||
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td><input size="30" type="text" name="email" value="'.$fuser->email.'"></td></tr>';
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Login").'</td>';
|
||||
print '<td><input size="12" maxlength="8" type="text" name="login" value="'.$fuser->login.'"></td></tr>';
|
||||
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
if ($fuser->societe_id > 0)
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
print '<input type="hidden" name="admin" value="0">'.$langs->trans("No");
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
$form->selectyesnonum('admin',$fuser->admin);
|
||||
print '</td></tr>';
|
||||
}
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("EMail").'</td>';
|
||||
print '<td><input size="30" type="text" name="email" value="'.$fuser->email.'"></td></tr>';
|
||||
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
|
||||
print '<textarea name="note" rows="10" cols="40">';
|
||||
print $fuser->note;
|
||||
print "</textarea></td></tr>";
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Administrator").'</td>';
|
||||
if ($fuser->societe_id > 0)
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
print '<input type="hidden" name="admin" value="0">'.$langs->trans("No");
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
$form->selectyesnonum('admin',$fuser->admin);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Autres caractéristiques issus des autres modules
|
||||
$langs->load("other");
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td class="valeur" colspan="2"><input size="30" type="text" name="webcal_login" value="'.$fuser->webcal_login.'"></td></tr>';
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
|
||||
print '<textarea name="note" rows="10" cols="40">';
|
||||
print $fuser->note;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '<tr><td align="center" colspan="3"><input value="'.$langs->trans("Save").'" type="submit"></td></tr>';
|
||||
// Autres caractéristiques issus des autres modules
|
||||
$langs->load("other");
|
||||
print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
|
||||
print '<td class="valeur" colspan="2"><input size="30" type="text" name="webcal_login" value="'.$fuser->webcal_login.'"></td></tr>';
|
||||
|
||||
print '</table><br>';
|
||||
print '</form>';
|
||||
|
||||
print '<tr><td align="center" colspan="3"><input value="'.$langs->trans("Save").'" type="submit"></td></tr>';
|
||||
|
||||
print '</table><br>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -104,7 +104,32 @@ if ($_GET["action"] == 'removeuser' && $user->admin)
|
||||
}
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
if ($_POST["action"] == 'update' && $user->admin)
|
||||
{
|
||||
$message="";
|
||||
|
||||
$db->begin();
|
||||
|
||||
$editgroup = new Usergroup($db, $_GET["id"]);
|
||||
$editgroup->fetch($_GET["id"]);
|
||||
|
||||
$editgroup->nom = $_POST["group"];
|
||||
$editgroup->note = $_POST["note"];
|
||||
|
||||
$ret=$editgroup->update();
|
||||
|
||||
if ($ret >= 0) {
|
||||
$message.='<div class="ok">'.$langs->trans("GroupModified").'</div>';
|
||||
$db->commit();
|
||||
} else {
|
||||
$message.='<div class="error">'.$editgroup->error.'</div>';
|
||||
$db->rollback;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("GroupCard"));
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
@ -145,7 +170,7 @@ if ($action == 'create')
|
||||
/* ************************************************************************** */
|
||||
else
|
||||
{
|
||||
if ($_GET["id"])
|
||||
if ($_GET["id"] )
|
||||
{
|
||||
$group = new UserGroup($db);
|
||||
$group->fetch($_GET["id"]);
|
||||
@ -182,141 +207,182 @@ else
|
||||
* Fiche en mode visu
|
||||
*/
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$group->nom.'</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td class="valeur">'.nl2br($group->note).' </td>';
|
||||
print "</tr>\n";
|
||||
print "</table>\n";
|
||||
print "<br>\n";
|
||||
if ($_GET["action"] != 'edit') {
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
if ($message) { print $message; }
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$group->id.'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
|
||||
if ($user->id <> $_GET["id"] && $user->admin)
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?action=delete&id='.$group->id.'">'.$langs->trans("DeleteGroup").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
print "<br>\n";
|
||||
|
||||
print_titre($langs->trans("ListOfUsersInGroup"));
|
||||
print "<br>\n";
|
||||
|
||||
// On sélectionne les users qui ne sont pas déjà dans le groupe
|
||||
$uss = array();
|
||||
|
||||
$sql = "SELECT u.rowid, u.name, u.firstname, u.code ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u ";
|
||||
# $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user";
|
||||
# $sql .= " WHERE ug.fk_usergroup IS NULL";
|
||||
$sql .= " ORDER BY u.name";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$group->nom.'</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td class="valeur">'.nl2br($group->note).' </td>';
|
||||
print "</tr>\n";
|
||||
print "</table>\n";
|
||||
print "<br>\n";
|
||||
|
||||
print '</div>';
|
||||
|
||||
if ($message) { print $message; }
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
$obj = $db->fetch_object();
|
||||
|
||||
$uss[$obj->rowid] = ucfirst(stripslashes($obj->firstname)) . " ".ucfirst(stripslashes($obj->name));
|
||||
$i++;
|
||||
print '<a class="tabAction" href="fiche.php?id='.$group->id.'&action=edit">'.$langs->trans("Edit").'</a>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
$form = new Form($db);
|
||||
print '<form action="fiche.php?id='.$group->id.'" method="post">'."\n";
|
||||
print '<input type="hidden" name="action" value="adduser">';
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
// print '<tr class="liste_titre"><td width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
|
||||
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Users").'</td>'."\n";
|
||||
print '<td>';
|
||||
print $form->select_array("user",$uss);
|
||||
print ' ';
|
||||
print '<input type="submit" class=button value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>'."\n";
|
||||
print '</table></form>'."\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Membres du groupe
|
||||
*/
|
||||
$sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.code ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql .= " WHERE ug.fk_user = u.rowid";
|
||||
$sql .= " AND ug.fk_usergroup = ".$group->id;
|
||||
$sql .= " ORDER BY u.name";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="25%">'.$langs->trans("Login").'</td>';
|
||||
print '<td width="25%">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="25%">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td>'.$langs->trans("Code").'</td>';
|
||||
print "<td> </td></tr>\n";
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
|
||||
if ($user->id <> $_GET["id"] && $user->admin)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a>';
|
||||
print '</td>';
|
||||
print '<td>'.ucfirst(stripslashes($obj->name)).'</td>';
|
||||
print '<td>'.ucfirst(stripslashes($obj->firstname)).'</td>';
|
||||
print '<td>'.$obj->code.'</td><td>';
|
||||
|
||||
if ($user->admin)
|
||||
print '<a class="butDelete" href="fiche.php?action=delete&id='.$group->id.'">'.$langs->trans("DeleteGroup").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
print "<br>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Liste des utilisateurs dans le groupe
|
||||
*/
|
||||
|
||||
print_titre($langs->trans("ListOfUsersInGroup"));
|
||||
print "<br>\n";
|
||||
|
||||
// On sélectionne les users qui ne sont pas déjà dans le groupe
|
||||
$uss = array();
|
||||
|
||||
$sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.code ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u ";
|
||||
# $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user";
|
||||
# $sql .= " WHERE ug.fk_usergroup IS NULL";
|
||||
$sql .= " ORDER BY u.name";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
|
||||
print '<a href="fiche.php?id='.$group->id.'&action=removeuser&user='.$obj->rowid.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
$obj = $db->fetch_object();
|
||||
|
||||
$uss[$obj->rowid] = ucfirst(stripslashes($obj->name)).' '.ucfirst(stripslashes($obj->firstname).' ('.$obj->login.')');
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
$form = new Form($db);
|
||||
print '<form action="fiche.php?id='.$group->id.'" method="post">'."\n";
|
||||
print '<input type="hidden" name="action" value="adduser">';
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
// print '<tr class="liste_titre"><td width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
|
||||
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("UsersToAdd").'</td>'."\n";
|
||||
print '<td>';
|
||||
print $form->select_array("user",$uss);
|
||||
print ' ';
|
||||
print '<input type="submit" class=button value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>'."\n";
|
||||
print '</table></form>'."\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Membres du groupe
|
||||
*/
|
||||
$sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.code ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql .= " WHERE ug.fk_user = u.rowid";
|
||||
$sql .= " AND ug.fk_usergroup = ".$group->id;
|
||||
$sql .= " ORDER BY u.name";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="25%">'.$langs->trans("Login").'</td>';
|
||||
print '<td width="25%">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td width="25%">'.$langs->trans("Firstname").'</td>';
|
||||
print '<td>'.$langs->trans("Code").'</td>';
|
||||
print "<td> </td></tr>\n";
|
||||
if ($num) {
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a>';
|
||||
print '</td>';
|
||||
print '<td>'.ucfirst(stripslashes($obj->name)).'</td>';
|
||||
print '<td>'.ucfirst(stripslashes($obj->firstname)).'</td>';
|
||||
print '<td>'.$obj->code.'</td><td>';
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
|
||||
print '<a href="fiche.php?id='.$group->id.'&action=removeuser&user='.$obj->rowid.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
}
|
||||
else
|
||||
{
|
||||
print "-";
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "-";
|
||||
print '<tr><td colspan=2>'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
$i++;
|
||||
print "</table>";
|
||||
print "<br>";
|
||||
$db->free($result);
|
||||
}
|
||||
print "</table>";
|
||||
print "<br>";
|
||||
$db->free($result);
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fiche en mode edition
|
||||
*/
|
||||
if ($_GET["action"] == 'edit' && $user->admin)
|
||||
{
|
||||
print '<form action="fiche.php?id='.$group->id.'" method="post" name="updategroup" enctype="multipart/form-data">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur"><input size="12" maxlength="8" type="text" name="group" value="'.$group->nom.'"></td>';
|
||||
print "</tr>\n";
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td class="valeur"><textarea name="note" rows="12" cols="40">'.nl2br($group->note).'</textarea></td>';
|
||||
print "</tr>\n";
|
||||
print '<tr><td align="center" colspan="2"><input value="'.$langs->trans("Save").'" type="submit"></td></tr>';
|
||||
print "</table>\n";
|
||||
print "<br>\n";
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -37,7 +37,10 @@ class UserGroup
|
||||
var $db;
|
||||
|
||||
var $id;
|
||||
var $label;
|
||||
var $nom;
|
||||
var $note;
|
||||
var $datec;
|
||||
var $datem;
|
||||
|
||||
|
||||
/**
|
||||
@ -64,7 +67,7 @@ class UserGroup
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
$sql = "SELECT g.rowid, g.nom, g.note";
|
||||
$sql = "SELECT g.rowid, g.nom, g.note, g.datec, tms as datem";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
||||
$sql .= " WHERE g.rowid = ".$this->id;
|
||||
|
||||
@ -79,7 +82,8 @@ class UserGroup
|
||||
$this->id = $obj->rowid;
|
||||
$this->nom = $obj->nom;
|
||||
$this->note = $obj->note;
|
||||
|
||||
$this->datec = $obj->datec;
|
||||
$this->datem = $obj->datem;
|
||||
}
|
||||
$this->db->free($result);
|
||||
|
||||
@ -344,6 +348,7 @@ class UserGroup
|
||||
function update()
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET ";
|
||||
$sql .= " nom = '$this->nom',";
|
||||
$sql .= " note = '$this->note'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user