akrom
February 13, 2020, 9:30am
1
Hello i serched the forum but dident find an answer. I am traying to put product extra field in PDF invoice and i tried all solution that are on https://wiki.dolibarr.org/index.php/Add_Extrafields_on_PDF_Models
I would like to put in seperate lines like
Ford Mustang
Serial: xxxxxxxx
Mileage: xxxxxx
…
Can someone please help.
Thanks in advance
akrom
February 13, 2020, 9:46am
3
Hi
How do i put extrafields of product in invoice
is this the right way
$outputlangs->convToOutputCharset($product->array_options[‘options_my_product_extra’]) or do i have to rename options_my_product_extra to options_my_product_mileage
ksar
February 13, 2020, 9:50am
4
Hi,
You need to use options_my_product_**********
Where ********** is equal to the Attribute code of the Extrafield
akrom
February 13, 2020, 9:52am
5
Hi,
Just tried and dident work.
Can you tell me if my code is corect
// Loop on each lines
for ($i = 0; $i < $nblines; $i++)
{
if ($object->lines[$i]->fk_product)
{
require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$product = new Product($this->db);
$product->fetch($object->lines[$i]->fk_product);
$extrafields_product = new ExtraFields($this->db);
$extralabels_product = $extrafields_product->fetch_name_optionals_label($product->table_element);
$product->fetch_optionals($product->rowid, $extralabels_product);
}
$outputlangs->convToOutputCharset($product->array_options['options_my_product_letnik']);
$object->lines[$i]->fetch_optionals($object->lines[$i]->rowid,$extralabelsline);
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
akrom
February 13, 2020, 10:36am
6
Hi i made the atribut title to load but not the atribute.
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Prevozeni",":")." ".$outputlangs->convToOutputCharset($product->array_options['options_product_prevozeni'],"km"), 0, 'L', 0);
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($product->array_options['options_my_product_letnik']), 0, 'L', 0);
$posYAfterDescription = $pdf->GetY();
ksar
February 13, 2020, 10:52am
7
Hi,
Sorry I was too quick,
You need to use options_**********
Where ********** is equal to the Attribute code of the Extrafield
1 Like
akrom
February 13, 2020, 11:04am
8
One more thing what about pick field so it wont show 1 for first item
akrom
February 13, 2020, 1:31pm
12
I done that and on creatig PDF i get 500 error
Made it like that
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Številka šasije")."".(":")." ".$extrafields->showOutputField('my_extra', $object->array_options['options_stevilka_sasije']), 0, 'L', 0);
ksar
February 13, 2020, 1:44pm
13
Hi,
Need to replace
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Številka šasije")."".(":")." ".$extrafields->showOutputField('my_extra', $object->array_options['options_stevilka_sasije']), 0, 'L', 0);
by
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Številka šasije")."".(":")." ".$extrafields->showOutputField('stevilka_sasije', $object->array_options['options_stevilka_sasije']), 0, 'L', 0);
akrom
February 13, 2020, 1:48pm
14
Still get 500 error
dose have to be $object->array_options or $product->array_options
Tried bouth and dont work
ksar
February 13, 2020, 1:53pm
15
Hi,
Depends where you have created the “stevilka_sasije” extrafield
if it is created on product then $product->array_options
if it is created on invoice then $object->array_options
akrom
February 13, 2020, 1:58pm
16
Tried and still get 500 error
ksar
February 13, 2020, 2:52pm
17
What Error ?
Give details please
akrom
February 14, 2020, 11:46am
18
ksar:
tions_stevilka_sa
Hi,
Thanks for the solutions but i decidet to do with text field insted of select list field
https://wiki.dolibarr.org/index.php/Add_Extrafields_on_PDF_Models
Is good for extrafield in PDF ok.
But for select list, PROBLEM.
I have had to comment momentarily, the line that gives me error (PDF crash)
$object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels);
$extrafields = new ExtraFields($db);
// $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
Special Case for Extrafields type “Select list” NOT WORKING
$pdf->MultiCell(0, 3, 'LISTA: '.$outputlangs->convToOutputCharset($object->array_options['options_lista']), 0, 'L', 0);
LISTA: 2
AND
$pdf->MultiCell(0, 3, 'LISTA: '.$extrafields->showOutputField('lista', $object->array_options['options_lista']), 0, 'L', 0);
not possible with the ($extralabels=$extrafields->fetch_…) // commented
Please HELP!
ksar
May 10, 2020, 1:12pm
20
Hi,
What error ?
What is the extra field configuration ?
Can you share the full model ?