[ 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_jaune.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_jaune.modules.php,v 1.22 2005/11/11 20:11:58 eldy Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php,v $
  22   */
  23  
  24  /**        \file       htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
  25          \ingroup    propale
  26          \brief      Fichier de la classe permettant de générer les propales au modèle Jaune
  27          \version    $Revision: 1.22 $
  28  */
  29  
  30  require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
  31  
  32  
  33  /**        \class      pdf_propale_jaune
  34          \brief      Classe permettant de générer les propales au modèle Jaune
  35  */
  36  
  37  class pdf_propale_jaune extends ModelePDFPropales
  38  {
  39  
  40      /**        \brief  Constructeur
  41              \param    db        handler accès base de donnée
  42      */
  43    function pdf_propale_jaune($db=0)
  44      { 
  45          $this->db = $db;
  46          $this->name = "jaune";
  47          $this->description = "Modèle de proposition Jaune";
  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              if (! file_exists($dir))
  85              {
  86                  if (create_exdir($dir) < 0)
  87                  {
  88                      $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
  89                      return 0;
  90                  }
  91              }
  92          }
  93        else
  94          {
  95              $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR");
  96              return 0;
  97          }
  98        
  99            $propref = sanitize_string($propale->ref);
 100            $file = $dir . "/" . $propref . ".pdf";
 101        
 102        if (file_exists($dir))
 103          {
 104  
 105            $pdf=new FPDF('P','mm',$this->format);
 106            $pdf->Open();
 107  
 108            $pdf->SetTitle($propale->ref);
 109            $pdf->SetSubject("Proposition commerciale");
 110            $pdf->SetCreator("Dolibarr ".DOL_VERSION);
 111            $pdf->SetAuthor($user->fullname);
 112  
 113            $pdf->AddPage();
 114            
 115            $this->_pagehead($pdf, $propale);
 116  
 117            /*
 118             */
 119            $tab_top = 100;
 120            $tab_height = 150;
 121            /*
 122             *
 123             */  
 124            
 125            $pdf->SetFillColor(242,239,119);
 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            $curY = $nexY;
 140            $total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty);
 141  
 142            $pdf->SetXY (30, $curY );
 143            $pdf->MultiCell(102, 5, $propale->lignes[$i]->desc, 0, 'J', 0);
 144  
 145            $nexY = $pdf->GetY();
 146           
 147            $pdf->SetXY (10, $curY );
 148            $pdf->MultiCell(20, 5, $propale->lignes[$i]->ref, 0, 'C', 0);
 149  
 150            $pdf->SetXY (132, $curY );          
 151            $pdf->MultiCell(12, 5, $propale->lignes[$i]->tva_tx, 0, 'C', 0);
 152            
 153            $pdf->SetXY (144, $curY );
 154            $pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C', 0);
 155  
 156            $pdf->SetXY (154, $curY );
 157            $pdf->MultiCell(22, 5, price($propale->lignes[$i]->price), 0, 'R', 0);
 158            
 159            $pdf->SetXY (176, $curY );
 160            $pdf->MultiCell(24, 5, $total, 0, 'R', 0);
 161            
 162            $pdf->line(10, $curY, 200, $curY );
 163  
 164            if ($nexY > 240 && $i < $nblignes - 1)
 165              {
 166                $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
 167                $pdf->AddPage();
 168                $nexY = $iniY;
 169                $this->_pagehead($pdf, $propale);
 170                $pdf->SetTextColor(0,0,0);
 171                $pdf->SetFont('Arial','', 10);
 172              }
 173          }
 174            
 175            $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
 176            /*
 177             *
 178             */
 179            $tab2_top = 254;
 180            $tab2_lh = 7;
 181            $tab2_height = $tab2_lh * 3;
 182  
 183            $pdf->SetFont('Arial','', 11);
 184            
 185            $pdf->Rect(132, $tab2_top, 68, $tab2_height);
 186            
 187            $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) );
 188            $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) );
 189            $pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh );
 190            
 191            $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
 192            
 193            $pdf->SetXY (132, $tab2_top + 0);
 194            $pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0);
 195            
 196            $pdf->SetXY (132, $tab2_top + $tab2_lh);
 197            $pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0);
 198            
 199            $pdf->SetXY (132, $tab2_top + ($tab2_lh*2));
 200            $pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1);
 201            
 202            $pdf->SetXY (174, $tab2_top + 0);
 203            $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0);
 204            
 205            $pdf->SetXY (174, $tab2_top + $tab2_lh);
 206            $pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0);
 207            
 208            $pdf->SetXY (174, $tab2_top + ($tab2_lh*2));
 209            $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1);
 210            
 211            /*
 212             *
 213             */
 214                      
 215            $pdf->Output($file);
 216        return 1;
 217          }
 218      }
 219      }
 220  
 221    function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
 222      {
 223          global $langs,$conf;
 224          $langs->load("main");
 225          $langs->load("bills");
 226  
 227        $pdf->SetFont('Arial','',11);
 228  
 229        $pdf->SetXY(10,$tab_top);
 230        $pdf->MultiCell(20,10,$langs->trans("Ref"),0,'C',1);
 231  
 232        $pdf->SetXY(30,$tab_top);
 233        $pdf->MultiCell(102,10,$langs->trans("Designation"),0,'L',1);
 234        
 235        $pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
 236        $pdf->SetXY(132,$tab_top);
 237        $pdf->MultiCell(12, 10,$langs->trans("VAT"),0,'C',1);
 238        
 239        $pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
 240        $pdf->SetXY(144,$tab_top);
 241        $pdf->MultiCell(10,10,$langs->trans("Qty"),0,'C',1);
 242        
 243        $pdf->line(154, $tab_top, 154, $tab_top + $tab_height);
 244        $pdf->SetXY(154,$tab_top);
 245        $pdf->MultiCell(22,10,$langs->trans("PriceU"),0,'R',1);
 246        
 247        $pdf->line(176, $tab_top, 176, $tab_top + $tab_height);
 248        $pdf->SetXY(176,$tab_top);
 249        $pdf->MultiCell(24,10,$langs->trans("Total"),0,'R',1);
 250        
 251        $pdf->Rect(10, $tab_top, 190, $tab_height);
 252  
 253        $pdf->SetTextColor(0,0,0);
 254        $pdf->SetFont('Arial','',10);
 255        $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie));
 256        $pdf->Text(10,280, $titre);
 257      }
 258  
 259    function _pagehead(&$pdf, $propale)
 260      {
 261        $pdf->SetXY(12,42);
 262        if (defined("FAC_PDF_INTITULE"))
 263      {
 264        $pdf->SetTextColor(0,0,200);
 265        $pdf->SetFont('Arial','B',14);
 266        $pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L');
 267      }
 268        
 269        $pdf->SetTextColor(70,70,170);
 270        if (defined("FAC_PDF_ADRESSE"))
 271      {
 272        $pdf->SetX(12);
 273        $pdf->SetFont('Arial','',12);
 274        $pdf->MultiCell(76, 5, FAC_PDF_ADRESSE);
 275      }
 276        if (defined("FAC_PDF_TEL"))
 277      {
 278        $pdf->SetX(12);
 279        $pdf->SetFont('Arial','',10);
 280        $pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL);
 281      }  
 282        if (defined("MAIN_INFO_SIREN"))
 283      {
 284        $pdf->SetX(12);
 285        $pdf->SetFont('Arial','',10);
 286        $pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN);
 287      }  
 288        $pdf->rect(10, 40, 80, 40);      
 289  
 290        $pdf->SetXY(10,5);
 291        $pdf->SetFont('Arial','B',16);
 292        $pdf->SetTextColor(0,0,200);
 293        $pdf->MultiCell(200, 20, "PROPOSITION COMMERCIALE", '' , 'C');
 294  
 295        /*
 296         * Adresse Client
 297         */
 298        $pdf->SetTextColor(0,0,0);
 299        $pdf->SetFont('Arial','B',12);
 300        $propale->fetch_client();
 301        $pdf->SetXY(102,42);
 302        $pdf->MultiCell(96,5, $propale->client->nom);
 303        $pdf->SetFont('Arial','B',11);
 304        $pdf->SetXY(102,47);
 305        $pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville);
 306        $pdf->rect(100, 40, 100, 40);
 307              
 308        $pdf->SetTextColor(200,0,0);
 309        $pdf->SetFont('Arial','B',12);
 310  
 311        $pdf->rect(10, 90, 100, 10);
 312        $pdf->rect(110, 90, 90, 10);
 313  
 314        $pdf->SetXY(10,90);
 315        $pdf->MultiCell(110, 10, "Numéro : ".$propale->ref);
 316        $pdf->SetXY(110,90);
 317        $pdf->MultiCell(100, 10, "Date : " . strftime("%d %B %Y", $propale->date));            
 318      }
 319  }
 320  ?>


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