00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.openmobileis.examples.mycrm.terminal.services;
00026
00027 import java.io.IOException;
00028
00029 import javax.servlet.ServletException;
00030 import javax.servlet.http.HttpServletRequest;
00031 import javax.servlet.http.HttpServletResponse;
00032
00033 import org.openmobileis.common.intl.IntlResourceManager;
00034 import org.openmobileis.common.util.collection.Array;
00035 import org.openmobileis.common.util.exception.DatabaseException;
00036 import org.openmobileis.common.util.log.LogManager;
00037 import org.openmobileis.examples.mycrm.data.Account;
00038 import org.openmobileis.examples.mycrm.data.Contact;
00039 import org.openmobileis.examples.mycrm.data.Leads;
00040 import org.openmobileis.examples.mycrm.data.Report;
00041 import org.openmobileis.examples.mycrm.data.fodb.AccountFactory;
00042 import org.openmobileis.examples.mycrm.data.fodb.LeadsFactory;
00043 import org.openmobileis.modules.common.data.LabelManager;
00044 import org.openmobileis.services.TemplateService;
00045 import org.openmobileis.services.common.ServiceManager;
00046 import org.openmobileis.services.navigation.NavigationBarService;
00047
00048 import freemarker.template.SimpleHash;
00049 import freemarker.template.SimpleList;
00050 import freemarker.template.SimpleScalar;
00051 import freemarker.template.TemplateModelRoot;
00052
00061 public final class DisplayLeadsService extends TemplateService implements NavigationBarService {
00062
00066 public DisplayLeadsService() {
00067 super();
00068 }
00069
00070
00071
00072
00073
00074
00075
00076
00077 public String runTemplate(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot templateData) throws ServletException, IOException {
00078 String leadid = req.getParameter("leadid");
00079 if (leadid != null) {
00080 try {
00081 Leads lead = LeadsFactory.getManager().getLeads(leadid);
00082 if (lead != null) {
00083 Account account = AccountFactory.getManager().getAccount(lead.getIdaccount());
00084 templateData.put("accountid", new SimpleScalar(account.getId()));
00085 templateData.put("accountname", new SimpleScalar(account.getName()));
00086 templateData.put("description", new SimpleScalar(lead.getDescription()));
00087 templateData.put("amount", new SimpleScalar(Integer.toString(lead.getAmount())));
00088 templateData.put("state", new SimpleScalar(LabelManager.getManager().getLabelWithIds(Integer.toString(lead.getState()), Leads.LEADS_STATE_LABEL_CATEGORY).getLabel()));
00089 java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat("EEEEE dd MMMMM yyyy", java.util.Locale.FRANCE);
00090 templateData.put("date", new SimpleScalar(formater.format(lead.getCloseDate()).toString()));
00091 }
00092
00093 templateData.put("leadid", new SimpleScalar(leadid));
00094 } catch (DatabaseException ex) {
00095 throw new ServletException(ex);
00096 }
00097 }
00098 return "crm/displaylead.htm";
00099 }
00100
00101
00102
00103
00104
00105
00106 public String getServiceUri() {
00107 return ServiceManager.getManager().getServiceBaseURI() + "/crm/displaylead";
00108 }
00109
00110
00111
00112
00113
00114 public String getNavigationBarLabel(HttpServletRequest req) {
00115 return IntlResourceManager.getManager().getLocalizedProperty("mycrm.displayleadservicenavbar", "Lead");
00116 }
00117
00118 public boolean displayFormExitMessage() {
00119 return false;
00120 }
00121
00122 public boolean displayRecursive() {
00123 return false;
00124 }
00125
00126 }