| 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 public class ReportInvoiceVendorJR extends HttpSecureAppServlet { 39 40 41 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 42 VariablesSecureApp vars = new VariablesSecureApp(request); 43 44 if (!Utility.hasProcessAccess(this, vars, "", "ReportInvoiceVendorJR")) { 45 bdError(response, "AccessTableNoView", vars.getLanguage()); 46 return; 47 } 48 49 if (vars.commandIn("DEFAULT")){ 50 String strdateFrom = vars.getStringParameter("inpdateFrom", ""); 51 String strdateTo = vars.getStringParameter("inpdateTo", ""); 52 printPageDataSheet(response, vars, strdateFrom, strdateTo); 53 }else if (vars.commandIn("EDIT_HTML","EDIT_PDF")) { 54 String strdateFrom = vars.getStringParameter("inpdateFrom"); 55 String strdateTo = vars.getStringParameter("inpdateTo"); 56 String strcBpartnetId = vars.getStringParameter("inpcBPartnerId"); 57 String strcProjectId = vars.getStringParameter("inpcProjectId"); 58 String strissotrx = "N"; 59 printPageHtml(response, vars, strdateFrom, strdateTo, strcBpartnetId, strcProjectId ,strissotrx); 60 } else pageErrorPopUp(response); 61 } 62 63 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo) throws IOException, ServletException { 64 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 65 String discard[]={"discard"}; 66 XmlDocument xmlDocument=null; 67 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceVendorFilterJR").createXmlDocument(); 68 69 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceVendorFilter", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 70 toolbar.prepareSimpleToolBarTemplate(); 71 xmlDocument.setParameter("toolbar", toolbar.toString()); 72 73 try { 74 KeyMap key = new KeyMap(this, vars, "ReportInvoiceVendorEdition.html"); 75 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 76 } catch (Exception ex) { 77 throw new ServletException(ex); 78 } 79 try { 80 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceVendorJR"); 81 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 82 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 83 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 84 xmlDocument.setParameter("theme", vars.getTheme()); 85 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceVendorFilterJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 86 xmlDocument.setParameter("navigationBar", nav.toString()); 87 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceVendorFilterJR.html", strReplaceWith); 88 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 89 } catch (Exception ex) { 90 throw new ServletException(ex); 91 } 92 { 93 OBError myMessage = vars.getMessage("ReportInvoiceVendorJR"); 94 vars.removeMessage("ReportInvoiceVendorJR"); 95 if (myMessage!=null) { 96 xmlDocument.setParameter("messageType", myMessage.getType()); 97 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 98 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 99 } 100 } 101 102 103 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 104 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 105 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 106 xmlDocument.setParameter("dateFrom", strdateFrom); 107 xmlDocument.setParameter("dateTo", strdateTo); 108 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 109 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 110 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 111 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 112 xmlDocument.setParameter("paramBPartnerId", ""); 113 xmlDocument.setParameter("mWarehouseId", ""); 114 xmlDocument.setParameter("cProjectId", ""); 115 xmlDocument.setParameter("projectName", ""); 116 try { 117 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Warehouse_ID", "", "", Utility.getContext(this, vars, "#User_Org", "InvoiceVendorJR"), Utility.getContext(this, vars, "#User_Client", "InvoiceVendorJR"), 0); 118 Utility.fillSQLParameters(this, vars, null, comboTableData, "InvoiceVendorFilter", ""); 119 xmlDocument.setData("reportM_WAREHOUSEID","liststructure", comboTableData.select(false)); 120 comboTableData = null; 121 } catch (Exception ex) { 122 throw new ServletException(ex); 123 } 124 125 response.setContentType("text/html; charset=UTF-8"); 126 PrintWriter out = response.getWriter(); 127 out.println(xmlDocument.print()); 128 out.close(); 129 } 130 131 void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcBpartnetId, String strcProjectId, String strissotrx) throws IOException, ServletException{ 132 if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); 133 134 InvoiceEditionData[] data = null; 135 data = InvoiceEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "InvoiceVendorJR"), Utility.getContext(this, vars, "#User_Client", "InvoiceVendorJR"), strdateFrom, strdateTo, strcBpartnetId, strcProjectId, strissotrx); 136 137 JasperPrint jasperPrint; 138 String strOutput = vars.commandIn("EDIT_HTML")?"html":"pdf"; 139 String strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportInvoiceVendorJR.jrxml"; 140 141 HashMap<String , Object > parameters = new HashMap<String , Object >(); 142 parameters.put("Title", classInfo.name); 143 renderJR(vars, response, strReportName, strOutput, parameters, data, null ); 145 } 146 147 148 149 public String getServletInfo() { 150 return "Servlet PurchaseOrderFilter. This Servlet was made by Jon AlegrÃa"; 151 } } 153 154 | Popular Tags |