
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="java.util.Vector" %>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    Vector v_roles=null;
    String action = pub.trimNull(request.getParameter("action"));
    String id = pub.trimNull(request.getParameter("id"));
    Hashtable ht = new Hashtable();
    StringBuffer sql = new StringBuffer();
    String add_user = pub.trimNull((String) session.getAttribute("session_login_id"));
    if ("".equals(add_user)) {
        System.out.println("当前没有用户信息");
    }
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        if("update".equals(action)){
            sql.append("select h_id,name,h_day,min(day) as b_time,max(day) as e_time from zb_holiday where h_id=?");
            v_list = cf.doQuery(conn, sql.toString(), null, new Object[]{id});
        }
        if (v_list!=null&&v_list.size() > 0) {
            ht = (Hashtable) v_list.get(0);
        }
    } catch (Exception e) {
        out.println("查询用户信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>
<style>
    .input-three {
        width: 22%
    }
    .input-two {
        width: 32%
    }
    .col-sm-2{
        width:34%;
    }
    .col-sm-3{
        width:34%;
    }
    .input-text{

    }
    .btn-red{ background-color:red;border: red}
    .btn-green{ background-color:green;border: green}


</style>
<div class="">
    <form class="form form-horizontal" id="form-admin-add">
        <input type="hidden" value="<%=action%>" name="action" id="action">
        <input type="hidden" value="<%=id%>" name="id" id="id">
        <div class="cl pd-5  bk-gray divOverflow" style="overflow:hidden;margin-bottom: 20px;">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">假日名称：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="text" name="name" id="name"  value="<%=pub.trimNull((String)ht.get("name"))%>" class="input-text ">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>日期&nbsp;：
                </label>
                <div class="formControls col-xs-4 col-sm-4">
                    <input type="text" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="h_day" id="h_day" value="<%=pub.trimNull((String)ht.get("h_day"))%>" >
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>休息日&nbsp;：
                </label>
                <div class="formControls col-xs-4 col-sm-4">
                    <input type="text" style="width: 47%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="b_time" id="b_time" value="<%=pub.trimNull((String)ht.get("b_time"))%>" >
                   - <input type="text" style="width: 48%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="e_time" id="e_time" value="<%=pub.trimNull((String)ht.get("e_time"))%>" >
                </div>
            </div>
        </div>
    </form>
</div>
<div class="cl mb-10  bk-gray " style="height: 50px;">
    <div class="col-sm-3 pd-10" style="width:100%;text-align: center;">
        <input class="btn btn-primary radius btn-green" type="button" onclick="javascript:saveForm();" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
    </div>
</div>
<script src="<%=request.getContextPath()%>/js/Convert_Pinyin.js"></script>
<script>
    function viewDeptOrUserInfo(title, url, w, h) {
        location.href=url;
    }
    function saveForm() {
        if($("#user_name").val()==''){
            layer.alert("用户名称不能为空",{icon:5,title:"提示"});
            return false;
        }
        $.ajax({
            type: "POST",
            url: "./action.jsp",
            data: $('#form-admin-add').serialize(),
            success: function (msg) {
                if (msg.indexOf("success") >= 0) {
                    var user_id=msg.substring(msg.indexOf(",")+1,msg.length);
                    layer.msg('操作成功!', {icon: 1, time: 1000},
                        function () {
                            parent.searchModel();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                } else {
                    layer.msg('操作失败', {
                        icon: 5,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                    });
                }
            }
        });
    }
</script>