diff --git a/core/lib/Thelia/Action/Pdf.php b/core/lib/Thelia/Action/Pdf.php
index 385f948fb..52ce0b92d 100644
--- a/core/lib/Thelia/Action/Pdf.php
+++ b/core/lib/Thelia/Action/Pdf.php
@@ -38,7 +38,7 @@ class Pdf extends BaseAction implements EventSubscriberInterface
public function generatePdf(PdfEvent $event)
{
- $html2pdf = new \HTML2PDF('P', 'A4', 'fr', true, 'UTF-8', array(0,0,0,0));
+ $html2pdf = new \HTML2PDF($event->getOrientation(), $event->getFormat(), $event->getLang(), $event->getUnicode(), $event->getEncoding(), $event->getMarges());
$html2pdf->pdf->SetDisplayMode('real');
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index f83874631..6051a3783 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -155,6 +155,11 @@
\d+
+
+ Thelia\Controller\Admin\OrderController::generateDeliveryPdf
+ \d+
+
+
diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php
index ececff6e8..1df0679f0 100644
--- a/core/lib/Thelia/Controller/Admin/OrderController.php
+++ b/core/lib/Thelia/Controller/Admin/OrderController.php
@@ -198,12 +198,22 @@ class OrderController extends BaseAdminController
}
public function generateInvoicePdf($order_id)
+ {
+ return $this->generatePdf($order_id, ConfigQuery::read('pdf_invoice_file', 'invoice'));
+ }
+
+ public function generateDeliveryPdf($order_id)
+ {
+ return $this->generatePdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery'));
+ }
+
+ protected function generatePdf($order_id, $fileName)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
$html = $this->renderRaw(
- ConfigQuery::read('pdf_invoice_file', 'invoice'),
+ $fileName,
array(
'order_id' => $order_id
),
diff --git a/core/lib/Thelia/Core/Event/PdfEvent.php b/core/lib/Thelia/Core/Event/PdfEvent.php
index b65ba39a2..e0f873e04 100644
--- a/core/lib/Thelia/Core/Event/PdfEvent.php
+++ b/core/lib/Thelia/Core/Event/PdfEvent.php
@@ -35,9 +35,31 @@ class PdfEvent extends ActionEvent
protected $pdf;
- public function __construct($content)
+ protected $orientation;
+ protected $format;
+ protected $lang;
+ protected $unicode;
+ protected $encoding;
+ protected $marges;
+
+ /**
+ * @param $content html content to transform into pdf
+ * @param string $orientation page orientation, same as TCPDF
+ * @param string $format The format used for pages, same as TCPDF
+ * @param string $lang Lang : fr, en, it...
+ * @param bool $unicode TRUE means that the input text is unicode (default = true)
+ * @param string $encoding charset encoding; default is UTF-8
+ * @param array $marges Default marges (left, top, right, bottom)
+ */
+ public function __construct($content, $orientation = 'P', $format = 'A4', $lang='fr', $unicode=true, $encoding='UTF-8',array $marges = array(0, 0, 0, 0))
{
$this->content = $content;
+ $this->orientation = $orientation;
+ $this->format = $format;
+ $this->lang = $lang;
+ $this->unicode = $unicode;
+ $this->encoding = $encoding;
+ $this->marges = $marges;
}
/**
@@ -70,4 +92,102 @@ class PdfEvent extends ActionEvent
{
return null !== $this->pdf;
}
+
+ /**
+ * @param mixed $encoding
+ */
+ public function setEncoding($encoding)
+ {
+ $this->encoding = $encoding;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getEncoding()
+ {
+ return $this->encoding;
+ }
+
+ /**
+ * @param mixed $format
+ */
+ public function setFormat($format)
+ {
+ $this->format = $format;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getFormat()
+ {
+ return $this->format;
+ }
+
+ /**
+ * @param mixed $lang
+ */
+ public function setLang($lang)
+ {
+ $this->lang = $lang;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getLang()
+ {
+ return $this->lang;
+ }
+
+ /**
+ * @param mixed $marges
+ */
+ public function setMarges($marges)
+ {
+ $this->marges = $marges;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getMarges()
+ {
+ return $this->marges;
+ }
+
+ /**
+ * @param mixed $orientation
+ */
+ public function setOrientation($orientation)
+ {
+ $this->orientation = $orientation;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getOrientation()
+ {
+ return $this->orientation;
+ }
+
+ /**
+ * @param mixed $unicode
+ */
+ public function setUnicode($unicode)
+ {
+ $this->unicode = $unicode;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getUnicode()
+ {
+ return $this->unicode;
+ }
+
+
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
index 315adf37e..17d9e37a3 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
@@ -30,6 +30,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Security\SecurityContext;
use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
+use Thelia\Model\ConfigQuery;
use Thelia\Model\CategoryQuery;
use Thelia\Model\ContentQuery;
use Thelia\Model\CountryQuery;
@@ -234,6 +235,17 @@ class DataAccessFunctions extends AbstractSmartyPlugin
return $this->dataAccess("Lang", $params, $this->request->getSession()->getLang());
}
+ public function ConfigDataAccess($params, $smarty)
+ {
+ if(false === array_key_exists("key", $params)) {
+ return null;
+ }
+
+ $key = $params['key'];
+
+ return ConfigQuery::read($key);
+ }
+
/**
* @param $objectLabel
* @param $params
@@ -344,6 +356,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'),
new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'),
new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'),
+ new SmartyPluginDescriptor('function', 'config', $this, 'ConfigDataAccess'),
);
}
diff --git a/install/insert.sql b/install/insert.sql
index ec4e1b02b..d91c511dc 100755
--- a/install/insert.sql
+++ b/install/insert.sql
@@ -27,7 +27,8 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
('thelia_admin_remember_me_cookie_expiration', 2592000, 0, 0, NOW(), NOW()),
('thelia_customer_remember_me_cookie_name', 'tcrmcn', 0, 0, NOW(), NOW()),
('thelia_customer_remember_me_cookie_expiration', 31536000, 0, 0, NOW(), NOW()),
-('session_config.handlers', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler', 0, 0, NOW(), NOW())
+('session_config.handlers', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler', 0, 0, NOW(), NOW()),
+('company_name','', 0, 0, NOW(), NOW())
;
diff --git a/templates/admin/default/order-edit.html b/templates/admin/default/order-edit.html
index 59c3d9cce..f05bc2a05 100644
--- a/templates/admin/default/order-edit.html
+++ b/templates/admin/default/order-edit.html
@@ -268,7 +268,7 @@
{intl l='Delivery address'}