[ 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/includes/modules/societe/ -> mod_codecompta_digitaria.php (source)

   1  <?php
   2  /* Copyright (C) 2004 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   * or see http://www.gnu.org/
  18   *
  19   * $Id: mod_codecompta_digitaria.php,v 1.2 2005/07/10 20:47:17 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/societe/mod_codecompta_digitaria.php,v $
  21   *
  22   */
  23  
  24  class mod_codecompta_digitaria
  25  {
  26  
  27    function mod_codecompta_digitaria()
  28    {
  29      $this->nom = "Digitaria";
  30    }
  31  
  32    function info()
  33    {
  34      return "Renvoie un code compta composé suivant le code client. Le code est composé du caractère 'C' en première position suivi des 5 premiers caractères du code client.";
  35    }
  36  
  37    /**
  38     *    \brief      Renvoi code
  39     *    \param      DB              Handler d'accès base
  40     *    \param      societe         Objet societe
  41     */
  42    function get_code($DB, $societe)
  43    {    
  44      $i = 0;
  45      $this->db = $DB;
  46  
  47      $this->code = "C".substr($societe->code_client,0,5);
  48  
  49      $is_dispo = $this->verif($DB, $this->code);
  50  
  51      while ( $is_dispo <> 0 && $i < 37)
  52        {
  53      $arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  54  
  55      $this->code = substr($this->code,0,5) . substr($arr, $i, 1);
  56  
  57      $is_dispo = $this->verif($DB, $this->code);
  58  
  59      $i++;
  60        }
  61  
  62  
  63      if ($is_dispo == 0)
  64        {
  65      return 0;
  66        }
  67      else
  68        {
  69      return -1;
  70        }
  71  
  72    }
  73    
  74    function verif($db, $code)
  75    {
  76      $sql = "SELECT code_compta FROM ".MAIN_DB_PREFIX."societe";
  77      $sql .= " WHERE code_compta = '".$code."'";
  78  
  79      if ($db->query($sql))
  80        {
  81      if ($db->num_rows() == 0)
  82        {
  83          return 0;
  84        }
  85      else
  86        {
  87          return -1;
  88        }
  89        }
  90      else
  91        {
  92      return -2;
  93        }
  94  
  95    }
  96  }
  97  
  98  ?>


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