kimai / DemoBundle

Kimai Demo bundle for developers, who want to create a plugin and extend the time-tracking experience
MIT License
16 stars 11 forks source link

Extending export controler / adding calculated values to pdf.twig export template #3

Open apiening opened 3 years ago

apiening commented 3 years ago

I have created a copy of an already existing PDF template and saved it unter var/export/myexport.pdf.twig. I modified it to my needs and this worked pretty well.

Now I want to add custom rounding to the duration field where some math is implied. Since I was not able to achieve this just with twig filters, I would like to add an extra field like duration_rounded and do the calculation of this value in PHP.

What would be the best / update safe way to implement this? Is it possible to register to a hook or extend the controller?

kevinpapst commented 3 years ago

I think using your own plugin with a simple Twig filter should be sufficient.

apiening commented 3 years ago

Thank you. I was able to do the rounding in my template with a few set var = <calculation> steps in between.

I'm still wondering, if I would like to add a custom twig filter, would this be possible to be done update proof like it is possible with Invoice templates placed under /var/export/ so that they don't get overwritten?

kevinpapst commented 3 years ago

Plugins will never be overwritten during updates. A plugin is more complex to setup though, but thats what this repository is made for.