1 19 package org.openbravo.erpCommon.ad_reports; 20 21 import org.openbravo.erpCommon.utility.*; 22 import org.openbravo.erpCommon.businessUtility.WindowTabs; 23 import org.openbravo.base.secureApp.HttpSecureAppServlet; 24 import org.openbravo.base.secureApp.VariablesSecureApp; 25 import org.openbravo.xmlEngine.XmlDocument; 26 import java.io.*; 27 import javax.servlet.*; 28 import javax.servlet.http.*; 29 30 import java.util.*; 31 import net.sf.jasperreports.engine.*; 32 import net.sf.jasperreports.engine.design.JasperDesign; 33 import java.sql.Connection ; 34 import net.sf.jasperreports.engine.xml.JRXmlLoader; 35 import net.sf.jasperreports.engine.export.JRHtmlExporter; 36 import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; 37 38 import org.openbravo.erpCommon.ad_combos.WorkRequirementComboData; 39 40 public class ReportProductionRunJR extends HttpSecureAppServlet { 41 42 43 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 44 VariablesSecureApp vars = new VariablesSecureApp(request); 45 46 if (!Utility.hasProcessAccess(this, vars, "", "ReportProductionRunJR")) { 47 bdError(response, "AccessTableNoView", vars.getLanguage()); 48 return; 49 } 50 51 if (vars.commandIn("DEFAULT")) { 52 String strLaunchDateFrom = vars.getGlobalVariable("inpLaunchDateFrom", "ReportProductionRunJR|LaunchDateFrom", ""); 53 String strLaunchDateTo = vars.getGlobalVariable("inpLaunchDateTo", "ReportProductionRunJR|LaunchDateTo", ""); 54 String strStartDateFrom = vars.getGlobalVariable("inpStartDateFrom", "ReportProductionRunJR|StartDateFrom", ""); 55 String strStartDateTo = vars.getGlobalVariable("inpStartDateTo", "ReportProductionRunJR|StartDateTo", ""); 56 String strEndDateFrom = vars.getGlobalVariable("inpEndDateFrom", "ReportProductionRunJR|EndDateFrom", ""); 57 String strEndDateTo = vars.getGlobalVariable("inpEndDateTo", "ReportProductionRunJR|EndDateTo", ""); 58 String strmaWorkRequirement = vars.getGlobalVariable("inpmaWorkRequirementId", "ReportProductionRunJR|maWorkRequirement", ""); 59 printPageDataSheet(response, vars, strLaunchDateFrom, strLaunchDateTo, strStartDateFrom, strStartDateTo, strEndDateFrom, strEndDateTo, strmaWorkRequirement); 60 } else if (vars.commandIn("FIND")) { 61 String strLaunchDateFrom = vars.getRequestGlobalVariable("inpLaunchDateFrom", "ReportProductionRunJR|LaunchDateFrom"); 62 String strLaunchDateTo = vars.getRequestGlobalVariable("inpLaunchDateTo", "ReportProductionRunJR|LaunchDateTo"); 63 String strStartDateFrom = vars.getRequestGlobalVariable("inpStartDateFrom", "ReportProductionRunJR|StartDateFrom"); 64 String strStartDateTo = vars.getRequestGlobalVariable("inpStartDateTo", "ReportProductionRunJR|StartDateTo"); 65 String strEndDateFrom = vars.getRequestGlobalVariable("inpEndDateFrom", "ReportProductionRunJR|EndDateFrom"); 66 String strEndDateTo = vars.getRequestGlobalVariable("inpEndDateTo", "ReportProductionRunJR|EndDateTo"); 67 String strmaWorkRequirement = vars.getRequestGlobalVariable("inpmaWorkRequirementId", "ReportProductionRunJR|maWorkRequirement"); 68 printPageDataHtml(response, vars, strLaunchDateFrom, strLaunchDateTo, strStartDateFrom, strStartDateTo, strEndDateFrom, strEndDateTo, strmaWorkRequirement); 69 } else pageError(response); 70 } 71 72 void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String strLaunchDateFrom, String strLaunchDateTo, String strStartDateFrom, String strStartDateTo, String strEndDateFrom, String strEndDateTo, String strmaWorkRequirement) 73 throws IOException, ServletException { 74 if (log4j.isDebugEnabled()) log4j.debug("Output: dataHtmlJR"); 75 76 77 ReportProductionRunData[] data=null; 78 data = ReportProductionRunData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportProductionRunJR"), Utility.getContext(this, vars, "#User_Org", "ReportProductionRunJR"), strLaunchDateFrom, strLaunchDateTo, strStartDateFrom, strStartDateTo, strEndDateFrom, strEndDateTo, strmaWorkRequirement); 79 80 String strSubtitle = ""; 81 if (!strLaunchDateFrom.equals("")) 82 strSubtitle = Utility.messageBD(this, "LaunchDateFrom", vars.getLanguage()) +":"+strLaunchDateFrom; 83 if (!strLaunchDateTo.equals("")) 84 strSubtitle += strSubtitle.equals("")?"":" - "+Utility.messageBD(this, "LaunchDateTo", vars.getLanguage())+":"+strLaunchDateTo; 85 if (!strStartDateFrom.equals("")) 86 strSubtitle += strSubtitle.equals("")?"":" - "+Utility.messageBD(this, "StartDateFrom", vars.getLanguage()) +":"+strStartDateFrom; 87 if (!strStartDateTo.equals("")) 88 strSubtitle += strSubtitle.equals("")?"":" - "+Utility.messageBD(this, "StartDateTo", vars.getLanguage()) +":"+strStartDateTo; 89 if (!strEndDateFrom.equals("")) 90 strSubtitle += strSubtitle.equals("")?"":" - "+Utility.messageBD(this, "EndDateFrom", vars.getLanguage()) +":"+strEndDateFrom; 91 if (!strmaWorkRequirement.equals("")) 92 strSubtitle += strSubtitle.equals("")?"":" - "+Utility.messageBD(this, "WorkRequirement", vars.getLanguage()) +":"+strmaWorkRequirement; 93 94 95 96 JasperPrint jasperPrint; 97 String strOutput = "html"; 98 String strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportProductionRun.jrxml"; 99 100 HashMap<String , Object > parameters = new HashMap<String , Object >(); 101 parameters.put("Title", classInfo.name); 102 parameters.put("Subtitle",strSubtitle); 103 renderJR(vars, response, strReportName, strOutput, parameters, data, null ); 104 } 105 106 107 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strLaunchDateFrom, String strLaunchDateTo, String strStartDateFrom, String strStartDateTo, String strEndDateFrom, String strEndDateTo, String strmaWorkRequirement) 108 throws IOException, ServletException { 109 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 110 response.setContentType("text/html; charset=UTF-8"); 111 PrintWriter out = response.getWriter(); 112 113 XmlDocument xmlDocument=null; 114 115 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportProductionRunJR").createXmlDocument(); 116 117 118 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportProductionRunJR", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 119 toolbar.prepareSimpleToolBarTemplate(); 120 xmlDocument.setParameter("toolbar", toolbar.toString()); 121 122 try { 123 KeyMap key = new KeyMap(this, vars, "ReportProductionRun.html"); 124 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 125 } catch (Exception ex) { 126 throw new ServletException(ex); 127 } 128 try { 129 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportProductionRunJR"); 130 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 131 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 132 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 133 xmlDocument.setParameter("theme", vars.getTheme()); 134 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportProductionRunJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 135 xmlDocument.setParameter("navigationBar", nav.toString()); 136 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportProductionRunJR.html", strReplaceWith); 137 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 138 } catch (Exception ex) { 139 throw new ServletException(ex); 140 } 141 { 142 OBError myMessage = vars.getMessage("ReportProductionRunJR"); 143 vars.removeMessage("ReportProductionRunJR"); 144 if (myMessage!=null) { 145 xmlDocument.setParameter("messageType", myMessage.getType()); 146 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 147 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 148 } 149 } 150 151 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 152 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 153 xmlDocument.setParameter("maWorkRequirement", strmaWorkRequirement); 154 xmlDocument.setParameter("launchDateFrom", strLaunchDateFrom); 155 xmlDocument.setParameter("launchDateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 156 xmlDocument.setParameter("launchDateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 157 xmlDocument.setParameter("launchDateTo", strLaunchDateTo); 158 xmlDocument.setParameter("launchDateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 159 xmlDocument.setParameter("launchDateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 160 xmlDocument.setParameter("startDateFrom", strStartDateFrom); 161 xmlDocument.setParameter("startDateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 162 xmlDocument.setParameter("startDateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 163 xmlDocument.setParameter("startDateTo", strStartDateTo); 164 xmlDocument.setParameter("startDateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 165 xmlDocument.setParameter("startDateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 166 xmlDocument.setParameter("endDateFrom", strEndDateFrom); 167 xmlDocument.setParameter("endDateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 168 xmlDocument.setParameter("endDateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 169 xmlDocument.setParameter("endDateTo", strEndDateTo); 170 xmlDocument.setParameter("endDateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 171 xmlDocument.setParameter("endDateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 172 xmlDocument.setData("reportMA_WORKREQUIREMENT", "liststructure", WorkRequirementComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportProductionRunJR"), Utility.getContext(this, vars, "#User_Org", "ReportProductionRunJR"))); 173 174 out.println(xmlDocument.print()); 175 out.close(); 176 } 177 178 236 public String getServletInfo() { 237 return "Servlet ReportProductionRunJR."; 238 } } 240 | Popular Tags |