BrightSide Workbench Full Report + Source Code
FinancialsCustomerSummary.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 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 
19 package org.turro.financials.command;
20 
21 import java.util.Collection;
22 import org.turro.annotation.ElephantPlugin;
23 import org.turro.elephant.context.Application;
24 import org.turro.elephant.db.WhereClause;
25 import org.turro.elephant.util.Images;
26 import org.turro.financials.db.FinancialsPU;
27 import org.turro.i18n.I_;
28 import org.turro.plugin.command.CustomerSummaryPlugin;
29 import org.turro.zkoss.label.LabelTypes;
30 import org.turro.zkoss.layout.GroupboxArrow;
31 import org.zkoss.zul.Hlayout;
32 import org.zkoss.zul.Image;
33 import org.zkoss.zul.Include;
34 
39 @ElephantPlugin
41 
42  private Collection<ContractPortfolio> active;
43 
44  @Override
45  protected void executePlugin() {
47  activeSales();
48  if(!active.isEmpty()) {
49  GroupboxArrow gba = new GroupboxArrow() {
50  @Override
51  protected void doFillContent() {
52  Include report = new Include("/WEB-INF/_zul/financials/contract/customerSummary.zul");
53  report.setDynamicProperty("active", active);
54  appendChild(report);
55  }
56  };
57  Hlayout hbox = new Hlayout();
58  gba.setCaption(hbox);
59  hbox.setSclass("z-valign-middle");
60  hbox.setValign("middle");
61  hbox.appendChild(new Image(Images.getImage("statement")));
62  hbox.appendChild(LabelTypes.getSoftLabel(I_.get("Portfolio")));
63  gba.setOpen(false);
64  addResult("financials", gba);
65  }
66  }
67 
68  private void activeSales() {
69  WhereClause wc = new WhereClause();
70  wc.addClause("select new org.turro.financials.command.ContractPortfolio(c) from Contract as c");
71  wc.addClause("where c.contractor = :contact");
72  wc.addNamedValue("contact", contact.getId());
73  active = new FinancialsPU().getResultList(wc);
74  }
75 
76 }
Object addResult(String key, Object value)
void addNamedValue(String name, Object value)
static String getImage(String image)
Definition: Images.java:36
static String get(String msg)
Definition: I_.java:41
static Label getSoftLabel(String value)
Definition: LabelTypes.java:28