[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/telephonie/ -> facturetel.class.php (source)

   1  <?PHP
   2  /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * 
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: facturetel.class.php,v 1.6 2005/04/08 08:16:10 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/facturetel.class.php,v $
  20   *
  21   */
  22  
  23  class FactureTel {
  24    var $db;
  25    var $id;
  26  
  27    function FactureTel($DB, $id=0)
  28    {
  29      $this->db = $DB;
  30  
  31      return 1;
  32    }
  33    /*
  34     *
  35     *
  36     */
  37    function fetch($id)
  38      {
  39        $sql = "SELECT rowid, ligne, date, cout_vente, cout_vente_remise, fk_facture";
  40        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf";
  41        $sql .= " WHERE tf.rowid = ".$id;
  42  
  43        $resql = $this->db->query($sql);
  44  
  45        if ($resql)
  46      {
  47        if ($this->db->num_rows($resql))
  48          {
  49            $obj = $this->db->fetch_object($resql);
  50  
  51            $this->id                = $obj->rowid;
  52            $this->ligne             = $obj->ligne;
  53            $this->cout_vente        = $obj->cout_vente;
  54            $this->cout_vente_remise = $obj->cout_vente_remise;
  55            $this->fk_facture        = $obj->fk_facture;
  56  
  57            $result = 0;
  58          }
  59        else
  60          {
  61            dolibarr_syslog("Erreur FactureTel::fetch() id=$id");
  62            $result = -2;
  63          }
  64  
  65        $this->db->free($resql);
  66      }
  67        else
  68      {
  69        /* Erreur select SQL */
  70        dolibarr_syslog("Erreur FactureTel::fetch(), sql error");
  71        print $this->db->error();
  72        $result = -1;
  73      }
  74  
  75  
  76        return $result;
  77    }
  78  
  79    /*
  80     * Met à jout la facture téléphonique avec le numéro de la facture
  81     * comptable
  82     */
  83    function affect_num_facture_compta($facid)
  84    {
  85  
  86      $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_facture";
  87      $sql .= " SET ";
  88      $sql .= " fk_facture = ".$facid ;
  89      $sql .= " WHERE rowid = ".$this->id;
  90  
  91      if ( $this->db->query($sql) )
  92        {
  93      return 0;
  94        }
  95      else
  96        {
  97      print $this->db->error();
  98      print $sql ;
  99      return 1;
 100        }
 101    }
 102  
 103    /*
 104     *
 105     */
 106  
 107    function get_comm_min_date($date)
 108    {
 109      $sql = "SELECT ".$this->db->pdate("min(date)");
 110      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
 111      $sql .= " WHERE ligne = '".$this->ligne."'";
 112      $sql .= " AND fk_telephonie_facture =".$this->id;
 113  
 114      $resql = $this->db->query($sql);
 115  
 116      if ($resql)
 117        {
 118      if ($this->db->num_rows($resql))
 119        {
 120          $row = $this->db->fetch_row($resql);
 121      
 122          return $row[0];
 123        }
 124        }
 125  
 126    }
 127  
 128    /*
 129     *
 130     */
 131  
 132    function get_comm_max_date($date)
 133    {
 134      $sql = "SELECT ".$this->db->pdate("max(date)");
 135      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
 136      $sql .= " WHERE ligne = '".$this->ligne."'";
 137      $sql .= " AND fk_telephonie_facture =".$this->id;
 138  
 139      $resql = $this->db->query($sql);
 140  
 141      if ($resql)
 142        {
 143      if ($this->db->num_rows($resql))
 144        {
 145          $row = $this->db->fetch_row($resql);
 146      
 147          return $row[0];
 148        }
 149        }
 150    }
 151  }
 152  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics