250 lines
12 KiB
PHP
250 lines
12 KiB
PHP
<?php
|
|
$pagination_baseurl = $this->getUrl($Mod, "EmailLog/$notification->id");
|
|
$pagination_baseurl_params = ["filter" => $filter];
|
|
$pagination_entity_name = "Emails";
|
|
?>
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
|
<?php //var_dump($notification->filter);exit;?>
|
|
|
|
<!-- 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("Preorder")?>">Vorbestellung</a></li>
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordernotification")?>">Emailaussendungen</a></li>
|
|
<li class="breadcrumb-item active"><?=$notification->campaign->name?> "<?=htmlentities($notification->subject)?>"</li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Emailaussendungen <?=$notification->campaign->name?> "<?=htmlentities($notification->subject)?>"</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
<h4 class="header-title mb-3">Filter</h4>
|
|
|
|
<form method="get" action="<?=self::getUrl("Invoice")?>">
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_from">Absender</label>
|
|
<input type="text" class="form-control" name="filter[from]" id="filter_from" value="<?=(array_key_exists("from", $filter)) ? $filter['from'] : ""?>"/>
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_to">Empfänger</label>
|
|
<input type="text" class="form-control" name="filter[to]" id="filter_to" value="<?=(array_key_exists("to", $filter)) ? $filter['to'] : ""?>"/>
|
|
</div>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_subject">Betreff</label>
|
|
<input type="text" class="form-control" name="filter[subject]" id="filter_subject" value="<?=(array_key_exists("subject", $filter)) ? $filter['subject'] : ""?>"/>
|
|
</div>
|
|
<!--div class="col-1">
|
|
<label class="form-label" for="filter_has_attachments">Anhang</label>
|
|
<select name="filter[has_attachments]" id="filter_has_attachments" class="form-control">
|
|
<option></option>
|
|
<option value="1" <?=((array_key_exists("has_attachments", $filter)) && ($filter['has_attachments'])) ? "selected" : ""?>>Mit Anhang</option>
|
|
<option value="0" <?=((array_key_exists("has_attachments", $filter)) && (!$filter['has_attachments'])) ? "selected" : ""?>>Ohne Anhang</option>
|
|
</select>
|
|
</div-->
|
|
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col-12">
|
|
<button type="submit" class="btn btn-primary"><i class="fas fa-fw fa-search"></i> Filter anwenden</button>
|
|
<a class="btn btn-secondary" href="<?=self::getUrl("Preordernotification", "EmailLog", ["id" => $notification->id])?>?resetFilter=1"><i class="fas fa-fw fa-xmark-large"></i> Filter zurücksetzen</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4 class="header-title mb-3">Ausgehende Emails zur Aussendung <?=$notification->campaign->name?> "<?=htmlentities($notification->subject)?>"</h4>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
|
|
|
<table class="table table-striped table-hover">
|
|
<tr>
|
|
<th>Von</th>
|
|
<th>An</th>
|
|
<th>Betreff</th>
|
|
<th>Anhänge</th>
|
|
<th>Gesendet</th>
|
|
<th></th>
|
|
</tr>
|
|
<?php foreach($emails as $email): ?>
|
|
<tr>
|
|
<td><?=$email->from?></td>
|
|
<td><?=$email->to?></td>
|
|
<td><?=$email->subject?></td>
|
|
<td><?=(is_array($email->attachments)) ? count($email->attachments) : 0?></td>
|
|
<td><?=date("d.m.Y H:i",$email->create)?></td>
|
|
<td><i class="fas fa-eye text-primary pointer" onclick="displayEmailLogEmail(<?=$email->id?>); return false;"></i></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal" tabindex="-1" id="email-log-modal" style="max-height: 100vh;">
|
|
<div class="modal-dialog modal-dialog-centered modal-xl">
|
|
<div class="modal-content" style="overflow: auto;">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Emailansicht</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="row">
|
|
<div class="col">
|
|
<table class="table">
|
|
<tr>
|
|
<th>Von:</th>
|
|
<td id="email-log-from-value" class="text-monospace"></td>
|
|
</tr><tr>
|
|
<th>An:</th>
|
|
<td id="email-log-to-value" class="text-monospace"></td>
|
|
</tr><tr>
|
|
<th>Gesendet:</th>
|
|
<td id="email-log-sent-value" class="text-monospace"></td>
|
|
</tr><tr>
|
|
<th>Betreff:</th>
|
|
<td id="email-log-subject-value" class="text-monospace"></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3" id="email-log-header-section">
|
|
<div class="col">
|
|
<a href="#" onclick="displayEmailLogHeaders(); return false;"><i class="fas fa-chevron-right fa-fw"></i> Alle Header anzeigen</a>
|
|
<div id="email-log-header-view" class="mt-2 text-monospace hidden" style="min-height: 48px; width:100%; border: 1px solid #ccc; padding: 8px; font-family: sans-serif;"></div>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-2" id="email-log-body-section">
|
|
<div class="col">
|
|
<div id="email-log-body-view" style="min-height: 48px; width:100%; border: 1px solid #000; padding: 8px; font-family: sans-serif; overflow-y: auto;"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3 hidden" id="email-log-attachments-section">
|
|
<div class="col-6">
|
|
<h5>Dateianhänge</h5>
|
|
<ul id="email-log-attachment-list" class="list-group"></ul>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function displayEmailLogEmail(email_id) {
|
|
$("#email-log-from-value").text("");
|
|
$("#email-log-to-value").text("");
|
|
$("#email-log-log-sent-value").text("");
|
|
$("#email-log-subject-value").text("");
|
|
$("#email-log-view").empty();
|
|
$("#email-log-attachments-section").hide();
|
|
$("#email-log-attachment-list").empty();
|
|
hideHeaders();
|
|
|
|
if(!email_id) return false;
|
|
|
|
var resp = await fetch("<?=self::getUrl("Preordernotification", "api", ["do" => "getLoggedEmail", "nid" => $notification->id])?>&eid=" + email_id);
|
|
console.log(resp);
|
|
if(!resp.ok) {
|
|
notify("error", "Email konnte nicht geladen werden");
|
|
return false;
|
|
}
|
|
|
|
var response = await resp.json();
|
|
|
|
if(!("result" in response) || typeof response.result !== "object") {
|
|
notify("error", "Email konnte nicht geladen werden");
|
|
return false;
|
|
}
|
|
|
|
var email = response.result;
|
|
$("#email-log-from-value").text(email.from);
|
|
$("#email-log-to-value").text(email.to);
|
|
$("#email-log-sent-value").text(email.sent);
|
|
$("#email-log-subject-value").text(email.subject);
|
|
|
|
if("headers" in email && typeof email.headers === "object" && Object.keys(email.headers).length > 0) {
|
|
for (const [key, value] of Object.entries(email.headers)) {
|
|
$("#email-log-header-view").append(
|
|
"<strong>" + key + "</strong>: "
|
|
+ value.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>')
|
|
+ "<br/>");
|
|
if(key == "From") {
|
|
$("#email-log-from-value").text(value);
|
|
}
|
|
}
|
|
}
|
|
|
|
if("attachments" in email && typeof email.attachments === "object" && Object.keys(email.attachments).length > 0) {
|
|
email.attachments.forEach( (item, index) => {
|
|
$("#email-log-attachment-list").append('<li class="list-group-item flex-fill p-1" style="border-radius: 0;"><a href="<?=self::getUrl("EmailLog", "downloadContent")?>?aid=' + item.id + '&hash=' + item.hash + '"><span class="filename text-monospace"><i class="far fa-file"></i> ' + item.filename + '</span></a> (' + Math.round((item.filesize/1024/1024)*100)/100 + ' MB)</li>');
|
|
});
|
|
$("#email-log-attachments-section").show();
|
|
}
|
|
|
|
if(email.bodyIsHtml) {
|
|
$("#email-log-body-view").html(email.body);
|
|
} else {
|
|
$("#email-logbody-view").text(email.body);
|
|
}
|
|
|
|
|
|
$("#email-log-modal").modal("show");
|
|
}
|
|
|
|
function displayEmailLogHeaders() {
|
|
$("#email-log-header-view").toggleClass("hidden");
|
|
if($("#email-log-header-view").hasClass("hidden")) {
|
|
$("#email-log-header-section").find("i").addClass("fa-chevron-right").removeClass("fa-chevron-down");
|
|
} else {
|
|
$("#email-log-header-section").find("i").addClass("fa-chevron-down").removeClass("fa-chevron-right");
|
|
}
|
|
|
|
}
|
|
|
|
function hideEmailLogHeaders() {
|
|
$("#email-log-header-view").empty();
|
|
if(!$("#email-log-header-view").hasClass("hidden")) {
|
|
$("#email-log-header-view").addClass("hidden");
|
|
$("#email-log-header-section").find("i").addClass("fa-chevron-down").removeClass("fa-chevron-right");
|
|
}
|
|
}
|
|
|
|
//$("#email-log-modal").modal("show");
|
|
</script>
|