[ 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/adherents/ -> adherent_type.class.php (source)

   1  <?php
   2  /* Copyright (C) 2002      Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: adherent_type.class.php,v 1.10 2005/04/16 13:30:50 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/adherents/adherent_type.class.php,v $
  21   *
  22   */
  23  
  24  /**
  25          \file       htdocs/adherents/adherent_type.class.php
  26          \ingroup    adherent
  27          \brief      Fichier de la classe gérant les types d'adhérents
  28          \author     Rodolphe Quiedeville
  29          \version    $Revision: 1.10 $
  30  */
  31  
  32  /**
  33          \class      AdherentType
  34          \brief      Classe gérant les types d'adhérents
  35  */
  36  
  37  
  38  class AdherentType
  39  {
  40    var $id;
  41    var $libelle;
  42    var $statut;
  43    var $cotisation;  /**< Soumis à la cotisation */
  44    var $errorstr;
  45    var $mail_valid;    /**< mail envoye lors de la validation */
  46    var $commentaire; /**< commentaire */
  47    var $vote;        /** droit de vote ? */
  48  
  49  
  50  /**
  51          \brief AdherentType
  52          \param DB                handler accès base de données
  53  */
  54  
  55    function AdherentType($DB)
  56      {
  57        $this->db = $DB ;
  58        $this->statut = 1;
  59      }
  60  
  61  
  62  /**
  63          \brief print_error_list
  64  */
  65  
  66  	function print_error_list()
  67    {
  68      $num = sizeof($this->errorstr);
  69      for ($i = 0 ; $i < $num ; $i++)
  70        {
  71      print "<li>" . $this->errorstr[$i];
  72        }
  73    }
  74  
  75  
  76  /**
  77          \brief      Fonction qui permet de créer le status de l'adhérent
  78          \param      userid            userid de l'adhérent
  79          \return     > 0 si ok, < 0 si ko
  80  */
  81  
  82  	function create($userid)
  83      {
  84        $this->statut=trim($this->statut);
  85  
  86        $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (statut)";
  87        $sql .= " VALUES ($this->statut)";
  88  
  89        $result = $this->db->query($sql);
  90  
  91        if ($result)
  92      {
  93        $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
  94        return $this->update();
  95      }
  96        else
  97      {
  98        return -1;
  99      }
 100      }
 101  
 102  
 103  /**
 104          \brief      Met a jour en base données du type
 105          \return     > 0 si ok, < 0 si ko
 106  */
 107    function update()
 108      {
 109        $this->libelle=trim($this->libelle);
 110  
 111        $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type SET ";
 112        $sql .= "libelle = '".$this->libelle ."'";
 113        $sql .= ",statut=".$this->statut;
 114        $sql .= ",cotisation='".$this->cotisation."'";
 115        $sql .= ",note='".$this->commentaire."'";
 116        $sql .= ",vote='".$this->vote."'";
 117        $sql .= ",mail_valid='".$this->mail_valid."'";
 118  
 119        $sql .= " WHERE rowid = $this->id";
 120  
 121        $result = $this->db->query($sql);
 122  
 123        if ($result)
 124      {
 125        return 1;
 126      }
 127        else
 128      {
 129        $error=$this->db->error();
 130        return -1;
 131      }
 132      }
 133  
 134  /**
 135          \brief      Fonction qui permet de supprimer le status de l'adhérent
 136          \param      rowid
 137  */
 138  
 139  	function delete($rowid)
 140    {
 141  
 142      $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type WHERE rowid = $rowid";
 143  
 144      if ( $this->db->query( $sql) )
 145        {
 146      if ( $this->db->affected_rows() )
 147        {
 148          return 1;
 149        }
 150      else
 151        {
 152          return 0;
 153        }
 154        }
 155      else
 156        {
 157      print "Err : ".$this->db->error();
 158      return 0;
 159        }
 160    }
 161  
 162      /**
 163          \brief fonction qui permet de récupérer le status de l'adhérent
 164          \param rowid
 165  */
 166  
 167  	function fetch($rowid)
 168    {
 169      $sql = "SELECT d.rowid, d.libelle, d.statut, d.cotisation, d.mail_valid, d.note, d.vote";
 170      $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
 171      $sql .= " WHERE d.rowid = $rowid";
 172      
 173      if ( $this->db->query( $sql) )
 174      {
 175          if ($this->db->num_rows())
 176          {
 177              $obj = $this->db->fetch_object();
 178      
 179              $this->id             = $obj->rowid;
 180              $this->libelle        = $obj->libelle;
 181              $this->statut         = $obj->statut;
 182              $this->cotisation     = $obj->cotisation;
 183              $this->mail_valid     = $obj->mail_valid;
 184              $this->commentaire    = $obj->note;
 185              $this->vote           = $obj->vote;
 186          }
 187      }
 188      else
 189      {
 190          print $this->db->error();
 191      }
 192  
 193    }
 194  
 195    function liste_array()
 196      {
 197        $projets = array();
 198  
 199        $sql = "SELECT rowid, libelle FROM ".MAIN_DB_PREFIX."adherent_type";
 200  
 201        if ($this->db->query($sql) )
 202      {
 203        $nump = $this->db->num_rows();
 204  
 205        if ($nump)
 206          {
 207            $i = 0;
 208            while ($i < $nump)
 209          {
 210            $obj = $this->db->fetch_object();
 211  
 212            $projets[$obj->rowid] = $obj->libelle;
 213            $i++;
 214          }
 215          }
 216        return $projets;
 217      }
 218        else
 219      {
 220        print $this->db->error();
 221      }
 222  
 223      }
 224  
 225  }
 226  ?>


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