1 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.DateTimeData; 28 29 30 public class RptC_Invoice 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 strcInvoiceId = vars.getSessionValue("RptC_Invoice.inpcInvoiceId_R"); 43 if (strcInvoiceId.equals("")) strcInvoiceId = vars.getSessionValue("RptC_Invoice.inpcInvoiceId"); 44 printPagePDF(response, vars, strcInvoiceId); 45 } else if (vars.commandIn("FIND")) { 46 String strbPartnerId = vars.getStringParameter("inpcBpartnerId"); 47 String strDateTo = vars.getStringParameter("inpDateInvoiceFrom"); 48 String strDateFrom = vars.getStringParameter("inpDateInvoiceTo"); 49 String strDocNoFrom = vars.getStringParameter("inpInvoicedocumentnoFrom"); 50 String strDocNoTo = vars.getStringParameter("inpInvoicedocumentnoTo"); 51 String strcInvoiceId=""; 52 RptCInvoiceData[] data2= RptCInvoiceData.select(this, strDocNoFrom, strDocNoTo, strbPartnerId, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1")); 53 int j; 54 for (j=0;j<data2.length;j++) { 55 if (j!=0) strcInvoiceId += ","; 56 strcInvoiceId += data2[j].cInvoiceId; 57 } 58 strcInvoiceId = "("+strcInvoiceId+")"; 59 printPagePDF(response, vars, strcInvoiceId); 60 } else pageError(response); 61 } 62 63 void printPagePDF(HttpServletResponse response, VariablesSecureApp vars, String strcInvoiceId) throws IOException,ServletException{ 64 if (log4j.isDebugEnabled()) log4j.debug("Output: pdf"); 65 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpReports/RptC_Invoice").createXmlDocument(); 66 67 int i=0; 68 RptCInvoiceHeaderData[] pdfInvoicesData = RptCInvoiceHeaderData.select(this, strcInvoiceId); 69 70 RptCInvoiceLinesData[][] pdfInvoiceLinesDataArray = new RptCInvoiceLinesData[pdfInvoicesData.length][]; 71 72 RptCInvoiceTaxData[][] pdfInvoiceTaxLinesDataArray = new RptCInvoiceTaxData[pdfInvoicesData.length][]; 73 74 for (i=0;i<pdfInvoicesData.length;i++) { 75 RptCInvoiceLinesData[] data = RptCInvoiceLinesData.select(this,pdfInvoicesData[i].cInvoiceId); 76 if (data == null || data.length == 0) { 78 data = RptCInvoiceLinesData.set(); 79 } 80 pdfInvoiceLinesDataArray[i] = data; 81 } 82 83 for (i=0;i<pdfInvoicesData.length;i++) { 84 RptCInvoiceTaxData[] data1 = RptCInvoiceTaxData.select(this,pdfInvoicesData[i].cInvoiceId); 85 if (data1 == null || data1.length == 0) { 87 data1 = RptCInvoiceTaxData.set(); 88 } 89 pdfInvoiceTaxLinesDataArray[i] = data1; 90 } 91 92 93 xmlDocument.setData("structure1",pdfInvoicesData); 94 xmlDocument.setDataArray("reportInvoiceLines","structureInvoiceLines",pdfInvoiceLinesDataArray); 95 xmlDocument.setDataArray("reportInvoiceLines","structureInvoiceTaxes",pdfInvoiceTaxLinesDataArray); 96 97 String strResult = xmlDocument.print(); 98 if (log4j.isDebugEnabled()) log4j.debug(strResult); 99 renderFO(strResult, response); 100 } 101 102 public String getServletInfo() { 103 return "Servlet that presents the RptCOrders seeker"; 104 } } 106 | Popular Tags |