Skip to content
Code-Schnipsel Gruppen Projekte
Commit 11a47c11 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: pcsg/kunden/froilein-adrett-template#31 - order mail attachments

Übergeordneter 4a81edd5
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -579,6 +579,30 @@
<de><![CDATA[Vorgehen bei gescheiterter Zahlung]]></de>
<en><![CDATA[Procedure for failed payment]]></en>
</locale>
<locale name="order.settings.mails.attachments">
<de><![CDATA[Automatische Mailanhänge]]></de>
<en><![CDATA[Automatic mail attachments]]></en>
</locale>
<locale name="order.settings.mails.attachments.description">
<de><![CDATA[
Die ausgewählten Seiten werden automatisch als Mailanhänge an jede Bestellmail mit versendet.
]]></de>
<en><![CDATA[
The selected pages are automatically attached to each order mail as mail attachments.
]]></en>
</locale>
<locale name="order.settings.mails.termsAndConditions">
<de><![CDATA[AGB]]></de>
<en><![CDATA[Terms and Condistions]]></en>
</locale>
<locale name="order.settings.mails.privacyPolicy">
<de><![CDATA[Datenschutz]]></de>
<en><![CDATA[Privacy Policy]]></en>
</locale>
<locale name="order.settings.mails.cancellationPolicy">
<de><![CDATA[Widerrufsrecht]]></de>
<en><![CDATA[Cancellation Policy]]></en>
</locale>
<locale name="order.settings.failedPaymentProcedure,execute">
<de><![CDATA[Bestellung ausführen]]></de>
......
......@@ -34,6 +34,21 @@
</conf>
</section>
<section name="mails">
<!-- Datenschutz -->
<conf name="privacyPolicy">
<type><![CDATA[string]]></type>
</conf>
<!-- AGB -->
<conf name="termsAndConditions">
<type><![CDATA[string]]></type>
</conf>
<!-- Cancellation policy -->
<conf name="cancellationPolicy">
<type><![CDATA[string]]></type>
</conf>
</section>
<section name="orderStatus">
<conf name="standard">
<type><![CDATA[integer]]></type>
......@@ -152,6 +167,34 @@
</input>
</settings>
<settings>
<title>
<locale group="quiqqer/order" var="order.settings.mails.attachments"/>
</title>
<text>
<locale group="quiqqer/order"
var="order.settings.mails.attachments.description"
/>
</text>
<input type="checkbox" conf="mails.termsAndConditions">
<text>
<locale group="quiqqer/order" var="order.settings.mails.termsAndConditions"/>
</text>
</input>
<input type="checkbox" conf="mails.privacyPolicy">
<text>
<locale group="quiqqer/order" var="order.settings.mails.privacyPolicy"/>
</text>
</input>
<input type="checkbox" conf="mails.cancellationPolicy">
<text>
<locale group="quiqqer/order" var="order.settings.mails.cancellationPolicy"/>
</text>
</input>
</settings>
<settings title="orderStatusSettings" name="orderStatusSettings">
<title>
<locale group="quiqqer/order" var="order.status.settings.title"/>
......
......@@ -7,6 +7,7 @@
namespace QUI\ERP\Order;
use QUI;
use QUI\Projects\Site\Utils as SiteUtils;
/**
* Class Mail
......@@ -178,6 +179,9 @@ public static function sendAdminOrderConfirmationMail(Order $Order)
])
);
self::addOrderMailAttachments($Mailer);
try {
$Engine = QUI::getTemplateManager()->getEngine();
$Order = $OrderControl->getOrder();
......@@ -249,4 +253,100 @@ public static function sendAdminOrderConfirmationMail(Order $Order)
return;
}
}
/**
* @param $Mail
*/
protected static function addOrderMailAttachments(QUI\Mail\Mailer $Mail)
{
// check if html2pdf is installed
if (QUI::getPackageManager()->isInstalled('quiqqer/htmltopdf') === false) {
return;
}
$Package = QUI::getPackage('quiqqer/order');
$Config = $Package->getConfig();
$language = QUI::getLocale()->getCurrent();
try {
$DefaultProject = QUI::getProjectManager()->getStandard();
$Project = QUI::getProject($DefaultProject->getName(), $language);
} catch (QUI\Exception $Exception) {
return;
}
$privacyPolicy = (int)$Config->getValue('mails', 'privacyPolicy');
$termsAndConditions = (int)$Config->getValue('mails', 'termsAndConditions');
$cancellationPolicy = (int)$Config->getValue('mails', 'cancellationPolicy');
if ($privacyPolicy) {
try {
$sites = $Project->getSites([
'where' => [
'type' => 'quiqqer/sitetypes:types/privacypolicy'
],
'limit' => 1
]);
if (isset($sites[0])) {
$Site = $sites[0];
$file = self::generatePdfFromSite($Site);
$Mail->addAttachment($file);
}
} catch (QUI\Exception $Exception) {
}
}
if ($termsAndConditions) {
try {
$sites = $Project->getSites([
'where' => [
'type' => 'quiqqer/sitetypes:types/generalTermsAndConditions'
],
'limit' => 1
]);
if (isset($sites[0])) {
$Site = $sites[0];
$file = self::generatePdfFromSite($Site);
$Mail->addAttachment($file);
}
} catch (QUI\Exception $Exception) {
}
}
if ($cancellationPolicy) {
try {
$sites = $Project->getSites([
'where' => [
'type' => 'quiqqer/order-cancellation-policy:types/privacypolicy'
],
'limit' => 1
]);
if (isset($sites[0])) {
$Site = $sites[0];
$file = self::generatePdfFromSite($Site);
$Mail->addAttachment($file);
}
} catch (QUI\Exception $Exception) {
}
}
}
/**
* @return string
* @throws QUI\Exception
*/
protected static function generatePdfFromSite(QUI\Projects\Site $Site)
{
$Document = new QUI\HtmlToPdf\Document();
//$Document->setHeaderHTML('<div class="header-test"><p>I am a header</p></div>');
$Document->setContentHTML($Site->getAttribute('content'));
//$Document->setFooterHTML('<div class="footer-test">I am a footer</div>');
// create PDF file
return $Document->createPDF();
}
}
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren