1 19 package org.openbravo.erpCommon.ad_callouts; 20 21 import org.openbravo.base.secureApp.HttpSecureAppServlet; 22 import org.openbravo.base.secureApp.VariablesSecureApp; 23 import org.openbravo.xmlEngine.XmlDocument; 24 import org.openbravo.utils.FormatUtilities; 25 import org.openbravo.erpCommon.utility.*; 26 import org.openbravo.data.FieldProvider; 27 import java.io.*; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 public class SL_WRPhaseProduct_Product extends HttpSecureAppServlet { 32 33 34 public void init (ServletConfig config) { 35 super.init(config); 36 boolHist = false; 37 } 38 39 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 40 VariablesSecureApp vars = new VariablesSecureApp(request); 41 if (vars.commandIn("DEFAULT")) { 42 String strChanged = vars.getStringParameter("inpLastFieldChanged"); 43 if (log4j.isDebugEnabled()) log4j.debug("CHANGED: " + strChanged); 44 String strTabId = vars.getStringParameter("inpTabId"); 45 46 String strMProductID = vars.getStringParameter("inpmProductId"); 47 48 try { 49 printPage(response, vars, strTabId, strMProductID); 50 } catch (ServletException ex) { 51 pageErrorCallOut(response); 52 } 53 } else pageError(response); 54 } 55 56 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strTabId, String strMProductID) throws IOException, ServletException { 57 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 58 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 59 60 String strProductUom = SLWRPhaseProductProductData.selectProductUom(this, strMProductID); 61 StringBuffer resultado = new StringBuffer (); 62 resultado.append("var calloutName='SL_WRPhaseProduct_Product';\n\n"); 63 resultado.append("var respuesta = new Array("); 64 resultado.append("new Array(\"inpcUomId\", \"" + FormatUtilities.replaceJS((strProductUom.equals("")?"\"\"":strProductUom)) + "\"),\n"); 65 String strHasSecondaryUOM = SLWRPhaseProductProductData.hasSecondaryUOM(this, strMProductID); 66 resultado.append("new Array(\"inphasseconduom\", " + strHasSecondaryUOM + "),\n"); 67 68 70 resultado.append("new Array(\"inpmProductUomId\", "); 71 String strmProductUOMId = SLWRPhaseProductProductData.strMProductUOMID(this,strMProductID,strProductUom); 72 if (vars.getLanguage().equals("en_US")) { 73 FieldProvider [] tld = null; 74 try { 75 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLE", "", "M_Product_UOM", "", Utility.getContext(this, vars, "#User_Org", "SLOrderProduct"), Utility.getContext(this, vars, "#User_Client", "SLOrderProduct"), 0); 76 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLOrderProduct", ""); 77 tld = comboTableData.select(false); 78 comboTableData = null; 79 } catch (Exception ex) { 80 throw new ServletException(ex); 81 } 82 83 if (tld!=null && tld.length>0) { 84 resultado.append("new Array("); 85 for (int i=0;i<tld.length;i++) { 86 resultado.append("new Array(\"" + tld[i].getField("id") + "\", \"" + tld[i].getField("name") + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strmProductUOMId)?"true":"false") + "\")"); 87 if (i<tld.length-1) resultado.append(",\n"); 88 } 89 resultado.append("\n)"); 90 } else resultado.append("null"); 91 resultado.append("\n),"); 92 } else { 93 FieldProvider [] tld = null; 94 try { 95 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLE", "", "M_Product_UOM", "", Utility.getContext(this, vars, "#User_Org", "SLOrderProduct"), Utility.getContext(this, vars, "#User_Client", "SLOrderProduct"), 0); 96 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLOrderProduct", ""); 97 tld = comboTableData.select(false); 98 comboTableData = null; 99 } catch (Exception ex) { 100 throw new ServletException(ex); 101 } 102 103 if (tld!=null && tld.length>0) { 104 resultado.append("new Array("); 105 for (int i=0;i<tld.length;i++) { 106 resultado.append("new Array(\"" + tld[i].getField("id") + "\", \"" + tld[i].getField("name") + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strmProductUOMId)?"true":"false") + "\")"); 107 if (i<tld.length-1) resultado.append(",\n"); 108 } 109 resultado.append("\n)"); 110 } else resultado.append("null"); 111 resultado.append("\n),"); 112 } 113 resultado.append("new Array(\"EXECUTE\", \"displayLogic();\")\n"); 114 resultado.append(");\n"); 118 119 xmlDocument.setParameter("array", resultado.toString()); 120 xmlDocument.setParameter("frameName", (Utility.isTreeTab(this, strTabId)?"frameAplicacion.frameWindowTreeTab":"frameAplicacion")); 121 response.setContentType("text/html; charset=UTF-8"); 122 PrintWriter out = response.getWriter(); 123 out.println(xmlDocument.print()); 124 out.close(); 125 } 126 } 127 | Popular Tags |