<%@ Page Language="C#" AutoEventWireup="true"  Inherits="Book.Book.AddBookOccur" %>
 <!DOCTYPE html>
 <html>
<head runat="server">
    <title>添加循环规则</title>
    <link href="../bootstrap/css/bootstrap.css" rel="stylesheet" />
    <script src="../javascript/jquery-1.9.1.min.js"></script>
    <script src="../bootstrap/js/bootstrap.js"></script>
    <script src="../javascript/datepick/moment.min.js"></script>
  

      <style>
        .form-control,.btn{ border-radius:0px; }
        #select_weekly label{  width:48px; display:inline-block; }
        #select_monthly label{ width:48px; display:inline-block; }
        label {font-weight:bold;}  
    </style>



</head>
<body style="margin:20px; font-size:13px; line-height:30px;">
    <form id="form1" runat="server">
          <asp:TextBox runat="server" ID="TextBoxName" Visible="false"></asp:TextBox>

    <div>
       
     
      <script src="js/recurrence.add.js"></script>

        重复:
        <select id="repeat" class="form-control">
            <option value="norepeat">无需重复</option>
            <option value="daily">按天</option>
            <option value="weekly">按周</option>
            <option value="monthly">按月</option>
            <option value="annually">按年</option>
        </select>

     <div style="height:20px;"></div>

<div id="select_norepeat" style="display:none">
</div>

<div id="select_daily" style="display:none">
重复每 <input id="daily_every" style="width:80px; display:inline-block" class="form-control" value="1" /> 天.
</div>

<div id="select_weekly" style="display:none">
重复每 <input id="weekly_every" style="width:80px; display:inline-block" class="form-control" value="1" /> 周.
<div style="height:20px;"></div>
<label for="weekly_0"><input type="checkbox" id="weekly_0" /><span id="weekly_span_0">周日</span></label>
<label for="weekly_1"><input type="checkbox" id="weekly_1" /><span id="weekly_span_1">周一</span></label>
<label for="weekly_2"><input type="checkbox" id="weekly_2" /><span id="weekly_span_2">周二</span></label>
 <label for="weekly_3"><input type="checkbox" id="weekly_3" /><span id="weekly_span_3">周三</span></label> 
<label for="weekly_4"><input type="checkbox" id="weekly_4" /><span id="weekly_span_4">周四</span></label>
<label for="weekly_5"><input type="checkbox" id="weekly_5" /><span id="weekly_span_5">周五</span></label>
<label for="weekly_6"><input type="checkbox" id="weekly_6" /><span id="weekly_span_6">周六</span></label>
     
</div>

<div id="select_monthly" style="display:none">
重复每 <input id="monthly_every" style="width:80px; display:inline-block" class="form-control"  value="1"/> 月.
<div style="height:20px;"></div>
<label for="monthly_1"><input type="checkbox" id="monthly_1" />1</label>
<label for="monthly_2"><input type="checkbox" id="monthly_2" />2</label>
<label for="monthly_3"><input type="checkbox" id="monthly_3" />3</label>
<label for="monthly_4"><input type="checkbox" id="monthly_4" />4</label>
<label for="monthly_5"><input type="checkbox" id="monthly_5" />5</label>
<label for="monthly_6"><input type="checkbox" id="monthly_6" />6</label>
<label for="monthly_7"><input type="checkbox" id="monthly_7" />7</label>
<label for="monthly_8"><input type="checkbox" id="monthly_8" />8</label>
<label for="monthly_9"><input type="checkbox" id="monthly_9" />9</label>
<label for="monthly_10"><input type="checkbox" id="monthly_10" />10</label>
<label for="monthly_11"><input type="checkbox" id="monthly_11" />11</label>
<label for="monthly_12"><input type="checkbox" id="monthly_12" />12</label>
<label for="monthly_13"><input type="checkbox" id="monthly_13" />13</label>
<label for="monthly_14"><input type="checkbox" id="monthly_14" />14</label>
<label for="monthly_15"><input type="checkbox" id="monthly_15" />15</label>
<label for="monthly_16"><input type="checkbox" id="monthly_16" />16</label>
<label for="monthly_17"><input type="checkbox" id="monthly_17" />17</label>
<label for="monthly_18"><input type="checkbox" id="monthly_18" />18</label>
<label for="monthly_19"><input type="checkbox" id="monthly_19" />19</label>
<label for="monthly_20"><input type="checkbox" id="monthly_20" />20</label>
<label for="monthly_21"><input type="checkbox" id="monthly_21" />21</label>
<label for="monthly_22"><input type="checkbox" id="monthly_22" />22</label>
<label for="monthly_23"><input type="checkbox" id="monthly_23" />23</label>
<label for="monthly_24"><input type="checkbox" id="monthly_24" />24</label>
<label for="monthly_25"><input type="checkbox" id="monthly_25" />25</label>
<label for="monthly_26"><input type="checkbox" id="monthly_26" />26</label>
<label for="monthly_27"><input type="checkbox" id="monthly_27" />27</label>
<label for="monthly_28"><input type="checkbox" id="monthly_28" />28</label>
<label for="monthly_29"><input type="checkbox" id="monthly_29" />29</label>
<label for="monthly_30"><input type="checkbox" id="monthly_30" />30</label>
<label for="monthly_31"><input type="checkbox" id="monthly_31" />31</label>
</div>

