New Member
Posts: 15
Registered: ‎09-07-2017
Kudos: 1
Solutions: 1

PHP or javascript in invoice template

Is it possibel to use php or javascript in the invoice template ? 

 

I need to generate a 15 digit number on the invoice

 

The first 14 numbers is just the client id with 0s infront 

The last number is a control number calculate from the first 14 numbers. 

 

Exaple: 

Client id: 143

 

Calcuæation:

14 digit:         0 0 0 0 0 0 0 0 0 0 0 1 4 3

Multiplyers:  1 2 1 2 1 2 1 2 1 2 1 2 1 2

Sum:              0 0 0 0 0 0 0 0 0 0 0 2 4 6    =  12

Modulo sum: 12/10 = rest = 2  (if this number is 0 control number = 0

Control number: 10-2 = 8

 

15 digit to generate: 000000000001438

 

 

 

Ubiquiti Employee
Posts: 4,155
Registered: ‎12-10-2015
Kudos: 1471
Solutions: 315

Re: PHP or javascript in invoice template

Hi,
the javascript is not allowed but you may try the standard twig operators and filters to modify and print custom values, check out the twig doc https://twig.symfony.com/doc/2.x/

Another option could be to place an image into the template while the source of the image would be URL to your custom script/plugin generating the image content showing the number you want.
Highlighted
New Member
Posts: 15
Registered: ‎09-07-2017
Kudos: 1
Solutions: 1

Re: PHP or javascript in invoice template

@UBNT-Petr non of the useful operators and filters are allowed. so for this kinda job twigs out.
went with making a plugin to make the calculation on the client id and then patch it to the clients userIdent insted.
but thanks for the response