From d462facf6d8a71d541a6d5826543ff30ffc6fae5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Nov 2014 14:44:49 +0100 Subject: [PATCH] Fixed: [ bug #1653 ] Can't access task notes --- htdocs/core/class/commonobject.class.php | 12 ++++++++---- htdocs/projet/card.php | 2 +- htdocs/projet/tasks/note.php | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 98bee3e052c..87ee2f1a1d2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -601,18 +601,22 @@ abstract class CommonObject /** * Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty * - * @return int <0 if KO, >0 if OK + * @param int $force_thirdparty_id Force thirdparty id + * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty() + function fetch_thirdparty($force_thirdparty_id=0) { global $conf; - if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty)) return 0; + if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) return 0; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $idtofetch=isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty); + if ($force_thirdparty_id) $idtofetch=$force_thirdparty_id; + $thirdparty = new Societe($this->db); - $result=$thirdparty->fetch(isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty)); + $result=$thirdparty->fetch($idtofetch); $this->client = $thirdparty; // deprecated $this->thirdparty = $thirdparty; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index df67d9d8fa1..f60d56cb633 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -260,7 +260,7 @@ if (empty($reshook)) { $db->commit(); - if (GETPOST('socid','int') > 0) $object->thirdparty->fetch(GETPOST('socid','int')); + if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int')); else unset($object->thirdparty); } } diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 04e92c7c7f2..30e6c3fe291 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -51,7 +51,7 @@ if ($id > 0 || ! empty($ref)) if ($object->fetch($id,$ref) > 0) { $projectstatic->fetch($object->fk_project); - if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid); + if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = dol_clone($projectstatic); } @@ -134,7 +134,7 @@ if ($object->id > 0) // Company print ''.$langs->trans("ThirdParty").''; - if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1); + if (! empty($projectstatic->thirdparty->id)) print $projectstatic->thirdparty->getNomUrl(1); else print ' '; print ''; print ''; @@ -196,7 +196,7 @@ if ($object->id > 0) // Third party print ''.$langs->trans("ThirdParty").''; - if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1); + if ($projectstatic->thirdparty->id > 0) print $projectstatic->thirdparty->getNomUrl(1); else print' '; print ''; }