diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 2f41a7df6eb..c1cd75f79cb 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2107,7 +2107,7 @@ function pdf_getTotalQty($object, $type, $outputlangs) */ function pdf_getLinkedObjects($object, $outputlangs) { - global $hookmanager; + global $db, $hookmanager; $linkedobjects = array(); @@ -2174,8 +2174,13 @@ function pdf_getLinkedObjects($object, $outputlangs) // We concat this record info into fields xxx_value. title is overwrote. if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order { - $elementobject->fetchObjectLinked(); - if (!empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); + $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); + if (! empty($elementobject->linkedObjectsIds['commande'])){ + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $order = new Commande($db); + $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); + if ($ret < 1) { $order=null; } + } } if (!is_object($order)) { diff --git a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php index 74d3356faeb..b2a79dc4751 100644 --- a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php +++ b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php @@ -242,7 +242,7 @@ class DoliStorage implements TokenStorageInterface $sql.= " WHERE service='".$this->db->escape($service)."'"; $resql = $this->db->query($sql); $result = $this->db->fetch_array($resql); - $states[$service] = $result[state]; + $states[$service] = $result['state']; $this->states[$service] = $states[$service]; return is_array($states)