Skip to content

Commit

Permalink
Merge pull request #8155 from atm-ph/fix_6.0_pdf_writelinkedobjects_p…
Browse files Browse the repository at this point in the history
…osition

Fix position if module use pdf hook "linkedobjects"
  • Loading branch information
eldy committed Feb 8, 2018
2 parents 2d4624a + 6254e20 commit 414093f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
22 changes: 15 additions & 7 deletions htdocs/core/modules/commande/doc/pdf_einstein.modules.php
Expand Up @@ -293,16 +293,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);


$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
$tab_height = 130-$top_shift;
$tab_height_newpage = 150;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;

// Incoterm
$height_incoterms = 0;
Expand Down Expand Up @@ -1298,16 +1299,22 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="Order"

$posy+=2;

$top_shift = 0;
// Show list of linked objects
$current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);

if ($current_y < $pdf->getY())
{
$top_shift = $pdf->getY() - $current_y;
}

if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);

// Show sender
$posy=42;
$posy=42+$top_shift;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
$hautcadre=40;
Expand Down Expand Up @@ -1359,7 +1366,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="Order"
// Show recipient
$widthrecbox=100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
$posy=42;
$posy=42+$top_shift;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

Expand All @@ -1384,6 +1391,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="Order"
}

$pdf->SetTextColor(0,0,0);
return $top_shift;
}

/**
Expand Down
20 changes: 15 additions & 5 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
Expand Up @@ -331,15 +331,16 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;

$this->_pagehead($pdf, $object, 1, $outputlangs);
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);

$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
$tab_height = 130-$top_shift;
$tab_height_newpage = 150;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;

// Incoterm
$height_incoterms = 0;
Expand Down Expand Up @@ -1670,16 +1671,23 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)

$posy+=1;

$top_shift = 0;
// Show list of linked objects
$current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);

if ($current_y < $pdf->getY())
{
$top_shift = $pdf->getY() - $current_y;
}

if ($showaddress)
{
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);

// Show sender
$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
$posy+=$top_shift;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;

Expand Down Expand Up @@ -1735,6 +1743,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
$posy+=$top_shift;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

Expand All @@ -1759,6 +1768,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
}

$pdf->SetTextColor(0,0,0);
return $top_shift;
}

/**
Expand Down
22 changes: 15 additions & 7 deletions htdocs/core/modules/propale/doc/pdf_azur.modules.php
Expand Up @@ -329,16 +329,17 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
//print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;

$this->_pagehead($pdf, $object, 1, $outputlangs);
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);


$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
$tab_height = 130-$top_shift;
$tab_height_newpage = 150;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;

// Incoterm
$height_incoterms = 0;
Expand Down Expand Up @@ -1484,9 +1485,15 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)

$posy+=2;

$top_shift = 0;
// Show list of linked objects
$current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);

if ($current_y < $pdf->getY())
{
$top_shift = $pdf->getY() - $current_y;
}

if ($showaddress)
{
// Sender properties
Expand All @@ -1503,7 +1510,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);

// Show sender
$posy=42;
$posy=42+$top_shift;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
$hautcadre=40;
Expand Down Expand Up @@ -1554,7 +1561,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
// Show recipient
$widthrecbox=100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
$posy=42;
$posy=42+$top_shift;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

Expand All @@ -1579,6 +1586,7 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
}

$pdf->SetTextColor(0,0,0);
return $top_shift;
}

/**
Expand Down

0 comments on commit 414093f

Please sign in to comment.