Add a hook in dol_print_phone

To allow more controls in this print function as in dol_print_address (there is a hook so we can create links to maps...).
Eg : create a other click to dial functions (different from dolibarr ones with more parameters, because each provider give differents api ) etc
Hope this one will be accepted and usefull for the community.

And happy new year :)
This commit is contained in:
dolibarr95
2018-01-02 11:24:28 +01:00
committed by GitHub
parent 24a59a7731
commit 12e414509c

View File

@@ -2172,7 +2172,7 @@ function dol_print_skype($skype,$cid=0,$socid=0,$addlink=0,$max=64)
*/
function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$separ=" ",$withpicto='',$titlealt='',$adddivfloat=0)
{
global $conf,$user,$langs,$mysoc;
global $conf, $user, $langs, $mysoc, $hookmanager;
// Clean phone parameter
$phone = preg_replace("/[\s.-]/","",trim($phone));
@@ -2262,23 +2262,33 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep
$titlealt=($withpicto=='fax'?$langs->trans("Fax"):$langs->trans("Phone"));
}
$rep='';
$picto = '';
if($withpicto){
if($withpicto=='fax'){
$picto = 'phoning_fax';
}elseif($withpicto=='phone'){
$picto = 'phoning';
}elseif($withpicto=='mobile'){
$picto = 'phoning_mobile';
}else{
$picto = '';
if ($hookmanager) {
$parameters = array('countrycode' => $countrycode, 'cid' => $cid, 'socid' => $socid);
$reshook = $hookmanager->executeHooks('printPhone', $parameters, $phone);
$rep.=$hookmanager->resPrint;
}
if (empty($reshook))
{
$picto = '';
if($withpicto){
if($withpicto=='fax'){
$picto = 'phoning_fax';
}elseif($withpicto=='phone'){
$picto = 'phoning';
}elseif($withpicto=='mobile'){
$picto = 'phoning_mobile';
}else{
$picto = '';
}
}
}
if ($adddivfloat) $rep.='<div class="nospan float" style="margin-right: 10px">';
else $rep.='<span style="margin-right: 10px;">';
$rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone;
if ($adddivfloat) $rep.='</div>';
else $rep.='</span>';
if ($adddivfloat) $rep.='<div class="nospan float" style="margin-right: 10px">';
else $rep.='<span style="margin-right: 10px;">';
$rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone;
if ($adddivfloat) $rep.='</div>';
else $rep.='</span>';
}
return $rep;
}