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 import java.util.HashMap ; 30 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 39 public class ReportShipmentEditionJR extends HttpSecureAppServlet { 40 41 42 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 43 VariablesSecureApp vars = new VariablesSecureApp(request); 44 45 if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportShipment")) { 46 bdError(response, "AccessTableNoView", vars.getLanguage()); 47 return; 48 } 49 50 if (vars.commandIn("DEFAULT")){ 51 String strdateFrom = vars.getStringParameter("inpDateFrom", ""); 52 String strdateTo = vars.getStringParameter("inpDateTo", ""); 53 printPageDataSheet(response, vars, strdateFrom, strdateTo); 54 } else if (vars.commandIn("EDIT_PDF","EDIT_HTML")) { 55 log4j.info("EDITAMOS EL PDF"); 56 String strdateFrom = vars.getStringParameter("inpDateFrom"); 57 String strdateTo = vars.getStringParameter("inpDateTo"); 58 String strcBpartnetId = vars.getStringParameter("inpcBPartnerId"); 59 String strmWarehouseId = vars.getStringParameter("inpmWarehouseId"); 60 String strcProjectId = vars.getStringParameter("inpcProjectId"); 61 String strissotrx = "Y"; 62 printPagePdf(response, vars, strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId ,strissotrx); 63 } else pageErrorPopUp(response); 64 65 } 66 67 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo) throws IOException, ServletException { 68 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 69 String discard[]={"discard"}; 70 XmlDocument xmlDocument=null; 71 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportShipmentFilterJR").createXmlDocument(); 72 73 74 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportShipmentFilterJR", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 75 toolbar.prepareSimpleToolBarTemplate(); 76 xmlDocument.setParameter("toolbar", toolbar.toString()); 77 78 try { 79 KeyMap key = new KeyMap(this, vars, "ReportShipmentEditionJR.html"); 80 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 81 } catch (Exception ex) { 82 throw new ServletException(ex); 83 } 84 try { 85 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportShipmentEditionJR"); 86 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 87 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 88 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 89 xmlDocument.setParameter("theme", vars.getTheme()); 90 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportShipmentEditionJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 91 xmlDocument.setParameter("navigationBar", nav.toString()); 92 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportShipmentEditionJR.html", strReplaceWith); 93 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 94 } catch (Exception ex) { 95 throw new ServletException(ex); 96 } 97 { 98 OBError myMessage = vars.getMessage("ReportShipmentEditionJR"); 99 vars.removeMessage("ReportShipmentEditionJR"); 100 if (myMessage!=null) { 101 xmlDocument.setParameter("messageType", myMessage.getType()); 102 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 103 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 104 } 105 } 106 107 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 108 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 109 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 110 xmlDocument.setParameter("dateFrom", strdateFrom); 111 xmlDocument.setParameter("dateTo", strdateTo); 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", "ShipmentFilter"), Utility.getContext(this, vars, "#User_Client", "ShipmentFilter"), 0); 118 Utility.fillSQLParameters(this, vars, null, comboTableData, "ShipmentFilter", ""); 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 132 void printPagePdf(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcBpartnetId, String strmWarehouseId, String strcProjectId, String strissotrx) throws IOException, ServletException{ 133 if (log4j.isDebugEnabled()) log4j.debug("Output: print pdf"); 134 JasperPrint jasperPrint; 135 136 145 String strOutput=new String (vars.commandIn("EDIT_PDF")?"pdf":"html"); 146 147 String strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportShipmentEdition.jrxml"; 148 if (strOutput.equals("pdf")) response.setHeader("Content-disposition", "inline; filename=ReportShipmetEditionJR.pdf"); 149 150 InoutEditionData[] data = InoutEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "ShipmentFilter"), Utility.getContext(this, vars, "#User_Client", "ShipmentFilter"), strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId, strissotrx); 151 HashMap <String , Object > parameters = new HashMap <String , Object >(); 152 String strTitle = classInfo.name; 153 parameters.put("REPORT_TITLE", strTitle); 154 if (log4j.isDebugEnabled()) log4j.debug("data"+data.length); 156 renderJR(vars, response, strReportName, strOutput, parameters, data, null ); 157 158 166 167 } 168 169 public String getServletInfo() { 170 return "Servlet PurchaseOrderFilter. This Servlet was made by Jon AlegrÃa"; 171 } } 173 174 | Popular Tags |