tune order by to sort nearest active dv first

This commit is contained in:
Harald Bamberger
2025-04-24 15:40:58 +02:00
parent a196da03d2
commit 9410388a7a
@@ -59,7 +59,14 @@ class Dienstverhaeltnis_model extends DB_Model
}
$qry .="
ORDER BY COALESCE(dv.bis, '2999-12-31'::date) DESC, dv.von DESC
ORDER BY
CASE
WHEN (COALESCE(dv.bis, '2999-12-31'::date) - NOW()::date) < 0 THEN NULL
ELSE
(COALESCE(dv.bis, '2999-12-31'::date) - NOW()::date)
END ASC NULLS LAST,
COALESCE(dv.bis, '2999-12-31'::date) DESC,
dv.von DESC
";
return $this->execQuery($qry, $data);