From ce090d43a00b3f47b8339c608bfea3ad9fbd5121 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Oct 2019 15:01:29 +0200 Subject: [PATCH] Close #8907 --- htdocs/fourn/card.php | 13 ++++++++++--- htdocs/fourn/commande/orderstoinvoice.php | 13 +++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 7d68fa5fbb6..0697a3711ea 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -605,9 +605,16 @@ if ($object->id > 0) $sql2.= ' WHERE c.fk_soc = s.rowid'; $sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2.= ' AND s.rowid = '.$object->id; - // Show orders with status validated, shipping started and delivered (even if any order we can bill). - //$sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; - $sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/orderstoinvoice.php + // Show orders we can bill + if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) + { + $sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/orderstoinvoice.php + } + else + { + // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY + $sql2.= " AND c.fk_statut IN (".$db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; + } $sql2.= " AND c.billed = 0"; // Find order that are not already invoiced // just need to check received status because we have the billed status now diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 97a714cfabb..814ad49ecee 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -449,8 +449,17 @@ if (($action != 'create' && $action != 'add') && !$error) { $sql .= ' WHERE c.entity = ' . $conf->entity; $sql .= ' AND c.fk_soc = s.rowid'; - // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php + // Show orders we can bill + if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) + { + $sql.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php + } + else + { + // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY + $sql.= " AND c.fk_statut IN (".$db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; + } + $sql .= " AND c.billed = 0"; // Find order that are not already invoiced