Merge pull request #24164 from frederic34/multidiroutput

use a fonction to get multidir output
This commit is contained in:
Laurent Destailleur 2023-03-18 10:56:25 +01:00 committed by GitHub
commit 66eb668965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 9 deletions

View File

@ -2991,7 +2991,7 @@ if ($action == 'create' && $usercancreate) {
// Presend form
$modelmail = 'order_send';
$defaulttopic = 'SendOrderRef';
$diroutput = $conf->commande->multidir_output[$object->entity];
$diroutput = getMultidirOutput($object);
$trackid = 'ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';

View File

@ -3978,6 +3978,7 @@ class Commande extends CommonOrder
$this->id = 0;
$this->ref = 'SPECIMEN';
$this->specimen = 1;
$this->entity = $conf->entity;
$this->socid = 1;
$this->date = time();
$this->date_lim_reglement = $this->date + 3600 * 24 * 30;

View File

@ -71,6 +71,27 @@ if (!function_exists('utf8_decode')) {
}
}
/**
* Return the full path of the directory where a module (or an object of a module) stores its files. Path may depends on the entity if a multicompany module is enabled.
*
* @param CommonObject $object Dolibarr common object
* @param string $module Override object element, for example to use 'mycompany' instead of 'societe'
* @return string|void The path of the relative directory of the module
* @since Dolibarr V18
*/
function getMultidirOutput($object, $module = '')
{
global $conf;
if (!is_object($object)) {
return null;
}
if (empty($module) && !empty($object->element)) {
$module = $object->element;
} else {
return null;
}
return $conf->$module->multidir_output[$object->entity];
}
/**
* Return dolibarr global constant string value

View File

@ -296,18 +296,18 @@ class pdf_eratosthene extends ModelePDFCommandes
if ($conf->commande->multidir_output[$conf->entity]) {
if (getMultidirOutput($object)) {
$object->fetch_thirdparty();
$deja_regle = 0;
// Definition of $dir and $file
if ($object->specimen) {
$dir = $conf->commande->multidir_output[$conf->entity];
$dir = getMultidirOutput($object);
$file = $dir."/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->commande->multidir_output[$object->entity]."/".$objectref;
$dir = getMultidirOutput($object)."/".$objectref;
$file = $dir."/".$objectref.".pdf";
}
@ -1447,7 +1447,7 @@ class pdf_eratosthene extends ModelePDFCommandes
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
{
// phpcs:enable
global $conf, $langs, $hookmanager;
global $conf, $langs, $hookmanager, $mysoc;
$ltrdirection = 'L';
if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R';
@ -1473,8 +1473,8 @@ class pdf_eratosthene extends ModelePDFCommandes
if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
if (!empty(getMultidirOutput($mysoc, 'mycompany'))) {
$logodir = getMultidirOutput($mysoc, 'mycompany');
}
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;

View File

@ -4358,7 +4358,9 @@ class Societe extends CommonObject
global $langs;
$this->id = 0;
$this->entity = $conf->entity;
$this->name = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
$this->nom = $this->name; // deprecated
$this->address = getDolGlobalString('MAIN_INFO_SOCIETE_ADDRESS');
$this->zip = getDolGlobalString('MAIN_INFO_SOCIETE_ZIP');
$this->town = getDolGlobalString('MAIN_INFO_SOCIETE_TOWN');
@ -4368,8 +4370,6 @@ class Societe extends CommonObject
$this->note_private = getDolGlobalString('MAIN_INFO_SOCIETE_NOTE');
$this->nom = $this->name; // deprecated
// We define country_id, country_code and country
$country_id = $country_code = $country_label = '';
if (!empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {