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; } }