439
edits
No edit summary |
|||
| Line 63: | Line 63: | ||
$pdf->SetY($pdf->GetY()+1); // line return for the next printing | $pdf->SetY($pdf->GetY()+1); // line return for the next printing | ||
} | } | ||
return 1; | |||
} | |||
</source> | |||
Alternative function (with a bit less functionalities, but more controllable): | |||
<source lang="php"> | |||
/** | |||
* \brief Show the customfields in a new page (used to debug if CustomFields setup is correct) | |||
* \param pdf PDF factory | |||
* \param object Object invoice/propal/product/whatever... | |||
* \param outputlangs Object lang for output | |||
*/ | |||
function _pagecustomfields(&$pdf,$object,$outputlangs) | |||
{ | |||
$default_font_size = pdf_getPDFFontSize($outputlangs); | |||
if (empty($object->table_element) or empty($object->id)) { | |||
$pdf->MultiCell(0,3, "Current \$object is not compatible with CustomFields, could not find table_element or id.", 0, 'L'); | |||
return 1; | |||
} | |||
// Init and main vars | |||
include_once(DOL_DOCUMENT_ROOT.'/customfields/class/customfields.class.php'); | |||
$customfields = new CustomFields($this->db, $object->table_element); | |||
// Fetching custom fields records | |||
$fields = $customfields->fetch($object->id); | |||
if (!isset($fields)) { | |||
$pdf->MultiCell(0,3, "No custom field could be found for this object. Please check your configuration (did you create at least one customfield and set a value in the current datasheet?)", 0, 'L'); | |||
return 1; | |||
} else { | |||
// Setting the starting position of the text cursor | |||
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $pdf->GetY()+4); | |||
$pdf->SetY($pdf->GetY()+1); | |||
// Printing the customfields | |||
foreach ($fields as $key=>$field) { | |||
$translatedname = $customfields->findLabelPDF($key, $outputlangs); // label of the customfield | |||
$value = $customfields->simpleprintFieldPDF($key, $field, $outputlangs); // value (cleaned and properly formatted) of the customfield | |||
$pdf->SetFont('','B', $default_font_size); | |||
$pdf->MultiCell(0,3, $translatedname.': '.$value, 0, 'L'); // printing the customfield | |||
$pdf->SetY($pdf->GetY()+1); // line return for the next printing | |||
} | |||
} | |||
return 1; | return 1; | ||
edits