Nouveau fichier
This commit is contained in:
parent
064f71b877
commit
92e45755d7
143
htdocs/telephonie/facturetel.class.php
Normal file
143
htdocs/telephonie/facturetel.class.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -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");
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user