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.erpCommon.ad_actionButton.*; 27 import java.io.*; 28 import javax.servlet.*; 29 import javax.servlet.http.*; 30 31 32 public class SE_Wh_SchedulePeriod extends HttpSecureAppServlet { 33 34 35 public void init (ServletConfig config) { 36 super.init(config); 37 boolHist = false; 38 } 39 40 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 41 VariablesSecureApp vars = new VariablesSecureApp(request); 42 if (vars.commandIn("DEFAULT")) { 43 String strChanged = vars.getStringParameter("inpLastFieldChanged"); 44 if (log4j.isDebugEnabled()) log4j.debug("CHANGED: " + strChanged); 45 String strWhSchedule = vars.getStringParameter("inpmWhScheduleId"); 46 String strTabId = vars.getStringParameter("inpTabId"); 47 48 try { 49 printPage(response, vars, strWhSchedule, strTabId); 50 } catch (ServletException ex) { 51 pageErrorCallOut(response); 52 } 53 } else pageError(response); 54 } 55 56 void printPage(HttpServletResponse response, VariablesSecureApp vars, String strWhSchedule, 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 InvoicingScheduleData[] data = InvoicingScheduleData.selectM_WH_Period_ID(this, Utility.getContext(this, vars, "#User_Org", "SE_Wh_SchedulePeriod"), Utility.getContext(this, vars, "#User_Client", "SE_Wh_SchedulePeriod"), strWhSchedule); 61 StringBuffer resultado = new StringBuffer (); 62 if (data==null || data.length==0) resultado.append("var respuesta = null;"); 63 else { 64 resultado.append("var calloutName='SE_Wh_SchedulePeriod';\n\n"); 65 resultado.append("var respuesta = new Array("); 66 resultado.append("new Array(\"inpPeriodFromId\", "); 67 if (data!=null && data.length>0) { 68 resultado.append("new Array("); 69 for (int i=0;i<data.length;i++) { 70 resultado.append("new Array(\"" + data[i].id + "\", \"" + FormatUtilities.replaceJS(data[i].name) +"\")"); 71 if (i<data.length-1) resultado.append(",\n"); 72 } 73 resultado.append("\n)"); 74 } else resultado.append("null"); 75 resultado.append("\n),"); 76 resultado.append("new Array(\"inpPeriodToId\", "); 77 if (data!=null && data.length>0) { 78 resultado.append("new Array("); 79 for (int i=0;i<data.length;i++) { 80 resultado.append("new Array(\"" + data[i].id + "\", \"" + FormatUtilities.replaceJS(data[i].name) +"\")"); 81 if (i<data.length-1) resultado.append(",\n"); 82 } 83 resultado.append("\n)"); 84 } else resultado.append("null"); 85 resultado.append("\n)"); 86 87 resultado.append(");"); 88 } 89 xmlDocument.setParameter("array", resultado.toString()); 90 xmlDocument.setParameter("frameName", "frameAplicacion"); 91 response.setContentType("text/html; charset=UTF-8"); 92 PrintWriter out = response.getWriter(); 93 out.println(xmlDocument.print()); 94 out.close(); 95 } 96 } 97 | Popular Tags |