1 19 20 package org.openbravo.erpCommon.ad_reports; 21 22 23 import org.openbravo.erpCommon.utility.Utility; 24 import org.openbravo.erpCommon.businessUtility.Tree; 25 import org.openbravo.base.secureApp.HttpSecureAppServlet; 26 import org.openbravo.base.secureApp.VariablesSecureApp; 27 import org.openbravo.xmlEngine.XmlDocument; 28 import java.io.*; 29 import javax.servlet.*; 30 import javax.servlet.http.*; 31 import org.openbravo.erpCommon.utility.*; 32 import org.openbravo.erpCommon.businessUtility.WindowTabs; 33 34 import org.openbravo.erpCommon.utility.DateTimeData; 35 36 public class ReportTrialBalanceDetail extends HttpSecureAppServlet { 37 38 39 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 40 VariablesSecureApp vars = new VariablesSecureApp(request); 41 42 if (!Utility.hasProcessAccess(this, vars, "", "ReportTrialBalanceDetail")) { 43 bdError(response, "AccessTableNoView", vars.getLanguage()); 44 return; 45 } 46 47 if (vars.commandIn("DEFAULT")) { 48 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportTrialBalanceDetailDetail|DateFrom", ""); 49 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportTrialBalanceDetailDetail|DateTo", ""); 50 String strOrg = vars.getGlobalVariable("inpOrg", "ReportTrialBalanceDetailDetail|Org", ""); 51 String strLevel = vars.getGlobalVariable("inpLevel", "ReportTrialBalanceDetailDetail|Level", ""); 52 String strId = vars.getGlobalVariable("inpcElementValueId", "ReportTrialBalanceDetailDetail|Id", ""); 53 printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strId); 54 } else if (vars.commandIn("FIND")) { 55 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTrialBalanceDetailDetail|DateFrom"); 56 String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTrialBalanceDetailDetail|DateTo"); 57 String strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTrialBalanceDetailDetail|Org"); 58 String strLevel = vars.getRequestGlobalVariable("inpLevel", "ReportTrialBalanceDetailDetail|Level"); 59 String strId = vars.getRequestGlobalVariable("inpcElementValueId", "ReportTrialBalanceDetailDetail|Id"); 60 printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strId); 61 }else pageError(response); 62 } 63 64 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strOrg, String strLevel, String strId) 65 throws IOException, ServletException { 66 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 67 response.setContentType("text/html; charset=UTF-8"); 68 PrintWriter out = response.getWriter(); 69 String discard[]={"sectionDiscard"}; 70 XmlDocument xmlDocument=null; 71 String strTreeOrg = ReportTrialBalanceDetailData.treeOrg(this, vars.getClient()); 72 String strOrgFamily = getFamily(strTreeOrg, strOrg); 73 String strTreeAccount = ReportTrialBalanceDetailData.treeAccount(this, vars.getClient()); 74 ReportTrialBalanceDetailData [] data = null; 75 if (strDateFrom.equals("") && strDateTo.equals("")) { 76 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalanceDetail", discard).createXmlDocument(); 77 data = ReportTrialBalanceDetailData.set(); 78 } else { 79 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTrialBalanceDetail").createXmlDocument(); 80 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - getFamily - strTreeAccount = " + strTreeAccount); 81 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - getFamily - strId = " + strId); 82 String strIdFamily = getFamily(strTreeAccount, strId); 83 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strOrgFamily = " + strOrgFamily); 84 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - #User_Client = " + Utility.getContext(this, vars, "#User_Client", "ReportTrialBalanceDetail")); 85 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - #User_Org = " + Utility.getContext(this, vars, "#User_Org", "ReportTrialBalanceDetail")); 86 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strDateFrom = " + strDateFrom); 87 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strDateTo = " + DateTimeData.nDaysAfter(this, strDateTo,"1")); 88 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strIdFamily = " + strIdFamily); 89 if (log4j.isDebugEnabled()) log4j.debug("printPageDataSheet - select - strId = " + strId); 90 data = ReportTrialBalanceDetailData.select(this, strOrgFamily, Utility.getContext(this, vars, "#User_Client", "ReportTrialBalanceDetail"), Utility.getContext(this, vars, "#User_Org", "ReportTrialBalanceDetail"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strIdFamily, strId); 91 } 92 93 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportTrialBalanceDetail", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 94 toolbar.prepareSimpleToolBarTemplate(); 95 xmlDocument.setParameter("toolbar", toolbar.toString()); 96 try { 97 KeyMap key = new KeyMap(this, vars, "ReportTrialBalanceDetail.html"); 98 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 99 } catch (Exception ex) { 100 throw new ServletException(ex); 101 } 102 try { 103 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportTrialBalanceDetail"); 104 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 105 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 106 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 107 xmlDocument.setParameter("theme", vars.getTheme()); 108 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportTrialBalanceDetail.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 109 xmlDocument.setParameter("navigationBar", nav.toString()); 110 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportTrialBalanceDetail.html", strReplaceWith); 111 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 112 } catch (Exception ex) { 113 throw new ServletException(ex); 114 } 115 { 116 OBError myMessage = vars.getMessage("ReportTrialBalanceDetail"); 117 vars.removeMessage("ReportTrialBalanceDetail"); 118 if (myMessage!=null) { 119 xmlDocument.setParameter("messageType", myMessage.getType()); 120 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 121 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 122 } 123 } 124 125 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 126 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 127 xmlDocument.setParameter("account", ReportTrialBalanceDetailData.selectAccountName(this, strId)); 128 xmlDocument.setData("structure1", data); 129 out.println(xmlDocument.print()); 130 out.close(); 131 } 132 133 public String getFamily(String strTree, String strChild) throws IOException, ServletException { 134 return Tree.getMembers(this, strTree, strChild); 135 145 } 146 147 public String getServletInfo() { 148 return "Servlet ReportTrialBalanceDetail. This Servlet was made by Eduardo Argal"; 149 } } 151 152 | Popular Tags |