BrightSide Workbench Full Report + Source Code
CrmMenu.java
Go to the documentation of this file.
1 package org.turro.crm.zul.menu;
2 
3 import java.util.Date;
4 import java.util.HashMap;
5 import org.turro.annotation.ExternalMenu;
6 import org.turro.crm.entity.Customer;
7 import org.turro.crm.entity.SaleProspect;
8 import org.turro.crm.entity.Vendor;
9 import org.turro.menu.ElephantMenu;
10 import static org.turro.menu.ElephantMenu.showZulFile;
11 import org.turro.menu.ElephantMenuBar;
12 import org.turro.security.Permission;
13 import org.zkoss.zk.ui.event.Event;
14 import org.zkoss.zk.ui.event.EventListener;
15 
21 public class CrmMenu extends ElephantMenu {
22 
23  @Override
24  public void addToMenu(ElephantMenuBar bar) {
25  bar.addMenu("Commercial", Permission.from("sale-action","sale-prospect", "campaign", "customer", "vendor"))
26  .addSubmenu()
27  .addMenuitem("Sale actions", "appointment", "/crm/saleactions.zul", Permission.from("sale-prospect:list"))
28  .addMenuitem("Sale prospects", "sale", "/crm/saleprospects.zul", Permission.from("sale-prospect:list"))
29  .addMenuitem("Activity", "activity", "/crm/activity.zul", Permission.from("sale-prospect:list"))
30  .addMenuitem("Campaigns", "campaign", "/crm/campaigns.zul", Permission.from("campaign:list"))
31  .addMenuitem("Customers", "vendor", "/crm/customers.zul", Permission.from("customer:list"))
33  .addMenuitem("Vendors", "vendor", "/crm/vendors.zul", Permission.from("vendor:list"))
34  .addMenuitem("Formulas", "formula", "/crm/formulas.zul", Permission.from("formula:list"))
35  .addMenuitem("Touch points", "/crm/touchpoints.zul", Permission.from("touchpoint:list"))
36  .addMenuitem("Activity sectors", "sector", "/crm/activitysectors.zul", Permission.from("activity-sector:list"))
37  .addMenuitem("Technologies", "technology", "/crm/technologies.zul", Permission.from("activity-sector:list"))
39  .addMenuitem("New campaign", "campaign_new", (EventListener) (Event event) -> {
40  showCampaign(0L);
41  }, false, Permission.from("campaign:new"))
42  .addMenuitem("New sale prospect", "sale_new", (EventListener) (Event event) -> {
43  showSaleProspect(0L);
44  }, false, Permission.from("sale-prospect:new"))
45  .addMenuitem("New customer", "customer_new", (EventListener) (Event event) -> {
46  showCustomer(0L);
47  }, false, Permission.from("customer:new"))
48  .addMenuitem("New vendor", "vendor_new", (EventListener) (Event event) -> {
49  showVendor(0L);
50  }, false, Permission.from("vendor:new"));
51  }
52 
53  public static void showCustomer(long id) {
54  showEntity(id, "customerId", "Customer", "/crm/customer.zul");
55  }
56 
57  public static void showVendor(long id) {
58  showEntity(id, "vendorId", "Vendor", "/crm/vendor.zul");
59  }
60 
61  public static void showCampaign(Long id) {
62  showEntity(id, "campaignId", "Campaign", "/crm/campaign.zul");
63  }
64 
65  public static void showSaleProspect(Long id) {
66  showEntity(id, "saleProspectId", "Sale prospect", "/crm/saleprospect.zul");
67  }
68 
69  public static void showSaleActions(Vendor vendor, SaleProspect saleProspect) {
70  showSaleActions(vendor, saleProspect, null, null);
71  }
72 
73  public static void showSaleActions(Vendor vendor, SaleProspect saleProspect, Date from, Date to) {
74  HashMap<String, Object> map = new HashMap<String, Object>();
75  map.put("vendor", vendor);
76  map.put("salep", saleProspect);
77  map.put("from", from);
78  map.put("to", to);
79  showZulFile("Sale actions", "/crm/saleactions.zul", map);
80  }
81 
82  public static void showActivity(Vendor vendor, Customer customer, SaleProspect saleProspect) {
83  HashMap<String, Object> map = new HashMap<String, Object>();
84  map.put("vendor", vendor);
85  map.put("saleProspect", saleProspect);
86  map.put("customer", customer);
87  showZulFile("Activity", "/crm/activity.zul", map);
88  }
89 
90 }
91 
static void showSaleProspect(Long id)
Definition: CrmMenu.java:65
static void showSaleActions(Vendor vendor, SaleProspect saleProspect)
Definition: CrmMenu.java:69
void addToMenu(ElephantMenuBar bar)
Definition: CrmMenu.java:24
static void showVendor(long id)
Definition: CrmMenu.java:57
static void showCampaign(Long id)
Definition: CrmMenu.java:61
static void showActivity(Vendor vendor, Customer customer, SaleProspect saleProspect)
Definition: CrmMenu.java:82
static void showCustomer(long id)
Definition: CrmMenu.java:53
static void showSaleActions(Vendor vendor, SaleProspect saleProspect, Date from, Date to)
Definition: CrmMenu.java:73
ElephantMenu addMenu(String label)
static void showEntity(Object id, String attribute, String label, String include)
ElephantSubmenu addSubmenu()
static void showZulFile(String label, String include)
ElephantSubmenu addMenuitem(String label, String include)
static Permission from(String... roles)
Definition: Permission.java:79