diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index f40da966786..e280fcb49e0 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -363,6 +363,7 @@ if (empty($reshook)) { $nbOrders = is_array($orders) ? count($orders) : 1; + $currentIndex = 0; foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) { @@ -373,6 +374,7 @@ if (empty($reshook)) { $objecttmp = new Facture($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we reuse it. + $currentIndex++; $objecttmp = $TFactThird[$cmd->socid]; } else { // If we want one invoice per order or if there is no first invoice yet for this thirdparty. @@ -389,6 +391,10 @@ if (empty($reshook)) { $objecttmp->ref_client = $cmd->ref_client; } + if (empty($objecttmp->note_public)) { + $objecttmp->note_public = $langs->transnoentities("Orders"); + } + $datefacture = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); if (empty($datefacture)) { $datefacture = dol_now(); @@ -553,6 +559,11 @@ if (empty($reshook)) { } } + if ($currentIndex <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) { + $objecttmp->note_public = dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_client) ? '' : ' ('.$cmd->ref_client.')')); + $objecttmp->update($user); + } + //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 8bab1e1bd0e..4096253a94d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2500,13 +2500,7 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("RefOrder").' :'); - foreach ($objects as $elementobject) { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).(empty($elementobject->ref_client) ? '' : ' ('.$elementobject->ref_client.')').(empty($elementobject->ref_supplier) ? '' : ' ('.$elementobject->ref_supplier.')').' '); - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '.dol_print_date($elementobject->date, 'day', '', $outputlangs)); - } - } elseif (count($objects) == 1) { + if (count($objects) == 1) { $elementobject = array_shift($objects); $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).(!empty($elementobject->ref_client) ? ' ('.$elementobject->ref_client.')' : '').(!empty($elementobject->ref_supplier) ? ' ('.$elementobject->ref_supplier.')' : ''); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 14c017d6521..75f01e33eb7 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -384,7 +384,7 @@ if (empty($reshook)) { $db->begin(); $default_ref_supplier = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); - + $currentIndex = 0; foreach ($orders as $id_order) { $cmd = new CommandeFournisseur($db); if ($cmd->fetch($id_order) <= 0) { @@ -393,6 +393,7 @@ if (empty($reshook)) { $objecttmp = new FactureFournisseur($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { + $currentIndex++; $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created supplier invoice. } else { // Search if the VAT reverse-charge is activated by default in supplier card to resume the information @@ -429,6 +430,10 @@ if (empty($reshook)) { } if ($objecttmp->id > 0) { + if (empty($objecttmp->note_public)) { + $objecttmp->note_public = $langs->transnoentities("Orders"); + } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql .= "fk_source"; $sql .= ", sourcetype"; @@ -549,6 +554,11 @@ if (empty($reshook)) { } } + if ($currentIndex <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) { + $objecttmp->note_public = dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_supplier) ? '' : ' ('.$cmd->ref_supplier.')')); + $objecttmp->update($user); + } + $cmd->classifyBilled($user); // TODO Move this in workflow like done for sales orders if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {