Skip to content

Commit

Permalink
FIX #13182
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 26, 2020
1 parent 8b1fff2 commit 9bc5eb4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
5 changes: 2 additions & 3 deletions htdocs/compta/tva/document.php
Expand Up @@ -70,8 +70,7 @@
$object = new Tva($db);
if ($id > 0) $object->fetch($id);

$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart='tax';
$upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref);


/*
Expand Down Expand Up @@ -144,7 +143,7 @@

dol_fiche_end();

$modulepart = 'tax';
$modulepart = 'tax-vat';
$permission = $user->rights->tax->charges->creer;
$permtoedit = $user->rights->fournisseur->facture->creer;
$param = '&id=' . $object->id;
Expand Down
4 changes: 3 additions & 1 deletion htdocs/core/class/html.formfile.class.php
Expand Up @@ -1099,7 +1099,7 @@ public function list_of_documents($filearray, $object, $modulepart, $param = '',
if ($disablecrop == -1)
{
$disablecrop = 1;
if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'mrp', 'project', 'product', 'produit', 'propal', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0;
if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'mrp', 'project', 'product', 'produit', 'propal', 'service', 'societe', 'tax', 'tax-vat', 'ticket', 'user'))) $disablecrop = 0;
}

// Define relative path used to store the file
Expand All @@ -1121,6 +1121,8 @@ public function list_of_documents($filearray, $object, $modulepart, $param = '',
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
}
// For example here $upload_dir = '/pathtodocuments/commande/SO2001-123/'
// For example here $upload_dir = '/pathtodocuments/tax/vat/1'

$hookmanager->initHooks(array('formfile'));
$parameters = array(
Expand Down
5 changes: 3 additions & 2 deletions htdocs/core/lib/files.lib.php
Expand Up @@ -2401,10 +2401,11 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file;
}
// Wrapping for taxes
elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output))
elseif (in_array($modulepart, array('tax', 'tax-vat')) && !empty($conf->tax->dir_output))
{
if ($fuser->rights->tax->charges->{$lire}) $accessallowed=1;
$original_file=$conf->tax->dir_output.'/'.$original_file;
$modulepartsuffix = str_replace('tax-', '', $modulepart);
$original_file=$conf->tax->dir_output.'/'.($modulepartsuffix != 'tax' ? $modulepartsuffix.'/' : '').$original_file;
}
// Wrapping for events
elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output))
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/vat.lib.php
Expand Up @@ -49,7 +49,7 @@ function vat_prepare_head($object)

require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref);
$upload_dir = $conf->tax->dir_output . "/vat/" . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id);
$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id;
Expand Down
2 changes: 2 additions & 0 deletions htdocs/core/tpl/document_actions_post_headers.tpl.php
Expand Up @@ -72,6 +72,7 @@

$formfile=new FormFile($db);


// We define var to enable the feature to add prefix of uploaded files.
// Caller of this include can make
// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__';
Expand All @@ -93,6 +94,7 @@
'project_task',
'expensereport',
'tax',
'tax-vat',
'produit',
'product_batch',
'bom',
Expand Down

0 comments on commit 9bc5eb4

Please sign in to comment.