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 ReportCash 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_ReportCash")) { 39 bdError(response, "AccessTableNoView", vars.getLanguage()); 40 return; 41 } 42 43 if (vars.commandIn("DEFAULT")) { 44 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportCash|DateFrom", ""); 45 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportCash|DateTo", ""); 46 String strCashbook = vars.getGlobalVariable("inpcCashbookId", "ReportCash|Cashbook", ""); 47 printPageDataSheet(response, vars, strDateFrom, strDateTo, strCashbook); 48 } else if (vars.commandIn("FIND")) { 49 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportCash|DateFrom"); 50 String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportCash|DateTo"); 51 String strCashbook = vars.getRequestGlobalVariable("inpcCashbookId", "ReportCash|Cashbook"); 52 printPageHtml(response, vars, strDateFrom, strDateTo, strCashbook); 53 } else pageError(response); 54 } 55 56 void printPageHtml(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strCashbook) 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 62 XmlDocument xmlDocument=null; 63 ReportCashData[] data=null; 64 if (strDateFrom.equals("") && strDateTo.equals("")) { 65 printPageDataSheet(response, vars, strDateFrom, strDateTo, strCashbook); 66 } else { 67 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportCashEdit").createXmlDocument(); 68 data = ReportCashData.select(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportCash"), Utility.getContext(this, vars, "#User_Org", "ReportCash"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strCashbook); 69 xmlDocument.setParameter("sumAmount", ReportCashData.BeginningBalance(this, Utility.getContext(this, vars, "#User_Client", "ReportCash"), Utility.getContext(this, vars, "#User_Org", "ReportCash"), strDateFrom, strCashbook)); 70 xmlDocument.setData("structure1", data); 71 out.println(xmlDocument.print()); 72 out.close(); 73 } 74 } 75 76 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strCashbook) 77 throws IOException, ServletException { 78 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 79 response.setContentType("text/html; charset=UTF-8"); 80 PrintWriter out = response.getWriter(); 81 82 XmlDocument xmlDocument=null; 83 ReportCashData[] data=null; 84 85 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportCash").createXmlDocument(); 86 data = ReportCashData.select(this, vars.getLanguage(), Utility.getContext(this, vars, "#User_Client", "ReportCash"), Utility.getContext(this, vars, "#User_Org", "ReportCash"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strCashbook); 87 xmlDocument.setParameter("sumAmount", ReportCashData.BeginningBalance(this, Utility.getContext(this, vars, "#User_Client", "ReportCash"), Utility.getContext(this, vars, "#User_Org", "ReportCash"), strDateFrom, strCashbook)); 88 89 90 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportCash", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 91 toolbar.prepareSimpleToolBarTemplate(); 92 xmlDocument.setParameter("toolbar", toolbar.toString()); 93 try { 94 KeyMap key = new KeyMap(this, vars, "ReportCash.html"); 95 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 96 } catch (Exception ex) { 97 throw new ServletException(ex); 98 } 99 try { 100 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportCash"); 101 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 102 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 103 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 104 xmlDocument.setParameter("theme", vars.getTheme()); 105 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportCash.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 106 xmlDocument.setParameter("navigationBar", nav.toString()); 107 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportCash.html", strReplaceWith); 108 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 109 } catch (Exception ex) { 110 throw new ServletException(ex); 111 } 112 { 113 OBError myMessage = vars.getMessage("ReportCash"); 114 vars.removeMessage("ReportCash"); 115 if (myMessage!=null) { 116 xmlDocument.setParameter("messageType", myMessage.getType()); 117 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 118 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 119 } 120 } 121 122 123 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 124 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 125 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 126 xmlDocument.setParameter("cCashbook", strCashbook); 127 xmlDocument.setParameter("dateFrom", strDateFrom); 128 xmlDocument.setParameter("dateFrom", strDateFrom); 129 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 130 xmlDocument.setParameter("dateTo", strDateTo); 131 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 132 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 133 try { 134 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_CashBook_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportCash"), Utility.getContext(this, vars, "#User_Client", "ReportCash"), 0); 135 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportCash", strCashbook); 136 xmlDocument.setData("reportC_CASHBOOK","liststructure", comboTableData.select(false)); 137 comboTableData = null; 138 } catch (Exception ex) { 139 throw new ServletException(ex); 140 } 141 142 out.println(xmlDocument.print()); 143 out.close(); 144 } 145 146 public String getServletInfo() { 147 return "Servlet ReportCash."; 148 } } 150 151 | Popular Tags |