Merge branch 'modules/rel_mod_pdfDocumentsFull' of git.d3data.de:Customers/elektroversand-schmidt.de into modules/rel_mod_pdfDocumentsFull

This commit is contained in:
MaxBUhe 2020-06-10 11:44:30 +02:00
commit b20fb0db72
3 changed files with 70 additions and 7 deletions

View File

@ -36,9 +36,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
const PDF_ORIENTATION_PORTRAIT = 'P';
const PDF_ORIENTATION_LANDSCAPE = 'L';
public $filenameExtension = 'pdf';
/** @var Smarty */
public $oSmarty;
/** @var string */
public $filename;
/**
* pdfDocumentsGeneric constructor.
*/
@ -126,6 +131,45 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
return [self::PDF_ORIENTATION_PORTRAIT, 'A4', 'de'];
}
/**
* @param $filename
*/
public function setFilename($filename)
{
$this->filename = $filename;
}
/**
* @param string $sFilename
*
* @return string
*/
public function getFilename()
{
// forced filename from setFilename()
if ($this->filename) {
return $this->addFilenameExtension($this->filename);
}
return $this->addFilenameExtension($this->getTypeForFilename());
}
/**
* @param string $filename
*
* @return string
*/
public function addFilenameExtension($filename)
{
$extension = $this->filenameExtension;
$extensionLength = (strlen($extension) + 1) * -1;
if ((bool) strlen($extension) && substr($filename, $extensionLength) != '.'.$extension) {
$filename .= '.'.$extension;
}
return $filename;
}
/**
* Gets proper file name
*

View File

@ -66,15 +66,22 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
*/
public function getFilename()
{
// forced filename from setFilename()
if ($this->filename) {
return $this->addFilenameExtension($this->filename);
}
$sTrimmedBillName = trim($this->getOrder()->getFieldData('oxbilllname'));
return implode(
'_',
[
$this->getTypeForFilename(),
$this->getOrder()->getFieldData('oxordernr'),
$sTrimmedBillName . ".pdf"
]
return $this->addFilenameExtension(
implode(
'_',
[
$this->getTypeForFilename(),
$this->getOrder()->getFieldData('oxordernr'),
$sTrimmedBillName
]
)
);
}

View File

@ -56,8 +56,20 @@ interface pdfdocumentsGenericInterface
*/
public function genPdf($sFilename, $iSelLang = 0, $target = 'I');
/**
* @param string $filename
*/
public function setFilename($filename);
/**
* @return string
*/
public function getFilename();
/**
* @param string $filename
*
* @return string
*/
public function addFilenameExtension($filename);
}