<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    Vector v_list_day = null;
    String login_id = (String) session.getAttribute("session_login_id");
    if ("".equals(login_id)) {
        System.out.println("当前没有用户信息");
    }
    String mx_id = pub.trimNull(request.getParameter("mx_id"));
    String Mxday = pub.trimNull(request.getParameter("day"));
    int divCount=8;
    if(!"".equals(Mxday)){
        divCount=Integer.parseInt(Mxday);
    }
    String divWidth=(divCount+2)*140-80+"px";
    StringBuffer sql = new StringBuffer();
    StringBuffer sql_day = new StringBuffer();
    sql.append("select * from zb_type where mx_id=? order by order_num asc ");
    sql_day.append("select * from zb_mx_day where mx_id=? and zb_type=? order by day asc ");
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        v_list = cf.doQuery(conn, sql.toString(), null, new Object[]{mx_id});
        if (v_list != null && v_list.size()>0) {
        }

%>
<div style="border: solid 1px #eee;margin-top: 20px;height:550px;width:1100px;overflow: auto;">
    <%
       for(int i=0;i<v_list.size();i++){
           Hashtable ht = (Hashtable) v_list.get(i);
           String id=pub.trimNull((String)ht.get("id"));
           String zb_type=pub.trimNull((String)ht.get("zb_type"));
           String b_time=pub.trimNull((String)ht.get("b_time"));
           String e_time=pub.trimNull((String)ht.get("e_time"));
           v_list_day = cf.doQuery(conn, sql_day.toString(), null, new Object[]{mx_id,id});
    %>
    <%
        if(i==0){%>
        <div  style="width:<%=divWidth%>;height:40px;float:left;white-space: nowrap;">
            <div style="width:140px;height:40px;float:left;border:0.5px solid #000;">
            </div>
            <%
                if(v_list_day!=null && v_list_day.size()>0){
                for(int n=0;n<v_list_day.size();n++){
                    Hashtable ht1 = (Hashtable) v_list_day.get(n);
                    String day=pub.trimNull((String)ht1.get("day"));
            %>

            <div style="width:140px;height:40px;line-height:40px;text-align:center;color:#fff;float:left;border:0.5px solid #000;background-color: #00b7ee">
                <%=day%>
            </div>
            <% }}%>
         </div>
    <%}%>

    <div  style="width:<%=divWidth%>;height:160px;float:left;">
        <div style="width:140px;height:160px;float:left;border:0.5px solid #000;text-align: center;line-height: 120px;">
            <p style="height:30px;"> <%=zb_type%></p>
            <p style="height:30px;">(<%=b_time%>-<%=e_time%>)</p>
        </div>
        <%
            if(v_list_day!=null && v_list_day.size()>0){
            for(int n=0;n<v_list_day.size();n++){
                Hashtable ht1 = (Hashtable) v_list_day.get(n);
                String day_id=pub.trimNull((String)ht1.get("id"));
                String user_name=pub.trimNull((String)ht1.get("user_name"));
                user_name=user_name.replace(",","</br>");
        %>
        <div style="text-align:center;width:140px;height:160px;float:left;border:0.5px solid #000;position: relative">
            <p style="height:10px;display:none;">
                <%=user_name%>
            </p>
            <button class="btn btn-success" onclick="editUser('<%=day_id%>','<%=mx_id%>');" style="display:none;text-align:center;position:absolute; right:0; bottom:0;">
                修改</button>
        </div>
        <%}}%>
    </div>
    <%}%>
</div>
<script type="text/javascript">
    function deleteUser(user_id){
      layer.confirm('确认要删除吗？', function (index) {
			$.ajax({
				type: "POST",
				url: "./action.jsp?user_id="+user_id+"&action=delete",
				success: function (msg) {
					if (msg.indexOf("success") >= 0) {
						layer.msg('操作成功!', {icon: 1, time: 1000},
							function () {
								searchModel();
							});
					} else {
						layer.msg('操作失败', {
							icon: 5,
							time: 2000 //2秒关闭（如果不配置，默认是3秒）
						}, function () {
							// console.log("********************8")
						});
					}
				}
			});
		})
    }
    function optOrder(opt,user_id){
        $.ajax({
            type: "post",
            url: "opt_order.jsp",
            data:{"user_id":user_id,"opt":opt},
            success: function (data) {
                if (data.indexOf("success") >= 0) {
                    layer.msg('操作成功!', {icon: 1, time: 1000},
                        function () {
                            searchModel();
                        });
                } else {
                    layer.msg('操作失败，'+data, {
                        icon: 5,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        // console.log("********************8")
                    });
                }
            }
        });
    }
</script>
<%
    } catch (Exception e) {
        out.println("查询用户信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>