Topic: Sales Order Inquiry Sort Descending?

When I select Sales Order Inquiry, I would like the most recent orders on top just like the Work Order Inquiry returns newest Work Orders on top. When I watch the sql query for the Work Order Inquiry, I get an idea how it works with the "ORDER BY workorder.id DESC" portion of the statement, but after going through the included files for the Sales Order Inquiry, I cannot seem to find the correct area to sort my Sales Orders.

  Could someone point me in the right direction? Thanks in advance.

Re: Sales Order Inquiry Sort Descending?

@paul

Click on the Order Date (I think Twice) and it will be sorted by the latest date.

Re: Sales Order Inquiry Sort Descending?

@rafat

Yes, thank you. That is what I do now, but since I need it that way every time, I wanted to make it "stick" so I didn't have to click on the Order Date twice.

Re: Sales Order Inquiry Sort Descending?

@paul

You are right.. I believe it should be as you described it.. Its more user friendly.. (logical).

Re: Sales Order Inquiry Sort Descending?

@joe: can this be incorporated into the core?

Re: Sales Order Inquiry Sort Descending?

I will have a look at it later.

Joe

Re: Sales Order Inquiry Sort Descending?

This has been committed to 2.4.7 stable repo.

/Joe

Re: Sales Order Inquiry Sort Descending?

Thanks @joe.

Whilst we are on this, we might as well optimise the sql in the last function in sales/includes/db/sales_order_db.inc with:

--- sales/includes/db/sales_order_db.inc    Tue Jan 14 05:30:15 2020
+++ sales/includes/db/sales_order_db.inc    Tue Jan 14 05:42:21 2020
@@ -632,11 +632,9 @@
 {
         $sql = "SELECT $field
             FROM ".TB_PREF."sales_order_details d
-            WHERE order_no =
-            (SELECT order_no FROM ".TB_PREF."sales_orders o
+            LEFT JOIN " .TB_PREF."sales_orders o on d.order_no=o.order_no
             WHERE debtor_no=" . db_escape($order->customer_id) . "
-            ORDER BY order_no DESC LIMIT 1)
-            ORDER BY d.id DESC LIMIT 1";        
+            ORDER BY d.id DESC LIMIT 1";
 
         $last_query=db_query($sql, "Could not retrieve last order detail");
         $row = db_fetch_row($last_query);
Post's attachments

so_opt.diff 731 b, 1 downloads since 2020-01-14 

You don't have the permssions to download the attachments of this post.

Re: Sales Order Inquiry Sort Descending?

Thank you very much. I thought I would get a notice of more replies to this post, but don't remember getting one. Anyways, thank you. I will apply patch when I can. The last line to add looks like the one above it to remove. ??

Re: Sales Order Inquiry Sort Descending?

@paul: highlighting the the two similar lines will expose trailing spaces in the one to be removed.