227 lines
12 KiB
PHP
227 lines
12 KiB
PHP
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
|
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Mailtemplate")?>">Emailtemplates</a></li>
|
|
<li class="breadcrumb-item active"><?=($template && $template->id) ? $template->code : "Neu" ?></li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title"><?=($template->id) ? "Emailtemplate bearbeiten" : "Neues Emailtemplate" ?></h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
|
|
<form class="form-horizontal" method="post" action="<?=self::getUrl("Mailtemplate", "save")?>" enctype="multipart/form-data">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<input type="hidden" name="id" value="<?=$template->id?>" />
|
|
|
|
<div class="form-group row col-12">
|
|
<label class="form-label" for="name">Template Name *:</label>
|
|
<input type="text" class="form-control" name="name" id="name" value="<?=$template->name?>" placeholder="Template Name" />
|
|
</div>
|
|
|
|
<div class="form-group row col-12">
|
|
<label class="form-label" for="code">Template Code:</label>
|
|
<input type="text" class="form-control" id="code" value="<?=$template->code?>" disabled="disabled" />
|
|
</div>
|
|
|
|
<div class="form-group row col-12">
|
|
<label class="form-label" for="description">Beschreibung:</label>
|
|
<input type="text" class="form-control" name="description" id="description" value="<?=$template->description?>" placeholder="Beschreibung" />
|
|
</div>
|
|
|
|
<hr class="mt-3" />
|
|
|
|
<h4 class="mt-3">Emailtemplate</h4>
|
|
|
|
<div class="form-group row col-12 mt-3">
|
|
<label><input type="checkbox" class="" id="is_include" name="is_include" value="1" <?=($template && $template->is_include) ? "checked='checked'" : ""?> /> Template zum Einbetten</label>
|
|
</div>
|
|
|
|
|
|
<div class="form-group row mt-3 col-12">
|
|
<label class="form-label" for="subject">Betreff *:</label>
|
|
<input type="text" class="form-control" name="subject" id="subject" value="<?=$template->subject?>" placeholder="Betreff" style="border-radius:0;" />
|
|
</div>
|
|
|
|
<div class="form-group row col-12 mt-3">
|
|
<label><input type="checkbox" id="is_html" name="is_html" value="1" <?=($template && $template->body_text) ? "" : "checked='checked'"?> onchange="toggleHtml()" /> HTML-Template</label>
|
|
</div>
|
|
|
|
<h4>Template Text</h4>
|
|
<textarea id="body_text" name="body_text" class="<?=($template && $template->body_text) ? "" : "hidden"?>" placeholder="Bitte geben Sie hier den Emailinhalt ein..." rows="12" style="width: 100%; height: 600px; padding: 10px;"><?= htmlentities($template->body_text)?></textarea>
|
|
<textarea id="body_html" name="body_html" class="<?=(!$template || $template->body_html) ? "" : "hidden"?>" placeholder="Bitte geben Sie hier den Emailinhalt ein..." rows="12" style="width: 100%; height: 600px; padding: 10px;"><?= htmlentities($template->body_html)?></textarea>
|
|
|
|
|
|
|
|
<h4 class="mt-4">Dateianhänge</h4>
|
|
<div class="form-group row mb-3">
|
|
<div class="col-xl-4 input-grop">
|
|
<div class="custom-file">
|
|
<input type="file" name="attachment[]" id="attachment" class="custom-file-input" multiple="multiple" />
|
|
<label class="custom-file-label" for="attachment"> Datei(en) auswählen</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if(is_array($template->files) && count($template->files)): ?>
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<div class="card">
|
|
<?php foreach($template->files as $file): ?>
|
|
<input type="hidden" name="deletefile[<?=$file->id?>]" id="deletefile-<?=$file->id?>" value="" />
|
|
<ul id="file-<?=$file->id?>" class="list-group list-group-horizontal">
|
|
<li class="list-group-item flex-fill" style="border-radius: 0;">
|
|
<span class="filename text-monospace"><i class="far fa-file"></i> <?=$file->filename?></span>
|
|
</li><li class="list-group-item" style="border-radius: 0;">
|
|
<a href="<?=self::getUrl("File", "download", ["id" => $file->file->id])?>"><i class="far fa-download text-primary"></i></a>
|
|
</li><li class="list-group-item" style="border-radius: 0;">
|
|
<a href="#" onclick="deleteFile(<?=$file->id?>)"><i class="far fa-trash-alt text-danger"></i></a>
|
|
|
|
</li>
|
|
</ul>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
|
<div class="col-lg-10">
|
|
<textarea id="note" class="form-control" name="note" rows="5"><?=$template->note?></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2"></label>
|
|
<div class="col-lg-10">
|
|
<button type="submit" name="return" value="form" class="btn btn-primary mr-1">Speichern</button>
|
|
<button type="submit" name="return" value="index" class="btn btn-primary">Speichern und zur Übersicht</button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript" src="<?=self::getResourcePath()?>plugins/tinymce/tinymce.min.js"></script>
|
|
<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 = [];
|
|
<?php foreach($embeds as $embed): ?>
|
|
menu_vars.push(['<?=$embed->code?>', "<?=$embed->name?>"]);
|
|
<?php endforeach; ?>
|
|
|
|
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 initEditor() {
|
|
tinymce.init({
|
|
//font_formats: "Arial=arial,sans-serif;",
|
|
selector: '#body_html',
|
|
language: 'de',
|
|
skin: "tinymce-5",
|
|
plugins: ' code link autolink lists table',
|
|
paste_block_drop: true,
|
|
paste_as_text: true,
|
|
paste_data_images: false,
|
|
promotion: false,
|
|
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",
|
|
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('{{EMBED:' + item[0].toLowerCase() + '}}');
|
|
}
|
|
});
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
bsCustomFileInput.init();
|
|
}
|
|
|
|
$(function () {
|
|
initEditor();
|
|
if($("#body_html").hasClass("hidden")) {
|
|
tinymce.get("body_html").hide();
|
|
$("#body_html").hide();
|
|
}
|
|
|
|
});
|
|
|
|
function toggleHtml() {
|
|
console.log($("#body_html"));
|
|
console.log($("#body_text"));
|
|
if($("#is_html").is(":checked")) {
|
|
console.log("is checked");
|
|
$("#body_text").hide();
|
|
tinymce.get("body_html").show();
|
|
} else {
|
|
console.log("is not checked");
|
|
$("#body_text").show();
|
|
tinymce.get("body_html").hide();
|
|
$("#body_html").hide();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
function deleteFile(id) {
|
|
event.preventDefault();
|
|
//console.log($("#deletefile-" + id).val());
|
|
if(!$("#deletefile-" + id).val()) {
|
|
$('#file-' + id + " .filename").css("text-decoration", "line-through");
|
|
$('#file-' + id + " .filename").css("color", "red");
|
|
$("#deletefile-" + id).val("1");
|
|
} else {
|
|
$('#file-' + id + " .filename").removeAttr("style");
|
|
$("#deletefile-" + id).val("");
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|