diff --git a/htdocs/telephonie/facture/pre.inc.php b/htdocs/telephonie/facture/pre.inc.php index 6a52f0cc74b..411695ff8d0 100644 --- a/htdocs/telephonie/facture/pre.inc.php +++ b/htdocs/telephonie/facture/pre.inc.php @@ -56,7 +56,7 @@ function llxHeader($head = "", $title="") { $menu->add_submenu(DOL_URL_ROOT."/telephonie/facture/check.php", "Verif"); $menu->add_submenu(DOL_URL_ROOT."/telephonie/facture/stats.php", "Stats"); - $menu->add(DOL_URL_ROOT."/telephonie/fournisseurs.php", "Fournisseurs"); + $menu->add(DOL_URL_ROOT."/telephonie/fournisseur/", "Fournisseurs"); $menu->add(DOL_URL_ROOT."/telephonie/statca/", "Chiffre d'affaire"); diff --git a/htdocs/telephonie/fournisseur/fiche.php b/htdocs/telephonie/fournisseur/fiche.php new file mode 100644 index 00000000000..55be8f8a267 --- /dev/null +++ b/htdocs/telephonie/fournisseur/fiche.php @@ -0,0 +1,101 @@ + + * + * 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$ + * + */ + +require("./pre.inc.php"); + +$mesg = ''; + +if ($_POST["action"] == 'add') +{ + $fourn = new FournisseurTelephonie($db); + + $fourn->nom = $_POST["nom"]; + $fourn->email_commande = $_POST["email_commande"]; + + if ( $fourn->create($user) == 0) + { + Header("Location: index.php"); + } +} + +if ($_GET["action"] == 'active') +{ + $fourn = new FournisseurTelephonie($db); + $fourn->id = $_GET["id"]; + + if ( $fourn->active($user) == 0) + { + Header("Location: index.php"); + } +} + +if ($_GET["action"] == 'desactive') +{ + $fourn = new FournisseurTelephonie($db); + $fourn->id = $_GET["id"]; + + if ( $fourn->desactive($user) == 0) + { + Header("Location: index.php"); + } +} + +llxHeader("","","Fiche Fournisseur"); + +if ($cancel == $langs->trans("Cancel")) +{ + $action = ''; +} + +/* + * Création + * + */ + +if ($_GET["action"] == 'create') +{ + $fourn = new FournisseurTelephonie($db); + print "
\n"; + print ''; + + print_titre("Nouveau fournisseur"); + + print ''; + + print ''; + print ''; + + print ''; + print '
Nom
Email de commande (adresse email à laquelle sont envoyées les commandes de lignes
 
'; + print '
'; +} +else +{ + print "Error"; +} + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/fournisseur/index.php b/htdocs/telephonie/fournisseur/index.php new file mode 100644 index 00000000000..f23ddd9c93c --- /dev/null +++ b/htdocs/telephonie/fournisseur/index.php @@ -0,0 +1,130 @@ + + * + * 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$ + * + */ +require("./pre.inc.php"); + +$user->getrights('telephonie'); + + + +$page = $_GET["page"]; +$sortorder = $_GET["sortorder"]; + +llxHeader(); + +if (!$user->rights->telephonie->lire) + accessforbidden(); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +if ($sortorder == "") { + $sortorder="ASC"; +} +if ($sortfield == "") { + $sortfield="f.nom"; +} + +if ($page == -1) { $page = 0 ; } + +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +/* + * Mode Liste + * + * + * + */ + +$sql = "SELECT f.rowid, f.nom, f.email_commande, f.commande_active"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; + +$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + print_barre_liste("Fournisseurs", $page, "fournisseurs.php", "", $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print_liste_field_titre("Société","fournisseurs.php","s.nom"); + print ''; + print ''; + + if($user->rights->telephonie->fournisseur->config) + { + print ''; + } + + print "\n"; + $var=True; + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($i); + $var=!$var; + + print ""; + print "\n"; + print "\n"; + print '\n"; + + if($user->rights->telephonie->fournisseur->config) + { + print ''; + } + + print "\n"; + $i++; + } + print "
Email de commandeCommande possible 
".$obj->nom."".$obj->email_commande."'.$langs->trans($yesno[$obj->commande_active])."'; + if ($obj->commande_active) + { + print 'Désactive'; + } + else + { + print 'Active'; + } + print '
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/fournisseur/pre.inc.php b/htdocs/telephonie/fournisseur/pre.inc.php new file mode 100644 index 00000000000..0a1ab8edc03 --- /dev/null +++ b/htdocs/telephonie/fournisseur/pre.inc.php @@ -0,0 +1,69 @@ + + * + * 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$ + * + */ +require("../../main.inc.php"); +require(DOL_DOCUMENT_ROOT."/telephonie/fournisseurtel.class.php"); +$user->getrights('telephonie'); + +function llxHeader($head = "", $title="") { + global $user, $conf; + + /* + * + * + */ + top_menu($head, $title); + + $menu = new Menu(); + + $menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie"); + + $menu->add(DOL_URL_ROOT."/telephonie/simulation/fiche.php", "Simulation"); + $menu->add_submenu(DOL_URL_ROOT."/telephonie/simulation/fiche.php?action=create", "Nouvelle"); + + $menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs"); + + $menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients"); + + $menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes"); + + $menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commandes"); + + $menu->add(DOL_URL_ROOT."/telephonie/facture/", "Factures"); + + $menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques"); + + $menu->add(DOL_URL_ROOT."/telephonie/fournisseur/index.php", "Fournisseurs"); + + if($user->rights->telephonie->fournisseur->config) + { + $menu->add_submenu(DOL_URL_ROOT."/telephonie/fournisseur/fiche.php?action=create", "Nouveau"); + } + + $menu->add(DOL_URL_ROOT."/telephonie/statca/", "Chiffre d'affaire"); + + if ($user->admin) + $menu->add(DOL_URL_ROOT."/telephonie/config/", "Configuration"); + + left_menu($menu->liste); +} + +?> diff --git a/htdocs/telephonie/fournisseurs.php b/htdocs/telephonie/fournisseurs.php index 789f6583440..a3a4a2e75b7 100644 --- a/htdocs/telephonie/fournisseurs.php +++ b/htdocs/telephonie/fournisseurs.php @@ -80,6 +80,13 @@ if ($result) print_liste_field_titre("Société","fournisseurs.php","s.nom"); print 'Email de commande'; + if($user->rights->telephonie->fournisseur->config) + { + print ''; + print ''; + print 'Email de commande'; + } + print "\n"; $var=True; diff --git a/htdocs/telephonie/fournisseurtel.class.php b/htdocs/telephonie/fournisseurtel.class.php index be0227c27b3..950e456fdbe 100644 --- a/htdocs/telephonie/fournisseurtel.class.php +++ b/htdocs/telephonie/fournisseurtel.class.php @@ -31,7 +31,24 @@ class FournisseurTelephonie { $this->id = $id; return 1; } - /* + /** + * + * + */ + function create() + { + $res = 0; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_fournisseur"; + $sql .= " (nom, email_commande, commande_active)"; + $sql .= " VALUES ('".$this->nom."','".$this->email_commande."',1)"; + + if (! $this->db->query($sql) ) + { + $res = -1; + } + return $res; + } + /** * * */ @@ -65,6 +82,40 @@ class FournisseurTelephonie { return -2; } } + /** + * + * + */ + function active() + { + $res = 0; + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_fournisseur"; + $sql .= " SET commande_active = 1"; + $sql .= " WHERE rowid = ".$this->id; + + if (! $this->db->query($sql) ) + { + $res = -1; + } + return $res; + } + /** + * + * + */ + function desactive() + { + $res = 0; + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_fournisseur"; + $sql .= " SET commande_active = 0"; + $sql .= " WHERE rowid = ".$this->id; + + if (! $this->db->query($sql) ) + { + $res = -1; + } + return $res; + } } ?> diff --git a/htdocs/telephonie/ligne/commande/pre.inc.php b/htdocs/telephonie/ligne/commande/pre.inc.php index 09af5f15f76..5e8504b36a3 100644 --- a/htdocs/telephonie/ligne/commande/pre.inc.php +++ b/htdocs/telephonie/ligne/commande/pre.inc.php @@ -60,7 +60,7 @@ function llxHeader($head = "", $title="") { $menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques"); - $menu->add(DOL_URL_ROOT."/telephonie/fournisseurs.php", "Fournisseurs"); + $menu->add(DOL_URL_ROOT."/telephonie/fournisseur/", "Fournisseurs"); left_menu($menu->liste); diff --git a/htdocs/telephonie/ligne/pre.inc.php b/htdocs/telephonie/ligne/pre.inc.php index 25aea825175..396388b9bf1 100644 --- a/htdocs/telephonie/ligne/pre.inc.php +++ b/htdocs/telephonie/ligne/pre.inc.php @@ -58,7 +58,7 @@ function llxHeader($head = "", $title="") { $menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques"); - $menu->add(DOL_URL_ROOT."/telephonie/fournisseurs.php", "Fournisseurs"); + $menu->add(DOL_URL_ROOT."/telephonie/fournisseur/", "Fournisseurs"); $menu->add(DOL_URL_ROOT."/telephonie/statca/", "Chiffre d'affaire"); diff --git a/htdocs/telephonie/pre.inc.php b/htdocs/telephonie/pre.inc.php index 1b050009713..f9fabfc1851 100644 --- a/htdocs/telephonie/pre.inc.php +++ b/htdocs/telephonie/pre.inc.php @@ -51,7 +51,7 @@ function llxHeader($head = "", $title="") { $menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques"); - $menu->add(DOL_URL_ROOT."/telephonie/fournisseurs.php", "Fournisseurs"); + $menu->add(DOL_URL_ROOT."/telephonie/fournisseur/index.php", "Fournisseurs"); $menu->add(DOL_URL_ROOT."/telephonie/statca/", "Chiffre d'affaire");