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 ABCproduct 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 strFrom = vars.getGlobalVariable("inpFrom", "ABCproduct|From", ""); 38 String strTo = vars.getGlobalVariable("inpTo", "ABCproduct|To", ""); 39 String strCategory = vars.getGlobalVariable("inpCategory", "ABCproduct|Category", ""); 40 printPageDataSheet(response, vars, strFrom, strTo, strCategory); 41 } else if (vars.commandIn("FIND")) { 42 String strFrom = vars.getRequestGlobalVariable("inpFrom", "ABCproduct|From"); 43 String strTo = vars.getRequestGlobalVariable("inpTo", "ABCproduct|To"); 44 String strCategory = vars.getGlobalVariable("inpCategory", "ABCproduct|Category", ""); 45 printPageDataSheet(response, vars, strFrom, strTo, strCategory); 46 } else pageError(response); 47 } 48 49 void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strFrom, String strTo, String strCategory) 50 throws IOException, ServletException { 51 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 52 response.setContentType("text/html; charset=UTF-8"); 53 PrintWriter out = response.getWriter(); 54 XmlDocument xmlDocument=null; 55 ABCproductData[] data=null; 56 if (strFrom.equals("") || strTo.equals("")){ 57 String discard[]= {"selEliminar"}; 58 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ABCproduct", discard).createXmlDocument(); 59 data = ABCproductData.set("0","0"); 60 } else { 61 xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_reports/ABCproduct").createXmlDocument(); 62 data = ABCproductData.select(this,strFrom, strTo, strCategory); 63 } 64 65 ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ABCproduct", false, "", "", "",false, "ad_reports", strReplaceWith, false, true); 66 toolbar.prepareSimpleToolBarTemplate(); 67 xmlDocument.setParameter("toolbar", toolbar.toString()); 68 try { 69 KeyMap key = new KeyMap(this, vars, "ABCproduct.html"); 70 xmlDocument.setParameter("keyMap", key.getReportKeyMaps()); 71 } catch (Exception ex) { 72 throw new ServletException(ex); 73 } 74 try { 75 WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.ABCbproduct"); 76 xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); 77 xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); 78 xmlDocument.setParameter("childTabContainer", tabs.childTabs()); 79 xmlDocument.setParameter("theme", vars.getTheme()); 80 NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ABCproduct.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); 81 xmlDocument.setParameter("navigationBar", nav.toString()); 82 LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ABCproduct.html", strReplaceWith); 83 xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); 84 } catch (Exception ex) { 85 throw new ServletException(ex); 86 } 87 { 88 OBError myMessage = vars.getMessage("ABCproduct"); 89 vars.removeMessage("ABCproduct"); 90 if (myMessage!=null) { 91 xmlDocument.setParameter("messageType", myMessage.getType()); 92 xmlDocument.setParameter("messageTitle", myMessage.getTitle()); 93 xmlDocument.setParameter("messageMessage", myMessage.getMessage()); 94 } 95 } 96 97 98 xmlDocument.setParameter("calendar", vars.getLanguage().substring(0,2)); 99 xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n"); 100 xmlDocument.setParameter("paramLanguage", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";"); 101 xmlDocument.setParameter("from", strFrom); 102 xmlDocument.setParameter("to", strTo); 103 xmlDocument.setParameter("category", strCategory); 104 105 try { 106 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "M_Product_Category_ID", "", "", Utility.getContext(this, vars, "#User_Org", "ABCproduct"), Utility.getContext(this, vars, "#User_Client", "ABCproduct"), 0); 107 Utility.fillSQLParameters(this, vars, null, comboTableData, "ABCproduct", ""); 108 xmlDocument.setData("reportCategory","liststructure", comboTableData.select(false)); 109 comboTableData = null; 110 } catch (Exception ex) { 111 throw new ServletException(ex); 112 } 113 114 xmlDocument.setData("structure", data); 115 out.println(xmlDocument.print()); 116 out.close(); 117 } 118 119 public String getServletInfo() { 120 return "Servlet ABCproduct. This Servlet was made by Eduardo Argal"; 121 } } 123 124 | Popular Tags |