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


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