From 6c4a7435acf3c145bd77458983d96d1100799935 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Thu, 31 May 2007 12:14:45 +0000 Subject: [PATCH] Gestion du format de CDR associe --- htdocs/telephonie/fournisseur/fiche.php | 28 ++++++++++++-- htdocs/telephonie/fournisseurtel.class.php | 45 +++++++++++++++++----- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/htdocs/telephonie/fournisseur/fiche.php b/htdocs/telephonie/fournisseur/fiche.php index 7580adb2701..6b08db901c3 100644 --- a/htdocs/telephonie/fournisseur/fiche.php +++ b/htdocs/telephonie/fournisseur/fiche.php @@ -32,10 +32,11 @@ if ($_POST["action"] == 'add') { $fourn = new FournisseurTelephonie($db); - $fourn->nom = $_POST["nom"]; - $fourn->email_commande = $_POST["email_commande"]; + $fourn->nom = $_POST["nom"]; + $fourn->email_commande = $_POST["email_commande"]; $fourn->methode_commande = $_POST["methode"]; - $fourn->grille = $_POST["grille"]; + $fourn->cdrformat = $_POST["cdrformat"]; + $fourn->grille = $_POST["grille"]; if ( $fourn->create($user) == 0) { @@ -53,6 +54,7 @@ if ($_POST["action"] == 'update' && $_GET["id"]) $fourn->num_client = $_POST["num_client"]; $fourn->email_commande = $_POST["email_commande"]; $fourn->methode_commande = $_POST["methode"]; + $fourn->cdrformat = $_POST["cdrformat"]; $fourn->commande_bloque = $_POST["commande_bloque"]; $fourn->grille = $_POST["grille"]; @@ -116,13 +118,20 @@ if ($_GET["action"] == 'create') $html = new Form($db); $arr = $fourn->array_methode(); - + $cdr = $fourn->array_cdrformat(); + print 'Méthode de commande'; print ''; print $html->select_array("methode",$arr,$fourn->class_commande); print ''; print 'méthode utilisée pour les commandes de lignes'; + print 'Format de CDR'; + print ''; + print $html->select_array("cdrformat",$cdr,$fourn->cdrformat); + print ''; + print 'Format des fichiers CDR'; + $ta->liste_name[0] = ' Creer une nouvelle grille'; asort($ta->liste_name); print 'Grille de tarif'; @@ -175,6 +184,7 @@ if ($_GET["id"] > 0) $html = new Form($db); $arr = $fourn->array_methode(); + $cdr = $fourn->array_cdrformat(); print 'Méthode de commande'; print ''; @@ -182,6 +192,12 @@ if ($_GET["id"] > 0) print ''; print 'méthode utilisée pour les commandes de lignes'; + print 'Format de CDR'; + print ''; + print $html->select_array("cdrformat",$cdr,$fourn->cdrformat); + print ''; + print 'Format des fichiers CDR'; + print 'Blocage des commandes'; print ''; @@ -235,6 +251,10 @@ if ($_GET["id"] > 0) print ''.$fourn->class_commande.''; print 'méthode utilisée pour les commandes de lignes'; + print 'Format de CDR'; + print ''.$fourn->cdrformat.''; + print 'Format des fichiers CDR'; + print 'Blocage des commandes'; print ''.$art[$fourn->commande_bloque].''; print 'Les commandes sont bloquées'; diff --git a/htdocs/telephonie/fournisseurtel.class.php b/htdocs/telephonie/fournisseurtel.class.php index 0547238f9f7..2d375a853b0 100644 --- a/htdocs/telephonie/fournisseurtel.class.php +++ b/htdocs/telephonie/fournisseurtel.class.php @@ -35,6 +35,7 @@ class FournisseurTelephonie { $this->db = $DB; $this->id = $id; $this->classdir = DOL_DOCUMENT_ROOT.'/telephonie/fournisseur/commande/'; + $this->cdrformatdir = DOL_DOCUMENT_ROOT.'/telephonie/fournisseur/cdrformat/'; return 1; } /** @@ -59,8 +60,8 @@ class FournisseurTelephonie { if ($res == 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_fournisseur"; - $sql .= " (nom, email_commande, commande_active, class_commande,fk_tarif_grille)"; - $sql .= " VALUES ('".$this->nom."','".$this->email_commande."',1,'".$this->methode_commande."',".$this->grille.")"; + $sql .= " (nom, email_commande, commande_active, class_commande,fk_tarif_grille,cdrformat)"; + $sql .= " VALUES ('".$this->nom."','".$this->email_commande."',1,'".$this->methode_commande."','".$this->grille."','".$this->cdrformat."');"; if (! $this->db->query($sql) ) { @@ -83,6 +84,7 @@ class FournisseurTelephonie { $sql .= ", num_client = '".$this->num_client."'"; $sql .= ", class_commande = '".$this->methode_commande."'"; $sql .= ", commande_bloque = '".$this->commande_bloque."'"; + $sql .= ", cdrformat = '".$this->cdrformat."'"; $sql .= " WHERE rowid = ".$this->id; @@ -102,7 +104,7 @@ class FournisseurTelephonie { $sql = "SELECT f.rowid, f.nom, f.email_commande, f.commande_active"; $sql .= ", f.class_commande, f.commande_bloque, f.fk_tarif_grille"; - $sql .= ", f.num_client"; + $sql .= ", f.num_client, f.cdrformat"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; $sql .= " WHERE f.rowid = ".$this->id; @@ -118,6 +120,7 @@ class FournisseurTelephonie { $this->commande_enable = $obj->commande_active; $this->class_commande = $obj->class_commande; $this->commande_bloque = $obj->commande_bloque; + $this->cdrformat = $obj->cdrformat; $this->grille = $obj->fk_tarif_grille; return 0; @@ -169,7 +172,7 @@ class FournisseurTelephonie { return $res; } /** - * + * Retourne la liste des classe de format de commande * * * @@ -177,16 +180,11 @@ class FournisseurTelephonie { function array_methode() { clearstatcache(); - $handle=opendir($this->classdir); - $arr = array(); while (($file = readdir($handle))!==false) { - - dolibarr_syslog($file); - if (is_readable($this->classdir.$file) && substr($file, 0, 8) == 'commande' && substr($file, -10) == '.class.php') { @@ -207,6 +205,35 @@ class FournisseurTelephonie { } return $arr; } + /** + * Retourne la liste des classe de format de commande + */ + function array_cdrformat() + { + clearstatcache(); + $handle=opendir($this->cdrformatdir); + $arr = array(); + + while (($file = readdir($handle))!==false) + { + if (is_readable($this->cdrformatdir.$file) && substr($file, 0, 9) == 'cdrformat' && substr($file, -10) == '.class.php') + { + $name = substr($file, 10, strlen($file) -20); + $filebis = $this->classdir . $file; + + // Chargement de la classe de numérotation + $classname = "CdrFormat".ucfirst($name); + + require_once($this->cdrformatdir.$file); + + $obj = new $classname($this->db); + + $arr[$name] = $obj->nom; + } + + } + return $arr; + } /** * Crée une commande pour ce fournisseur *