Skip to content

Commit

Permalink
Fix Mailfilter (#266)
Browse files Browse the repository at this point in the history
* Zwischenstand

* Update MailControl.java
  • Loading branch information
JohannMaierhofer authored Jul 26, 2024
1 parent 1538b04 commit 1efa8cb
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/de/jost_net/JVerein/gui/control/MailControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.TreeSet;
Expand Down Expand Up @@ -652,18 +653,20 @@ private DBIterator<Mail> getMails() throws RemoteException
{
DBService service = Einstellungen.getDBService();
DBIterator<Mail> mails = service.createList(Mail.class);
mails.join("mailempfaenger");
mails.addFilter("mailempfaenger.mail = mail.id");
mails.join("mitglied");
mails.addFilter("mitglied.id = mailempfaenger.mitglied");


if (isSuchnameAktiv() && getSuchname().getValue() != null)
{
String tmpSuchname = (String) getSuchname().getValue();
if (tmpSuchname.length() > 0)
{
mails.addFilter("(lower(betreff) like ?)",
new Object[] { "%" + tmpSuchname.toLowerCase() + "%" });
mails.join("mailempfaenger");
mails.addFilter("mailempfaenger.mail = mail.id");
mails.join("mitglied");
mails.addFilter("mitglied.id = mailempfaenger.mitglied");
mails.addFilter("(lower(name) like ? or lower(vorname) like ?) ",
new Object[] { "%" + tmpSuchname.toLowerCase() + "%",
"%" + tmpSuchname.toLowerCase() + "%"});
}
}
if (isSuchtextAktiv() && getSuchtext().getValue() != null)
Expand All @@ -682,8 +685,11 @@ private DBIterator<Mail> getMails() throws RemoteException
}
if (isEingabedatumbisAktiv() && getEingabedatumbis().getValue() != null)
{
Date d = (Date) getEingabedatumbis().getValue();
mails.addFilter("bearbeitung <= ?", new Object[] { new java.sql.Date(d.getTime()) });
Calendar cal = Calendar.getInstance();
cal.setTime((Date) getEingabedatumbis().getValue());
cal.add(Calendar.DAY_OF_MONTH, 1);
mails.addFilter("bearbeitung <= ?",
new Object[] { new java.sql.Date(cal.getTimeInMillis()) });
}
if (isDatumvonAktiv() && getDatumvon().getValue() != null)
{
Expand All @@ -692,8 +698,11 @@ private DBIterator<Mail> getMails() throws RemoteException
}
if (isDatumbisAktiv() && getDatumbis().getValue() != null)
{
Date d = (Date) getDatumbis().getValue();
mails.addFilter("mail.versand <= ?", new Object[] { new java.sql.Date(d.getTime()) });
Calendar cal = Calendar.getInstance();
cal.setTime((Date) getDatumbis().getValue());
cal.add(Calendar.DAY_OF_MONTH, 1);
mails.addFilter("mail.versand <= ?",
new Object[] { new java.sql.Date(cal.getTimeInMillis()) });
}
mails.setOrder("ORDER BY betreff");

Expand Down

0 comments on commit 1efa8cb

Please sign in to comment.