ralphonz Posted March 3, 2014 Share Posted March 3, 2014 How can I make the client area invoice history default to display in reverse order (latest invoices first)? Seems silly that they are displayed with the oldest first... 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 3, 2014 Share Posted March 3, 2014 I assume that you are using the 'Portal' template (or at least a template based on 'Portal') ? when using one of the three default templates, the invoice history ("My Invoices") will be shown in different ways - 'Portal' displays them from oldest to newest; 'Classic' shows them from newest to oldest and 'Default' allows the columns to be sorted by the client. the template code in clientareainvoices.tpl is similar in each, so the sort order of 'Classic' and 'Portal' must be coded in the WHMCS core files... however, the order can be reversed by using a bit of Smarty! the first step is to download or create a Smarty plugin called - modifier.reverse_array.php this can either be downloaded from - https://github.com/exponentcms/exponent-cms/blob/master/framework/plugins/modifier.reverse_array.php ... or just create a blank file in the Smarty plugins directory (includes/classes/Smarty/plugins/), call it modifier.reverse_array.php and add the following code to it.. <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Smarty reverse_array modifier plugin * * Type: modifier<br> * Name: reverse_array<br> * Purpose: reverse arrays * @author Noel McGran * @param array * @return array */ function smarty_modifier_reverse_array($array) { return array_reverse($array); } /* vim: set expandtab: */ ?> with the plugin in place, you can now edit the clientareainvoices.tpl template - you just need to replace... {foreach key=num item=invoice from=$invoices} with... {foreach key=num item=invoice from=$invoices|@array_reverse} that will reverse the default sort order - e.g., 'Portal' will now sort invoice numbers from newest to oldest... it also works on 'Classic' too. you may need to empty your template_c folder and/or browser cache to see the sort changes. 0 Quote Link to comment Share on other sites More sharing options...
ralphonz Posted March 4, 2014 Author Share Posted March 4, 2014 Thanks for the reply again Brian. I had tried @array_reverse but the pagination wasn't correct, i.e. page 2 still showed the newest invoices... However, thanks to your info on templates I just used the clientareainvoices.tpl from "Default" as a starting point rather than the one from "Portal". That works great and it'll be easier in the event of a major update as i don't have to add any files outside of the template folder. I should really have used "Default" rather than "Portal" as my starting point for making modifications but it's too late now... 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 4, 2014 Share Posted March 4, 2014 apologies for the pagination issue... I never checked that! 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.