KickJava   Java API By Example, From Geeks To Geeks.

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


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
36
37
38 public class ReportTaxInvoice extends HttpSecureAppServlet {
39
40   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
41     VariablesSecureApp vars = new VariablesSecureApp(request);
42
43     if (vars.commandIn("DEFAULT")) {
44       String JavaDoc strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportTaxInvoice|DateFrom", "");
45       String JavaDoc strDateTo = vars.getGlobalVariable("inpDateTo", "ReportTaxInvoice|DateTo", "");
46       String JavaDoc strOrg = vars.getGlobalVariable("inpOrg", "ReportTaxInvoice|Org", "0");
47       String JavaDoc strDetail = vars.getStringParameter("inpDetalle", "-1");
48       String JavaDoc strSales = vars.getStringParameter("inpSales", "S");
49       printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
50     } else if (vars.commandIn("FIND")) {
51       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTaxInvoice|DateFrom");
52       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTaxInvoice|DateTo");
53       String JavaDoc strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTaxInvoice|Org");
54       if (strOrg.equals("")) strOrg = "0";
55       String JavaDoc strDetail = vars.getStringParameter("inpDetalle");
56       String JavaDoc strSales = vars.getStringParameter("inpSales");
57       printPageDataHtml(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
58     } else if (vars.commandIn("RELATION_XLS")) {
59       String JavaDoc strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "ReportTaxInvoice|DateFrom");
60       String JavaDoc strDateTo = vars.getRequestGlobalVariable("inpDateTo", "ReportTaxInvoice|DateTo");
61       String JavaDoc strOrg = vars.getRequestGlobalVariable("inpOrg", "ReportTaxInvoice|Org");
62       if (strOrg.equals("")) strOrg = "0";
63       String JavaDoc strDetail = vars.getStringParameter("inpDetalle");
64       String JavaDoc strSales = vars.getStringParameter("inpSales");
65       printPageDataExcel(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
66     } else pageError(response);
67   }
68
69   void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strOrg, String JavaDoc strDetail, String JavaDoc strSales)
70     throws IOException, ServletException {
71     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
72     response.setContentType("text/html; charset=UTF-8");
73     PrintWriter out = response.getWriter();
74     XmlDocument xmlDocument=null;
75     ReportTaxInvoiceData[] dataSale=null;
76     ReportTaxInvoiceData[] data2Sale=null;
77     ReportTaxInvoiceData[] dataPurchase=null;
78     ReportTaxInvoiceData[] data2Purchase=null;
79     String JavaDoc strSalesAux;
80     String JavaDoc strTitle = "FACTURAS CON EL EXTRANJERO";
81     String JavaDoc strSale = "";
82     String JavaDoc strPurchase = "";
83     String JavaDoc discard[] = {"discard", "discard", "discard", "discard"};
84     if (log4j.isDebugEnabled()) log4j.debug("****** strSales: " + strSales + " fecha desde: " + strDateFrom + " fecha hasta: " + strDateTo + " detalle: " + strDetail);
85     /* if (strSales.equals("S")) strSalesAux = "Y";
86           else strSalesAux = "N";*/

87     if (strDateFrom.equals("") && strDateTo.equals("") && strDetail.equals("-1")) {
88       printPageDataSheet(response, vars, strDateFrom, strDateTo, strOrg, strDetail, strSales);
89     } else if (!strDetail.equals("-1")){
90       if (log4j.isDebugEnabled()) log4j.debug("****** not datailed");
91       discard[0] = "selEliminarSale";
92       discard[1] = "selEliminar1Sale";
93       discard[2] = "selEliminarPurchase";
94       discard[3] = "selEliminar1Purchase";
95       if (strSales.equals("S")) {
96         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));
97         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));
98         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
99       } else if (strSales.equals("P")) {
100         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));
101         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));
102         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
103       } else {
104         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));
105         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));
106         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));
107         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));
108         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
109         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
110       }
111     } else {
112       if (log4j.isDebugEnabled()) log4j.debug("****** detailed");
113       if (strSales.equals("S")) {
114         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));
115         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));
116         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
117       } else if (strSales.equals("P")) {
118         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));
119         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));
120         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
121       } else {
122         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));
123         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));
124         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));
125         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));
126         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
127         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
128       }
129     }
130     if (log4j.isDebugEnabled()) log4j.debug("****** strSale: " + strSale + " strPurchase: " + strPurchase);
131     if (log4j.isDebugEnabled()) log4j.debug("****** check nulls");
132     if (dataSale == null || dataSale.length == 0){
133       discard [0] = "sectionTaxSale";
134       dataSale = ReportTaxInvoiceData.set();
135     }
136     if (data2Sale == null || data2Sale.length == 0){
137       discard [1] = "sectionTaxForeignSale";
138       strTitle = "";
139       data2Sale = ReportTaxInvoiceData.set();
140     }
141     if (dataPurchase == null || dataPurchase.length == 0){
142       discard [2] = "sectionTaxPurchase";
143       dataPurchase = ReportTaxInvoiceData.set();
144     }
145     if (data2Purchase == null || data2Purchase.length == 0){
146       discard [3] = "sectionTaxForeignPurchase";
147       strTitle = "";
148       data2Purchase = ReportTaxInvoiceData.set();
149     }
150     if (log4j.isDebugEnabled()) log4j.debug("****** xmlDocument");
151     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTaxInvoiceEdit", discard).createXmlDocument();
152
153     
154    
155
156     if (log4j.isDebugEnabled()) log4j.debug("****** setData dataSale");
157     xmlDocument.setData("structure1Sale", dataSale);
158     if (log4j.isDebugEnabled()) log4j.debug("****** setData data2Sale");
159     xmlDocument.setData("structure2Sale", data2Sale);
160     if (log4j.isDebugEnabled()) log4j.debug("****** setData dataPurchase");
161     xmlDocument.setData("structure1Purchase", dataPurchase);
162     if (log4j.isDebugEnabled()) log4j.debug("****** setData data2Purchase");
163     xmlDocument.setData("structure2Purchase", data2Purchase);
164
165     xmlDocument.setParameter("titleSale", strTitle);
166     xmlDocument.setParameter("titlePurchase", strTitle);
167     xmlDocument.setParameter("sale", strSale);
168     xmlDocument.setParameter("purchase", strPurchase);
169     out.println(xmlDocument.print());
170     out.close();
171   }
172
173   void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strOrg, String JavaDoc strDetail, String JavaDoc strSales)
174     throws IOException, ServletException {
175     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
176     response.setContentType("text/html; charset=UTF-8");
177     PrintWriter out = response.getWriter();
178     XmlDocument xmlDocument=null;
179
180     String JavaDoc strSalesAux;
181     String JavaDoc strTitle = "FACTURAS CON EL EXTRANJERO";
182     String JavaDoc strSale = "";
183     String JavaDoc strPurchase = "";
184     String JavaDoc discard[] = {"discard", "discard", "discard", "discard"};
185     if (log4j.isDebugEnabled()) log4j.debug("****** strSales: " + strSales + " fecha desde: " + strDateFrom + " fecha hasta: " + strDateTo + " detalle: " + strDetail);
186   
187
188
189     if (log4j.isDebugEnabled()) log4j.debug("****** xmlDocument");
190     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTaxInvoice", discard).createXmlDocument();
191
192     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportTaxInvoice", false, "", "", "",false, "ad_reports", strReplaceWith, false, true);
193     toolbar.prepareSimpleExcelToolBarTemplate("submitCommandForm('RELATION_XLS', false, null, 'ReportTaxInvoice_Excel.xls', 'EXCEL');return false;");
194     xmlDocument.setParameter("toolbar", toolbar.toString());
195
196     try {
197       KeyMap key = new KeyMap(this, vars, "ReportTaxInvoice.html");
198       xmlDocument.setParameter("keyMap", key.getReportKeyMaps());
199     } catch (Exception JavaDoc ex) {
200       throw new ServletException(ex);
201     }
202     try {
203       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportTaxInvoice");
204       xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
205       xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
206       xmlDocument.setParameter("childTabContainer", tabs.childTabs());
207       xmlDocument.setParameter("theme", vars.getTheme());
208       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportTaxInvoice.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
209       xmlDocument.setParameter("navigationBar", nav.toString());
210       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportTaxInvoice.html", strReplaceWith);
211       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
212     } catch (Exception JavaDoc ex) {
213       throw new ServletException(ex);
214     }
215     {
216       OBError myMessage = vars.getMessage("ReportTaxInvoice");
217       vars.removeMessage("ReportTaxInvoice");
218       if (myMessage!=null) {
219         xmlDocument.setParameter("messageType", myMessage.getType());
220         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
221         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
222       }
223     }
224
225     xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2));
226     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
227     xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
228     xmlDocument.setParameter("dateFrom", strDateFrom);
229     xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
230     xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
231     xmlDocument.setParameter("dateTo", strDateTo);
232     xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
233     xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
234     xmlDocument.setParameter("detalle", strDetail);
235     xmlDocument.setParameter("psale", strSales);
236     xmlDocument.setParameter("ppurchase", strSales);
237     xmlDocument.setParameter("pboth", strSales);
238     xmlDocument.setParameter("adOrgId", strOrg);
239     xmlDocument.setParameter("titleSale", strTitle);
240     xmlDocument.setParameter("titlePurchase", strTitle);
241     xmlDocument.setParameter("sale", strSale);
242     xmlDocument.setParameter("purchase", strPurchase);
243     if (log4j.isDebugEnabled()) log4j.debug("****** setData reportAD_ORGID");
244     /*String strTreeNode = ReportTaxInvoiceData.selectTreeNode(this, Utility.getContext(this, vars, "#User_Client", "ReportTaxInvoice"));
245       xmlDocument.setData("reportAD_ORGID","liststructure",AdOrgTreeComboData.select(this, strTreeNode, vars.getOrg()));*/

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

