diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 4b9511ce0df..093e0fd331b 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -298,11 +298,23 @@ if ($action == 'create' && !$error) { if ($socid) $res = $soc->fetch($socid); if ($res) { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; + $cond_reglement_id = $soc->cond_reglement_supplier_id; + $mode_reglement_id = $soc->mode_reglement_supplier_id; } $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : ''; + $objectsrc = new CommandeFournisseur($db); + $listoforders = array(); + foreach ($selected as $sel) { + $result = $objectsrc->fetch($sel); + if ($result > 0) { + $listoforders[] = $objectsrc->ref; + } + + if (empty($cond_reglement_id)) $cond_reglement_id = $objectsrc->cond_reglement_id; + if (empty($mode_reglement_id)) $mode_reglement_id = $objectsrc->mode_reglement_id; + } + print '