Trigger or bypass Global parameter from PDF template script

Hello, I am new to Dolibarr and must say I am very impressed with the system so far.
I am looking at implementing it in the coming weeks and seem to have hit a slight block.

I have been able to create my own basic proposal/sales order templates for PDF, including hiding references, descriptions etc…

I notice there are global options for PDF under the ‘setup’ menu which allow me display ‘Kits’ component/descriptions if the product is a kit (which is great by the way).

The problem I have is that I want these to be shown on all PDF relating to purchasing, and not on any PDF relating to sales.
From what I have seen the global parameter used is SHOW_SUBPRODUCT_REF_IN_PDF but this must be activated/disabled from the setup menu which will be unworkable to switch on an off between sales/purchase order when in production.

Is there a way that this can enabled/disabled or manually bypassed directly from a PDF template script ?

Hopefully someone can help :slight_smile:

Hi,

For customizations, try ODT either for Sales / Purchase depending upon the fitment.

thanks
yesbee

Hi Rise, thanks for the suggestion.

I did look at the .ODT templates briefly which looked a lot more basic than the PDF templates, hence why I was digging in to the PDF workaround.
Which ODT template parameter would be responsible for showing/hiding a product’s subproducts ?
From what I can see there is only {line_fulldesc} which suggets that field has been pre-compiled according to the global parameters (which wouldn’t solve my issue).

In an ideal world there would be an option to enable/disable SHOW_SUBPRODUCT_REF_IN_PDF global parameter for both sales or purchase orders which would solve this problem instantly, which is what I may need to consider doing if I am unable to bypass this parameter through a template, although this would undoubtedly break at the next update so isn’t really a solution.
Unless I can temporarily disable it in the proposal/sales order PDF generation PHP script.

You can choose templates including ODT. Use ODT for not showing sub products. Alternatively, you can also create a custom field if needed and add it in ODT.

1 Like

Hello,

Yes it can be bypassed directly on PDF template script, you need to create your own templates.

1 Like

Thanks for the answers guys, its really appreciated.

My lazy self was hoping I could just use one of the (very nice) default templates and simply call
$GLOBALS[‘SHOW_SUBPRODUCT_REF_IN_PDF’] = 0 at the start of a current template and call
$GLOBALS[‘SHOW_SUBPRODUCT_REF_IN_PDF’] = 1 at the end.
(or the equivalent thereof to write to the required parameter).

To be fair I haven’t dug in to the framework yet, so it may be that I can do that once I do a little more reading. :slight_smile:

Your answers at least let me know it’s possible to accomplish and not too difficult so will dig in a bit deeper and sort this out.

Thank you again.

I just wanted to confirm that I have tried as my lazy self would have liked it to be done (as suggested above) and it works flawlessly.

Slightly different code but the principle was the same and I got it working as expected in a few minutes.

Dolibarr is brilliant and so flexible/easy to tweak to one’s requirements.

Thanks again for the help guys.

1 Like

Good afternoon Krasta. I would like to do exactly what you did. Please could you confirm which instructions exactly you added to your ODT ? thanks in advance