Jump to content

Add 30 days extra to {$invoice_date_due}, how?


Tapeix

Recommended Posts

I want to add 30 days extra to the generated output of {$invoice_date_due}. Is there any possibility of? E.g. by creating a hook or a simple php tag that can be inserted in invoicepdf.tpl?

 

About this request: my invoices are generated 7 days in advance. The generation date = 7 days in advance, the due date = 7. My clients have 30 days after the due date to pay their invoices. I want to display the final due date on the invoice only, so I need a code to be added in invoicepdf.tpl.

 

I think it should be something like:

date("Y-m-d", strtotime(substr($ex[0], strrpos($ex[0], ")") - 10, 10)));

 

Does anyone have an idea how to convert this into a working code? Thanks!

Edited by Tapeix
Link to comment
Share on other sites

well you can't use hooks in the invoice file, but as it's already a PHP file, you could try using....

 

$advancedduedate = DateTime::createFromFormat('Y-m-d', $duedate)->modify('+30 days')->format('Y-m-d');

the first 'Y-m-d' is the current format of $duedate from the WHMCS date format settings - you'll need to get this right (e.g match the settings) for this to work... the second 'Y-m-d' is how you want the date to appear in the invoice (they don't need to be the same).

 

remember that this is only for show, e.g any email reminders etc will use the real due date and not this artificial one. :idea:

Link to comment
Share on other sites

Thanks Brian! I have added this code to invoicepdf.tpl, but it seems to be not working.

 

I receive this error:

Fatal error: Call to a member function modify() on boolean in /template/invoicepdf.tpl on line 115

 

Line 114 - 116:

# Invoice Details
$advancedduedate = DateTime::createFromFormat('Y-m-d', $duedate)->modify('+30 days')->format('Y-m-d'); 
$clientnumber = substr(sprintf('%04u', $clientsdetails["id"]),0,4);

 

Any suggestions?

Edited by Tapeix
Link to comment
Share on other sites

Just getting back to this topic. I will like to display this date in a mail template. Is it possible to convert this code to html? Thanks.

 

Edit: I assume this is possible when I use the {php} tag. I'll try it later. :)

 

- - - Updated - - -

 

Whoops, it is not that easy. :')

 

Parse error: syntax error, unexpected '$duedate' (T_VARIABLE) 

Link to comment
Share on other sites

Just getting back to this topic. I will like to display this date in a mail template. Is it possible to convert this code to html? Thanks.

Edit: I assume this is possible when I use the {php} tag. I'll try it later. :)

Whoops, it is not that easy. :')

if you think {php} in the code is the answer, you're asking the wrong question! :)

 

if you have access to {$invoice_date_due} in the email template, e.g it's an invoice created template, you should be able to do the following in Smarty...

 

{$invoice_date_due|replace:'/':'-'|cat:' +30 days'|date_format:'%d/%m/%Y'}

if you were using US dates (m/d/y), then you shouldn't need the replace, but EU dates (d/m/y) will. :roll:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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