2
0
forked from Wavyzz/dolibarr

Fix: Id prof are not lost

This commit is contained in:
Laurent Destailleur
2008-05-13 23:55:08 +00:00
parent de42c0db22
commit 5453283be7
2 changed files with 48 additions and 60 deletions

View File

@@ -488,61 +488,48 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
if ($soc->pays_code == 'FR')
{
$maxlength1=9;
$maxlength2=14;
$maxlength3=5;
$maxlength4=12;
}
// Id prof
print '<tr><td>'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').'</td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print '<input type="text" name="idprof1" size="15" maxlength="'.$maxlength1.'" value="'.$soc->siren.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td>';
print '<td>'.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').'</td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print '<input type="text" name="idprof2" size="15" maxlength="'.$maxlength2.'" value="'.$soc->siret.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
print '<tr><td>'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').'</td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print '<input type="text" name="idprof3" size="15" maxlength="'.$maxlength3.'" value="'.$soc->ape.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td>';
print '<td>'.($langs->transcountry("ProfId4",$soc->pays_code) != '-'?$langs->transcountry('ProfId4',$soc->pays_code):'').'</td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId4",$soc->pays_code) != '-') print '<input type="text" name="idprof4" size="15" maxlength="'.$maxlength4.'" value="'.$soc->idprof4.'">';
else print '&nbsp;';
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
print '<tr>';
// IdProf1 (SIREN pour France)
$idprof=$langs->transcountry('ProfId1',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(1,'idprof1',$soc->siren);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
// IdProf2 (SIRET pour France)
$idprof=$langs->transcountry('ProfId2',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(2,'idprof2',$soc->siret);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
print '</tr>';
print '<tr>';
// IdProf3 (APE pour France)
$idprof=$langs->transcountry('ProfId3',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(3,'idprof3',$soc->ape);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
// IdProf4 (NU pour France)
$idprof=$langs->transcountry('ProfId4',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$soc->show_input_id_prof(4,'idprof4',$soc->idprof4);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
print '</tr>';
// Forme juridique
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td>';
print '<td colspan="3">';

View File

@@ -1835,8 +1835,9 @@ class Societe extends CommonObject
* \brief Retourne le formulaire de saisie d'un identifiant professionnel (siren, siret, etc...)
* \param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
* \param htmlname Nom de la zone input
* \param preselected Default value to show
*/
function show_input_id_prof($idprof,$htmlname)
function show_input_id_prof($idprof,$htmlname,$preselected)
{
global $langs;
@@ -1848,11 +1849,11 @@ class Societe extends CommonObject
if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier
if ($idprof==4) $formlength=12;
}
$selected='';
if ($idprof==1) $selected=$soc->siren;
if ($idprof==2) $selected=$soc->siret;
if ($idprof==3) $selected=$soc->ape;
if ($idprof==4) $selected=$soc->idprof4;
$selected=$preselected;
if (! $selected && $idprof==1) $selected=$this->siren;
if (! $selected && $idprof==2) $selected=$this->siret;
if (! $selected && $idprof==3) $selected=$this->ape;
if (! $selected && $idprof==4) $selected=$this->idprof4;
print '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">';
}