[ 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/ -> distributeurtel.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: distributeurtel.class.php,v 1.4 2005/06/21 12:28:17 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/distributeurtel.class.php,v $
  20   *
  21   */
  22  
  23  class DistributeurTelephonie {
  24    var $db;
  25    var $id;
  26  
  27    /**
  28     * Créateur
  29     *
  30     *
  31     */
  32    function DistributeurTelephonie($DB, $id=0)
  33    {
  34      $this->db = $DB;
  35      $this->id = $id;
  36  
  37      return 0;
  38    }
  39    /**
  40     *
  41     *
  42     */
  43    function create()
  44      {
  45        $error = 0;
  46  
  47        if (strlen(trim($this->nom)) == 0)
  48      {
  49        $this->error_string["nom"] = "Valeur manquante";
  50        $error++;
  51      }
  52        if (strlen(trim($this->avance)) == 0)
  53      {
  54        $this->error_string["avance"] = "Valeur manquante";
  55        $error++;
  56      }
  57        if ($this->avance > 100 or $this->avance < 0)
  58      {
  59        $this->error_string["avance"] = "Valeur incohérente";
  60        $error++;
  61      }
  62  
  63  
  64  
  65        if (!is_numeric($this->duree))
  66      {
  67        $this->error_string["duree"] = "Mauvais format";
  68        $error++;
  69      }
  70        if ($this->duree > 12 or $this->duree < 0)
  71      {
  72        $this->error_string["duree"] = "Valeur incohérente";
  73        $error++;
  74      }
  75        if (strlen(trim($this->duree)) == 0)
  76      {
  77        $this->error_string["duree"] = "Valeur manquante";
  78        $error++;
  79      }
  80  
  81  
  82        if ($this->prelev > 100 or $this->prelev < 0)
  83      {
  84        $this->error_string["prelev"] = "Valeur incohérente";
  85        $error++;
  86      }
  87        if (!is_numeric($this->prelev))
  88      {
  89        $this->error_string["prelev"] = "Mauvais format";
  90        $error++;
  91      }
  92        if (strlen(trim($this->prelev)) == 0)
  93      {
  94        $this->error_string["prelev"] = "Valeur manquante";
  95        $error++;
  96      }
  97  
  98  
  99        if ($this->autre > 100 or $this->autre < 0)
 100      {
 101        $this->error_string["autre"] = "Valeur incohérente";
 102        $error++;
 103      }
 104        if (!is_numeric($this->autre))
 105      {
 106        $this->error_string["autre"] = "Mauvais format";
 107        $error++;
 108      }
 109        if (strlen(trim($this->autre)) == 0)
 110      {
 111        $this->error_string["autre"] = "Valeur manquante";
 112        $error++;
 113      }
 114  
 115     
 116        if ($error == 0)
 117      {
 118  
 119        $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_distributeur ";
 120        $sql .= " (grille_tarif, nom, avance_pourcent, avance_duree, rem_pour_prev, rem_pour_autr)";
 121        
 122        $sql .= " VALUES (2,'".trim($this->nom)."'";
 123        $sql .= " ,".$this->avance;
 124        $sql .= " ,".$this->duree;
 125        $sql .= " ,".$this->prelev;
 126        $sql .= " ,".$this->autre.")";
 127        
 128        if ($this->db->query($sql))
 129          {
 130            
 131          }
 132        else
 133          {
 134            dolibarr_syslog("DistributeurTelephonie::Create");
 135            $this->error_string["prelev"] = "Erreur SQL : $sql";
 136            $this->error_string["autre"] = $this->db->error();
 137            $error++;
 138          }
 139      }
 140        else
 141      {
 142        
 143      }
 144        
 145        return $error;
 146        
 147      }
 148  
 149    /**
 150     *
 151     *
 152     */
 153    function fetch($id)
 154      {
 155        $this->id = $id;
 156  
 157        $sql = "SELECT d.rowid, d.nom";
 158        $sql .= " , d.avance_pourcent";
 159        $sql .= " , d.rem_pour_prev, d.rem_pour_autr";
 160  
 161        $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur as d";
 162        $sql .= " WHERE d.rowid = ".$this->id;
 163        
 164        if ($this->db->query($sql))
 165      {
 166        if ($this->db->num_rows())
 167          {
 168            $obj = $this->db->fetch_object(0);
 169  
 170            $this->nom          = stripslashes($obj->nom);
 171            $this->remun_avance = $obj->remun_avance;
 172  
 173            $this->remun_pourcent_prev = $obj->remun_pourcent_prev;
 174            $this->remun_pourcent_autr = $obj->remun_pourcent_autr;
 175  
 176            return 0;
 177          }
 178        else
 179          {
 180            dolibarr_syslog("DistributeurTelephonie::Fetch Erreur id=".$this->id);
 181            return -1;
 182          }
 183      }
 184        else
 185      {
 186        dolibarr_syslog("DistributeurTelephonie::Fetch Erreur SQL id=".$this->id);
 187        return -2;
 188      }
 189      }
 190  
 191  
 192  }
 193  ?>


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