From 04672e1d80dd076a39227cb3ed55f2a3afffe425 Mon Sep 17 00:00:00 2001 From: Mohamed DAOUD Date: Tue, 29 Jul 2025 21:09:46 +0200 Subject: [PATCH] fix use delivery date v21 (#34831) --- 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 b5d9785da63..442b3090955 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1001,7 +1001,12 @@ if ($search_status != '') { } } if ($search_option == 'late') { - $sql .= " AND c.date_commande < '".$db->idate(dol_now() - $conf->commande->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)."'";