Skip to content

Commit

Permalink
Qual: Uniformize pdf templates
Browse files Browse the repository at this point in the history
Qual: Removed duplicate pdf templates when content with no technology
difference nor functionnal difference
  • Loading branch information
eldy committed Sep 4, 2012
1 parent 2bf933f commit aea8938
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 3,018 deletions.
696 changes: 0 additions & 696 deletions htdocs/core/modules/commande/doc/pdf_edison.modules.php

This file was deleted.

88 changes: 55 additions & 33 deletions htdocs/core/modules/commande/doc/pdf_einstein.modules.php
Expand Up @@ -131,7 +131,6 @@ function __construct($db)
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{
global $user,$langs,$conf;
$default_font_size = pdf_getPDFFontSize($outputlangs);

if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
Expand All @@ -144,13 +143,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$outputlangs->load("products");
$outputlangs->load("orders");

$default_font_size = pdf_getPDFFontSize($outputlangs);

if ($conf->commande->dir_output)
{
$object->fetch_thirdparty();

$deja_regle = "";

// Definition de $dir et $file
// Definition of $dir and $file
if ($object->specimen)
{
$dir = $conf->commande->dir_output;
Expand Down Expand Up @@ -793,55 +794,76 @@ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0,
{
global $conf;

// Amount in (at tab_top - 1)
$default_font_size = pdf_getPDFFontSize($outputlangs);

// Amount in (at tab_top - 1)
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2);
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);

if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
}

$pdf->SetDrawColor(128,128,128);
$pdf->SetFont('','', $default_font_size - 1);

// Output Rect
$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param

// Rect prend une longueur en 3eme et 4eme param
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
// line prend une position y en 3eme et 4eme param
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);

$pdf->SetFont('','', $default_font_size - 1);

$pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
if (empty($hidetop))
{
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);

$pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
}

if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxtva-3, $tab_top+1);
$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
if (empty($hidetop))
{
$pdf->SetXY($this->posxtva-3, $tab_top+1);
$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
}
}

$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxup-1, $tab_top+1);
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');

if (empty($hidetop))
{
$pdf->SetXY($this->posxup-1, $tab_top+1);
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
}

$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');

if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}

$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
if ($this->atleastonediscount)
if (empty($hidetop))
{
$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
if ($this->atleastonediscount)
{
$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
}
}

if ($this->atleastonediscount)
{
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
}
$pdf->SetXY($this->postotalht-1, $tab_top+1);
$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');

if (empty($hidetop))
{
$pdf->SetXY($this->postotalht-1, $tab_top+1);
$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
}
}

/**
Expand Down Expand Up @@ -976,7 +998,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
if (! empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
else $socname = $object->client->nom;
$carac_client_name=$outputlangs->convToOutputCharset($socname);
}
Expand All @@ -985,7 +1007,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
}

$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');

// Show recipient
$posy=42;
Expand Down Expand Up @@ -1017,7 +1039,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
* @param PDF &$pdf PDF
* @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @return void
* @return int Return height of bottom margin including footer text
*/
function _pagefoot(&$pdf,$object,$outputlangs)
{
Expand Down
9 changes: 5 additions & 4 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
Expand Up @@ -168,7 +168,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return 0;
}
}
Expand Down Expand Up @@ -273,6 +273,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);

$pageposafter=$pdf->getPage();

$pdf->setPage($pageposbefore);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.

Expand Down Expand Up @@ -324,9 +325,9 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$localtax2rate=(string) $object->lines[$i]->localtax2_tx;

if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
if (! isset($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]='';
if (! isset($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]='';
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
if (! isset($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]='';
if (! isset($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]='';
$this->tva[$vatrate] += $tvaligne;
$this->localtax1[$localtax1rate]+=$localtax1ligne;
$this->localtax2[$localtax2rate]+=$localtax2ligne;
Expand Down

0 comments on commit aea8938

Please sign in to comment.