diff --git a/src/de/jost_net/JVerein/gui/action/MailVorlageZuweisenAction.java b/src/de/jost_net/JVerein/gui/action/MailVorlageZuweisenAction.java index 1c0dd8fdb..946d82adb 100644 --- a/src/de/jost_net/JVerein/gui/action/MailVorlageZuweisenAction.java +++ b/src/de/jost_net/JVerein/gui/action/MailVorlageZuweisenAction.java @@ -53,8 +53,8 @@ public void handleAction(Object context) throws ApplicationException if (context instanceof MitgliedskontoControl) { MitgliedskontoControl kto = (MitgliedskontoControl) context; - kto.getBetreff(null).setValue(mv.getBetreff()); - kto.getTxt(null).setValue(mv.getTxt()); + kto.getBetreff().setValue(mv.getBetreff()); + kto.getTxt().setValue(mv.getTxt()); } else if (context instanceof SpendenbescheinigungMailControl) { diff --git a/src/de/jost_net/JVerein/gui/control/FilterControl.java b/src/de/jost_net/JVerein/gui/control/FilterControl.java index 95f3ee7bb..3823e76d4 100644 --- a/src/de/jost_net/JVerein/gui/control/FilterControl.java +++ b/src/de/jost_net/JVerein/gui/control/FilterControl.java @@ -781,7 +781,7 @@ public CheckboxInput getOhneAbbucher() return ohneabbucher; } - public boolean isOhneAbbucher() + public boolean isOhneAbbucherAktiv() { return ohneabbucher != null; } diff --git a/src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java b/src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java index a34292bd7..a933295f2 100644 --- a/src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java +++ b/src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java @@ -21,13 +21,11 @@ import java.rmi.RemoteException; import java.sql.ResultSet; import java.sql.SQLException; -import java.text.ParseException; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.StringTokenizer; -import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; @@ -57,7 +55,6 @@ import de.willuhn.datasource.rmi.DBIterator; import de.willuhn.datasource.rmi.DBService; import de.willuhn.datasource.rmi.ResultSetExtractor; -import de.willuhn.jameica.gui.AbstractControl; import de.willuhn.jameica.gui.AbstractView; import de.willuhn.jameica.gui.Action; import de.willuhn.jameica.gui.GUI; @@ -86,7 +83,7 @@ import de.willuhn.logging.Logger; import de.willuhn.util.ApplicationException; -public class MitgliedskontoControl extends AbstractControl +public class MitgliedskontoControl extends FilterControl { public enum DIFFERENZ { @@ -115,8 +112,7 @@ public static DIFFERENZ fromString(final String text) } } - private Settings settings; - + // SollbuchungDetailView private DateInput datum = null; private TextAreaInput zweck1; @@ -127,54 +123,34 @@ public static DIFFERENZ fromString(final String text) private AbstractInput buchungsart; - private FormularInput formular = null; - - private Mitgliedskonto mkto; - - private TablePart mitgliedskontoList; - - private TablePart mitgliedskontoList2; - - private TreePart mitgliedskontoTree; - - public static final String DATUM_MITGLIEDSKONTO = "datum.mitgliedskonto."; - - // - // public static final String DATUM_RECHNUNG = "datum.rechnung."; - // - // public static final String DATUM_MAHNUNG = "datum.mahnung."; - + // MitgliedskontoMahnung/RechnungView public enum TYP { RECHNUNG, MAHNUNG } - - private String datumverwendung = null; - - private DateInput vondatum = null; - - private DateInput bisdatum = null; - - private CheckboxInput ohneabbucher = null; + private FormularInput formular = null; private SelectInput ausgabeart = null; private SelectInput ausgabesortierung = null; + + private TextInput betreff = null; - private TextInput suchname = null; + private TextAreaInput txt = null; + + private Mitgliedskonto mkto; - private TextInput suchname2 = null; + private TreePart mitgliedskontoTree; + + // SollbuchungListeView, SollbuchungAuswahldialog + private TablePart mitgliedskontoList; - private SelectInput differenz = null; + private TablePart mitgliedskontoList2; - private CheckboxInput spezialsuche1 = null; + private TextInput suchname2 = null; private CheckboxInput spezialsuche2 = null; - private TextInput betreff = null; - - private TextAreaInput txt = null; - // private CheckboxInput offenePosten = null; private MitgliedskontoMessageConsumer mc = null; @@ -182,6 +158,9 @@ public enum TYP private Action action; private boolean umwandeln; + + // KontoauszugView + private TextAreaInput info; public MitgliedskontoControl(AbstractView view) { @@ -310,71 +289,11 @@ public FormularInput getFormular(FormularArt mahnung) throws RemoteException return formular; } - public String getDatumverwendung() - { - return this.datumverwendung; - } - - public DateInput getVondatum(String datumverwendung) - { - if (vondatum != null) - { - return vondatum; - } - Date d = null; - this.datumverwendung = datumverwendung; - - String tmp = settings.getString(datumverwendung + "datumvon", null); - - if (tmp != null) - { - try - { - d = new JVDateFormatTTMMJJJJ().parse(tmp); - } - catch (ParseException e) - { - // - } - } - - this.vondatum = new DateInput(d, new JVDateFormatTTMMJJJJ()); - this.vondatum.setTitle("Anfangsdatum"); - this.vondatum.setText("Bitte Anfangsdatum wählen"); - return vondatum; - } - - public DateInput getBisdatum(String datumverwendung) - { - if (bisdatum != null) - { - return bisdatum; - } - this.datumverwendung = datumverwendung; - Date d = null; - String tmp = settings.getString(datumverwendung + "datumbis", null); - if (tmp != null) - { - try - { - d = new JVDateFormatTTMMJJJJ().parse(tmp); - } - catch (ParseException e) - { - // - } - } - this.bisdatum = new DateInput(d, new JVDateFormatTTMMJJJJ()); - this.bisdatum.setTitle("Endedatum"); - this.bisdatum.setText("Bitte Endedatum wählen"); - return bisdatum; - } - public Object[] getCVSExportGrenzen(Mitglied selectedMitglied) { return new Object[] { - getVondatum(MitgliedskontoControl.DATUM_MITGLIEDSKONTO).getValue(), - getBisdatum(MitgliedskontoControl.DATUM_MITGLIEDSKONTO).getValue(), + getDatumvon().getValue(), + getDatumbis().getValue(), getDifferenz().getValue(), getCVSExportGrenzeOhneAbbucher(), selectedMitglied }; } @@ -385,44 +304,6 @@ private Boolean getCVSExportGrenzeOhneAbbucher() return Boolean.FALSE; return (Boolean) ohneabbucher.getValue(); } - - public CheckboxInput getOhneAbbucher() - { - if (ohneabbucher != null) - { - return ohneabbucher; - } - ohneabbucher = new CheckboxInput(false); - return ohneabbucher; - } - - public CheckboxInput getSpezialSuche1() - { - if (spezialsuche1 != null && !spezialsuche1.getControl().isDisposed()) - { - return spezialsuche1; - } - spezialsuche1 = new CheckboxInput(false); - spezialsuche1.setName("Erlaube Teilstring Vergleich"); - spezialsuche1.addListener(new Listener() - { - - @Override - public void handleEvent(Event event) - { - try - { - refreshMitgliedkonto1(); - } - catch (RemoteException e) - { - Logger.error("Fehler", e); - } - } - }); - - return spezialsuche1; - } public CheckboxInput getSpezialSuche2() { @@ -452,37 +333,6 @@ public void handleEvent(Event event) return spezialsuche2; } - public SelectInput getDifferenz() - { - if (differenz != null) - { - return differenz; - } - DIFFERENZ defaultwert = DIFFERENZ - .fromString(settings.getString("differenz", DIFFERENZ.EGAL.toString())); - return getDifferenz(defaultwert); - } - - public SelectInput getDifferenz(DIFFERENZ defaultvalue) - { - differenz = new SelectInput(DIFFERENZ.values(), defaultvalue); - differenz.setName("Differenz"); - differenz.addListener(new FilterListener()); - return differenz; - } - - // Für SollbuchungListeView - public TextInput getSuchName() - { - if (suchname != null && !suchname.getControl().isDisposed()) - { - return suchname; - } - suchname = new TextInput(settings.getString("sollbuchung.suchname",""), 30); - suchname.setName("Name"); - return suchname; - } - // Für SollbuchungAuswahlDialog public TextInput getSuchName1(boolean newcontrol) { @@ -514,7 +364,7 @@ public SelectInput getAusgabeart() return ausgabeart; } ausgabeart = new SelectInput(Ausgabeart.values(), - Ausgabeart.valueOf(settings.getString("ausgabeart", "DRUCK"))); + Ausgabeart.valueOf(settings.getString(settingsprefix + "ausgabeart", "DRUCK"))); ausgabeart.setName("Ausgabe"); return ausgabeart; } @@ -526,66 +376,35 @@ public SelectInput getAusgabesortierung() return ausgabesortierung; } ausgabesortierung = new SelectInput(Ausgabesortierung.values(), - Ausgabesortierung.getByKey(settings.getInt("ausgabesortierung", 1))); + Ausgabesortierung.getByKey(settings.getInt(settingsprefix + "ausgabesortierung", 1))); ausgabesortierung.setName("Sortierung"); return ausgabesortierung; } - public TextInput getBetreff(String verwendung) + public TextInput getBetreff() { if (betreff != null) { return betreff; } betreff = new TextInput( - settings.getString(verwendung + ".mail.betreff", ""), 100); + settings.getString(settingsprefix + "mail.betreff", ""), 100); betreff.setName("Betreff"); return betreff; } - public TextAreaInput getTxt(String verwendung) + public TextAreaInput getTxt() { if (txt != null) { return txt; } - txt = new TextAreaInput(settings.getString(verwendung + ".mail.text", ""), + txt = new TextAreaInput(settings.getString(settingsprefix + "mail.text", ""), 10000); txt.setName("Text"); return txt; } - public void saveDefaults() - { - if (this.vondatum != null) - { - Date tmp = (Date) getVondatum("kontoauszugdatumvon").getValue(); - if (tmp != null) - { - settings.setAttribute("kontoauszugdatumvon", - new JVDateFormatTTMMJJJJ().format(tmp)); - } - else - { - settings.setAttribute("kontoauszugdatumvon", ""); - } - } - - if (this.bisdatum != null) - { - Date tmp = (Date) getBisdatum("kontoauszugdatumbis").getValue(); - if (tmp != null) - { - settings.setAttribute("kontoauszugdatumbis", - new JVDateFormatTTMMJJJJ().format(tmp)); - } - else - { - settings.setAttribute("kontoauszugbatumbis", ""); - } - } - } - public void handleStore() { try @@ -678,7 +497,6 @@ public TablePart getMitgliedskontoList(Action action, ContextMenu menu, boolean this.umwandeln = umwandeln; @SuppressWarnings("rawtypes") GenericIterator mitgliedskonten = getMitgliedskontoIterator(umwandeln); - settings.setAttribute(datumverwendung + "differenz", getDifferenz().getValue().toString()); if (mitgliedskontoList == null) { mitgliedskontoList = new SollbuchungListTablePart(mitgliedskonten, action); @@ -790,7 +608,6 @@ public void refreshMitgliedkonto1() throws RemoteException { @SuppressWarnings("rawtypes") GenericIterator mitgliedskonten = getMitgliedskontoIterator(umwandeln); - settings.setAttribute(datumverwendung + "differenz", getDifferenz().getValue().toString()); mitgliedskontoList.removeAll(); while (mitgliedskonten.hasNext()) { @@ -805,33 +622,21 @@ public GenericIterator getMitgliedskontoIterator(boolean umwandeln) throws Remot Date d1 = null; java.sql.Date vd = null; java.sql.Date bd = null; - if (vondatum != null) + if (datumvon != null) { - d1 = (Date) vondatum.getValue(); + d1 = (Date) datumvon.getValue(); if (d1 != null) { - settings.setAttribute(datumverwendung + "datumvon", - new JVDateFormatTTMMJJJJ().format(d1)); vd = new java.sql.Date(d1.getTime()); } - else - { - settings.setAttribute(datumverwendung + "datumvon", ""); - } } - if (bisdatum != null) + if (datumbis != null) { - d1 = (Date) bisdatum.getValue(); + d1 = (Date) datumbis.getValue(); if (d1 != null) { - settings.setAttribute(datumverwendung + "datumbis", - new JVDateFormatTTMMJJJJ().format(d1)); bd = new java.sql.Date(d1.getTime()); } - else - { - settings.setAttribute(datumverwendung + "datumbis", ""); - } } DIFFERENZ diff = DIFFERENZ.EGAL; @@ -1156,7 +961,7 @@ public void handleAction(Object context) } public Button getStartKontoauszugButton(final Object currentObject, - final DateInput von, final DateInput bis) + final MitgliedskontoControl control) { Button button = new Button("Starten", new Action() { @@ -1166,8 +971,9 @@ public void handleAction(Object context) { try { - saveDefaults(); - new Kontoauszug(currentObject, (Date) von.getValue(), (Date) bis.getValue()); + saveSettings(); + saveFilterSettings(); + new Kontoauszug(currentObject, control); } catch (Exception e) { @@ -1181,15 +987,8 @@ public void handleAction(Object context) private void generiereRechnung(Object currentObject) throws IOException { - Ausgabeart aa = (Ausgabeart) getAusgabeart().getValue(); - settings.setAttribute("ausgabeart", aa.toString()); - Ausgabesortierung as = (Ausgabesortierung) getAusgabesortierung() - .getValue(); - settings.setAttribute("ausgabesortierung", as.getKey()); - settings.setAttribute(TYP.RECHNUNG.name() + ".mail.betreff", - (String) getBetreff(TYP.RECHNUNG.name()).getValue()); - settings.setAttribute(TYP.RECHNUNG.name() + ".mail.text", - (String) getTxt(TYP.RECHNUNG.name()).getValue()); + saveSettings(); + saveFilterSettings(); new Rechnungsausgabe(this); } @@ -1222,46 +1021,49 @@ public void handleAction(Object context) private void generiereMahnung(Object currentObject) throws IOException { - Ausgabeart aa = (Ausgabeart) getAusgabeart().getValue(); - settings.setAttribute("ausgabeart", aa.toString()); - settings.setAttribute(TYP.MAHNUNG.name() + ".mail.betreff", - (String) getBetreff(TYP.MAHNUNG.name()).getValue()); - settings.setAttribute(TYP.MAHNUNG.name() + ".mail.text", - (String) getTxt(TYP.MAHNUNG.name()).getValue()); + saveSettings(); + saveFilterSettings(); new Mahnungsausgabe(this); } - - private class FilterListener implements Listener + + private void saveSettings() { - - @Override - public void handleEvent(Event event) + if (ausgabeart != null ) { - if (event.type == SWT.Selection || event.type != SWT.FocusOut) - { - try - { - getMitgliedskontoList(action, null, umwandeln); - } - catch (RemoteException e) - { - Logger.error("Fehler", e); - } - } + Ausgabeart aa = (Ausgabeart) getAusgabeart().getValue(); + settings.setAttribute(settingsprefix + "ausgabeart", aa.toString()); + } + if (ausgabesortierung != null) + { + Ausgabesortierung as = (Ausgabesortierung) getAusgabesortierung() + .getValue(); + settings.setAttribute(settingsprefix + "ausgabesortierung", as.getKey()); + } + if (betreff != null) + { + settings.setAttribute(settingsprefix + "mail.betreff", + (String) getBetreff().getValue()); + } + if (txt != null) + { + settings.setAttribute(settingsprefix + "mail.text", + (String) getTxt().getValue()); } } // Für Sollbuchungen View - public void refreshMitgliedskontoList() + public void TabRefresh() { - try - { - settings.setAttribute("sollbuchung.suchname", getSuchName().getValue().toString()); - getMitgliedskontoList(action, null, umwandeln); - } - catch (RemoteException e) + if (mitgliedskontoList != null) { - Logger.error("Fehler", e); + try + { + getMitgliedskontoList(action, null, umwandeln); + } + catch (RemoteException e) + { + Logger.error("Fehler", e); + } } } @@ -1376,5 +1178,53 @@ public void run() }); } } + + public TextAreaInput getInfo() throws RemoteException + { + if (info != null) + { + return info; + } + info = new TextAreaInput(getInfoText(getCurrentObject()), 10000); + info.setHeight(100); + info.setEnabled(false); + return info; + } + public String getInfoText(Object mitgliedArray) + { + Mitglied[] mitglieder = null; + if (mitgliedArray instanceof Mitglied) + { + mitglieder = new Mitglied[] { (Mitglied) mitgliedArray }; + } + else if (mitgliedArray instanceof Mitglied[]) + { + mitglieder = (Mitglied[]) mitgliedArray; + } + else + { + return ""; + } + + String text = "Es wurden " + mitglieder.length + + " Mitglieder ausgewählt" + + "\nFolgende Mitglieder haben keine Mailadresse:"; + try + { + for (Mitglied m: mitglieder) + { + if ( m.getEmail() == null || m.getEmail().isEmpty()) + { + text = text + "\n - " + m.getName() + + ", " + m.getVorname(); + } + } + } + catch (Exception ex) + { + GUI.getStatusBar().setErrorText("Fehler beim Ermitteln der Mitglieder"); + } + return text; + } } diff --git a/src/de/jost_net/JVerein/gui/control/MitgliedskontoNode.java b/src/de/jost_net/JVerein/gui/control/MitgliedskontoNode.java index 6fb558ace..c8aa33280 100644 --- a/src/de/jost_net/JVerein/gui/control/MitgliedskontoNode.java +++ b/src/de/jost_net/JVerein/gui/control/MitgliedskontoNode.java @@ -278,5 +278,15 @@ public void remove() parent.children.remove(this); } } + + public Double getSoll() + { + return soll; + } + + public Double getIst() + { + return ist; + } } diff --git a/src/de/jost_net/JVerein/gui/dialogs/SollbuchungAuswahlDialog.java b/src/de/jost_net/JVerein/gui/dialogs/SollbuchungAuswahlDialog.java index e5a775024..957f5b630 100755 --- a/src/de/jost_net/JVerein/gui/dialogs/SollbuchungAuswahlDialog.java +++ b/src/de/jost_net/JVerein/gui/dialogs/SollbuchungAuswahlDialog.java @@ -111,7 +111,6 @@ else if (item.getText().startsWith("Soll")) grNurIst.addLabelPair("Name", control.getSuchName1(false)); grNurIst.addLabelPair("Differenz", control.getDifferenz(DIFFERENZ.FEHLBETRAG)); - //grNurIst.addInput(control.getSpezialSuche1()); ButtonArea button1 = new ButtonArea(); suchen1 = new MyButton("Suchen", new Action() diff --git a/src/de/jost_net/JVerein/gui/view/AbstractMitgliedDetailView.java b/src/de/jost_net/JVerein/gui/view/AbstractMitgliedDetailView.java index 947b47345..03ea911e7 100644 --- a/src/de/jost_net/JVerein/gui/view/AbstractMitgliedDetailView.java +++ b/src/de/jost_net/JVerein/gui/view/AbstractMitgliedDetailView.java @@ -192,8 +192,6 @@ private void zeichneButtonArea(Composite parent) throws RemoteException DokumentationUtil.MITGLIED, false, "question-circle.png"); if (!control.getMitglied().isNewObject()) { - MitgliedskontoControl mkcontrol = new MitgliedskontoControl(this); - mkcontrol.getStartKontoauszugButton(control.getMitglied(), null, null); buttons.addButton(new Button("Kontoauszug", new KontoauszugAction(), control.getMitglied(), false, "file-invoice.png")); } diff --git a/src/de/jost_net/JVerein/gui/view/KontoauszugView.java b/src/de/jost_net/JVerein/gui/view/KontoauszugView.java index 8c91c5abb..3027e8ae9 100644 --- a/src/de/jost_net/JVerein/gui/view/KontoauszugView.java +++ b/src/de/jost_net/JVerein/gui/view/KontoauszugView.java @@ -17,11 +17,15 @@ package de.jost_net.JVerein.gui.view; import de.jost_net.JVerein.gui.action.DokumentationAction; +import de.jost_net.JVerein.gui.action.MailVorlageZuweisenAction; import de.jost_net.JVerein.gui.control.MitgliedskontoControl; import de.willuhn.jameica.gui.AbstractView; import de.willuhn.jameica.gui.GUI; +import de.willuhn.jameica.gui.parts.Button; import de.willuhn.jameica.gui.parts.ButtonArea; +import de.willuhn.jameica.gui.util.ColumnLayout; import de.willuhn.jameica.gui.util.LabelGroup; +import de.willuhn.jameica.gui.util.SimpleContainer; public class KontoauszugView extends AbstractView { @@ -32,17 +36,42 @@ public void bind() throws Exception GUI.getView().setTitle("Kontoauszug"); final MitgliedskontoControl control = new MitgliedskontoControl(this); + control.init("kontoauszug.", null, null); - LabelGroup group = new LabelGroup(getParent(), "Zeitraum"); - group.addLabelPair("Von", control.getVondatum("kontoauszug")); - group.addLabelPair("Bis", control.getBisdatum("kontoauszug")); + LabelGroup group = new LabelGroup(getParent(), "Filter"); + ColumnLayout cl = new ColumnLayout(group.getComposite(), 2); + SimpleContainer left = new SimpleContainer(cl.getComposite()); + left.addInput(control.getDifferenz()); + + SimpleContainer right = new SimpleContainer(cl.getComposite()); + right.addInput(control.getDatumvon()); + right.addInput(control.getDatumbis()); + + SimpleContainer cont1 = new SimpleContainer(getParent(), false); + cont1.addHeadline("Info"); + cont1.addInput(control.getInfo()); + + SimpleContainer cont = new SimpleContainer(getParent(), true); + cont.addHeadline("Parameter"); + + cont.addInput(control.getAusgabeart()); + + cont.addHeadline("Mail"); + cont.addInput(control.getBetreff()); + cont.addLabelPair("Text", control.getTxt()); + + ButtonArea fbuttons = new ButtonArea(); + fbuttons.addButton(control.getResetButton()); + fbuttons.addButton(control.getSpeichernButton()); + group.addButtonArea(fbuttons); ButtonArea buttons = new ButtonArea(); buttons.addButton("Hilfe", new DokumentationAction(), DokumentationUtil.KONTOAUSZUG, false, "question-circle.png"); - buttons.addButton(control.getStartKontoauszugButton(this.getCurrentObject(), - control.getVondatum("kontoauszugdatumvon"), - control.getBisdatum("kontoauszugdatumbis"))); + buttons.addButton(new Button("Mail-Vorlage", new MailVorlageZuweisenAction(), + control, false, "view-refresh.png")); + buttons.addButton(control.getStartKontoauszugButton( + this.getCurrentObject(), control)); buttons.paint(this.getParent()); } } diff --git a/src/de/jost_net/JVerein/gui/view/MitgliederSucheView.java b/src/de/jost_net/JVerein/gui/view/MitgliederSucheView.java index 8fae4163c..5c13e95d6 100644 --- a/src/de/jost_net/JVerein/gui/view/MitgliederSucheView.java +++ b/src/de/jost_net/JVerein/gui/view/MitgliederSucheView.java @@ -58,6 +58,10 @@ public void getFilter() throws RemoteException } left.addInput(control.getEigenschaftenAuswahl()); left.addInput(control.getBeitragsgruppeAusw()); + if (Einstellungen.getEinstellung().hasZusatzfelder()) + { + left.addInput(control.getZusatzfelderAuswahl()); + } SimpleContainer middle = new SimpleContainer(cl.getComposite()); middle.addInput(control.getSuchname()); @@ -71,11 +75,7 @@ public void getFilter() throws RemoteException right.addInput(control.getEintrittbis()); right.addInput(control.getAustrittvon()); right.addInput(control.getAustrittbis()); - - if (Einstellungen.getEinstellung().hasZusatzfelder()) - { - left.addInput(control.getZusatzfelderAuswahl()); - } + right.addInput(control.getMailauswahl()); ButtonArea buttons = new ButtonArea(); buttons.addButton(control.getProfileButton()); diff --git a/src/de/jost_net/JVerein/gui/view/MitgliedskontoMahnungView.java b/src/de/jost_net/JVerein/gui/view/MitgliedskontoMahnungView.java index f3891df97..4888f4db7 100644 --- a/src/de/jost_net/JVerein/gui/view/MitgliedskontoMahnungView.java +++ b/src/de/jost_net/JVerein/gui/view/MitgliedskontoMahnungView.java @@ -27,6 +27,7 @@ import de.willuhn.jameica.gui.GUI; import de.willuhn.jameica.gui.parts.Button; import de.willuhn.jameica.gui.parts.ButtonArea; +import de.willuhn.jameica.gui.util.LabelGroup; import de.willuhn.jameica.gui.util.SimpleContainer; public class MitgliedskontoMahnungView extends AbstractView @@ -38,25 +39,29 @@ public void bind() throws Exception GUI.getView().setTitle("Mahnung"); final MitgliedskontoControl control = new MitgliedskontoControl(this); - - SimpleContainer cont = new SimpleContainer(getParent(), true); - cont.addHeadline("Parameter"); + control.init(MitgliedskontoControl.TYP.MAHNUNG.name() + ".", null, null); + if (this.getCurrentObject() == null) { - cont.addLabelPair("Von Datum", - control.getVondatum(MitgliedskontoControl.TYP.MAHNUNG.name())); - cont.addLabelPair("Bis Datum", - control.getBisdatum(MitgliedskontoControl.TYP.MAHNUNG.name())); + LabelGroup group = new LabelGroup(getParent(), "Filter"); + group.addInput(control.getDatumvon()); + group.addInput(control.getDatumbis()); + + ButtonArea filterbuttons = new ButtonArea(); + filterbuttons.addButton(control.getResetButton()); + filterbuttons.addButton(control.getSpeichernButton()); + group.addButtonArea(filterbuttons); } - cont.addLabelPair("Formular", control.getFormular(FormularArt.MAHNUNG)); control.getDifferenz(DIFFERENZ.FEHLBETRAG); + SimpleContainer cont = new SimpleContainer(getParent(), true); + cont.addHeadline("Parameter"); + + cont.addLabelPair("Formular", control.getFormular(FormularArt.MAHNUNG)); cont.addInput(control.getAusgabeart()); - cont.addHeadline("Mail"); - cont.addInput(control.getBetreff(MitgliedskontoControl.TYP.MAHNUNG.name())); - cont.addLabelPair("Text", - control.getTxt(MitgliedskontoControl.TYP.MAHNUNG.name())); + cont.addInput(control.getBetreff()); + cont.addLabelPair("Text", control.getTxt()); ButtonArea buttons = new ButtonArea(); buttons.addButton("Hilfe", new DokumentationAction(), diff --git a/src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java b/src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java index 89e9f138d..29885a1e5 100644 --- a/src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java +++ b/src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java @@ -26,6 +26,7 @@ import de.willuhn.jameica.gui.GUI; import de.willuhn.jameica.gui.parts.Button; import de.willuhn.jameica.gui.parts.ButtonArea; +import de.willuhn.jameica.gui.util.LabelGroup; import de.willuhn.jameica.gui.util.SimpleContainer; public class MitgliedskontoRechnungView extends AbstractView @@ -37,26 +38,31 @@ public void bind() throws Exception GUI.getView().setTitle("Rechnung"); final MitgliedskontoControl control = new MitgliedskontoControl(this); + control.init(MitgliedskontoControl.TYP.RECHNUNG.name() + ".", null, null); - SimpleContainer cont = new SimpleContainer(getParent(), true); - cont.addHeadline("Parameter"); if (this.getCurrentObject() == null) { - cont.addLabelPair("Von Datum", - control.getVondatum(MitgliedskontoControl.TYP.RECHNUNG.name())); - cont.addLabelPair("Bis Datum", - control.getBisdatum(MitgliedskontoControl.TYP.RECHNUNG.name())); - cont.addLabelPair("Ohne Abbucher", control.getOhneAbbucher()); + LabelGroup group = new LabelGroup(getParent(), "Filter"); + group.addInput(control.getDatumvon()); + group.addInput(control.getDatumbis()); + group.addLabelPair("Ohne Abbucher", control.getOhneAbbucher()); + + ButtonArea filterbuttons = new ButtonArea(); + filterbuttons.addButton(control.getResetButton()); + filterbuttons.addButton(control.getSpeichernButton()); + group.addButtonArea(filterbuttons); } + + SimpleContainer cont = new SimpleContainer(getParent(), true); + cont.addHeadline("Parameter"); + cont.addLabelPair("Formular", control.getFormular(FormularArt.RECHNUNG)); cont.addInput(control.getAusgabeart()); cont.addInput(control.getAusgabesortierung()); cont.addHeadline("Mail"); - cont.addInput( - control.getBetreff(MitgliedskontoControl.TYP.RECHNUNG.name())); - cont.addLabelPair("Text", - control.getTxt(MitgliedskontoControl.TYP.RECHNUNG.name())); + cont.addInput(control.getBetreff()); + cont.addLabelPair("Text", control.getTxt()); ButtonArea buttons = new ButtonArea(); buttons.addButton("Hilfe", new DokumentationAction(), diff --git a/src/de/jost_net/JVerein/gui/view/NichtMitgliederSucheView.java b/src/de/jost_net/JVerein/gui/view/NichtMitgliederSucheView.java index 1d1f2b53e..5db66e5c3 100644 --- a/src/de/jost_net/JVerein/gui/view/NichtMitgliederSucheView.java +++ b/src/de/jost_net/JVerein/gui/view/NichtMitgliederSucheView.java @@ -62,6 +62,7 @@ public void getFilter() throws RemoteException right.addInput(control.getGeburtsdatumvon()); right.addInput(control.getGeburtsdatumbis()); right.addInput(control.getSuchGeschlecht()); + right.addInput(control.getMailauswahl()); ButtonArea buttons = new ButtonArea(); buttons.addButton(control.getResetButton()); diff --git a/src/de/jost_net/JVerein/gui/view/SollbuchungListeView.java b/src/de/jost_net/JVerein/gui/view/SollbuchungListeView.java index 4007be53f..1b012620f 100644 --- a/src/de/jost_net/JVerein/gui/view/SollbuchungListeView.java +++ b/src/de/jost_net/JVerein/gui/view/SollbuchungListeView.java @@ -23,12 +23,12 @@ import de.jost_net.JVerein.gui.control.MitgliedskontoControl; import de.jost_net.JVerein.gui.menu.Mitgliedskonto2Menu; import de.willuhn.jameica.gui.AbstractView; -import de.willuhn.jameica.gui.Action; import de.willuhn.jameica.gui.GUI; import de.willuhn.jameica.gui.parts.Button; import de.willuhn.jameica.gui.parts.ButtonArea; +import de.willuhn.jameica.gui.util.ColumnLayout; import de.willuhn.jameica.gui.util.LabelGroup; -import de.willuhn.util.ApplicationException; +import de.willuhn.jameica.gui.util.SimpleContainer; public class SollbuchungListeView extends AbstractView { @@ -39,25 +39,23 @@ public void bind() throws Exception GUI.getView().setTitle("Sollbuchungen"); final MitgliedskontoControl control = new MitgliedskontoControl(this); + control.init("sollbuchung.", null, null); + LabelGroup group = new LabelGroup(getParent(), "Filter"); - group.addInput(control.getSuchName()); - group.addLabelPair("Von", - control.getVondatum(MitgliedskontoControl.DATUM_MITGLIEDSKONTO)); - group.addLabelPair("Bis", - control.getBisdatum(MitgliedskontoControl.DATUM_MITGLIEDSKONTO)); - group.addLabelPair("Differenz", control.getDifferenz()); + ColumnLayout cl = new ColumnLayout(group.getComposite(), 2); + + SimpleContainer left = new SimpleContainer(cl.getComposite()); + left.addInput(control.getSuchname()); + left.addInput(control.getDifferenz()); + + SimpleContainer right = new SimpleContainer(cl.getComposite()); + right.addInput(control.getDatumvon()); + right.addInput(control.getDatumbis()); - ButtonArea button = new ButtonArea(); - Button suchen = new Button("Suchen", new Action() - { - @Override - public void handleAction(Object context) throws ApplicationException - { - control.refreshMitgliedskontoList(); - } - }, null, true, "search.png"); - button.addButton(suchen); - group.addButtonArea(button); + ButtonArea fbuttons = new ButtonArea(); + fbuttons.addButton(control.getResetButton()); + fbuttons.addButton(control.getSuchenButton()); + group.addButtonArea(fbuttons); control.getMitgliedskontoList(new MitgliedskontoSollbuchungEditAction(), new Mitgliedskonto2Menu(), false).paint(this.getParent()); diff --git a/src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java b/src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java index f4bdbbe42..a321f6c1e 100644 --- a/src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java +++ b/src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java @@ -113,8 +113,8 @@ public void aufbereitung(Formular formular) throws IOException break; case EMAIL: zos.close(); - new ZipMailer(file, (String) control.getBetreff(typ.name()).getValue(), - (String) control.getTxt(typ.name()).getValue()); + new ZipMailer(file, (String) control.getBetreff().getValue(), + (String) control.getTxt().getValue(), typ.name() + ".pdf"); break; } diff --git a/src/de/jost_net/JVerein/io/Kontoauszug.java b/src/de/jost_net/JVerein/io/Kontoauszug.java index f7ab941fc..1294a5f0f 100644 --- a/src/de/jost_net/JVerein/io/Kontoauszug.java +++ b/src/de/jost_net/JVerein/io/Kontoauszug.java @@ -17,10 +17,15 @@ package de.jost_net.JVerein.io; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.FileDialog; @@ -30,12 +35,16 @@ import com.itextpdf.text.Element; import de.jost_net.JVerein.Einstellungen; +import de.jost_net.JVerein.gui.control.MitgliedskontoControl; +import de.jost_net.JVerein.gui.control.MitgliedskontoControl.DIFFERENZ; import de.jost_net.JVerein.gui.control.MitgliedskontoNode; import de.jost_net.JVerein.io.Adressbuch.Adressaufbereitung; +import de.jost_net.JVerein.keys.Ausgabeart; import de.jost_net.JVerein.keys.Zahlungsweg; import de.jost_net.JVerein.rmi.Mitglied; import de.jost_net.JVerein.util.Dateiname; import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ; +import de.jost_net.JVerein.util.StringTool; import de.willuhn.datasource.GenericIterator; import de.willuhn.jameica.gui.GUI; @@ -52,30 +61,100 @@ private Kontoauszug() throws IOException, DocumentException { settings = new de.willuhn.jameica.system.Settings(this.getClass()); settings.setStoreWhenRead(true); - init(); - rpt = new Reporter(new FileOutputStream(file), 40, 20, 20, 40); } - public Kontoauszug(Object object, Date von, Date bis) throws Exception + public Kontoauszug(Object object, MitgliedskontoControl control) throws Exception { this(); - if (object instanceof Mitglied) + ArrayList mitglieder = new ArrayList<>(); + + if (object != null && object instanceof Mitglied) { - generiereMitglied((Mitglied) object, von, bis); + mitglieder.add((Mitglied) object); } - else if (object instanceof Mitglied[]) + else if (object != null && object instanceof Mitglied[]) { - Mitglied[] mitglieder = (Mitglied[]) object; - for (Mitglied m : mitglieder) - { - generiereMitglied(m, von, bis); - } + mitglieder = new ArrayList<>(Arrays.asList((Mitglied[]) object)); } - rpt.close(); - zeigeDokument(); + else + { + GUI.getStatusBar().setErrorText( + "Kein Mitglied ausgewählt. Vorgang abgebrochen."); + return; + } + + int anzahl = 0; + switch ((Ausgabeart) control.getAusgabeart().getValue()) + { + case DRUCK: + init("pdf"); + if (file == null) + { + return; + } + rpt = new Reporter(new FileOutputStream(file), 40, 20, 20, 40); + for (Mitglied mg : mitglieder) + { + if (generiereMitglied(mg, control)) + anzahl++; + } + if (anzahl == 0) + { + GUI.getStatusBar().setErrorText( + "Kein Mitglied erfüllt das Differenz Kriterium."); + file.delete(); + return; + } + rpt.close(); + zeigeDokument(); + break; + case EMAIL: + init("zip"); + if (file == null) + { + return; + } + ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file)); + for (Mitglied mg : mitglieder) + { + if (mg.getEmail() == null || mg.getEmail().isEmpty()) + { + continue; + } + File f = File.createTempFile(getDateiname(mg), ".pdf"); + rpt = new Reporter(new FileOutputStream(f), 40, 20, 20, 40); + if (generiereMitglied(mg, control) == false) + { + continue; + } + rpt.close(); + anzahl++; + zos.putNextEntry(new ZipEntry(getDateiname(mg) + ".pdf")); + FileInputStream in = new FileInputStream(f); + // buffer size + byte[] b = new byte[1024]; + int count; + while ((count = in.read(b)) > 0) + { + zos.write(b, 0, count); + } + in.close(); + } + zos.close(); + if (anzahl == 0) + { + GUI.getStatusBar().setErrorText( + "Kein Mitglied erfüllt das Differenz Kriterium."); + file.delete(); + return; + } + new ZipMailer(file, (String) control.getBetreff().getValue(), + (String) control.getTxt().getValue(), "Kontoauszug.pdf"); + break; + } } - private void init() throws IOException + private void init(String extension) throws IOException { FileDialog fd = new FileDialog(GUI.getShell(), SWT.SAVE); fd.setText("Ausgabedatei wählen."); @@ -85,26 +164,44 @@ private void init() throws IOException { fd.setFilterPath(path); } - fd.setFileName(new Dateiname("kontoauszug", "", Einstellungen - .getEinstellung().getDateinamenmuster(), "pdf").get()); - fd.setFilterExtensions(new String[] { "*.pdf" }); + fd.setFileName(new Dateiname("KONTOAUSZUG", "", Einstellungen + .getEinstellung().getDateinamenmuster(), extension).get()); + fd.setFilterExtensions(new String[] { "*." + extension }); String s = fd.open(); if (s == null || s.length() == 0) { return; } - if (!s.toLowerCase().endsWith(".pdf")) + if (!s.toLowerCase().endsWith("." + extension)) { - s = s + ".pdf"; + s = s + "*." + extension; } file = new File(s); settings.setAttribute("lastdir", file.getParent()); } - private void generiereMitglied(Mitglied m, Date von, Date bis) + private boolean generiereMitglied(Mitglied m, MitgliedskontoControl control) throws RemoteException, DocumentException { + DIFFERENZ diff = DIFFERENZ.EGAL; + if (control.isDifferenzAktiv() && control.getDifferenz().getValue() != null) + { + diff = (DIFFERENZ) control.getDifferenz().getValue(); + } + + MitgliedskontoNode node = new MitgliedskontoNode(m, (Date) control.getDatumvon().getValue(), + (Date) control.getDatumbis().getValue()); + + if (diff == DIFFERENZ.FEHLBETRAG && node.getIst() >= node.getSoll()) + { + return false; + } + if (diff == DIFFERENZ.UEBERZAHLUNG && node.getSoll() >= node.getIst()) + { + return false; + } + rpt.newPage(); rpt.add(Einstellungen.getEinstellung().getName(), 20); rpt.add( @@ -124,7 +221,6 @@ private void generiereMitglied(Mitglied m, Date von, Date bis) BaseColor.LIGHT_GRAY); rpt.createHeader(); - MitgliedskontoNode node = new MitgliedskontoNode(m, von, bis); generiereZeile(node); @SuppressWarnings("rawtypes") GenericIterator gi1 = node.getChildren(); @@ -141,6 +237,7 @@ private void generiereMitglied(Mitglied m, Date von, Date bis) } } rpt.closeTable(); + return true; } private void generiereZeile(MitgliedskontoNode node) @@ -171,4 +268,12 @@ private void zeigeDokument() GUI.getStatusBar().setSuccessText("Kontoauszug erstellt"); FileViewer.show(file); } + + String getDateiname(Mitglied m) throws RemoteException + { + String filename = m.getID() + "#"; + String email = StringTool.toNotNullString(m.getEmail()); + filename += email; + return filename; + } } \ No newline at end of file diff --git a/src/de/jost_net/JVerein/io/Mahnungsausgabe.java b/src/de/jost_net/JVerein/io/Mahnungsausgabe.java index 802e8c589..12ecc7102 100644 --- a/src/de/jost_net/JVerein/io/Mahnungsausgabe.java +++ b/src/de/jost_net/JVerein/io/Mahnungsausgabe.java @@ -25,6 +25,7 @@ import de.jost_net.JVerein.rmi.Formular; import de.jost_net.JVerein.rmi.Mitgliedskonto; import de.willuhn.datasource.GenericIterator; +import de.willuhn.jameica.gui.GUI; public class Mahnungsausgabe extends AbstractMitgliedskontoDokument { @@ -61,6 +62,13 @@ public Mahnungsausgabe(MitgliedskontoControl control) throws IOException } mks = getRechnungsempfaenger(mk); } + if (mks.size() == 0) + { + GUI.getStatusBar().setErrorText( + "Keine passenden Sollbuchungen gefunden."); + file.delete(); + return; + } aufbereitung(formular); try { diff --git a/src/de/jost_net/JVerein/io/Rechnungsausgabe.java b/src/de/jost_net/JVerein/io/Rechnungsausgabe.java index 0e65a5683..3535c3b7e 100644 --- a/src/de/jost_net/JVerein/io/Rechnungsausgabe.java +++ b/src/de/jost_net/JVerein/io/Rechnungsausgabe.java @@ -26,8 +26,8 @@ import de.jost_net.JVerein.keys.Zahlungsweg; import de.jost_net.JVerein.rmi.Formular; import de.jost_net.JVerein.rmi.Mitgliedskonto; -import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ; import de.willuhn.datasource.rmi.DBIterator; +import de.willuhn.jameica.gui.GUI; import de.willuhn.logging.Logger; public class Rechnungsausgabe extends AbstractMitgliedskontoDokument @@ -57,39 +57,23 @@ public Rechnungsausgabe(MitgliedskontoControl control) throws IOException DBIterator it = Einstellungen.getDBService() .createList(Mitgliedskonto.class); Date d = null; - if (control.getVondatum(control.getDatumverwendung()).getValue() != null) + if (control.isDatumvonAktiv() && control.getDatumvon().getValue() != null) { - d = (Date) control.getVondatum(control.getDatumverwendung()).getValue(); + d = (Date) control.getDatumvon().getValue(); if (d != null) { - control.getSettings().setAttribute( - control.getDatumverwendung() + "datumvon", - new JVDateFormatTTMMJJJJ().format(d)); + it.addFilter("datum >= ?", d); } - it.addFilter("datum >= ?", d); } - else + if (control.isDatumbisAktiv() && control.getDatumbis().getValue() != null) { - control.getSettings() - .setAttribute(control.getDatumverwendung() + "datumvon", ""); - } - if (control.getBisdatum(control.getDatumverwendung()).getValue() != null) - { - d = (Date) control.getBisdatum(control.getDatumverwendung()).getValue(); + d = (Date) control.getDatumbis().getValue(); if (d != null) { - control.getSettings().setAttribute( - control.getDatumverwendung() + "datumbis", - new JVDateFormatTTMMJJJJ().format(d)); + it.addFilter("datum <= ?", d); } - it.addFilter("datum <= ?", d); - } - else - { - control.getSettings() - .setAttribute(control.getDatumverwendung() + "datumbis", ""); } - if ((Boolean) control.getOhneAbbucher().getValue()) + if (control.isOhneAbbucherAktiv() && (Boolean) control.getOhneAbbucher().getValue()) { it.addFilter("zahlungsweg <> ?", Zahlungsweg.BASISLASTSCHRIFT); } @@ -103,6 +87,13 @@ public Rechnungsausgabe(MitgliedskontoControl control) throws IOException } mks = getRechnungsempfaenger(mk); } + if (mks.size() == 0) + { + GUI.getStatusBar().setErrorText( + "Keine passenden Sollbuchungen gefunden."); + file.delete(); + return; + } aufbereitung(formular); try { diff --git a/src/de/jost_net/JVerein/io/ZipMailer.java b/src/de/jost_net/JVerein/io/ZipMailer.java index d23af8bf1..0597aa1f0 100644 --- a/src/de/jost_net/JVerein/io/ZipMailer.java +++ b/src/de/jost_net/JVerein/io/ZipMailer.java @@ -53,7 +53,7 @@ */ public class ZipMailer { - public ZipMailer(final File zipfile, final String betreff, final String text) + public ZipMailer(final File zipfile, final String betreff, final String text, final String dateiname) { BackgroundTask t = new BackgroundTask() { @@ -112,7 +112,7 @@ public void run(ProgressMonitor monitor) throws ApplicationException } in.close(); ma.setAnhang(bos.toByteArray()); - ma.setDateiname("Rechnung.pdf"); + ma.setDateiname(dateiname); TreeSet anhang = new TreeSet<>(); anhang.add(ma);