KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 ReportInvoiceDiscount 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_ReportInvoiceCustomer")) {
39       bdError(response, "AccessTableNoView", vars.getLanguage());
40       return;
41     }
42
43     if (vars.commandIn("DEFAULT")){
44       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportInvoiceDiscount|dateFrom", "");
45       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateTo", "ReportInvoiceDiscount|dateTo", "");
46       String JavaDoc strcBpartnerId = vars.getInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceDiscount|partner", "");
47       String JavaDoc strDiscount = vars.getGlobalVariable("inpDiscount", "ReportInvoiceDiscount|discount", "N");
48       printPageDataSheet(response, vars, strDateFrom, strDateTo, strcBpartnerId, strDiscount);
49     } else if (vars.commandIn("FIND")) {
50       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportInvoiceDiscount|dateFrom", "");
51       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateTo", "ReportInvoiceDiscount|dateTo", "");
52       String JavaDoc strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceDiscount|partner");
53       String JavaDoc strDiscount = vars.getRequestGlobalVariable("inpDiscount", "ReportInvoiceDiscount|discount");
54       printPageDataHtml(response, vars, strDateFrom, strDateTo, strcBpartnerId, strDiscount);
55     } else pageError(response);
56   }
57
58   void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strcBpartnerId, String JavaDoc strDiscount) throws IOException, ServletException {
59     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
60  
61     XmlDocument xmlDocument=null;
62     if (strDiscount.equals("")) strDiscount = "N";
63     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceDiscountEdit").createXmlDocument();
64
65     
66     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
67     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
68
69     xmlDocument.setData("structure1", ReportInvoiceDiscountData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportInvoiceDiscount"), Utility.getContext(this, vars, "#User_Org", "ReportInvoiceDiscount"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strcBpartnerId, (strDiscount.equals("N"))?"":"discount"));
70     response.setContentType("text/html; charset=UTF-8");
71     PrintWriter out = response.getWriter();
72     out.println(xmlDocument.print());
73     out.close();
74   }
75   
76   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strcBpartnerId, String JavaDoc strDiscount) throws IOException, ServletException {
77     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
78     
79     XmlDocument xmlDocument=null;
80     if (strDiscount.equals("")) strDiscount = "N";
81     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceDiscount").createXmlDocument();
82
83     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceDiscountReportInvoiceDiscount", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
84     toolbar.prepareSimpleToolBarTemplate();
85     xmlDocument.setParameter("toolbar", toolbar.toString());
86     try {
87       KeyMap key = new KeyMap(this, vars, "ReportInvoiceDiscount.html");
88       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
89     } catch (Exception JavaDoc ex) {
90       throw new ServletException(ex);
91     }
92     try {
93       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceDiscount");
94       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
95       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
96       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
97       xmlDocument.setParameter("theme", vars.getTheme());
98       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceDiscount.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
99       xmlDocument.setParameter("navigationBar", nav.toString());
100       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceDiscount.html", strReplaceWith);
101       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
102     } catch (Exception JavaDoc ex) {
103       throw new ServletException(ex);
104     }
105     {
106       OBError myMessage = vars.getMessage("ReportInvoiceDiscount");
107       vars.removeMessage("ReportInvoiceDiscount");
108       if (myMessage!=null) {
109         xmlDocument.setParameter("messageType", myMessage.getType());
110         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
111         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
112       }
113     }
114
115     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
116     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
117     xmlDocument.setParameter("dateFrom", strDateFrom);
118     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
119     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
120     xmlDocument.setParameter("dateTo", strDateTo);
121     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
122     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
123     xmlDocument.setParameter("discount", strDiscount);
124     xmlDocument.setData("reportCBPartnerId_IN", "liststructure", ReportInvoiceDiscountData.selectBpartner(this, Utility.getContext(this, vars, "#User_Org", "ReportInvoiceDiscount"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceDiscount"), strcBpartnerId));
125     
126     response.setContentType("text/html; charset=UTF-8");
127     PrintWriter out = response.getWriter();
128     out.println(xmlDocument.print());
129     out.close();
130   }
131
132   
133   /*void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strcBpartnerId, String strDiscount) throws IOException, ServletException {
134     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
135     String discard[]={"discard"};
136     XmlDocument xmlDocument=null;
137     if (strDiscount.equals("")) strDiscount = "N";
138     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceDiscount").createXmlDocument();
139
140     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceDiscountReportInvoiceDiscount", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
141     toolbar.prepareSimpleToolBarTemplate();
142     xmlDocument.setParameter("toolbar", toolbar.toString());
143     try {
144       KeyMap key = new KeyMap(this, vars, "ReportInvoiceDiscount.html");
145       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
146     } catch (Exception ex) {
147       throw new ServletException(ex);
148     }
149     try {
150       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceDiscount");
151       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
152       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
153       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
154       xmlDocument.setParameter("theme", vars.getTheme());
155       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceDiscount.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
156       xmlDocument.setParameter("navigationBar", nav.toString());
157       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceDiscount.html", strReplaceWith);
158       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
159     } catch (Exception ex) {
160       throw new ServletException(ex);
161     }
162     {
163       OBError myMessage = vars.getMessage("ReportInvoiceDiscount");
164       vars.removeMessage("ReportInvoiceDiscount");
165       if (myMessage!=null) {
166         xmlDocument.setParameter("messageType", myMessage.getType());
167         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
168         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
169       }
170     }
171
172     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
173     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
174     xmlDocument.setParameter("dateFrom", strDateFrom);
175     xmlDocument.setParameter("dateTo", strDateTo);
176     xmlDocument.setParameter("discount", strDiscount);
177     xmlDocument.setData("reportCBPartnerId_IN", "liststructure", ReportInvoiceDiscountData.selectBpartner(this, Utility.getContext(this, vars, "#User_Org", "ReportInvoiceDiscount"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceDiscount"), strcBpartnerId));
178     xmlDocument.setData("structure1", ReportInvoiceDiscountData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportInvoiceDiscount"), Utility.getContext(this, vars, "#User_Org", "ReportInvoiceDiscount"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strcBpartnerId, (strDiscount.equals("N"))?"":"discount"));
179     response.setContentType("text/html; charset=UTF-8");
180     PrintWriter out = response.getWriter();
181     out.println(xmlDocument.print());
182     out.close();
183   }*/

184
185
186   public String JavaDoc getServletInfo() {
187     return "Servlet ReportInvoiceDiscount. This Servlet was made by Pablo Sarobe";
188   } // end of getServletInfo() method
189
}
190
191
Popular Tags