[ 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/comm/mailing/ -> cibles.php (source)

   1  <?PHP
   2  /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2005 Laurent Destailleur  <eldy@uers.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: cibles.php,v 1.27 2005/11/08 00:26:34 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/mailing/cibles.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/comm/mailing/cibles.php
  25          \ingroup    mailing
  26          \brief      Page des cibles de mailing
  27          \version    $Revision: 1.27 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  
  32  $langs->load("mails");
  33  
  34  $user->getrights("mailing");
  35  
  36  if (! $user->rights->mailing->lire || $user->societe_id > 0)
  37    accessforbidden();
  38  
  39  
  40  $dir=DOL_DOCUMENT_ROOT."/includes/modules/mailings";
  41  $mesg = '';
  42  
  43  
  44  $page=$_GET["page"];
  45  $sortorder=$_GET["sortorder"];
  46  $sortfield=$_GET["sortfield"];
  47  
  48  if ($page == -1) { $page = 0 ; }
  49  
  50  $offset = $conf->liste_limit * $_GET["page"] ;
  51  $pageprev = $_GET["page"] - 1;
  52  $pagenext = $_GET["page"] + 1;
  53  
  54  if (! $sortorder) $sortorder="ASC";
  55  if (! $sortfield) $sortfield="nom";
  56  
  57  
  58  
  59  /*
  60   * Actions
  61   */
  62  if ($_GET["action"] == 'add')
  63  {
  64      $modulename=$_GET["module"];
  65      
  66      // Chargement de la classe
  67      $file = $dir."/".$modulename.".modules.php";
  68      $classname = "mailing_".$modulename;
  69      require_once($file);
  70      
  71      $filtersarray=array();
  72      if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"];
  73      
  74      $obj = new $classname($db);
  75      $result=$obj->add_to_target($_GET["rowid"],$filtersarray);
  76  
  77      if ($result > 0)
  78      {
  79          Header("Location: cibles.php?id=".$_GET["rowid"]);
  80          exit;
  81      }
  82      if ($result == 0)
  83      {
  84          $mesg='<div class="warning">'.$langs->trans("WarningNoEMailsAdded").'</div>';
  85      }   
  86      if ($result < 0)
  87      {
  88          $mesg='<div class="error">'.$obj->error.'</div>';
  89      }   
  90      $_GET["id"]=$_GET["rowid"];
  91  }
  92  
  93  if ($_GET["action"] == 'clear')
  94  {
  95      // Chargement de la classe
  96      $file = $dir."/modules_mailings.php";
  97      $classname = "MailingTargets";
  98      require_once($file);
  99      
 100      $obj = new $classname($db);
 101      $obj->clear_target($_GET["rowid"]);
 102     
 103      Header("Location: cibles.php?id=".$_GET["rowid"]);
 104  }
 105  
 106  if ($_GET["action"] == 'delete')
 107  {
 108      // Ici, rowid indique le destinataire et id le mailing
 109      $sql="DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles where rowid=".$_GET["rowid"];
 110      $resql=$db->query($sql);
 111      if ($resql)
 112      {
 113          $file = $dir."/modules_mailings.php";
 114          $classname = "MailingTargets";
 115          require_once($file);
 116          
 117          $obj = new $classname($db);
 118          $obj->update_nb($_GET["id"]);
 119      }
 120      else
 121      {
 122          dolibarr_print_error($db);
 123      }
 124  }
 125  
 126  
 127  /*
 128   * Liste des destinataires
 129   */
 130  
 131  llxHeader("","",$langs->trans("MailCard"));
 132  
 133  $mil = new Mailing($db);
 134  
 135  $html = new Form($db);
 136  if ($mil->fetch($_GET["id"]) == 0)
 137  {
 138      
 139      $h=0;
 140      $head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
 141      $head[$h][1] = $langs->trans("MailCard");
 142      $h++;
 143      
 144      $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id;
 145      $head[$h][1] = $langs->trans("MailRecipients");
 146      $hselected = $h;
 147      $h++;
 148  
 149      /*
 150      $head[$h][0] = DOL_URL_ROOT."/comm/mailing/history.php?id=".$mil->id;
 151      $head[$h][1] = $langs->trans("MailHistory");
 152      $h++;
 153      */
 154      dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing").": ".substr($mil->titre,0,20));
 155      
 156      
 157      print '<table class="border" width="100%">';
 158      
 159      print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$mil->id.'</td></tr>';
 160      print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
 161      print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.htmlentities($mil->email_from).'</td></tr>';
 162      print '<tr><td width="25%">'.$langs->trans("TotalNbOfDistinctRecipients").'</td><td colspan="3">'.($mil->nbemail?$mil->nbemail:'<font class="error">'.$langs->trans("NoTargetYet").'</font>').'</td></tr>';
 163      print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->statuts[$mil->statut].'</td></tr>';
 164      print '</table>';
 165      
 166      print "</div>";
 167      
 168      if ($mesg) print "$mesg<br>\n";
 169  
 170      $var=!$var;
 171  
 172      // Affiche les listes de sélection
 173      if ($mil->statut == 0)
 174      {
 175          print '<form action="cibles.php?action=clear&rowid='.$mil->id.'" method="POST">';
 176          print_titre($langs->trans("ToClearAllRecipientsClickHere").' &nbsp; <input type="submit" class="button" value="'.$langs->trans("TargetsReset").'"></form>');
 177          print '<br>';
 178                  
 179          print_titre($langs->trans("ToAddRecipientsChooseHere"));
 180          print '<table class="noborder" width="100%">';
 181          print '<tr class="liste_titre">';
 182          print '<td>'.$langs->trans("RecipientSelectionModules").'</td>';
 183          print '<td align="center">'.$langs->trans("NbOfUniqueEMails").'</td>';
 184          print '<td align="center">'.$langs->trans("Filter").'</td>';
 185          print '<td align="center" width="120">&nbsp;</td>';
 186          print "</tr>\n";
 187          
 188          clearstatcache();
 189          
 190          $handle=opendir($dir);
 191          
 192          $var=True;
 193          while (($file = readdir($handle))!==false)
 194          {
 195              if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 196              {
 197                  if (eregi("(.*)\.(.*)\.(.*)",$file,$reg)) {
 198                      $modulename=$reg[1];
 199          
 200                      // Chargement de la classe
 201                      $file = $dir."/".$modulename.".modules.php";
 202                      $classname = "mailing_".$modulename;
 203                      require_once($file);
 204          
 205                      $obj = new $classname($db);
 206  
 207                      $qualified=1;
 208                      foreach ($obj->require_module as $key)
 209                      {
 210                          if (! $conf->$key->enabled || (! $user->admin && $obj->require_admin))
 211                          {
 212                              $qualified=0;
 213                              //print "Les prérequis d'activation du module mailing ne sont pas respectés. Il ne sera pas actif";
 214                              break;
 215                          }
 216                      }
 217                      
 218                      // Si le module mailing est qualifié
 219                      if ($qualified)
 220                      {
 221                          $var = !$var;
 222                          print '<tr '.$bc[$var].'>';
 223                          
 224                          if ($mil->statut == 0) print '<form action="cibles.php?action=add&rowid='.$mil->id.'&module='.$modulename.'" method="POST">';
 225                          
 226                          print '<td>';
 227                          print img_object('',$obj->picto).' '.$obj->getDesc();
 228                          print '</td>';
 229              
 230                          /*
 231                          print '<td width=\"100\">';
 232                          print $modulename;
 233                          print "</td>";
 234                          */
 235                          print '<td align="center">'.($obj->getNbOfRecipients()).'</td>';
 236  
 237                          print '<td align="center">';
 238                          print $obj->formFilter();
 239                          print '</td>';
 240          
 241                          print '<td align="center">';
 242                          if ($mil->statut == 0)
 243                          {
 244                              print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
 245                          }
 246                          else
 247                          {
 248                              //print $langs->trans("MailNoChangePossible");
 249                              print "&nbsp;";
 250                          }
 251                          print '</td>';
 252  
 253                          if ($mil->statut == 0) print '</form>';
 254                          
 255                          print "</tr>\n";
 256                      }
 257                  }
 258              }
 259          }
 260          closedir($handle);
 261  
 262          print '</table><br>';
 263      }
 264      
 265  
 266      // Liste des destinataires sélectionnés
 267      $sql  = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email, mc.statut, mc.date_envoi, mc.url";
 268      $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
 269      $sql .= " WHERE mc.fk_mailing=".$mil->id;
 270      if ($sortfield) { $sql .= " ORDER BY $sortfield $sortorder"; }
 271      $sql .= $db->plimit($conf->liste_limit+1, $offset);
 272      
 273      $resql=$db->query($sql);
 274      if ($resql)
 275      {
 276          $num = $db->num_rows($resql);
 277      
 278          $addu = "&amp;id=".$mil->id."&amp;page=$page";;
 279          print_barre_liste($langs->trans("MailSelectedRecipients"), $page, "cibles.php","&amp;id=".$mil->id,$sortfield,$sortorder,"",$num);
 280  
 281          print '<table class="noborder" width="100%">';
 282          print '<tr class="liste_titre">';
 283          print_liste_field_titre($langs->trans("Lastname"),"cibles.php","mc.nom",$addu,"","",$sortfield);
 284          print_liste_field_titre($langs->trans("Firstname"),"cibles.php","mc.prenom",$addu,"","",$sortfield);
 285          print_liste_field_titre($langs->trans("EMail"),"cibles.php","mc.email",$addu,"","",$sortfield);
 286          print '<td align="center">&nbsp;</td>';
 287          print '<td align="center">'.$langs->trans("Status").'</td>';
 288          if ($mil->statut == 0)
 289          {
 290              print '<td>&nbsp;</td>';
 291          }
 292          if ($mil->statut != 0)
 293          {
 294              print '<td align="center">'.$langs->trans("Date").'</td>';
 295          }        
 296          print '</tr>';
 297          $var = true;
 298          $i = 0;
 299      
 300          while ($i < $num)
 301          {
 302              $obj = $db->fetch_object($resql);
 303              $var=!$var;
 304      
 305              print "<tr $bc[$var]>";
 306              print '<td>'.stripslashes($obj->nom).'</td>';
 307              print '<td>'.stripslashes($obj->prenom).'</td>';
 308              print '<td>'.$obj->email.'</td>';
 309              print '<td>'.$obj->url.'</td>';
 310              if ($mil->statut == 0)
 311              {
 312                  print '<td align="center">'.$langs->trans("MailingStatusNotSent").'</td>';
 313                  print '<td><a href="cibles.php?action=delete&id='.$mil->id.'&rowid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveRecipient")).'</td>';
 314              }
 315              if ($mil->statut != 0)
 316              {
 317                  print '<td align="center">';
 318                  if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error();
 319                  if ($obj->statut==1) print $langs->trans("MailingStatusSent");
 320                  print '</td>';
 321                  print '<td align="center">'.$obj->date_envoi.'</td>';
 322              }        
 323              print '</tr>';
 324  
 325              $i++;
 326          }
 327      
 328          print "</table><br>";
 329      
 330          $db->free($resql);
 331      }
 332      else
 333      {
 334          dolibarr_print_error($db);
 335      }
 336  }
 337    
 338  
 339  $db->close();
 340  
 341  llxFooter('$Date: 2005/11/08 00:26:34 $ - $Revision: 1.27 $');
 342  ?>


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