diff --git a/htdocs/telephonie/adsl/productxdsl.class.php b/htdocs/telephonie/adsl/productxdsl.class.php new file mode 100644 index 00000000000..d745b08c51d --- /dev/null +++ b/htdocs/telephonie/adsl/productxdsl.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 ProductXdsl { + var $db; + var $id; + + /** + * Constructeur de la classe + * + */ + function ProductXdsl($DB, $id=0, $user=0) + { + global $config; + $this->id = $id; + $this->db = $DB; + $this->error_message = ''; + + return 1; + } + /** + * Cree le product dans la base de donnees + * + */ + function Create($user) + { + if ($this->prodid > 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_adsl_type"; + $sql .= " (fk_product, commande_active, intitule)"; + $sql .= " VALUES ("; + $sql .= " $this->prodid,1,'".addslashes($this->intitule)."')"; + + $resql = $this->db->query($sql); + + if ( $resql ) + { + $this->id = $this->db->last_insert_id($resql); + return 0; + } + else + { + dolibarr_syslog("ProductXdsl::Create Error -3"); + return -3; + } + } + else + { + dolibarr_syslog("ProductXdsl::Create Error -2"); + return -2; + } + } + /** + * + * + */ + function SwitchCommandeActive($id) + { + $sql= "UPDATE ".MAIN_DB_PREFIX."telephonie_adsl_type as t"; + $sql.= " SET commande_active = abs(commande_active -1) WHERE t.rowid =".$id.";"; + + $resql=$this->db->query($sql); + + if ($resql) + { + return 0; + } + else + { + dolibarr_syslog("ProductXdsl::SwithCommandeActive Error -20", LOG_ERR); + return -20; + } + + } + /** + * Retourne la liste des produits + * + */ + function ListArray() + { + $arr = array(); + + $sql = "SELECT t.rowid, t.intitule, t.commande_active"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p,".MAIN_DB_PREFIX."telephonie_adsl_type as t"; + $sql.= " WHERE p.rowid=t.fk_product;"; + + $resql=$this->db->query($sql); + + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $arr[$obj->rowid]['rowid'] = $obj->rowid; + $arr[$obj->rowid]['intitule'] = stripslashes($obj->intitule); + $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_product.php b/htdocs/telephonie/config/xdsl_product.php new file mode 100644 index 00000000000..a1549002b23 --- /dev/null +++ b/htdocs/telephonie/config/xdsl_product.php @@ -0,0 +1,131 @@ + + * + * 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/productxdsl.class.php'); + +$langs->load("admin"); +$langs->load("suppliers"); +$langs->load("products"); + +if (!$user->admin) accessforbidden(); + +if ($_GET["action"] == "addproduct") +{ + $fourn = new ProductXdsl($db); + $fourn->prodid = $_POST["prod"]; + $fourn->intitule = $_POST["intitule"]; + $fourn->create($user); + + Header("Location: xdsl_product.php"); +} + +if ($_GET["action"] == "switch") +{ + $fourn = new ProductXdsl($db); + $fourn->SwitchCommandeActive($_GET['id']); + + Header("Location: xdsl_product.php"); +} + +/* + * + * + * + */ +llxHeader('','Téléphonie - Configuration - Liens xDSL'); + +$h=0; +$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl.php"; +$head[$h][1] = $langs->trans("Suppliers"); +$h++; + +$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl_product.php"; +$head[$h][1] = $langs->trans("Products"); +$hselected = $h; +$h++; + + +dolibarr_fiche_head($head, $hselected, "Configuration des liens xDSL"); +$form = new Form($db); +print_titre($langs->trans("Products")); +print '
'; +print ''; + +$prods = array(); + +$sql = "SELECT rowid, label"; +$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; +$sql.= " WHERE p.fk_product_type = 1"; + +$resql=$db->query($sql); +if ($resql) +{ + while ($obj=$db->fetch_object($resql)) + { + $prods[$obj->rowid]=stripslashes($obj->label); + } +} +$db->free($resql); + + +$xfourn = new ProductXdsl($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 liens depuis les services'; +print ''; +$form->select_array("prod",$prods); + +print ''; +print '
NomCommande possible  
".$name['intitule'].''.$langs->trans($yesno[$name['commande_active']]).'Changer'; + print ' 
'; +print '
'; + +$db->close(); + +llxFooter(); +?>