diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php
index accdcda43d0..a74f86a79fb 100644
--- a/htdocs/adherents/subscription/card.php
+++ b/htdocs/adherents/subscription/card.php
@@ -403,9 +403,19 @@ if ($rowid && $action != 'edit') {
$somethingshown = $formfile->numoffiles;
*/
// Show links to link elements
- //$tmparray = $form->showLinkToObjectBlock($object, null, array('subscription'), 1);
- $somethingshown = $form->showLinkedObjectBlock($object, '');
+ $object->fetchObjectLinked();
+ print '';
+ $tmparray = $form->showLinkToObjectBlock($object, array(), array('societe'), 1);
+ $linktoelem = $tmparray['linktoelem'];
+ $htmltoenteralink = $tmparray['htmltoenteralink'];
+ print $htmltoenteralink;
+
+ $compatibleImportElementsList = array();
+ $id = $object->fk_adherent;
+ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be 'include', not 'include_once'
+ // without that include PHP Warning: Undefined variable $id in /var/www/html/core/actions_dellink.inc.php on line 47
+ $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
print '
';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index f0064afe003..dc882a185d9 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4373,6 +4373,7 @@ abstract class CommonObject
{
// phpcs:enable
global $user, $hookmanager, $action;
+ dol_syslog(__METHOD__, LOG_DEBUG);
if (empty($this->origin_type) && !empty($this->origin)) {
$this->origin_type = $this->origin;
@@ -4646,6 +4647,7 @@ abstract class CommonObject
$sql .= " ORDER BY ".$orderby;
dol_syslog(get_class($this)."::fetchObjectLink", LOG_DEBUG);
+
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -4739,6 +4741,7 @@ abstract class CommonObject
$updatesource = false;
$updatetarget = false;
$f_user = isset($f_user) ? $f_user : $user;
+ dol_syslog(__METHOD__, LOG_DEBUG);
if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) {
$updatesource = true;
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 45f8d778b19..a33bafe2407 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -10284,6 +10284,8 @@ class Form
global $action;
global $db, $user; // Will be used into tpl
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
$object->fetchObjectLinked();
// Bypass the default method
@@ -10458,6 +10460,8 @@ class Form
global $conf, $langs, $hookmanager, $form;
global $action;
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
if (empty($form)) {
$form = new Form($this->db);
}
@@ -10467,23 +10471,34 @@ class Form
$listofidcompanytoscan = '';
if (!is_object($object->thirdparty)) {
- $object->fetch_thirdparty();
+ if ($object->element == 'subscription' && isset($object->fk_adherent)) {
+ $subby = new Subscription($object->db);
+ $subby->fetch($object->id);
+ $adh = new Adherent($object->db);
+ //$fk_adherent = $object->fk_adherent;
+ // creating new subscription object only to fetch the adherent which obviously exists given the if statement above are Inefficient, but else phan complains
+ $fk_adherent = $subby->fk_adherent;
+ $adh->fetch($fk_adherent);
+ $thirdparty_id = $adh->fetch_thirdparty();
+ }
+ } else {
+ $thirdparty_id = $object->thirdparty->id;
}
$possiblelinks = array();
$dontIncludeCompletedItems = getDolGlobalString('DONT_INCLUDE_COMPLETED_ELEMENTS_LINKS');
- if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
- $listofidcompanytoscan = (int) $object->thirdparty->id;
- if (($object->thirdparty->parent > 0) && getDolGlobalString('THIRDPARTY_INCLUDE_PARENT_IN_LINKTO')) {
+ if (!empty($thirdparty_id) && $thirdparty_id > 0) {
+ $listofidcompanytoscan = (int) $thirdparty_id;
+ if (is_object($object->thirdparty) && ($object->thirdparty->parent > 0) && getDolGlobalString('THIRDPARTY_INCLUDE_PARENT_IN_LINKTO')) {
$listofidcompanytoscan .= ',' . (int) $object->thirdparty->parent;
}
if (($object->fk_project > 0) && getDolGlobalString('THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO')) {
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$tmpproject = new Project($this->db);
$tmpproject->fetch((int) $object->fk_project);
- if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) {
+ if ($tmpproject->socid > 0 && ($tmpproject->socid != $thirdparty_id)) {
$listofidcompanytoscan .= ',' . (int) $tmpproject->socid;
}
unset($tmpproject);