From 3da3d1e3ab752bceef5ce09c7b6231faa6206c2d Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Sat, 30 May 2020 00:48:43 +0200 Subject: [PATCH] add documents and document classes --- .../AbstractClasses/pdfDocuments_generic.php | 2 + .../AbstractClasses/pdfDocuments_order.php | 17 +++++++ .../Model/Documents/deliverynotePdf.php | 22 ++++++++- .../Documents/deliverynotewithoutlogoPdf.php | 45 +++++++++++++++++++ Application/Model/Documents/invoicePdf.php | 25 +++++++++++ .../Model/Documents/invoicewithoutlogoPdf.php | 45 +++++++++++++++++++ .../pdfdocuments_generic_interface.php | 13 ++++++ 7 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 Application/Model/Documents/deliverynotewithoutlogoPdf.php create mode 100644 Application/Model/Documents/invoicewithoutlogoPdf.php diff --git a/Application/Model/AbstractClasses/pdfDocuments_generic.php b/Application/Model/AbstractClasses/pdfDocuments_generic.php index 77510c7..b96e725 100644 --- a/Application/Model/AbstractClasses/pdfDocuments_generic.php +++ b/Application/Model/AbstractClasses/pdfDocuments_generic.php @@ -17,6 +17,7 @@ namespace D3\PdfDocuments\Application\Model\AbstractClasses; +use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_generic_interface as genericInterface; use OxidEsales\Eshop\Core\Registry; use Smarty; @@ -40,6 +41,7 @@ abstract class pdfDocuments_generic implements genericInterface * @param $sFilename * @param int $iSelLang * @param string $target + * @throws noBaseObjectSetException */ public function genPdf($sFilename, $iSelLang = 0, $target = 'I') { diff --git a/Application/Model/AbstractClasses/pdfDocuments_order.php b/Application/Model/AbstractClasses/pdfDocuments_order.php index f28f5be..d76ac3d 100644 --- a/Application/Model/AbstractClasses/pdfDocuments_order.php +++ b/Application/Model/AbstractClasses/pdfDocuments_order.php @@ -17,6 +17,7 @@ namespace D3\PdfDocuments\Application\Model\AbstractClasses; +use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_order_interface as orderInterface; use \OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\Payment; @@ -72,4 +73,20 @@ abstract class pdfDocuments_order extends pdfDocuments_generic implements orderI return str_replace($ordernr, $billnr, $sFilename); } + + /** + * @param $sFilename + * @param int $iSelLang + * @param string $target + * @throws noBaseObjectSetException + */ + public function genPdf($sFilename, $iSelLang = 0, $target = 'I') + { + if (false == $this->getOrder()) { + $e = oxNew(noBaseObjectSetException::class); + throw $e; + } + + parent::genPdf($sFilename, $iSelLang, $target); + } } \ No newline at end of file diff --git a/Application/Model/Documents/deliverynotePdf.php b/Application/Model/Documents/deliverynotePdf.php index ccb64a2..557027f 100644 --- a/Application/Model/Documents/deliverynotePdf.php +++ b/Application/Model/Documents/deliverynotePdf.php @@ -21,7 +21,27 @@ use D3\PdfDocuments\Application\Model\AbstractClasses\pdfDocuments_order; class deliverynotePdf extends pdfDocuments_order { - public function getTemplate(){ + /** + * @return string + */ + public function getRequestId() + { + return 'dnote'; + } + + /** + * @return string + */ + public function getTitleIdent() + { + return "ORDER_OVERVIEW_PDF_DNOTE"; + } + + /** + * @return string + */ + public function getTemplate() + { return 'd3deliverynote_pdf.tpl'; } } \ No newline at end of file diff --git a/Application/Model/Documents/deliverynotewithoutlogoPdf.php b/Application/Model/Documents/deliverynotewithoutlogoPdf.php new file mode 100644 index 0000000..3291940 --- /dev/null +++ b/Application/Model/Documents/deliverynotewithoutlogoPdf.php @@ -0,0 +1,45 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\PdfDocuments\Application\Model\Documents; + +class deliverynotewithoutlogoPdf extends deliverynotePdf +{ + /** + * @return string + */ + public function getRequestId() + { + return 'dnote_without_logo'; + } + + /** + * @return string + */ + public function getTitleIdent() + { + return "ORDER_OVERVIEW_PDF_DNOTE_WITHOUT_LOGO"; + } + + /** + * @return string + */ + public function getTemplate() + { + return 'd3deliverynote_pdf.tpl'; + } +} \ No newline at end of file diff --git a/Application/Model/Documents/invoicePdf.php b/Application/Model/Documents/invoicePdf.php index 581dcde..4b3c936 100644 --- a/Application/Model/Documents/invoicePdf.php +++ b/Application/Model/Documents/invoicePdf.php @@ -18,12 +18,37 @@ namespace D3\PdfDocuments\Application\Model\Documents; use D3\PdfDocuments\Application\Model\AbstractClasses\pdfDocuments_order; +use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_orderinvoice_interface; class invoicePdf extends pdfDocuments_order implements pdfdocuments_orderinvoice_interface { protected $blIsNewOrder = false; + /** + * @return string + */ + public function getRequestId() + { + // same like in OXID PDF module + return 'standart'; + } + + /** + * @return string + */ + public function getTitleIdent() + { + return "ORDER_OVERVIEW_PDF_STANDART"; + } + + /** + * @param $sFilename + * @param int $iSelLang + * @param string $target + * @return void + * @throws noBaseObjectSetException + */ public function genPdf( $sFilename, $iSelLang = 0, $target = 'I' ) { $this->setInvoiceNumber(); diff --git a/Application/Model/Documents/invoicewithoutlogoPdf.php b/Application/Model/Documents/invoicewithoutlogoPdf.php new file mode 100644 index 0000000..c15a049 --- /dev/null +++ b/Application/Model/Documents/invoicewithoutlogoPdf.php @@ -0,0 +1,45 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\PdfDocuments\Application\Model\Documents; + +class invoicewithoutlogoPdf extends invoicePdf +{ + /** + * @return string + */ + public function getRequestId() + { + // same like in OXID PDF module + return 'standart_without_logo'; + } + + /** + * @return string + */ + public function getTitleIdent() + { + return "ORDER_OVERVIEW_PDF_STANDART_WITHOUT_LOGO"; + } + + /** + * @return string + */ + public function getTemplate(){ + return 'd3invoice_pdf.tpl'; + } +} \ No newline at end of file diff --git a/Application/Model/Interfaces/pdfdocuments_generic_interface.php b/Application/Model/Interfaces/pdfdocuments_generic_interface.php index 924dd6b..b99c9d2 100644 --- a/Application/Model/Interfaces/pdfdocuments_generic_interface.php +++ b/Application/Model/Interfaces/pdfdocuments_generic_interface.php @@ -17,8 +17,20 @@ namespace D3\PdfDocuments\Application\Model\Interfaces; +use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException; + interface pdfdocuments_generic_interface { + /** + * @return string + */ + public function getRequestId(); + + /** + * @return string + */ + public function getTitleIdent(); + /** * @return string */ @@ -35,6 +47,7 @@ interface pdfdocuments_generic_interface * @param string $target * * @return mixed + * @throws noBaseObjectSetException */ public function genPdf($sFilename, $iSelLang = 0, $target = 'I'); } \ No newline at end of file