NEW Add getFormatedCustomerRef and getFormatedSupplierRef methods

This commit is contained in:
Laurent Destailleur 2019-01-21 15:22:35 +01:00
parent 4b3876d8e8
commit 8950720fb5
3 changed files with 45 additions and 3 deletions

View File

@ -1409,11 +1409,11 @@ else
$morehtmlref.='<div class="refidno">';
// 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.='<br>';
$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.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->thirdparty->id.'&search_name='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherContracts").'</a>)';

View File

@ -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)
*

View File

@ -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',