[ 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/propale/ -> pdf_propale_bleu.modules.php (source)

   1  <?php
   2  /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-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   * or see http://www.gnu.org/
  19   *
  20   * $Id: pdf_propale_bleu.modules.php,v 1.19 2005/11/11 20:11:58 eldy Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php,v $
  22   */
  23  
  24  /**        \file       htdocs/includes/modules/propale/pdf_propale_bleu.modules.php
  25          \ingroup    propale
  26          \brief      Fichier de la classe permettant de générer les propales au modèle Bleu
  27          \version    $Revision: 1.19 $
  28  */
  29  
  30  require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
  31  
  32  
  33  /**        \class      pdf_propale_bleu
  34          \brief      Classe permettant de générer les propales au modèle Bleu
  35  */
  36  
  37  class pdf_propale_bleu extends ModelePDFPropales
  38  {
  39  
  40      /**        \brief  Constructeur
  41              \param    db        handler accès base de donnée
  42      */
  43    function pdf_propale_bleu($db=0)
  44      { 
  45          $this->db = $db;
  46          $this->name = "bleu";
  47          $this->description = "Modèle de propale sans remise.";
  48  
  49          // Dimension page pour format A4
  50          $this->page_largeur = 210;
  51          $this->page_hauteur = 297;
  52          $this->format = array($this->page_largeur,$this->page_hauteur);
  53  
  54          $this->error = "";
  55      }
  56  
  57  
  58    /**    \brief      Renvoi dernière erreur
  59          \return     string      Dernière erreur
  60    */
  61    function pdferror() 
  62    {
  63        return $this->error;
  64    }
  65    
  66    
  67    /**
  68              \brief      Fonction générant la propale sur le disque
  69               \param        id        id de la propale à générer
  70              \return        int     1=ok, 0=ko
  71      */
  72    function write_pdf_file($id)
  73      {
  74        global $user,$conf,$langs;
  75        
  76        $propale = new Propal($this->db,"",$id);
  77        if ($propale->fetch($id))
  78      {
  79  
  80        if ($conf->propal->dir_output)
  81          {
  82                $propref = sanitize_string($propale->ref);
  83                $dir = $conf->propal->dir_output . "/" . $propref ;
  84  
  85              if (! file_exists($dir))
  86              {
  87                  if (create_exdir($dir) < 0)
  88                  {
  89                      $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
  90                      return 0;
  91                  }
  92              }
  93          }
  94        else
  95          {
  96              $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR");
  97              return 0;
  98          }
  99        
 100            $propref = sanitize_string($propale->ref);
 101            $file = $dir . "/" . $propref . ".pdf";
 102        
 103        if (file_exists($dir))
 104          {
 105  
 106            $pdf=new FPDF('P','mm',$this->format);
 107            $pdf->Open();
 108            $pdf->AddPage();
 109  
 110            $pdf->SetTitle($propale->ref);
 111            $pdf->SetSubject("Proposition commerciale");
 112            $pdf->SetCreator("Dolibarr ".DOL_VERSION);
 113            $pdf->SetAuthor($user->fullname);
 114  
 115            $this->_pagehead($pdf, $propale);
 116  
 117            /*
 118             */
 119            $tab_top = 100;
 120            $tab_height = 150;
 121            /*
 122             *
 123             */  
 124            
 125            $pdf->SetFillColor(220,220,220);
 126  
 127            $pdf->SetTextColor(0,0,0);
 128            $pdf->SetFont('Arial','', 10);
 129  
 130            $pdf->SetXY (10, $tab_top + 10 );
 131  
 132            $iniY = $pdf->GetY();
 133            $curY = $pdf->GetY();
 134            $nexY = $pdf->GetY();
 135            $nblignes = sizeof($propale->lignes);
 136  
 137            for ($i = 0 ; $i < $nblignes ; $i++)
 138          {
 139  
 140            $curY = $nexY;
 141  
 142            $pdf->SetXY (30, $curY );
 143  
 144            $pdf->MultiCell(100, 5, $propale->lignes[$i]->desc, 0, 'J', 0);
 145  
 146            $nexY = $pdf->GetY();
 147           
 148            $pdf->SetXY (10, $curY );
 149  
 150            $pdf->MultiCell(20, 5, $propale->lignes[$i]->ref, 0, 'C');
 151  
 152            $pdf->SetXY (133, $curY );          
 153            $pdf->MultiCell(10, 5, $propale->lignes[$i]->tva_tx, 0, 'C');
 154            
 155            $pdf->SetXY (145, $curY );
 156            $pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C');
 157  
 158            $pdf->SetXY (156, $curY );
 159            $pdf->MultiCell(18, 5, price($propale->lignes[$i]->price), 0, 'R', 0);
 160            
 161            $pdf->SetXY (174, $curY );
 162            $total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty);
 163            $pdf->MultiCell(26, 5, $total, 0, 'R', 0);
 164            
 165            $pdf->line(10, $curY, 200, $curY );
 166  
 167            if ($nexY > 240 && $i < $nblignes - 1)
 168              {
 169                $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
 170                $pdf->AddPage();
 171                $nexY = $iniY;
 172                $this->_pagehead($pdf, $propale);
 173                $pdf->SetTextColor(0,0,0);
 174                $pdf->SetFont('Arial','', 10);
 175              }
 176          }
 177            
 178            $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
 179            /*
 180             *
 181             */
 182            $tab2_top = 254;
 183            $tab2_lh = 7;
 184            $tab2_height = $tab2_lh * 3;
 185  
 186            $pdf->SetFont('Arial','', 11);
 187            
 188            $pdf->Rect(132, $tab2_top, 68, $tab2_height);
 189            
 190            $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) );
 191            $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) );
 192            $pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh );
 193            
 194            $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
 195            
 196            $pdf->SetXY (132, $tab2_top + 0);
 197            $pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0);
 198            
 199            $pdf->SetXY (132, $tab2_top + $tab2_lh);
 200            $pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0);
 201            
 202            $pdf->SetXY (132, $tab2_top + ($tab2_lh*2));
 203            $pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1);
 204            
 205            $pdf->SetXY (174, $tab2_top + 0);
 206            $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0);
 207            
 208            $pdf->SetXY (174, $tab2_top + $tab2_lh);
 209            $pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0);
 210            
 211            $pdf->SetXY (174, $tab2_top + ($tab2_lh*2));
 212            $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1);
 213            
 214            /*
 215             *
 216             */
 217                      
 218            $pdf->Output($file);
 219            return 1;          
 220          }
 221      }
 222      }
 223  
 224    function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
 225      {
 226          global $langs,$conf;
 227          $langs->load("main");
 228          $langs->load("bills");
 229  
 230        $pdf->SetFont('Arial','',11);
 231              
 232        $pdf->Text(30,$tab_top + 5,$langs->trans("Designation"));
 233        
 234        $pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
 235        $pdf->Text(134,$tab_top + 5,$langs->trans("VAT"));
 236        
 237        $pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
 238        $pdf->Text(147,$tab_top + 5,$langs->trans("Qty"));
 239        
 240        $pdf->line(156, $tab_top, 156, $tab_top + $tab_height);
 241        $pdf->Text(160,$tab_top + 5,$langs->trans("PriceU"));
 242        
 243        $pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
 244        $pdf->Text(187,$tab_top + 5,$langs->trans("Total"));
 245        
 246        //      $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top);
 247        $pdf->Rect(10, $tab_top, 190, $tab_height);
 248  
 249  
 250        $pdf->SetTextColor(0,0,0);
 251        $pdf->SetFont('Arial','',10);
 252        $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie));
 253        $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre);
 254  
 255      }
 256  
 257    function _pagehead(&$pdf, $propale)
 258      {
 259          global $langs;
 260        $pdf->SetXY(10,5);
 261        if (defined("FAC_PDF_INTITULE"))
 262      {
 263        $pdf->SetTextColor(0,0,200);
 264        $pdf->SetFont('Times','B',14);
 265        $pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L');
 266      }
 267        
 268        $pdf->SetTextColor(70,70,170);
 269        if (defined("FAC_PDF_ADRESSE"))
 270      {
 271        $pdf->SetFont('Times','',12);
 272        $pdf->MultiCell(76, 5, FAC_PDF_ADRESSE);
 273      }
 274        if (defined("FAC_PDF_TEL"))
 275      {
 276        $pdf->SetFont('Times','',10);
 277        $pdf->MultiCell(76, 5, $langs->trans("Phone")." : ".FAC_PDF_TEL);
 278      }  
 279        if (defined("MAIN_INFO_SIREN"))
 280      {
 281        $pdf->SetFont('Times','',10);
 282        $pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN);
 283      }  
 284        
 285        if (defined("FAC_PDF_INTITULE2"))
 286      {
 287        $pdf->SetXY(100,5);
 288        $pdf->SetFont('Times','B',14);
 289        $pdf->SetTextColor(0,0,200);
 290        $pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R');
 291      }
 292        /*
 293         * Adresse Client
 294         */
 295        $pdf->SetTextColor(0,0,0);
 296        $pdf->SetFont('Courier','B',12);
 297        $propale->fetch_client();
 298        $pdf->SetXY(102,42);
 299        $pdf->MultiCell(96,5, $propale->client->nom);
 300        $pdf->SetFont('Courier','B',11);
 301        $pdf->SetXY(102,47);
 302        $pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville);
 303        $pdf->rect(100, 40, 100, 40);
 304        
 305        
 306        $pdf->SetTextColor(200,0,0);
 307        $pdf->SetFont('Courier','B',12);
 308        $pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $propale->date));
 309        $pdf->Text(11, 94, "Proposition commerciale : ".$propale->ref);
 310        
 311        
 312      }
 313  
 314  }
 315  
 316  ?>


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