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 org.openbravo.erpCommon.ad_combos.ProcessPlanComboData; 31 import org.openbravo.erpCommon.ad_combos.ProcessPlanVersionComboData; 32 33 public class ReportStandardCost extends HttpSecureAppServlet { 34 35 36 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 37 VariablesSecureApp vars = new VariablesSecureApp(request); 38 39 44 if (vars.commandIn("DEFAULT")){ 45 String strdate = vars.getGlobalVariable("inpDate", "ReportStandardCost|date", ""); 46 String strProductId = vars.getGlobalVariable("inpProductId", "ReportStandardCost|product", ""); 47 String strProcessPlan = vars.getGlobalVariable("inpmaProcessPlanId", "ReportStandardCost|ProcessPlanID", ""); 48 String strVersion = vars.getGlobalVariable("inpmaProcessPlanVersionId", "ReportStandardCost|versionID", ""); 49 printPageDataSheet(response, vars, strdate, strProductId, strProcessPlan, strVersion); 50 }else if (vars.commandIn("FIND")) { 51 String strdate = vars.getRequestGlobalVariable("inpDate", "ReportStandardCost|date"); 52 String strProductId = vars.getRequestGlobalVariable("inpProductId", "ReportStandardCost|product"); 53 String strProcessPlan = vars.getRequestGlobalVariable("inpmaProcessPlanId", "ReportStandardCost|ProcessPlanID"); 54 String strVersion = vars.getRequestGlobalVariable("inpmaProcessPlanVersionId", "ReportStandardCost|versionID"); 55 printPageHtml(response, vars, strdate, strProductId, strProcessPlan, strVersion); 56 } else pageError(response); 57 } 58 59 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strdate, String strProductId, String strProcessPlan, String strVersion) throws IOException, ServletException { 60 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 61 String discard[]={"discard"}; 62 XmlDocument xmlDocument=null; 63 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportStandardCostFilter").createXmlDocument(); 64 65 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportStandardCostFilter", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 66 toolbar.prepareSimpleToolBarTemplate(); 67 xmlDocument.setParameter("toolbar", toolbar.toString()); 68 69 try { 70 KeyMap key = new KeyMap(this, vars, "ReportStandardCost.html"); 71 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 72 } catch (Exception ex) { 73 throw new ServletException(ex); 74 } 75 try { 76 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportStandardCost"); 77 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 78 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 79 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 80 xmlDocument.setParameter("theme", vars.getTheme()); 81 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportStandardCost.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 82 xmlDocument.setParameter("navigationBar", nav.toString()); 83 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportStandardCost.html", strReplaceWith); 84 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 85 } catch (Exception ex) { 86 throw new ServletException(ex); 87 } 88 { 89 OBError myMessage = vars.getMessage("ReportStandardCost"); 90 vars.removeMessage("ReportStandardCost"); 91 if (myMessage!=null) { 92 xmlDocument.setParameter("messageType", myMessage.getType()); 93 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 94 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 95 } 96 } 97 98 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 99 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 100 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 101 xmlDocument.setParameter("date", strdate); 102 xmlDocument.setParameter("datedisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 103 xmlDocument.setParameter("datesaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 104 xmlDocument.setParameter("paramProductId", strProductId); 105 xmlDocument.setData("reportMA_PROCESSPLAN", "liststructure", ProcessPlanComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportStandardCost"), Utility.getContext(this, vars, "#User_Org", "ReportStandardCost"))); 107 xmlDocument.setData("reportMA_PROCESSVERSIONPLAN", "liststructure", ProcessPlanVersionComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportStandardCost"), Utility.getContext(this, vars, "#User_Org", "ReportStandardCost"))); 108 response.setContentType("text/html; charset=UTF-8"); 109 PrintWriter out = response.getWriter(); 110 out.println(xmlDocument.print()); 111 out.close(); 112 } 113 114 void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String strdate, String strProductId, String strProcessPlan, String strVersion) throws IOException, ServletException{ 115 if (log4j.isDebugEnabled()) log4j.debug("Output: print html"); 116 XmlDocument xmlDocument=null; 117 ReportStandardCostData[] data = null; 118 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportStandardCost").createXmlDocument(); 119 120 data = ReportStandardCostData.select(this,strdate,strProductId,strProcessPlan,strVersion); 121 xmlDocument.setData("structure2", data); 122 response.setContentType("text/html; charset=UTF-8"); 123 PrintWriter out = response.getWriter(); 124 out.println(xmlDocument.print()); 125 out.close(); 126 } 127 128 public String getServletInfo() { 129 return "Servlet ReportStandardCostFilter. This Servlet was made by Pablo Sarobe"; 130 } } 132 133 | Popular Tags |