document can save to disc
This commit is contained in:
parent
c1ce7ac95c
commit
d194491675
@ -31,6 +31,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
const PDF_DESTINATION_DOWNLOAD = 'D'; // force download in browser
|
const PDF_DESTINATION_DOWNLOAD = 'D'; // force download in browser
|
||||||
const PDF_DESTINATION_STDOUT = 'I'; // show in browser plugin if available, otherwise download
|
const PDF_DESTINATION_STDOUT = 'I'; // show in browser plugin if available, otherwise download
|
||||||
const PDF_DESTINATION_FILE = 'F'; // save as local file
|
const PDF_DESTINATION_FILE = 'F'; // save as local file
|
||||||
|
const PDF_DESTINATION_FILEANDSTDOUT = 'FI'; // output as local file and show in browser plugin
|
||||||
|
const PDF_DESTINATION_FILEANDDOWNLOAD = 'FD'; // output as local file and force download in browser
|
||||||
const PDF_DESTINATION_STRING = 'S'; // output as string
|
const PDF_DESTINATION_STRING = 'S'; // output as string
|
||||||
|
|
||||||
const PDF_ORIENTATION_PORTRAIT = 'P';
|
const PDF_ORIENTATION_PORTRAIT = 'P';
|
||||||
@ -59,11 +61,12 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
* @param $sFilename
|
* @param $sFilename
|
||||||
* @param int $iSelLang
|
* @param int $iSelLang
|
||||||
* @param string $target
|
* @param string $target
|
||||||
|
*
|
||||||
|
* @return mixed|string
|
||||||
* @throws Html2PdfException
|
* @throws Html2PdfException
|
||||||
*/
|
*/
|
||||||
public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT)
|
public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT)
|
||||||
{
|
{
|
||||||
$sFilename = $this->getFilename();
|
|
||||||
$oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
|
$oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
|
||||||
$oPdf->writeHTML($this->getHTMLContent($iSelLang));
|
$oPdf->writeHTML($this->getHTMLContent($iSelLang));
|
||||||
return $oPdf->output($sFilename, $target);
|
return $oPdf->output($sFilename, $target);
|
||||||
@ -84,6 +87,27 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
* @param int $iLanguage
|
||||||
|
*
|
||||||
|
* @throws Html2PdfException
|
||||||
|
*/
|
||||||
|
public function savePdfFile($path, $iLanguage = 0)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$sFilename = $this->getFilename();
|
||||||
|
$this->genPdf(
|
||||||
|
rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$sFilename,
|
||||||
|
$iLanguage,
|
||||||
|
self::PDF_DESTINATION_FILE
|
||||||
|
);
|
||||||
|
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||||
|
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||||
|
Registry::getLogger()->error($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $iLanguage
|
* @param int $iLanguage
|
||||||
*
|
*
|
||||||
@ -94,15 +118,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$sFilename = $this->getFilename();
|
$sFilename = $this->getFilename();
|
||||||
ob_start();
|
return $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING );
|
||||||
//$this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STDOUT );
|
|
||||||
$this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING );
|
|
||||||
return ob_get_contents();
|
|
||||||
} catch (pdfGeneratorExceptionAbstract $e) {
|
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||||
Registry::getLogger()->error($e);
|
Registry::getLogger()->error($e);
|
||||||
} catch (\Exception $e) {
|
|
||||||
dumpvar($e->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -22,6 +22,7 @@ use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface as o
|
|||||||
use \OxidEsales\Eshop\Application\Model\Order;
|
use \OxidEsales\Eshop\Application\Model\Order;
|
||||||
use OxidEsales\Eshop\Application\Model\Payment;
|
use OxidEsales\Eshop\Application\Model\Payment;
|
||||||
use OxidEsales\Eshop\Application\Model\User;
|
use OxidEsales\Eshop\Application\Model\User;
|
||||||
|
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||||
|
|
||||||
abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface
|
abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface
|
||||||
{
|
{
|
||||||
@ -89,6 +90,9 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
|
|||||||
* @param $sFilename
|
* @param $sFilename
|
||||||
* @param int $iSelLang
|
* @param int $iSelLang
|
||||||
* @param string $target
|
* @param string $target
|
||||||
|
*
|
||||||
|
* @return mixed|string|void
|
||||||
|
* @throws Html2PdfException
|
||||||
* @throws noBaseObjectSetException
|
* @throws noBaseObjectSetException
|
||||||
*/
|
*/
|
||||||
public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
|
public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
|
||||||
@ -98,6 +102,6 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::genPdf($sFilename, $iSelLang, $target);
|
return parent::genPdf($sFilename, $iSelLang, $target);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,6 +35,14 @@ class deliverynotewithoutlogoPdf extends deliverynotePdf
|
|||||||
return "ORDER_OVERVIEW_PDF_DNOTE_WITHOUT_LOGO";
|
return "ORDER_OVERVIEW_PDF_DNOTE_WITHOUT_LOGO";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTypeForFilename()
|
||||||
|
{
|
||||||
|
return 'delnote-nl';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +20,7 @@ namespace D3\PdfDocuments\Application\Model\Documents;
|
|||||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder;
|
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder;
|
||||||
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
|
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
|
||||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderinvoiceInterface;
|
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderinvoiceInterface;
|
||||||
|
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||||
|
|
||||||
class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceInterface
|
class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceInterface
|
||||||
{
|
{
|
||||||
@ -54,7 +55,9 @@ class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceIn
|
|||||||
* @param $sFilename
|
* @param $sFilename
|
||||||
* @param int $iSelLang
|
* @param int $iSelLang
|
||||||
* @param string $target
|
* @param string $target
|
||||||
* @return void
|
*
|
||||||
|
* @return mixed|string|void
|
||||||
|
* @throws Html2PdfException
|
||||||
* @throws noBaseObjectSetException
|
* @throws noBaseObjectSetException
|
||||||
*/
|
*/
|
||||||
public function genPdf( $sFilename, $iSelLang = 0, $target = 'I' )
|
public function genPdf( $sFilename, $iSelLang = 0, $target = 'I' )
|
||||||
@ -63,7 +66,7 @@ class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceIn
|
|||||||
$this->setInvoiceDate();
|
$this->setInvoiceDate();
|
||||||
$this->saveOrderOnChanges();
|
$this->saveOrderOnChanges();
|
||||||
|
|
||||||
parent::genPdf( $sFilename, $iSelLang, $target );
|
return parent::genPdf( $sFilename, $iSelLang, $target );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setInvoiceNumber()
|
public function setInvoiceNumber()
|
||||||
|
@ -36,6 +36,14 @@ class invoicewithoutlogoPdf extends invoicePdf
|
|||||||
return "ORDER_OVERVIEW_PDF_STANDART_WITHOUT_LOGO";
|
return "ORDER_OVERVIEW_PDF_STANDART_WITHOUT_LOGO";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTypeForFilename()
|
||||||
|
{
|
||||||
|
return 'invoice-nl';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +53,12 @@ interface pdfdocumentsGenericInterface
|
|||||||
*/
|
*/
|
||||||
public function getPdfContent($iLanguage = 0);
|
public function getPdfContent($iLanguage = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
* @param int $iLanguage
|
||||||
|
*/
|
||||||
|
public function savePdfFile($path, $iLanguage = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $sFilename
|
* @param $sFilename
|
||||||
* @param int $iSelLang
|
* @param int $iSelLang
|
||||||
|
Loading…
x
Reference in New Issue
Block a user