[ 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/script/ -> facturation-details.php (source)

   1  <?PHP
   2  /* Copyright (C) 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: facturation-details.php,v 1.2 2005/04/08 07:56:35 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/facturation-details.php,v $
  20   *
  21   *
  22   * Génération des factures détaillées
  23   *
  24   * Génère les factures détaillées du dernier mois.
  25   *
  26   *
  27   */
  28  
  29  require  ("../../master.inc.php");
  30  
  31  require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
  32  require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php");
  33  require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie-tarif.class.php");
  34  require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php");
  35  require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
  36  
  37  $error = 0;
  38  
  39  $datetime = time();
  40  
  41  /*
  42   *
  43   */
  44  
  45  $sql = "SELECT max(date) FROM ".MAIN_DB_PREFIX."telephonie_facture";
  46  
  47  $resql = $db->query($sql);
  48    
  49  if ( $resql )
  50  {
  51    $num = $db->num_rows($resql);
  52  
  53    $row = $db->fetch_row($resql);
  54  
  55    $date = $row[0];
  56  }
  57  else
  58  {
  59    $error++;
  60  }
  61  
  62  dolibarr_syslog("Génère les factures détaillées pour : ".$date);
  63  
  64  /*
  65   * Lectures de différentes factures
  66   * Basé sur le dernier mois de facturation
  67   */
  68  
  69  if (!$error)
  70  {
  71    $user = new user($db,1);
  72    
  73    $sql = "SELECT rowid";
  74    $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
  75    $sql .= " WHERE date='".$date."'";
  76    $sql .= " AND fk_facture IS NOT NULL";
  77    
  78    $factures = array();
  79  
  80    $resql = $db->query($sql);
  81    
  82    if ( $resql )
  83      {
  84        $num = $db->num_rows($resql);      
  85        $i = 0;
  86        
  87        while ($i < $num)
  88      {
  89        $objp = $db->fetch_object($resql);      
  90        $factures[$i] = $objp->rowid;      
  91        $i++;
  92      }            
  93        $db->free($resql);
  94        dolibarr_syslog("$i lignes trouvées");
  95      }
  96    else
  97      {
  98        $error = 1;
  99        dolibarr_syslog($db->error());
 100      }
 101  }
 102  
 103  /*
 104   * Traitements
 105   *
 106   */
 107  
 108  if (!$error && sizeof($factures))
 109  {
 110    $facok = 0;
 111  
 112     foreach ($factures as $facid)
 113      {
 114        $error = 0;
 115  
 116        /* Creation des factures détaillée */
 117        
 118        $factel = new FactureTel($db);
 119        if ($factel->fetch($facid) == 0)
 120      {
 121        $objligne = new LigneTel($db);
 122        
 123        if ($objligne->fetch($factel->ligne) == 1)    
 124          {          
 125            // Différents modèles de factures détaillées
 126            
 127            $modele = "standard";
 128            
 129            require_once (DOL_DOCUMENT_ROOT."/telephonie/pdf/pdfdetail_".$modele.".modules.php");
 130            $class = "pdfdetail_".$modele;
 131                      
 132            $facdet = new $class($db, $ligne, $year, $month, $factel);
 133            
 134            if ($facdet->write_pdf_file($factel, $factel->ligne) == 0)
 135          {
 136            $facok++;
 137          }
 138            else
 139          {
 140            dolibarr_syslog("ERREUR lors de Génération du pdf détaillé");
 141            $error = 19;
 142          }
 143          }
 144      }
 145      }
 146  
 147     dolibarr_syslog(sizeof($factures)." factures traitées");
 148     dolibarr_syslog($facok." factures générées");
 149  }
 150  
 151  $db->close();
 152  ?>


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