From f1b4980eeea5456f0299ceb988bfc2f7fe961dcc Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 10 Jul 2007 07:48:27 +0000 Subject: [PATCH] Nouveau fichier --- .../telephonie/adsl/fournisseurxdsl.class.php | 129 ++++++++++++++++++ htdocs/telephonie/config/xdsl.php | 105 ++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 htdocs/telephonie/adsl/fournisseurxdsl.class.php create mode 100644 htdocs/telephonie/config/xdsl.php diff --git a/htdocs/telephonie/adsl/fournisseurxdsl.class.php b/htdocs/telephonie/adsl/fournisseurxdsl.class.php new file mode 100644 index 00000000000..85e49bd252f --- /dev/null +++ b/htdocs/telephonie/adsl/fournisseurxdsl.class.php @@ -0,0 +1,129 @@ + + * + * 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$ + * + */ + +class FournisseurXdsl { + var $db; + var $id; + + /** + * Constructeur de la classe + * + */ + function FournisseurXdsl($DB, $id=0, $user=0) + { + global $config; + $this->id = $id; + $this->db = $DB; + $this->error_message = ''; + + return 1; + } + /** + * Cree le fournisseur dans la base de donnees + * + */ + function Create($user) + { + if ($this->socid > 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_adsl_fournisseur"; + $sql .= " (fk_soc, commande_active)"; + $sql .= " VALUES ("; + $sql .= " $this->socid,1)"; + + $resql = $this->db->query($sql); + + if ( $resql ) + { + $this->id = $this->db->last_insert_id($resql); + return 0; + } + else + { + dolibarr_syslog("FournisseurXdsl::Create Error -3"); + return -3; + } + } + else + { + dolibarr_syslog("FournisseurXdsl::Create Error -2"); + return -2; + } + } + /** + * + * + */ + function SwitchCommandeActive($id) + { + $sql= "UPDATE ".MAIN_DB_PREFIX."telephonie_adsl_fournisseur as f"; + $sql.= " SET commande_active = abs(commande_active -1) WHERE f.rowid =".$id.";"; + + $resql=$this->db->query($sql); + + if ($resql) + { + return 0; + } + else + { + dolibarr_syslog("FournisseurXdsl::SwithCommandeActive Error -20", LOG_ERR); + return -20; + } + + } + /** + * Retourne la liste des fournisseurs + * + */ + function ListArray() + { + $arr = array(); + + $sql = "SELECT f.rowid, s.nom, f.commande_active"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_adsl_fournisseur as f"; + $sql.= " WHERE s.fournisseur = 1 AND s.rowid=f.fk_soc"; + + $resql=$this->db->query($sql); + + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $arr[$obj->rowid]['rowid'] = $obj->rowid; + $arr[$obj->rowid]['name'] = stripslashes($obj->nom); + $arr[$obj->rowid]['commande_active'] = $obj->commande_active; + } + + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + + } + + return $arr; + } + +} +?> diff --git a/htdocs/telephonie/config/xdsl.php b/htdocs/telephonie/config/xdsl.php new file mode 100644 index 00000000000..e20c64e08d5 --- /dev/null +++ b/htdocs/telephonie/config/xdsl.php @@ -0,0 +1,105 @@ + + * + * 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$ + */ + +/** + \file htdocs/telephonie/config/xdsl.php + \ingroup telephonie + \brief Page configuration telephonie + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/telephonie/adsl/fournisseurxdsl.class.php'); + +$langs->load("admin"); + +if (!$user->admin) accessforbidden(); + +if ($_GET["action"] == "addfourn") +{ + + $fourn = new FournisseurXdsl($db); + $fourn->socid = $_POST["fourn"]; + $fourn->create($user); + + Header("Location: xdsl.php"); +} + +if ($_GET["action"] == "switch") +{ + $fourn = new FournisseurXdsl($db); + $fourn->SwitchCommandeActive($_GET['id']); + + Header("Location: xdsl.php"); +} + +/* + * + * + * + */ +llxHeader('','Téléphonie - Configuration - Liens xDSL'); + +dolibarr_fiche_head($head, $hselected, "Configuration des liens xDSL"); + +print_titre("Fournisseurs"); +print '
'; +print ''; + +$form = new Form($db); +$fourn = new Fournisseur($db,0,$user); +$fourns = $fourn->ListArray(); + +$xfourn = new FournisseurXdsl($db,0,$user); +$xfourns = $xfourn->ListArray(); + +/* ***************************************** */ + +print ''; +print ''; + +print ''; +print ''; +print ''; +print "\n"; + +foreach ($xfourns as $id => $name) +{ + $var=!$var; + print "'; + print ''; + print ''; +} + +print '
Ajouter un fournisseur'; + +$form->select_array("fourn",$fourns); + +print ''; +print '
NomCommande possible 
".$name['name'].''.$langs->trans($yesno[$name['commande_active']]).'Changer'; + print '
'; +print '
'; + +$db->close(); + +llxFooter(); +?>