Commit 9c503527 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Adding pagination to queue. Fixing some errors

parent 5ccd6a4c
......@@ -72,14 +72,13 @@ class QueueController extends ActionController {
* @param int $uid
*/
public function sendMailAction($uid) {
/** @var Mail $mail */
$mail = $this->mailRepository->findByUid($uid)->getFirst();
$mailService = new MailTemplateService();
$mailService->sendMailFromQueue($uid);
$message = LocalizationUtility::translate('backend.success', 'sg_mail');
$message = LocalizationUtility::translate('backend.success_mail', 'sg_mail');
$this->addFlashMessage($message, '', FlashMessage::OK);
$arguments = $this->request->getArguments();
$this->redirect('index', NULL, NULL, $arguments);
......
......@@ -142,6 +142,11 @@ class MailTemplateService {
*/
private $priority = Mail::PRIORITY_LOWEST;
/**
* @var string
*/
private $fromName = '';
/**
* @var \SGalinski\SgMail\Domain\Repository\TemplateRepository
*/
......@@ -409,14 +414,16 @@ class MailTemplateService {
$mail->setExtensionKey($extensionKey);
$mail->setTemplateName($templateName);
$mail->setFromAddress($this->fromAddress);
$mail->setFromName($this->fromName);
$mail->setToAddress($this->toAddresses);
$mail->setMailSubject($subject);
$mail->setMailBody($emailBody);
$mail->setPriority($priority);
$mail->setBccAddresses(implode(',', $this->bccAddresses));
$mail->setCcAddresses(implode(',', $this->ccAddresses));
$mail->setBccAddresses($this->bccAddresses);
$mail->setCcAddresses($this->ccAddresses);
$mail->setSent($sent);
$mail->setSendingTime($sendingTime);
$mail->setReplyTo($this->replyToAddress);
$mailRepository = $this->objectManager->get(MailRepository::class);
$mailRepository->add($mail);
......@@ -590,5 +597,14 @@ class MailTemplateService {
$this->setCcAddresses($template->getCc());
$this->setBccAddresses($template->getBcc());
$this->setReplyToAddress($template->getReplyTo());
$this->setFromName($template->getFromName());
$this->setReplyToAddress($template->getReplyTo());
}
/**
* @param string $fromName
*/
public function setFromName($fromName) {
$this->fromName = $fromName;
}
}
......@@ -65,6 +65,10 @@
<source>No Extension was registered</source>
<target>Es wurde noch keine Extension registriert</target>
</trans-unit>
<trans-unit id="backend.not_sent" approved="yes">
<source>Not Sent</source>
<target>Nicht versendet</target>
</trans-unit>
<trans-unit id="backend.priority" approved="yes">
<source>Priority</source>
<target>Priorität</target>
......@@ -85,6 +89,10 @@
<source>Send Preview Mail</source>
<target>Sende Vorschau-Mail</target>
</trans-unit>
<trans-unit id="backend.sending_time" approved="yes">
<source>Sending Time</source>
<target>Versendet am</target>
</trans-unit>
<trans-unit id="backend.sent" approved="yes">
<source>Sent</source>
<target>Versendet</target>
......
......@@ -51,6 +51,9 @@
<trans-unit id="backend.no_extension">
<source>No Extension was registered</source>
</trans-unit>
<trans-unit id="backend.not_sent">
<source>Not Sent</source>
</trans-unit>
<trans-unit id="backend.priority">
<source>Priority</source>
</trans-unit>
......@@ -66,6 +69,9 @@
<trans-unit id="backend.send_test">
<source>Send Preview Mail</source>
</trans-unit>
<trans-unit id="backend.sending_time">
<source>Sending Time</source>
</trans-unit>
<trans-unit id="backend.sent">
<source>Sent</source>
</trans-unit>
......
......@@ -6,37 +6,56 @@
</f:section>
<f:section name="main">
<f:flashMessages renderMode="div" />
<f:widget.paginate objects="{queue}" as="paginatedMails" configuration="{itemsPerPage: 10, insertAbove: 1, insertBelow: 1, maximumNumberOfLinks: 10}">
<table class="table table-hover">
<thead>
<tr>
<th><f:translate key="backend.toAddress" /></th>
<th><f:translate key="backend.fromAddress" /></th>
<th><f:translate key="backend.sent" /></th>
<th><f:translate key="backend.sending_time" /></th>
<th>cc</th>
<th>bcc</th>
<th></th>
</tr>
</thead>
<table class="table table-hover">
<thead>
<tr>
<th><f:translate key="backend.toAddress" /></th>
<th><f:translate key="backend.fromAddress" /></th>
<th><f:translate key="backend.sent" /></th>
<th><f:translate key="backend.priority" /></th>
<th></th>
</tr>
</thead>
<f:for each="{queue}" as="mail">
<tr>
<td>{mail.toAddress}</td>
<td>{mail.fromAddress}</td>
<td>{mail.sent}</td>
<td>{mail.priority}</td>
<td>
<f:if condition="{mail.sent} == '0'">
<f:then>
<f:link.action class="btn btn-primary" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Now</f:link.action>
</f:then>
<f:else>
<f:link.action class="btn btn-warning" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Again</f:link.action>
</f:else>
</f:if>
</td>
</tr>
</f:for>
</table>
<f:for each="{paginatedMails}" as="mail">
<tr>
<td>{mail.toAddress}</td>
<td>{mail.fromAddress}</td>
<td>
<f:if condition="{mail.sent} == '0'">
<f:then>
<f:translate key="backend.not_sent" />
</f:then>
<f:else>
<f:translate key="backend.sent" />
</f:else>
</f:if>
</td>
<td>
<f:format.date format="d.m.Y h:i:s">{mail.sendingTime}</f:format.date>
</td>
<td>
{mail.ccAddresses}
</td>
<td>
{mail.bccAddresses}
</td>
<td>
<f:if condition="{mail.sent} == '0'">
<f:then>
<f:link.action class="btn btn-primary" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Now</f:link.action>
</f:then>
<f:else>
<f:link.action class="btn btn-warning" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Again</f:link.action>
</f:else>
</f:if>
</td>
</tr>
</f:for>
</table>
</f:widget.paginate>
</f:section>
......@@ -7,3 +7,47 @@
vertical-align: top;
width: 300px;
}
.f3-widget-paginator {
display: inline-block;
border-radius: 4px;
margin: 20px 0px;
padding-left: 0px;
background-color: red;
}
.f3-widget-paginator > li {
display: inline;
}
.f3-widget-paginator > li > a,
.f3-widget-paginator > li.current {
position: relative;
float: left;
padding: 6px 12px;
margin-left: -1px;
text-decoration: none;
border: 1px solid #DDD;
background-color: #FFF;
color: #FF8700;
}
.f3-widget-paginator > li.current,
.f3-widget-paginator > li > a:hover,
.f3-widget-paginator > li > a:focus {
text-decoration: underline;
background-color: #EEE;
}
.f3-widget-paginator > li:first-child > a,
.f3-widget-paginator > li.current:first-child {
margin-left: 0px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.f3-widget-paginator > li:last-child > a,
.f3-widget-paginator > li.current:last-child {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment