FIX link to check prof id was hardcoded instead of using dedicated

function
This commit is contained in:
Laurent Destailleur 2016-07-04 10:28:11 +02:00
parent fa6570d9cb
commit 23cac5b157
2 changed files with 41 additions and 19 deletions

View File

@ -823,7 +823,8 @@ else
if (! empty($conf->global->MAIN_INFO_SIREN)) if (! empty($conf->global->MAIN_INFO_SIREN))
{ {
print $conf->global->MAIN_INFO_SIREN; print $conf->global->MAIN_INFO_SIREN;
if ($mysoc->country_code == 'FR') print ' &nbsp; <a href="http://avis-situation-sirene.insee.fr/avisitu/jsp/avis.jsp" target="_blank">'.$langs->trans("Check").'</a>'; $s = $mysoc->id_prof_url(1,$mysoc);
if ($s) print ' - '.$s;
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
@ -838,6 +839,8 @@ else
if (! empty($conf->global->MAIN_INFO_SIRET)) if (! empty($conf->global->MAIN_INFO_SIRET))
{ {
print $conf->global->MAIN_INFO_SIRET; print $conf->global->MAIN_INFO_SIRET;
$s = $mysoc->id_prof_url(2,$mysoc);
if ($s) print ' - '.$s;
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
@ -852,6 +855,8 @@ else
if (! empty($conf->global->MAIN_INFO_APE)) if (! empty($conf->global->MAIN_INFO_APE))
{ {
print $conf->global->MAIN_INFO_APE; print $conf->global->MAIN_INFO_APE;
$s = $mysoc->id_prof_url(3,$mysoc);
if ($s) print ' - '.$s;
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
@ -866,6 +871,8 @@ else
if (! empty($conf->global->MAIN_INFO_RCS)) if (! empty($conf->global->MAIN_INFO_RCS))
{ {
print $conf->global->MAIN_INFO_RCS; print $conf->global->MAIN_INFO_RCS;
$s = $mysoc->id_prof_url(4,$mysoc);
if ($s) print ' - '.$s;
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
@ -880,6 +887,8 @@ else
if (! empty($conf->global->MAIN_INFO_PROFID5)) if (! empty($conf->global->MAIN_INFO_PROFID5))
{ {
print $conf->global->MAIN_INFO_PROFID5; print $conf->global->MAIN_INFO_PROFID5;
$s = $mysoc->id_prof_url(5,$mysoc);
if ($s) print ' - '.$s;
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
@ -894,6 +903,8 @@ else
if (! empty($conf->global->MAIN_INFO_PROFID6)) if (! empty($conf->global->MAIN_INFO_PROFID6))
{ {
print $conf->global->MAIN_INFO_PROFID6; print $conf->global->MAIN_INFO_PROFID6;
$s = $mysoc->id_prof_url(6,$mysoc);
if ($s) print ' - '.$s;
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }
@ -909,9 +920,9 @@ else
$s=''; $s='';
$s.=$conf->global->MAIN_INFO_TVAINTRA; $s.=$conf->global->MAIN_INFO_TVAINTRA;
$s.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$conf->global->MAIN_INFO_TVAINTRA.'">'; $s.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$conf->global->MAIN_INFO_TVAINTRA.'">';
if (empty($conf->global->MAIN_DISABLEVATCHECK)) if (empty($conf->global->MAIN_DISABLEVATCHECK) && $mysoc->isInEEC())
{ {
$s.=' &nbsp; '; $s.=' - ';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
print "\n"; print "\n";

View File

@ -2608,7 +2608,7 @@ class Societe extends CommonObject
* @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) * @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
* @param Societe $soc Objet societe * @param Societe $soc Objet societe
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
* TODO not in business class * TODO better to have this in a lib than into a business class
*/ */
function id_prof_check($idprof,$soc) function id_prof_check($idprof,$soc)
{ {
@ -2720,27 +2720,38 @@ class Societe extends CommonObject
} }
/** /**
* Renvoi url de verification d'un identifiant professionnal * Return an url to check online a professional id or empty string
* *
* @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
* @param Societe $soc Objet societe * @param Societe $thirdparty Object thirdparty
* @return string url ou chaine vide si aucune url connue * @return string Url or empty string if no URL known
* TODO not in business class * TODO better in a lib than into business class
*/ */
function id_prof_url($idprof,$soc) function id_prof_url($idprof,$thirdparty)
{ {
global $conf,$langs; global $conf,$langs,$hookmanager;
if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return '';
$url=''; $url='';
$hookmanager->initHooks(array('idprofurl'));
$parameters=array('idprof'=>$idprof, 'company'=>$thirdparty);
$reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return '';
if ($idprof == 1 && $soc->country_code == 'FR') $url='http://www.societe.com/cgi-bin/recherche?rncs='.$soc->idprof1; if ($idprof == 1 && $thirdparty->country_code == 'FR') $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/
if ($idprof == 1 && ($soc->country_code == 'GB' || $soc->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/';
if ($idprof == 1 && $soc->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$soc->idprof1; if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1;
if ($idprof == 1 && $soc->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$soc->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp';
if ($url) return '<a target="_blank" href="'.$url.'">['.$langs->trans("Check").']</a>'; if ($url) return '<a target="_blank" href="'.$url.'">'.$langs->trans("Check").'</a>';
}
else
{
return $hookmanager->resPrint;
}
return ''; return '';
} }