[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/scripts/ -> prelevement-verif.php (source)

   1  <?PHP
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 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: prelevement-verif.php,v 1.4 2005/10/18 14:03:06 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/scripts/prelevement-verif.php,v $
  21   *
  22   *
  23   * Script de verification des demandes de prélèvement
  24   *
  25   * Vérifie que les sociétés qui doivent être prélevées ont bien un RIB correct
  26   */
  27   
  28  require_once ("../htdocs/master.inc.php");
  29  require_once (DOL_DOCUMENT_ROOT."/facture.class.php");
  30  require_once (DOL_DOCUMENT_ROOT."/societe.class.php");
  31  
  32  $error = 0;
  33  
  34  $puser = new user($db, PRELEVEMENT_USER);
  35  $puser->fetch();
  36  dolibarr_syslog("Prélèvements effectués par ".$puser->fullname." [".PRELEVEMENT_USER."]");
  37  
  38  dolibarr_syslog("Raison sociale : ".PRELEVEMENT_RAISON_SOCIALE);
  39  dolibarr_syslog("Numéro Nation Emetteur : ".PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR);
  40  
  41  dolibarr_syslog("Code etablissement : ".PRELEVEMENT_CODE_BANQUE);
  42  dolibarr_syslog("Code guichet       : ". PRELEVEMENT_CODE_GUICHET);
  43  dolibarr_syslog("Numero compte      : ".PRELEVEMENT_NUMERO_COMPTE);
  44  
  45  /*
  46   *
  47   * Lectures des factures a prélever
  48   *
  49   */
  50  
  51  $factures = array();
  52  $factures_prev = array();
  53  
  54  if (!$error)
  55  {
  56    
  57    $sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc";
  58    $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
  59    $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
  60  
  61    $sql .= " WHERE f.fk_statut = 1";
  62    $sql .= " AND f.rowid = pfd.fk_facture";
  63    $sql .= " AND f.paye = 0";
  64    $sql .= " AND pfd.traite = 0";
  65    $sql .= " AND f.total_ttc > 0";
  66    $sql .= " AND f.fk_mode_reglement = 3";
  67    
  68    if ( $db->query($sql) )
  69      {
  70        $num = $db->num_rows();
  71        
  72        $i = 0;
  73        
  74        while ($i < $num)
  75      {
  76        $row = $db->fetch_row();
  77        
  78        $factures[$i] = $row;
  79        
  80        $i++;
  81      }            
  82        $db->free();
  83        dolibarr_syslog("$i factures à prélever");
  84      }
  85    else
  86      {
  87        $error = 1;
  88        dolibarr_syslog("Erreur -1");
  89        dolibarr_syslog($db->error());
  90      }
  91  }
  92  
  93  /*
  94   *
  95   * Vérification des clients
  96   *
  97   */
  98  
  99  if (!$error)
 100  {
 101    /*
 102     * Vérification des RIB
 103     *
 104     */
 105    $i = 0;
 106    dolibarr_syslog("Début vérification des RIB");
 107  
 108    if (sizeof($factures) > 0)
 109      {      
 110        foreach ($factures as $fac)
 111      {
 112        $fact = new Facture($db);
 113        
 114        if ($fact->fetch($fac[0]) == 1)
 115          {
 116            $soc = new Societe($db);
 117            if ($soc->fetch($fact->socidp) == 1)
 118          {
 119            
 120            if ($soc->verif_rib() == 1)
 121              {
 122  
 123                $factures_prev[$i] = $fac;
 124  
 125                $i++;
 126              }
 127            else
 128              {
 129                dolibarr_syslog("Erreur de RIB societe $fact->socidp $soc->nom");
 130              }
 131          }
 132            else
 133          {
 134            dolibarr_syslog("Impossible de lire la société");
 135          }
 136          }
 137        else
 138          {
 139            dolibarr_syslog("Impossible de lire la facture");
 140          }
 141      }
 142      }
 143    else
 144      {
 145        dolibarr_syslog("Aucune factures a traiter");
 146      }
 147  }
 148  
 149  dolibarr_syslog(sizeof($factures_prev)." factures sur ".sizeof($factures)." seront prélevées");
 150  
 151  $db->close();
 152  
 153  
 154  ?>


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