diff --git a/htdocs/telephonie/fournisseur/fiche.php b/htdocs/telephonie/fournisseur/fiche.php index 86661e025e6..a6372a8fb6e 100644 --- a/htdocs/telephonie/fournisseur/fiche.php +++ b/htdocs/telephonie/fournisseur/fiche.php @@ -21,6 +21,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/telephonie/telephonie.tarif.grille.class.php'); if (!$user->rights->telephonie->fournisseur->lire) accessforbidden(); @@ -53,7 +54,8 @@ if ($_POST["action"] == 'update' && $_GET["id"]) $fourn->email_commande = $_POST["email_commande"]; $fourn->methode_commande = $_POST["methode"]; $fourn->commande_bloque = $_POST["commande_bloque"]; - + $fourn->grille = $_POST["grille"]; + if ( $fourn->update($user) == 0) { Header("Location: fiche.php?id=".$fourn->id); @@ -90,6 +92,9 @@ if ($cancel == $langs->trans("Cancel")) $action = ''; } +$ta = new TelephonieTarifGrille($db); +$ta->GetListe($user,'achat'); + /* * Création * @@ -118,11 +123,8 @@ if ($_GET["action"] == 'create') print ''; print 'méthode utilisée pour les commandes de lignes'; - require DOL_DOCUMENT_ROOT.'/telephonie/telephonie.tarif.grille.class.php'; - - $ta = new TelephonieTarifGrille($db); - $ta->GetListe($user,'achat'); - + $ta->liste_name[0] = ' Creer une nouvelle grille'; + asort($ta->liste_name); print 'Grille de tarif'; print ''; print $html->select_array("grille",$ta->liste_name); @@ -187,6 +189,15 @@ if ($_GET["id"] > 0) print ''; print 'Les commandes vers ce fournisseur sont bloquées'; + + + print 'Grille de tarif'; + print ''; + print $html->select_array("grille",$ta->liste_name, $fourn->grille); + print ''; + print 'Grille de tarif'; + + print ''; print '
'; } @@ -223,12 +234,15 @@ if ($_GET["id"] > 0) print 'Méthode de commande'; print ''.$fourn->class_commande.''; print 'méthode utilisée pour les commandes de lignes'; - - + print 'Blocage des commandes'; print ''.$art[$fourn->commande_bloque].''; print 'Les commandes sont bloquées'; + print 'Grille de tarif'; + print ''.$ta->liste_name[$fourn->grille].''; + print 'Grille de tarif'; + print '
'; } } diff --git a/htdocs/telephonie/fournisseurtel.class.php b/htdocs/telephonie/fournisseurtel.class.php index c140d8e57b6..0547238f9f7 100644 --- a/htdocs/telephonie/fournisseurtel.class.php +++ b/htdocs/telephonie/fournisseurtel.class.php @@ -19,6 +19,7 @@ * $Source$ * */ +require_once(DOL_DOCUMENT_ROOT.'/telephonie/telephonie.tarif.grille.class.php'); class FournisseurTelephonie { var $db; @@ -40,16 +41,31 @@ class FournisseurTelephonie { * * */ - function create() + function create($user) { $res = 0; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_fournisseur"; - $sql .= " (nom, email_commande, commande_active, class_commande)"; - $sql .= " VALUES ('".$this->nom."','".$this->email_commande."',1,'".$this->methode_commande."')"; - if (! $this->db->query($sql) ) + if ($this->grille == 0) { - $res = -1; + $grille = new TelephonieTarifGrille($this->db); + + if ($grille->CreateGrille($user, $this->nom, 'achat') <> 0) + { + $res = -2; + } + $this->grille = $grille->id; + } + + 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.")"; + + if (! $this->db->query($sql) ) + { + $res = -1; + } } return $res; } @@ -85,7 +101,7 @@ class FournisseurTelephonie { $this->id = $id; $sql = "SELECT f.rowid, f.nom, f.email_commande, f.commande_active"; - $sql .= ", f.class_commande, f.commande_bloque"; + $sql .= ", f.class_commande, f.commande_bloque, f.fk_tarif_grille"; $sql .= ", f.num_client"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; $sql .= " WHERE f.rowid = ".$this->id; @@ -102,6 +118,7 @@ class FournisseurTelephonie { $this->commande_enable = $obj->commande_active; $this->class_commande = $obj->class_commande; $this->commande_bloque = $obj->commande_bloque; + $this->grille = $obj->fk_tarif_grille; return 0; }