package org.apache.jsp.service;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
import org.ofbiz.security.*;
import org.ofbiz.entity.*;
import org.ofbiz.base.util.*;
import org.ofbiz.webapp.pseudotag.*;
import org.ofbiz.service.*;
import org.ofbiz.service.config.*;
import org.ofbiz.service.calendar.*;

public final class schedulejob_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  static {
    _jspx_dependants = new java.util.Vector(1);
    _jspx_dependants.add("/WEB-INF/ofbiz.tld");
  }

  private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_ofbiz_url;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _jspx_tagPool_ofbiz_url = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
  }

  public void _jspDestroy() {
    _jspx_tagPool_ofbiz_url.release();
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      response.addHeader("X-Powered-By", "JSP/2.0");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      org.ofbiz.security.Security security = null;
      synchronized (request) {
        security = (org.ofbiz.security.Security) _jspx_page_context.getAttribute("security", PageContext.REQUEST_SCOPE);
        if (security == null){
          throw new java.lang.InstantiationException("bean security not found within scope");
        }
      }
      out.write('\r');
      out.write('\n');
      org.ofbiz.entity.GenericDelegator delegator = null;
      synchronized (request) {
        delegator = (org.ofbiz.entity.GenericDelegator) _jspx_page_context.getAttribute("delegator", PageContext.REQUEST_SCOPE);
        if (delegator == null){
          throw new java.lang.InstantiationException("bean delegator not found within scope");
        }
      }
      out.write('\r');
      out.write('\n');
      org.ofbiz.service.LocalDispatcher dispatcher = null;
      synchronized (request) {
        dispatcher = (org.ofbiz.service.LocalDispatcher) _jspx_page_context.getAttribute("dispatcher", PageContext.REQUEST_SCOPE);
        if (dispatcher == null){
          throw new java.lang.InstantiationException("bean dispatcher not found within scope");
        }
      }
      out.write("\r\n");
      out.write("\r\n");
if(security.hasPermission("WEBTOOLS_VIEW", session)) {
      out.write("\r\n");
      out.write("\r\n");

	String serviceName = request.getParameter("SERVICE_NAME");
	String poolName = ServiceConfigUtil.getSendPool();

      out.write("\r\n");
      out.write("\r\n");
 if (serviceName == null) { 
      out.write("\r\n");
      out.write("  <div class=\"head2\">Schedule A Job</div>\r\n");
      out.write("  <div class=\"tabletext\">Step 1: Service & Recurrence Information</div>\r\n");
      out.write("  <br/>\r\n");
      out.write("\r\n");
      out.write("  <FORM name=\"scheduleForm\" method='POST' action='");
      if (_jspx_meth_ofbiz_url_0(_jspx_page_context))
        return;
      out.write("'>\r\n");
      out.write("    <table border='0'>\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Service:</div></td>\r\n");
      out.write("        <td><input type=\"text\" class=\"inputBox\" size=\"20\" name=\"SERVICE_NAME\"></td>\r\n");
      out.write("      </tr>      \r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Pool Name:</div></td>\r\n");
      out.write("        <td><input type=\"text\" class=\"inputBox\" size=\"20\" name=\"POOL_NAME\" value=\"");
      out.print(poolName);
      out.write("\"></td>\r\n");
      out.write("      </tr>      \r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Start Date/Time:</div></td>\r\n");
      out.write("        <td>\r\n");
      out.write("          <input type=\"text\" class=\"inputBox\" size=\"25\" name=\"SERVICE_TIME\">\r\n");
      out.write("          <a href=\"javascript:call_cal(document.scheduleForm.SERVICE_TIME, null);\"><img src='/images/cal.gif' width='16' height='16' border='0' alt='Click here For Calendar'></a>\r\n");
      out.write("        </td>\r\n");
      out.write("      </tr>    \r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Finish Date/Time:</div></td>\r\n");
      out.write("        <td>\r\n");
      out.write("          <input type=\"text\" class=\"inputBox\" size=\"25\" name=\"SERVICE_END_TIME\">\r\n");
      out.write("          <a href=\"javascript:call_cal(document.scheduleForm.SERVICE_END_TIME, null);\"><img src='/images/cal.gif' width='16' height='16' border='0' alt='Click here For Calendar'></a>\r\n");
      out.write("        </td>\r\n");
      out.write("      </tr>   \r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Frequency:</div></td>\r\n");
      out.write("        <td>\r\n");
      out.write("          <select class=\"selectBox\" name=\"SERVICE_FREQUENCY\">    \r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.DAILY);
      out.write("\">None</option>                                                                    \r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.YEARLY);
      out.write("\">Yearly</option>\r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.MONTHLY);
      out.write("\">Monthly</option>\r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.WEEKLY);
      out.write("\">Weekly</option>\r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.DAILY);
      out.write("\">Daily</option>\r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.HOURLY);
      out.write("\">Hourly</option>\r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.MINUTELY);
      out.write("\">Minutely</option>\r\n");
      out.write("            <option value=\"");
      out.print(RecurrenceRule.SECONDLY);
      out.write("\">Secondly</option>\r\n");
      out.write("\r\n");
      out.write("        </td>\r\n");
      out.write("      </tr>\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Interval:</div></td>\r\n");
      out.write("        <td><input type=\"text\" class=\"inputBox\" size=\"6\" name=\"SERVICE_INTERVAL\">&nbsp;<span class='tabletext'>(for use with frequency)</span></td>\r\n");
      out.write("      </tr>\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Count:</div></td>\r\n");
      out.write("        <td><input type=\"text\" class=\"inputBox\" size=\"6\" name=\"SERVICE_COUNT\" value=\"1\">&nbsp;<span class=\"tabletext\">(number of time the job will run; use -1 for no limit i.e. forever)</span></td>\r\n");
      out.write("      </tr>\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">Max Retry:</div></td>\r\n");
      out.write("        <td><input type=\"text\" class=\"inputBox\" size=\"6\" name=\"SERVICE_MAXRETRY\" value=\"\">&nbsp;<span class=\"tabletext\">(number of time the job will retry on error; use -1 for no limit or leave empty for service default)</span></td>\r\n");
      out.write("      </tr>\r\n");
      out.write("\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td colspan=\"2\">&nbsp;</td>\r\n");
      out.write("      </tr>\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td colspan=\"2\" align=\"center\"><input type=\"submit\" class=\"smallSubmit\" value=\"Submit\"></td>\r\n");
      out.write("      </tr>\r\n");
      out.write("    </table>\r\n");
      out.write("  </FORM>\r\n");
} else {
      out.write("\r\n");
      out.write("  <div class=\"head2\">Schedule A Job</div>\r\n");
      out.write("  <div class=\"tabletext\">Step 2: Service Parameters</div>\r\n");
      out.write("  <br/>\r\n");
      out.write("\r\n");
      out.write("  <FORM name=\"scheduleForm\" method='POST' action='");
      if (_jspx_meth_ofbiz_url_1(_jspx_page_context))
        return;
      out.write("'>\r\n");
      out.write("    ");
 
  		Enumeration e = request.getParameterNames();  		
  		while (e.hasMoreElements()) {
  			String paramName = (String) e.nextElement();
  			String paramValue = request.getParameter(paramName);
    
      out.write("\r\n");
      out.write("\t<input type='hidden' name='");
      out.print(paramName);
      out.write("' value='");
      out.print(paramValue);
      out.write("'>\r\n");
      out.write("\t");
  } 
      out.write("\r\n");
      out.write("\t\r\n");
      out.write("\t");

		DispatchContext dctx = dispatcher.getDispatchContext();
		ModelService model = dctx.getModelService(serviceName);

	
      out.write("\r\n");
      out.write("\r\n");
      out.write("    <table border='0'>\r\n");
      out.write("      ");

      	Iterator pi = model.getInParamNames().iterator();
      	while (pi.hasNext()) {
      		ModelParam par = model.getParam((String)pi.next());
      		if (par.internal) continue;
      
      out.write("\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td align=\"right\"><div class=\"tabletext\">");
      out.print(par.name);
      out.write(' ');
      out.write('(');
      out.print(par.type);
      out.write(")</div></td>\r\n");
      out.write("        <td>\r\n");
      out.write("          <input type=\"text\" class=\"inputBox\" size=\"20\" name=\"");
      out.print(par.name);
      out.write("\">\r\n");
      out.write("          <span class=\"tabletext\">");
if(!par.optional){
      out.write("(required)");
}else{
      out.write("(optional)");
}
      out.write("\r\n");
      out.write("        </td>\r\n");
      out.write("      </tr>\r\n");
      out.write("      ");
}
      out.write("\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td colspan=\"2\">&nbsp;</td>\r\n");
      out.write("      </tr>\r\n");
      out.write("      <tr>\r\n");
      out.write("        <td colspan=\"2\" align=\"center\"><input type=\"submit\" class=\"smallSubmit\" value=\"Submit\"></td>\r\n");
      out.write("      </tr>      \r\n");
      out.write("    </table>\r\n");
      out.write("  </FORM>\t\r\n");
}
      out.write("\r\n");
      out.write("\t\r\n");
}else{
      out.write("\r\n");
      out.write("  <hr>\r\n");
      out.write("  <div>You do not have permission to use this page.</div>\r\n");
}
      out.write("\t\r\n");
      out.write("\t");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }

  private boolean _jspx_meth_ofbiz_url_0(PageContext _jspx_page_context)
          throws Throwable {
    PageContext pageContext = _jspx_page_context;
    JspWriter out = _jspx_page_context.getOut();
    //  ofbiz:url
    org.ofbiz.webapp.taglib.UrlTag _jspx_th_ofbiz_url_0 = (org.ofbiz.webapp.taglib.UrlTag) _jspx_tagPool_ofbiz_url.get(org.ofbiz.webapp.taglib.UrlTag.class);
    _jspx_th_ofbiz_url_0.setPageContext(_jspx_page_context);
    _jspx_th_ofbiz_url_0.setParent(null);
    int _jspx_eval_ofbiz_url_0 = _jspx_th_ofbiz_url_0.doStartTag();
    if (_jspx_eval_ofbiz_url_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
      if (_jspx_eval_ofbiz_url_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
        out = _jspx_page_context.pushBody();
        _jspx_th_ofbiz_url_0.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
        _jspx_th_ofbiz_url_0.doInitBody();
      }
      do {
        out.write("/scheduleJob");
        int evalDoAfterBody = _jspx_th_ofbiz_url_0.doAfterBody();
        if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
          break;
      } while (true);
      if (_jspx_eval_ofbiz_url_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)
        out = _jspx_page_context.popBody();
    }
    if (_jspx_th_ofbiz_url_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
      return true;
    _jspx_tagPool_ofbiz_url.reuse(_jspx_th_ofbiz_url_0);
    return false;
  }

  private boolean _jspx_meth_ofbiz_url_1(PageContext _jspx_page_context)
          throws Throwable {
    PageContext pageContext = _jspx_page_context;
    JspWriter out = _jspx_page_context.getOut();
    //  ofbiz:url
    org.ofbiz.webapp.taglib.UrlTag _jspx_th_ofbiz_url_1 = (org.ofbiz.webapp.taglib.UrlTag) _jspx_tagPool_ofbiz_url.get(org.ofbiz.webapp.taglib.UrlTag.class);
    _jspx_th_ofbiz_url_1.setPageContext(_jspx_page_context);
    _jspx_th_ofbiz_url_1.setParent(null);
    int _jspx_eval_ofbiz_url_1 = _jspx_th_ofbiz_url_1.doStartTag();
    if (_jspx_eval_ofbiz_url_1 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
      if (_jspx_eval_ofbiz_url_1 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
        out = _jspx_page_context.pushBody();
        _jspx_th_ofbiz_url_1.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
        _jspx_th_ofbiz_url_1.doInitBody();
      }
      do {
        out.write("/scheduleService");
        int evalDoAfterBody = _jspx_th_ofbiz_url_1.doAfterBody();
        if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
          break;
      } while (true);
      if (_jspx_eval_ofbiz_url_1 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)
        out = _jspx_page_context.popBody();
    }
    if (_jspx_th_ofbiz_url_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
      return true;
    _jspx_tagPool_ofbiz_url.reuse(_jspx_th_ofbiz_url_1);
    return false;
  }
}
