From 92e45755d7025011ec8be17963b5c1dfed84cc21 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 3 Dec 2004 13:19:14 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/telephonie/facturetel.class.php | 143 +++++++++++++++++++++++++ htdocs/telephonie/ligne/pre.inc.php | 5 +- htdocs/telephonie/pre.inc.php | 2 + 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 htdocs/telephonie/facturetel.class.php diff --git a/htdocs/telephonie/facturetel.class.php b/htdocs/telephonie/facturetel.class.php new file mode 100644 index 00000000000..264de615a17 --- /dev/null +++ b/htdocs/telephonie/facturetel.class.php @@ -0,0 +1,143 @@ + + * + * 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 FactureTel { + var $db; + + var $id; + + function FactureTel($DB, $id=0) + { + $this->db = $DB; + + return 1; + } + /* + * + * + */ + function fetch($id) + { + $sql = "SELECT rowid, ligne, date, cout_vente, cout_vente_remise"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf"; + $sql .= " WHERE tf.rowid = ".$id; + + + if ($this->db->query($sql)) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object(0); + + $this->id = $obj->rowid; + $this->ligne = $obj->ligne; + $this->cout_vente = $obj->cout_vente; + $this->cout_vente_remise = $obj->cout_vente_remise; + + $result = 0; + } + else + { + dolibarr_syslog("Erreur FactureTel::fetch() id=$id"); + $result = -2; + } + + $this->db->free(); + } + else + { + /* Erreur select SQL */ + dolibarr_syslog("Erreur FactureTel::fetch(), sql error"); + print $this->db->error(); + $result = -1; + } + + + return $result; + } + + /* + * Met à jout la facture téléphonique avec le numéro de la facture + * comptable + */ + function affect_num_facture_compta($facid) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_facture"; + $sql .= " SET "; + $sql .= " fk_facture = $facid "; + + $sql .= " WHERE rowid = $this->id"; + + if ( $this->db->query($sql) ) + { + return 0; + } + else + { + print $this->db->error(); + print $sql ; + return 1; + } + } + + + + function get_comm_min_date($date) + { + $sql = "SELECT ".$this->db->pdate("min(date)")." FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; + $sql .= " WHERE ligne = '".$this->ligne."' and EXTRACT(YEAR_MONTH FROM date) = $date"; + + + if ($this->db->query($sql)) + { + if ($this->db->num_rows()) + { + $row = $this->db->fetch_row(0); + + return $row[0]; + } + } + + } + + function get_comm_max_date($date) + { + $sql = "SELECT ".$this->db->pdate("max(date)")." FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; + $sql .= " WHERE ligne = '".$this->ligne."' and EXTRACT(YEAR_MONTH FROM date) = $date"; + + + if ($this->db->query($sql)) + { + if ($this->db->num_rows()) + { + $row = $this->db->fetch_row(0); + + return $row[0]; + } + } + + } + +} + +?> diff --git a/htdocs/telephonie/ligne/pre.inc.php b/htdocs/telephonie/ligne/pre.inc.php index 396388b9bf1..8c33f44f78b 100644 --- a/htdocs/telephonie/ligne/pre.inc.php +++ b/htdocs/telephonie/ligne/pre.inc.php @@ -46,7 +46,10 @@ function llxHeader($head = "", $title="") { $menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes"); $menu->add_submenu(DOL_URL_ROOT."/telephonie/ligne/liste.php", "Liste"); - $menu->add_submenu(DOL_URL_ROOT."/telephonie/ligne/fiche.php?action=create", "Nouvelle ligne"); + + if ($user->rights->telephonie->ligne->creer) + $menu->add_submenu(DOL_URL_ROOT."/telephonie/ligne/fiche.php?action=create", "Nouvelle ligne"); + $menu->add_submenu(DOL_URL_ROOT."/telephonie/ligne/listecommande.php", "En commande"); $menu->add_submenu(DOL_URL_ROOT."/telephonie/ligne/communications.php", "Communications"); $menu->add_submenu(DOL_URL_ROOT."/telephonie/ligne/groupe.php", "Groupes"); diff --git a/htdocs/telephonie/pre.inc.php b/htdocs/telephonie/pre.inc.php index f9fabfc1851..2988d0dc1a8 100644 --- a/htdocs/telephonie/pre.inc.php +++ b/htdocs/telephonie/pre.inc.php @@ -44,6 +44,8 @@ function llxHeader($head = "", $title="") { $menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients"); $menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes"); + if ($user->rights->telephonie->ligne->creer) + $menu->add_submenu(DOL_URL_ROOT."/telephonie/ligne/fiche.php?action=create", "Nouvelle ligne"); $menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commandes");