/*
 * Generated by the Jasper component of Apache Tomcat
 * Version: ......
 * Generated at: 2020-03-15 12:55:24 UTC
 * Note: The last modified time of this file was set to
 *       the last modified time of the source file after
 *       generation to assist with modification tracking.
 */
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
import java.sql.*;
import wiseoa.*;
import wiseoa.util.*;
import jun.db.core.*;
import jun.db.impl.*;
import java.net.*;
import org.json.*;

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

  private static final javax.servlet.jsp.JspFactory _jspxFactory =
          javax.servlet.jsp.JspFactory.getDefaultFactory();

  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

  private volatile javax.el.ExpressionFactory _el_expressionfactory;
  private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
    return _jspx_dependants;
  }

  public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
    if (_el_expressionfactory == null) {
      synchronized (this) {
        if (_el_expressionfactory == null) {
          _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
        }
      }
    }
    return _el_expressionfactory;
  }

  public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
    if (_jsp_instancemanager == null) {
      synchronized (this) {
        if (_jsp_instancemanager == null) {
          _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
        }
      }
    }
    return _jsp_instancemanager;
  }

  public void _jspInit() {
  }

  public void _jspDestroy() {
  }

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

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html;charset=UTF-8");
      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");
      out.write("\r\n");
      out.write("\r\n");
      out.write(" \r\n");


request.setCharacterEncoding("UTF-8");
FF.setResponseContentType(response);


String  s= FF.GetStringFromRequest(request,"q",""); 
String callback= FF.GetStringFromRequest(request,"callback","");
 
int showbm= FF.GetIntFromRequest(request,"showbm",1);

DBF dbf = DBF.getInstance();
Connection con = null;
try
{
	con = dbf.getConnection();
	DataStore ds=DataStoreFactory.newDataStore(con,"select news_user.name,news_user.showname , oa_mygroup.groupcode , oa_mygroup.name as groupname  from news_user  left join oa_mygroup on (news_user.groupid=oa_mygroup.id) where news_user.state=1 and (news_user.name like '%"+s+"%' or  news_user.showname like '%"+s+"%' "+ 
			" or   news_user.ssoname like '%"+s+"%'  or   news_user.name_firstchar= '"+s+"'   or   news_user.showname_firstchar= '"+s+"' ) ");
	ds.setOnceRetrieveCount(20);
	FF.log( ds.getSelect());
	FF.log( ds.getRowCount());
	
	ds.retrieve("oa=1 and freezed=0 and state=1");

	JSONObject js=new JSONObject();
	JSONArray ja=new JSONArray();
	for(int i=0;i<ds.getRowCount();i++)
	{
	 	JSONArray ja2=new JSONArray();
	 	ja2.put(ds.getString(i,"name"));
	 	ja2.put( ( ds.getString(i,"name").equals(ds.getString(i,"showname"))?"":ds.getString(i,"showname"))+ ((showbm==1)? ( "["+ ds.getString(i,"groupcode")+"]"+ ds.getString(i,"groupname")):""));
	 	
	 	ja.put(ja2);
	}
	js.put( "result",ja);
	   
	 

	String script=" var data___="+js.toString() +";\n"+callback+"(data___ );";
	//System.out.println(script);
	response.getWriter().println( script);
 
} catch (Exception e)
{
} finally
{
	dbf.ReleaseConnection(con);
}


 



      out.write(" \r\n");
      out.write(" \r\n");
      out.write(" ");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            if (response.isCommitted()) {
              out.flush();
            } else {
              out.clearBuffer();
            }
          } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
