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.AccountNumberComboData; 31 32 33 public class ReportCashflowForecast extends HttpSecureAppServlet { 34 35 36 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 37 VariablesSecureApp vars = new VariablesSecureApp(request); 38 39 if (vars.commandIn("DEFAULT")) { 40 String strBankAccount = vars.getRequestGlobalVariable("inpcBankAccountId", "ReportCashflowForecast|AcctNo"); 41 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportCashflowForecast|DateFrom"); 42 String strBreakDate = vars.getRequestGlobalVariable("inpBreakDate", "ReportCashflowForecast|BreakDate"); 43 44 printPageDataSheet(response, vars, strBankAccount, strDateFrom, strBreakDate, true); 45 } else if (vars.commandIn("FIND")) { 46 String strBankAccount = vars.getRequestGlobalVariable("inpcBankAccountId", "ReportCashflowForecast|AcctNo"); 47 String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportCashflowForecast|DateFrom"); 48 String strBreakDate = vars.getRequestGlobalVariable("inpBreakDate", "ReportCashflowForecast|BreakDate"); 49 50 printPageDataSheet(response, vars, strBankAccount, strDateFrom, strBreakDate, false); 51 }else pageError(response); 52 } 53 54 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strBankAccount, String strDateMax, String strBreakDate, boolean showDefault) throws IOException, ServletException { 55 String [] discard = {"",""}; 56 XmlDocument xmlDocument = null; 57 58 if (showDefault) 59 discard[0] = "subrpt"; 60 else { 61 if (strBreakDate.equals("")) discard[0] = "reportAccountDate"; 62 else discard[0] = "reportAccount"; 63 } 64 65 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportCashflowForecast", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 66 67 ReportCashflowForecastData[] dataSummary = ReportCashflowForecastData.select(this,strDateMax,"",Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars, "#User_Org", "ReportBank")); 69 70 if (!showDefault) { 71 ReportCashflowForecastData[][] data = null; 72 ReportCashflowForecastData[] dataAcct = null; 73 ReportCashflowForecastData[] dataDetail = null; 74 75 dataAcct = ReportCashflowForecastData.select(this,strDateMax,strBankAccount,Utility.getContext(this, vars, "#User_Client", "ReportBank"), Utility.getContext(this, vars, "#User_Org", "ReportBank")); 77 data = new ReportCashflowForecastData[dataAcct.length][]; 78 79 if (log4j.isDebugEnabled()) log4j.debug("length: "+dataAcct.length+" - bankaccount:"+strBankAccount); 80 if (dataAcct.length==0) { 81 discard[0] = "reportAccountDate"; 82 discard[1] = "reportAccount"; 83 } else { 84 for (int i =0; i < dataAcct.length; i++){ 85 if (strBreakDate.equals("")) 86 dataDetail = ReportCashflowForecastData.selectLines(this, vars.getSqlDateFormat(), vars.getLanguage(), dataAcct[i].cBankaccountId, strDateMax, "2 DESC, 1"); 87 else 88 dataDetail = ReportCashflowForecastData.selectLines(this, vars.getSqlDateFormat(), vars.getLanguage(), dataAcct[i].cBankaccountId, strDateMax, "1,2 DESC"); 89 if (log4j.isDebugEnabled()) log4j.debug("length: "+dataAcct.length+" bankacct:"+dataAcct[i].cBankaccountId+" lenght:"+dataDetail.length); 90 data[i] = dataDetail; 91 } 92 } 93 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportCashflowForecast",discard).createXmlDocument(); 94 95 xmlDocument.setData("structureDetail",dataAcct); 96 if (strBreakDate.equals("")) 97 xmlDocument.setDataArray("reportAcct","structureAccount",data); 98 else 99 xmlDocument.setDataArray("reportAcctDate","structureAccount",data); 100 } else 101 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportCashflowForecast",discard).createXmlDocument(); 102 103 104 106 toolbar.prepareSimpleToolBarTemplate(); 107 xmlDocument.setParameter("toolbar", toolbar.toString()); 108 xmlDocument.setData("reportC_ACCOUNTNUMBER","liststructure",AccountNumberComboData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportCashflowForecast"), Utility.getContext(this, vars, "#User_Org", "ReportCashflowForecast"))); 109 xmlDocument.setParameter("cBankAccount", strBankAccount); 110 xmlDocument.setParameter("dateFrom",strDateMax); 111 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 112 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 113 xmlDocument.setParameter("finalDate",strDateMax); 114 xmlDocument.setParameter("date",ReportCashflowForecastData.getDate(this, vars.getSqlDateFormat())); 115 xmlDocument.setParameter("date1",ReportCashflowForecastData.getDate(this, vars.getSqlDateFormat())); 116 xmlDocument.setParameter("breakDate",strBreakDate.equals("")?"0":"1"); 117 xmlDocument.setData("structureSummary",dataSummary); 118 119 try { 120 KeyMap key = new KeyMap(this, vars, "ReportCashflowForecast.html"); 121 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 122 } catch (Exception ex) { 123 throw new ServletException(ex); 124 } 125 try { 126 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportCashflowForecast"); 127 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 128 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 129 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 130 xmlDocument.setParameter("theme", vars.getTheme()); 131 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportCashflowForecast.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 132 xmlDocument.setParameter("navigationBar", nav.toString()); 133 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportCashflowForecast.html", strReplaceWith); 134 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 135 } catch (Exception ex) { 136 throw new ServletException(ex); 137 } 138 { 139 OBError myMessage = vars.getMessage("ReportCashflowForecast"); 140 vars.removeMessage("ReportCashflowForecast"); 141 if (myMessage!=null) { 142 xmlDocument.setParameter("messageType", myMessage.getType()); 143 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 144 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 145 } 146 } 147 148 149 response.setContentType("text/html; charset=UTF-8"); 150 PrintWriter out = response.getWriter(); 151 out.println(xmlDocument.print()); 152 out.close(); 153 } 154 155 156 public String getServletInfo() { 157 return "Servlet ReportCashflowForecast"; 158 } } 160 | Popular Tags |