From 9ee44809740fba13c9a8ba7022502cc9d0d501ef Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 17 Oct 2005 18:14:46 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/telephonie/script/retour-check.php | 136 ++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 htdocs/telephonie/script/retour-check.php diff --git a/htdocs/telephonie/script/retour-check.php b/htdocs/telephonie/script/retour-check.php new file mode 100644 index 00000000000..7cbd9f490d4 --- /dev/null +++ b/htdocs/telephonie/script/retour-check.php @@ -0,0 +1,136 @@ + + * + * 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 retour + * + * Ce script permet de rechercher des lignes inconnues chez nous + * presentes dans les fichiers de retour + * + * + */ +$verbose = 1; +require ("../../master.inc.php"); + +require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); +require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php"); +require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie-tarif.class.php"); +require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php"); +require_once (DOL_DOCUMENT_ROOT."/societe.class.php"); + +$dir = DOL_DATA_ROOT."/telephonie/ligne/commande/retour/"; +$dirdone = DOL_DATA_ROOT."/telephonie/ligne/commande/retour/traite/"; + +$dirback = DOL_DATA_ROOT."/telephonie/ligne/commande/retour/backup/"; + +if (! file_exists($dirback)) +{ + umask(0); + if (! @mkdir($dirback, 0755)) + { + dolibarr_syslog("Erreur: creation '$dir'"); + } +} + + +$handle=opendir($dir); + +if ($verbose) dolibarr_syslog("Lecture repertoire $dir"); + +while (($file = readdir($handle))!==false) +{ + if (is_file($dir.$file)) + { + if (is_readable($dir.$file)) + { + if ($verbose) dolibarr_syslog("Lecture $file"); + + if (! file_exists($dirdone)) + { + umask(0); + if (! @mkdir($dirdone, 0755)) + { + dolibarr_syslog("Erreur: creation '$dirdone'"); + } + } + + /* + * On teste le fichier + */ + check_file($db, $dir, $file); + } + else + { + dolibarr_syslog("Erreur Lecture $file permissions insuffisante"); + } + } +} + +closedir($handle); + +/** + * + * + * + */ + +Function check_file($db,$dir,$file) +{ + $error = 0; + $line = 0; + $hf = fopen ($dir.$file, "r"); + + while (!feof($hf)) + { + $cont = fgets($hf, 1024); + + $tabline = explode(";", $cont); + + if (substr($tabline, 0, 3) <> 'CLI') + { + if (sizeof($tabline) == 8) + { + $numero = $tabline[0]; + $mode = $tabline[1]; + $situation = $tabline[2]; + $date_mise_service = $tabline[3]; + $date_resiliation = $tabline[4]; + $motif_resiliation = $tabline[5]; + $commentaire = $tabline[6]; + $fichier = $file; + + $ligne = new LigneTel($db); + if ($ligne->fetch($numero) == 1) + { + + } + else + { + print "Ligne inconnue : $numero\n"; + } + + } + } + $line++; + } + + fclose($hf); + + return $error; +}