Saving Preordernotification and test email done
This commit is contained in:
@@ -7,8 +7,8 @@
|
|||||||
<div class="page-title-right">
|
<div class="page-title-right">
|
||||||
<ol class="breadcrumb m-0">
|
<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("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Network")?>">Vorbestellung</a></li>
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preorder")?>">Vorbestellung</a></li>
|
||||||
<li class="breadcrumb-item">Emailaussendungen</li>
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordernotification")?>">Emailaussendungen</a></li>
|
||||||
<li class="breadcrumb-item active"><?=($notification->id) ? "bearbeiten" : "Neu" ?></li>
|
<li class="breadcrumb-item active"><?=($notification->id) ? "bearbeiten" : "Neu" ?></li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@@ -24,19 +24,20 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Preordernotification ", "save")?>">
|
<form class="form-horizontal" method="post" action="<?=self::getUrl("Preordernotification", "save")?>" enctype="multipart/form-data">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<input type="hidden" name="id" value="<?=$notification->id?>" />
|
<input type="hidden" name="id" value="<?=$notification->id?>" />
|
||||||
|
<input type="hidden" name="preordercampaign_id" value="<?=$campaign->id?>" />
|
||||||
<h4>Empfänger</h4>
|
<h4>Empfänger</h4>
|
||||||
<p>Die Aussendung wird an die Kontaktemailadresse aller Bestellungen versendet. Wählen Sie folgende Konditionen aus, um die Empfänger zu beschränken:</p>
|
<p>Die Aussendung wird an die Kontaktemailadresse aller Bestellungen versendet. Wählen Sie folgende Konditionen aus, um die Empfänger zu beschränken:</p>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="name">Vorbestellkampagne</label>
|
<label class="col-lg-2 col-form-label" for="preordercamaign">Vorbestellkampagne</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<input type="text" class="form-control" name="preordercampaign_id" id="preordercampaign_id" value="<?=$campaign->name?>" disabled="disabled">
|
<input type="text" class="form-control" name="preordercampaign" id="preordercampaign" value="<?=$campaign->name?>" disabled="disabled">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -44,11 +45,11 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="type">Bestelltyp</label>
|
<label class="col-lg-2 col-form-label" for="type">Bestelltyp</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control select2" name="type" id="type" multiple="multiple">
|
<select class="form-control select2" name="type[]" id="type" multiple="multiple">
|
||||||
<?php if(array_key_exists("interest", $campaign->types)): ?><option value="interest" <?=($notification->type == "interest") ? "selected='selected'" : ""?>>Interessensbekundung</option><?php endif; ?>
|
<option value="interest" <?=(array_key_exists("type", $notification->filter) && in_array("interest", $notification->filter["type"])) ? "selected='selected'" : ""?>>Interessensbekundung</option>
|
||||||
<?php if(array_key_exists("provision", $campaign->types)): ?><option value="provision" <?=($notification->type == "provision") ? "selected='selected'" : ""?>>Vorsorgeanschluss</option><?php endif; ?>
|
<option value="provision" <?=(array_key_exists("type", $notification->filter) && in_array("provision", $notification->filter["type"])) ? "selected='selected'" : ""?>>Vorsorgeanschluss</option>
|
||||||
<?php if(array_key_exists("order", $campaign->types)): ?><option value="order" <?=($notification->type == "order") ? "selected='selected'" : ""?>>Vollanschluss</option><?php endif; ?>
|
<option value="order" <?=(array_key_exists("type", $notification->filter) && in_array("order", $notification->filter["type"])) ? "selected='selected'" : ""?>>Vollanschluss</option>
|
||||||
<?php if(array_key_exists("reorder", $campaign->types)): ?><option value="reorder" <?=($notification->type == "reorder") ? "selected='selected'" : ""?>>Nachbestellung</option><?php endif; ?>
|
<option value="reorder" <?=(array_key_exists("type", $notification->filter) && in_array("reorder", $notification->filter["type"])) ? "selected='selected'" : ""?>>Nachbestellung</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,12 +57,12 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="connection_type">Anschlusstyp</label>
|
<label class="col-lg-2 col-form-label" for="connection_type">Anschlusstyp</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<select class="form-control select2" name="connection_type" id="connection_type" multiple="multiple">
|
<select class="form-control select2" name="connection_type[]" id="connection_type" multiple="multiple">
|
||||||
<option value="single-dwelling" <?=($notification->connection_type == "single-dwelling") ? "selected='selected'" : ""?>>Einfamilienhaus</option>
|
<option value="single-dwelling" <?=(array_key_exists("connection_type", $notification->filter) && in_array("single-dwelling", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Einfamilienhaus</option>
|
||||||
<option value="multi-dwelling" <?=($notification->connection_type == "multi-dwelling") ? "selected='selected'" : ""?>>Mehrfamilienhaus</option>
|
<option value="multi-dwelling" <?=(array_key_exists("connection_type", $notification->filter) && in_array("multi-dwelling", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Mehrfamilienhaus</option>
|
||||||
<option value="apartment-building" <?=($notification->connection_type == "apartment-building") ? "selected='selected'" : ""?>>Mehrparteienhaus</option>
|
<option value="apartment-building" <?=(array_key_exists("connection_type", $notification->filter) && in_array("apartment-building", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Mehrparteienhaus</option>
|
||||||
<option value="apartment" <?=($notification->connection_type == "apartment") ? "selected='selected'" : ""?>>Wohneinheit in Mehrparteienhaus</option>
|
<option value="apartment" <?=(array_key_exists("connection_type", $notification->filter) && in_array("apartment", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Wohneinheit in Mehrparteienhaus</option>
|
||||||
<option value="business" <?=($notification->connection_type == "business") ? "selected='selected'" : ""?>>Gewerbebetrieb</option>
|
<option value="business" <?=(array_key_exists("connection_type", $notification->filter) && in_array("business", $notification->filter['connection_type'])) ? "selected='selected'" : ""?>>Gewerbebetrieb</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -82,19 +83,89 @@
|
|||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
|
||||||
<h4 class="mt-4">Emailinhalt</h4>
|
<h4 class="mt-4">Email</h4>
|
||||||
<p>Im folgenden Editor können Sie ein HTML-Email verfassen. Verwenden Sie as Menü und die Werkzeugleiste um den Text zu formatieren:</p>
|
|
||||||
<textarea id="body_html" name="body_html" placeholder="Bitte geben Sie hier den Emailinhalt ein..." rows="12" style="width: 100%; height: 600px; padding: 10px;"><?=$notification->body_html?></textarea>
|
<p>Im folgenden Editor können Sie ein HTML-Email verfassen. Verwenden Sie das Menü und die Werkzeugleiste um den Text zu formatieren.</p>
|
||||||
|
<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="<?=$notification->subject?>" placeholder="Betreff" style="border-radius:0;" />
|
||||||
|
</div>
|
||||||
|
<textarea id="body_html" name="body_html" placeholder="Bitte geben Sie hier den Emailinhalt ein..." rows="12" style="width: 100%; height: 600px; padding: 10px;"><?= htmlentities($notification->body_html)?></textarea>
|
||||||
|
|
||||||
|
|
||||||
<h4 class="mt-4">Dateianhänge</h4>
|
<h4 class="mt-4">Dateianhänge</h4>
|
||||||
<div class="row mb-3">
|
<div class="form-group row mb-3">
|
||||||
<div class="col-xl-5 input-grop ml-1">
|
<div class="col-xl-5 input-grop">
|
||||||
<label class="custom-file-label" for="attachment"><i class="far fa-file-import"></i> Datei(en) auswählen</label>
|
<div class="custom-file">
|
||||||
<input type="file" name="attachment[]" id="attachment" class="custom-file-input" multiple="multiple" />
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if(is_array($notification->files) && count($notification->files)): ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<div class="card" style="">
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php foreach($notification->files as $file): ?>
|
||||||
|
<li id="file-<?=$file->id?>" class="list-group-item"><input type="hidden" name="deletefile[<?=$file->id?>]" id="deletefile-<?=$file->id?>" value="" /><a href="#" onclick="deleteFile(<?=$file->id?>)" class="mr-2"><i class="far fa-trash text-danger"></i></a> <span class="filename"><i class="far fa-file"></i> <?=$file->filename?></span></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<h4>Versand</h4>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label" for="tosend_day">Versandzeitpunkt</label>
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<label>Datum</label>
|
||||||
|
<input type="text" class="form-control" name="tosend_day" id="tosend_date" value="<?=($notification->tosend_date) ? date("d.m.Y", $notification->tosend_date) : ""?>" />
|
||||||
|
<small>Emailversand wird zu diesem Zeitpunkt gestartet</small>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<label>Uhrzeit</label>
|
||||||
|
<select name="tosend_hour" class="form-control">
|
||||||
|
<?php for($h = 0; $h < 24; $h++): ?>
|
||||||
|
<option value="<?=$h?>" <?=($notification->tosend_date && date('H', $notification->tosend_date) == $h) ? "selected='selected'" : ""?>><?=str_pad($h, 2, "0", STR_PAD_LEFT)?>:00</option>
|
||||||
|
<?php endfor; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label" for="testmail_to">Test Email versenden</label>
|
||||||
|
<div class="col-lg-10">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6">
|
||||||
|
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fas fa-envelope"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" name="testmail_to" id="testmail_to" value="" placeholder="Testempfänger" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<button type="submit" name="send_testmail" value="1" class="btn btn-outline-success"><i class="far fa-paper-plane"></i> Testmail jetzt abschicken</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -105,7 +176,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<textarea id="note" class="form-control" name="note" rows="5"><?=$pop->note?></textarea>
|
<textarea id="note" class="form-control" name="note" rows="5"><?=$notification->note?></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -136,12 +207,12 @@
|
|||||||
selector: '#body_html',
|
selector: '#body_html',
|
||||||
language: 'de',
|
language: 'de',
|
||||||
skin: "tinymce-5",
|
skin: "tinymce-5",
|
||||||
plugins: 'link autolink lists table',
|
plugins: ' code link autolink lists table',
|
||||||
paste_block_drop: true,
|
paste_block_drop: true,
|
||||||
paste_as_text: true,
|
paste_as_text: true,
|
||||||
paste_data_images: false,
|
paste_data_images: false,
|
||||||
promotion: 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',
|
toolbar: 'undo redo | styles | bold italic underline strikethrough | fontfamily fontsize fontcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | table | link unlink | code',
|
||||||
content_css: "<?=self::getResourcePath()?>/assets/css/tinymce.css",
|
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"
|
||||||
|
|
||||||
@@ -170,12 +241,33 @@
|
|||||||
});
|
});
|
||||||
//$('#body_html').summernote('fontSizeUnit', "pt");
|
//$('#body_html').summernote('fontSizeUnit', "pt");
|
||||||
//$('#body_html').summernote("fontSize", 12);*/
|
//$('#body_html').summernote("fontSize", 12);*/
|
||||||
|
|
||||||
|
$('#tosend_date').datepicker({
|
||||||
|
language: 'de',
|
||||||
|
format: "dd.mm.yyyy",
|
||||||
|
showWeekDays: true,
|
||||||
|
todayBtn: 'linked',
|
||||||
|
autoclose: true
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".select2").select2({
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: ""
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".select2").select2({
|
function deleteFile(id) {
|
||||||
allowClear: true,
|
event.preventDefault();
|
||||||
placeholder: ""
|
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>
|
</script>
|
||||||
|
|
||||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<div class="card-body mb-3">
|
<div class="card-body mb-3">
|
||||||
<h4 class="header-title mb-3">Filter</h4>
|
<h4 class="header-title mb-3">Filter</h4>
|
||||||
|
|
||||||
<form method="get" action="<?=self::getUrl("Preordercampaign")?>">
|
<form method="get" action="<?=self::getUrl("Preordernotification")?>">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<div class="row mt-2">
|
<div class="row mt-2">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||||
<a class="btn btn-secondary" href="<?=self::getUrl("Preordercampaign")?>">Filter zurücksetzen</a>
|
<a class="btn btn-secondary" href="<?=self::getUrl("Preordernotification")?>">Filter zurücksetzen</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -78,24 +78,28 @@
|
|||||||
|
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th class="text-center">Versendet</th>
|
||||||
<th>Kampagne</th>
|
<th>Kampagne</th>
|
||||||
<th>Betreff</th>
|
<th>Betreff</th>
|
||||||
<th>Anzahl Empfänger</th>
|
<th>Anzahl Empfänger</th>
|
||||||
<th>Geplanter Versand</th>
|
<th>Geplanter Versand</th>
|
||||||
<th>Versendet</th>
|
<th>Bearbeitet</th>
|
||||||
|
<th>Erstellt</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php foreach($notifications as $notification): ?>
|
<?php foreach($notifications as $notification): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?=$notification->preordercampaign->name?></td>
|
<td class="text-center"><?=($notification->sent_date) ? date('d.m.Y', $notification->sent_date) : "<i class='fas fa-remove text-danger' title='Noch nicht versendet'></i>"?></td>
|
||||||
|
<td><?=$notification->campaign->name?></td>
|
||||||
<td><?=$notification->subject?></td>
|
<td><?=$notification->subject?></td>
|
||||||
<td><?=($notification->recipient_count) ? "ca. ".$notification->recipient_count : ""?></td>
|
<td title="Anzahl berechnet am <?=date('d.m.Y H:i', $notification->edit)?>"><?=($notification->recipient_count) ? $notification->recipient_count : ""?></td>
|
||||||
<td><?=($notification->tosend_date) ? date('d.m.Y', $notification->tosend_date) : "" ?></td>
|
<td><?=($notification->tosend_date) ? date('d.m.Y', $notification->tosend_date) : "" ?></td>
|
||||||
<td><?=($notification->sent_date) ? date('d.m.Y', $notification->sent_date) : ""?></td>
|
<td><?=date("d.m.Y H:i",$notification->edit)?> (<?=$notification->editor->name?>)</td>
|
||||||
|
<td><?=date("d.m.Y H:i",$notification->create)?> (<?=$notification->creator->name?>)</td>
|
||||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||||
<?php if(!$notification->sent_date): ?>
|
<?php if(!$notification->sent_date): ?>
|
||||||
<a href="<?=self::getUrl("Preordercampaign", "edit", ["id" => $camp->id])?>"><i class="far fa-edit" title="Aussendung bearbeiten"></i></a>
|
<a href="<?=self::getUrl("Preordernotification", "edit", ["id" => $notification->id])?>"><i class="far fa-edit" title="Aussendung bearbeiten"></i></a>
|
||||||
<a href="<?=self::getUrl("Preordercampaign", "delete", ["id" => $camp->id])?>" class="text-danger" onclick="if(!confirm('Aussendung wirklich löschen?')) return false;" title="Vorbestellkampagne Löschen"><i class="fas fa-trash"></i></a>
|
<a href="<?=self::getUrl("Preordernotification", "delete", ["id" => $notification->id])?>" class="text-danger" onclick="if(!confirm('Aussendung wirklich löschen?')) return false;" title="Aussendung Löschen"><i class="fas fa-trash"></i></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class Emailnotification {
|
|||||||
private $headers = [];
|
private $headers = [];
|
||||||
private $subject;
|
private $subject;
|
||||||
private $body;
|
private $body;
|
||||||
|
private $html;
|
||||||
private $from_name = false;
|
private $from_name = false;
|
||||||
private $email_from = false;
|
private $email_from = false;
|
||||||
private $email_to = false;
|
private $email_to = false;
|
||||||
@@ -52,6 +53,10 @@ class Emailnotification {
|
|||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setHtmlBody($html) {
|
||||||
|
$this->html = $html;
|
||||||
|
}
|
||||||
|
|
||||||
public function setFrom($email, $name = false) {
|
public function setFrom($email, $name = false) {
|
||||||
$this->email_from = $email;
|
$this->email_from = $email;
|
||||||
$this->from_name = $name;
|
$this->from_name = $name;
|
||||||
@@ -65,7 +70,7 @@ class Emailnotification {
|
|||||||
if(!$this->email_to) {
|
if(!$this->email_to) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!$this->body) {
|
if(!$this->body && !$this->html) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!is_array($this->headers) || !count($this->headers)) {
|
if(!is_array($this->headers) || !count($this->headers)) {
|
||||||
@@ -93,8 +98,13 @@ class Emailnotification {
|
|||||||
$mimeparams['head_charset']="utf-8";
|
$mimeparams['head_charset']="utf-8";
|
||||||
|
|
||||||
$mime = new Mail_mime();
|
$mime = new Mail_mime();
|
||||||
$mime->setTXTBody($this->body);
|
if($this->body) {
|
||||||
|
$mime->setTXTBody($this->body);
|
||||||
|
}
|
||||||
|
if($this->html) {
|
||||||
|
$mime->setHTMLBody($this->html);
|
||||||
|
}
|
||||||
|
|
||||||
//var_dump($this->attachments);exit;
|
//var_dump($this->attachments);exit;
|
||||||
|
|
||||||
if(count($this->attachments)) {
|
if(count($this->attachments)) {
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ class File extends mfBaseModel {
|
|||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
|
|
||||||
// delete file in store
|
// delete file in store
|
||||||
$path = MFUPLOAD_FILE_SAVE_PATH."/documents/".$this->store_filename;
|
if($this->ubfolder) {
|
||||||
|
$path = MFUPLOAD_FILE_SAVE_PATH."/".$this->subfolder."/".$this->store_filename;
|
||||||
|
} else {
|
||||||
|
$path = MFUPLOAD_FILE_SAVE_PATH."/".$this->store_filename;
|
||||||
|
}
|
||||||
if(!unlink($path)) {
|
if(!unlink($path)) {
|
||||||
$this->log->warn(__CLASS__."::delete(): Error unlinking file ($path)");
|
$this->log->warn(__CLASS__."::delete(): Error unlinking file ($path)");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class FileModel {
|
|||||||
public $store_filename;
|
public $store_filename;
|
||||||
public $orig_filename;
|
public $orig_filename;
|
||||||
public $subfolder;
|
public $subfolder;
|
||||||
|
public $mimetype;
|
||||||
|
|
||||||
public $create_by = null;
|
public $create_by = null;
|
||||||
public $edit_by = null;
|
public $edit_by = null;
|
||||||
@@ -66,7 +67,7 @@ class FileModel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFirst() {
|
public static function getFirst($filter) {
|
||||||
$db = FronkDB::singleton();
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
$where = self::getSqlFilter($filter);
|
$where = self::getSqlFilter($filter);
|
||||||
|
|||||||
@@ -387,6 +387,18 @@ class PreorderModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("connection_type", $filter)) {
|
||||||
|
$connection_type = $filter['connection_type'];
|
||||||
|
if(is_array($connection_type) && count($connection_type)) {
|
||||||
|
$where .= " AND connection_type IN ('".implode("','",$connection_type)."')";
|
||||||
|
} else {
|
||||||
|
$connection_type = FronkDB::singleton()->escape($filter['connection_type']);
|
||||||
|
if($connection_type) {
|
||||||
|
$where .= " AND connection_type like '%$connection_type%'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(array_key_exists("ucode", $filter)) {
|
if(array_key_exists("ucode", $filter)) {
|
||||||
$ucode = FronkDB::singleton()->escape($filter['ucode']);
|
$ucode = FronkDB::singleton()->escape($filter['ucode']);
|
||||||
if($ucode) {
|
if($ucode) {
|
||||||
|
|||||||
@@ -1,5 +1,119 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Preordernotification extends mfBaseModel {
|
class Preordernotification extends mfBaseModel {
|
||||||
|
private $campaign;
|
||||||
|
private $filter;
|
||||||
|
private $files;
|
||||||
|
|
||||||
|
private $creator;
|
||||||
|
private $editor;
|
||||||
|
|
||||||
|
public function getPreorders() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendToPreorder(Preorder $preorder, $email_to) {
|
||||||
|
$subject = $this->subject;
|
||||||
|
$body = $this->body_html; // TODO: Variable replacement
|
||||||
|
$from = "office@xinon.at";
|
||||||
|
$from_name = "XINON Kundenservice";
|
||||||
|
$to = $preorder->email;
|
||||||
|
|
||||||
|
if($email_to) {
|
||||||
|
$to = $email_to;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$to) return true;
|
||||||
|
|
||||||
|
// get attachments
|
||||||
|
$attachments = [];
|
||||||
|
foreach($this->getProperty("files") as $file) {
|
||||||
|
$att = [];
|
||||||
|
$att["path"] = MFUPLOAD_FILE_SAVE_PATH."/".$file->file->subfolder."/".$file->file->store_filename;
|
||||||
|
$att["filename"] = $file->filename;
|
||||||
|
$att["mimetype"] = $file->file->mimetype;
|
||||||
|
$attachments[] = $att;
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($attachments);exit;
|
||||||
|
|
||||||
|
if(!$subject || !$from || !$from_name || !$to) {
|
||||||
|
$this->log->warn("Preordernotification not sent. subject, from or to missing. Preorder id ".$preorder->id);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$email = new Emailnotification();
|
||||||
|
$email->setSubject($subject);
|
||||||
|
$email->setHtmlBody($body);
|
||||||
|
$email->setFrom($from, $from_name);
|
||||||
|
$email->setTo($to);
|
||||||
|
$email->setHeader("X-".MFAPPNAME."-Pnid", $this->id);
|
||||||
|
if(count($attachments)) {
|
||||||
|
foreach($attachments as $file) {
|
||||||
|
$email->addAttachment($file["path"], null, $file["filename"], $file['mimetype']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$email->send();
|
||||||
|
$this->log->info(__CLASS__."::sendToPreorder(): Sending Preordernotification for Preorder id ".$preorder->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProperty($name) {
|
||||||
|
if($this->$name == null) {
|
||||||
|
|
||||||
|
if($name == "campaign") {
|
||||||
|
$this->campaign = new Preordercampaign($this->preordercampaign_id);
|
||||||
|
return $this->campaign;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($name == "filter") {
|
||||||
|
if($this->preorder_filter) {
|
||||||
|
$this->filter = json_decode($this->preorder_filter, true);
|
||||||
|
} else {
|
||||||
|
$this->filter = [];
|
||||||
|
}
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($name == "files") {
|
||||||
|
$this->files = PreordernotificationFileModel::search(["preordernotification_id" => $this->id]);
|
||||||
|
return $this->files;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($name == "creator") {
|
||||||
|
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||||
|
if($user) {
|
||||||
|
$this->creator = $user;
|
||||||
|
return $this->creator;
|
||||||
|
}
|
||||||
|
$this->creator = new User($this->create_by);
|
||||||
|
if($this->creator->id) {
|
||||||
|
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
||||||
|
}
|
||||||
|
return $this->creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($name == "editor") {
|
||||||
|
$this->editor = new User($this->edit_by);
|
||||||
|
return $this->editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
$classname = ucfirst($name);
|
||||||
|
$idfield = $name."_id";
|
||||||
|
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||||
|
if(!$this->$name) {
|
||||||
|
$this->$name = new $classname($this->$idfield);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->$name->id) {
|
||||||
|
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||||
|
return $this->$name;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->$name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -71,12 +71,12 @@ class PreordernotificationController extends mfBaseController {
|
|||||||
$filter['preordercampaign_id'] = $my_campaign_ids;
|
$filter['preordercampaign_id'] = $my_campaign_ids;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//var_dump($filter);exit;
|
||||||
$pagination['maxItems'] = PreordernotificationModel::count($filter);
|
$pagination['maxItems'] = PreordernotificationModel::count($filter);
|
||||||
$notifications = PreordernotificationModel::search($filter, $pagination);
|
$notifications = PreordernotificationModel::search($filter, $pagination);
|
||||||
|
|
||||||
$this->layout()->set("pagination", $pagination);
|
$this->layout()->set("pagination", $pagination);
|
||||||
$this->layout()->set("preorders", $notifications);
|
$this->layout()->set("notifications", $notifications);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -111,22 +111,271 @@ class PreordernotificationController extends mfBaseController {
|
|||||||
protected function editAction() {
|
protected function editAction() {
|
||||||
$id = $this->request->id;
|
$id = $this->request->id;
|
||||||
if(!is_numeric($id) || $id < 1) {
|
if(!is_numeric($id) || $id < 1) {
|
||||||
$this->layout()->setFlash("Vorbestellung nicht gefunden", "error");
|
$this->layout()->setFlash("Aussendung nicht gefunden", "error");
|
||||||
$this->redirect("Preordercampaign");
|
$this->redirect("Preordernotification");
|
||||||
}
|
}
|
||||||
|
|
||||||
$preorder = new Preorder($id);
|
$notification = new Preordernotification($id);
|
||||||
if(!$preorder->id) {
|
if(!$notification->id) {
|
||||||
$this->layout()->setFlash("Vorbestellung nicht gefunden", "error");
|
$this->layout()->setFlash("Aussendung nicht gefunden", "error");
|
||||||
$this->redirect("Preordercampaign");
|
$this->redirect("Preordernotification");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->request->set("preordercampaign_id", $preorder->preordercampaign_id); // needed in addAction()
|
//var_dump($notification->filter);exit;
|
||||||
$this->layout()->set("preorder", $preorder);
|
|
||||||
|
|
||||||
//var_dump($preorder->building->street);exit;
|
$this->request->set("preordercampaign_id", $notification->preordercampaign_id); // needed in addAction()
|
||||||
|
$this->layout()->set("notification", $notification);
|
||||||
|
|
||||||
return $this->addAction();
|
return $this->addAction();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function saveAction() {
|
||||||
|
$r = $this->request;
|
||||||
|
//var_dump($r->get(), $_FILES);exit;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* add or edit
|
||||||
|
*/
|
||||||
|
$id = $r->id;
|
||||||
|
if(is_numeric($id) && $id > 0) {
|
||||||
|
$mode = "edit";
|
||||||
|
$notification = new Preordernotification($id);
|
||||||
|
if(!$notification->id) {
|
||||||
|
$this->layout()->setFlash("Aussendung nicht gefunden", "error");
|
||||||
|
$this->redirect("Preordernotification");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$id = false;
|
||||||
|
$mode = "add";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check campaign and permissions
|
||||||
|
*/
|
||||||
|
|
||||||
|
$campaign_id = $r->preordercampaign_id;
|
||||||
|
if(!$campaign_id) {
|
||||||
|
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
|
||||||
|
$this->redirect("Preordernotification");
|
||||||
|
}
|
||||||
|
$campaign = new Preordercampaign($campaign_id);
|
||||||
|
if(!$campaign->id) {
|
||||||
|
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
|
||||||
|
$this->redirect("Preordernotification");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check permission
|
||||||
|
if(!$this->me->is("Admin")) {
|
||||||
|
$my_campaign_ids = [];
|
||||||
|
$my_networks = $this->me->myNetworks(["netowner", "salespartner"]);
|
||||||
|
//var_dump($my_networks);exit;
|
||||||
|
|
||||||
|
foreach($my_networks as $network) {
|
||||||
|
foreach(PreordercampaignModel::search(['network_id' => $network->id]) as $campaign) {
|
||||||
|
if(!in_array($campaign->id, $my_campaign_ids)) $my_campaign_ids[] = $campaign->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!in_array($campaign_id, $my_campaign_ids)) {
|
||||||
|
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
|
||||||
|
$this->redirect("Preordernotification");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* data colletion
|
||||||
|
*/
|
||||||
|
$filter = [];
|
||||||
|
if(is_array($r->type) && count($r->type)) {
|
||||||
|
$filter['type'] = [];
|
||||||
|
foreach($r->type as $type) {
|
||||||
|
switch($type) {
|
||||||
|
case "interest":
|
||||||
|
$filter["type"][] = "interest";
|
||||||
|
break;
|
||||||
|
case "provision":
|
||||||
|
$filter["type"][] = "provision";
|
||||||
|
break;
|
||||||
|
case "order":
|
||||||
|
$filter["type"][] = "order";
|
||||||
|
break;
|
||||||
|
case "reorder":
|
||||||
|
$filter["type"][] = "reorder";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_array($r->connection_type) && count($r->connection_type)) {
|
||||||
|
$filter['connection_type'] = [];
|
||||||
|
foreach($r->connection_type as $type) {
|
||||||
|
switch($type) {
|
||||||
|
case "single-dwelling":
|
||||||
|
$filter["connection_type"][] = "single-dwelling";
|
||||||
|
break;
|
||||||
|
case "multi-dwelling":
|
||||||
|
$filter["connection_type"][] = "multi-dwelling";
|
||||||
|
break;
|
||||||
|
case "apartment-building":
|
||||||
|
$filter["connection_type"][] = "apartment-building";
|
||||||
|
break;
|
||||||
|
case "apartment":
|
||||||
|
$filter["connection_type"][] = "apartment";
|
||||||
|
break;
|
||||||
|
case "business":
|
||||||
|
$filter["connection_type"][] = "business";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($filter);
|
||||||
|
$data = [];
|
||||||
|
$data['preordercampaign_id'] = $campaign_id;
|
||||||
|
$data['subject'] = $r->subject;
|
||||||
|
$data['body_html'] = $r->body_html;
|
||||||
|
$data['note'] = $r->note;
|
||||||
|
|
||||||
|
if($r->tosend_day) {
|
||||||
|
$tosend_day = $r->tosend_day;
|
||||||
|
$tosend_hour = $r->tosend_hour;
|
||||||
|
if($tosend_hour < 0 || $tosend_hour > 23) {
|
||||||
|
$tosend_hour = 0;
|
||||||
|
}
|
||||||
|
$data['tosend_date'] = self::dateToTimestamp($tosend_day." ".str_pad($tosend_hour, 2, "0", STR_PAD_LEFT).":00:00");
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['preorder_filter'] = json_encode($filter);
|
||||||
|
|
||||||
|
//var_dump($data);exit;
|
||||||
|
|
||||||
|
if($mode == "edit") {
|
||||||
|
$notification->update($data);
|
||||||
|
} else {
|
||||||
|
$notification = PreordernotificationModel::create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_id = $notification->save();
|
||||||
|
if(!$new_id) {
|
||||||
|
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||||
|
if($id) {
|
||||||
|
$this->redirect("Preordernotification", "edit", ['id' => $id]);
|
||||||
|
} else {
|
||||||
|
$this->redirect("Preordernotification");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attachment upload
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(array_key_exists("attachment", $_FILES)) {
|
||||||
|
$files = $_FILES['attachment'];
|
||||||
|
if(is_array($files) && count($files)) {
|
||||||
|
$file_errors = 0;
|
||||||
|
foreach($files['name'] as $i => $name) {
|
||||||
|
if(!$name) continue;
|
||||||
|
$upload_error = false;
|
||||||
|
try {
|
||||||
|
$upload = new mfUpload(['attachment', $i]);
|
||||||
|
$upload->setSavepath(MFUPLOAD_FILE_SAVE_PATH . "/" . TT_PREORDERNOTIFICATION_FILE_UPLOAD_SUBFOLDER);
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$this->layout()->setFlash("Dateiupload fehlgeschlagen: ".$e->getMessage(), "warn");
|
||||||
|
$file_errors++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$upload->getSize()) {
|
||||||
|
$this->layout()->setFlash("Dateiupload fehlgeschlagen: Datei ist leer!", "warn");
|
||||||
|
$upload_error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mime = "";
|
||||||
|
|
||||||
|
if(!$upload_error) {
|
||||||
|
try {
|
||||||
|
$mime = $upload->getMimetype();
|
||||||
|
$upload->save();
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "warn");
|
||||||
|
$upload_error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($upload_error) {
|
||||||
|
$file_errors++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_data = [];
|
||||||
|
$file_data['name'] = $upload->getOriginalFilename();
|
||||||
|
$file_data['filename'] = $upload->getOriginalFilename();
|
||||||
|
$file_data['subfolder'] = TT_PREORDERNOTIFICATION_FILE_UPLOAD_SUBFOLDER;
|
||||||
|
$file_data['store_filename'] = $upload->getFilename();
|
||||||
|
$file_data['orig_filename'] = $upload->getOriginalFilename();
|
||||||
|
$file_data['mimetype'] = $mime;
|
||||||
|
|
||||||
|
$file = FileModel::create($file_data);
|
||||||
|
$file_id = $file->save();
|
||||||
|
if(!$file_id) {
|
||||||
|
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "warn");
|
||||||
|
unlink($upload->getSavepath()."/".$upload->getFilename());
|
||||||
|
} else {
|
||||||
|
$pnf = [];
|
||||||
|
$pnf['preordernotification_id'] = $notification->id;
|
||||||
|
$pnf['file_id'] = $file_id;
|
||||||
|
$pnf['filename'] = $file->filename;
|
||||||
|
|
||||||
|
$notification_file = PreordernotificationFileModel::create($pnf);
|
||||||
|
if(!$notification_file->save()) {
|
||||||
|
$file->delete();
|
||||||
|
unlink($upload->getSavepath()."/".$upload->getFilename());
|
||||||
|
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "warn");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* delete files
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(is_array($r->deletefile)) {
|
||||||
|
foreach($r->deletefile as $pnf_id) {
|
||||||
|
$pnf = new PreordernotificationFile($pnf_id);
|
||||||
|
if($pnf->preordernotification_id != $notification->id) continue;
|
||||||
|
$pnf->file->delete();
|
||||||
|
$pnf->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get and save preorder count
|
||||||
|
$preorder_filter = json_decode($notification->preorder_filter, true);
|
||||||
|
$preorder_filter['preordercampaign_id'] = $notification->preordercampaign_id;
|
||||||
|
$preorder_count = PreorderModel::count($preorder_filter);
|
||||||
|
$notification->recipient_count = $preorder_count;
|
||||||
|
$notification->save();
|
||||||
|
|
||||||
|
if($r->send_testmail && $r->testmail_to) {
|
||||||
|
$preorder = PreorderModel::getFirst($preorder_filter);
|
||||||
|
if(!$preorder) {
|
||||||
|
$this->layout()->setFlash("Testmail konnte nicht versendet werden. Keine Empfänger gefunden", "warn");
|
||||||
|
$this->redirect("Preordernotification", "edit", ['id' => $new_id]);
|
||||||
|
}
|
||||||
|
$notification->sendToPreorder($preorder, $r->testmail_to);
|
||||||
|
$this->layout()->setFlash("Testmail versendet", "success");
|
||||||
|
$this->redirect("Preordernotification", "edit", ['id' => $new_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->layout()->setFlash("Erfolgreich gepeichert.", "success");
|
||||||
|
$this->redirect("Preordernotification", "edit", ['id' => $new_id]);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PreordernotificationModel {
|
class PreordernotificationModel {
|
||||||
public $name = null;
|
|
||||||
public $subject;
|
public $subject;
|
||||||
public $body_text;
|
public $body_text;
|
||||||
public $body_html;
|
public $body_html;
|
||||||
public $tosend_date;
|
public $tosend_date;
|
||||||
public $sent_date;
|
public $sent_date;
|
||||||
|
public $recipient_count;
|
||||||
public $preordercampaign_id;
|
public $preordercampaign_id;
|
||||||
|
public $preorder_filter;
|
||||||
|
|
||||||
public $note = null;
|
public $note = null;
|
||||||
public $create_by = null;
|
public $create_by = null;
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class PreordernotificationFile extends mfBaseModel {
|
||||||
|
private $file;
|
||||||
|
private $preordernotification;
|
||||||
|
|
||||||
|
public function getProperty($name) {
|
||||||
|
if($this->$name == null) {
|
||||||
|
|
||||||
|
|
||||||
|
$classname = ucfirst($name);
|
||||||
|
$idfield = $name."_id";
|
||||||
|
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||||
|
if(!$this->$name) {
|
||||||
|
$this->$name = new $classname($this->$idfield);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->$name->id) {
|
||||||
|
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||||
|
return $this->$name;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->$name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class PreordernotificationFileModel {
|
||||||
|
public $preordernotification_id;
|
||||||
|
public $file_id;
|
||||||
|
public $filename;
|
||||||
|
|
||||||
|
public $create_by = null;
|
||||||
|
public $edit_by = null;
|
||||||
|
public $create = null;
|
||||||
|
public $edit = null;
|
||||||
|
|
||||||
|
|
||||||
|
public static function create(Array $data) {
|
||||||
|
$model = new PreordernotificationFile();
|
||||||
|
|
||||||
|
foreach($data as $field => $value) {
|
||||||
|
if(property_exists(get_called_class(), $field)) {
|
||||||
|
$model ->$field = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$me = new User();
|
||||||
|
$me->loadMe();
|
||||||
|
|
||||||
|
if($model->create_by === null) {
|
||||||
|
$model->create_by = $me->id;
|
||||||
|
}
|
||||||
|
if($model->edit_by === null) {
|
||||||
|
$model->edit_by = $me->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAll() {
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$res = $db->select("PreordernotificationFile", "*", "1 = 1 ORDER BY preordernotification_id,file_id");
|
||||||
|
if($db->num_rows($res)) {
|
||||||
|
while($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new PreordernotificationFile($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFirst() {
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$res = $db->select("PreordernotificationFile", "*", "$where ORDER BY preordernotification_id,file_id LIMIT 1");
|
||||||
|
if($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new PreordernotificationFile($data);
|
||||||
|
if($item->id) {
|
||||||
|
return $item;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function count($filter) {
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$sql = "SELECT COUNT(*) as cnt FROM `PreordernotificationFile`
|
||||||
|
WHERE $where
|
||||||
|
";
|
||||||
|
|
||||||
|
mfLoghandler::singleton()->debug($sql);
|
||||||
|
$res = $db->query($sql);
|
||||||
|
if($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
return $data->cnt;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function search($filter, $limit=false) {
|
||||||
|
$items = [];
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
|
||||||
|
$sql = "SELECT PreordernotificationFile.* FROM `PreordernotificationFile`
|
||||||
|
WHERE $where
|
||||||
|
ORDER BY preordernotification_id,file_id
|
||||||
|
";
|
||||||
|
|
||||||
|
mfLoghandler::singleton()->debug($sql);
|
||||||
|
if(is_array($limit) && count($limit)) {
|
||||||
|
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||||
|
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||||
|
} elseif(is_numeric($count)) {
|
||||||
|
$sql .= " LIMIT ".$limit['count'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $db->query($sql);
|
||||||
|
if($db->num_rows($res)) {
|
||||||
|
while($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new PreordernotificationFile($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getSqlFilter($filter) {
|
||||||
|
$where = "1=1 ";
|
||||||
|
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
//var_dump($filter);exit;
|
||||||
|
if(array_key_exists("id", $filter)) {
|
||||||
|
$id = $db->escape($filter['id']);
|
||||||
|
if($id) {
|
||||||
|
$where .= " AND PreordernotificationFile.`id` = '$id'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("preordernotification_id", $filter)) {
|
||||||
|
$preordernotification_id = $filter['preordernotification_id'];
|
||||||
|
if(is_numeric($preordernotification_id)) {
|
||||||
|
$where .= " AND preordernotification_id=$preordernotification_id";
|
||||||
|
} elseif(is_array($preordernotification_id) && count($preordernotification_id)) {
|
||||||
|
$where .= " AND PreordernotificationFile.preordernotification_id IN (". implode(",", $preordernotification_id).")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(array_key_exists("file_id", $filter)) {
|
||||||
|
$file_id = $filter['file_id'];
|
||||||
|
if(is_numeric($file_id)) {
|
||||||
|
$where .= " AND PreordernotificationFile.file_id=$file_id";
|
||||||
|
} elseif(is_array($file_id) && count($file_id)) {
|
||||||
|
$where .= " AND PreordernotificationFile.file_id IN (". implode(",", $file_id).")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($filter, $where);exit;
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -46,6 +46,50 @@ class mfUpload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSavepath() {
|
||||||
|
return $this->savepath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSavepath($path) {
|
||||||
|
$this->savepath = $path;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOriginalFilename() {
|
||||||
|
return $this->original_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilename() {
|
||||||
|
return $this->filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFilename($name) {
|
||||||
|
$this->filename = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSize() {
|
||||||
|
return $this->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDirmode() {
|
||||||
|
return $this->dirmode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDirmode($mode) {
|
||||||
|
$this->dirmode = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilemode() {
|
||||||
|
return $this->filemode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFilemode($mode) {
|
||||||
|
$this->filemode = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMimetype() {
|
||||||
|
return $this->upload->getMimetype();
|
||||||
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
if(!$this->savepath) {
|
if(!$this->savepath) {
|
||||||
@@ -95,7 +139,7 @@ class mfUpload {
|
|||||||
$string = '';
|
$string = '';
|
||||||
|
|
||||||
for ($p = 0; $p < $length; $p++) {
|
for ($p = 0; $p < $length; $p++) {
|
||||||
$string .= $characters[mt_rand(0, strlen($characters))];
|
$string .= $characters[mt_rand(0, strlen($characters) -1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
$rand = uniqid(md5(rand()), true);
|
$rand = uniqid(md5(rand()), true);
|
||||||
@@ -133,44 +177,5 @@ class mfUpload {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSavepath() {
|
|
||||||
return $this->savepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSavepath($path) {
|
|
||||||
$this->savepath = $path;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOriginalFilename() {
|
|
||||||
return $this->original_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilename() {
|
|
||||||
return $this->filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilename($name) {
|
|
||||||
$this->filename = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSize() {
|
|
||||||
return $this->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDirmode() {
|
|
||||||
return $this->dirmode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDirmode($mode) {
|
|
||||||
$this->dirmode = $mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilemode() {
|
|
||||||
return $this->filemode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilemode($mode) {
|
|
||||||
$this->filemode = $mode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,15 +13,30 @@ class mfUpload_TmpFile {
|
|||||||
|
|
||||||
|
|
||||||
public function __construct($_file) {
|
public function __construct($_file) {
|
||||||
$this->log = mfLoghandler::singleton();
|
if(is_array($_file) && count($_file) == 2) {
|
||||||
|
$upload_name = $_file[0];
|
||||||
|
$index = $_file[1];
|
||||||
|
$upload = [
|
||||||
|
'name' => $_FILES[$upload_name]['name'][$index],
|
||||||
|
'full_path' => $_FILES[$upload_name]['full_path'][$index],
|
||||||
|
'type' => $_FILES[$upload_name]['type'][$index],
|
||||||
|
'tmp_name' => $_FILES[$upload_name]['tmp_name'][$index],
|
||||||
|
'error' => $_FILES[$upload_name]['error'][$index],
|
||||||
|
'size' => $_FILES[$upload_name]['size'][$index],
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$upload = $_FILES[$_file];
|
||||||
|
}
|
||||||
|
|
||||||
if(count($_FILES[$_file])) {
|
if(count($upload)) {
|
||||||
$this->_file = $_FILES[$_file];
|
$this->_file = $upload;
|
||||||
} else {
|
} else {
|
||||||
$this->errormessage = "Upload not found";
|
$this->errormessage = "Upload not found";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->filename = $this->_file['name'];
|
$this->filename = $this->_file['name'];
|
||||||
$this->error = $this->_file['error'];
|
$this->error = $this->_file['error'];
|
||||||
$this->tmp_name = $this->_file['tmp_name'];
|
$this->tmp_name = $this->_file['tmp_name'];
|
||||||
@@ -81,7 +96,7 @@ class mfUpload_TmpFile {
|
|||||||
$ext = strtolower(array_pop($parts));
|
$ext = strtolower(array_pop($parts));
|
||||||
|
|
||||||
if(!preg_match('/^'.MFUPLOAD_ALLOWED_EXTENSIONS.'$/i',$ext)) {
|
if(!preg_match('/^'.MFUPLOAD_ALLOWED_EXTENSIONS.'$/i',$ext)) {
|
||||||
$this->errormessage = "File type not allowed. Supported file types are ".ALLOWED_EXTENSIONS_STR;
|
$this->errormessage = "File type not allowed. Supported file types are ".MFUPLOAD_ALLOWED_EXTENSIONS_STR;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,12 @@ h1, h2, h3, h4, h5, h6 {
|
|||||||
background-color: #eee !important;
|
background-color: #eee !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* allow icons in custom-file label */
|
||||||
|
.custom-file-label::before {
|
||||||
|
font-family: "Font Awesome 6 Pro";
|
||||||
|
content: "\f56f";
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************
|
/**************************
|
||||||
* custom styles
|
* custom styles
|
||||||
|
|||||||
Reference in New Issue
Block a user