2020-05-26 15:59:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2020-07-04 23:25:24 +02:00
|
|
|
* See LICENSE file for license details.
|
2020-05-26 15:59:10 +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 15:59:10 +02:00
|
|
|
*/
|
|
|
|
|
2020-05-28 13:32:34 +02:00
|
|
|
namespace D3\PdfDocuments\Application\Model\Documents;
|
2020-05-26 15:59:10 +02:00
|
|
|
|
2023-09-19 23:32:55 +02:00
|
|
|
use Assert\InvalidArgumentException;
|
2020-05-30 01:17:27 +02:00
|
|
|
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder;
|
|
|
|
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderinvoiceInterface;
|
2020-05-26 16:12:17 +02:00
|
|
|
|
2020-05-30 01:17:27 +02:00
|
|
|
class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceInterface
|
2020-05-26 15:59:10 +02:00
|
|
|
{
|
2020-05-26 16:32:22 +02:00
|
|
|
protected $blIsNewOrder = false;
|
|
|
|
|
2020-05-30 00:48:43 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getRequestId()
|
|
|
|
{
|
2020-07-03 21:59:18 +02:00
|
|
|
return 'invoice';
|
2020-05-30 00:48:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTitleIdent()
|
|
|
|
{
|
2020-07-03 20:04:21 +02:00
|
|
|
return "D3_PDFDOCUMENTS_INVOICE";
|
2020-05-30 00:48:43 +02:00
|
|
|
}
|
|
|
|
|
2020-06-04 10:31:38 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTypeForFilename()
|
|
|
|
{
|
|
|
|
return 'invoice';
|
|
|
|
}
|
|
|
|
|
2023-09-19 23:32:55 +02:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws InvalidArgumentException
|
|
|
|
*/
|
2020-08-13 14:50:48 +02:00
|
|
|
public function runPreAction()
|
2020-05-27 09:46:44 +02:00
|
|
|
{
|
2020-08-13 14:50:48 +02:00
|
|
|
parent::runPreAction();
|
|
|
|
|
2020-05-27 09:46:44 +02:00
|
|
|
$this->setInvoiceNumber();
|
|
|
|
$this->setInvoiceDate();
|
|
|
|
$this->saveOrderOnChanges();
|
|
|
|
}
|
|
|
|
|
2023-09-19 23:32:55 +02:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws InvalidArgumentException
|
|
|
|
*/
|
2020-05-26 16:32:22 +02:00
|
|
|
public function setInvoiceNumber()
|
|
|
|
{
|
|
|
|
if (!$this->getOrder()->getFieldData('oxbillnr')) {
|
|
|
|
$this->getOrder()->assign(['oxbillnr' => $this->getOrder()->getNextBillNum()]);
|
|
|
|
|
|
|
|
$this->blIsNewOrder = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-19 23:32:55 +02:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws InvalidArgumentException
|
|
|
|
*/
|
2020-05-26 16:32:22 +02:00
|
|
|
public function setInvoiceDate()
|
|
|
|
{
|
|
|
|
if ($this->getOrder()->getFieldData('oxbilldate') == '0000-00-00') {
|
2020-06-04 11:04:17 +02:00
|
|
|
$this->getOrder()->assign([
|
|
|
|
"oxbilldate" => date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')))
|
|
|
|
]);
|
2020-05-26 16:32:22 +02:00
|
|
|
|
|
|
|
$this->blIsNewOrder = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-19 23:32:55 +02:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws InvalidArgumentException
|
|
|
|
*/
|
2020-05-26 16:32:22 +02:00
|
|
|
public function saveOrderOnChanges()
|
|
|
|
{
|
|
|
|
if ($this->blIsNewOrder) {
|
|
|
|
$this->getOrder()->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-26 16:12:17 +02:00
|
|
|
public function getTemplate(){
|
2020-05-28 14:31:35 +02:00
|
|
|
return 'd3invoice_pdf.tpl';
|
2020-05-26 16:12:17 +02:00
|
|
|
}
|
2020-06-04 10:31:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
2023-09-19 23:32:55 +02:00
|
|
|
* @throws InvalidArgumentException
|
2020-06-04 10:31:38 +02:00
|
|
|
*/
|
|
|
|
public function getFilename()
|
|
|
|
{
|
|
|
|
$filename = parent::getFilename();
|
|
|
|
|
2020-06-17 09:05:49 +02:00
|
|
|
$filename = str_replace(
|
2020-06-04 10:31:38 +02:00
|
|
|
$this->getOrder()->getFieldData('oxordernr'),
|
|
|
|
$this->getOrder()->getFieldData('oxbillnr'),
|
|
|
|
$filename
|
|
|
|
);
|
2020-06-17 09:05:49 +02:00
|
|
|
|
|
|
|
return $this->makeValidFileName($filename);
|
2020-06-04 10:31:38 +02:00
|
|
|
}
|
2020-05-26 15:59:10 +02:00
|
|
|
}
|