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 ReportInvoiceDiscount 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_ReportInvoiceCustomer")) { 39 bdError(response, "AccessTableNoView", vars.getLanguage()); 40 return; 41 } 42 43 if (vars.commandIn("DEFAULT")){ 44 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportInvoiceDiscount|dateFrom", ""); 45 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportInvoiceDiscount|dateTo", ""); 46 String strcBpartnerId = vars.getInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceDiscount|partner", ""); 47 String strDiscount = vars.getGlobalVariable("inpDiscount", "ReportInvoiceDiscount|discount", "N"); 48 printPageDataSheet(response, vars, strDateFrom, strDateTo, strcBpartnerId, strDiscount); 49 } else if (vars.commandIn("FIND")) { 50 String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportInvoiceDiscount|dateFrom", ""); 51 String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportInvoiceDiscount|dateTo", ""); 52 String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN", "ReportInvoiceDiscount|partner"); 53 String strDiscount = vars.getRequestGlobalVariable("inpDiscount", "ReportInvoiceDiscount|discount"); 54 printPageDataHtml(response, vars, strDateFrom, strDateTo, strcBpartnerId, strDiscount); 55 } else pageError(response); 56 } 57 58 void printPageDataHtml(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strcBpartnerId, String strDiscount) throws IOException, ServletException { 59 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 60 61 XmlDocument xmlDocument=null; 62 if (strDiscount.equals("")) strDiscount = "N"; 63 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceDiscountEdit").createXmlDocument(); 64 65 66 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 67 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 68 69 xmlDocument.setData("structure1", ReportInvoiceDiscountData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportInvoiceDiscount"), Utility.getContext(this, vars, "#User_Org", "ReportInvoiceDiscount"), strDateFrom, DateTimeData.nDaysAfter(this, strDateTo,"1"), strcBpartnerId, (strDiscount.equals("N"))?"":"discount")); 70 response.setContentType("text/html; charset=UTF-8"); 71 PrintWriter out = response.getWriter(); 72 out.println(xmlDocument.print()); 73 out.close(); 74 } 75 76 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strDateFrom, String strDateTo, String strcBpartnerId, String strDiscount) throws IOException, ServletException { 77 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 78 79 XmlDocument xmlDocument=null; 80 if (strDiscount.equals("")) strDiscount = "N"; 81 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportInvoiceDiscount").createXmlDocument(); 82 83 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportInvoiceDiscountReportInvoiceDiscount", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 84 toolbar.prepareSimpleToolBarTemplate(); 85 xmlDocument.setParameter("toolbar", toolbar.toString()); 86 try { 87 KeyMap key = new KeyMap(this, vars, "ReportInvoiceDiscount.html"); 88 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 89 } catch (Exception ex) { 90 throw new ServletException(ex); 91 } 92 try { 93 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportInvoiceDiscount"); 94 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 95 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 96 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 97 xmlDocument.setParameter("theme", vars.getTheme()); 98 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportInvoiceDiscount.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 99 xmlDocument.setParameter("navigationBar", nav.toString()); 100 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportInvoiceDiscount.html", strReplaceWith); 101 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 102 } catch (Exception ex) { 103 throw new ServletException(ex); 104 } 105 { 106 OBError myMessage = vars.getMessage("ReportInvoiceDiscount"); 107 vars.removeMessage("ReportInvoiceDiscount"); 108 if (myMessage!=null) { 109 xmlDocument.setParameter("messageType", myMessage.getType()); 110 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 111 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 112 } 113 } 114 115 xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 116 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 117 xmlDocument.setParameter("dateFrom", strDateFrom); 118 xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 119 xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 120 xmlDocument.setParameter("dateTo", strDateTo); 121 xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat")); 122 xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat")); 123 xmlDocument.setParameter("discount", strDiscount); 124 xmlDocument.setData("reportCBPartnerId_IN", "liststructure", ReportInvoiceDiscountData.selectBpartner(this, Utility.getContext(this, vars, "#User_Org", "ReportInvoiceDiscount"), Utility.getContext(this, vars, "#User_Client", "ReportInvoiceDiscount"), strcBpartnerId)); 125 126 response.setContentType("text/html; charset=UTF-8"); 127 PrintWriter out = response.getWriter(); 128 out.println(xmlDocument.print()); 129 out.close(); 130 } 131 132 133 184 185 186 public String getServletInfo() { 187 return "Servlet ReportInvoiceDiscount. This Servlet was made by Pablo Sarobe"; 188 } } 190 191 | Popular Tags |