From d2ceb7ead809b8ffb375613a22d92874f3ca74c5 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 26 Jan 2023 19:24:35 +0100 Subject: [PATCH] Saving Preordernotification and test email done --- Layout/default/Preordernotification/Form.php | 152 ++++++++-- Layout/default/Preordernotification/Index.php | 20 +- .../Emailnotification/Emailnotification.php | 16 +- application/File/File.php | 6 +- application/File/FileModel.php | 3 +- application/Preorder/PreorderModel.php | 12 + .../Preordernotification.php | 114 ++++++++ .../PreordernotificationController.php | 271 +++++++++++++++++- .../PreordernotificationModel.php | 3 +- .../PreordernotificationFile.php | 28 ++ .../PreordernotificationFileModel.php | 150 ++++++++++ lib/mvcfronk/mfUpload/mfUpload.php | 85 +++--- lib/mvcfronk/mfUpload/mfUpload_TmpFile.php | 25 +- public/assets/css/thetool.css | 6 + 14 files changed, 791 insertions(+), 100 deletions(-) create mode 100644 application/PreordernotificationFile/PreordernotificationFile.php create mode 100644 application/PreordernotificationFile/PreordernotificationFileModel.php diff --git a/Layout/default/Preordernotification/Form.php b/Layout/default/Preordernotification/Form.php index ee0b6a4e5..b36192766 100644 --- a/Layout/default/Preordernotification/Form.php +++ b/Layout/default/Preordernotification/Form.php @@ -7,8 +7,8 @@
@@ -24,19 +24,20 @@
-
"> + " enctype="multipart/form-data">
+

Empfänger

Die Aussendung wird an die Kontaktemailadresse aller Bestellungen versendet. Wählen Sie folgende Konditionen aus, um die Empfänger zu beschränken:

- +
- +
@@ -44,11 +45,11 @@
- + + + +
@@ -56,12 +57,12 @@
- + + + + +
@@ -82,19 +83,89 @@
-

Emailinhalt

-

Im folgenden Editor können Sie ein HTML-Email verfassen. Verwenden Sie as Menü und die Werkzeugleiste um den Text zu formatieren:

- +

Email

+ +

Im folgenden Editor können Sie ein HTML-Email verfassen. Verwenden Sie das Menü und die Werkzeugleiste um den Text zu formatieren.

+
+ + +
+

Dateianhänge

-
-
- - +
+
+
+ + +
+ files) && count($notification->files)): ?> +
+
+
+
    + files as $file): ?> +
  • filename?>
  • + +
+
+ +
+
+ + +
+
+ +
+
+ +

Versand

+
+ +
+ + tosend_date) : ""?>" /> + Emailversand wird zu diesem Zeitpunkt gestartet +
+
+ + +
+ +
+ +
+ +
+ +
+
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
@@ -105,7 +176,7 @@
- +
@@ -136,12 +207,12 @@ selector: '#body_html', language: 'de', skin: "tinymce-5", - plugins: 'link autolink lists table', + plugins: ' code link autolink lists table', paste_block_drop: true, 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', + 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: "/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" @@ -170,12 +241,33 @@ }); //$('#body_html').summernote('fontSizeUnit', "pt"); //$('#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({ - allowClear: true, - placeholder: "" - }); + 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(""); + } + } \ No newline at end of file diff --git a/Layout/default/Preordernotification/Index.php b/Layout/default/Preordernotification/Index.php index 964bbf5bf..1851e789d 100644 --- a/Layout/default/Preordernotification/Index.php +++ b/Layout/default/Preordernotification/Index.php @@ -24,7 +24,7 @@

Filter

