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_Inventory_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 strProduct = vars.getStringParameter("inpmProductId"); 45 String strLocator = vars.getStringParameter("inpmProductId_LOC"); 46 String strAttribute = vars.getStringParameter("inpmProductId_ATR"); 47 String strQty = vars.getStringParameter("inpmProductId_QTY"); 48 String strUOM = vars.getStringParameter("inpmProductId_UOM"); 49 String strQtyOrder = vars.getStringParameter("inpmProductId_PQTY"); 50 String strPUOM = vars.getStringParameter("inpmProductId_PUOM"); 51 String strTabId = vars.getStringParameter("inpTabId"); 52 printPage(response, vars, strChanged, strProduct, strLocator, strAttribute, strQty, strUOM, strQtyOrder, strPUOM, strTabId); 53 } else pageError(response); 54 } 55 56 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strChanged, String strProduct, String strLocator, String strAttribute, String strQty, String strUOM, String strQtyOrder, String strPUOM, String strTabId) 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 StringBuffer resultado = new StringBuffer (); 61 resultado.append("var calloutName='SL_Inventory_Product';\n\n"); 62 resultado.append("var respuesta = new Array("); 63 if (strLocator.startsWith("\"")) strLocator=strLocator.substring(1,strLocator.length()-1); 64 if (!strLocator.equals("")) { 65 resultado.append("new Array(\"inpmLocatorId\", \"" + strLocator + "\"),"); 66 resultado.append("new Array(\"inpmLocatorId_R\", \"" + FormatUtilities.replaceJS(SLInOutLineProductData.locator(this, strLocator, vars.getLanguage())) + "\"),"); 67 } 68 69 resultado.append("new Array(\"inpcUomId\", " + (strUOM.equals("")?"\"\"":strUOM) + "),"); 70 if (strAttribute.startsWith("\"")) strAttribute=strAttribute.substring(1,strAttribute.length()-1); 71 resultado.append("new Array(\"inpmAttributesetinstanceId\", \"" + strAttribute + "\"),"); 72 resultado.append("new Array(\"inpmAttributesetinstanceId_R\", \"" + FormatUtilities.replaceJS(SLInOutLineProductData.attribute(this, strAttribute)) + "\"),"); 73 String strHasSecondaryUOM = SLOrderProductData.hasSecondaryUOM(this, strProduct); 74 resultado.append("new Array(\"inphasseconduom\", " + strHasSecondaryUOM + "),\n"); 75 resultado.append("new Array(\"inpquantityorder\", " + ((strQtyOrder==null || strQtyOrder=="")?"\"\"":strQtyOrder) + "), \n"); 76 resultado.append("new Array(\"inpquantityorderbook\", " + ((strQtyOrder==null || strQtyOrder=="")?"\"\"":strQtyOrder) + "), \n"); 77 resultado.append("new Array(\"inpqtycount\", " + ((strQty==null || strQty=="")?"\"\"":strQty) + "), \n"); 78 resultado.append("new Array(\"inpqtybook\", " + ((strQty==null || strQty=="")?"\"\"":strQty) + "), \n"); 79 resultado.append("new Array(\"inpmProductUomId\", "); 80 if (strPUOM.startsWith("\"")) strPUOM=strPUOM.substring(1,strPUOM.length()-1); 81 if (vars.getLanguage().equals("en_US")) { 82 FieldProvider [] tld = null; 83 try { 84 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLE", "", "M_Product_UOM", "", Utility.getContext(this, vars, "#User_Org", "SLInventoryProduct"), Utility.getContext(this, vars, "#User_Client", "SLInventoryProduct"), 0); 85 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLInventoryProduct", ""); 86 tld = comboTableData.select(false); 87 comboTableData = null; 88 } catch (Exception ex) { 89 throw new ServletException(ex); 90 } 91 92 if (tld!=null && tld.length>0) { 93 resultado.append("new Array("); 94 for (int i=0;i<tld.length;i++) { 95 resultado.append("new Array(\"" + tld[i].getField("id") + "\", \"" + FormatUtilities.replaceJS(tld[i].getField("name")) + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strPUOM)?"true":"false") + "\")"); 96 if (i<tld.length-1) resultado.append(",\n"); 97 } 98 resultado.append("\n)"); 99 } else resultado.append("null"); 100 resultado.append("\n),"); 101 } else { 102 FieldProvider [] tld = null; 103 try { 104 ComboTableData comboTableData = new ComboTableData(vars, this, "TABLE", "", "M_Product_UOM", "", Utility.getContext(this, vars, "#User_Org", "SLInventoryProduct"), Utility.getContext(this, vars, "#User_Client", "SLInventoryProduct"), 0); 105 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLInventoryProduct", ""); 106 tld = comboTableData.select(false); 107 comboTableData = null; 108 } catch (Exception ex) { 109 throw new ServletException(ex); 110 } 111 112 if (tld!=null && tld.length>0) { 113 resultado.append("new Array("); 114 for (int i=0;i<tld.length;i++) { 115 resultado.append("new Array(\"" + tld[i].getField("id") + "\", \"" + FormatUtilities.replaceJS(tld[i].getField("name")) + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strPUOM)?"true":"false") + "\")"); 116 if (i<tld.length-1) resultado.append(",\n"); 117 } 118 resultado.append("\n)"); 119 } else resultado.append("null"); 120 resultado.append("\n),"); 121 } 122 resultado.append("new Array(\"EXECUTE\", \"displayLogic();\")\n"); 123 resultado.append(");"); 124 xmlDocument.setParameter("array", resultado.toString()); 125 xmlDocument.setParameter("frameName", "frameAplicacion"); 126 response.setContentType("text/html; charset=UTF-8"); 127 PrintWriter out = response.getWriter(); 128 out.println(xmlDocument.print()); 129 out.close(); 130 } 131 } 132 | Popular Tags |