From d542e335a8c54db1297e92d7f1763ec0a8f507bb Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 9 May 2005 08:25:43 +0000 Subject: [PATCH] Nouveau fichier --- .../telephonie/script/import-rename-cdr.php | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 htdocs/telephonie/script/import-rename-cdr.php diff --git a/htdocs/telephonie/script/import-rename-cdr.php b/htdocs/telephonie/script/import-rename-cdr.php new file mode 100644 index 00000000000..2847f367506 --- /dev/null +++ b/htdocs/telephonie/script/import-rename-cdr.php @@ -0,0 +1,97 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + * Script d'import des CDR BT + */ + +require ("../../master.inc.php"); + +$opt = getopt("f:i:"); + +$file = $opt['f']; +$id_fourn = $opt['i']; + +if (strlen($file) == 0 ) +{ + print "Usage :\n php import-cdr-bt.php -f \n"; + exit; +} + +/* + * Traitement + * + */ + +$files = array(); + +if (is_dir($file)) +{ + $handle=opendir($file); + + if ($handle) + { + $i = 0 ; + $var=True; + + while (($xfile = readdir($handle))!==false) + { + if (is_file($file.$xfile) && substr($xfile, -4) == ".csv") + { + $files[$i] = $file.$xfile; + dolibarr_syslog($file.$xfile." ajouté"); + $i++; + } + else + { + dolibarr_syslog($file.$xfile." ignoré"); + } + } + + closedir($handle); + } + else + { + dolibarr_syslog("Impossible de libre $file"); + exit ; + } +} +elseif (is_file($file)) +{ + $files[0] = $file; +} +else +{ + dolibarr_syslog("Impossible de libre $file"); + exit ; +} + +$datef = strftime("%y%m", (time() - (15*3600*24)) ); + +foreach ($files as $xfile) +{ + if (is_readable($xfile)) + { + $newfile = ereg_replace(".csv","-".$datef.".csv", $xfile); + + rename ($xfile, $newfile); + } +} + +return $error;