mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 19:40:44 +01:00
Fix esportazione file in bulk con stesso nome generato
This commit is contained in:
parent
8da180c8c5
commit
3c134f00d8
@ -53,7 +53,7 @@ switch (post('op')) {
|
|||||||
foreach ($fatture as $r) {
|
foreach ($fatture as $r) {
|
||||||
$print = Prints::getModulePredefinedPrint($id_module);
|
$print = Prints::getModulePredefinedPrint($id_module);
|
||||||
|
|
||||||
Prints::render($print['id'], $r['id'], $dir.'tmp/');
|
Prints::render($print['id'], $r['id'], $dir.'tmp/', false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creazione zip
|
// Creazione zip
|
||||||
|
@ -56,7 +56,7 @@ switch (post('op')) {
|
|||||||
foreach ($interventi as $r) {
|
foreach ($interventi as $r) {
|
||||||
$print = Prints::getModulePredefinedPrint($id_module);
|
$print = Prints::getModulePredefinedPrint($id_module);
|
||||||
|
|
||||||
Prints::render($print['id'], $r['id'], $dir.'tmp/');
|
Prints::render($print['id'], $r['id'], $dir.'tmp/', false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dir = slashes($dir);
|
$dir = slashes($dir);
|
||||||
|
@ -139,7 +139,7 @@ class Prints
|
|||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @param bool $return_string
|
* @param bool $return_string
|
||||||
*/
|
*/
|
||||||
public static function render($print, $id_record, $directory = null, $return_string = false)
|
public static function render($print, $id_record, $directory = null, $return_string = false, $overwrite = true)
|
||||||
{
|
{
|
||||||
//ob_end_clean(); // Compatibilità con versioni vecchie delle stampe
|
//ob_end_clean(); // Compatibilità con versioni vecchie delle stampe
|
||||||
$dbo = $database = database();
|
$dbo = $database = database();
|
||||||
@ -186,9 +186,9 @@ class Prints
|
|||||||
if (self::isCompletelyCustom($print)) {
|
if (self::isCompletelyCustom($print)) {
|
||||||
return self::customLoader($infos['id'], $id_record, $directory, $return_string);
|
return self::customLoader($infos['id'], $id_record, $directory, $return_string);
|
||||||
} elseif (self::isOldStandard($print)) {
|
} elseif (self::isOldStandard($print)) {
|
||||||
return self::oldLoader($infos['id'], $id_record, $directory, $return_string);
|
return self::oldLoader($infos['id'], $id_record, $directory, $return_string, $overwrite);
|
||||||
} else {
|
} else {
|
||||||
return self::loader($infos['id'], $id_record, $directory, $return_string);
|
return self::loader($infos['id'], $id_record, $directory, $return_string, $overwrite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ class Prints
|
|||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @param bool $return_string
|
* @param bool $return_string
|
||||||
*/
|
*/
|
||||||
protected static function oldLoader($id_print, $id_record, $directory = null, $return_string = false)
|
protected static function oldLoader($id_print, $id_record, $directory = null, $return_string = false, $overwrite = true)
|
||||||
{
|
{
|
||||||
$format = 'A4';
|
$format = 'A4';
|
||||||
|
|
||||||
@ -415,6 +415,20 @@ class Prints
|
|||||||
$html2pdf->writeHTML($report);
|
$html2pdf->writeHTML($report);
|
||||||
$html2pdf->pdf->setTitle($title);
|
$html2pdf->pdf->setTitle($title);
|
||||||
|
|
||||||
|
// Ridenominazione file se l'impostazione è disattivata
|
||||||
|
if (!$overwrite) {
|
||||||
|
$index = 1;
|
||||||
|
|
||||||
|
$file_parts = pathinfo($path);
|
||||||
|
$filename_no_extension = $file_parts['filename'];
|
||||||
|
|
||||||
|
while (file_exists($directory.'/'.$file_parts['basename'])) {
|
||||||
|
$path = $file_parts['dirname'].'/'.$filename_no_extension.'_'.$index++.'.'.$file_parts['extension'];
|
||||||
|
|
||||||
|
$file_parts = pathinfo($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pdf = $html2pdf->output($path, $mode);
|
$pdf = $html2pdf->output($path, $mode);
|
||||||
$file['pdf'] = $pdf;
|
$file['pdf'] = $pdf;
|
||||||
}else{
|
}else{
|
||||||
@ -458,7 +472,7 @@ class Prints
|
|||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @param bool $return_string
|
* @param bool $return_string
|
||||||
*/
|
*/
|
||||||
protected static function loader($id_print, $id_record, $directory = null, $return_string = false)
|
protected static function loader($id_print, $id_record, $directory = null, $return_string = false, $overwrite = true)
|
||||||
{
|
{
|
||||||
$infos = self::get($id_print);
|
$infos = self::get($id_print);
|
||||||
$options = self::readOptions($infos['options']);
|
$options = self::readOptions($infos['options']);
|
||||||
@ -650,6 +664,20 @@ class Prints
|
|||||||
$title = $file['name'];
|
$title = $file['name'];
|
||||||
$path = $file['path'];
|
$path = $file['path'];
|
||||||
|
|
||||||
|
// Ridenominazione file se l'impostazione è disattivata
|
||||||
|
if (!$overwrite) {
|
||||||
|
$index = 1;
|
||||||
|
|
||||||
|
$file_parts = pathinfo($path);
|
||||||
|
$filename_no_extension = $file_parts['filename'];
|
||||||
|
|
||||||
|
while (file_exists($directory.'/'.$file_parts['basename'])) {
|
||||||
|
$path = $file_parts['dirname'].'/'.$filename_no_extension.'_'.$index++.'.'.$file_parts['extension'];
|
||||||
|
|
||||||
|
$file_parts = pathinfo($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Impostazione del titolo del PDF
|
// Impostazione del titolo del PDF
|
||||||
$mpdf->SetTitle($title);
|
$mpdf->SetTitle($title);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user