From b9a91c667faa21dac469093c355aaddd80d4896b Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 27 Mar 2018 16:04:56 +0200 Subject: [PATCH 1/2] NEW : Add link between credit note invoice and origin --- htdocs/compta/facture/card.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d438c505a8d..2f49526d1cb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -916,9 +916,9 @@ if (empty($reshook)) $id = $object->create($user); + $facture_source = new Facture($db); // fetch origin object if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) { - $facture_source = new Facture($db); // fetch origin object if ($facture_source->fetch($object->fk_facture_source)>0) { $fk_parent_line = 0; @@ -969,7 +969,6 @@ if (empty($reshook)) if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) { - $facture_source = new Facture($db); // fetch origin object if not previously defined if ($facture_source->fetch($object->fk_facture_source)>0) { $totalpaye = $facture_source->getSommePaiement(); @@ -980,6 +979,20 @@ if (empty($reshook)) $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); } } + + // Add link between credit note and origin + if(! empty($object->fk_facture_source)) { + $facture_source->fetch($object->fk_facture_source); + } + $facture_source->fetchObjectLinked(); + + if(! empty($facture_source->linkedObjectsIds)) { + $linkedObjectIds = $facture_source->linkedObjectsIds; + $sourcetype = key($linkedObjectIds); + $fk_origin = current($facture_source->linkedObjectsIds[$sourcetype]); + + $object->add_object_linked($sourcetype, $fk_origin); + } } } From 1719b43909768420153df8aaa2771b3e55a1ee5d Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 4 Apr 2018 09:52:10 +0200 Subject: [PATCH 2/2] FIX : Travis --- htdocs/user/agenda_extsites.php | 2 +- htdocs/user/card.php | 2 +- htdocs/user/document.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 46ca99d3727..c39dbaafc97 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -69,7 +69,7 @@ if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','useragenda','globalcard'); +$hookmanager->initHooks(array('usercard','useragenda','globalcard')); /* * Actions diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3d63c308729..5709cb6df05 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -102,7 +102,7 @@ $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('usercard','globalcard'); +$hookmanager->initHooks(array('usercard','globalcard')); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index d77b30a4721..b8fc923acae 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -94,7 +94,7 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','userdoc','globalcard'); +$hookmanager->initHooks(array('usercard','userdoc','globalcard')); /*