Skip to content

Commit

Permalink
Spendenbescheinigung per Mail versenden, implementiert #191 (#218)
Browse files Browse the repository at this point in the history
* Zwischenstand

* Mailanhang speichern konfigurierbar

* Update Update0438.java

* Spendenbescheinigung per Mail versenden, implementiert #191

* Update progress

* Fix Exception bei druck von Spendenbescheinigung ohne Mitglied

* Update MailAnhangImpl.java

* Update SpendenbescheinigungPrintAction.java

* Infofeld sichtbar und Einstellung Text geaendert

* Jetzt schaut es besser aus
  • Loading branch information
JohannMaierhofer committed May 20, 2024
1 parent f1bc788 commit 0c52346
Show file tree
Hide file tree
Showing 13 changed files with 672 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.parts.TablePart;
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

/**
Expand Down Expand Up @@ -172,9 +171,8 @@ else if (context instanceof Spendenbescheinigung[])
Formular spendeformular = spb.getFormular();
if (spendeformular == null)
{
GUI.getStatusBar().setErrorText(
"Nicht alle Spendenbescheinigungen haben ein gültiges Formular!");
return;
String text = "Nicht alle Spendenbescheinigungen haben ein gültiges Formular!";
throw new ApplicationException(text);
}
}
}
Expand Down Expand Up @@ -246,8 +244,7 @@ else if (gc.get(GregorianCalendar.YEAR) == 2013)
{
String fehler = "Fehler beim Aufbereiten der Spendenbescheinigung ("
+ e.getMessage() + ")";
GUI.getStatusBar().setErrorText(fehler);
Logger.error(fehler, e);
throw new ApplicationException(fehler);
}
}

Expand Down Expand Up @@ -1300,7 +1297,11 @@ private void generiereSpendenbescheinigungStandardAb2014(
rpt.closeTable();
}

String email = spb.getMitglied().getEmail();
String email = null;
if (spb.getMitglied() != null)
{
email = spb.getMitglied().getEmail();
}
if ( (mailversand == false && Einstellungen.getEinstellung().getSpendenbescheinigungadresse())
|| (mailversand == true && Einstellungen.getEinstellung().getSpendenbescheinigungadresse()
&& (email == null || email.isEmpty()))
Expand Down
109 changes: 109 additions & 0 deletions src/de/jost_net/JVerein/gui/action/SpendenbescheinigungSendAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**********************************************************************
* Copyright (c) by Alexander Dippe
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not,
* see <http://www.gnu.org/licenses/>.
*
* https://openjverein.github.io
**********************************************************************/
package de.jost_net.JVerein.gui.action;

import de.jost_net.JVerein.gui.view.SpendenbescheinigungMailView;

import de.jost_net.JVerein.gui.dialogs.MailAbfrageDialog;
import de.jost_net.JVerein.gui.dialogs.MailAbfrageDialog.Auswahl;
import de.jost_net.JVerein.rmi.Spendenbescheinigung;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.parts.TablePart;
import de.willuhn.jameica.system.OperationCanceledException;
import de.willuhn.util.ApplicationException;

/**
* E-Mail senden Formular anhand des zugewiesenen Spenders
*/
public class SpendenbescheinigungSendAction implements Action
{
private de.willuhn.jameica.system.Settings settings;

public SpendenbescheinigungSendAction()
{
super();
settings = new de.willuhn.jameica.system.Settings(this.getClass());
settings.setStoreWhenRead(true);
}

/**
* Versenden einer E-Mail mit der Spendenbescheinigung im Anhang
* für Mitglieder deren Spendenbescheinigung im View ausgewählt ist.
*/
@Override
public void handleAction(Object context) throws ApplicationException
{
Spendenbescheinigung[] spbArr = null;
// Prüfung des Contexs, vorhanden, eine oder mehrere
if (context instanceof TablePart)
{
TablePart tp = (TablePart) context;
context = tp.getSelection();
}
if (context == null)
{
throw new ApplicationException("Keine Spendenbescheinigung ausgewählt");
}
else if (context instanceof Spendenbescheinigung)
{
spbArr = new Spendenbescheinigung[] { (Spendenbescheinigung) context };
}
else if (context instanceof Spendenbescheinigung[])
{
spbArr = (Spendenbescheinigung[]) context;
}
else
{
return;
}

try
{
String text = "Für das Versenden werden gedruckte Spendenbescheinigungen benötigt."
+ "\nWenn sie schon gedruckt wurden brauchen sie nicht neu gedruckt werden.";
MailAbfrageDialog d = new MailAbfrageDialog(text, MailAbfrageDialog.POSITION_CENTER);
d.setTitle("Spendenbescheinigungen versenden");
d.setPanelText("Spendenbescheinigungen drucken?");

MailAbfrageDialog.Auswahl choice = (MailAbfrageDialog.Auswahl) d.open();
if (choice == null)
{
return;
}
else if (choice == Auswahl.DRUCKEN_STANDARD)
{
SpendenbescheinigungPrintAction action = new SpendenbescheinigungPrintAction(true, true);
action.handleAction(spbArr);
}
else if (choice == Auswahl.DRUCKEN_INDIVIDUELL)
{
SpendenbescheinigungPrintAction action = new SpendenbescheinigungPrintAction(false, true);
action.handleAction(spbArr);
}

GUI.startView(SpendenbescheinigungMailView.class, spbArr);
}
catch (OperationCanceledException oce)
{
throw oce;
}
catch (Exception e)
{
GUI.getStatusBar().setErrorText(e.getMessage());
}
}
}
13 changes: 13 additions & 0 deletions src/de/jost_net/JVerein/gui/control/EinstellungControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ public class EinstellungControl extends AbstractControl
private CheckboxInput unterschriftdrucken;

private ImageInput unterschrift;

private CheckboxInput anhangspeichern;


private IntegerInput qrcodesize;
Expand Down Expand Up @@ -1964,6 +1966,16 @@ public ImageInput getUnterschrift() throws RemoteException
unterschrift = new ImageInput(Einstellungen.getEinstellung().getUnterschrift(), 400, 75);
return unterschrift;
}

public CheckboxInput getAnhangSpeichern() throws RemoteException
{
if (anhangspeichern != null)
{
return anhangspeichern;
}
anhangspeichern = new CheckboxInput(Einstellungen.getEinstellung().getAnhangSpeichern());
return anhangspeichern;
}

public void handleStoreAllgemein()
{
Expand Down Expand Up @@ -2135,6 +2147,7 @@ public void handleStoreSpendenbescheinigungen()
e.setSpendenbescheinigungadressem((Boolean) getSpendenbescheinigungadressem().getValue());
e.setUnterschriftdrucken((Boolean) unterschriftdrucken.getValue());
e.setUnterschrift((byte[]) unterschrift.getValue());
e.setAnhangSpeichern((Boolean) anhangspeichern.getValue());
e.store();
Einstellungen.setEinstellung(e);
GUI.getStatusBar().setSuccessText("Einstellungen gespeichert");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public void handleAction(Object context) throws ApplicationException
GUI.getStatusBar().setSuccessText("Spendenbescheinigung erstellt");
FileViewer.show(file);
}
catch (RemoteException e)
catch (Exception e)
{
Logger.error(e.getMessage());
throw new ApplicationException(
Expand Down
Loading

0 comments on commit 0c52346

Please sign in to comment.