1 (edited by cristiart 03/26/2013 04:20:20 am)

Topic: Sales Orders view DESC mode

is there a way to view all sales order in DESC mode/order by default?
i'm trying to figure this out to see if I can use FA for my company. We have hundreds of orders/invoices per month and it's very hard to keep track with invoices + overdue invoices if they are on the back of the list.

I can hack the php code to do this if i can get some pointers since i'm new here smile
thanks

Re: Sales Orders view DESC mode

Then just look into the sales_orders_view.php code. You have sortable 'Required by' column here.
Janusz

Re: Sales Orders view DESC mode

Try line 268 in sales/inquiry/sales_orders_view.php :

        _("Required By") =>array('type'=>'date', 'ord'=>''),

to be:

        _("Required By") =>array('type'=>'date', 'ord'=>'desc'),

Re: Sales Orders view DESC mode

That did not worked but i change line 270 in to this

        _("Order #") => array('fun'=>'view_link', 'ord'=>'asc'),

This will allow me to short by asc/desc but not by default. Once you navigate back from page, and come back you'll have to press "order#" again to rearrange the order...

Re: Sales Orders view DESC mode

Then the following should sort by descending order by default:

_("Order #") => array('fun'=>'view_link', 'ord'=>'desc'),

Re: Sales Orders view DESC mode

i thought so to, but it will not for some reason...

7 (edited by apmuthu 03/27/2013 03:57:55 am)

Re: Sales Orders view DESC mode

Lines 127 to 138 of includes/db_pager.inc:

    //    Change sort column direction 
    //    in order asc->desc->none->asc
    //
    function sort_table($col) 
    {
        $ord = $this->columns[$col]['ord'];
        $ord = ($ord == '') ? 'asc' : (($ord == 'asc') ? 'desc' : '');
        $this->columns[$col]['ord'] = $ord;
        $this->set_page(1);
        $this->query();
        return true;
    }

This clearly shows a $ord check for empty being retained as empty becoming ASC, a check for asc being set to DESC  but if desc, no enforcement is done unless invoked by a click to be ASC. Hence Line 133:

        $ord = ($ord == '') ? 'asc' : (($ord == 'asc') ? 'desc' : '');

should possibly be explicit in all it's redundant splendour  (default being to capture any invalid declaration degrading gracefully) like:

        switch ($ord) {
            case 'asc':
                $ord = 'desc';
                break;
            case 'desc':
            case '':
                $ord = 'asc';
                break;
            default:
                $ord = 'asc';
        }

Hence a setting of 'asc' in the code would result in a default display of DESC in this case as in the earlier one as well. This code fragment does not change any logic and is unnecessary and is placed for an understanding of how activation occurs on clicking only.

If there is a check for an initial value placed in the php page we should use that value to be the default when the $ord is empty thru' clicking route - thereafter, the clicked value of $ord will be available as asc or desc.

Lines 50-62 of includes/ui/db_pager_view.php:

    foreach($pager->columns as $num_col=>$col) {
        // record status control column is displayed only when control checkbox is on
        if (isset($col['head']) && ($col['type']!='inactive' || get_post('show_inactive'))) {
            if (!isset($col['ord']))
                $headers[] = $col['head'];
            else {
                  $icon = (($col['ord'] == 'desc') ? 'sort_desc.gif' : 
                    ($col['ord'] == 'asc' ? 'sort_asc.gif' : 'sort_none.gif'));
                $headers[] = navi_button($pager->name.'_sort_'.$num_col, 
                    $col['head'], true, $icon);
            }
         }
    }

sets the sort image on the header correctly and checks used here can be used in the earlier code fragment to synch a similar behaviour.

8 (edited by cristiart 07/26/2013 12:35:43 am)

Re: Sales Orders view DESC mode

The simple solution is this
_("Order Date") => array('name'=>'ord_date', 'type'=>'date', 'ord'=>'desc'),