From 3fdc9de178ccffc1b4fbc756faf6f38f1b10eed7 Mon Sep 17 00:00:00 2001 From: Mohamed DAOUD Date: Tue, 29 Jul 2025 21:08:24 +0200 Subject: [PATCH] fix use delivery date (#34830) --- htdocs/commande/list.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index ea5762a61ba..f38dc6d33d0 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1057,7 +1057,12 @@ if ($search_status != '') { } } if ($search_option == 'late') { - $sql .= " AND c.date_commande < '".$db->idate(dol_now() - $conf->order->client->warning_delay)."'"; + // Use delivery date if set and not disabled, otherwise use order date. + if (!getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE')) { + $sql .= " AND ((c.date_livraison IS NOT NULL AND c.date_livraison < '".$db->idate(dol_now() - $conf->order->client->warning_delay)."') OR (c.date_livraison IS NULL AND c.date_commande < '".$db->idate(dol_now() - $conf->order->client->warning_delay)."'))"; + } else { + $sql .= " AND c.date_commande < '".$db->idate(dol_now() - $conf->order->client->warning_delay)."'"; + } } if ($search_datecloture_start) { $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'";