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_SequenceProduct_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 try { 48 printPage(response, vars, strTabId, strMProductID); 49 } catch (ServletException ex) { 50 pageErrorCallOut(response); 51 } 52 } else pageError(response); 53 } 54 55 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strTabId, String strMProductID) throws IOException, ServletException { 56 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 57 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 58 59 String strProductUom = SLSequenceProductProductData.selectProductUom(this, strMProductID); 60 StringBuffer resultado = new StringBuffer (); 61 resultado.append("var calloutName='SL_SequenceProduct_Product';\n\n"); 62 resultado.append("var respuesta = new Array("); 63 resultado.append("new Array(\"inpcUomId\", \"" + FormatUtilities.replaceJS(strProductUom) + "\"),\n"); 64 String strHasSecondaryUOM = SLSequenceProductProductData.hasSecondaryUOM(this, strMProductID); 65 resultado.append("new Array(\"inphasseconduom\", " + strHasSecondaryUOM + "),\n"); 66 67 resultado.append("new Array(\"inpmProductUomId\", "); 68 String strmProductUOMId = SLSequenceProductProductData.strMProductUOMID(this,strMProductID,strProductUom); 69 if (vars.getLanguage().equals("en_US")) { 70 FieldProvider [] tld = null; 71 try { 72 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); 73 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLOrderProduct", ""); 74 tld = comboTableData.select(false); 75 comboTableData = null; 76 } catch (Exception ex) { 77 throw new ServletException(ex); 78 } 79 80 if (tld!=null && tld.length>0) { 81 resultado.append("new Array("); 82 for (int i=0;i<tld.length;i++) { 83 resultado.append("new Array(" + tld[i].getField("id") + ", \"" + FormatUtilities.replaceJS(tld[i].getField("name")) + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strmProductUOMId)?"true":"false") + "\")"); 84 if (i<tld.length-1) resultado.append(",\n"); 85 } 86 resultado.append("\n)"); 87 } else resultado.append("null"); 88 resultado.append("\n),"); 89 } else { 90 FieldProvider [] tld = null; 91 try { 92 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); 93 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLOrderProduct", ""); 94 tld = comboTableData.select(false); 95 comboTableData = null; 96 } catch (Exception ex) { 97 throw new ServletException(ex); 98 } 99 100 if (tld!=null && tld.length>0) { 101 resultado.append("new Array("); 102 for (int i=0;i<tld.length;i++) { 103 resultado.append("new Array(" + tld[i].getField("id") + ", \"" + FormatUtilities.replaceJS(tld[i].getField("name")) + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strmProductUOMId)?"true":"false") + "\")"); 104 if (i<tld.length-1) resultado.append(",\n"); 105 } 106 resultado.append("\n)"); 107 } else resultado.append("null"); 108 resultado.append("\n),"); 109 } 110 resultado.append("new Array(\"EXECUTE\", \"displayLogic();\")\n"); 111 115 resultado.append(");\n"); 116 xmlDocument.setParameter("array", resultado.toString()); 117 xmlDocument.setParameter("frameName", "frameAplicacion"); 118 response.setContentType("text/html; charset=UTF-8"); 119 PrintWriter out = response.getWriter(); 120 out.println(xmlDocument.print()); 121 out.close(); 122 } 123 } 124 | Popular Tags |