Tapeix Posted October 11, 2016 Share Posted October 11, 2016 (edited) 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 October 11, 2016 by Tapeix 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 11, 2016 Share Posted October 11, 2016 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. 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted October 11, 2016 Author Share Posted October 11, 2016 (edited) 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 October 11, 2016 by Tapeix 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 11, 2016 Share Posted October 11, 2016 is the date format 'Y-m-d' correct for your client date settings, e.g YYYY-MM-DD ? 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted October 11, 2016 Author Share Posted October 11, 2016 Ah, my bad. Had to replace it to: $advancedduedate = DateTime::createFromFormat('[b]d/m/Y[/b]', $duedate)->modify('+30 days')->format('[b]d/m/Y[/b]'); Thanks again, your help is much appreciated 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted October 16, 2016 Author Share Posted October 16, 2016 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) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 16, 2016 Share Posted October 16, 2016 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. 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted October 16, 2016 Author Share Posted October 16, 2016 You're my hero of today, thanks Brain! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.