- "> + ">
@@ -56,7 +56,7 @@ @@ -78,24 +78,28 @@ + - + + - + + - + - + + diff --git a/application/Emailnotification/Emailnotification.php b/application/Emailnotification/Emailnotification.php index ee8c10aa5..3b2e29286 100644 --- a/application/Emailnotification/Emailnotification.php +++ b/application/Emailnotification/Emailnotification.php @@ -7,6 +7,7 @@ class Emailnotification { private $headers = []; private $subject; private $body; + private $html; private $from_name = false; private $email_from = false; private $email_to = false; @@ -52,6 +53,10 @@ class Emailnotification { $this->body = $body; } + public function setHtmlBody($html) { + $this->html = $html; + } + public function setFrom($email, $name = false) { $this->email_from = $email; $this->from_name = $name; @@ -65,7 +70,7 @@ class Emailnotification { if(!$this->email_to) { return false; } - if(!$this->body) { + if(!$this->body && !$this->html) { return false; } if(!is_array($this->headers) || !count($this->headers)) { @@ -93,8 +98,13 @@ class Emailnotification { $mimeparams['head_charset']="utf-8"; $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; if(count($this->attachments)) { diff --git a/application/File/File.php b/application/File/File.php index 1eac539d0..512dee644 100644 --- a/application/File/File.php +++ b/application/File/File.php @@ -15,7 +15,11 @@ class File extends mfBaseModel { $id = $this->id; // 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)) { $this->log->warn(__CLASS__."::delete(): Error unlinking file ($path)"); } diff --git a/application/File/FileModel.php b/application/File/FileModel.php index d3d709180..5be0f2eb3 100644 --- a/application/File/FileModel.php +++ b/application/File/FileModel.php @@ -7,6 +7,7 @@ class FileModel { public $store_filename; public $orig_filename; public $subfolder; + public $mimetype; public $create_by = null; public $edit_by = null; @@ -66,7 +67,7 @@ class FileModel { } - public static function getFirst() { + public static function getFirst($filter) { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); diff --git a/application/Preorder/PreorderModel.php b/application/Preorder/PreorderModel.php index f2c6d9513..ad0708014 100644 --- a/application/Preorder/PreorderModel.php +++ b/application/Preorder/PreorderModel.php @@ -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)) { $ucode = FronkDB::singleton()->escape($filter['ucode']); if($ucode) { diff --git a/application/Preordernotification/Preordernotification.php b/application/Preordernotification/Preordernotification.php index 4e48c8682..a25e95a88 100644 --- a/application/Preordernotification/Preordernotification.php +++ b/application/Preordernotification/Preordernotification.php @@ -1,5 +1,119 @@ 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; + } } \ No newline at end of file diff --git a/application/Preordernotification/PreordernotificationController.php b/application/Preordernotification/PreordernotificationController.php index ca8c4dd61..609428b50 100644 --- a/application/Preordernotification/PreordernotificationController.php +++ b/application/Preordernotification/PreordernotificationController.php @@ -71,12 +71,12 @@ class PreordernotificationController extends mfBaseController { $filter['preordercampaign_id'] = $my_campaign_ids; } } - + //var_dump($filter);exit; $pagination['maxItems'] = PreordernotificationModel::count($filter); $notifications = PreordernotificationModel::search($filter, $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() { $id = $this->request->id; if(!is_numeric($id) || $id < 1) { - $this->layout()->setFlash("Vorbestellung nicht gefunden", "error"); - $this->redirect("Preordercampaign"); + $this->layout()->setFlash("Aussendung nicht gefunden", "error"); + $this->redirect("Preordernotification"); } - $preorder = new Preorder($id); - if(!$preorder->id) { - $this->layout()->setFlash("Vorbestellung nicht gefunden", "error"); - $this->redirect("Preordercampaign"); + $notification = new Preordernotification($id); + if(!$notification->id) { + $this->layout()->setFlash("Aussendung nicht gefunden", "error"); + $this->redirect("Preordernotification"); } - $this->request->set("preordercampaign_id", $preorder->preordercampaign_id); // needed in addAction() - $this->layout()->set("preorder", $preorder); + //var_dump($notification->filter);exit; - //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(); } + + 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]); + + } } \ No newline at end of file diff --git a/application/Preordernotification/PreordernotificationModel.php b/application/Preordernotification/PreordernotificationModel.php index f851e8a0d..063b10dee 100644 --- a/application/Preordernotification/PreordernotificationModel.php +++ b/application/Preordernotification/PreordernotificationModel.php @@ -1,13 +1,14 @@ $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; + } +} \ No newline at end of file diff --git a/application/PreordernotificationFile/PreordernotificationFileModel.php b/application/PreordernotificationFile/PreordernotificationFileModel.php new file mode 100644 index 000000000..5734b0767 --- /dev/null +++ b/application/PreordernotificationFile/PreordernotificationFileModel.php @@ -0,0 +1,150 @@ + $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; + } + +} \ No newline at end of file diff --git a/lib/mvcfronk/mfUpload/mfUpload.php b/lib/mvcfronk/mfUpload/mfUpload.php index b1a591a30..c9814d55f 100644 --- a/lib/mvcfronk/mfUpload/mfUpload.php +++ b/lib/mvcfronk/mfUpload/mfUpload.php @@ -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() { if(!$this->savepath) { @@ -95,7 +139,7 @@ class mfUpload { $string = ''; 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); @@ -133,44 +177,5 @@ class mfUpload { 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; - } } diff --git a/lib/mvcfronk/mfUpload/mfUpload_TmpFile.php b/lib/mvcfronk/mfUpload/mfUpload_TmpFile.php index 547ae1012..d3c8045c9 100644 --- a/lib/mvcfronk/mfUpload/mfUpload_TmpFile.php +++ b/lib/mvcfronk/mfUpload/mfUpload_TmpFile.php @@ -13,15 +13,30 @@ class mfUpload_TmpFile { 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])) { - $this->_file = $_FILES[$_file]; + if(count($upload)) { + $this->_file = $upload; } else { $this->errormessage = "Upload not found"; return false; } - + + + $this->filename = $this->_file['name']; $this->error = $this->_file['error']; $this->tmp_name = $this->_file['tmp_name']; @@ -81,7 +96,7 @@ class mfUpload_TmpFile { $ext = strtolower(array_pop($parts)); 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; } diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css index 21adadfb0..341894cbd 100644 --- a/public/assets/css/thetool.css +++ b/public/assets/css/thetool.css @@ -98,6 +98,12 @@ h1, h2, h3, h4, h5, h6 { 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
Versendet Kampagne Betreff Anzahl Empfänger Geplanter VersandVersendetBearbeitetErstellt
preordercampaign->name?>sent_date) ? date('d.m.Y', $notification->sent_date) : ""?>campaign->name?> subject?>recipient_count) ? "ca. ".$notification->recipient_count : ""?>recipient_count) ? $notification->recipient_count : ""?> tosend_date) ? date('d.m.Y', $notification->tosend_date) : "" ?>sent_date) ? date('d.m.Y', $notification->sent_date) : ""?>edit)?> (editor->name?>)create)?> (creator->name?>) sent_date): ?> - $camp->id])?>"> - $camp->id])?>" class="text-danger" onclick="if(!confirm('Aussendung wirklich löschen?')) return false;" title="Vorbestellkampagne Löschen"> + $notification->id])?>"> + $notification->id])?>" class="text-danger" onclick="if(!confirm('Aussendung wirklich löschen?')) return false;" title="Aussendung Löschen">