Show state in address for us and india
This commit is contained in:
parent
6296c2ab22
commit
ad8440d276
@ -1226,7 +1226,7 @@ if ($rowid && $action != 'edit')
|
|||||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'</td></tr>';
|
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'</td></tr>';
|
||||||
|
|
||||||
// Country
|
// Country
|
||||||
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.getCountryLabel($adh->pays_id).'</td></tr>';
|
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.getCountry($adh->pays_id).'</td></tr>';
|
||||||
|
|
||||||
// Department
|
// Department
|
||||||
print '<tr><td>'.$langs->trans('State').'</td><td class="valeur">'.$adh->departement.'</td>';
|
print '<tr><td>'.$langs->trans('State').'</td><td class="valeur">'.$adh->departement.'</td>';
|
||||||
|
|||||||
@ -270,7 +270,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
|
|||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td>';
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td>';
|
||||||
$pays_code=getCountryLabel($conf->global->MAIN_INFO_SOCIETE_PAYS,2);
|
$pays_code=getCountry($conf->global->MAIN_INFO_SOCIETE_PAYS,2);
|
||||||
$formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT,$pays_code,'departement_id');
|
$formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT,$pays_code,'departement_id');
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
|
|
||||||
@ -601,7 +601,7 @@ else
|
|||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCountry").'</td><td>';
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCountry").'</td><td>';
|
||||||
print getCountryLabel($conf->global->MAIN_INFO_SOCIETE_PAYS,1);
|
print getCountry($conf->global->MAIN_INFO_SOCIETE_PAYS,1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
@ -180,19 +180,19 @@ function societe_prepare_head2($objsoc)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne le nom traduit ou code+nom d'un pays depuis id
|
* \brief Return country translated from an id
|
||||||
* \param id id of country
|
* \param id id of country
|
||||||
* \param withcode 0=Return label, 1=Return code + label, 2=Return code
|
* \param withcode 0=Return label, 1=Return code + label, 2=Return code
|
||||||
* \return string String with country code or translated country name
|
* \return string String with country code or translated country name
|
||||||
*/
|
*/
|
||||||
function getCountryLabel($id,$withcode=0)
|
function getCountry($id,$withcode=0)
|
||||||
{
|
{
|
||||||
global $db,$langs;
|
global $db,$langs;
|
||||||
|
|
||||||
$sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays";
|
$sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays";
|
||||||
$sql.= " WHERE rowid=".$id;
|
$sql.= " WHERE rowid=".$id;
|
||||||
|
|
||||||
dol_syslog("Company.lib::getCountryLabel sql=".$sql);
|
dol_syslog("Company.lib::getCountry sql=".$sql);
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -208,8 +208,41 @@ function getCountryLabel($id,$withcode=0)
|
|||||||
{
|
{
|
||||||
return $langs->trans("NotDefined");
|
return $langs->trans("NotDefined");
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
|
||||||
}
|
}
|
||||||
|
else dol_print_error($db,'');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return state translated from an id
|
||||||
|
* \param id id of state (province/departement)
|
||||||
|
* \param withcode 0=Return label, 1=Return code + label, 2=Return code
|
||||||
|
* \return string String with state code or translated state name
|
||||||
|
*/
|
||||||
|
function getState($id,$withcode=0)
|
||||||
|
{
|
||||||
|
global $db,$langs;
|
||||||
|
|
||||||
|
$sql = "SELECT rowid, code_departement as code, nom as label FROM ".MAIN_DB_PREFIX."c_departements";
|
||||||
|
$sql.= " WHERE rowid=".$id;
|
||||||
|
|
||||||
|
dol_syslog("Company.lib::getState sql=".$sql);
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
$label=$obj->label;
|
||||||
|
if ($withcode == 1) return $label=$obj->code?"$obj->code":"$obj->code - $label";
|
||||||
|
else if ($withcode == 2) return $label=$obj->code;
|
||||||
|
else return $label;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $langs->trans("NotDefined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else dol_print_error($db,'');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -49,6 +49,11 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
|
|||||||
{
|
{
|
||||||
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($sourcecompany->address);
|
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($sourcecompany->address);
|
||||||
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($sourcecompany->cp).' '.$outputlangs->convToOutputCharset($sourcecompany->ville);
|
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($sourcecompany->cp).' '.$outputlangs->convToOutputCharset($sourcecompany->ville);
|
||||||
|
if (($sourcecompany->departement_id || $sourcecompany->departement) && in_array($sourcecompany->pays_code,array('US','IN')))
|
||||||
|
{
|
||||||
|
if ($sourcecompany->departement_id && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->departement_id);
|
||||||
|
$stringaddress.=" - ".$outputlangs->convToOutputCharset($sourcecompany->departement);
|
||||||
|
}
|
||||||
$stringaddress .= "\n";
|
$stringaddress .= "\n";
|
||||||
// Tel
|
// Tel
|
||||||
if ($sourcecompany->tel) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$outputlangs->convToOutputCharset($sourcecompany->tel);
|
if ($sourcecompany->tel) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$outputlangs->convToOutputCharset($sourcecompany->tel);
|
||||||
@ -68,8 +73,9 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
|
|||||||
// Recipient properties
|
// Recipient properties
|
||||||
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcontact->address);
|
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcontact->address);
|
||||||
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcontact->cp) . " " . $outputlangs->convToOutputCharset($targetcontact->ville);
|
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcontact->cp) . " " . $outputlangs->convToOutputCharset($targetcontact->ville);
|
||||||
if ($targetcompany->departement && in_array($targetcompany->pays_code,array('US','IN')))
|
if (($targetcompany->departement_id || $targetcompany->departement) && in_array($targetcompany->pays_code,array('US','IN')))
|
||||||
{
|
{
|
||||||
|
if ($targetcompany->departement_id && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->departement_id);
|
||||||
$stringaddress.=" - ".$outputlangs->convToOutputCharset($targetcompany->departement);
|
$stringaddress.=" - ".$outputlangs->convToOutputCharset($targetcompany->departement);
|
||||||
}
|
}
|
||||||
$stringaddress.="\n";
|
$stringaddress.="\n";
|
||||||
@ -80,8 +86,9 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
|
|||||||
// Recipient properties
|
// Recipient properties
|
||||||
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcompany->address);
|
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcompany->address);
|
||||||
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcompany->cp) . " " . $outputlangs->convToOutputCharset($targetcompany->ville);
|
$stringaddress.="\n".$outputlangs->convToOutputCharset($targetcompany->cp) . " " . $outputlangs->convToOutputCharset($targetcompany->ville);
|
||||||
if ($targetcompany->departement && in_array($targetcompany->pays_code,array('US','IN')))
|
if (($targetcompany->departement_id || $targetcompany->departement) && in_array($targetcompany->pays_code,array('US','IN')))
|
||||||
{
|
{
|
||||||
|
if ($targetcompany->departement_id && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->departement_id);
|
||||||
$stringaddress.=" - ".$outputlangs->convToOutputCharset($targetcompany->departement);
|
$stringaddress.=" - ".$outputlangs->convToOutputCharset($targetcompany->departement);
|
||||||
}
|
}
|
||||||
$stringaddress.="\n";
|
$stringaddress.="\n";
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class Multicompany
|
|||||||
|
|
||||||
if (preg_match('/^MAIN_INFO_SOCIETE_PAYS$/i',$obj->name))
|
if (preg_match('/^MAIN_INFO_SOCIETE_PAYS$/i',$obj->name))
|
||||||
{
|
{
|
||||||
$entityDetails[$obj->name] = getCountryLabel($obj->value);
|
$entityDetails[$obj->name] = getCountry($obj->value);
|
||||||
}
|
}
|
||||||
else if (preg_match('/^MAIN_MONNAIE$/i',$obj->name))
|
else if (preg_match('/^MAIN_MONNAIE$/i',$obj->name))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user