6.4 Custom functions
If you need a special treatment of vtiger data in your template, you can use custom (your own) functions. There is a folder „functions“ under [vTigerROOT]/modules/PDFMaker/resources/, where you can place your own .php file with functions which would you like to use. This file will be included automatically. Inside this folder is file „its4you.php“, which contains our functions. These functions are listed in the Table 6-1 and are provided for you for free. Do not modify this file, because by next version it will be overwritten. If you would like to use your own functions, please create your own file/files, it means create new .php file under [vTigerROOT]/modules/PDFMaker/resources/functions and place here your functions. In order to insert custom function into template provide following:
- Go to EditView, and in Other information tab select custom function from selectbox „Custom functions“. You can choose one of our functions (its4you_*), or your own function.
- Click
button. It adds function in form [CUSTOMFUNCTION|functionname|param1|param2|…|CUSTOMFUNCTION].
- Finally you have to define parameters of the function as shown in the Picture 6.10.
Picture 6.10 Custom functions
In the above example function with 5 parameters was used, i.e. [CUSTOMFUNCTION|functionname|param1|param2| param3| param4|param5| CUSTOMFUNCTION]. It is possible to use functions without parameters as well. In this case use just notation [CUSTOMFUNCTION|functionname|CUSTOMFUNCTION].
Following table contains short description of our its4you_* functions which you can use in your pdf templates.
Name | Description |
---|---|
its4you_if | [CUSTOMFUNCTION|its4you_if|param1| comparator|param2|whatToReturn1|whatToReturn2|CUSTOMFUNCTION] |
This function executes if-else statement based on given parameters: param1 first parameter of comparison comparator comparison sign - one of ==,!=,<,>,<=,>= param2 second parameter of comparison whatToReturn1 value returned when comparison succeeded whatToReturn2 value returned when comparison didn’t succeed |
|
its4you_getTemplateId | [CUSTOMFUNCTION|its4you_getTemplateId|CUSTOMFUNCTION] |
This function returns id of current template. | |
its4you_getContactImage | [CUSTOMFUNCTION|its4you_getContactImage|id|width|height|CUSTOMFUNCTION] |
This function returns image of contact. id - contact id width - width of returned image (10%, 100px) height - height of returned image (10%, 100px) |
|
its4you_sum | [CUSTOMFUNCTION|its4you_sum|arg1|arg2|CUSTOMFUNCTION] |
This function returns sum of input values: arg1+arg2+…+argN. Function is inserted with two arguments by default but you can edit it and add more arguments. | |
its4you_deduct | [CUSTOMFUNCTION|its4you_deduct|arg1|arg2|CUSTOMFUNCTION] |
This function returns deducted value arg1-arg2-...-argN (all following values are deducted from the first one). Function is inserted with two arguments by default but you can edit it and add more arguments. | |
its4you_multiplication | [CUSTOMFUNCTION|its4you_multiplication|arg1|arg2|CUSTOMFUNCTION] |
This function returns multiplication of all input values: arg1*arg2*…*argN. Function is inserted with two arguments by default but you can edit it and add more arguments. | |
its4you_divide | [CUSTOMFUNCTION|its4you_divide|arg1|arg2|CUSTOMFUNCTION] |
This function returns divided value arg1/arg2/.../argN. Function is inserted with two arguments by default but you can edit it and add more arguments. | |
its4you_formatNumberToPDF | [CUSTOMFUNCTION|its4you_formatNumberToPDF|value|CUSTOMFUNCTION] |
This function returns formatted value and is used by other functions. value – int | |
its4you_formatNumberFromPDF | [CUSTOMFUNCTION|its4you_formatNumberFromPDF|value|CUSTOMFUNCTION] |
This function returns converted value into integer and is used by other functions. value - int |
Table 6-1 its4you functions