[ 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/contact/ -> fiche.php (source)

   1  <?php
   2  /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
   5   * Copyright (C) 2005      Regis Houssin        <regis.houssin@cap-networks.com>
   6   *
   7   * This program is free software; you can redistribute it and/or modify
   8   * it under the terms of the GNU General Public License as published by
   9   * the Free Software Foundation; either version 2 of the License, or
  10   * (at your option) any later version.
  11   *
  12   * This program is distributed in the hope that it will be useful,
  13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15   * GNU General Public License for more details.
  16   *
  17   * You should have received a copy of the GNU General Public License
  18   * along with this program; if not, write to the Free Software
  19   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20   *
  21   * $Id: fiche.php,v 1.64.2.1 2005/12/20 22:55:44 eldy Exp $
  22   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/contact/fiche.php,v $
  23   */
  24  
  25  /**
  26          \file       htdocs/contact/fiche.php
  27          \ingroup    societe
  28          \brief      Onglet général d'un contact
  29          \version    $Revision: 1.64.2.1 $
  30  */
  31  
  32  require ("./pre.inc.php");
  33  require_once (DOL_DOCUMENT_ROOT."/contact.class.php");
  34  require_once(DOL_DOCUMENT_ROOT."/lib/vcard/vcard.class.php");
  35  
  36  $langs->load("companies");
  37  $langs->load("users");
  38  
  39  $error = array();
  40  $socid=$_GET["socid"]?$_GET["socid"]:$_POST["socid"];
  41  
  42  
  43  if ($_GET["action"] == 'create_user' && $user->admin) 
  44  {
  45    // Recuperation contact actuel
  46    $contact = new Contact($db);
  47    $result = $contact->fetch($_GET["id"]);
  48    
  49    // Creation user
  50    $nuser = new User($db);
  51    $nuser->nom = $contact->name;
  52    $nuser->prenom = $contact->firstname;
  53    $nuser->create_from_contact($contact);
  54  }
  55  
  56  if ($_POST["action"] == 'add')
  57  {
  58      $contact = new Contact($db);
  59  
  60      $contact->socid        = $_POST["socid"];
  61  
  62      $contact->name         = $_POST["name"];
  63      $contact->firstname    = $_POST["firstname"];
  64      $contact->civilite_id  = $_POST["civilite_id"];
  65      $contact->poste        = $_POST["poste"];
  66      $contact->address      = $_POST["address"];
  67      $contact->cp           = $_POST["cp"];
  68      $contact->ville        = $_POST["ville"];
  69      $contact->fk_pays      = $_POST["pays_id"];
  70      $contact->email        = $_POST["email"];
  71      $contact->phone_pro    = $_POST["phone_pro"];
  72      $contact->phone_perso  = $_POST["phone_perso"];
  73      $contact->phone_mobile = $_POST["phone_mobile"];
  74      $contact->fax          = $_POST["fax"];
  75      $contact->jabberid     = $_POST["jabberid"];
  76  
  77      $contact->note         = $_POST["note"];
  78  
  79      if (! $_POST["name"])
  80      {
  81          array_push($error,$langs->trans("ErrorFieldRequired",$langs->trans("Lastname")));
  82          $_GET["action"]="create";
  83      }
  84  
  85      if ($_POST["name"])
  86      {
  87          $id =  $contact->create($user);
  88          if ($id > 0)
  89          {
  90                Header("Location: fiche.php?id=".$id);
  91                exit;
  92          }
  93  
  94          $error=array($contact->error);
  95      }
  96  }
  97  
  98  if ($_POST["action"] == 'confirm_delete' AND $_POST["confirm"] == 'yes') 
  99  {
 100      $contact = new Contact($db);
 101      
 102      $contact->old_name      = $_POST["old_name"];
 103      $contact->old_firstname = $_POST["old_firstname"];
 104      
 105      $result = $contact->delete($_GET["id"]);
 106      
 107      Header("Location: index.php");
 108      exit;
 109  }
 110  
 111  
 112  if ($_POST["action"] == 'update') 
 113  {
 114      $contact = new Contact($db);
 115      
 116      $contact->old_name      = $_POST["old_name"];
 117      $contact->old_firstname = $_POST["old_firstname"];
 118      
 119      $contact->socid         = $_POST["socid"];
 120      $contact->name          = $_POST["name"];
 121      $contact->firstname     = $_POST["firstname"];
 122      $contact->civilite_id   = $_POST["civilite_id"];
 123      $contact->poste         = $_POST["poste"];
 124      
 125      $contact->address       = $_POST["address"];
 126      $contact->cp            = $_POST["cp"];
 127      $contact->ville         = $_POST["ville"];
 128      $contact->fk_pays       = $_POST["pays_id"];
 129      
 130      $contact->email         = $_POST["email"];
 131      $contact->phone_pro     = $_POST["phone_pro"];
 132      $contact->phone_perso   = $_POST["phone_perso"];
 133      $contact->phone_mobile  = $_POST["phone_mobile"];
 134      $contact->fax           = $_POST["fax"];
 135      $contact->jabberid      = $_POST["jabberid"];
 136      
 137      $contact->note          = $_POST["note"];
 138      
 139      $result = $contact->update($_POST["contactid"], $user);
 140      
 141      if ($contact->error) 
 142      {
 143          $error = $contact->error;
 144      }
 145  }
 146  
 147  
 148  /*
 149   *
 150   *
 151   */
 152  
 153  llxHeader();
 154  $form = new Form($db);
 155  
 156  if ($socid)
 157  {
 158      $objsoc = new Societe($db);
 159      $objsoc->fetch($socid);
 160  }
 161  
 162  
 163  /*
 164   * Onglets
 165   */
 166  if ($_GET["id"] > 0)
 167  {
 168      // Si edition contact deja existant
 169      $contact = new Contact($db);
 170      $return=$contact->fetch($_GET["id"], $user);
 171      if ($return < 0)
 172      {
 173          dolibarr_print_error('',$contact->error);
 174      }
 175      
 176      $h=0;
 177      $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"];
 178      $head[$h][1] = $langs->trans("General");
 179      $hselected=$h;
 180      $h++;
 181      
 182      $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"];
 183      $head[$h][1] = $langs->trans("PersonalInformations");
 184      $h++;
 185      
 186      $head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"];
 187      $head[$h][1] = $langs->trans("ExportImport");
 188      $h++;
 189      
 190      $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"];
 191      $head[$h][1] = $langs->trans("Info");
 192      $h++;
 193      
 194      dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name);
 195  }
 196  
 197  
 198  /*
 199   * Confirmation de la suppression du contact
 200   *
 201   */
 202  if ($_GET["action"] == 'delete')
 203  {
 204      $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Êtes-vous sûr de vouloir supprimer ce contact&nbsp;?","confirm_delete");
 205      print '<br>';
 206  }
 207  
 208  if ($_GET["action"] == 'create')
 209  {
 210      /*
 211       * Fiche en mode creation
 212       *
 213       */
 214      print_fiche_titre($langs->trans("AddContact"));
 215  
 216      // Affiche les erreurs
 217      if (sizeof($error))
 218      {
 219          print "<div class='error'>";
 220          print join("<br>",$error);
 221          print "</div>\n";
 222      }
 223  
 224      print '<br>';
 225      print '<form method="post" action="fiche.php">';
 226      print '<input type="hidden" name="action" value="add">';
 227      print '<table class="border" width="100%">';
 228  
 229      if ($socid)
 230      {
 231          // On remplit avec le numéro de la société par défaut
 232          if (strlen(trim($contact->phone_pro)) == 0)
 233          {
 234              $contact->phone_pro = $objsoc->tel;
 235          }
 236  
 237          print '<tr><td>'.$langs->trans("Company").'</td>';
 238          print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socid.'">'.$objsoc->nom.'</a></td>';
 239          print '<input type="hidden" name="socid" value="'.$objsoc->id.'">';
 240          print '</td></tr>';
 241      }
 242      else {
 243          print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
 244          //print $form->select_societes('','socid','');
 245          print $langs->trans("ContactNotLinkedToCompany");
 246          print '</td></tr>';
 247      }
 248  
 249      print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
 250      print $form->select_civilite($contact->civilite_id);
 251      print '</td></tr>';
 252  
 253      print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>';
 254      print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="15" maxlength="80" value="'.$contact->firstname.'"></td></tr>';
 255  
 256      print '<tr><td>Poste/Fonction</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td>';
 257  
 258      print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><input name="address" type="text" size="50" maxlength="80" value="'.$contact->address.'"></td>';
 259  
 260      print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.$contact->cp.'">&nbsp;';
 261      print '<input name="ville" type="text" size="20" value="'.$contact->ville.'" maxlength="80"></td></tr>';
 262  
 263      print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
 264      $form->select_pays($contact->fk_pays);
 265      print '</td></tr>';
 266  
 267      print '<tr><td>Tel Pro</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.$contact->phone_pro.'"></td>';
 268      print '<td>Tel Perso</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->phone_perso.'"></td></tr>';
 269  
 270      print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>';
 271      print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>';
 272  
 273      print '<tr><td>'.$langs->trans("Email").'</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td></tr>';
 274  
 275      print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.$contact->jabberid.'"></td></tr>';
 276  
 277      print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="note"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.$contact->note.'</textarea></td></tr>';
 278  
 279      print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
 280      print "</table><br>";
 281  
 282      print "</form>";
 283  }
 284  elseif ($_GET["action"] == 'edit' && $_GET["id"])
 285  {
 286      /*
 287       * Fiche en mode edition
 288       *
 289       */
 290  
 291      // Affiche les erreurs
 292      if (sizeof($error))
 293      {
 294          print "<div class='error'>";
 295          print join("<br>",$error);
 296          print "</div>\n";
 297      }
 298  
 299      print '<form method="post" action="fiche.php?id='.$_GET["id"].'">';
 300      print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
 301      print '<input type="hidden" name="action" value="update">';
 302      print '<input type="hidden" name="contactid" value="'.$contact->id.'">';
 303      print '<input type="hidden" name="old_name" value="'.$contact->name.'">';
 304      print '<input type="hidden" name="old_firstname" value="'.$contact->firstname.'">';
 305      print '<table class="border" width="100%">';
 306  
 307      if ($contact->socid > 0)
 308      {
 309          $objsoc = new Societe($db);
 310          $objsoc->fetch($contact->socid);
 311  
 312          print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->nom_url.'</td></tr>';
 313      }
 314      else
 315      {
 316          print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">';
 317          print $langs->trans("ContactNotLinkedToCompany");
 318          print '</td></tr>';
 319      }
 320      print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
 321      print $form->select_civilite($contact->civilite_id);
 322      print '</td></tr>';
 323  
 324      print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>';
 325      print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="20" maxlength="80" value="'.$contact->firstname.'"></td></tr>';
 326  
 327      print '<tr><td>Poste/Fonction</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td></tr>';
 328  
 329      print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><input name="address" type="text" size="50" maxlength="80" value="'.$contact->address.'"></td>';
 330  
 331      print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.$contact->cp.'">&nbsp;';
 332      print '<input name="ville" type="text" size="20" value="'.$contact->ville.'" maxlength="80"></td></tr>';
 333  
 334      print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
 335      $form->select_pays($contact->fk_pays);
 336      print '</td></tr>';
 337  
 338      print '<tr><td>Tel Pro</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.$contact->phone_pro.'"></td>';
 339      print '<td>Tel Perso</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->phone_perso.'"></td></tr>';
 340  
 341      print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>';
 342      print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>';
 343  
 344      print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="40" maxlength="80" value="'.$contact->email.'"></td>';
 345      if ($conf->mailing->enabled)
 346      {
 347          $langs->load("mails");
 348          print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>';
 349          print '<td>'.$contact->getNbOfEMailings().'</td>';
 350      }
 351      else
 352      {
 353          print '<td colspan="2">&nbsp;</td>';
 354      }
 355      print '</tr>';
 356  
 357      print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="40" maxlength="80" value="'.$contact->jabberid.'"></td></tr>';
 358  
 359      print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">';
 360      print '<textarea name="note" cols="70" rows="'.ROWS_3.'">';
 361      print $contact->note;
 362      print '</textarea></td></tr>';
 363  
 364      $contact->load_ref_elements();
 365      
 366      if ($conf->facture->enabled)
 367      {
 368          print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
 369          if ($contact->ref_facturation)
 370          {
 371              print $contact->ref_facturation." ";
 372              if ($contact->ref_facturation > 1) print $langs->trans("Invoices");
 373              else  print $langs->trans("Invoice");
 374          }
 375          else print $langs->trans("NoContactForAnyInvoice");
 376          print '</td></tr>';
 377      }
 378      
 379      if ($conf->contrat->enabled)
 380      {
 381          print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
 382          if ($contact->ref_contrat)
 383          {
 384              print $contact->ref_contrat." ";
 385              if ($contact->ref_contrat > 1) print $langs->trans("Contracts");
 386              else  print $langs->trans("Contract");
 387          }
 388          else print $langs->trans("NoContactForAnyContract");
 389          print '</td></tr>';
 390      }
 391      
 392      print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
 393      if ($contact->user_id) print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$contact->user_id.'">'.$contact->user_login.'</a>';
 394      else print $langs->trans("NoDolibarrAccess");
 395      print '</td></tr>';
 396      
 397      print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
 398      print '</table>';
 399  
 400      print "</form>";
 401  }
 402  elseif ($_GET["id"])
 403  {
 404      /*
 405       * Fiche en mode visualisation
 406       *
 407       */
 408      
 409      print '<table class="border" width="100%">';
 410      
 411      if ($contact->socid > 0)
 412      {
 413          $objsoc = new Societe($db);
 414          $objsoc->fetch($contact->socid);
 415  
 416          print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->nom_url.'</td></tr>';
 417      }
 418      else
 419      {
 420          print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
 421          print $langs->trans("ContactNotLinkedToCompany");
 422          print '</td></tr>';
 423      }
 424      
 425      print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
 426      print $form->civilite_name($contact->civilite_id);
 427      print '</td></tr>';
 428      
 429      print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td>'.$contact->name.'</td>';
 430      print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
 431      
 432      print '<tr><td>Poste/Fonction</td><td colspan="3">'.$contact->poste.'</td>';
 433      
 434      print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">'.$contact->address.'</td></tr>';
 435      
 436      print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$contact->cp.'&nbsp;';
 437      print $contact->ville.'</td></tr>';
 438      
 439      print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
 440      print $contact->pays;
 441      print '</td></tr>';
 442  
 443      print '<tr><td>Tel Pro</td><td>'.$contact->phone_pro.'</td>';
 444      print '<td>Tel Perso</td><td>'.$contact->phone_perso.'</td></tr>';
 445      
 446      print '<tr><td>Portable</td><td>'.$contact->phone_mobile.'</td>';
 447      print '<td>'.$langs->trans("Fax").'</td><td>'.$contact->fax.'</td></tr>';
 448      
 449      print '<tr><td>'.$langs->trans("EMail").'</td><td>';
 450      if ($contact->email && ! ValidEmail($contact->email))
 451      {
 452          print '<font class="error">'.$langs->trans("ErrorBadEMail",$contact->email)."</font>";
 453      }
 454      else
 455      {
 456          print $contact->email;
 457      }
 458      print '</td>';
 459      if ($conf->mailing->enabled)
 460      {
 461          $langs->load("mails");
 462          print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>';
 463          print '<td>'.$contact->getNbOfEMailings().'</td>';
 464      }
 465      else
 466      {
 467          print '<td colspan="2">&nbsp;</td>';
 468      }
 469      print '</tr>';
 470  
 471      print '<tr><td>Jabberid</td><td colspan="3">'.$contact->jabberid.'</td></tr>';
 472      
 473      print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">';
 474      print nl2br($contact->note);
 475      print '</td></tr>';
 476      
 477      $contact->load_ref_elements();
 478      
 479      if ($conf->facture->enabled)
 480      {
 481          print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
 482          if ($contact->ref_facturation)
 483          {
 484              print $contact->ref_facturation." ";
 485              if ($contact->ref_facturation > 1) print $langs->trans("Invoices");
 486              else  print $langs->trans("Invoice");
 487          }
 488          else print $langs->trans("NoContactForAnyInvoice");
 489          print '</td></tr>';
 490      }
 491      
 492      if ($conf->contrat->enabled)
 493      {
 494          print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
 495          if ($contact->ref_contrat)
 496          {
 497              print $contact->ref_contrat." ";
 498              if ($contact->ref_contrat > 1) print $langs->trans("Contracts");
 499              else  print $langs->trans("Contract");
 500          }
 501          else print $langs->trans("NoContactForAnyContract");
 502          print '</td></tr>';
 503      }
 504      
 505      print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
 506      if ($contact->user_id) print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$contact->user_id.'">'.$contact->user_login.'</a>';
 507      else print $langs->trans("NoDolibarrAccess");
 508      print '</td></tr>';
 509      
 510      print "</table>";
 511      
 512      print "</div>";
 513      
 514      
 515      // Barre d'actions
 516      if (! $user->societe_id)
 517      {
 518          print '<div class="tabsAction">';
 519              
 520              if ($user->rights->societe->contact->creer)
 521              {
 522          print '<a class="tabAction" href="fiche.php?id='.$contact->id.'&amp;action=edit">'.$langs->trans('Edit').'</a>';
 523            }
 524      
 525          if (! $contact->user_id && $user->admin)
 526          {
 527              print '<a class="tabAction" href="fiche.php?id='.$contact->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
 528          }
 529              
 530              if ($user->rights->societe->contact->supprimer)
 531              {
 532                  print '<a class="butDelete" href="fiche.php?id='.$contact->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
 533          }
 534      
 535          print "</div><br>";
 536      }
 537      
 538      
 539      // Historique des actions sur ce contact
 540      print_titre ($langs->trans("TasksHistoryForThisContact"));
 541      $histo=array();
 542      $numaction = 0 ;
 543      
 544      // Recherche histo sur actioncomm
 545      $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, a.note, a.percent as percent,";
 546      $sql.= " c.code as acode, c.libelle,";
 547      $sql.= " u.rowid as user_id, u.code";
 548      $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u ";
 549      $sql.= " WHERE fk_contact = ".$contact->id;
 550      $sql.= " AND u.rowid = a.fk_user_author";
 551      $sql.= " AND c.id=a.fk_action";
 552      $sql.= " ORDER BY a.datea DESC, a.id DESC";
 553      
 554      $resql=$db->query($sql);
 555      if ($resql)
 556      {
 557          $i = 0 ;
 558          $num = $db->num_rows($resql);
 559          $var=true;
 560          while ($i < $num)
 561          {
 562              $obj = $db->fetch_object($resql);
 563              $histo[$numaction]=array('type'=>'action','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent,
 564                               'acode'=>$obj->acode,'libelle'=>$obj->libelle,
 565                               'userid'=>$obj->user_id,'code'=>$obj->code);
 566              $numaction++;
 567              $i++;
 568          }
 569      }
 570      else
 571      {
 572          dolibarr_print_error($db);
 573      }
 574  
 575      // Recherche histo sur mailing
 576      $sql = "SELECT m.rowid as id, ".$db->pdate("mc.date_envoi")." as da, m.titre as note, '100' as percent,";
 577      $sql.= " 'AC_EMAILING' as acode,";
 578      $sql.= " u.rowid as user_id, u.code";
 579      $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u ";
 580      $sql.= " WHERE mc.email = '".$contact->email."'";
 581      $sql.= " AND mc.statut = 1";
 582      $sql.= " AND u.rowid = m.fk_user_valid";
 583      $sql.= " AND mc.fk_mailing=m.rowid";
 584      $sql.= " ORDER BY mc.date_envoi DESC, m.rowid DESC";
 585  
 586      $resql=$db->query($sql);
 587      if ($resql)
 588      {
 589          $i = 0 ;
 590          $num = $db->num_rows($resql);
 591          $var=true;
 592          while ($i < $num)
 593          {
 594              $obj = $db->fetch_object($resql);
 595              $histo[$numaction]=array('type'=>'mailing','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent,
 596                               'acode'=>$obj->acode,'libelle'=>$obj->libelle,
 597                               'userid'=>$obj->user_id,'code'=>$obj->code);
 598              $numaction++;
 599              $i++;
 600          }
 601      }
 602      else
 603      {
 604          dolibarr_print_error($db);
 605      }
 606  
 607      // Affichage actions sur contact
 608      print '<table width="100%" class="noborder">';
 609      
 610      print '<tr class="liste_titre">';
 611      print '<td>'.$langs->trans("Date").'</td>';
 612      print '<td align="center">'.$langs->trans("Status").'</td>';
 613      print '<td>'.$langs->trans("Actions").'</td>';
 614      print '<td>'.$langs->trans("Comments").'</td>';
 615      print '<td>'.$langs->trans("Author").'</td></tr>';
 616  
 617      foreach ($histo as $key=>$value)
 618      {
 619          $var=!$var;
 620          print "<tr $bc[$var]>";
 621  
 622          // Date
 623          print "<td>". dolibarr_print_date($histo[$key]['date'],"%d %b %Y %H:%M") ."</td>";
 624  
 625          // Status/Percent
 626          if ($histo[$key]['percent'] < 100) {
 627              print "<td align=\"center\">".$histo[$key]['percent']."%</td>";
 628          }
 629          else {
 630              print "<td align=\"center\">".$langs->trans("Done")."</td>";
 631          }
 632  
 633          // Action
 634          print '<td>';
 635          if ($histo[$key]['type']=='action')
 636          {
 637              print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowTask"),"task").' ';
 638              $transcode=$langs->trans("Action".$histo[$key]['acode']);
 639              $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['libelle']);
 640              print dolibarr_trunc($libelle,30);
 641              print '</a>';
 642          }
 643          if ($histo[$key]['type']=='mailing')
 644          {
 645              print '<a href="'.DOL_URL_ROOT.'/comm/mailing/fiche.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"),"email").' ';
 646              $transcode=$langs->trans("Action".$histo[$key]['acode']);
 647              $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing');
 648              print dolibarr_trunc($libelle,30);
 649              print '</a>';
 650          }
 651          print '</td>';
 652  
 653          // Note
 654          print '<td>'.dolibarr_trunc($histo[$key]['note'], 30).'</td>';
 655  
 656          // Author
 657          print '<td>';
 658          if ($histo[$key]['code'])
 659          {
 660              print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$histo[$key]['userid'].'">'.img_object($langs->trans("ShowUser"),'user').' '.$histo[$key]['code'].'</a>';
 661          }
 662          else print "&nbsp;";
 663          print "</td>";
 664          print "</tr>\n";
 665      }
 666      print "</table>";
 667    
 668      print '<br>';
 669  }
 670  
 671  $db->close();
 672  
 673  llxFooter('$Date: 2005/12/20 22:55:44 $ - $Revision: 1.64.2.1 $');
 674  
 675  ?>


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