410
411   
412   void printPageDataExcel(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strDateFrom, String JavaDoc strDateTo, String JavaDoc strOrg, String JavaDoc strDetail, String JavaDoc strSales)
413     throws IOException, ServletException {
414     if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");
415     response.setContentType("application/xls");
416     PrintWriter out = response.getWriter();
417     XmlDocument xmlDocument=null;
418     ReportTaxInvoiceData[] dataSale=null;
419     ReportTaxInvoiceData[] data2Sale=null;
420     ReportTaxInvoiceData[] dataPurchase=null;
421     ReportTaxInvoiceData[] data2Purchase=null;
422     String JavaDoc strSalesAux;
423     String JavaDoc strTitle = "FACTURAS CON EL EXTRANJERO";
424     String JavaDoc strSale = "";
425     String JavaDoc strPurchase = "";
426     String JavaDoc discard[] = {"discard", "discard", "discard", "discard"};
427     if (log4j.isDebugEnabled()) log4j.debug("****** strSales: " + strSales + " fecha desde: " + strDateFrom + " fecha hasta: " + strDateTo + " detalle: " + strDetail);
428     /* if (strSales.equals("S")) strSalesAux = "Y";
429           else strSalesAux = "N";*/

430     if (strDateFrom.equals("") && strDateTo.equals("")) {
431       if (log4j.isDebugEnabled()) log4j.debug("****** all null");
432       discard[0] = "sectionDetailSale";
433       discard[1] = "sectionDetail1Sale";
434       discard[2] = "sectionDetailPurchase";
435       discard[3] = "sectionDetail1Purchase";
436       strTitle = "";
437       dataSale = ReportTaxInvoiceData.set();
438       data2Sale = ReportTaxInvoiceData.set();
439       dataPurchase = ReportTaxInvoiceData.set();
440       data2Purchase = ReportTaxInvoiceData.set();
441     } else {
442       if (log4j.isDebugEnabled()) log4j.debug("****** detailed");
443       if (strSales.equals("S")) {
444         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));
445         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));
446         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
447       } else if (strSales.equals("P")) {
448         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));
449         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));
450         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
451       } else {
452         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));
453         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));
454         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));
455         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));
456         strSale = Utility.messageBD(this, "Sale", vars.getLanguage());
457         strPurchase = Utility.messageBD(this, "Purchase", vars.getLanguage());
458       }
459     }
460     if (log4j.isDebugEnabled()) log4j.debug("****** strSale: " + strSale + " strPurchase: " + strPurchase);
461     if (log4j.isDebugEnabled()) log4j.debug("****** check nulls");
462     if (dataSale == null || dataSale.length == 0){
463       discard [0] = "sectionDetailSale";
464       dataSale = ReportTaxInvoiceData.set();
465     }
466     if (data2Sale == null || data2Sale.length == 0){
467       discard [1] = "sectionDetail1Sale";
468       strTitle = "";
469       data2Sale = ReportTaxInvoiceData.set();
470     }
471     if (dataPurchase == null || dataPurchase.length == 0){
472       discard [2] = "sectionDetailPurchase";
473       dataPurchase = ReportTaxInvoiceData.set();
474     }
475     if (data2Purchase == null || data2Purchase.length == 0){
476       discard [3] = "sectionDetail1Purchase";
477       strTitle = "";
478       data2Purchase = ReportTaxInvoiceData.set();
479     }
480     if (log4j.isDebugEnabled()) log4j.debug("****** xmlDocument");
481     xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportTaxInvoice_Excel", discard).createXmlDocument();
482
483     xmlDocument.setData("structure1Sale", dataSale);
484     xmlDocument.setData("structure2Sale", data2Sale);
485     xmlDocument.setData("structure1Purchase", dataPurchase);
486     xmlDocument.setData("structure2Purchase", data2Purchase);
487     out.println(xmlDocument.print());
488     out.close();
489   }
490
491   public String JavaDoc getServletInfo() {
492     return "Servlet ReportTaxInvoice. This Servlet was made by Jon Alegria";
493   } // end of getServletInfo() method
494
}
495
Popular Tags