Jump to content

Client Area Invoice History Display Order


ralphonz

Recommended Posts

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.

Link to comment
Share on other sites

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...

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