KickJava   Java API By Example, From Geeks To Geeks.

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


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.erpCommon.businessUtility.Tree;
24 import org.openbravo.erpCommon.businessUtility.TreeData;
25 import org.openbravo.base.secureApp.HttpSecureAppServlet;
26 import org.openbravo.base.secureApp.VariablesSecureApp;
27 import org.openbravo.xmlEngine.XmlDocument;
28 import java.io.*;
29 import javax.servlet.*;
30 import javax.servlet.http.*;
31 import org.openbravo.erpCommon.ad_combos.OrganizationComboData;
32
33 import org.openbravo.erpCommon.utility.DateTimeData;
34
35 import java.util.HashMap JavaDoc;
36 import net.sf.jasperreports.engine.*;
37 import net.sf.jasperreports.engine.design.JasperDesign;
38
39
40
41 public class ReportTaxInvoiceJR extends HttpSecureAppServlet {
42
43   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
44     VariablesSecureApp vars = new VariablesSecureApp(request);
45
46     if (vars.commandIn("DEFAULT")) {
47       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportTaxInvoiceJR|DateFrom", "");
48       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateTo", "ReportTaxInvoiceJR|DateTo", "");
49       String JavaDoc strOrg = vars.getGlobalVariable("inpOrg", "ReportTaxInvoiceJR|Org", "0");
50       String JavaDoc strDetail = vars.getStringParameter("inpDetalle", "-1");
51       String JavaDoc strSales = vars.getStringParameter("inpSales", "S");
52       printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
53     } else if (vars.commandIn("FIND")) {
54       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTaxInvoiceJR|DateFrom");
55       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTaxInvoiceJR|DateTo");
56       String JavaDoc strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTaxInvoiceJR|Org");
57       if (strOrg.equals("")) strOrg = "0";
58       String JavaDoc strDetail = vars.getStringParameter("inpDetalle");
59       String JavaDoc strSales = vars.getStringParameter("inpSales");
60       printPageDataHtml(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
61     } else if (vars.commandIn("RELATION_XLS")) {
62       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTaxInvoiceJR|DateFrom");
63       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTaxInvoiceJR|DateTo");
64       String JavaDoc strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTaxInvoiceJR|Org");
65       if (strOrg.equals("")) strOrg = "0";
66       String JavaDoc strDetail = vars.getStringParameter("inpDetalle");
67       String JavaDoc strSales = vars.getStringParameter("inpSales");
68       printPageDataExcel(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
69     } else pageError(response);
70   }
71
72   void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strOrg, String JavaDoc strDetail, String JavaDoc strSales)
73     throws IOException, ServletException {
74     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
75     response.setContentType("text/html; charset=UTF-8");
76     XmlDocument xmlDocument=null;
77     ReportTaxInvoiceData[] dataSale=null;
78     ReportTaxInvoiceData[] data2Sale=null;
79     ReportTaxInvoiceData[] dataPurchase=null;
80     ReportTaxInvoiceData[] data2Purchase=null;
81     String JavaDoc strSalesAux;
82     String JavaDoc strTitle = "FACTURAS CON EL EXTRANJERO";
83     String JavaDoc strSale = "";
84     String JavaDoc strPurchase = "";
85     String JavaDoc discard[] = {"discard", "discard", "discard", "discard"};
86     if (log4j.isDebugEnabled()) log4j.debug("****** strSales: " + strSales + " fecha desde: " + strDateFrom + " fecha hasta: " + strDateTo + " detalle: " + strDetail);
87     /* if (strSales.equals("S")) strSalesAux = "Y";
88           else strSalesAux = "N";*/

89     if (strDateFrom.equals("") && strDateTo.equals("") && strDetail.equals("-1")) {
90       printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
91     } else if (!strDetail.equals("-1")){
92       if (log4j.isDebugEnabled()) log4j.debug("****** not datailed");
93       discard[0] = "selEliminarSale";
94       discard[1] = "selEliminar1Sale";
95       discard[2] = "selEliminarPurchase";
96       discard[3] = "selEliminar1Purchase";
97       if (strSales.equals("S")) {
98         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
99         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
100         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
101       } else if (strSales.equals("P")) {
102         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
103         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
104         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
105       } else {
106         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
107         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
108         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
109         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
110         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
111         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
112       }
113     } else {
114       if (log4j.isDebugEnabled()) log4j.debug("****** detailed");
115       if (strSales.equals("S")) {
116         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
117         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
118         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
119       } else if (strSales.equals("P")) {
120         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
121         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
122         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
123       } else {
124         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
125         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
126         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
127         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoiceJR"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
128         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
129         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
130       }
131     }
132     if (log4j.isDebugEnabled()) log4j.debug("****** strSale: " + strSale + " strPurchase: " + strPurchase);
133     if (log4j.isDebugEnabled()) log4j.debug("****** check nulls");
134     if (dataSale == null || dataSale.length == 0){
135       discard [0] = "sectionTaxSale";
136       dataSale = ReportTaxInvoiceData.set();
137     }
138     if (data2Sale == null || data2Sale.length == 0){
139       discard [1] = "sectionTaxForeignSale";
140       strTitle = "";
141       data2Sale = ReportTaxInvoiceData.set();
142     }
143     if (dataPurchase == null || dataPurchase.length == 0){
144       discard [2] = "sectionTaxPurchase";
145       dataPurchase = ReportTaxInvoiceData.set();
146     }
147     if (data2Purchase == null || data2Purchase.length == 0){
148       discard [3] = "sectionTaxForeignPurchase";
149       strTitle = "";
150       data2Purchase = ReportTaxInvoiceData.set();
151     }
152     if (log4j.isDebugEnabled()) log4j.debug("****** xmlDocument");
153 // xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTaxInvoiceEdit", discard).createXmlDocument();
154

155     
156    
157
158 /* if (log4j.isDebugEnabled()) log4j.debug("****** setData dataSale");
159     xmlDocument.setData("structure1Sale", dataSale);
160     if (log4j.isDebugEnabled()) log4j.debug("****** setData data2Sale");
161     xmlDocument.setData("structure2Sale", data2Sale);
162     if (log4j.isDebugEnabled()) log4j.debug("****** setData dataPurchase");
163     xmlDocument.setData("structure1Purchase", dataPurchase);
164     if (log4j.isDebugEnabled()) log4j.debug("****** setData data2Purchase");
165     xmlDocument.setData("structure2Purchase", data2Purchase);*/

166
167       JasperPrint jasperPrint;
168       String JavaDoc strOutput = "html";
169       String JavaDoc strReportName = "@basedesign@/org/openbravo/erpCommon/ad_reports/ReportTaxInvoice.jrxml";
170
171 // data = ReportPurchaseDimensionalAnalysesData.selectNoComparative(this, strTextShow[0], strTextShow[1], strTextShow[2], strTextShow[3], strTextShow[4], Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg), Utility.getContext(this, vars, "#User_Client", "ReportPurchaseDimensionalAnalyses"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strOrderby);
172
HashMap JavaDoc<String JavaDoc, Object JavaDoc> parameters = new HashMap JavaDoc<String JavaDoc, Object JavaDoc>();
173         parameters.put("REPORT_TITLE", strTitle);
174         parameters.put("cCountryId", new Integer JavaDoc(Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoiceJR")));
175         parameters.put("parDateFrom", strDateFrom);
176         parameters.put("parDateTo", DateTimeData.nDaysAfter(this, strDateTo,"1"));
177
178       renderJR(vars, response, strReportName, strOutput, parameters, null, null );
179
180     /*xmlDocument.setParameter("titleSale", strTitle);
181     xmlDocument.setParameter("titlePurchase", strTitle);
182     xmlDocument.setParameter("sale", strSale);
183     xmlDocument.setParameter("purchase", strPurchase);
184     out.println(xmlDocument.print());
185     out.close();*/

186   }
187
188   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strOrg, String JavaDoc strDetail, String JavaDoc strSales)
189     throws IOException, ServletException {
190     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
191     response.setContentType("text/html; charset=UTF-8");
192     PrintWriter out = response.getWriter();
193     XmlDocument xmlDocument=null;
194
195     String JavaDoc strSalesAux;
196     String JavaDoc strTitle = "FACTURAS CON EL EXTRANJERO";
197     String JavaDoc strSale = "";
198     String JavaDoc strPurchase = "";
199     String JavaDoc discard[] = {"discard", "discard", "discard", "discard"};
200     if (log4j.isDebugEnabled()) log4j.debug("****** strSales: " + strSales + " fecha desde: " + strDateFrom + " fecha hasta: " + strDateTo + " detalle: " + strDetail);
201   
202
203
204     if (log4j.isDebugEnabled()) log4j.debug("****** xmlDocument");
205     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTaxInvoice", discard).createXmlDocument();
206
207     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportTaxInvoiceJR", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
208     toolbar.prepareSimpleExcelToolBarTemplate("submitCommandForm('RELATION_XLS', false, null, 'ReportTaxInvoiceJR_Excel.xls', 'EXCEL');return false;");
209     xmlDocument.setParameter("toolbar", toolbar.toString());
210
211     try {
212       KeyMap key = new KeyMap(this, vars, "ReportTaxInvoiceJR.html");
213       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
214     } catch (Exception JavaDoc ex) {
215       throw new ServletException(ex);
216     }
217     try {
218       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportTaxInvoiceJR");
219       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
220       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
221       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
222       xmlDocument.setParameter("theme", vars.getTheme());
223       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportTaxInvoiceJR.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
224       xmlDocument.setParameter("navigationBar", nav.toString());
225       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportTaxInvoiceJR.html", strReplaceWith);
226       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
227     } catch (Exception JavaDoc ex) {
228       throw new ServletException(ex);
229     }
230     {
231       OBError myMessage = vars.getMessage("ReportTaxInvoiceJR");
232       vars.removeMessage("ReportTaxInvoiceJR");
233       if (myMessage!=null) {
234         xmlDocument.setParameter("messageType", myMessage.getType());
235         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
236         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
237       }
238     }
239
240     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
241     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
242     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
243     xmlDocument.setParameter("dateFrom", strDateFrom);
244     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
245     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
246     xmlDocument.setParameter("dateTo", strDateTo);
247     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
248     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
249     xmlDocument.setParameter("detalle", strDetail);
250     xmlDocument.setParameter("psale", strSales);
251     xmlDocument.setParameter("ppurchase", strSales);
252     xmlDocument.setParameter("pboth", strSales);
253     xmlDocument.setParameter("adOrgId", strOrg);
254     xmlDocument.setParameter("titleSale", strTitle);
255     xmlDocument.setParameter("titlePurchase", strTitle);
256     xmlDocument.setParameter("sale", strSale);
257     xmlDocument.setParameter("purchase", strPurchase);
258     if (log4j.isDebugEnabled()) log4j.debug("****** setData reportAD_ORGID");
259     /*String strTreeNode = ReportTaxInvoiceData.selectTreeNode(this, Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"));
260       xmlDocument.setData("reportAD_ORGID","liststructure",AdOrgTreeComboData.select(this, strTreeNode, vars.getOrg()));*/

261     xmlDocument.setData("reportAD_ORGID", "liststructure", OrganizationComboData.selectCombo(this, vars.getRole()));
262
263     out.println(xmlDocument.print());
264     out.close();
265   }
266
267   /*void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strOrg, String strDetail, String strSales)
268     throws IOException, ServletException {
269     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
270     response.setContentType("text/html; charset=UTF-8");
271     PrintWriter out = response.getWriter();
272     XmlDocument xmlDocument=null;
273     ReportTaxInvoiceData[] dataSale=null;
274     ReportTaxInvoiceData[] data2Sale=null;
275     ReportTaxInvoiceData[] dataPurchase=null;
276     ReportTaxInvoiceData[] data2Purchase=null;
277     String strSalesAux;
278     String strTitle = "FACTURAS CON EL EXTRANJERO";
279     String strSale = "";
280     String strPurchase = "";
281     String discard[] = {"discard", "discard", "discard", "discard"};
282     if (log4j.isDebugEnabled()) log4j.debug("****** strSales: " + strSales + " fecha desde: " + strDateFrom + " fecha hasta: " + strDateTo + " detalle: " + strDetail);
283     
284     if (strDateFrom.equals("") && strDateTo.equals("") && strDetail.equals("-1")) {
285       if (log4j.isDebugEnabled()) log4j.debug("****** all null");
286       discard[0] = "sectionTaxSale";
287       discard[1] = "sectionTaxForeignSale";
288       discard[2] = "sectionTaxPurchase";
289       discard[3] = "sectionTaxForeignPurchase";
290       strTitle = "";
291       dataSale = ReportTaxInvoiceData.set();
292       data2Sale = ReportTaxInvoiceData.set();
293       dataPurchase = ReportTaxInvoiceData.set();
294       data2Purchase = ReportTaxInvoiceData.set();
295     } else if (!strDetail.equals("-1")){
296       if (log4j.isDebugEnabled()) log4j.debug("****** not datailed");
297       discard[0] = "selEliminarSale";
298       discard[1] = "selEliminar1Sale";
299       discard[2] = "selEliminarPurchase";
300       discard[3] = "selEliminar1Purchase";
301       if (strSales.equals("S")) {
302         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
303         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
304         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
305       } else if (strSales.equals("P")) {
306         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
307         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
308         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
309       } else {
310         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
311         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
312         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
313         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
314         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
315         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
316       }
317     } else {
318       if (log4j.isDebugEnabled()) log4j.debug("****** detailed");
319       if (strSales.equals("S")) {
320         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
321         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
322         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
323       } else if (strSales.equals("P")) {
324         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
325         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
326         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
327       } else {
328         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
329         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
330         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
331         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
332         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
333         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
334       }
335     }
336     if (log4j.isDebugEnabled()) log4j.debug("****** strSale: " + strSale + " strPurchase: " + strPurchase);
337     if (log4j.isDebugEnabled()) log4j.debug("****** check nulls");
338     if (dataSale == null || dataSale.length == 0){
339       discard [0] = "sectionTaxSale";
340       dataSale = ReportTaxInvoiceData.set();
341     }
342     if (data2Sale == null || data2Sale.length == 0){
343       discard [1] = "sectionTaxForeignSale";
344       strTitle = "";
345       data2Sale = ReportTaxInvoiceData.set();
346     }
347     if (dataPurchase == null || dataPurchase.length == 0){
348       discard [2] = "sectionTaxPurchase";
349       dataPurchase = ReportTaxInvoiceData.set();
350     }
351     if (data2Purchase == null || data2Purchase.length == 0){
352       discard [3] = "sectionTaxForeignPurchase";
353       strTitle = "";
354       data2Purchase = ReportTaxInvoiceData.set();
355     }
356     if (log4j.isDebugEnabled()) log4j.debug("****** xmlDocument");
357     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTaxInvoice", discard).createXmlDocument();
358
359     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportTaxInvoice", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
360     toolbar.prepareSimpleExcelToolBarTemplate("submitCommandForm('RELATION_XLS', false, null, 'ReportTaxInvoice_Excel.xls', 'EXCEL');return false;");
361     xmlDocument.setParameter("toolbar", toolbar.toString());
362
363     try {
364       KeyMap key = new KeyMap(this, vars, "ReportTaxInvoice.html");
365       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
366     } catch (Exception ex) {
367       throw new ServletException(ex);
368     }
369     try {
370       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportTaxInvoice");
371       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
372       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
373       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
374       xmlDocument.setParameter("theme", vars.getTheme());
375       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportTaxInvoice.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
376       xmlDocument.setParameter("navigationBar", nav.toString());
377       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportTaxInvoice.html", strReplaceWith);
378       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
379     } catch (Exception ex) {
380       throw new ServletException(ex);
381     }
382     {
383       OBError myMessage = vars.getMessage("ReportTaxInvoice");
384       vars.removeMessage("ReportTaxInvoice");
385       if (myMessage!=null) {
386         xmlDocument.setParameter("messageType", myMessage.getType());
387         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
388         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
389       }
390     }
391
392     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
393     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
394     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
395     xmlDocument.setParameter("dateFrom", strDateFrom);
396     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
397     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
398     xmlDocument.setParameter("dateTo", strDateTo);
399     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
400     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
401     xmlDocument.setParameter("detalle", strDetail);
402     xmlDocument.setParameter("psale", strSales);
403     xmlDocument.setParameter("ppurchase", strSales);
404     xmlDocument.setParameter("pboth", strSales);
405     xmlDocument.setParameter("adOrgId", strOrg);
406     xmlDocument.setParameter("titleSale", strTitle);
407     xmlDocument.setParameter("titlePurchase", strTitle);
408     xmlDocument.setParameter("sale", strSale);
409     xmlDocument.setParameter("purchase", strPurchase);
410     if (log4j.isDebugEnabled()) log4j.debug("****** setData reportAD_ORGID");
411     
412     xmlDocument.setData("reportAD_ORGID", "liststructure", OrganizationComboData.selectCombo(this, vars.getRole()));
413
414     if (log4j.isDebugEnabled()) log4j.debug("****** setData dataSale");
415     xmlDocument.setData("structure1Sale", dataSale);
416     if (log4j.isDebugEnabled()) log4j.debug("****** setData data2Sale");
417     xmlDocument.setData("structure2Sale", data2Sale);
418     if (log4j.isDebugEnabled()) log4j.debug("****** setData dataPurchase");
419     xmlDocument.setData("structure1Purchase", dataPurchase);
420     if (log4j.isDebugEnabled()) log4j.debug("****** setData data2Purchase");
421     xmlDocument.setData("structure2Purchase", data2Purchase);
422     out.println(xmlDocument.print());
423     out.close();
424   }*/

425
426   
427   void printPageDataExcel(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strOrg, String JavaDoc strDetail, String JavaDoc strSales)
428     throws IOException, ServletException {
429     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
430     response.setContentType("application/xls");
431     PrintWriter out = response.getWriter();
432     XmlDocument xmlDocument=null;
433     ReportTaxInvoiceData[] dataSale=null;
434     ReportTaxInvoiceData[] data2Sale=null;
435     ReportTaxInvoiceData[] dataPurchase=null;
436     ReportTaxInvoiceData[] data2Purchase=null;
437     String JavaDoc strSalesAux;
438     String JavaDoc strTitle = "FACTURAS CON EL EXTRANJERO";
439     String JavaDoc strSale = "";
440     String JavaDoc strPurchase = "";
441     String JavaDoc discard[] = {"discard", "discard", "discard", "discard"};
442     if (log4j.isDebugEnabled()) log4j.debug("****** strSales: " + strSales + " fecha desde: " + strDateFrom + " fecha hasta: " + strDateTo + " detalle: " + strDetail);
443     /* if (strSales.equals("S")) strSalesAux = "Y";
444           else strSalesAux = "N";*/

445     if (strDateFrom.equals("") && strDateTo.equals("")) {
446       if (log4j.isDebugEnabled()) log4j.debug("****** all null");
447       discard[0] = "sectionDetailSale";
448       discard[1] = "sectionDetail1Sale";
449       discard[2] = "sectionDetailPurchase";
450       discard[3] = "sectionDetail1Purchase";
451       strTitle = "";
452       dataSale = ReportTaxInvoiceData.set();
453       data2Sale = ReportTaxInvoiceData.set();
454       dataPurchase = ReportTaxInvoiceData.set();
455       data2Purchase = ReportTaxInvoiceData.set();
456     } else {
457       if (log4j.isDebugEnabled()) log4j.debug("****** detailed");
458       if (strSales.equals("S")) {
459         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
460         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
461         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
462       } else if (strSales.equals("P")) {
463         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
464         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
465         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
466       } else {
467         dataSale = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
468         data2Sale = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "Y", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
469         dataPurchase = ReportTaxInvoiceData.select(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
470         data2Purchase = ReportTaxInvoiceData.selectForeign(this, Utility.getContext(this, vars, "C_Country_Id", "ReportTaxInvoice"), Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), "N", Tree.getMembers(this, TreeData.getTreeOrg(this, vars.getClient()), strOrg));
471         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
472         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
473       }
474     }
475     if (log4j.isDebugEnabled()) log4j.debug("****** strSale: " + strSale + " strPurchase: " + strPurchase);
476     if (log4j.isDebugEnabled()) log4j.debug("****** check nulls");
477     if (dataSale == null || dataSale.length == 0){
478       discard [0] = "sectionDetailSale";
479       dataSale = ReportTaxInvoiceData.set();
480     }
481     if (data2Sale == null || data2Sale.length == 0){
482       discard [1] = "sectionDetail1Sale";
483       strTitle = "";
484       data2Sale = ReportTaxInvoiceData.set();
485     }
486     if (dataPurchase == null || dataPurchase.length == 0){
487       discard [2] = "sectionDetailPurchase";
488       dataPurchase = ReportTaxInvoiceData.set();
489     }
490     if (data2Purchase == null || data2Purchase.length == 0){
491       discard [3] = "sectionDetail1Purchase";
492       strTitle = "";
493       data2Purchase = ReportTaxInvoiceData.set();
494     }
495     if (log4j.isDebugEnabled()) log4j.debug("****** xmlDocument");
496     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTaxInvoice_Excel", discard).createXmlDocument();
497
498     xmlDocument.setData("structure1Sale", dataSale);
499     xmlDocument.setData("structure2Sale", data2Sale);
500     xmlDocument.setData("structure1Purchase", dataPurchase);
501     xmlDocument.setData("structure2Purchase", data2Purchase);
502     out.println(xmlDocument.print());
503     out.close();
504   }
505
506   public String JavaDoc getServletInfo() {
507     return "Servlet ReportTaxInvoice. This Servlet was made by Jon Alegria";
508   } // end of getServletInfo() method
509
}
510
Popular Tags