KickJava   Java API By Example, From Geeks To Geeks.

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


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_Proposal 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 strClave = vars.getSessionValue("RptC_Proposal.inpcProjectproposalId_R");
43       if (strClave.equals("")) strClave = vars.getSessionValue("RptC_Proposal.inpcProjectproposalId");
44       printPagePartePDF(response, vars, strClave);
45     } else pageError(response);
46   }
47
48
49    void printPagePartePDF(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strClave) throws IOException,ServletException{
50     if (log4j.isDebugEnabled()) log4j.debug("Output: pdf");
51     RptCProposalData[] data = RptCProposalData.select(this, Utility.getContext(this, vars, "#User_Client", "RptC_Proposal"), Utility.getContext(this, vars, "#User_Org", "RptC_Proposal"), strClave);
52     String JavaDoc discard[] = {""};
53     if (data==null || data.length==0) discard[0] = new String JavaDoc("sectionDetailHeader");
54     RptCProposalData[][] dataHeader = new RptCProposalData[data.length][];
55     RptCProposalData[][] dataLines = new RptCProposalData[data.length][];
56     RptCProposalData[][] dataFootnote = new RptCProposalData[data.length][];
57
58     for ( int i=0; i<data.length; i++){
59       dataHeader[i] = RptCProposalData.selectHeader(this, data[i].cBpartnerId, data[i].cProjectproposalId);
60       if (dataHeader[i] == null || dataHeader[i].length == 0) dataHeader[i] = RptCProposalData.set();
61       dataLines[i] = RptCProposalData.selectLines(this, data[i].cProjectproposalId);
62       if (dataLines[i] == null || dataLines[i].length == 0) dataLines[i] = RptCProposalData.set();
63       dataFootnote[i] = RptCProposalData.selectFootnote(this, data[i].cProjectproposalId);
64       if (dataFootnote[i] == null || dataFootnote[i].length == 0) dataFootnote[i] = RptCProposalData.set();
65     }
66     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpReports/RptC_Proposal", discard).createXmlDocument();
67     // here we pass the familiy-ID with report.setData
68
xmlDocument.setData("structure", data);
69     xmlDocument.setDataArray("reportProposalHeader", "structure1", dataHeader);
70     xmlDocument.setDataArray("reportProposalLines", "structure2", dataLines);
71     xmlDocument.setDataArray("reportProposalFootnote", "structure3", dataFootnote);
72     
73     String JavaDoc strResult = xmlDocument.print();
74     if (log4j.isDebugEnabled()) log4j.debug(strResult);
75     renderFO(strResult, response);
76   }
77
78   public String JavaDoc getServletInfo() {
79     return "Servlet that presents the RptCOrders seeker";
80   } // End of getServletInfo() method
81
}
82
Popular Tags