1 19 20 package org.openbravo.erpCommon.ad_reports; 21 22 import org.openbravo.erpCommon.utility.*; 23 import org.openbravo.erpCommon.businessUtility.WindowTabs; 24 import org.openbravo.base.secureApp.HttpSecureAppServlet; 25 import org.openbravo.base.secureApp.VariablesSecureApp; 26 import org.openbravo.xmlEngine.XmlDocument; 27 import java.io.*; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 public class ReportMaterialTransactionEdition extends HttpSecureAppServlet { 32 33 34 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 35 VariablesSecureApp vars = new VariablesSecureApp(request); 36 37 if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportMaterialTransaction")) { 38 bdError(response, "AccessTableNoView", vars.getLanguage()); 39 return; 40 } 41 42 if (vars.commandIn("DEFAULT")){ 43 String strdateFrom = vars.getStringParameter("inpDateFrom", ""); 44 String strdateTo = vars.getStringParameter("inpDateTo", ""); 45 printPageDataSheet(response, vars, strdateFrom, strdateTo); 46 }else if (vars.commandIn("EDIT_HTML")) { 47 String strdateFrom = vars.getStringParameter("inpDateFrom"); 48 String strdateTo = vars.getStringParameter("inpDateTo"); 49 String strcBpartnetId = vars.getStringParameter("inpcBPartnerId"); 50 String strmWarehouseId = vars.getStringParameter("inpmWarehouseId"); 51 String strcProjectId = vars.getStringParameter("inpcProjectId"); 52 String strissotrx = "N"; 53 printPageHtml(response, vars, strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId ,strissotrx); 54 } else if (vars.commandIn("EDIT_PDF")) { 55 if (log4j.isDebugEnabled()) log4j.debug("WE EDIT THE 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 = "N"; 62 printPagePdf(response, vars, strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId ,strissotrx); 63 } else pageErrorPopUp(response); 64 } 65 66 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo) throws IOException, ServletException { 67 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 68 String discard[]={"discard"}; 69 XmlDocument xmlDocument=null; 70 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportMaterialTransactionFilter").createXmlDocument(); 71 72 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportMaterialTransactionEdition", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 73 toolbar.prepareSimpleToolBarTemplate(); 74 xmlDocument.setParameter("toolbar", toolbar.toString()); 75 try { 76 KeyMap key = new KeyMap(this, vars, "ReportMaterialTransactionEdition.html"); 77 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 78 } catch (Exception ex) { 79 throw new ServletException(ex); 80 } 81 try { 82 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportMaterialTransactionEdition"); 83 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 84 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 85 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 86 xmlDocument.setParameter("theme", vars.getTheme()); 87 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportMaterialTransactionEdition.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 88 xmlDocument.setParameter("navigationBar", nav.toString()); 89 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportMaterialTransactionEdition.html", strReplaceWith); 90 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 91 } catch (Exception ex) { 92 throw new ServletException(ex); 93 } 94 { 95 OBError myMessage = vars.getMessage("ReportMaterialTransactionEdition"); 96 vars.removeMessage("ReportMaterialTransactionEdition"); 97 if (myMessage!=null) { 98 xmlDocument.setParameter("messageType", myMessage.getType()); 99 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 100 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 101 } 102 } 103 104 105 106 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 107 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 108 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 109 xmlDocument.setParameter("dateFrom", strdateFrom); 110 xmlDocument.setParameter("dateTo", strdateTo); 111 xmlDocument.setParameter("paramBPartnerId", ""); 112 xmlDocument.setParameter("mWarehouseId", ""); 113 xmlDocument.setParameter("cProjectId", ""); 114 try { 115 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Warehouse_ID", "", "", Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), 0); 116 Utility.fillSQLParameters(this, vars, null, comboTableData, "MaterialReceiptFilter", ""); 117 xmlDocument.setData("reportM_WAREHOUSEID","liststructure", comboTableData.select(false)); 118 comboTableData = null; 119 } catch (Exception ex) { 120 throw new ServletException(ex); 121 } 122 123 124 try { 125 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_Project_ID", "", "", Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), 0); 126 Utility.fillSQLParameters(this, vars, null, comboTableData, "MaterialReceiptFilter", ""); 127 xmlDocument.setData("reportC_PROJECTID","liststructure", comboTableData.select(false)); 128 comboTableData = null; 129 } catch (Exception ex) { 130 throw new ServletException(ex); 131 } 132 133 response.setContentType("text/html; charset=UTF-8"); 134 PrintWriter out = response.getWriter(); 135 out.println(xmlDocument.print()); 136 out.close(); 137 } 138 139 void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcBpartnetId, String strmWarehouseId, String strcProjectId, String strissotrx) throws IOException, ServletException{ 140 if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); 141 XmlDocument xmlDocument=null; 142 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportMaterialTransactionEdition").createXmlDocument(); 143 InoutEditionData[] data = null; 144 data = InoutEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId, strissotrx); 145 xmlDocument.setData("structure1", data); 146 response.setContentType("text/html; charset=UTF-8"); 147 PrintWriter out = response.getWriter(); 148 out.println(xmlDocument.print()); 149 out.close(); 150 } 151 152 void printPagePdf(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcBpartnetId, String strmWarehouseId, String strcProjectId, String strissotrx) throws IOException, ServletException{ 153 if (log4j.isDebugEnabled()) log4j.debug("Output: print pdf"); 154 XmlDocument xmlDocument=null; 155 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportMaterialTransactionEdition_Pdf").createXmlDocument(); 156 InoutEditionData[] data = null; 157 data = InoutEditionData.select(this, Utility.getContext(this, vars, "#User_Org", "MaterialReceiptFilter"), Utility.getContext(this, vars, "#User_Client", "MaterialReceiptFilter"), strdateFrom, strdateTo, strcBpartnetId, strmWarehouseId, strcProjectId, strissotrx); 158 xmlDocument.setData("structure1", data); 159 String strResult = xmlDocument.print(); 160 if (log4j.isDebugEnabled()) log4j.debug(strResult); 161 renderFO(strResult, response); 162 } 163 164 public String getServletInfo() { 165 return "Servlet PurchaseOrderFilter. This Servlet was made by Jon AlegrÃa"; 166 } } 168 169 | Popular Tags |