KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_process > PrintInvoices


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-2007 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19
20 package org.openbravo.erpCommon.ad_process;
21
22 import org.openbravo.erpCommon.utility.*;
23 import org.openbravo.erpCommon.businessUtility.*;
24
25 import org.openbravo.erpCommon.ad_actionButton.*;
26
27 import org.openbravo.base.secureApp.HttpSecureAppServlet;
28 import org.openbravo.base.secureApp.VariablesSecureApp;
29 import org.openbravo.xmlEngine.XmlDocument;
30 import java.io.*;
31 import javax.servlet.*;
32 import javax.servlet.http.*;
33
34 import org.openbravo.erpCommon.ad_combos.OrganizationComboData;
35
36
37 public class PrintInvoices extends HttpSecureAppServlet {
38   
39
40   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
41     VariablesSecureApp vars = new VariablesSecureApp(request);
42
43     if (!Utility.hasProcessAccess(this, vars, "", "Invoice_Print")) {
44       bdError(response, "AccessTableNoView", vars.getLanguage());
45       return;
46     }
47
48     if (vars.commandIn("DEFAULT")) {
49       printPageDataSheet(response, vars);
50     } else pageError(response);
51   }
52
53   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars)
54     throws IOException, ServletException {
55     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
56     response.setContentType("text/html; charset=UTF-8");
57     PrintWriter out = response.getWriter();
58     XmlDocument xmlDocument=null;
59     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_process/PrintInvoices").createXmlDocument();
60     
61     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "PrintInvoices", false, "", "", "",false, "ad_process", strReplaceWith, false, true);
62     toolbar.prepareSimpleToolBarTemplate();
63     xmlDocument.setParameter("toolbar", toolbar.toString());
64
65     ActionButtonDefaultData[] data = null;
66     String JavaDoc strHelp="", strDescription="";
67     if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, classInfo.id);
68     else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), classInfo.id);
69
70     if (data!=null && data.length!=0) {
71       strDescription = data[0].description;
72       strHelp = data[0].help;
73     }
74     xmlDocument.setParameter("help", strHelp);
75     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
76     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
77     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
78     xmlDocument.setData("reportAD_ORGID", "liststructure", OrganizationComboData.selectCombo(this, vars.getRole()));
79     
80     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
81     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
82     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
83     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
84     
85     // New interface paramenters
86
try {
87         KeyMap key = new KeyMap(this, vars, "PrintInvoices.html");
88         xmlDocument.setParameter("keyMap", key.getActionButtonKeyMaps());
89       } catch (Exception JavaDoc ex) {
90         throw new ServletException(ex);
91       }
92       try {
93         WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_process.PrintInvoices");
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(), "PrintInvoices.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
99         xmlDocument.setParameter("navigationBar", nav.toString());
100         LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "PrintInvoices.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("PrintInvoices");
107         vars.removeMessage("PrintInvoices");
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      ////----
116

117     out.println(xmlDocument.print());
118     out.close();
119   }
120
121   public String JavaDoc getServletInfo() {
122     return "Servlet ReportInvoices. This Servlet was made by Pablo Sarobe";
123   } // end of getServletInfo() method
124
}
125
126
Free Books   Free Magazines  
Popular Tags