[ 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_aquarium.php (source)

   1  <?php
   2  /*
   3   * Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   4   * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
   5   *
   6   * This program is free software; you can redistribute it and/or modify
   7   * it under the terms of the GNU General Public License as published by
   8   * the Free Software Foundation; either version 2 of the License, or
   9   * (at your option) any later version.
  10   *
  11   * This program is distributed in the hope that it will be useful,
  12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14   * GNU General Public License for more details.
  15   *
  16   * You should have received a copy of the GNU General Public License
  17   * along with this program; if not, write to the Free Software
  18   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19   * or see http://www.gnu.org/
  20   *
  21   * $Id: mod_codecompta_aquarium.php,v 1.2 2005/07/10 20:47:17 eldy Exp $
  22   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/societe/mod_codecompta_aquarium.php,v $
  23   *
  24   */
  25  
  26  class mod_codecompta_aquarium
  27  {
  28  
  29    function mod_codecompta_aquarium()
  30    {
  31      $this->nom = "Aquarium";
  32    }
  33  
  34    function info()
  35    {
  36      return "Renvoie un code compta composé de 401 suivit du code tiers si c'est un fournisseur, et 411 suivit du code tiers si c'est un client (compta française).";
  37    }
  38  
  39    /**
  40     *    \brief      Renvoi code
  41     *    \param      DB              Handler d'accès base
  42     *    \param      societe         Objet societe
  43     */
  44    function get_code($DB, $societe)
  45    {    
  46      $i = 0;
  47      $this->db = $DB;
  48  
  49      if($societe->fournisseur == "1")
  50        $this->code = "401".$societe->code_client;
  51      if($societe->client == "1")
  52        $this->code = "411".$societe->code_client;
  53  
  54      $is_dispo = $this->verif($DB, $this->code);
  55  
  56      while ( $is_dispo <> 0 && $i < 37)
  57        {
  58      $arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  59  
  60      $this->code = $societe->prefix_comm . $societe->code_client . substr($arr, $i, 1);
  61  
  62      $is_dispo = $this->verif($DB, $this->code);
  63  
  64      $i++;
  65        }
  66  
  67  
  68      if ($is_dispo == 0)
  69        {
  70      return 0;
  71        }
  72      else
  73        {
  74      return -1;
  75        }
  76      
  77    }
  78    
  79    function verif($db, $code)
  80    {
  81      $sql = "SELECT code_compta FROM ".MAIN_DB_PREFIX."societe";
  82      $sql .= " WHERE code_compta = '".$code."'";
  83  
  84      if ($db->query($sql))
  85        {
  86      if ($db->num_rows() == 0)
  87        {
  88          return 0;
  89        }
  90      else
  91        {
  92          return -1;
  93        }
  94        }
  95      else
  96        {
  97      return -2;
  98        }
  99  
 100    }
 101  }
 102  
 103  ?>


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