BrightSide Workbench Full Report + Source Code
DossierCustomerSummary.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.dossier.command;
20 
21 import java.util.Collection;
22 import org.turro.annotation.ElephantPlugin;
23 import org.turro.dossier.db.DossierPU;
24 import org.turro.dossier.entity.Dossier;
25 import org.turro.dossier.entity.DossierStatus;
26 import org.turro.elephant.context.Application;
27 import org.turro.elephant.db.WhereClause;
28 import org.turro.elephant.util.Images;
29 import org.turro.i18n.I_;
30 import org.turro.plugin.command.CustomerSummaryPlugin;
31 import org.turro.zkoss.label.LabelTypes;
32 import org.turro.zkoss.layout.GroupboxArrow;
33 import org.zkoss.zul.Hlayout;
34 import org.zkoss.zul.Image;
35 import org.zkoss.zul.Include;
36 
41 @ElephantPlugin
43 
44  private Collection<Dossier> active;
45 
46  @Override
47  protected void executePlugin() {
49  activeSales();
50  if(!active.isEmpty()) {
51  GroupboxArrow gba = new GroupboxArrow() {
52  @Override
53  protected void doFillContent() {
54  }
55  };
56  Hlayout hbox = new Hlayout();
57  gba.setCaption(hbox);
58  hbox.setSclass("z-valign-middle");
59  hbox.setValign("middle");
60  hbox.appendChild(new Image(Images.getImage("dossier")));
61  hbox.appendChild(LabelTypes.getSoftLabel(I_.get("Dossiers") + ":"));
62  hbox.appendChild(LabelTypes.getPreLabel(active.size() + " " + I_.get("Opened")));
63  Include report = new Include("/WEB-INF/_zul/dossier/customerSummary.zul");
64  report.setDynamicProperty("active", active);
65  gba.appendChild(report);
66  gba.setOpen(false);
67  addResult("dossier", gba);
68  }
69  }
70 
71  private void activeSales() {
72  WhereClause wc = new WhereClause();
73  wc.addClause("select distinct dossier from Dossier as dossier");
74  wc.addClause("join dossier.participants participant");
75  wc.addClause("where participant.idContact = :contact");
76  wc.addClause("and dossier.status = :status");
77  wc.addClause("order by dossier.description");
78  wc.addNamedValue("contact", contact.getId());
80  active = new DossierPU().getResultList(wc);
81  }
82 
83 }
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 getPreLabel(String value)
Definition: LabelTypes.java:52
static Label getSoftLabel(String value)
Definition: LabelTypes.java:28