forked from Wavyzz/dolibarr
New: add method for show linked objects in pdf
This commit is contained in:
@@ -282,7 +282,6 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a draft watermark on PDF files
|
* Add a draft watermark on PDF files
|
||||||
*
|
*
|
||||||
@@ -1250,7 +1249,6 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
|
|||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a currency code into its symbol
|
* Convert a currency code into its symbol
|
||||||
*
|
*
|
||||||
@@ -1607,4 +1605,48 @@ function pdf_getCurrencySymbol(&$pdf, $currency_code)
|
|||||||
return $currency_sign;
|
return $currency_sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show linked objects for PDF generation
|
||||||
|
*
|
||||||
|
* @param object $object Object
|
||||||
|
* @param Translate $outputlangs Object lang for output
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function pdf_getLinkedObjects($object,$outputlangs)
|
||||||
|
{
|
||||||
|
$linkedobjects=array();
|
||||||
|
|
||||||
|
$object->fetchObjectLinked();
|
||||||
|
|
||||||
|
foreach($object->linkedObjects as $objecttype => $objects)
|
||||||
|
{
|
||||||
|
if ($objecttype == 'propal')
|
||||||
|
{
|
||||||
|
$outputlangs->load('propal');
|
||||||
|
$num=count($objects);
|
||||||
|
for ($i=0;$i<$num;$i++)
|
||||||
|
{
|
||||||
|
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
|
||||||
|
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
|
||||||
|
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
|
||||||
|
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($objecttype == 'commande')
|
||||||
|
{
|
||||||
|
$outputlangs->load('orders');
|
||||||
|
$num=count($objects);
|
||||||
|
for ($i=0;$i<$num;$i++)
|
||||||
|
{
|
||||||
|
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
|
||||||
|
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref) . ($objects[$i]->ref_client ? ' ('.$objects[$i]->ref_client.')' : '');
|
||||||
|
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
|
||||||
|
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $linkedobjects;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -631,14 +631,37 @@ class pdf_edison extends ModelePDFCommandes
|
|||||||
$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
|
$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
|
||||||
$pdf->MultiCell(86,4, $carac_client, 0, 'L');
|
$pdf->MultiCell(86,4, $carac_client, 0, 'L');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$curY = 80;
|
||||||
|
$posy=$curY;
|
||||||
|
|
||||||
// Date - order
|
// Date - order
|
||||||
$pdf->SetTextColor(200,0,0);
|
$pdf->SetTextColor(200,0,0);
|
||||||
$pdf->SetFont('','B', $default_font_size + 2);
|
$pdf->SetFont('','B', $default_font_size + 1);
|
||||||
$pdf->SetXY(11, 88);
|
$pdf->SetXY(11, $posy);
|
||||||
|
$posy+=6;
|
||||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs), 0, 'L');
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs), 0, 'L');
|
||||||
$pdf->SetXY(11, 94);
|
$pdf->SetXY(11, $posy);
|
||||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref), 0, 'L');
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref), 0, 'L');
|
||||||
|
|
||||||
|
|
||||||
|
$posy+=1;
|
||||||
|
|
||||||
|
// Add list of linked objects
|
||||||
|
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
|
||||||
|
if (! empty($linkedobjects))
|
||||||
|
{
|
||||||
|
foreach($linkedobjects as $linkedobject)
|
||||||
|
{
|
||||||
|
$posy+=3;
|
||||||
|
$pdf->SetXY(11,$posy);
|
||||||
|
$pdf->SetFont('','', $default_font_size + 1);
|
||||||
|
$pdf->MultiCell(100, 4, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', 'L');
|
||||||
|
$posy+=4;
|
||||||
|
$pdf->SetXY(11,$posy);
|
||||||
|
$pdf->MultiCell(100, 4, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', 'L');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
|
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -922,7 +922,25 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
$pdf->SetXY($posx,$posy);
|
$pdf->SetXY($posx,$posy);
|
||||||
$pdf->SetTextColor(0,0,60);
|
$pdf->SetTextColor(0,0,60);
|
||||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
|
||||||
|
|
||||||
|
$posy+=2;
|
||||||
|
|
||||||
|
// Add list of linked objects
|
||||||
|
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
|
||||||
|
if (! empty($linkedobjects))
|
||||||
|
{
|
||||||
|
foreach($linkedobjects as $linkedobject)
|
||||||
|
{
|
||||||
|
$posy+=3;
|
||||||
|
$pdf->SetXY($posx,$posy);
|
||||||
|
$pdf->SetFont('','', $default_font_size - 2);
|
||||||
|
$pdf->MultiCell(100, 3, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', 'R');
|
||||||
|
$posy+=3;
|
||||||
|
$pdf->SetXY($posx,$posy);
|
||||||
|
$pdf->MultiCell(100, 3, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', 'R');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($showaddress)
|
if ($showaddress)
|
||||||
{
|
{
|
||||||
// Sender properties
|
// Sender properties
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -1121,44 +1121,20 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
|
|
||||||
$posy+=2;
|
$posy+=2;
|
||||||
|
|
||||||
// Add list of linked orders and proposals
|
// Add list of linked objects
|
||||||
// TODO mutualiser
|
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
|
||||||
$object->fetchObjectLinked();
|
if (! empty($linkedobjects))
|
||||||
|
{
|
||||||
foreach($object->linkedObjects as $objecttype => $objects)
|
foreach($linkedobjects as $linkedobject)
|
||||||
{
|
|
||||||
if ($objecttype == 'propal')
|
|
||||||
{
|
|
||||||
$outputlangs->load('propal');
|
|
||||||
$num=count($objects);
|
|
||||||
for ($i=0;$i<$num;$i++)
|
|
||||||
{
|
|
||||||
$posy+=3;
|
|
||||||
$pdf->SetXY($posx,$posy);
|
|
||||||
$pdf->SetFont('','', $default_font_size - 2);
|
|
||||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'R');
|
|
||||||
$posy+=3;
|
|
||||||
$pdf->SetXY($posx,$posy);
|
|
||||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DatePropal")." : ".dol_print_date($objects[$i]->date,'day','',$outputlangs), '', 'R');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'commande')
|
|
||||||
{
|
{
|
||||||
$outputlangs->load('orders');
|
$posy+=3;
|
||||||
$num=count($objects);
|
$pdf->SetXY($posx,$posy);
|
||||||
for ($i=0;$i<$num;$i++)
|
$pdf->SetFont('','', $default_font_size - 2);
|
||||||
{
|
$pdf->MultiCell(100, 3, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', 'R');
|
||||||
$posy+=3;
|
$posy+=3;
|
||||||
$pdf->SetXY($posx,$posy);
|
$pdf->SetXY($posx,$posy);
|
||||||
$pdf->SetFont('','', $default_font_size - 2);
|
$pdf->MultiCell(100, 3, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', 'R');
|
||||||
$text=$objects[$i]->ref;
|
}
|
||||||
if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
|
|
||||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
|
|
||||||
$posy+=3;
|
|
||||||
$pdf->SetXY($posx,$posy);
|
|
||||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($objects[$i]->date,'day','',$outputlangs), '', 'R');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($showaddress)
|
if ($showaddress)
|
||||||
|
|||||||
@@ -997,44 +997,21 @@ class pdf_oursin extends ModelePDFFactures
|
|||||||
}
|
}
|
||||||
|
|
||||||
$posy+=1;
|
$posy+=1;
|
||||||
|
|
||||||
// Add list of linked orders and proposals
|
// Add list of linked objects
|
||||||
// TODO mutualiser
|
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
|
||||||
$object->fetchObjectLinked();
|
if (! empty($linkedobjects))
|
||||||
|
{
|
||||||
foreach($object->linkedObjects as $objecttype => $objects)
|
foreach($linkedobjects as $linkedobject)
|
||||||
{
|
{
|
||||||
if ($objecttype == 'propal')
|
$posy+=3;
|
||||||
{
|
$pdf->SetXY($this->marges['g'],$posy);
|
||||||
$outputlangs->load('propal');
|
$pdf->SetFont('','', $default_font_size - 2);
|
||||||
$num=count($objects);
|
$pdf->MultiCell(60, 3, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', 'L');
|
||||||
for ($i=0;$i<$num;$i++)
|
$posy+=3;
|
||||||
{
|
$pdf->SetXY($posx,$posy);
|
||||||
$posy+=3;
|
$pdf->MultiCell(60, 3, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', 'L');
|
||||||
$pdf->SetXY($this->marges['g'],$posy);
|
}
|
||||||
$pdf->SetFont('','', $default_font_size - 2);
|
|
||||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'L');
|
|
||||||
$posy+=3;
|
|
||||||
$pdf->SetXY($this->marges['g'],$posy);
|
|
||||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("DatePropal")." : ".dol_print_date($objects[$i]->date,'day','',$outputlangs), '', 'L');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'commande')
|
|
||||||
{
|
|
||||||
$num=count($objects);
|
|
||||||
for ($i=0;$i<$num;$i++)
|
|
||||||
{
|
|
||||||
$posy+=3;
|
|
||||||
$pdf->SetXY($this->marges['g'],$posy);
|
|
||||||
$pdf->SetFont('','', $default_font_size - 2);
|
|
||||||
$text=$objects[$i]->ref;
|
|
||||||
if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
|
|
||||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'L');
|
|
||||||
$posy+=3;
|
|
||||||
$pdf->SetXY($this->marges['g'],$posy);
|
|
||||||
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($objects[$i]->date,'day','',$outputlangs), '', 'L');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amount in (at tab_top - 1)
|
// Amount in (at tab_top - 1)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||||
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
@@ -963,6 +963,24 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
$pdf->SetTextColor(0,0,60);
|
$pdf->SetTextColor(0,0,60);
|
||||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
|
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$posy+=2;
|
||||||
|
|
||||||
|
// Add list of linked objects
|
||||||
|
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
|
||||||
|
if (! empty($linkedobjects))
|
||||||
|
{
|
||||||
|
foreach($linkedobjects as $linkedobject)
|
||||||
|
{
|
||||||
|
$posy+=3;
|
||||||
|
$pdf->SetXY($posx,$posy);
|
||||||
|
$pdf->SetFont('','', $default_font_size - 2);
|
||||||
|
$pdf->MultiCell(100, 3, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', 'R');
|
||||||
|
$posy+=3;
|
||||||
|
$pdf->SetXY($posx,$posy);
|
||||||
|
$pdf->MultiCell(100, 3, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', 'R');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($showaddress)
|
if ($showaddress)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user