From 6f6f67691a541fa094e7bd6e4c97efd298cb6cac Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Mon, 6 Feb 2023 16:48:54 +0100
Subject: [PATCH] Bug 32883: Correct cubside pickups ordering

They are displayed by date of creation, it's not what we want for "to be
staged" for instance, where it needs to be ordered by date/time of
scheduled pickup.

Test plan:
Create several curbside pickups, to have some in the different tabs
Confirm that the order is the one you expect.
=> to be staged ordered by pickup date/time
=> stage and ready ordered by pickup date/time
=> patron is outside ordered by arrival date/time
=> delivered today ordered by *desc* delivered date/time

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 circ/curbside_pickups.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/circ/curbside_pickups.pl b/circ/curbside_pickups.pl
index a2e06d78ca..fcdc99dbd4 100755
--- a/circ/curbside_pickups.pl
+++ b/circ/curbside_pickups.pl
@@ -159,7 +159,8 @@ $template->param(
     curbside_pickups => Koha::CurbsidePickups->search(
         {
             branchcode => $branchcode,
-        }
+        },
+        { order_by => [ { -desc => 'delivered_datetime' }, 'arrival_datetime', 'scheduled_pickup_datetime' ], }
       )->filter_by_scheduled_today,
 );
 
-- 
2.30.2