BrightSide Workbench Full Report + Source Code
batchof/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.batchof.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, "batch.batch.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, "batch.batch.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, "batch.batch.receiptDate");
55  }
56  });
57  addField(new FilterField("Internal ID", 0L, FilterFieldOperator.FILTER_EQUAL) {
58  @Override
59  public void addConstraint(WhereClause wc) {
60  doAddConstraint(wc, "batch.id");
61  }
62  });
63  addField(new FilterField("Contract") {
64  @Override
65  protected HtmlBasedComponent createEditor() {
66  return new ContractCombobox();
67  }
68  @Override
69  public void addConstraint(WhereClause wc) {
70  doAddConstraint(wc, "batch.batch.contract");
71  }
72  });
73  addField(new FilterField("Contact") {
74  @Override
75  protected HtmlBasedComponent createEditor() {
76  return new ContactCombobox();
77  }
78  @Override
79  protected Object getEditorValue() {
80  Contact c = ((ContactCombobox) editor).getContact();
81  return c == null ? null : c.getId();
82  }
83  @Override
84  public void addConstraint(WhereClause wc) {
85  doAddConstraint(wc, "batch.batch.contract.contractor");
86  }
87  });
88  addField(new FilterField("View") {
89  @Override
90  protected HtmlBasedComponent createEditor() {
91  ViewListbox vl = new ViewListbox();
92  vl.setMold("select");
93  vl.setAllowNull(true);
94  return vl;
95  }
96  @Override
97  public void addConstraint(WhereClause wc) {
98  doAddConstraint(wc, "ifnull(batch.batch.forcedView, 0)");
99  }
100  });
101  addField(new FilterField("Amount", 0.0) {
102  @Override
103  public void addConstraint(WhereClause wc) {
104  doAddSubqueryConstraint(wc, "bacth.bacth.documentLines", "price");
105  }
106  });
107  addField(new FilterField("Quantity", 0.0) {
108  @Override
109  public void addConstraint(WhereClause wc) {
110  doAddSubqueryConstraint(wc, "bacth.bacth.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, "bacth.bacth.documentLines", "store");
121  }
122  });
123  addField(new FilterField("Concept", "") {
124  @Override
125  public void addConstraint(WhereClause wc) {
126  doAddSubqueryConstraint(wc, "bacth.bacth.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[] {"bacth.bacth.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[] {"bacth.bacth.registers", "sqx.bookRegisters"}, "bookOrder");
146  }
147  });
148  if(!loadPreferences(this.getClass().getName()+"_filter")) {
149  addCurrentField("Number");
150  }
151  }
152 
153 }
FilterField addField(FilterField filterField)
Definition: FilterGrid.java:62