Modifica generazione stampe email
This commit is contained in:
parent
a7f9aa35ec
commit
1be26ce7c6
|
@ -168,7 +168,7 @@ class EmailNotification extends PHPMailer implements NotificationInterface
|
||||||
$this->SmtpClose();
|
$this->SmtpClose();
|
||||||
|
|
||||||
// Pulizia file generati
|
// Pulizia file generati
|
||||||
delete($this->getTempDirectory());
|
//delete($this->getTempDirectory());
|
||||||
|
|
||||||
// Segnalazione degli errori
|
// Segnalazione degli errori
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
@ -224,13 +224,10 @@ class EmailNotification extends PHPMailer implements NotificationInterface
|
||||||
{
|
{
|
||||||
$print = Prints::get($print);
|
$print = Prints::get($print);
|
||||||
|
|
||||||
// Utilizzo di una cartella particolare per il salvataggio temporaneo degli allegati
|
$info = Prints::render($print['id'], $id_record, null, true);
|
||||||
$path = $this->getTempDirectory();
|
$name = $name ?: $info['path'];
|
||||||
|
|
||||||
$info = Prints::render($print['id'], $id_record, $path);
|
$this->AddStringAttachment($info['pdf'], $name);
|
||||||
$name = $name ?: $info['name'];
|
|
||||||
|
|
||||||
$this->addAttachment($info['path'], $name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -117,8 +117,9 @@ class Prints
|
||||||
* @param string|int $print
|
* @param string|int $print
|
||||||
* @param int $id_record
|
* @param int $id_record
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
|
* @param bool $return_string
|
||||||
*/
|
*/
|
||||||
public static function render($print, $id_record, $directory = null)
|
public static function render($print, $id_record, $directory = null, $return_string = false)
|
||||||
{
|
{
|
||||||
//ob_end_clean(); // Compatibilità con versioni vecchie delle stampe
|
//ob_end_clean(); // Compatibilità con versioni vecchie delle stampe
|
||||||
$dbo = $database = database();
|
$dbo = $database = database();
|
||||||
|
@ -158,9 +159,9 @@ class Prints
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::isOldStandard($print)) {
|
if (self::isOldStandard($print)) {
|
||||||
return self::oldLoader($infos['id'], $id_record, $directory);
|
return self::oldLoader($infos['id'], $id_record, $directory, $return_string);
|
||||||
} else {
|
} else {
|
||||||
return self::loader($infos['id'], $id_record, $directory);
|
return self::loader($infos['id'], $id_record, $directory, $return_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,10 +311,12 @@ class Prints
|
||||||
* @param string|int $id_print
|
* @param string|int $id_print
|
||||||
* @param int $id_record
|
* @param int $id_record
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @param string $format
|
* @param bool $return_string
|
||||||
*/
|
*/
|
||||||
protected static function oldLoader($id_print, $id_record, $directory = null, $format = 'A4')
|
protected static function oldLoader($id_print, $id_record, $directory = null, $return_string = false)
|
||||||
{
|
{
|
||||||
|
$format = 'A4';
|
||||||
|
|
||||||
$infos = self::get($id_print);
|
$infos = self::get($id_print);
|
||||||
$options = self::readOptions($infos['options']);
|
$options = self::readOptions($infos['options']);
|
||||||
$docroot = DOCROOT;
|
$docroot = DOCROOT;
|
||||||
|
@ -355,6 +358,7 @@ class Prints
|
||||||
include DOCROOT.'/templates/replace.php';
|
include DOCROOT.'/templates/replace.php';
|
||||||
|
|
||||||
$mode = !empty($directory) ? 'F' : 'I';
|
$mode = !empty($directory) ? 'F' : 'I';
|
||||||
|
$mode = !empty($return_string) ? 'S' : $mode;
|
||||||
|
|
||||||
$file = self::getFile($infos, $id_record, $directory, $replaces);
|
$file = self::getFile($infos, $id_record, $directory, $replaces);
|
||||||
$title = $file['name'];
|
$title = $file['name'];
|
||||||
|
@ -365,7 +369,8 @@ class Prints
|
||||||
$html2pdf->writeHTML($report);
|
$html2pdf->writeHTML($report);
|
||||||
$html2pdf->pdf->setTitle($title);
|
$html2pdf->pdf->setTitle($title);
|
||||||
|
|
||||||
$html2pdf->output($path, $mode);
|
$pdf = $html2pdf->output($path, $mode);
|
||||||
|
$file['pdf'] = $pdf;
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
@ -387,7 +392,7 @@ class Prints
|
||||||
$name = replace($name, $replaces);
|
$name = replace($name, $replaces);
|
||||||
|
|
||||||
$filename = sanitizeFilename($name);
|
$filename = sanitizeFilename($name);
|
||||||
$file = ( empty($directory) ) ? $filename : rtrim($directory, '/').'/'.$filename;
|
$file = (empty($directory)) ? $filename : rtrim($directory, '/').'/'.$filename;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
@ -401,8 +406,9 @@ class Prints
|
||||||
* @param string|int $id_print
|
* @param string|int $id_print
|
||||||
* @param int $id_record
|
* @param int $id_record
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
|
* @param bool $return_string
|
||||||
*/
|
*/
|
||||||
protected static function loader($id_print, $id_record, $directory = null)
|
protected static function loader($id_print, $id_record, $directory = null, $return_string = false)
|
||||||
{
|
{
|
||||||
$infos = self::get($id_print);
|
$infos = self::get($id_print);
|
||||||
$options = self::readOptions($infos['options']);
|
$options = self::readOptions($infos['options']);
|
||||||
|
@ -538,6 +544,7 @@ class Prints
|
||||||
include DOCROOT.'/templates/replace.php';
|
include DOCROOT.'/templates/replace.php';
|
||||||
|
|
||||||
$mode = !empty($directory) ? 'F' : 'I';
|
$mode = !empty($directory) ? 'F' : 'I';
|
||||||
|
$mode = !empty($return_string) ? 'S' : $mode;
|
||||||
|
|
||||||
$file = self::getFile($infos, $id_record, $directory, $replaces);
|
$file = self::getFile($infos, $id_record, $directory, $replaces);
|
||||||
$title = $file['name'];
|
$title = $file['name'];
|
||||||
|
@ -557,7 +564,8 @@ class Prints
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creazione effettiva del PDF
|
// Creazione effettiva del PDF
|
||||||
$mpdf->Output($path, $mode);
|
$pdf = $mpdf->Output($path, $mode);
|
||||||
|
$file['pdf'] = $pdf;
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue