diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index b192f1636cd..c11d5023e27 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -60,7 +60,10 @@ if ($action == 'update') { dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity); } if (GETPOSTISSET('MAIN_PDF_MARGIN_RIGHT')) { - dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_RIGHT"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_PDF_MARGIN_TOP')) { + dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity); } if (GETPOSTISSET('MAIN_PDF_MARGIN_BOTTOM')) { dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity); diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index ce8e3e06932..f885677225e 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -147,10 +147,13 @@ class DolibarrApiAccess implements iAuthenticate if ($result <= 0) { throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')'); } + $fuser->getrights(); + + // Set the property $user to the $user of API static::$user = $fuser; - // Set the global variable $user to the $user of API + // Set also the global variable $user to the $user of API $user = $fuser; if ($fuser->socid) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e9329b34e23..dd22c804f23 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2212,13 +2212,19 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs if (!empty($object->state)) { $ret .= "\n".$object->state; } + } elseif (isset($object->country_code) && in_array($object->country_code, array('JP'))) { + // JP: In romaji, title firstname name\n address lines \n [state,] town zip \n country + // See https://www.sljfaq.org/afaq/addresses.html + $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town)); + $ret .= ($ret ? $sep : '').($object->state ? $object->state.', ' : '').$town.($object->zip ? ' ' : '').$object->zip; } elseif (isset($object->country_code) && in_array($object->country_code, array('IT'))) { - // IT: tile firstname name\n address lines \n zip (Code Departement) \n country + // IT: title firstname name\n address lines \n zip town state_code \n country $ret .= ($ret ? $sep : '').$object->zip; $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town)); $ret .= ($town ? (($object->zip ? ' ' : '').$town) : ''); $ret .= (empty($object->state_code) ? '' : (' '.$object->state_code)); - } else { // Other: title firstname name \n address lines \n zip town \n country + } else { + // Other: title firstname name \n address lines \n zip town[, state] \n country $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town)); $ret .= !empty($object->zip) ? (($ret ? $sep : '').$object->zip) : ''; $ret .= ($town ? (($object->zip ? ' ' : ($ret ? $sep : '')).$town) : ''); diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index d7855c381d4..32b6cceb2e9 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -951,6 +951,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $object->country_code='AU'; $address=dol_format_address($object); $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); + + $object->country_code='JP'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\nMyState, MyTown 99999", $address); }