BrightSide Workbench Full Report + Source Code
portfolio/filter/BatchOfFilterGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.financials.portfolio.filter;
19 
20 import org.turro.contacts.Contact;
21 import org.turro.contacts.util.ContactCombobox;
22 import org.turro.elephant.db.WhereClause;
23 import org.turro.financials.book.BookListbox;
24 import org.turro.financials.contract.ContractCombobox;
25 import org.turro.financials.view.ViewListbox;
26 import org.turro.zkoss.filter.FilterField;
27 import org.turro.zkoss.filter.FilterFieldOperator;
28 import org.turro.zkoss.filter.FilterGrid;
29 import org.zkoss.zk.ui.HtmlBasedComponent;
30 
35 public class BatchOfFilterGrid extends FilterGrid {
36 
37  public BatchOfFilterGrid() {
38  super();
40  @Override
41  public void addConstraint(WhereClause wc) {
42  doAddConstraint(wc, "doc.documentNumber");
43  }
44  });
45  addField(new FilterField("Date", new java.util.Date(new java.util.Date().getTime() - (1L * 30L * 24L * 60L * 60L * 1000L))) {
46  @Override
47  public void addConstraint(WhereClause wc) {
48  doAddConstraint(wc, "doc.documentDate");
49  }
50  });
51  addField(new FilterField("Receipt/Issue", new java.util.Date(new java.util.Date().getTime() - (1L * 30L * 24L * 60L * 60L * 1000L))) {
52  @Override
53  public void addConstraint(WhereClause wc) {
54  doAddConstraint(wc, "doc.receiptDate");
55  }
56  });
57  addField(new FilterField("Contract") {
58  @Override
59  protected HtmlBasedComponent createEditor() {
60  return new ContractCombobox();
61  }
62  @Override
63  public void addConstraint(WhereClause wc) {
64  doAddConstraint(wc, "doc.contract");
65  }
66  });
67  addField(new FilterField("Contact") {
68  @Override
69  protected HtmlBasedComponent createEditor() {
70  return new ContactCombobox();
71  }
72  @Override
73  protected Object getEditorValue() {
74  Contact c = ((ContactCombobox) editor).getContact();
75  return c == null ? null : c.getId();
76  }
77  @Override
78  public void addConstraint(WhereClause wc) {
79  doAddConstraint(wc, "doc.contract.contractor");
80  }
81  });
82  addField(new FilterField("View") {
83  @Override
84  protected HtmlBasedComponent createEditor() {
85  ViewListbox vl = new ViewListbox();
86  vl.setMold("select");
87  vl.setAllowNull(true);
88  return vl;
89  }
90  @Override
91  public void addConstraint(WhereClause wc) {
92  doAddConstraint(wc, "ifnull(doc.forcedView, 0)");
93  }
94  });
95  addField(new FilterField("Draft", true) {
96  @Override
97  public void addConstraint(WhereClause wc) {
98  doAddConstraint(wc, "doc.draft");
99  }
100  });
101  addField(new FilterField("Amount", 0.0) {
102  @Override
103  public void addConstraint(WhereClause wc) {
104  doAddSubqueryConstraint(wc, "doc.documentLines", "price");
105  }
106  });
107  addField(new FilterField("Quantity", 0.0) {
108  @Override
109  public void addConstraint(WhereClause wc) {
110  doAddSubqueryConstraint(wc, "doc.documentLines", "quantity");
111  }
112  });
113  addField(new FilterField("Store") {
114  @Override
115  protected HtmlBasedComponent createEditor() {
116  return new ContractCombobox();
117  }
118  @Override
119  public void addConstraint(WhereClause wc) {
120  doAddSubqueryConstraint(wc, "doc.documentLines", "store");
121  }
122  });
123  addField(new FilterField("Concept", "") {
124  @Override
125  public void addConstraint(WhereClause wc) {
126  doAddSubqueryConstraint(wc, "doc.documentLines", "concept");
127  }
128  });
129  addField(new FilterField("Book") {
130  @Override
131  protected HtmlBasedComponent createEditor() {
132  BookListbox bl = new BookListbox();
133  bl.setMold("select");
134  bl.setAllowNull(true);
135  return bl;
136  }
137  @Override
138  public void addConstraint(WhereClause wc) {
139  doAddSubqueryConstraint(wc, new String[] {"doc.registers", "sqx.bookRegisters"}, "bookDefinition");
140  }
141  });
142  addField(new FilterField("Book entry", 0L) {
143  @Override
144  public void addConstraint(WhereClause wc) {
145  doAddSubqueryConstraint(wc, new String[] {"doc.registers", "sqx.bookRegisters"}, "bookOrder");
146  }
147  });
148  if(!loadPreferences(this.getClass().getName()+"_filter")) {
149  // no default
150  }
151  }
152 
153 }
FilterField addField(FilterField filterField)
Definition: FilterGrid.java:62