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.utility.DateTimeData; 31 32 public class ReportProduction extends HttpSecureAppServlet { 33 34 35 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 36 VariablesSecureApp vars = new VariablesSecureApp(request); 37 38 if (!Utility.hasProcessAccess(this, vars, "", "RV_ReportProduction")) { 39 bdError(response, "AccessTableNoView", vars.getLanguage()); 40 return; 41 } 42 43 if (vars.commandIn("DEFAULT")) { 44 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportProduction|DateFrom", ""); 45 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportProduction|DateTo", ""); 46 String strRawMaterial = vars.getGlobalVariable("inpRawMaterial", "ReportProduction|RawMaterial", ""); 47 printPageDataSheet(response, vars, strDateFrom, strDateTo, strRawMaterial); 48 } else if (vars.commandIn("FIND")) { 49 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportProduction|DateFrom"); 50 String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportProduction|DateTo"); 51 String strRawMaterial = vars.getRequestGlobalVariable("inpRawMaterial", "ReportProduction|RawMaterial"); 52 printPagePDF(response, vars, strDateFrom, strDateTo, strRawMaterial); 53 } else pageError(response); 54 } 55 56 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strRawMaterial) 57 throws IOException, ServletException { 58 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 59 response.setContentType("text/html; charset=UTF-8"); 60 PrintWriter out = response.getWriter(); 61 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportProduction").createXmlDocument(); 62 63 64 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportProduction", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 65 toolbar.prepareSimpleToolBarTemplate(); 66 xmlDocument.setParameter("toolbar", toolbar.toString()); 67 68 try { 69 KeyMap key = new KeyMap(this, vars, "ReportProduction.html"); 70 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 71 } catch (Exception ex) { 72 throw new ServletException(ex); 73 } 74 try { 75 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportProduction"); 76 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 77 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 78 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 79 xmlDocument.setParameter("theme", vars.getTheme()); 80 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportProduction.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 81 xmlDocument.setParameter("navigationBar", nav.toString()); 82 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportProduction.html", strReplaceWith); 83 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 84 } catch (Exception ex) { 85 throw new ServletException(ex); 86 } 87 { 88 OBError myMessage = vars.getMessage("ReportProduction"); 89 vars.removeMessage("ReportProduction"); 90 if (myMessage!=null) { 91 xmlDocument.setParameter("messageType", myMessage.getType()); 92 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 93 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 94 } 95 } 96 97 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 98 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 99 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 100 xmlDocument.setParameter("dateFrom", strDateFrom); 101 xmlDocument.setParameter("dateTo", strDateTo); 102 xmlDocument.setParameter("rawMaterial", strRawMaterial); 103 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 104 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 105 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 106 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 107 out.println(xmlDocument.print()); 108 out.close(); 109 } 110 111 void printPagePDF(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strRawMaterial) 112 throws IOException, ServletException { 113 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 114 115 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportProductionPDF").createXmlDocument(); 116 117 String strTitle = "Informe de producción"; 118 if (!strDateFrom.equals("")) strTitle = strTitle + "desde el " + strDateFrom; 119 if (!strDateTo.equals("")) strTitle = strTitle + " hasta el "+strDateTo; 120 121 if (!strRawMaterial.equals("Y")) strRawMaterial = "N"; 122 123 ReportProductionData[] data= ReportProductionData.select(this, strRawMaterial, Utility.getContext(this, vars, "#User_Client", "ReportProduction"), Utility.getContext(this, vars, "#User_Org", "ReportProduction"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1")); 124 if (data == null || data.length == 0) { 125 data = ReportProductionData.set(); 126 } 127 ReportProductionData[] dataSummering = ReportProductionData.selectSummering(this, Utility.getContext(this, vars, "#User_Client", "ReportProduction"), Utility.getContext(this, vars, "#User_Org", "ReportProduction"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1")); 128 129 if (dataSummering == null || dataSummering.length == 0) { 130 dataSummering = ReportProductionData.set(); 131 } 132 133 xmlDocument.setParameter("title", strTitle); 134 xmlDocument.setData("structure1", data); 135 xmlDocument.setData("structure2", dataSummering); 136 String strResult = xmlDocument.print(); 137 renderFO(strResult, response); 138 } 139 140 public String getServletInfo() { 141 return "Servlet ReportProduction. This Servlet was made by Jon Alegria"; 142 } } 144 145 | Popular Tags |