| 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 31 import org.openbravo.erpCommon.utility.DateTimeData; 32 33 import net.sf.jasperreports.engine.*; 34 import net.sf.jasperreports.engine.design.JasperDesign; 35 import java.sql.Connection ; 36 import net.sf.jasperreports.engine.xml.JRXmlLoader; 37 import net.sf.jasperreports.engine.export.JRHtmlExporter; 38 import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; 39 import java.util.HashMap ; 40 41 42 public class ReportGuaranteeDateJR extends HttpSecureAppServlet { 43 44 45 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 46 VariablesSecureApp vars = new VariablesSecureApp(request); 47 48 if (vars.commandIn("DEFAULT")) { 49 String strDate = vars.getGlobalVariable("inpDate", "ReportGuaranteeDateJR|date", ""); 50 String strcBpartnerId = vars.getGlobalVariable("inpcBPartnerId", "ReportGuaranteeDateJR|cBpartnerId", ""); 51 String strmWarehouseId = vars.getStringParameter("inpmWarehouseId",""); 52 printPageDataSheet(response, vars, strDate, strcBpartnerId, strmWarehouseId); 53 } else if (vars.commandIn("FIND")) { 54 String strDate = vars.getRequestGlobalVariable("inpDate", "ReportGuaranteeDateJR|date"); 55 String strcBpartnerId = vars.getRequestGlobalVariable("inpcBPartnerId", "ReportGuaranteeDateJR|cBpartnerId"); 56 String strmWarehouseId = vars.getStringParameter("inpmWarehouseId"); 57 setHistoryCommand(request, "FIND"); 58 printPageDataHtml(response, vars, strDate, strcBpartnerId, strmWarehouseId); 59 } else pageError(response); 60 } 61 62 void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String strDate, String strcBpartnerId, String strmWarehouseId) 63 throws IOException, ServletException { 64 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 65 response.setContentType("text/html; charset=UTF-8"); 66 67 XmlDocument xmlDocument=null; 68 ReportGuaranteeDateData[] data = null; 69 70 data = ReportGuaranteeDateData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportGuaranteeDateJR"), Utility.getContext(this, vars, "#User_Org", "ReportGuaranteeDateJR"), DateTimeData.nDaysAfter(this, strDate,"1"), strcBpartnerId, strmWarehouseId); 71 72 73 JasperPrint jasperPrint; 74 String strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportGuaranteeDateJR.jrxml"; 75 String strOutput="html"; 76 if (strOutput.equals("pdf")) response.setHeader("Content-disposition", "inline; filename=ReportGuaranteeDateJR.pdf"); 77 78 79 HashMap <String , Object > parameters = new HashMap <String , Object >(); 80 parameters.put("Title", "Guarantee date"); 81 parameters.put("REPORT_TITLE", "Guarantee date"); 82 parameters.put("REPORT_SUBTITLE", "Date: "+strDate); 83 84 renderJR(vars, response, strReportName, strOutput, parameters, data, null ); 85 86 } 87 88 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDate, String strcBpartnerId, String strmWarehouseId) 89 throws IOException, ServletException { 90 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 91 response.setContentType("text/html; charset=UTF-8"); 92 PrintWriter out = response.getWriter(); 93 XmlDocument xmlDocument=null; 94 95 96 97 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportGuaranteeDateJR").createXmlDocument(); 98 99 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportGuaranteeDateJR", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 100 toolbar.prepareSimpleToolBarTemplate(); 101 xmlDocument.setParameter("toolbar", toolbar.toString()); 102 try { 103 KeyMap key = new KeyMap(this, vars, "ReportGuaranteeDateJR.html"); 104 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 105 } catch (Exception ex) { 106 throw new ServletException(ex); 107 } 108 try { 109 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportGuaranteeDateJR"); 110 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 111 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 112 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 113 xmlDocument.setParameter("theme", vars.getTheme()); 114 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportGuaranteeDateJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 115 xmlDocument.setParameter("navigationBar", nav.toString()); 116 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportGuaranteeDateJR.html", strReplaceWith); 117 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 118 } catch (Exception ex) { 119 throw new ServletException(ex); 120 } 121 { 122 OBError myMessage = vars.getMessage("ReportGuaranteeDateJR"); 123 vars.removeMessage("ReportGuaranteeDateJR"); 124 if (myMessage!=null) { 125 xmlDocument.setParameter("messageType", myMessage.getType()); 126 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 127 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 128 } 129 } 130 131 132 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 133 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 134 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 135 xmlDocument.setParameter("date", strDate); 136 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 137 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 138 xmlDocument.setParameter("paramBPartnerId", strcBpartnerId); 139 xmlDocument.setParameter("mWarehouseId", strmWarehouseId); 140 xmlDocument.setParameter("bPartnerDescription", ReportGuaranteeDateData.selectBpartner(this, strcBpartnerId)); 141 try { 142 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Warehouse_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportGuaranteeDateJR"), Utility.getContext(this, vars, "#User_Client", "ReportGuaranteeDateJR"), 0); 143 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportGuaranteeDateJR", strmWarehouseId); 144 xmlDocument.setData("reportM_WAREHOUSEID","liststructure", comboTableData.select(false)); 145 comboTableData = null; 146 } catch (Exception ex) { 147 throw new ServletException(ex); 148 } 149 150 151 out.println(xmlDocument.print()); 152 out.close(); 153 } 154 155 156 157 public String getServletInfo() { 158 return "Servlet ReportGuaranteeDateJR. This Servlet was made by Jon Alegria"; 159 } } 161 | Popular Tags |