forked from Wavyzz/dolibarr
Fix: Pdf merge tool must see only pdf files
This commit is contained in:
@@ -810,10 +810,8 @@ if ($resql)
|
|||||||
{
|
{
|
||||||
// Checkbox to merge
|
// Checkbox to merge
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if (! empty($formfile->numoffiles))
|
if (! empty($formfile->infofiles['extensions']['pdf']))
|
||||||
print '<input id="cb'.$objp->facid.'" class="flat checkformerge" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">';
|
print '<input id="cb'.$objp->facid.'" class="flat checkformerge" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">';
|
||||||
else
|
|
||||||
print ' ';
|
|
||||||
print '</td>' ;
|
print '</td>' ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class FormFile
|
|||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
var $numoffiles;
|
var $numoffiles;
|
||||||
|
var $infofiles; // Used to return informations by function getDocumentsLink
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -680,16 +681,17 @@ class FormFile
|
|||||||
* @param string $modulepart propal, facture, facture_fourn, ...
|
* @param string $modulepart propal, facture, facture_fourn, ...
|
||||||
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
||||||
* @param string $filedir Directory to scan
|
* @param string $filedir Directory to scan
|
||||||
* @return string Output string with HTML link of documents (might be empty string)
|
* @param string $filter Filter filenames on this regex string (Example: '\.pdf$')
|
||||||
|
* @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles
|
||||||
*/
|
*/
|
||||||
function getDocumentsLink($modulepart, $modulesubdir, $filedir)
|
function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter='')
|
||||||
{
|
{
|
||||||
if (! function_exists('dol_dir_list')) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
$out='';
|
$out='';
|
||||||
$this->numoffiles=0;
|
$this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array());
|
||||||
|
|
||||||
$file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$');
|
$file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name fo ref (but not followed by "-" to discard uploaded files)
|
||||||
|
|
||||||
// For ajax treatment
|
// For ajax treatment
|
||||||
$out.= '<div id="gen_pdf_'.$modulesubdir.'" class="linkobject hideobject">'.img_picto('', 'refresh').'</div>'."\n";
|
$out.= '<div id="gen_pdf_'.$modulesubdir.'" class="linkobject hideobject">'.img_picto('', 'refresh').'</div>'."\n";
|
||||||
@@ -699,6 +701,8 @@ class FormFile
|
|||||||
// Loop on each file found
|
// Loop on each file found
|
||||||
foreach($file_list as $file)
|
foreach($file_list as $file)
|
||||||
{
|
{
|
||||||
|
if ($filter && ! preg_match('/'.$filter.'/i', $file["name"])) continue; // Discard this. It does not match provided filter.
|
||||||
|
|
||||||
// Define relative path for download link (depends on module)
|
// Define relative path for download link (depends on module)
|
||||||
$relativepath=$file["name"]; // Cas general
|
$relativepath=$file["name"]; // Cas general
|
||||||
if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture...
|
if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture...
|
||||||
@@ -721,7 +725,11 @@ class FormFile
|
|||||||
$out.= img_mime($relativepath, $file["name"]);
|
$out.= img_mime($relativepath, $file["name"]);
|
||||||
$out.= '</a>'."\n";
|
$out.= '</a>'."\n";
|
||||||
|
|
||||||
$this->numoffiles++;
|
$this->infofiles['nboffiles']++;
|
||||||
|
$this->infofiles['files'][]=$file['fullname'];
|
||||||
|
$ext=pathinfo($file["name"], PATHINFO_EXTENSION);
|
||||||
|
if (empty($this->infofiles[$ext])) $this->infofiles['extensions'][$ext]=1;
|
||||||
|
else $this->infofiles['extensions'][$ext]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user