Skip to content

Commit

Permalink
Filter für Anfangsbestände View (#237)
Browse files Browse the repository at this point in the history
* Filter für Anfangsbestand View

* unnoetige Zeile loeschen
  • Loading branch information
JohannMaierhofer committed Jun 14, 2024
1 parent 40dde85 commit 4227384
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 16 deletions.
63 changes: 48 additions & 15 deletions src/de/jost_net/JVerein/gui/control/AnfangsbestandControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import de.jost_net.JVerein.rmi.Konto;
import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.datasource.rmi.DBService;
import de.willuhn.jameica.gui.AbstractControl;
import de.willuhn.jameica.gui.AbstractView;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.Part;
Expand All @@ -41,11 +39,9 @@
import de.willuhn.logging.Logger;
import de.willuhn.util.ApplicationException;

public class AnfangsbestandControl extends AbstractControl
public class AnfangsbestandControl extends FilterControl
{

private de.willuhn.jameica.system.Settings settings;

private TablePart anfangsbestandList;

private TextInput konto;
Expand Down Expand Up @@ -151,12 +147,11 @@ public void handleStore()

public Part getAnfangsbestandList() throws RemoteException
{
DBService service = Einstellungen.getDBService();
DBIterator<Anfangsbestand> anfangsbestaende = service
.createList(Anfangsbestand.class);
anfangsbestaende.setOrder("ORDER BY konto, datum desc");

anfangsbestandList = new TablePart(anfangsbestaende,
if (anfangsbestandList != null)
{
return anfangsbestandList;
}
anfangsbestandList = new TablePart(getAnfangsstaende(),
new AnfangsbestandDetailAction());
anfangsbestandList.addColumn("Konto", "kontotext");
anfangsbestandList.addColumn("Datum", "datum",
Expand All @@ -170,15 +165,53 @@ public Part getAnfangsbestandList() throws RemoteException
return anfangsbestandList;
}

public void refreshTable() throws RemoteException
public void TabRefresh()
{
if (anfangsbestandList == null)
{
return;
}
anfangsbestandList.removeAll();
try
{
DBIterator<Anfangsbestand> anfangsbestaende = getAnfangsstaende();
while (anfangsbestaende.hasNext())
{
anfangsbestandList.addItem(anfangsbestaende.next());
}
}
catch (RemoteException e1)
{
Logger.error("Fehler", e1);
}
}

private DBIterator<Anfangsbestand> getAnfangsstaende() throws RemoteException
{
DBIterator<Anfangsbestand> anfangsbestaende = Einstellungen.getDBService()
.createList(Anfangsbestand.class);
anfangsbestaende.setOrder("ORDER BY konto, datum desc");
while (anfangsbestaende.hasNext())
anfangsbestaende.join("konto");
anfangsbestaende.addFilter("konto.id = anfangsbestand.konto");
if (isSuchnameAktiv() && getSuchname().getValue() != null)
{
String tmpSuchname = (String) getSuchname().getValue();
if (tmpSuchname.length() > 0)
{
anfangsbestaende.addFilter("(lower(bezeichnung) like ?)",
new Object[] { "%" + tmpSuchname.toLowerCase() + "%"});
}
}
if (isDatumvonAktiv() && getDatumvon().getValue() != null)
{
anfangsbestandList.addItem(anfangsbestaende.next());
anfangsbestaende.addFilter("datum >= ?",
new Object[] { (Date) getDatumvon().getValue() });
}
if (isDatumbisAktiv() && getDatumbis().getValue() != null)
{
anfangsbestaende.addFilter("datum <= ?",
new Object[] { (Date) getDatumbis().getValue() });
}
anfangsbestaende.setOrder("ORDER BY konto, datum desc");
return anfangsbestaende;
}
}
20 changes: 19 additions & 1 deletion src/de/jost_net/JVerein/gui/view/AnfangsbestandListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import de.willuhn.jameica.gui.AbstractView;
import de.willuhn.jameica.gui.GUI;
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 AnfangsbestandListView extends AbstractView
{
Expand All @@ -32,13 +35,28 @@ public void bind() throws Exception
GUI.getView().setTitle("Anfangsbestände");

AnfangsbestandControl control = new AnfangsbestandControl(this);

LabelGroup group = new LabelGroup(getParent(), "Filter");
ColumnLayout cl = new ColumnLayout(group.getComposite(), 2);

SimpleContainer left = new SimpleContainer(cl.getComposite());
left.addLabelPair("Konto", control.getSuchname());

SimpleContainer right = new SimpleContainer(cl.getComposite());
right.addInput(control.getDatumvon());
right.addInput(control.getDatumbis());

ButtonArea fbuttons = new ButtonArea();
fbuttons.addButton(control.getResetButton());
fbuttons.addButton(control.getSuchenButton());
group.addButtonArea(fbuttons);

control.getAnfangsbestandList().paint(this.getParent());

ButtonArea buttons = new ButtonArea();
buttons.addButton("Hilfe", new DokumentationAction(),
DokumentationUtil.ANFANGSBESTAENDE, false, "question-circle.png");
buttons.addButton("Neu", new AnfangsbestandNeuAction(), null, true,
buttons.addButton("Neu", new AnfangsbestandNeuAction(), null, false,
"document-new.png");
buttons.paint(this.getParent());
}
Expand Down

0 comments on commit 4227384

Please sign in to comment.