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 public class ReportPricelist extends HttpSecureAppServlet { 31 32 33 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 34 VariablesSecureApp vars = new VariablesSecureApp(request); 35 36 if (vars.commandIn("DEFAULT")) { 37 String strProductCategory = vars.getGlobalVariable("inpProductCategory", "ReportPricelist|productCategory", ""); 38 String strPricelistversionId = vars.getGlobalVariable("inpmPricelistVersion", "ReportPricelist|pricelistversion", ""); 39 String strmProductId = vars.getInGlobalVariable("inpmProductId_IN", "ReportPricelist|mProductId", ""); 40 printPageDataSheet(response, vars, strProductCategory, strPricelistversionId,strmProductId); 41 48 } else if (vars.commandIn("FIND")) { 49 String strProductCategory = vars.getRequestGlobalVariable("inpProductCategory", "ReportPricelist|productCategory"); 50 String strPricelistversionId = vars.getRequestGlobalVariable("inpmPricelistVersion", "ReportPricelist|pricelistversion"); 51 String strmProductId = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportPricelist|mProductId"); 52 53 printPageDataSheet(response, vars, strProductCategory, strPricelistversionId, strmProductId); 54 } else if (vars.commandIn("EDIT_PDF")) { 55 String strProductCategory = vars.getRequestGlobalVariable("inpProductCategory", "ReportPricelist|productCategory"); 56 String strPricelistversionId = vars.getRequestGlobalVariable("inpmPricelistVersion", "ReportPricelist|pricelistversion"); 57 String strmProductId = vars.getRequestInGlobalVariable("inpmProductId_IN", "ReportPricelist|mProductId"); 58 printPagePdf(response, vars, strProductCategory, strPricelistversionId, strmProductId); 59 } else pageError(response); 60 } 61 62 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strProductCategory, String strPricelistversionId, String strmProductId) 63 throws IOException, ServletException { 64 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 65 response.setContentType("text/html; charset=UTF-8"); 66 PrintWriter out = response.getWriter(); 67 XmlDocument xmlDocument=null; 68 ReportPricelistData[] data = null; 69 String discard[] = {"discard"}; 70 if (vars.commandIn("DEFAULT") && strProductCategory.equals("") && strPricelistversionId.equals("") && strmProductId.equals("")){ 71 discard[0] = "sectionPricelistVersion"; 72 data = ReportPricelistData.set(); 73 } else { 74 data = ReportPricelistData.select(this, Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), strPricelistversionId, strProductCategory, strmProductId); 75 } 76 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportPricelist", discard).createXmlDocument(); 77 78 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ReportPricelist", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 79 toolbar.prepareSimpleToolBarTemplate(); 80 xmlDocument.setParameter("toolbar", toolbar.toString()); 81 82 try { 83 KeyMap key = new KeyMap(this, vars, "ReportPricelist.html"); 84 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 85 } catch (Exception ex) { 86 throw new ServletException(ex); 87 } 88 try { 89 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ReportPricelist"); 90 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 91 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 92 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 93 xmlDocument.setParameter("theme", vars.getTheme()); 94 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ReportPricelist.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 95 xmlDocument.setParameter("navigationBar", nav.toString()); 96 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ReportPricelist.html", strReplaceWith); 97 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 98 } catch (Exception ex) { 99 throw new ServletException(ex); 100 } 101 { 102 OBError myMessage = vars.getMessage("ReportPricelist"); 103 vars.removeMessage("ReportPricelist"); 104 if (myMessage!=null) { 105 xmlDocument.setParameter("messageType", myMessage.getType()); 106 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 107 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 108 } 109 } 110 111 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 112 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 113 xmlDocument.setParameter("mProductCategoryId", strProductCategory); 114 xmlDocument.setParameter("mPricelistVersionId", strPricelistversionId); 115 116 try { 117 ComboTableData comboTableData = new ComboTableData(vars, this, "LIST", "MProductId_IN", "null", "", Utility.getContext(this, vars, "#User_Org", ""), Utility.getContext(this, vars, "#User_Client", ""), 0); 118 Utility.fillSQLParameters(this, vars, null, comboTableData, "", strmProductId); 119 xmlDocument.setData("reportMProductId_IN", "liststructure", comboTableData.select(false)); 120 comboTableData = null; 121 } catch (Exception ex) { 122 throw new ServletException(ex); 123 } 124 125 126 try { 127 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), 0); 128 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportPricelist", strProductCategory); 129 xmlDocument.setData("reportM_PRODUCT_CATEGORYID","liststructure", comboTableData.select(false)); 130 comboTableData = null; 131 } catch (Exception ex) { 132 throw new ServletException(ex); 133 } 134 135 136 try { 137 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_PriceList_Version_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), 0); 138 Utility.fillSQLParameters(this, vars, null, comboTableData, "ReportPricelist", strPricelistversionId); 139 xmlDocument.setData("reportM_PRICELIST_VERSIONID","liststructure", comboTableData.select(false)); 140 comboTableData = null; 141 } catch (Exception ex) { 142 throw new ServletException(ex); 143 } 144 145 146 xmlDocument.setData("structure1", data); 147 148 out.println(xmlDocument.print()); 149 out.close(); 150 } 151 152 void printPagePdf(HttpServletResponse response, VariablesSecureApp vars, String strProductCategory, String strPricelistversionId, String strmProductId) throws IOException, ServletException{ 153 if (log4j.isDebugEnabled()) log4j.debug("Output: print pdf"); 154 XmlDocument xmlDocument=null; 155 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ReportPricelist_Pdf").createXmlDocument(); 156 xmlDocument.setData("structure1", ReportPricelistData.selectPDF(this, Utility.getContext(this, vars, "#User_Client", "ReportPricelist"), Utility.getContext(this, vars, "#User_Org", "ReportPricelist"), strPricelistversionId, strProductCategory, strmProductId)); 157 String strResult = xmlDocument.print(); 158 if (log4j.isDebugEnabled()) log4j.debug(strResult); 159 renderFO(strResult, response); 160 } 161 162 public String getServletInfo() { 163 return "Servlet ReportPricelist. This Servlet was made by Pablo Sarobe"; 164 } } 166 | Popular Tags |