Print Complementary Attributes (orders) to PDF

Hi everyone!

We’ve recently decided to move from our old obsolete and non secure purchase order system. We needed as well a timesheet system, so that’s all the better. Dlibar works great for all of it.

My only concern is the lack of options for the Supplier Orders module. Basically, we do not sell anything, but we need to buy devices and equipment from different vendors, to which we supply Purchase Orders (PO). We have several sites where we can ship stock, but unfortunately, when the orders are generated, the only address field is queried from the Company info, and that is our Head office.

I figured I can add Custom field in the form of a drop down list on the New Order Card (which I marked as Required) but once it’s selected and the Card draft is actually generated, the Complementary field is there (Shipping Address), but it does not get printed on the PDF form.

I already have edited the PDF template, as it wasn’t printing both taxes in use (Canada), as it is mandatory to print both.

What I’m curious to find is if there is anyway to have the Complementary information printed as well. I assume it has to do with the ExtraFields function for modules. Alas, I’m not a programmer and PHP is definitely not my forte.

If anyone has any leads on that specific matter, that would be greatly appreciated.

Cheers!

For extra field, there is not way to show them in pdf. Except if you edit the template (need php knowledge)
But for addresses, did you try to use the “contact” tab to force a different contact. The contact should be used by default on PDF if defined.

For double taxes, can you paste a sample of pdf to show that info is missing and same screen for the PO that show double taxes are present on PO.

Hi Eldy,

First off, thanks for the quick reply. The problem I have right now is that the Order Card doesn’t seem to be able to do that. I don’t know if the default PDF model for the Order Card is bugged or some code is missing, but it never shows up, even if I select a different contact, ether for my company or for my provider.

Hence the need to be able to print the extra field. I think I can figure where to put it, and what to do, the problem I have with the documentation regarding them is that I’m not sure I understand correctly what DB tables to query for the info.

As for the taxes, I will add some picture to better show what I have done, and I will gladly include my code along, if anyone wants to do the same.

First off, here is what you get in the order card when you make a draft

Dolibarr-Tax1.png

Now, here is what you get with the default template, muscadet:

Dolibarr-Tax2.png

I parsed through the template code and found out that if there is a first sales tax (defined as VAT all the time in the code, which is a little bit bothering to work with), it will add sales tax 2 and/or 3 to the total, but it doesn’t seem to print them. The function to print them only works if ( and that’s the way the original code works) the first sales tax (VAT) is 0. That was seriously puzzling to me.

I edited the code for my own template. Had to add an extra table row, and modify the other items to be displayed (Total net, tax 1, and grand total) to be displayed taking the extra line in account. Here is what it looks like:

Dolibarr-Tax3.png

And here is the code I modified:

In function _tableau_tot

Under global config, I edited table values to add an extra row

        $tab2_top = $posy;
		$tab2_hl = 4;
		$tab2_hl2 = 8;
		$pdf->SetFont('','', $default_font_size - 1);

Then after the code if ($tvakey > 0) used to print the VAT if it’s not 0, I added the following, which was copied from the next IF function, that prints taxes 2 and 3, but only if the VAT is 0.

 				//Display of Tax Rate 2 on top of VAT
				$pdf->SetXY($col1x, $tab2_top + $tab2_hl2 * $index);
				$pdf->MultiCell($col2x-$col1x, $tab2_hl2, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1);
				$pdf->SetXY($col2x, $tab2_top + $tab2_hl2 * $index);
				$pdf->MultiCell($largcol2, $tab2_hl2, price($object->total_localtax1), $useborder, 'R', 1);

The same could probably be done for tax 3, you’d just need to add a third table row and make the appropriate correction to the code.