Jump to content

Adding subtotal and tax to the invoicepdf.tpl


diablo666

Recommended Posts

$tblhtml .= '
    <tr height="30" bgcolor="#efefef" style="font-weight:bold;">
        <td align="right">' . Lang::trans('invoicessubtotal') . '</td>
        <td align="center">' . $subtotal . '</td>
    </tr>';
if ($taxname) {
    $tblhtml .= '
    <tr height="30" bgcolor="#efefef" style="font-weight:bold;">
        <td align="right">' . $taxrate . '% ' . $taxname . '</td>
        <td align="center">' . $tax . '</td>
    </tr>';
}

$tblhtml .= '
    <tr height="30" bgcolor="#efefef" style="font-weight:bold;">
        <td align="right">Totale Fattura</td>
        <td align="center">' . $myvariable . '</td>
    </tr>';

Hello i try to edit invoipdf.tpl, in this little pice of code, we have two already defined varible standard in whmcs $subtotal and $tax, what i want to achive is that the new variable $myvariable contains the sum of $subtotal+$tax how may i do this?

There is a variable already with this value?

The predefined variable $total is not good for me because he adds also the $tax2, and i don't want this.

Hope in some help :)

Link to comment
Share on other sites

$myvariableXXX = $item['amount'] + $tax;
$tblhtml .= '
    <tr height="30" bgcolor="#efefef" style="font-weight:bold;">
        <td align="right">Totale Fattura</td>
        <td align="center">' . $myvariableXXX . '</td>
    </tr>';

This piece of code, will not work and i don't know why.

$item['amount'] is 100.00

$tax is 22.00

but $myvariableXXX  will get value 1.22 wich has no sense...

Any one can help?

 

Link to comment
Share on other sites

the problem you have is that those variables are strings, not numbers - so I assume $tax is really "$22.00 USD" (or your equivalent currency).

if your site uses one currency, then you can easily do this in the template with existing variables;  - e.g, you could do this to get the string as a number...

$mysubtotal = $subtotal->toNumeric();

do the same for tax, add them together, format it and then you just need to get the currency - if there's only one, you can hardcode it in the output... otherwise, you'll need to get the currency details... either from exiting variables or by querying the database (you know the client and invoice IDs).

Link to comment
Share on other sites

It works like a charm :)

I've hardoced soemthing like this 

$mysubtotal = $subtotal->toNumeric();
$mytax = $tax->toNumeric();
$myvariableXXX = $mysubtotal+$mytax;

Another thing if you can help me ... when i disaply the variable i need 2 decimal end the full stop in the number: for example 48.8, how may i change it to 48,80 ?

Thank you!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated