Added replacement variables to Preordernotifcation
This commit is contained in:
@@ -229,6 +229,27 @@
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var menu_vars = [
|
||||
['vorname', "Vorname"],
|
||||
['nachname', "Nachname"],
|
||||
['firma', "Firma"],
|
||||
['firma_oder_name', "Firma oder Name"],
|
||||
['email', "Emailadresse"],
|
||||
['anschluss_oaid', "Anschluss OAID"],
|
||||
['anschluss_strasse', "Anschluss Straße"],
|
||||
['anschluss_hausnummer', "Anschluss Hausnummer"],
|
||||
['anschluss_plz', "Anschluss PLZ"],
|
||||
['anschluss_ort', "Anschluss Ort"],
|
||||
['anschluss_gemeinde', "Anschluss Gemeinde"],
|
||||
['preorder_code', "Bestellcode"],
|
||||
];
|
||||
|
||||
var menu_vars_items = "";
|
||||
menu_vars.forEach((item) => { menu_vars_items += " " + item[0]});
|
||||
menu_vars_items = menu_vars_items.trim();
|
||||
console.log(menu_vars_items);
|
||||
|
||||
$(function () {
|
||||
tinymce.init({
|
||||
//font_formats: "Arial=arial,sans-serif;",
|
||||
@@ -240,9 +261,55 @@
|
||||
paste_as_text: true,
|
||||
paste_data_images: false,
|
||||
promotion: false,
|
||||
toolbar: 'undo redo | styles | bold italic underline strikethrough | fontfamily fontsize fontcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | table | link unlink | code',
|
||||
toolbar1: 'undo redo | styles | bold italic underline strikethrough | fontfamily fontsize fontcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | table | link unlink | code',
|
||||
toolbar2: 'vorname nachname firma',
|
||||
content_css: "<?=self::getResourcePath()?>/assets/css/tinymce.css",
|
||||
font_family_formats: "Arial=arial,sans-serif; Courier New=courier new,courier,monospace; Georgia=georgia,palatino,serif; Helvetica=helvetica,sans-serif; Lucida Sans=lucida sans unicode,sans-serif; Tahoma=tahoma,arial,helvetica,sans-serif; Times New Roman=times new roman,times,serif"
|
||||
font_family_formats: "Arial=arial,sans-serif; Courier New=courier new,courier,monospace; Georgia=georgia,palatino,serif; Helvetica=helvetica,sans-serif; Lucida Sans=lucida sans unicode,sans-serif; Tahoma=tahoma,arial,helvetica,sans-serif; Times New Roman=times new roman,times,serif",
|
||||
menubar: 'file edit view insert format tools table variables',
|
||||
menu: {
|
||||
variables: { title: 'Textbausteine', items: menu_vars_items }
|
||||
},
|
||||
setup: function (editor) {
|
||||
menu_vars.forEach(function(item) {
|
||||
editor.ui.registry.addMenuItem(item[0], {
|
||||
text: item[1],
|
||||
onAction: function () {
|
||||
editor.insertContent('{{' + item[0].toUpperCase() + '}}');
|
||||
}
|
||||
});
|
||||
});
|
||||
/*
|
||||
editor.ui.registry.addMenuItem('vorname', {
|
||||
text: 'Vorname',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{VORNAME}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('nachname', {
|
||||
text: 'Nachname',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{NACHNAME}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('firma', {
|
||||
text: 'Firma',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{FIRMA}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('firmaodername', {
|
||||
text: 'Firma oder Name',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{FIRMA_ODER_NAME}}');
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('email', {
|
||||
text: 'Emailadresse',
|
||||
onAction: function () {
|
||||
editor.insertContent('{{EMAIL}}');
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ class Preordernotification extends mfBaseModel {
|
||||
|
||||
public function sendToPreorder(Preorder $preorder, $email_to = false) {
|
||||
$subject = $this->subject;
|
||||
$body = $this->body_html; // TODO: Variable replacement
|
||||
$body = $this->replaceBodyVariables($this->body_html, $preorder); // TODO: Variable replacement
|
||||
//var_dump($body);exit;
|
||||
$from = $this->sender_email;
|
||||
$from_name = $this->sender_name;
|
||||
$reply_to = null;
|
||||
@@ -102,6 +103,40 @@ class Preordernotification extends mfBaseModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
private function replaceBodyVariables($body, $preorder) {
|
||||
$fullname = "";
|
||||
if($preorder->firstname) {
|
||||
$fullname = $preorder->firstname;
|
||||
if($preorder->lastname) {
|
||||
$fullname .= " ".$preorder->lastname;
|
||||
}
|
||||
} elseif($preorder->lastname) {
|
||||
$fullname = $preorder->lastname;
|
||||
}
|
||||
|
||||
$replacers = [
|
||||
'VORNAME' => $preorder->firstname,
|
||||
'NACHNAME' => $preorder->nachname,
|
||||
'FIRMA' => $preorder->company,
|
||||
'FIRMA_ODER_NAME' => ($preorder->company) ? $preorder->company : $fullname,
|
||||
'EMAIL' => $preorder->email,
|
||||
'ANSCHLUSS_OAID' => $preorder->adb_wohneinheit->oaid,
|
||||
'ANSCHLUSS_STRASSE' => $preorder->adb_hausnummer->strasse->name,
|
||||
'ANSCHLUSS_HAUSNUMMER' => $preorder->adb_hausnummer->hausnummer,
|
||||
'ANSCHLUSS_PLZ' => $preorder->adb_hausnummer->plz->plz,
|
||||
'ANSCHLUSS_ORT' => $preorder->adb_hausnummer->ortschaft->name,
|
||||
'ANSCHLUSS_GEMEINDE' => $preorder->adb_hausnummer->strasse->gemeinde->name,
|
||||
'PREORDER_CODE' => $preorder->ucode
|
||||
|
||||
];
|
||||
|
||||
foreach($replacers as $key => $replacement) {
|
||||
$body = str_replace("{{".$key."}}", $replacement, $body);
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user