KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpReports > RptC_Settlement


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.erpReports;
20
21 import org.openbravo.base.secureApp.*;
22 import org.openbravo.xmlEngine.XmlDocument;
23 import java.io.*;
24 import javax.servlet.*;
25 import javax.servlet.http.*;
26
27 import org.openbravo.erpCommon.utility.Utility;
28
29
30 public class RptC_Settlement extends HttpSecureAppServlet {
31   
32   
33   public void init (ServletConfig config) {
34     super.init(config);
35     boolHist = false;
36   }
37
38   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
39     VariablesSecureApp vars = new VariablesSecureApp(request);
40
41     if (vars.commandIn("DEFAULT")) {
42       String JavaDoc strcSettlementId = vars.getSessionValue("RptC_Settlement.inpcSettlementId_R");
43       if (strcSettlementId.equals("")) strcSettlementId = vars.getSessionValue("RptC_Settlement.inpcSettlementId");
44       printPagePDF(response, vars, strcSettlementId);
45     } else pageError(response);
46   }
47
48   void printPagePDF(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strcSettlementId) throws IOException,ServletException{
49     if (log4j.isDebugEnabled()) log4j.debug("Output: pdf");
50     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpReports/RptC_Settlement").createXmlDocument();
51
52     RptCSettlementData[] pdfSettlementData = RptCSettlementData.select(this, Utility.getContext(this, vars, "#User_Client", "RptC_Settlement"), Utility.getContext(this, vars, "#User_Org", "RptC_Settlement"), strcSettlementId);
53
54     if (pdfSettlementData == null || pdfSettlementData.length == 0) pdfSettlementData = RptCSettlementData.set();
55
56     RptCSettlementHeaderData[][] pdfSettlementHeaderData = new RptCSettlementHeaderData[pdfSettlementData.length][];
57
58     RptCSettlementLinesData[][] pdfSettlementLinesData = new RptCSettlementLinesData[pdfSettlementData.length][];
59
60     for (int i=0;i<pdfSettlementData.length;i++) {
61       pdfSettlementHeaderData[i] = RptCSettlementHeaderData.select(this, pdfSettlementData[i].cSettlementId);
62       if (pdfSettlementHeaderData[i] == null || pdfSettlementHeaderData[i].length == 0) RptCSettlementHeaderData.set();
63       pdfSettlementLinesData[i] = RptCSettlementLinesData.select(this, pdfSettlementData[i].cSettlementId);
64       if (pdfSettlementLinesData[i] == null || pdfSettlementLinesData[i].length == 0) pdfSettlementLinesData[i] = RptCSettlementLinesData.set();
65     }
66
67     xmlDocument.setData("structure1",pdfSettlementData);
68     xmlDocument.setDataArray("reportSettlementHeader","structureSettlementHeader",pdfSettlementHeaderData);
69     xmlDocument.setDataArray("reportSettlementLines","structureSettlementLines",pdfSettlementLinesData);
70
71     String JavaDoc strResult = xmlDocument.print();
72     renderFO(strResult, response);
73   }
74
75   public String JavaDoc getServletInfo() {
76     return "Servlet that presents the RptCOrders seeker";
77   } // End of getServletInfo() method
78
}
79
Popular Tags