[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/user/ -> fiche.php (source)

   1  <?php
   2  /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
   4   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   5   * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
   6   * Copyright (C) 2005      Regis Houssin        <regis.houssin@cap-networks.com>
   7   * Copyright (C) 2005      Lionel COUSTEIX      <etm_ltd@tiscali.co.uk>
   8   *
   9   * This program is free software; you can redistribute it and/or modify
  10   * it under the terms of the GNU General Public License as published by
  11   * the Free Software Foundation; either version 2 of the License, or
  12   * (at your option) any later version.
  13   *
  14   * This program is distributed in the hope that it will be useful,
  15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17   * GNU General Public License for more details.
  18   *
  19   * You should have received a copy of the GNU General Public License
  20   * along with this program; if not, write to the Free Software
  21   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22   *
  23   * $Id: fiche.php,v 1.81.2.2 2005/12/23 15:37:53 hregis Exp $
  24   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/user/fiche.php,v $
  25   */
  26  
  27  /**     
  28          \file       htdocs/user/fiche.php
  29          \brief      Onglet user et permissions de la fiche utilisateur
  30          \version    $Revision: 1.81.2.2 $
  31  */
  32  
  33  require ("./pre.inc.php");
  34  require_once (DOL_DOCUMENT_ROOT."/contact.class.php");
  35  
  36  
  37  // Defini si peux lire/modifier utilisateurs et permisssions
  38  $canreadperms=($user->admin || $user->rights->user->user->lire);
  39  $caneditperms=($user->admin || $user->rights->user->user->creer);
  40  $candisableperms=($user->admin || $user->rights->user->user->supprimer);
  41  
  42  if ($user->id <> $_GET["id"])
  43  {
  44      if (! $canreadperms)
  45      {
  46          accessforbidden();
  47      }
  48  }
  49  
  50  $langs->load("users");
  51  $langs->load("companies");
  52  
  53  
  54  $form = new Form($db);
  55  
  56  $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
  57  
  58  
  59  /**
  60   * Actions
  61   */
  62  if ($_GET["subaction"] == 'addrights' && $caneditperms)
  63  {
  64      $edituser = new User($db,$_GET["id"]);
  65      $edituser->addrights($_GET["rights"]);
  66  }
  67  
  68  if ($_GET["subaction"] == 'delrights' && $caneditperms)
  69  {
  70      $edituser = new User($db,$_GET["id"]);
  71      $edituser->delrights($_GET["rights"]);
  72  }
  73  
  74  if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes")
  75  {
  76      if ($_GET["id"] <> $user->id)
  77      {
  78          $edituser = new User($db, $_GET["id"]);
  79          $edituser->fetch($_GET["id"]);
  80          $edituser->disable();
  81          Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]);
  82          exit;
  83      }
  84  }
  85  
  86  if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
  87  {
  88      if ($_GET["id"] <> $user->id)
  89      {
  90          $edituser = new User($db, $_GET["id"]);
  91          $edituser->fetch($_GET["id"]);
  92          $edituser->delete();
  93          Header("Location: index.php");
  94          exit;
  95      }
  96  }
  97  
  98  // Action ajout user
  99  if ($_POST["action"] == 'add' && $caneditperms)
 100  {
 101      $message="";
 102      if (! $_POST["nom"]) {
 103          $message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
 104          $action="create";       // Go back to create page
 105      }
 106      if (! $_POST["login"]) {
 107          $message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>';
 108          $action="create";       // Go back to create page
 109      }
 110  
 111      if (! $message)
 112      {
 113          $edituser = new User($db,0);
 114  
 115          $edituser->nom           = trim($_POST["nom"]);
 116          $edituser->prenom        = trim($_POST["prenom"]);
 117          $edituser->login         = trim($_POST["login"]);
 118          $edituser->admin         = trim($_POST["admin"]);
 119           $edituser->office_phone  = trim($_POST["office_phone"]);
 120           $edituser->office_fax    = trim($_POST["office_fax"]);
 121           $edituser->user_mobile   = trim($_POST["user_mobile"]);
 122          $edituser->email         = trim($_POST["email"]);
 123          $edituser->webcal_login  = trim($_POST["webcal_login"]);
 124          $edituser->note          = trim($_POST["note"]);
 125  
 126          $db->begin();
 127  
 128          $id = $edituser->create();
 129  
 130          if ($id > 0)
 131          {
 132              if (isset($_POST['password']) && trim($_POST['password']))
 133              {
 134                  $edituser->password($user,trim($_POST['password']),$conf->password_encrypted);
 135              }
 136  
 137              $db->commit();
 138  
 139              Header("Location: fiche.php?id=$id");
 140              exit;
 141          }
 142          else
 143          {
 144              $db->rollback();
 145  
 146              $message='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
 147              $action="create";       // Go back to create page
 148          }
 149  
 150      }
 151  }
 152  
 153  // Action ajout groupe utilisateur
 154  if ($_POST["action"] == 'addgroup' && $caneditperms)
 155  {
 156      if ($_POST["group"])
 157      {
 158          $edituser = new User($db, $_GET["id"]);
 159          $edituser->SetInGroup($_POST["group"]);
 160  
 161          Header("Location: fiche.php?id=".$_GET["id"]);
 162          exit;
 163      }
 164  }
 165  
 166  if ($_GET["action"] == 'removegroup' && $caneditperms)
 167  {
 168      if ($_GET["group"])
 169      {
 170          $edituser = new User($db, $_GET["id"]);
 171          $edituser->RemoveFromGroup($_GET["group"]);
 172  
 173          Header("Location: fiche.php?id=".$_GET["id"]);
 174          exit;
 175      }
 176  }
 177  
 178  if ($_POST["action"] == 'update' && $caneditperms)
 179  {
 180      $message="";
 181  
 182      $db->begin();
 183  
 184      $edituser = new User($db, $_GET["id"]);
 185      $edituser->fetch();
 186  
 187      $edituser->nom           = $_POST["nom"];
 188      $edituser->prenom        = $_POST["prenom"];
 189      $edituser->login         = $_POST["login"];
 190      $edituser->pass          = $_POST["pass"];
 191      $edituser->admin         = $_POST["admin"];
 192      $edituser->office_phone  = $_POST["office_phone"];
 193       $edituser->office_fax    = $_POST["office_fax"];
 194       $edituser->user_mobile   = $_POST["user_mobile"];
 195      $edituser->email         = $_POST["email"];
 196      $edituser->note          = $_POST["note"];
 197      $edituser->webcal_login  = $_POST["webcal_login"];
 198  
 199      $ret=$edituser->update();
 200      if ($ret < 0)
 201      {
 202          if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
 203          {
 204              $message.='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
 205          }
 206          else
 207          {
 208              $message.='<div class="error">'.$edituser->error.'</div>';
 209          }
 210      }
 211      if ($ret >= 0 && isset($_POST["password"]) && $_POST["password"] !='' )
 212      {
 213          $ret=$edituser->password($user,$password,$conf->password_encrypted);
 214          if ($ret < 0)
 215          {
 216              $message.='<div class="error">'.$edituser->error.'</div>';
 217          }
 218      }
 219  
 220      if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
 221      {
 222          // Si une photo est fournie avec le formulaire
 223          if (! is_dir($conf->users->dir_output))
 224          {
 225              create_exdir($conf->users->dir_output);
 226          }
 227          if (is_dir($conf->users->dir_output))
 228          {
 229              $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";
 230              if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))
 231              {
 232                  $message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
 233              }
 234          }
 235      }
 236  
 237      if ($ret >= 0)
 238      {
 239          $message.='<div class="ok">'.$langs->trans("UserModified").'</div>';
 240          $db->commit();
 241      } else
 242      {
 243          $db->rollback;
 244      }
 245  
 246  }
 247  
 248  // Action modif mot de passe
 249  if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes')
 250        || $_GET["action"] == 'confirm_passwordsend') && $caneditperms)
 251  {
 252      $edituser = new User($db, $_GET["id"]);
 253      $edituser->fetch();
 254  
 255      $newpassword=$edituser->password($user,'',$conf->password_encrypted);
 256      if ($newpassword < 0)
 257      {
 258          // Echec
 259          $message = '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
 260      }
 261      else 
 262      {
 263          // Succes
 264          if ($_GET["action"] == 'confirm_passwordsend')
 265          {
 266              if ($edituser->send_password($user,$newpassword) > 0)
 267              {
 268                  $message = '<div class="ok">'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'</div>';
 269                  //$message.=$newpassword;
 270              }
 271              else
 272              {
 273                  $message = '<div class="ok">'.$langs->trans("PasswordChangedTo",$newpassword).'</div>';
 274                  $message.= '<div class="error">'.$edituser->error.'</div>';
 275              }
 276          }
 277          else
 278          {
 279              $message = '<div class="ok">'.$langs->trans("PasswordChangedTo",$newpassword).'</div>';
 280          }
 281      }
 282  }
 283  
 284  
 285  
 286  llxHeader('',$langs->trans("UserCard"));
 287  
 288  if ($action == 'create')
 289  {
 290      /* ************************************************************************** */
 291      /*                                                                            */
 292      /* Affichage fiche en mode création                                           */
 293      /*                                                                            */
 294      /* ************************************************************************** */
 295  
 296      print_titre($langs->trans("NewUser"));
 297  
 298      print "<br>";
 299      if ($message) { print $message.'<br>'; }
 300  
 301      print '<form action="fiche.php" method="post" name="createuser">';
 302      print '<input type="hidden" name="action" value="add">';
 303  
 304      print '<table class="border" width="100%">';
 305  
 306      print "<tr>".'<td valign="top">'.$langs->trans("Lastname").'</td>';
 307      print '<td class="valeur"><input size="30" type="text" name="nom" value=""></td></tr>';
 308  
 309      print '<tr><td valign="top" width="20%">'.$langs->trans("Firstname").'</td>';
 310      print '<td class="valeur"><input size="30" type="text" name="prenom" value=""></td></tr>';
 311  
 312      print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
 313      print '<td class="valeur"><input size="20" maxsize="24" type="text" name="login" value=""></td></tr>';
 314  
 315      print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
 316      print '<td class="valeur"><input size="30" maxsize="32" type="text" name="password" value=""></td></tr>';
 317  
 318      if ($user->admin)
 319      {
 320          print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
 321          print '<td class="valeur">';
 322          $form->selectyesnonum('admin',0);
 323          print "</td></tr>\n";
 324      }
 325      
 326      print '<tr><td valign="top">'.$langs->trans("Phone").'</td>';
 327      print '<td class="valeur"><input size="20" type="text" name="office_phone" value=""></td></tr>';
 328  
 329      print '<tr><td valign="top">'.$langs->trans("Fax").'</td>';
 330      print '<td class="valeur"><input size="20" type="text" name="office_fax" value=""></td></tr>';
 331  
 332      print '<tr><td valign="top">'.$langs->trans("Mobile").'</td>';
 333      print '<td class="valeur"><input size="20" type="text" name="user_mobile" value=""></td></tr>';
 334  
 335      print '<tr><td valign="top">'.$langs->trans("EMail").'</td>';
 336      print '<td class="valeur"><input size="40" type="text" name="email" value=""></td></tr>';
 337  
 338      print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>';
 339      print "<textarea name=\"note\" rows=\"6\" cols=\"40\">";
 340      print "</textarea></td></tr>\n";
 341  
 342      // Autres caractéristiques issus des autres modules
 343      if ($conf->webcal->enabled)
 344      {
 345          print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
 346          print '<td class="valeur"><input size="30" type="text" name="webcal_login" value=""></td></tr>';
 347      }
 348  
 349      print "<tr>".'<td align="center" colspan="2"><input class="button" value="'.$langs->trans("CreateUser").'" type="submit"></td></tr>';
 350      print "</table>\n";
 351      print "</form>";
 352  }
 353  else
 354  {
 355      /* ************************************************************************** */
 356      /*                                                                            */
 357      /* Visu et edition                                                            */
 358      /*                                                                            */
 359      /* ************************************************************************** */
 360  
 361      if ($_GET["id"])
 362      {
 363          $fuser = new User($db, $_GET["id"]);
 364          $fuser->fetch();
 365          $fuser->getrights();
 366  
 367          $caneditpassword=( (($user->id == $fuser->id) && $user->rights->user->self->password)
 368                          || (($user->id != $fuser->id) && $user->rights->user->user->password) );
 369  
 370          /*
 371           * Affichage onglets
 372           */
 373  
 374          $h = 0;
 375  
 376          $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
 377          $head[$h][1] = $langs->trans("UserCard");
 378          $hselected=$h;
 379          $h++;
 380  
 381          $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
 382          $head[$h][1] = $langs->trans("UserRights");
 383          $h++;
 384  
 385          $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id;
 386          $head[$h][1] = $langs->trans("UserGUISetup");
 387          $h++;
 388  
 389          if ($conf->bookmark4u->enabled)
 390          {
 391              $head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
 392              $head[$h][1] = $langs->trans("Bookmark4u");
 393              $h++;
 394          }
 395  
 396          if ($conf->clicktodial->enabled)
 397          {
 398              $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
 399              $head[$h][1] = $langs->trans("ClickToDial");
 400              $h++;
 401          }
 402  
 403          dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
 404  
 405  
 406          /*
 407           * Confirmation réinitialisation mot de passe
 408           */
 409          if ($action == 'password')
 410          {
 411              $html = new Form($db);
 412              $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password");
 413              print '<br>';
 414          }
 415  
 416          /*
 417           * Confirmation envoi mot de passe
 418           */
 419          if ($action == 'passwordsend')
 420          {
 421              $html = new Form($db);
 422              $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend");
 423              print '<br>';
 424          }
 425  
 426          /*
 427           * Confirmation désactivation
 428           */
 429          if ($action == 'disable')
 430          {
 431              $html = new Form($db);
 432              $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable");
 433              print '<br>';
 434          }
 435  
 436          /*
 437           * Confirmation suppression
 438           */
 439          if ($action == 'delete')
 440          {
 441              $html = new Form($db);
 442              $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete");
 443              print '<br>';
 444          }
 445  
 446  
 447          /*
 448           * Fiche en mode visu
 449           */
 450          if ($_GET["action"] != 'edit')
 451          {
 452              print '<table class="border" width="100%">';
 453  
 454              print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
 455              print '<td width="50%" class="valeur">'.$fuser->nom.'</td>';
 456              print '<td align="center" valign="middle" width="25%" rowspan="14">';
 457              if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
 458              {
 459                  print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';
 460              }
 461              else
 462              {
 463                  print '<img src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
 464              }
 465              print '</td></tr>';
 466  
 467              print '<tr><td width="25%" valign="top">'.$langs->trans("Firstname").'</td>';
 468              print '<td width="50%" class="valeur">'.$fuser->prenom.'</td>';
 469              print "</tr>\n";
 470  
 471              print '<tr><td width="25%" valign="top">'.$langs->trans("Login").'</td>';
 472              if ($fuser->login)
 473              {
 474                  print '<td width="50%" class="valeur">'.$fuser->login.'</td></tr>';
 475              }
 476              else
 477              {
 478                  print '<td width="50%" class="error">'.$langs->trans("LoginAccountDisable").'</td></tr>';
 479              }
 480  
 481              // Password
 482              print '<tr><td width="25%" valign="top">'.$langs->trans("Password").'</td>';
 483              print '<td width="50%" class="valeur">'.eregi_replace('.','*',$fuser->pass).'</td>';
 484              print "</tr>\n";
 485  
 486              // Administrateur
 487              print '<tr><td width="25%" valign="top">'.$langs->trans("Administrator").'</td>';
 488              print '<td class="valeur">'.yn($fuser->admin);
 489              if ($fuser->admin) print ' '.img_picto($langs->trans("Administrator"),"star");
 490              print '</td>';
 491              print "</tr>\n";
 492              
 493              // Source
 494              print '<tr><td width="25%" valign="top">'.$langs->trans("Source").'</td>';
 495              print '<td class="valeur">';
 496              if ($fuser->societe_id)
 497              {
 498                  print $langs->trans("External");
 499              }
 500              else
 501              {
 502                  print $langs->trans("Internal");
 503              }
 504              print '</td></tr>';
 505  
 506              // Company / Contact
 507              print '<tr><td width="25%" valign="top">'.$langs->trans("Company").' / '.$langs->trans("Contact").'</td>';
 508              print '<td class="valeur">';
 509              if ($fuser->societe_id > 0)
 510              {
 511                  $societe = new Societe($db);
 512                  $societe->fetch($fuser->societe_id);
 513                  print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$fuser->societe_id.'">'.img_object($langs->trans("ShowCompany"),'company').' '.dolibarr_trunc($societe->nom,32).'</a>';
 514                  if ($fuser->contact_id)
 515                  {
 516                      $contact = new Contact($db);
 517                      $contact->fetch($fuser->contact_id);
 518                      print ' / '.'<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$fuser->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dolibarr_trunc($contact->fullname,32).'</a>';
 519                  }
 520              }            
 521              else
 522              {
 523                  print $langs->trans("ThisUserIsNot");
 524              }
 525              print '</td>';
 526              print "</tr>\n";
 527  
 528              // Tel, fax, portable
 529              print '<tr><td width="25%" valign="top">'.$langs->trans("Phone").'</td>';
 530               print '<td width="50%" class="valeur">'.$fuser->office_phone.'</td>';
 531               print '<tr><td width="25%" valign="top">'.$langs->trans("Fax").'</td>';
 532               print '<td width="50%" class="valeur">'.$fuser->office_fax.'</td>';
 533               print '<tr><td width="25%" valign="top">'.$langs->trans("Mobile").'</td>';
 534               print '<td width="50%" class="valeur">'.$fuser->user_mobile.'</td>';
 535  
 536              print '<tr><td width="25%" valign="top">'.$langs->trans("EMail").'</td>';
 537              print '<td width="50%" class="valeur"><a href="mailto:'.$fuser->email.'">'.$fuser->email.'</a></td>';
 538              print "</tr>\n";
 539  
 540              print '<tr><td width="25%" valign="top">'.$langs->trans("DateCreation").'</td>';
 541              print '<td class="valeur">'.dolibarr_print_date($fuser->datec).'</td>';
 542              print "</tr>\n";
 543  
 544              print '<tr><td width="25%" valign="top">'.$langs->trans("DateModification").'</td>';
 545              print '<td class="valeur">'.dolibarr_print_date($fuser->datem).'</td>';
 546              print "</tr>\n";
 547  
 548              print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Note").'</td>';
 549              print '<td class="valeur">'.nl2br($fuser->note).'&nbsp;</td>';
 550              print "</tr>\n";
 551  
 552              // Autres caractéristiques issus des autres modules
 553              if ($conf->webcal->enabled)
 554              {
 555                  $langs->load("other");
 556                  print '<tr><td width="25%" valign="top">'.$langs->trans("LoginWebcal").'</td>';
 557                  print '<td colspan="2">'.$fuser->webcal_login.'&nbsp;</td>';
 558                  print "</tr>\n";
 559              }
 560  
 561              print "</table>\n";
 562  
 563              print "</div>\n";
 564  
 565              if ($message) { print $message; }
 566  
 567              /*
 568               * Barre d'actions
 569               */
 570              print '<div class="tabsAction">';
 571  
 572              if ($caneditperms || ($user->id == $fuser->id))
 573              {
 574                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
 575              }
 576  
 577              if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login)
 578              {
 579                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a>';
 580              }
 581  
 582              if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->email && $fuser->login)
 583              {
 584                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a>';
 585              }
 586  
 587              if ($user->id <> $_GET["id"] && $candisableperms && $fuser->login)
 588              {
 589                  print '<a class="butActionDelete" href="fiche.php?action=disable&amp;id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';
 590              }
 591  
 592              if ($user->id <> $_GET["id"] && $candisableperms)
 593              {
 594                  print '<a class="butActionDelete" href="fiche.php?action=delete&amp;id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>';
 595              }
 596  
 597              print "</div>\n";
 598              print "<br>\n";
 599  
 600  
 601  
 602              /*
 603               * Liste des groupes dans lequel est l'utilisateur
 604               */
 605  
 606              print_fiche_titre($langs->trans("ListOfGroupsForUser"));
 607  
 608              // On sélectionne les groups
 609              $uss = array();
 610  
 611              $sql = "SELECT ug.rowid, ug.nom ";
 612              $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as ug ";
 613              #      $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user";
 614              #      $sql .= " WHERE ug.fk_usergroup IS NULL";
 615              $sql .= " ORDER BY ug.nom";
 616  
 617              $resql = $db->query($sql);
 618              if ($resql)
 619              {
 620                  $num = $db->num_rows($resql);
 621                  $i = 0;
 622  
 623                  while ($i < $num)
 624                  {
 625                      $obj = $db->fetch_object($resql);
 626  
 627                      $uss[$obj->rowid] = $obj->nom;
 628                      $i++;
 629                  }
 630              }
 631              else {
 632                  dolibarr_print_error($db);
 633              }
 634  
 635              if ($caneditperms)
 636              {
 637                  $form = new Form($db);
 638                  print '<form action="fiche.php?id='.$_GET["id"].'" method="post">'."\n";
 639                  print '<input type="hidden" name="action" value="addgroup">';
 640                  print '<table class="noborder" width="100%">'."\n";
 641                  //      print '<tr class="liste_titre"><td width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
 642                  print '<tr class="liste_titre"><td width="25%">'.$langs->trans("GroupsToAdd").'</td>'."\n";
 643                  print '<td>';
 644                  print $form->select_array("group",$uss);
 645                  print ' &nbsp; ';
 646                  print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
 647                  print '</td></tr>'."\n";
 648                  print '</table></form>'."\n";
 649              }
 650  
 651              /*
 652               * Groupes affectés
 653               */
 654              $sql = "SELECT g.rowid, g.nom ";
 655              $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
 656              $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
 657              $sql .= " WHERE ug.fk_usergroup = g.rowid";
 658              $sql .= " AND ug.fk_user = ".$_GET["id"];
 659              $sql .= " ORDER BY g.nom";
 660  
 661              $result = $db->query($sql);
 662              if ($result)
 663              {
 664                  $num = $db->num_rows($result);
 665                  $i = 0;
 666  
 667                  print '<br>';
 668  
 669                  print '<table class="noborder" width="100%">';
 670                  print '<tr class="liste_titre">';
 671                  print '<td width="25%">'.$langs->trans("Group").'</td>';
 672                  print "<td>&nbsp;</td></tr>\n";
 673  
 674                  if ($num) {
 675                      $var=True;
 676                      while ($i < $num)
 677                      {
 678                          $obj = $db->fetch_object($result);
 679                          $var=!$var;
 680  
 681                          print "<tr $bc[$var]>";
 682                          print '<td>';
 683                          print '<a href="'.DOL_URL_ROOT.'/user/group/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.'</a>';
 684                          print '</td>';
 685                          print '<td>';
 686  
 687                          if ($caneditperms)
 688                          {
 689  
 690                              print '<a href="fiche.php?id='.$_GET["id"].'&amp;action=removegroup&amp;group='.$obj->rowid.'">';
 691                              print img_delete($langs->trans("RemoveFromGroup"));
 692                          }
 693                          else
 694                          {
 695                              print "-";
 696                          }
 697                          print "</td></tr>\n";
 698                          $i++;
 699                      }
 700                  }
 701                  else
 702                  {
 703                      print '<tr><td colspan=2>'.$langs->trans("None").'</td></tr>';
 704                  }
 705                  print "</table>";
 706                  print "<br>";
 707                  $db->free($result);
 708              }
 709              else {
 710                  dolibarr_print_error($db);
 711              }
 712  
 713          }
 714  
 715          /*
 716           * Fiche en mode edition
 717           */
 718          if ($_GET["action"] == 'edit' && ($caneditperms || ($user->id == $fuser->id)))
 719          {
 720  
 721              print '<form action="fiche.php?id='.$fuser->id.'" method="post" name="updateuser" enctype="multipart/form-data">';
 722              print '<input type="hidden" name="action" value="update">';
 723              print '<table width="100%" class="border">';
 724              
 725              $rowspan=12;
 726  
 727              print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
 728              print '<td width="50%" class="valeur"><input class="flat" size="30" type="text" name="nom" value="'.$fuser->nom.'"></td>';
 729              print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
 730              if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
 731              {
 732                  print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';
 733              }
 734              else
 735              {
 736                  print '<img src="'.DOL_URL_ROOT.'/theme/nophoto.jpg">';
 737              }
 738              print '<br><br><table class="noborder"><tr><td>'.$langs->trans("PhotoFile").'</td></tr><tr><td><input type="file" class="flat" name="photo"></td></tr></table>';
 739              print '</td></tr>';
 740  
 741              print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>';
 742              print '<td><input size="30" type="text" class="flat" name="prenom" value="'.$fuser->prenom.'"></td></tr>';
 743  
 744              // Login
 745              print "<tr>".'<td valign="top">'.$langs->trans("Login").'</td>';
 746              print '<td>';
 747              if ($user->admin) print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="'.$fuser->login.'">';
 748              else print $fuser->login.'<input type="hidden" name="login" value="'.$fuser->login.'">';
 749              print '</td></tr>';
 750  
 751              // Pass
 752              if ($caneditpassword) 
 753              {
 754                  print "<tr>".'<td valign="top">'.$langs->trans("Password").'</td>';
 755                  print '<td><input size="12" maxlength="32" type="password" class="flat" name="pass" value="'.$fuser->pass.'"></td></tr>';
 756              }
 757              else
 758              {
 759                  print '<tr><td width="25%" valign="top">'.$langs->trans("Password").'</td>';
 760                  print '<td width="50%" class="valeur">'.eregi_replace('.','*',$fuser->pass).'</td>';
 761                  print "</tr>\n";
 762              }
 763              
 764              // Administrateur
 765              print "<tr>".'<td valign="top">'.$langs->trans("Administrator").'</td>';
 766              if ($fuser->societe_id > 0)
 767              {
 768                  print '<td class="valeur">';
 769                  print '<input type="hidden" name="admin" value="'.$fuser->admin.'">'.yn($fuser->admin);
 770                  print '</td></tr>';
 771              }
 772              else
 773              {
 774                  print '<td class="valeur">';
 775                  if ($user->admin)
 776                  {
 777                      $form->selectyesnonum('admin',$fuser->admin);
 778                  }
 779                  else
 780                  {
 781                      print '<input type="hidden" name="admin" value="'.$fuser->admin.'">'.yn($fuser->admin);
 782                  }
 783                  print '</td></tr>';
 784              }
 785  
 786              // Source
 787              print '<tr><td width="25%" valign="top">'.$langs->trans("Source").'</td>';
 788              print '<td class="valeur">';
 789              if ($fuser->societe_id)
 790              {
 791                  print $langs->trans("External");
 792              }
 793              else
 794              {
 795                  print $langs->trans("Internal");
 796              }
 797              print '</td></tr>';
 798  
 799              // Company / Contact
 800              print '<tr><td width="25%" valign="top">'.$langs->trans("Company").' / '.$langs->trans("Contact").'</td>';
 801              print '<td class="valeur">';
 802              if ($fuser->societe_id > 0)
 803              {
 804                  $societe = new Societe($db);
 805                  $societe->fetch($fuser->societe_id);
 806                  print '<a href="'.DOL_URL_ROOT.'/soc.php?id='.$fuser->societe_id.'">'.img_object($langs->trans("ShowCompany"),'company').' '.dolibarr_trunc($societe->nom,32).'</a>';
 807                  if ($fuser->contact_id)
 808                  {
 809                      $contact = new Contact($db);
 810                      $contact->fetch($fuser->contact_id);
 811                      print ' / '.'<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$fuser->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dolibarr_trunc($contact->fullname,32).'</a>';
 812                  }
 813              }            
 814              else
 815              {
 816                  print $langs->trans("ThisUserIsNot");
 817              }
 818              print '</td>';
 819              print "</tr>\n";
 820  
 821              // Tel, fax, portable
 822               print "<tr>".'<td valign="top">'.$langs->trans("Phone").'</td>';
 823              print '<td><input size="20" type="text" name="office_phone" class="flat" value="'.$fuser->office_phone.'"></td></tr>';
 824              
 825              print "<tr>".'<td valign="top">'.$langs->trans("Fax").'</td>';
 826               print '<td><input size="20" type="text" name="office_fax" class="flat" value="'.$fuser->office_fax.'"></td></tr>';
 827              
 828              print "<tr>".'<td valign="top">'.$langs->trans("Mobile").'</td>';
 829              print '<td><input size="20" type="text" name="user_mobile" class="flat" value="'.$fuser->user_mobile.'"></td></tr>';
 830  
 831              print "<tr>".'<td valign="top">'.$langs->trans("EMail").'</td>';
 832              print '<td><input size="40" type="text" name="email" class="flat" value="'.$fuser->email.'"></td></tr>';
 833  
 834              print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
 835              print '<textarea class="flat" name="note" rows="'.ROWS_3.'" cols="70">';
 836              print $fuser->note;
 837              print "</textarea></td></tr>";
 838  
 839              // Autres caractéristiques issus des autres modules
 840              if ($conf->webcal->enabled)
 841               {
 842                      $langs->load("other");
 843                      print "<tr>".'<td valign="top">'.$langs->trans("LoginWebcal").'</td>';
 844                      print '<td class="valeur" colspan="2"><input size="30" type="text" class="flat" name="webcal_login" value="'.$fuser->webcal_login.'"></td></tr>';
 845                  }
 846              
 847              print '<tr><td align="center" colspan="3"><input value="'.$langs->trans("Save").'" class="button" type="submit"></td></tr>';
 848  
 849              print '</table>';
 850              print '</form>';
 851          }
 852  
 853          print '</div>';
 854      }
 855  }
 856  
 857  $db->close();
 858  
 859  llxFooter('$Date: 2005/12/23 15:37:53 $ - $Revision: 1.81.2.2 $');
 860  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics