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.utility.DateTimeData; 39 40 public class ReportWarehousePartnerJR extends HttpSecureAppServlet { 41 42 43 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 44 VariablesSecureApp vars = new VariablesSecureApp(request); 45 46 if (vars.commandIn("DEFAULT")) { 47 String strDate = vars.getGlobalVariable("inpDateFrom", "ReportWarehousePartnerJR|Date", DateTimeData.today(this)); 48 String strProductCategory = vars.getGlobalVariable("inpProductCategory", "ReportWarehousePartnerJR|productCategory", ""); 49 String strmProductId = vars.getInGlobalVariable("inpmProductId_IN", "ReportWarehousePartnerJR|mProductId", ""); 50 String strX = vars.getGlobalVariable("inpX", "ReportWarehousePartnerJR|X", ""); 51 String strY = vars.getGlobalVariable("inpY", "ReportWarehousePartnerJR|Y", ""); 52 String strZ = vars.getGlobalVariable("inpZ", "ReportWarehousePartnerJR|Z", ""); 53 printPageDataSheet(response, vars, strDate, strProductCategory, strmProductId, strX, strY, strZ); 54 } else if (vars.commandIn("FIND")) { 55 String strDate = vars.getGlobalVariable("inpDateFrom", "ReportWarehousePartner|Date"); 56 String strProductCategory = vars.getRequestGlobalVariable("inpProductCategory", "ReportWarehousePartnerJR|productCategory"); 57 String strmProductId = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportWarehousePartnerJR|mProductId"); 58 String strX = vars.getRequestGlobalVariable("inpX", "ReportWarehousePartnerJR|X"); 59 String strY = vars.getRequestGlobalVariable("inpY", "ReportWarehousePartnerJR|Y"); 60 String strZ = vars.getRequestGlobalVariable("inpZ", "ReportWarehousePartnerJR|Z"); 61 setHistoryCommand(request, "FIND"); 62 printPageDataHtml(response, vars, strDate, strProductCategory, strmProductId, strX, strY, strZ); 63 } else pageError(response); 64 } 65 66 void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String strDate, String strProductCategory, String strmProductId, String strX, String strY, String strZ) 67 throws IOException, ServletException { 68 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 69 70 ReportWarehousePartnerData[] data=ReportWarehousePartnerData.select(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportWarehouseControl"), Utility.getContext(this, vars, "#User_Org", "ReportWarehouseControl"), DateTimeData.nDaysAfter(this, strDate,"1"), strmProductId, strProductCategory, strX, strY, strZ); 71 72 JasperPrint jasperPrint; 73 String strOutput = "html"; 74 String strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportWarehousePartnerJR.jrxml"; 75 76 HashMap<String , Object > parameters = new HashMap<String , Object >(); 77 parameters.put("Title", classInfo.name); 78 renderJR(vars, response, strReportName, strOutput, parameters, data, null ); 80 81 } 82 83 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDate, String strProductCategory, String strmProductId, String strX, String strY, String strZ) 84 throws IOException, ServletException { 85 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 86 response.setContentType("text/html; charset=UTF-8"); 87 PrintWriter out = response.getWriter(); 88 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportWarehousePartnerJR").createXmlDocument(); 89 90 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportWarehousePartnerJR", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 91 toolbar.prepareSimpleToolBarTemplate(); 92 xmlDocument.setParameter("toolbar", toolbar.toString()); 93 94 try { 95 KeyMap key = new KeyMap(this, vars, "ReportWarehousePartnerJR.html"); 96 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 97 } catch (Exception ex) { 98 throw new ServletException(ex); 99 } 100 try { 101 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportWarehousePartnerJR"); 102 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 103 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 104 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 105 xmlDocument.setParameter("theme", vars.getTheme()); 106 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportWarehousePartnerJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 107 xmlDocument.setParameter("navigationBar", nav.toString()); 108 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportWarehousePartnerJR.html", strReplaceWith); 109 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 110 } catch (Exception ex) { 111 throw new ServletException(ex); 112 } 113 { 114 OBError myMessage = vars.getMessage("ReportWarehousePartnerJR"); 115 vars.removeMessage("ReportWarehousePartnerJR"); 116 if (myMessage!=null) { 117 xmlDocument.setParameter("messageType", myMessage.getType()); 118 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 119 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 120 } 121 } 122 123 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 124 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 125 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 126 xmlDocument.setParameter("date", strDate); 127 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 128 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 129 xmlDocument.setParameter("parameterX", strX); 130 xmlDocument.setParameter("parameterY", strY); 131 xmlDocument.setParameter("parameterZ", strZ); 132 xmlDocument.setParameter("mProductCategoryId", strProductCategory); 133 134 xmlDocument.setData("reportMProductId_IN", "liststructure", ReportWarehousePartnerData.selectMproduct2(this, Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), strmProductId)); 135 try { 136 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), 0); 137 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportPricelist", strProductCategory); 138 xmlDocument.setData("reportM_PRODUCT_CATEGORYID","liststructure", comboTableData.select(false)); 139 comboTableData = null; 140 } catch (Exception ex) { 141 throw new ServletException(ex); 142 } 143 144 145 146 out.println(xmlDocument.print()); 147 out.close(); 148 } 149 150 214 215 public String getServletInfo() { 216 return "Servlet ReportWarehousePartner. This Servlet was made by Jon Alegria"; 217 } } 219 | Popular Tags |