-->
Welcome, Guest
Username: Password: Remember me
Kindly provide clear instructions for other users on how to make your submitted template work. Please clearly state your current working version to avoid any issues for other users. Templates submitted by any user are provided as-is.

Poll: Is This Useful?

Yes 4 100%
No No votes 0%
Total number of voters: 4 ( hORb, Efstathiou, n15c, aljawaid )
Only registered users can participate to this poll

TOPIC: Theresa | Expense Report PDF Model

Theresa | Expense Report PDF Model 4 months 2 weeks ago #35484

  • aljawaid
  • aljawaid's Avatar
  • OFFLINE
  • Moderator
  • Learning to be open, one source at a time.
  • Posts: 726
  • Thank you received: 116
  • Karma: 13
Theresa - An Alternative Expense Report PDF Document Model

WARNING:
This information and code is presented to you in good faith. Using parts of this code or file is at your own risk. This feature has been tested on Dolibarr 7.0.4 and 8.0.2 .


What this does
Upto Dolibarr 8.0 the 'standard' expense report PDF model followed the typical invoice-style layout. With Dolibarr 9.0 a new improved layout was created for the 'standard' model which tackled reducing the columns and blank pages.

The 'theresa' model is focussed on a business expense usage, as opposed to a user expense usage. Model 'theresa' is based on the improved 'standard' model but with the following changes:
  • Added payment table to PDF
  • Amount paid/claimed/unpaid is only shown when unpaid
  • Add PDF Description and Author *
  • Only show payments on PDF if there is a payment.
  • Hidden config MAIN_GENERATE_NON_SALES_DOCUMENTS_WITHOUT_VAT to make sales doc vat different from internal docs
  • Page table titles in bold and aligned
  • Changed the overall text color to black for paper printing
  • Highlighted date (in bold) for easier reference
  • Changed the status color to a paper-friendly green
  • Changed the 'Amount in' to italics
  • Aligned columns
* Requires new translation string


What the PDF looks like

Here's the general look...
theresa-no-payment.png




Here's with the payment table...
theresa-payment-table.png



Here's the unpaid section...
theresa-unpaid.png



Upload the document model
EXTRACT and upload to:
/core/modules/expensereport/doc/

This file:
Part of the message is hidden for the guests. Please log in or register to see it.


Add the translation text
In file:
/langs/en_US/trips.lang

Add: (around line 39)
PDFTheresaExpenseReports=Advanced template to generate a PDF document for Expense Reports more suitable for business expenses. <br>Shows the payment table if payments have been made. Amount paid/claimed/unpaid is only shown when unpaid.<br>Set <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">MAIN_GENERATE_NON_SALES_DOCUMENTS_WITHOUT_VAT</b>  to  <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">1</b>  in  <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">Setup > Other</b>  to hide VAT details on the generated PDF.


Activate the document model
Finally in Dolibarr, go to: Home ► Setup ► Modules ► Expense Reports

theresa-status.png
Last Edit: 4 months 2 weeks ago by aljawaid.
The administrator has disabled public write access.
The following user(s) said Thank You: ariffidaali, hORb, n15c

Theresa | Expense Report PDF Model 4 months 2 weeks ago #35491

  • n15c
  • n15c's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 2
  • Karma: 0
Hello, Thanks for your model. Unfortunately this isn't working on my system. I have Dolibarr 8.0.1 but the report has the same problem.
Maybe there is another problem?
Attachments:
The administrator has disabled public write access.

Theresa | Expense Report PDF Model 4 months 2 weeks ago #35492

  • aljawaid
  • aljawaid's Avatar
  • OFFLINE
  • Moderator
  • Learning to be open, one source at a time.
  • Posts: 726
  • Thank you received: 116
  • Karma: 13
Hello

There is no easy way to fix the line spacing from what I know as the pdf is created through "guessing" because of all the different bits that link to it to create a single document.

When I tested, I did notice that re-creating an expense report did improve one 'silly empty page' pdf but from 5 white pages i got 1 so I was happy. It may be too time consuming for you to re-create (not just generate the pdf) your expense reports.

At least you have two choices in expense report models now. Hopefully one is better system-generated than the other.
The administrator has disabled public write access.

Theresa | Expense Report PDF Model 4 months 1 week ago #35537

  • aljawaid
  • aljawaid's Avatar
  • OFFLINE
  • Moderator
  • Learning to be open, one source at a time.
  • Posts: 726
  • Thank you received: 116
  • Karma: 13
Hello, I have just experienced (even in this new model) the problem similar to yours. I think it is to do with how many lines in the expense report.

Anyway, my new problem was 36 lines of expenses created 8 pages but only 3 or 4 of the pages had REAL lines on them. In the blank pages it was one value per page - not even a full row.

So I have just been playing around to try to get this 'improved' and I think I MAY have found the solution.

Try this code and see if it works. It has worked for me and reduced my 8 silly pages to a correct 3 pages.

Replace: (line 307)
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10);

With:
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?50:10);


I still have around 5 or 6 expense reports to do so I will keep testing it on my side in this report. Please check on your side and let me know if it improves or solves the problem.
The administrator has disabled public write access.
The following user(s) said Thank You: n15c

Theresa | Expense Report PDF Model 4 months 1 week ago #35538

  • n15c
  • n15c's Avatar
  • OFFLINE
  • Newcomer
  • Posts: 2
  • Karma: 0
Hello,

Thank you for your response, i tried your lines of code but unfortunately the same thing happens.
The model looks a bit nicer because there is less space between the header and the table but the problem still exists.

I tried to play with the numbers but it will only get worse :)

By the way, i just updated to 8.0.3.
The administrator has disabled public write access.

Theresa | Expense Report PDF Model 4 months 1 week ago #35539

  • aljawaid
  • aljawaid's Avatar
  • OFFLINE
  • Moderator
  • Learning to be open, one source at a time.
  • Posts: 726
  • Thank you received: 116
  • Karma: 13
but you should have less pages now with 'less space between the header and table' ? What line number is your blank page problem starting from? mine was 31 or 32
The administrator has disabled public write access.

Theresa | Expense Report PDF Model 4 months 1 week ago #35540

  • aljawaid
  • aljawaid's Avatar
  • OFFLINE
  • Moderator
  • Learning to be open, one source at a time.
  • Posts: 726
  • Thank you received: 116
  • Karma: 13
Your image earlier shows your pdf breaks at line 12... hmmm

I just noticed, in your blurred part, you're using two lines in your description
Your pdf:
date / type
line 1
line 2

try
date / type
line 1 | line 2

Maybe it's that extra second line in the description which is the culprit. Worth a try.
The administrator has disabled public write access.

Theresa | Expense Report PDF Model 4 months 1 week ago #35554

  • aljawaid
  • aljawaid's Avatar
  • OFFLINE
  • Moderator
  • Learning to be open, one source at a time.
  • Posts: 726
  • Thank you received: 116
  • Karma: 13
So today I had one report which was enough for one page but spread across two. I solved it. Still a few more reports to do but this could be useful for the blank page problem.

I will finalise the original theresa template model once I have finished all my reports (about 4 left).

Replace: line 264
$heightforinfotot = 40;	// Height reserved to output the info and total part

With:
$heightforinfotot = 35;	// Height reserved to output the info and total part 				// old value 40
The administrator has disabled public write access.
Time to create page: 0.132 seconds