[ 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/telephonie/script/tools/ -> verif-ligne-attente.php (source)

   1  <?PHP
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: verif-ligne-attente.php,v 1.1 2005/12/06 17:02:25 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/tools/verif-ligne-attente.php,v $
  20   *
  21   * Vérifie les lignes ayant le statut d'attente
  22   *
  23   */
  24  require  ("../../../master.inc.php");
  25  /*
  26   *
  27   */
  28  $users = array();
  29  $sqll  = "SELECT rowid,name,firstname,email";
  30  $sqll .= " FROM ".MAIN_DB_PREFIX."user";
  31  
  32  $resqll = $db->query($sqll) ;
  33  if ( $resqll )
  34  {
  35    while ($row = $db->fetch_row($resqll))
  36      {
  37        $users[$row[0]] = $row;
  38      }
  39  }
  40  
  41  else
  42  {
  43    print $db->error();
  44  }
  45  
  46  $sqll  = "SELECT l.datec, l.ligne, l.fk_commercial_sign, l.rowid";
  47  $sqll .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
  48  $sqll .= " WHERE statut = -1";
  49  $sqll .= " AND l.datec + INTERVAL 1 MONTH < now();";
  50  
  51  $resqll = $db->query($sqll);
  52  if ( $resqll )
  53  {
  54    while ($row = $db->fetch_row($resqll))
  55      {
  56  
  57        $sqlc  = "SELECT counter";
  58        $sqlc .= " FROM ".MAIN_DB_PREFIX."telephonie_alertecounter";
  59        $sqlc .= " WHERE fk_ligne = ".$row[3];
  60        $sqlc .= " AND fk_user = ".$row[2];
  61        
  62        $resqlc = $db->query($sqlc);
  63        if ( $resqlc )
  64      {
  65        if ($rowc = $db->fetch_row($resqlc))
  66          {
  67            $count = $rowc[0];
  68            $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_alertecounter";
  69            $sql .= " SET counter=counter+1 WHERE fk_ligne=".$row[3];
  70            $sql .= " AND fk_user=".$row[2].";";
  71            $db->query($sql);
  72          }
  73        else
  74          {
  75            $count = 1;
  76            $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_alertecounter";
  77            $sql .= " (fk_ligne,fk_user,counter)";
  78            $sql .= " VALUES (".$row[3].",".$row[2].",1);";
  79            $db->query($sql);
  80          }
  81      }
  82  
  83        $mesg = "Bonjour,\n\n";
  84        $mesg .= "Alerte Ligne ".$row[1]." en attente\n";
  85        $mesg .= "Depuis le ".$row[0]."\n";
  86        $mesg .= "Envoi # ".$count."\n\n";
  87        $mesg .= "--\nmessage automatique en provenance de dolibarr";
  88  
  89        $headers = 'From: metac@NE_PAS_REPONDRE.com' . "\r\n" .
  90      'Reply-To: '.$users[$row[2]][3]. "\r\n" .
  91      'X-Mailer: Dolibarr';
  92        
  93        $to = $users[$row[2]][3];
  94        $subject = "Alerte ligne en attente";
  95        
  96        mail($to,$subject,$mesg, $headers);
  97      }
  98  }
  99  
 100  else
 101  {
 102    print $db->error();
 103  }
 104  
 105  
 106  
 107  $db->close();
 108  ?>


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