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_InOutLine_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 strLocator = vars.getStringParameter("inpmProductId_LOC"); 45 String strQty = vars.getStringParameter("inpmProductId_QTY"); 46 String strUOM = vars.getStringParameter("inpmProductId_UOM"); 47 String strAttribute = vars.getStringParameter("inpmProductId_ATR"); 48 String strQtyOrder = vars.getStringParameter("inpmProductId_PQTY"); 49 String strPUOM = vars.getStringParameter("inpmProductId_PUOM"); 50 String strMProductID = vars.getStringParameter("inpmProductId"); 51 String strWindowId = vars.getStringParameter("inpwindowId"); 52 String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); 53 String strWharehouse = Utility.getContext(this, vars, "#M_Warehouse_ID", strWindowId); 54 String strTabId = vars.getStringParameter("inpTabId"); 55 String strmInoutlineId = vars.getStringParameter("inpmInoutlineId"); 56 57 58 59 try { 60 printPage(response, vars, strLocator, strQty, strUOM, strAttribute, strQtyOrder, strPUOM, strMProductID, strIsSOTrx, strWharehouse, strTabId,strmInoutlineId); 61 } catch (ServletException ex) { 62 pageErrorCallOut(response); 63 } 64 } else pageError(response); 65 } 66 67 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strLocator, String strQty, String strUOM, String strAttribute, String strQtyOrder, String strPUOM, String strMProductID, String strIsSOTrx, String strWharehouse, String strTabId, String strmInoutlineId) throws IOException, ServletException { 68 if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); 69 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument(); 70 71 StringBuffer resultado = new StringBuffer (); 72 74 75 76 resultado.append("var calloutName='SL_InOutLine_Product';\n\n"); 77 resultado.append("var respuesta = new Array("); 78 if (strLocator.startsWith("\"")) strLocator=strLocator.substring(1,strLocator.length()-1); 80 resultado.append("new Array(\"inpmLocatorId\", \"" + strLocator + "\"),"); 81 resultado.append("new Array(\"inpmLocatorId_R\", \"" + FormatUtilities.replaceJS(SLInOutLineProductData.locator(this, strLocator, vars.getLanguage())) + "\"),"); 82 if (!strAttribute.equals("")) { 83 if (strAttribute.startsWith("\"")) strAttribute=strAttribute.substring(1,strAttribute.length()-1); 84 resultado.append("new Array(\"inpmAttributesetinstanceId\", \"" + strAttribute + "\"),"); 85 resultado.append("new Array(\"inpmAttributesetinstanceId_R\", \"" + FormatUtilities.replaceJS(SLInOutLineProductData.attribute(this, strAttribute)) + "\"),"); 86 } 87 String fromOrder=SLInOutLineProductData.fromOrder(this, strmInoutlineId); 89 if (fromOrder.equals("0")){ 90 resultado.append("new Array(\"inpquantityorder\", " + (strQtyOrder.equals("")?"\"\"":strQtyOrder) + "),"); 91 resultado.append("new Array(\"inpmovementqty\", " + (strQty.equals("")?"\"\"":strQty) + "),"); 93 } 94 String strHasSecondaryUOM = SLOrderProductData.hasSecondaryUOM(this, strMProductID); 96 resultado.append("new Array(\"inphasseconduom\", " + strHasSecondaryUOM + "),\n"); 97 resultado.append("new Array(\"inpmProductUomId\", "); 98 if (strPUOM.startsWith("\"")) strPUOM=strPUOM.substring(1,strPUOM.length()-1); 99 if (vars.getLanguage().equals("en_US")) { 100 FieldProvider [] tld = null; 101 try { 102 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); 103 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLOrderProduct", ""); 104 tld = comboTableData.select(false); 105 comboTableData = null; 106 } catch (Exception ex) { 107 throw new ServletException(ex); 108 } 109 110 if (tld!=null && tld.length>0) { 111 resultado.append("new Array("); 112 for (int i=0;i<tld.length;i++) { 113 resultado.append("new Array(\"" + tld[i].getField("id") + "\", \"" + FormatUtilities.replaceJS(tld[i].getField("name")) + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strPUOM)?"true":"false") + "\")"); 114 if (i<tld.length-1) resultado.append(",\n"); 115 } 116 resultado.append("\n)"); 117 } else resultado.append("null"); 118 resultado.append("\n),"); 119 } else { 120 FieldProvider [] tld = null; 121 try { 122 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); 123 Utility.fillSQLParameters(this, vars, null, comboTableData, "SLOrderProduct", ""); 124 tld = comboTableData.select(false); 125 comboTableData = null; 126 } catch (Exception ex) { 127 throw new ServletException(ex); 128 } 129 130 if (tld!=null && tld.length>0) { 131 resultado.append("new Array("); 132 for (int i=0;i<tld.length;i++) { 133 resultado.append("new Array(\"" + tld[i].getField("id") + "\", \"" + FormatUtilities.replaceJS(tld[i].getField("name")) + "\", \"" + (tld[i].getField("id").equalsIgnoreCase(strPUOM)?"true":"false") + "\")"); 134 if (i<tld.length-1) resultado.append(",\n"); 135 } 136 resultado.append("\n)"); 137 } else resultado.append("null"); 138 resultado.append("\n),"); 139 } 140 resultado.append("new Array(\"inpcUomId\", " + (strUOM.equals("")?"\"\"":strUOM) + "),\n"); 141 resultado.append("new Array(\"EXECUTE\", \"displayLogic();\")\n"); 142 143 144 resultado.append(");"); 145 146 if (log4j.isDebugEnabled()) log4j.debug("Array: " + resultado.toString()); 147 xmlDocument.setParameter("frameName", "frameAplicacion"); 148 xmlDocument.setParameter("array", resultado.toString()); 149 response.setContentType("text/html; charset=UTF-8"); 150 PrintWriter out = response.getWriter(); 151 out.println(xmlDocument.print()); 152 out.close(); 153 } 154 } 155 | Popular Tags |