[ 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/ -> import-rename-cdr.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: import-rename-cdr.php,v 1.1 2005/05/09 08:25:43 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/import-rename-cdr.php,v $
  20   *
  21   * Script d'import des CDR BT
  22   */
  23  
  24  require  ("../../master.inc.php");
  25  
  26  $opt = getopt("f:i:");
  27  
  28  $file = $opt['f'];
  29  $id_fourn = $opt['i'];
  30  
  31  if (strlen($file) == 0 )
  32  {
  33    print "Usage :\n php import-cdr-bt.php -f <filename>\n";
  34    exit;
  35  }
  36  
  37  /*
  38   * Traitement
  39   *
  40   */
  41  
  42  $files = array();
  43  
  44  if (is_dir($file))
  45  {
  46    $handle=opendir($file);
  47  
  48    if ($handle)
  49      {
  50        $i = 0 ;
  51        $var=True;
  52        
  53        while (($xfile = readdir($handle))!==false)
  54      {
  55        if (is_file($file.$xfile) && substr($xfile, -4) == ".csv")
  56          {
  57            $files[$i] = $file.$xfile;
  58            dolibarr_syslog($file.$xfile." ajouté");
  59            $i++;
  60          }
  61        else
  62          {
  63            dolibarr_syslog($file.$xfile." ignoré");
  64          }
  65      }
  66        
  67        closedir($handle);
  68      }
  69    else
  70      {
  71        dolibarr_syslog("Impossible de libre $file");
  72        exit ;
  73      }
  74  }
  75  elseif (is_file($file))
  76  {
  77    $files[0] = $file;
  78  }
  79  else
  80  {
  81    dolibarr_syslog("Impossible de libre $file");
  82    exit ;
  83  }
  84  
  85  $datef = strftime("%y%m", (time() - (15*3600*24)) );
  86  
  87  foreach ($files as $xfile)
  88  {
  89    if (is_readable($xfile))
  90      {
  91        $newfile = ereg_replace(".csv","-".$datef.".csv", $xfile);
  92  
  93        rename ($xfile, $newfile);
  94      }
  95  }
  96  
  97  return $error;


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