BrightSide Workbench Full Report + Source Code
SaleActionComposer.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.crm.zul.sale;
20 
21 import java.util.Date;
22 import org.turro.contacts.zul.label.ContactInfo;
23 import org.turro.crm.entity.SaleProspect;
24 import org.turro.crm.entity.Vendor;
25 import org.turro.crm.zul.vendor.AssignedListbox;
26 import org.turro.crm.zul.vendor.VendorCombobox;
27 import org.turro.elephant.context.Application;
28 import org.turro.elephant.util.Images;
29 import org.zkoss.zk.ui.Component;
30 import org.zkoss.zk.ui.Executions;
31 import org.zkoss.zk.ui.util.GenericForwardComposer;
32 import org.zkoss.zul.Label;
33 
38 public class SaleActionComposer extends GenericForwardComposer {
39 
40  private VendorCombobox vendor;
41  private AssignedListbox saleps;
42  private Label description;
43  private ContactInfo customer;
44  private SaleActionGrid actions;
45 
46  public void onSelect$vendor() {
47  saleps.setVendor(vendor.getObjectValue());
48  saleps.setObjectValue(null);
49  }
50 
51  public void onSelect$saleps() {
52  SaleProspect sp = saleps.getObjectValue();
53  actions.setSaleProspect(sp);
54  actions.setFrom((Date) Executions.getCurrent().getAttribute("from"));
55  actions.setTo((Date) Executions.getCurrent().getAttribute("to"));
56  actions.refresh();
57  if(sp != null) {
58  if(sp.getCustomer() != null) {
59  customer.setIContact(sp.getCustomer().getIContact());
60  } else {
61  customer.setIContact(null);
62  }
63  customer.setImage(Images.getImage("customer"));
64  description.setValue(sp.getDescription());
65  } else {
66  customer.setIContact(null);
67  description.setValue(null);
68  }
69  }
70 
71  @Override
72  public void doAfterCompose(Component comp) throws Exception {
73  super.doAfterCompose(comp);
74  saleps.setAllowNull(true);
75  Vendor v = (Vendor) Executions.getCurrent().getAttribute("vendor");
76  if(v == null) {
77  vendor.setSelectSelf(true);
78  } else {
79  vendor.setObjectValue(v);
80  }
81  onSelect$vendor();
82  vendor.setReadonly(!Application.getApplication().isInRole("sale-action:all"));
83  SaleProspect sp = (SaleProspect) Executions.getCurrent().getAttribute("salep");
84  saleps.setObjectValue(sp);
85  onSelect$saleps();
86  }
87 
88 }
final void setIContact(IContact icontact)
void setSaleProspect(SaleProspect saleProspect)
void setSelectSelf(boolean selectSelf)
static String getImage(String image)
Definition: Images.java:36