pdfdokumente/Application/Model/AbstractClasses/pdfdocumentsOrder.php

128 lines
3.2 KiB
PHP
Raw Normal View History

2020-05-26 16:32:22 +02:00
<?php
/**
2020-07-04 23:25:24 +02:00
* See LICENSE file for license details.
2020-05-26 16:32:22 +02:00
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
2020-07-04 23:25:24 +02:00
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
* @link http://www.oxidmodule.com
2020-05-26 16:32:22 +02:00
*/
namespace D3\PdfDocuments\Application\Model\AbstractClasses;
2020-05-30 00:48:43 +02:00
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
2020-05-30 01:17:27 +02:00
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface as orderInterface;
2020-05-26 16:32:22 +02:00
use \OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Application\Model\Payment;
use OxidEsales\Eshop\Application\Model\User;
2020-07-02 01:21:14 +02:00
use OxidEsales\Eshop\Core\Registry;
2020-05-26 16:32:22 +02:00
2020-05-30 01:17:27 +02:00
abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface
2020-05-26 16:32:22 +02:00
{
/** @var Order */
public $oOrder;
/**
* @param Order $order
*/
public function setOrder(Order $order)
{
$this->oOrder = $order;
}
/**
* @return Order
*/
public function getOrder()
{
return $this->oOrder;
}
2020-07-02 01:21:14 +02:00
/**
* @param int $iSelLang
*/
public function setSmartyVars($iSelLang)
{
2020-07-02 01:21:14 +02:00
parent::setSmartyVars($iSelLang);
$this->oSmarty->assign('order', $this->getOrder());
$oUser = oxNew(User::Class);
$oUser->load($this->getOrder()->getFieldData('oxuserid'));
$this->oSmarty->assign('user', $oUser);
$oPayment = oxNew(Payment::class);
2020-07-02 01:21:14 +02:00
$oPayment->loadInLang($iSelLang, $this->getOrder()->getFieldData('oxpaymenttype'));
$this->oSmarty->assign('payment', $oPayment);
}
/**
* @return string
*/
public function getFilename()
{
2020-06-05 09:37:11 +02:00
// forced filename from setFilename()
if ($this->filename) {
return $this->makeValidFileName(
$this->addFilenameExtension(
2020-06-17 09:05:49 +02:00
$this->filename
)
);
2020-06-05 09:37:11 +02:00
}
$sTrimmedBillName = trim($this->getOrder()->getFieldData('oxbilllname'));
return $this->makeValidFileName(
$this->addFilenameExtension(
2020-06-17 09:05:49 +02:00
implode(
'_',
[
$this->getTypeForFilename(),
$this->getOrder()->getFieldData('oxordernr'),
$sTrimmedBillName
]
)
2020-06-05 10:06:58 +02:00
)
);
}
2020-05-30 00:48:43 +02:00
/**
2020-07-03 20:04:21 +02:00
* @param $sFilename
* @param int $iSelLang
2020-05-30 00:48:43 +02:00
* @param string $target
2020-07-03 20:04:21 +02:00
* @return mixed|string|null
2020-05-30 00:48:43 +02:00
*/
public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
{
if (false == $this->getOrder()) {
2020-07-03 20:04:21 +02:00
throw oxNew(noBaseObjectSetException::class);
2020-05-30 00:48:43 +02:00
}
2020-06-09 14:56:14 +02:00
return parent::genPdf($sFilename, $iSelLang, $target);
2020-05-30 00:48:43 +02:00
}
2020-07-02 01:21:14 +02:00
/**
* @return int
*/
public function getPaymentTerm()
{
if (null === $iPaymentTerm = Registry::getConfig()->getConfigParam('iPaymentTerm')) {
$iPaymentTerm = 7;
}
return $iPaymentTerm;
}
/**
* @return false|string
*/
public function getPayableUntilDate()
{
return strtotime(
'+' . $this->getPaymentTerm() . ' day',
strtotime(
$this->getOrder()->getFieldData('oxbilldate')
)
);
}
2020-05-26 16:32:22 +02:00
}