KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class ReportShipper extends HttpSecureAppServlet {
31
32
33   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
34     VariablesSecureApp vars = new VariablesSecureApp(request);
35
36     if (vars.commandIn("DEFAULT")) {
37       String JavaDoc strFrom = vars.getGlobalVariable("inpFrom", "ReportShipper|From", "");
38       String JavaDoc strTo = vars.getGlobalVariable("inpTo", "ReportShipper|To", "");
39       String JavaDoc strShipper = vars.getGlobalVariable("inpShipper", "ReportShipper|Shipper", "");
40       String JavaDoc strSale = vars.getGlobalVariable("inpSale", "ReportShipper|Sale", "N");
41       String JavaDoc strPurchase = vars.getGlobalVariable("inpPurchase", "ReportShipper|Purchase", "N");
42       String JavaDoc strDetail = vars.getGlobalVariable("inpDetail", "ReportShipper|Detail", "N");
43       printPageDataSheet(response, vars, strFrom, strTo, strShipper, strSale, strPurchase, strDetail);
44     } else if (vars.commandIn("FIND")) {
45       String JavaDoc strFrom = vars.getRequestGlobalVariable("inpFrom", "ReportShipper|From");
46       String JavaDoc strTo = vars.getRequestGlobalVariable("inpTo", "ReportShipper|To");
47       String JavaDoc strShipper = vars.getRequestGlobalVariable("inpShipper", "ReportShipper|Shipper");
48       String JavaDoc strSale = vars.getRequestGlobalVariable("inpSale", "ReportShipper|Sale");
49       String JavaDoc strPurchase = vars.getRequestGlobalVariable("inpPurchase", "ReportShipper|Purchase");
50       String JavaDoc strDetail = vars.getRequestGlobalVariable("inpDetail", "ReportShipper|Detail");
51       printPageDataSheet(response, vars, strFrom, strTo, strShipper, strSale, strPurchase, strDetail);
52     } else pageError(response);
53   }
54
55   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strFrom, String JavaDoc strTo, String JavaDoc strShipper, String JavaDoc strSale, String JavaDoc strPurchase, String JavaDoc strDetail)
56     throws IOException, ServletException {
57     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
58     response.setContentType("text/html; charset=UTF-8");
59     PrintWriter out = response.getWriter();
60     XmlDocument xmlDocument=null;
61     ReportShipperData[] data=null;
62
63     String JavaDoc discard[]= {""};
64     if (!strDetail.equals("Y")) discard[0] = "reportLine";
65     if (vars.commandIn("DEFAULT")) discard[0] = "selEliminar";
66
67
68     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportShipper", discard).createXmlDocument();
69
70     String JavaDoc strIsSOTrx = "";
71     if (strSale.equals("Y") && !strPurchase.equals("Y")) strIsSOTrx = "Y";
72     else if (!strSale.equals("Y") && strPurchase.equals("Y")) strIsSOTrx = "N";
73     else if (!strSale.equals("Y") && !strPurchase.equals("Y")) strIsSOTrx = "D";
74
75     if (log4j.isDebugEnabled()) log4j.debug("****data passed from: " + strFrom + " to: " +strTo + " shiper: " + strShipper + " isso " + strIsSOTrx + " det " + strDetail);
76     data = ReportShipperData.select(this, vars.getLanguage(), strFrom, strTo, strShipper, strIsSOTrx);
77
78     ReportShipperData[][] dataLine = new ReportShipperData[0][0];
79     if (data != null && data.length > 0) {
80       dataLine = new ReportShipperData[data.length][];
81
82       for (int i=0; i<data.length ; i++) {
83         if (log4j.isDebugEnabled()) log4j.debug("shipment " + data[i].shipmentid);
84         dataLine[i] = ReportShipperData.selectLine(this, vars.getLanguage(), data[i].shipmentid);
85         //if (RawMaterialData[i] == null || RawMaterialData[i].length == 0) RawMaterialData[i] = ReportRawMaterialData.set();
86
}
87     } //else dataLine[0] = ReportShipperData.set();
88

89
90     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportShipper", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
91     toolbar.prepareSimpleToolBarTemplate();
92     xmlDocument.setParameter("toolbar", toolbar.toString());
93
94     try {
95       KeyMap key = new KeyMap(this, vars, "ReportShipper.html");
96       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
97     } catch (Exception JavaDoc ex) {
98       throw new ServletException(ex);
99     }
100     try {
101       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportShipper");
102       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
103       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
104       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
105       xmlDocument.setParameter("theme", vars.getTheme());
106       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportShipper.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
107       xmlDocument.setParameter("navigationBar", nav.toString());
108       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportShipper.html", strReplaceWith);
109       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
110     } catch (Exception JavaDoc ex) {
111       throw new ServletException(ex);
112     }
113     {
114       OBError myMessage = vars.getMessage("ReportShipper");
115       vars.removeMessage("ReportShipper");
116       if (myMessage!=null) {
117         xmlDocument.setParameter("messageType", myMessage.getType());
118         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
119         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
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("paramFrom", strFrom);
127     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
128     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
129     xmlDocument.setParameter("paramTo", strTo);
130     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
131     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
132     xmlDocument.setParameter("paramSale", strSale);
133     xmlDocument.setParameter("paramPurchase", strPurchase);
134     xmlDocument.setParameter("paramDetalle", strDetail);
135
136     xmlDocument.setParameter("paramShipper", strShipper);
137     try {
138       ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Shipper_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportShipper"), Utility.getContext(this, vars, "#User_Client", "ReportShipper"), 0);
139       Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportShipper", strShipper);
140       xmlDocument.setData("reportShipper","liststructure", comboTableData.select(false));
141       comboTableData = null;
142     } catch (Exception JavaDoc ex) {
143       throw new ServletException(ex);
144     }
145
146
147     xmlDocument.setData("structure", data);
148     xmlDocument.setDataArray("reportLine","structureLine", dataLine);
149     out.println(xmlDocument.print());
150     out.close();
151   }
152
153   public String JavaDoc getServletInfo() {
154     return "Servlet ReportShipper.";
155   } // end of getServletInfo() method
156
}
157
158
Popular Tags