KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_reports > ReportNotPosted


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18  */

19
20 package org.openbravo.erpCommon.ad_reports;
21
22 import java.io.*;
23 import javax.servlet.*;
24 import javax.servlet.http.*;
25 import org.openbravo.base.secureApp.HttpSecureAppServlet;
26 import org.openbravo.base.secureApp.VariablesSecureApp;
27 import org.openbravo.erpCommon.businessUtility.WindowTabs;
28 import org.openbravo.erpCommon.utility.*;
29 import org.openbravo.xmlEngine.XmlDocument;
30
31 public class ReportNotPosted extends HttpSecureAppServlet {
32   //static Category log4j = Category.getInstance(ReportNotPosted.class);
33

34   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
35     VariablesSecureApp vars = new VariablesSecureApp(request);
36
37     if (!Utility.hasProcessAccess(this, vars, "", "ReportNotPosted")) {
38       bdError(response, "AccessTableNoView", vars.getLanguage());
39       return;
40     }
41
42     if (vars.commandIn("DEFAULT")) {
43       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportNotPosted|DateFrom", "");
44       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateTo", "ReportNotPosted|DateTo", "");
45       printPageDataSheet(response, vars, strDateFrom, strDateTo);
46     } else if (vars.commandIn("FIND")) {
47       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportNotPosted|DateFrom");
48       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportNotPosted|DateTo");
49       printPageDataSheet(response, vars, strDateFrom, strDateTo);
50     } else pageError(response);
51   }
52
53   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo)
54     throws IOException, ServletException {
55     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
56     response.setContentType("text/html");
57     PrintWriter out = response.getWriter();
58     String JavaDoc discard[]={"sectionDocType"};
59     XmlDocument xmlDocument=null;
60     ReportNotPostedData[] data=null;
61     if (strDateFrom.equals("") && strDateTo.equals("")) {
62       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportNotPosted", discard).createXmlDocument();
63       data = ReportNotPostedData.set();
64     } else {
65       xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportNotPosted").createXmlDocument();
66       data = ReportNotPostedData.select(this, strDateFrom,strDateTo);
67     }//DateTimeData.nDaysAfter
68

69
70     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportNotPosted", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
71     toolbar.prepareSimpleToolBarTemplate();
72
73     xmlDocument.setParameter("toolbar", toolbar.toString());
74
75     try {
76       KeyMap key = new KeyMap(this, vars, "ReportNotPosted.html");
77       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
78     } catch (Exception JavaDoc ex) {
79       throw new ServletException(ex);
80     }
81     try {
82       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportNotPosted");
83       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
84       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
85       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
86       xmlDocument.setParameter("theme", vars.getTheme());
87       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportNotPosted.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
88       xmlDocument.setParameter("navigationBar", nav.toString());
89       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportNotPosted.html", strReplaceWith);
90       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
91     } catch (Exception JavaDoc ex) {
92       throw new ServletException(ex);
93     }
94     {
95       OBError myMessage = vars.getMessage("ReportNotPosted");
96       vars.removeMessage("ReportNotPosted");
97       if (myMessage!=null) {
98         xmlDocument.setParameter("messageType", myMessage.getType());
99         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
100         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
101       }
102     }
103
104     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
105     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
106     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
107     xmlDocument.setParameter("dateFrom", strDateFrom);
108     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
109     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
110     xmlDocument.setParameter("dateTo", strDateTo);
111     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
112     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
113     xmlDocument.setData("structure1", data);
114     out.println(xmlDocument.print());
115     out.close();
116   }
117
118   public String JavaDoc getServletInfo() {
119     return "Servlet ReportNotPosted. This Servlet was made by Juan Pablo Calvente";
120   } // end of the getServletInfo() method
121
}
122
Popular Tags