mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 19:18:22 +01:00
Debug v20 - Fix getMultidirOutput
This commit is contained in:
@@ -513,7 +513,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
|
||||
// others mass actions
|
||||
// mass actions on lettering
|
||||
if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) {
|
||||
if ($massaction == 'letteringauto') {
|
||||
$lettering = new Lettering($db);
|
||||
@@ -1135,9 +1135,15 @@ while ($i < min($num, $limit)) {
|
||||
|
||||
// Journal code
|
||||
if (!empty($arrayfields['t.code_journal']['checked'])) {
|
||||
if (empty($conf->cache['accountingjournal'][$line->code_journal])) {
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$result = $accountingjournal->fetch('', $line->code_journal);
|
||||
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
|
||||
$accountingjournal->fetch(0, $line->code_journal);
|
||||
$conf->cache['accountingjournal'][$line->code_journal] = $accountingjournal;
|
||||
} else {
|
||||
$accountingjournal = $conf->cache['accountingjournal'][$line->code_journal];
|
||||
}
|
||||
|
||||
$journaltoshow = (($accountingjournal->id > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
|
||||
print '<td class="center tdoverflowmax150">'.$journaltoshow.'</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
@@ -1176,9 +1182,18 @@ while ($i < min($num, $limit)) {
|
||||
|
||||
$modulepart = 'invoice_supplier';
|
||||
$filename = dol_sanitizeFileName($line->doc_ref);
|
||||
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
|
||||
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
|
||||
|
||||
//$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
|
||||
//$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
|
||||
$filedir = getMultidirOutput($objectstatic, '', 1).dol_sanitizeFileName($line->doc_ref);
|
||||
$subdir = getMultidirOutput($objectstatic, '', 1, 'outputrel').dol_sanitizeFileName($line->doc_ref);
|
||||
//var_dump($filedir); var_dump($subdir);
|
||||
|
||||
if ($objectstatic->id > 0) {
|
||||
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
|
||||
} else {
|
||||
$documentlink = $line->doc_ref;
|
||||
}
|
||||
} elseif ($line->doc_type == 'expense_report') {
|
||||
$langs->loadLangs(array('trips'));
|
||||
|
||||
@@ -1201,6 +1216,7 @@ while ($i < min($num, $limit)) {
|
||||
|
||||
$labeltoshow = '';
|
||||
$labeltoshowalt = '';
|
||||
$classforlabel = '';
|
||||
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
|
||||
$labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
|
||||
$labeltoshow .= $documentlink;
|
||||
@@ -1214,9 +1230,10 @@ while ($i < min($num, $limit)) {
|
||||
} else {
|
||||
$labeltoshow .= $line->doc_ref;
|
||||
$labeltoshowalt .= $line->doc_ref;
|
||||
$classforlabel = 'tdoverflowmax250';
|
||||
}
|
||||
|
||||
print '<td class="nowraponall tdoverflowmax250" title="'.dol_escape_htmltag($labeltoshowalt).'">';
|
||||
print '<td class="nowraponall'.($classforlabel ? ' '.$classforlabel : '').'" title="'.dol_escape_htmltag($labeltoshowalt).'">';
|
||||
print $labeltoshow;
|
||||
print "</td>\n";
|
||||
if (!$i) {
|
||||
|
||||
@@ -445,8 +445,8 @@ if ($result) {
|
||||
}
|
||||
|
||||
$arrayofmassactions = array(
|
||||
'set_default_account' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount"),
|
||||
'ventil' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate")
|
||||
,'set_default_account' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount")
|
||||
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||
);
|
||||
|
||||
@@ -418,12 +418,11 @@ if ($action == 'writebookkeeping' && !$error) {
|
||||
|
||||
$companystatic = new Societe($db);
|
||||
$invoicestatic = new Facture($db);
|
||||
$accountingaccountcustomer = new AccountingAccount($db);
|
||||
|
||||
$accountingaccountcustomer = new AccountingAccount($db);
|
||||
$accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
|
||||
|
||||
$accountingaccountcustomerwarranty = new AccountingAccount($db);
|
||||
|
||||
$accountingaccountcustomerwarranty->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true);
|
||||
|
||||
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
||||
|
||||
@@ -452,8 +452,8 @@ if ($result) {
|
||||
}
|
||||
|
||||
$arrayofmassactions = array(
|
||||
'ventil' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate"),
|
||||
'set_default_account' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount")
|
||||
'set_default_account' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount"),
|
||||
'ventil' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate")
|
||||
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||
);
|
||||
|
||||
@@ -126,8 +126,8 @@ if (!function_exists('str_contains')) {
|
||||
* @param CommonObject $object Dolibarr common object
|
||||
* @param string $module Override object element, for example to use 'mycompany' instead of 'societe'
|
||||
* @param int $forobject Return the more complete path for the given object instead of for the module only.
|
||||
* @param string $mode 'output' or 'temp' or 'version'
|
||||
* @return string|null The path of the relative directory of the module
|
||||
* @param string $mode 'output' (full main dir) or 'outputrel' (relative dir) or 'temp' (for temporary files) or 'version' (dir for archived files)
|
||||
* @return string|null The path of the relative directory of the module, ending with /
|
||||
* @since Dolibarr V18
|
||||
*/
|
||||
function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'output')
|
||||
@@ -144,14 +144,21 @@ function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'outpu
|
||||
// Special case for backward compatibility
|
||||
if ($module == 'fichinter') {
|
||||
$module = 'ficheinter';
|
||||
} elseif ($module == 'invoice_supplier') {
|
||||
$module = 'supplier_invoice';
|
||||
} elseif ($module == 'order_supplier') {
|
||||
$module = 'supplier_order';
|
||||
}
|
||||
|
||||
// Get the relative path of directory
|
||||
if ($mode == 'output' || $mode == 'version') {
|
||||
if ($mode == 'output' || $mode == 'outputrel' || $mode == 'version') {
|
||||
if (isset($conf->$module) && property_exists($conf->$module, 'multidir_output')) {
|
||||
$s = '';
|
||||
if ($mode != 'outputrel') {
|
||||
$s = $conf->$module->multidir_output[(empty($object->entity) ? $conf->entity : $object->entity)];
|
||||
}
|
||||
if ($forobject && $object->id > 0) {
|
||||
$s .= '/'.get_exdir(0, 0, 0, 0, $object);
|
||||
$s .= ($mode != 'outputrel' ? '/' : '').get_exdir(0, 0, 0, 0, $object);
|
||||
}
|
||||
return $s;
|
||||
} else {
|
||||
@@ -7568,13 +7575,15 @@ function yn($yesno, $case = 1, $color = 0)
|
||||
|
||||
/**
|
||||
* Return a path to have a the directory according to object where files are stored.
|
||||
* This function is called by getMultidirOutput
|
||||
* New usage: $conf->module->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, '').'/'
|
||||
* or: $conf->module->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, '') if multidir_output not defined.
|
||||
* Example out with new usage: $object is invoice -> 'INYYMM-ABCD'
|
||||
* Example out with old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
|
||||
* or: $conf->module->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, '')
|
||||
*
|
||||
* @param string|int $num Id of object (deprecated, $object will be used in future)
|
||||
* @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future)
|
||||
* Example of output with new usage: $object is invoice -> 'INYYMM-ABCD'
|
||||
* Example of output with old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
|
||||
*
|
||||
* @param string|int $num Id of object (deprecated, $object->id will be used in future)
|
||||
* @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global setup will be used in future)
|
||||
* @param int $alpha 0=Keep number only to forge path, 1=Use alpha part after the - (By default, use 0). (deprecated, global option will be used in future)
|
||||
* @param int $withoutslash 0=With slash at end (except if '/', we return ''), 1=without slash at end
|
||||
* @param ?CommonObject $object Object to use to get ref to forge the path.
|
||||
@@ -7584,18 +7593,31 @@ function yn($yesno, $case = 1, $color = 0)
|
||||
*/
|
||||
function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = '')
|
||||
{
|
||||
if (empty($modulepart) && !empty($object->module)) {
|
||||
if (empty($modulepart) && is_object($object)) {
|
||||
if (!empty($object->module)) {
|
||||
$modulepart = $object->module;
|
||||
} elseif (!empty($object->element)) {
|
||||
$modulepart = $object->element;
|
||||
}
|
||||
}
|
||||
|
||||
$path = '';
|
||||
|
||||
$arrayforoldpath = array('cheque', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
|
||||
// Define $arrayforoldpath that is module path using a hierarchy on more than 1 level.
|
||||
$arrayforoldpath = array('cheque' => 2, 'category' => 2, 'holiday' => 2, 'supplier_invoice' => 2, 'invoice_supplier' => 2, 'mailing' => 2, 'supplier_payment' => 2);
|
||||
if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
|
||||
$arrayforoldpath[] = 'product';
|
||||
$arrayforoldpath['product'] = 2;
|
||||
}
|
||||
if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
|
||||
|
||||
if (empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
|
||||
$level = $arrayforoldpath[$modulepart];
|
||||
}
|
||||
|
||||
if (!empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
|
||||
// This part should be removed once all code is using "get_exdir" to forge path, with parameter $object and $modulepart provided.
|
||||
if (empty($num) && is_object($object)) {
|
||||
$num = $object->id;
|
||||
}
|
||||
if (empty($alpha)) {
|
||||
$num = preg_replace('/([^0-9])/i', '', $num);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user