diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 491ead83b6e..844cd4321a4 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1409,11 +1409,11 @@ else $morehtmlref.='
'; // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); // Ref supplier $morehtmlref.='
'; $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherContracts").')'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 627e67a38b7..6ffe65cc996 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -457,6 +457,46 @@ abstract class CommonObject return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):''); } + /** + * Return customer ref for screen output. + * + * @param string $objref Customer ref + * @return string Customer ref formated + */ + function getFormatedCustomerRef($objref) + { + global $hookmanager; + + $parameters=array('objref'=>$objref); + $action=''; + $reshook = $hookmanager->executeHooks('getFormatedCustomerRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) + { + return $hookmanager->resArray['objref']; + } + return $objref.(isset($hookmanager->resArray['objref'])?$hookmanager->resArray['objref']:''); + } + + /** + * Return supplier ref for screen output. + * + * @param string $objref Supplier ref + * @return string Supplier ref formated + */ + function getFormatedSupplierRef($objref) + { + global $hookmanager; + + $parameters=array('objref'=>$objref); + $action=''; + $reshook = $hookmanager->executeHooks('getFormatedSupplierRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) + { + return $hookmanager->resArray['objref']; + } + return $objref.(isset($hookmanager->resArray['objref'])?$hookmanager->resArray['objref']:''); + } + /** * Return full name (civility+' '+name+' '+lastname) * diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 4b0ed682e49..98193f1e32e 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -33,7 +33,7 @@ class HookManager * @var DoliDB Database handler. */ public $db; - + /** * @var string Error code (or message) */ @@ -168,6 +168,8 @@ class HookManager 'getFormMail', 'getIdProfUrl', 'getDirList', + 'getFormatedCustomerRef', + 'getFormatedSupplierRef', 'moveUploadedFile', 'moreHtmlStatus', 'pdf_build_address',