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 ReportProductionCost 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_ReportProductionCost")) { 39 bdError(response, "AccessTableNoView", vars.getLanguage()); 40 return; 41 } 42 43 if (vars.commandIn("DEFAULT")){ 44 String strdateFrom = vars.getGlobalVariable("inpDateFrom", "ReportProductionCost|dateFrom", ""); 45 String strdateTo = vars.getGlobalVariable("inpDateTo", "ReportProductionCost|dateTo", ""); 46 String strmProductId = vars.getGlobalVariable("inpmProductId", "ReportProductionCost|mProductId", ""); 49 printPageDataSheet(response, vars, strdateFrom, strdateTo, strmProductId); 50 }else if (vars.commandIn("FIND")) { 51 String strdateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportProductionCost|dateFrom"); 52 String strdateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportProductionCost|dateTo"); 53 String strmProductId = vars.getRequestGlobalVariable("inpmProductId", "ReportProductionCost|mProductId"); 56 printPageDataSheet(response, vars, strdateFrom, strdateTo, strmProductId); 57 } else if (vars.commandIn("OPEN")) { 58 String strdateFrom = vars.getRequiredStringParameter("inpDateFrom"); 59 String strdateTo = vars.getRequiredStringParameter("inpDateTo"); 60 String strmProductId = vars.getRequiredStringParameter("inpProduct"); 61 String strId = vars.getRequiredStringParameter("inpId"); 62 String strLevel = vars.getRequiredStringParameter("inpLevel"); 63 if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strdateFrom); 64 if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strdateTo); 65 if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strmProductId); 66 if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strId); 67 if (log4j.isDebugEnabled()) log4j.debug("***************************+: "+strLevel); 68 69 printPageOpen(response, vars, strdateFrom, strdateTo, strmProductId, strId, strLevel); 70 }else pageError(response); 71 } 72 73 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strmProductId) throws IOException, ServletException { 74 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 75 String discard[]={"discard"}; 76 XmlDocument xmlDocument=null; 77 String strLevel = "0"; 78 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportProductionCost").createXmlDocument(); 79 80 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportProductionCost", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 81 toolbar.prepareSimpleToolBarTemplate(); 82 ReportProductionCostData[] data = null; 83 84 if (strdateFrom.equals("") && strdateTo.equals("")){ 85 data = ReportProductionCostData.set(); 86 discard[0] = "sectionDetail"; 87 } else{ 88 data = ReportProductionCostData.select(this, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId); 89 if (data == null || data.length == 0){ 90 data = ReportProductionCostData.set(); 91 discard[0] = "sectionDetail"; 92 } 93 } 94 95 96 xmlDocument.setParameter("toolbar", toolbar.toString()); 97 98 try { 99 KeyMap key = new KeyMap(this, vars, "ReportProductionCost.html"); 100 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 101 } catch (Exception ex) { 102 throw new ServletException(ex); 103 } 104 try { 105 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportProductionCost"); 106 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 107 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 108 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 109 xmlDocument.setParameter("theme", vars.getTheme()); 110 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportProductionCost.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 111 xmlDocument.setParameter("navigationBar", nav.toString()); 112 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportProductionCost.html", strReplaceWith); 113 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 114 } catch (Exception ex) { 115 throw new ServletException(ex); 116 } 117 { 118 OBError myMessage = vars.getMessage("ReportProductionCost"); 119 vars.removeMessage("ReportProductionCost"); 120 if (myMessage!=null) { 121 xmlDocument.setParameter("messageType", myMessage.getType()); 122 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 123 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 124 } 125 } 126 127 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 128 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 129 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 130 xmlDocument.setParameter("dateFrom", strdateFrom); 131 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 132 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 133 xmlDocument.setParameter("dateTo", strdateTo); 134 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 135 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 136 xmlDocument.setParameter("parammProductId", strmProductId); 140 xmlDocument.setParameter("paramProductDescription", ReportProductionCostData.mProductDescription(this, strmProductId)); 141 142 xmlDocument.setData("structure", data); 144 response.setContentType("text/html; charset=UTF-8"); 145 PrintWriter out = response.getWriter(); 146 out.println(xmlDocument.print()); 147 out.close(); 148 } 149 150 151 void printPageOpen(HttpServletResponse response, VariablesSecureApp vars, String strdateFrom, String strdateTo, String strmProductId, String strId, String strLevel) throws IOException, ServletException { 152 if (log4j.isDebugEnabled()) log4j.debug("Output: ajax"); 154 XmlDocument xmlDocument = null; 155 String [] discard = {"discard", "discard", "discard", "discard"}; 156 ReportProductionCostData[] dataMaterial = ReportProductionCostData.selectMaterial(this, strId, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId); 157 if (dataMaterial == null || dataMaterial.length == 0){ 158 dataMaterial = ReportProductionCostData.set(); 159 discard[0] = "structureMaterial"; 160 } 161 ReportProductionCostData[] dataMachine = ReportProductionCostData.selectMachine(this, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId); 162 if (dataMachine == null || dataMachine.length == 0) { 163 dataMachine = ReportProductionCostData.set(); 164 discard[1] = "structureMachine"; 165 } 166 ReportProductionCostData[] dataIndirect = ReportProductionCostData.selectIndirect(this, strLevel, strdateFrom, DateTimeData.nDaysAfter(this, strdateTo,"1"), strmProductId); 167 if (dataIndirect == null || dataIndirect.length == 0) { 168 dataIndirect = ReportProductionCostData.set(); 169 discard[2] = "structureIndirect"; 170 } 171 ReportProductionCostData[] dataEmployee = ReportProductionCostData.selectEmployee(this, strLevel, strdateFrom, strdateTo, strmProductId); 172 if (dataEmployee == null || dataEmployee.length == 0) { 173 dataEmployee = ReportProductionCostData.set(); 174 discard[3] = "structureEmployee"; 175 } 176 177 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportProductionCostSubreport", discard).createXmlDocument(); 178 xmlDocument.setData("structureMaterial", dataMaterial); 180 xmlDocument.setData("structureMachine", dataMachine); 181 xmlDocument.setData("structureIndirect", dataIndirect); 182 xmlDocument.setData("structureEmployee", dataEmployee); 183 184 response.setContentType("text/plain"); 185 response.setHeader("Cache-Control", "no-cache"); 186 PrintWriter out = response.getWriter(); 187 out.println(xmlDocument.print()); 189 out.close(); 190 } 191 192 209 210 public String getServletInfo() { 211 return "Servlet ReportProductionCost."; 212 } } 214 215 | Popular Tags |