1 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.base.secureApp.HttpSecureAppServlet; 24 import org.openbravo.base.secureApp.VariablesSecureApp; 25 import org.openbravo.xmlEngine.XmlDocument; 26 import java.io.*; 27 import javax.servlet.*; 28 import javax.servlet.http.*; 29 30 import org.openbravo.erpCommon.utility.DateTimeData; 31 32 public class ReportInvoices extends HttpSecureAppServlet { 33 34 35 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 36 VariablesSecureApp vars = new VariablesSecureApp(request); 37 38 if (!Utility.hasProcessAccess(this, vars, "", "RV_C_InvoiceLine")) { 39 bdError(response, "AccessTableNoView", vars.getLanguage()); 40 return; 41 } 42 43 if (vars.commandIn("DEFAULT")) { 44 String strC_BPartner_ID = vars.getGlobalVariable("inpcBpartnerId", "ReportInvoices|C_BPartner_ID", ""); 45 String strM_Product_ID = vars.getGlobalVariable("inpmProductId", "ReportInvoices|M_Product_ID", ""); 46 String strDateFrom = vars.getGlobalVariable("inpDateInvoiceFrom", "ReportInvoices|DateFrom", ""); 47 String strDateTo = vars.getGlobalVariable("inpDateInvoiceTo", "ReportInvoices|DateTo", ""); 48 String strDocumentNo = vars.getGlobalVariable("inpInvoicedocumentno", "ReportInvoices|DocumentNo", ""); 49 String strOrder = vars.getGlobalVariable("inpOrder", "ReportInvoices|Order", "SalesOrder"); 50 String strC_BpGroup_ID = vars.getGlobalVariable("inpcBpGroupId", "ReportInvoices|C_BpGroup_ID", ""); 51 String strM_Product_Category_ID = vars.getGlobalVariable("inpmProductCategoryId", "ReportInvoices|M_Product_Category_ID", ""); 52 printPageDataSheet(response, vars, strC_BPartner_ID, strM_Product_ID, strDateFrom, strDateTo, strDocumentNo, strOrder, strC_BpGroup_ID, strM_Product_Category_ID); 53 } else if (vars.commandIn("FIND")) { 54 String strC_BPartner_ID = vars.getRequestGlobalVariable("inpcBpartnerId", "ReportInvoices|C_BPartner_ID"); 55 String strM_Product_ID = vars.getRequestGlobalVariable("inpmProductId", "ReportInvoices|M_Product_ID"); 56 String strDateFrom = vars.getRequestGlobalVariable("inpDateInvoiceFrom", "ReportInvoices|DateFrom"); 57 String strDateTo = vars.getRequestGlobalVariable("inpDateInvoiceTo", "ReportInvoices|DateTo"); 58 String strDocumentNo = vars.getRequestGlobalVariable("inpInvoicedocumentno", "ReportInvoices|DocumentNo"); 59 String strOrder = vars.getGlobalVariable("inpOrder", "ReportInvoices|Order"); 60 String strC_BpGroup_ID = vars.getRequestGlobalVariable("inpcBpGroupId", "ReportInvoices|C_BpGroup_ID"); 61 String strM_Product_Category_ID = vars.getRequestGlobalVariable("inpmProductCategoryId", "ReportInvoices|M_Product_Category_ID"); 62 printPageDataHtml(response, vars, strC_BPartner_ID, strM_Product_ID, strDateFrom, strDateTo, strDocumentNo, strOrder, strC_BpGroup_ID, strM_Product_Category_ID); 63 } else pageError(response); 64 } 65 66 void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String strC_BPartner_ID, String strM_Product_ID, String strDateFrom, String strDateTo, String strDocumentNo, String strOrder, String strC_BpGroup_ID, String strM_Product_Category_ID) 67 throws IOException, ServletException { 68 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 69 response.setContentType("text/html; charset=UTF-8"); 70 PrintWriter out = response.getWriter(); 71 String discard[]={"sectionBPartner"}; 72 XmlDocument xmlDocument=null; 73 ReportInvoicesData[] data=null; 74 if (strC_BPartner_ID.equals("") && strM_Product_ID.equals("") && strDateFrom.equals("") && strDateTo.equals("") && strDocumentNo.equals("") && strC_BpGroup_ID.equals("") && strM_Product_Category_ID.equals("")) { 75 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoicesEdit", discard).createXmlDocument(); 76 data = ReportInvoicesData.set(); 77 } else { 78 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoicesEdit").createXmlDocument(); 79 data = ReportInvoicesData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), strC_BpGroup_ID, strM_Product_Category_ID, strC_BPartner_ID, strM_Product_ID, strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strDocumentNo, (strOrder.equals("PurchaseOrder"))?"":"sales", (strOrder.equals("PurchaseOrder"))?"purchase":""); 80 } 81 82 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 83 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 84 85 86 xmlDocument.setData("structure1", data); 87 out.println(xmlDocument.print()); 88 out.close(); 89 } 90 91 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strC_BPartner_ID, String strM_Product_ID, String strDateFrom, String strDateTo, String strDocumentNo, String strOrder, String strC_BpGroup_ID, String strM_Product_Category_ID) 92 throws IOException, ServletException { 93 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 94 response.setContentType("text/html; charset=UTF-8"); 95 PrintWriter out = response.getWriter(); 96 97 XmlDocument xmlDocument=null; 98 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoices").createXmlDocument(); 99 100 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoices", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 101 toolbar.prepareSimpleToolBarTemplate(); 102 xmlDocument.setParameter("toolbar", toolbar.toString()); 103 try { 104 KeyMap key = new KeyMap(this, vars, "ReportInvoices.html"); 105 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 106 } catch (Exception ex) { 107 throw new ServletException(ex); 108 } 109 try { 110 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoices"); 111 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 112 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 113 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 114 xmlDocument.setParameter("theme", vars.getTheme()); 115 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoices.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 116 xmlDocument.setParameter("navigationBar", nav.toString()); 117 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoices.html", strReplaceWith); 118 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 119 } catch (Exception ex) { 120 throw new ServletException(ex); 121 } 122 { 123 OBError myMessage = vars.getMessage("ReportInvoices"); 124 vars.removeMessage("ReportInvoices"); 125 if (myMessage!=null) { 126 xmlDocument.setParameter("messageType", myMessage.getType()); 127 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 128 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 129 } 130 } 131 132 133 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 134 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 135 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 136 xmlDocument.setParameter("paramBPartnerId", strC_BPartner_ID); 137 xmlDocument.setParameter("paramMProductId", strM_Product_ID); 138 xmlDocument.setParameter("dateFrom", strDateFrom); 139 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 140 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 141 xmlDocument.setParameter("dateTo", strDateTo); 142 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 143 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 144 xmlDocument.setParameter("paramDocumentNo", strDocumentNo); 145 xmlDocument.setParameter("paramCBpGroupID", strC_BpGroup_ID); 146 xmlDocument.setParameter("paramMProductCategoryID", strM_Product_Category_ID); 147 xmlDocument.setParameter("sales", strOrder); 148 xmlDocument.setParameter("purchase", strOrder); 149 xmlDocument.setParameter("paramBPartnerDescription", ReportInvoicesData.bPartnerDescription(this, strC_BPartner_ID)); 150 xmlDocument.setParameter("paramMProductIDDES", ReportInvoicesData.mProductDescription(this, strM_Product_ID)); 151 152 153 try { 154 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "C_BP_Group_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), 0); 155 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoices", strC_BpGroup_ID); 156 xmlDocument.setData("reportC_Bp_Group","liststructure", comboTableData.select(false)); 157 comboTableData = null; 158 } catch (Exception ex) { 159 throw new ServletException(ex); 160 } 161 162 163 164 try { 165 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportInvoices"), Utility.getContext(this, vars, "#User_Client", "ReportInvoices"), 0); 166 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportInvoices", strM_Product_Category_ID); 167 xmlDocument.setData("reportM_Product_Category","liststructure", comboTableData.select(false)); 168 comboTableData = null; 169 } catch (Exception ex) { 170 throw new ServletException(ex); 171 } 172 173 174 175 out.println(xmlDocument.print()); 176 out.close(); 177 } 178 179 269 270 public String getServletInfo() { 271 return "Servlet ReportInvoices. This Servlet was made by Pablo Sarobe"; 272 } } 274 275 | Popular Tags |