<%@ page language="C#" autoeventwireup="true" inherits="sysadmin_EquipmentCreate, App_Web_equipmentcreate.aspx.a929186b" enableEventValidation="false" %>

<%@ Register Src="~/sadmin/NewHeader.ascx" TagPrefix="uc1" TagName="NewHeader" %>
<%@ Register Src="~/sadmin/NewFooter.ascx" TagPrefix="uc1" TagName="NewFooter" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>网上预约系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link href="/control/plugin/bootstrap3/css/bootstrap.min.css" rel="stylesheet" />
    <script src="/control/js/jquery.js"></script>
    <script src="/control/plugin/bootstrap3/js/bootstrap.min.js"></script>
    <!-- ionicons -->
    <link href="/lib/ionicons/ionicons.min.css" rel="stylesheet" />
    <!-- Animate -->
    <link href="/lib/animate/animate.min.css" rel="stylesheet" />
    <!-- base -->
    <link href="/css/base.css" rel="stylesheet" />

   <script src="/control/plugin/My97DatePicker/WdatePicker.js"></script>
    <!--[if lt IE 9]>
      <script src="/js/html5shiv.min.js"></script>
      <script src="/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="wrapper">
        <uc1:NewHeader runat="server" ID="NewHeader" />
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <form runat="server" id="form">
                        <h3 class="page-header">新增预约设备<small> 新增预约设备，可以是人或物、区域</small></h3>
                        <div class="panel panel-default">
                            <div class="panel-body">
                                <!-- Add.aspx -->

                                <div class="form-group">
                                    <label class=" control-label">预约设备名称</label>
                                    <div class="">
                                        <asp:TextBox ID="txte_name" runat="server" MaxLength="50" CssClass="form-control"></asp:TextBox>

                                        <p class="help-block">
                                            <asp:RequiredFieldValidator ID="rfve_name" runat="server" ForeColor="Red" Display="Dynamic" ErrorMessage="请填写预约设备名称" ControlToValidate="txte_name"></asp:RequiredFieldValidator>
                                        </p>

                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class=" control-label">预约设备照片</label>
                                    <div class="">

                                        <asp:FileUpload ID="fuImg" runat="server" />
                                        <p class="help-block">
                                            请上传 150 * 200 的图片
                                                    <asp:RequiredFieldValidator ID="rfvimg"
                                                        runat="server" ForeColor="Red"
                                                        Display="Dynamic" ErrorMessage="请上传预约设备照片"
                                                        ControlToValidate="fuImg">
                                                    </asp:RequiredFieldValidator>

                                        </p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class=" control-label">所属管理员</label>
                                    <div>
                                        <asp:DropDownList ID="ddlSaAdmin" CssClass="form-control" runat="server"></asp:DropDownList>
                                        <p class="help-block">
                                            <asp:RequiredFieldValidator ID="rfvsaadmin" runat="server" ForeColor="Red" 
                                                Display="Dynamic" ErrorMessage="请选择" ControlToValidate="ddlSaAdmin"></asp:RequiredFieldValidator>
                                        </p>
                                    </div>
                                </div>
                                 <div class="form-group">
                                    <label class=" control-label">最短预约时间</label>
                                    <div>
                                        <asp:TextBox ID="txt_min" runat="server" TextMode="Number" placeholder="分钟数" MaxLength="255" CssClass="form-control"></asp:TextBox>
                                    </div>
                                </div>
                                 <div class="form-group">
                                    <label class=" control-label">最长预约时间</label>
                                    <div>
                                        <asp:TextBox ID="txt_max" runat="server" TextMode="Number" placeholder="分钟数" MaxLength="255" CssClass="form-control"></asp:TextBox>
                                    </div>
                                </div>
                                 <div class="form-group">
                                    <label class=" control-label">提前预约天数</label>
                                    <div>
                                        <asp:TextBox ID="txt_before2" runat="server" TextMode="Number" MaxLength="255" CssClass="form-control"></asp:TextBox>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class=" control-label">提前预约最长天数</label>
                                    <div>
                                        <asp:TextBox ID="txt_before" runat="server" TextMode="Number" MaxLength="255" CssClass="form-control"></asp:TextBox>
                                    </div>
                                </div>
                               <div class="form-group">
                                    <label class=" control-label">收费标准（元/小时）</label>
                                    <div>
                                        <asp:TextBox ID="txt_fee" runat="server" MaxLength="255" CssClass="form-control"></asp:TextBox>
                                        <p class="help-block">
                                            <asp:RegularExpressionValidator ID="revfee" runat="server" Display="Dynamic" ControlToValidate="txt_fee"
                                                 ForeColor="Red" ErrorMessage="必须是数字，小数点后最多两位" ValidationExpression="^\d+(.\d{1,2}){0,1}$"></asp:RegularExpressionValidator>
                                        </p>   
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class=" control-label">备注</label>
                                    <div class="">
                                        <asp:TextBox ID="txte_note" runat="server" TextMode="MultiLine" MaxLength="255" CssClass="form-control"></asp:TextBox>
                                        <p class="help-block">
                                            <asp:RequiredFieldValidator ID="rfve_note" runat="server" ForeColor="Red" Display="Dynamic" ErrorMessage="请填写备注" ControlToValidate="txte_note"></asp:RequiredFieldValidator>
                                        </p>
                                    </div>
                                </div>
                                 <div class="form-group">
                                    <label class=" control-label">教学日</label>
                                    <div>
                                        <button type="button" class="btn btn-default btn-min " onclick="addUseDate()"><i class="glyphicon glyphicon-plus"></i> 新增教学日</button> 
                                        <br />
                                        <input type="text" name="start" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="margin-top:8px;width:180px;display:inline"  />至
                                        <input type="text" name="end" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width:180px;display:inline" />
                                        每隔<input type="number" name="day" class="form-control" style="width:80px;display:inline" />天，
                                        <button type="button" class="btn btn-default btn-min " onclick="addUseDates()"><i class="glyphicon glyphicon-random"></i> 快速生成教学日</button>                         
                                    </div>
                                    <div id="usedate" class="row col-sm-12" style="margin-top:9px;">
                                       
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="form-group">

                                    <div class=" ">
                                        <asp:CheckBox ID="chke_allow" Text="允许预约" runat="server" Checked="False" />
                                    </div>

                                </div>

                                <div class="form-group">
                                       
                                    <asp:Button ID="btnSubmit" runat="server" Text="保存预约设备" OnClientClick="return beforeSubmit()" CssClass="btn btn-lg btn-block btn-primary" OnClick="btnSubmit_Click" />
                                    
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <uc1:NewFooter runat="server" ID="NewFooter" />
    </div>
     <script>
        Date.prototype.format = function (format) {
            var o = {
                "M+": this.getMonth() + 1, //month 
                "d+": this.getDate(),    //day 
                "h+": this.getHours(),   //hour 
                "m+": this.getMinutes(), //minute 
                "s+": this.getSeconds(), //second 
                "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter 
                "S": this.getMilliseconds() //millisecond 
            }
            if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
              (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o) if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1,
                  RegExp.$1.length == 1 ? o[k] :
                    ("00" + o[k]).substr(("" + o[k]).length));
            return format;
        }

        function addUseDate()
        {
            var sb = new StringBuilder();
            sb.append('<div class="col-sm-2" style="padding-left:0px">');
            sb.append('<div style="width:75%;float:left">');
            sb.append('<input type="text" name="date" class="form-control" onfocus=\'WdatePicker({dateFmt:"yyyy-MM-dd"})\' /></div>');
            sb.append('<a style="color:#666666;top:7px;" onclick="removeUseDate()" class="glyphicon glyphicon-remove"></a></div>');
            $("#usedate").append(sb.tostring());
        }
        function addUseDates() {
            var start = $("input[name='start']").val();
            var end = $("input[name='end']").val();
            var day = $("input[name='day']").val();
            if ((start == "" || end == "" || day == "" )&&day>0)
                return;
            var sdate=new Date(start);
            var edate = new Date(end);
            var sb = new StringBuilder();
            for(var t=sdate;t<=edate;t.setDate(t.getDate()+parseInt(day)))
            {
                sb.append('<div class="col-sm-2" style="padding-left:0px">');
                sb.append('<div style="width:75%;float:left">');
                sb.append('<input type="text" name="date" class="form-control" value="'+t.format("yyyy-MM-dd")+'" onfocus=\'WdatePicker({dateFmt:"yyyy-MM-dd"})\' /></div>');
                sb.append('<a style="color:#666666;top:7px;" onclick="removeUseDate()" class="glyphicon glyphicon-remove"></a></div>');
            }
            $("#usedate").append(sb.tostring());
        }
        function removeUseDate() {
            var event = window.event;
            var obj = event.srcElement || event.target;
            $(obj).parent().remove();
        }

        function beforeSubmit()
        {
            if (Page_ClientValidate()) {
                var inputs = $("input[name='date']");
                for (var i = 0; i < inputs.length; i++)
                {
                    if($(inputs[i]).val()=="")
                    {
                        alert("请选择日期");
                        return false;
                    }
                }
            }
            return false;
        }
    </script>
</body>
</html>