<div id="select_annually" style="display:none">
</div>



<div id="range" style="display:none">
<div style="border-bottom:2px dotted #d0d0d0; margin-top:10px; margin-bottom: 10px;"></div>
<label for="repeat_indefinitely"><input type="radio" name="repeat_range" id="repeat_indefinitely" />无结束日期</label><br />
<label for="repeat_until"><input type="radio" name="repeat_range" id="repeat_until" />重复直到: </label><input id="repeat_until_value" style="width: 150px; display:inline-block " class="form-control" value="<%=nextyear %>" /><br />
<label for="repeat_times"><input type="radio" checked="checked" name="repeat_range" id="repeat_times" />重复 </label><input id="repeat_times_value" style="width:80px; display:inline-block" class="form-control" value="10" /> <label>次</label><br />
</div>

     
 
<!-- Recurrence section ends here -->

    <div style="margin-top:10px; text-align:center ">
        <asp:HiddenField ID="Recurrence" runat="server" />
        <asp:Button ID="ButtonSave" runat="server" Text="保存" CommandArgument="mobile" CssClass="btn btn-primary" OnClick="ButtonSave_Click" />
        <input type="button" value="取消" class="btn btn-danger" onclick="parent.document.getElementById('popWinClose').click();" />

    </div>
    </div>






   <input type="text" id="tip"  name="tip" style="display:none" value="无需重复"/>

         

 

      <script>  


          var r = new DayPilot.Recurrence();
          r.saveButtonId = "ButtonSave";
          r.jsonHiddenId = "Recurrence";
          r.config = <%= RecurrenceJson %>;
          r.Init();



    function setrepeat()
    {
        
        v=$("#repeat").val();
         
        

        var _until="";
          
        if ($("#repeat_indefinitely").prop("checked")) {
            _until ='<%=iseng?"Indefinitely":"无结束日期" %>'; 
        }

        if ($("#repeat_until").prop("checked")) {
            
            _until ='<%=iseng?"Until":"结束日期" %> ' +$("#repeat_until_value").val();
        }

        if ($("#repeat_times").prop("checked")) {            
            _until=' <%=iseng?"Repeat":"重复" %> ' + $("#repeat_times_value").val()+" <%=iseng?"times":"次" %>";
        }

         


        var _tip=$("#tip");
        if(v=="norepeat")
        {
            _tip.val('<%=iseng?"No Repeat":"无需重复" %>');
            return true;
        }




        if(v=="daily")
        { 
            _tip.val('<%=iseng?"Repeat every":"重复每" %> '+$("#daily_every").val()+' <%=iseng?"days":"天" %>,' +_until);
            return true;
        }



        if(v=="weekly")
        {
        
            var txt="";


            for(var i = 0; i < 7; i++) {
                if ($("#weekly_" + i).prop("checked")) {                    
                    txt+=$("#weekly_span_"+i).html()+" ";
                }
            }

            if(txt=="")
            {
                alert('<%=iseng?"Please select repeat week":"请选择周重复日期" %>');
                return false;
            }
             

            _tip.val("<%=iseng?"Repeat Every":"重复每" %>  "+$("#weekly_every").val()+" <%=iseng?"Weeks Every":"周" %> . <%=iseng?"On":"在" %>  "+txt +","+_until);
            return true;
        
        }









        if(v=="monthly")
        {
        
            var txt="";


            for(var i = 1; i < 31; i++) {
                if ($("#monthly_" + i).prop("checked")) {                    
                    txt+= i+"  ";
                }
            }

            if(txt=="")
            {
                alert('<%=iseng?"Please select repleat day Every":"请选择月重复的日期" %> ' );
                return false;
            }

            _tip.val(" <%=iseng?"Repeat Every":"重复每" %> "+$("#monthly_every").val()+" <%=iseng?"Months":"月" %> . <%=iseng?"On":"在" %> "+txt +","+_until);
            return true;
        
        }





        
        if(v=="annually")
        {
         
            _tip.val("  <%=iseng?"Repeat Every Year":"重复每年" %>  , " +_until);
            return true;
        
        }


        return true;





    }
</script>

    </form>
</body>
</html>