[ 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/ -> facture-detail-tableur-one.class.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: facture-detail-tableur-one.class.php,v 1.4 2005/09/07 10:04:14 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/facture-detail-tableur-one.class.php,v $
  20   *
  21   *
  22   */
  23  require_once (DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_workbook.inc.php");
  24  require_once (DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_worksheet.inc.php");
  25  
  26  class FactureDetailTableurOne {
  27  
  28    Function FactureDetailTableurOne($DB)
  29    {
  30      $this->db = $DB;
  31    }
  32  
  33    Function GenerateFile($ligne_id, $year, $month)
  34    {
  35      $this->ligne = new LigneTel($db);
  36      $this->ligne->id = $ligne_id;
  37  
  38      $dir = "/tmp";
  39      $error = 0;
  40  
  41      $sql = "SELECT rowid";
  42      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
  43      $sql .= " WHERE fk_ligne = '".$this->ligne->id."'";
  44      $sql .= " AND date = '".$year."-".$month."-01';";
  45  
  46      $resql = $this->db->query($sql);
  47      
  48      if ($resql)
  49        {
  50      if ($row = $this->db->fetch_row($resql))
  51        {
  52          $facid = substr('0000'.$row[0], -4);
  53        }
  54      else
  55        {
  56          //dolibarr_syslog("Pas de facture pour ".$this->ligne->id);
  57        }
  58        }
  59      else
  60        {
  61      dolibarr_syslog("Error");
  62        }
  63  
  64  
  65      if ($facid > 0)
  66        {
  67  
  68      $dir = DOL_DATA_ROOT.'/telephonie/facture/';
  69  
  70      $dir .= substr($facid,0,1)."/";
  71      $dir .= substr($facid,1,1)."/";
  72      $dir .= substr($facid,2,1)."/";
  73      $dir .= substr($facid,3,1)."/";
  74      
  75      create_exdir($dir);
  76  
  77      $fname = $dir . $facid . "-detail.xls";
  78      
  79      dolibarr_syslog("Open ".$facid."-detail.xls");
  80      
  81      $workbook = &new writeexcel_workbook($fname);
  82      
  83      $page = &$workbook->addworksheet($year."/".substr("00".$month,-2));
  84      
  85      $fnb =& $workbook->addformat();
  86      $fnb->set_align('vcenter');
  87      $fnb->set_align('right');
  88  
  89      $fp =& $workbook->addformat();
  90      $fp->set_align('vcenter');
  91      $fp->set_align('right');
  92      $fp->set_num_format('0.000');
  93      
  94      $fdest =& $workbook->addformat();
  95      $fdest->set_align('vcenter');
  96      
  97      $page->set_column(0,0,12); // A
  98      $page->set_column(1,1,20); // B
  99      $page->set_column(2,2,15); // C
 100      
 101      $page->set_column(3,3,30);  // D
 102      $page->set_column(6,6,7); // G
 103      $page->set_column(9,9,7); // J
 104      $page->set_column(12,12,7); // M
 105      
 106      $page->write(0, 0,  "Ligne", $format_titre_agence1);
 107      $page->write(0, 1,  "Date", $format_titre);
 108      $page->write(0, 2,  "Numero", $format_titre);
 109      $page->write(0, 3,  "Destination", $format_titre);
 110      $page->write(0, 4,  "Duree", $format_titre);
 111      $page->write(0, 5,  "Cout", $format_titre);
 112      
 113      $sql = "SELECT ligne, date, numero, dest, dureetext, duree, cout_vente";
 114      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
 115      $sql .= " WHERE fk_ligne = '".$this->ligne->id."'";
 116      $sql .= " AND fk_telephonie_facture = ".$facid;
 117      $sql .= " ORDER BY date ASC";
 118      
 119      $resql = $this->db->query($sql);
 120      
 121      if ($resql)
 122        {
 123          $i = 0;
 124          $numsql = $this->db->num_rows($resql);
 125          
 126          dolibarr_syslog("Ligne : ".$this->ligne->id . " : ".$numsql);
 127          
 128          while ($i < $numsql)
 129            {
 130          $obj = $this->db->fetch_object($resql);
 131          
 132          $xx = $i + 1;
 133          
 134          $page->write_string($xx, 0,  $obj->ligne, $fdest);
 135          $page->write_string($xx, 1,  $obj->date, $fdest);
 136          $page->write_string($xx, 2,  $obj->numero, $fdest);
 137          $page->write_string($xx, 3,  $obj->dest, $fdest);
 138          $page->write($xx, 4,  $obj->duree, $fnb);
 139          $page->write($xx, 5,  $obj->cout_vente, $fp);
 140          
 141          $i++;
 142            }
 143          $this->db->free($resql);
 144        }
 145      else
 146        {
 147          dolibarr_syslog($this->db->error());
 148        }
 149      
 150      $workbook->close();
 151      //dolibarr_syslog("Close $fname");
 152        }
 153      
 154      return $error;
 155    }
 156  }
 157  ?>


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