<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddBookOccur.aspx.cs" Inherits="Book.Book.AddBookOccur" %>
<!DOCTYPE HTML>
<html >
<head runat="server">
    <title>设定重复周期</title> 
  

    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="../Javascript/jquery-1.9.1.min.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>  
    <script src="../Javascript/datepick/moment.min.js"></script>
    <link href="style/book.css" rel="stylesheet" />
    <link href="../Style/patch.css" rel="stylesheet" />
    <script src="../javascript/laydate/laydate.dev.js"></script>
 

    <style>
          label {
         font-weight:normal;
        }
        .monthday {
         margin-top:10px;}

        .monthday label {
         display:inline-block; width:48px;
        }
        label {
         font-weight:bold;
        }
   
      #repeat { width: 128px;  
      } 

     
    </style>

    
</head>
<body style="margin:20px; color:#1970c0; font-weight:bold;">
    <form id="form1" runat="server">
    

   <table class="table">
   
       
    <tr style="display:none">
            <td>主题:</td>
            <td><asp:TextBox ID="TextBoxName" runat="server" Width="400px"></asp:TextBox></td>
    </tr>

     <tr style="display:none">
            <td >Begin:</td>
            <td><asp:TextBox ID="TextBoxStart" runat="server"  Width="500px" CssClass=" form-control flat bdc"></asp:TextBox></td>
     </tr>
     <tr style="display:none">
            <td>End:</td>
            <td><asp:TextBox ID="TextBoxEnd" runat="server" Width="500px"  CssClass=" form-control flat bdc"></asp:TextBox></td>
      </tr>



<tr>
    <td style="width:200px">
        <input type="radio"  value="none" checked="checked" id="rbl_none"  name="rpt"/>
       <%=iseng?"No Repeat":"无需重复" %>

    </td>

    <td onclick=" $('#rbl_none').click() ">
        <div id="select_norepeat" style="display:none"></div>
    </td>
</tr>


<tr>
    <td>
        <input type="radio"  value="daily" name="rpt" id="rbl_daily"    />
        
         <%=iseng?"Daily":"按天" %> 
    </td>

    <td onclick=" $('#rbl_daily').click() ">

        <div id="select_daily">
    <%=iseng?"Repeat every":"重复每" %>        <input id="daily_every" style="width:50px; border:0px; border-bottom:solid 1px #666; text-align:center" value="1" />  <%=iseng?"days":"天" %>.
            </div>
    </td>
</tr>



<tr>
    <td>
       <input type="radio"  value="weekly"  id="rbl_weekly"     name="rpt"/> 
        <%=iseng?"Weekly":"按周" %>

    </td>

    <td  onclick=" $('#rbl_weekly').click() ">
        <div id="select_weekly"  >
        <%=iseng?"Repeat every":"重复每" %>   <input id="weekly_every"  style="width:50px; border:0px; border-bottom:solid 1px #666; text-align:center" value="1" />  <%=iseng?"weeks":"周" %> .

   <div class="monthday">
    
    <label><input type="checkbox" id="weekly_0" /><span id="weekly_span_0"> <%=iseng?"Sun":"周日" %></span></label> 
    <label><input type="checkbox" id="weekly_1" /><span id="weekly_span_1"> <%=iseng?"Mon":"周一" %></span></label> 
    <label><input type="checkbox" id="weekly_2" /><span id="weekly_span_2"> <%=iseng?"Tue":"周二" %></span></label>
    <label><input type="checkbox" id="weekly_3" /><span id="weekly_span_3"> <%=iseng?"Wed":"周三" %></span></label> 
    <label><input type="checkbox" id="weekly_4" /><span id="weekly_span_4"> <%=iseng?"Thu":"周四" %></span></label>
    <label><input type="checkbox" id="weekly_5" /><span id="weekly_span_5"> <%=iseng?"Fri":"周五" %></span></label> 
    <label><input type="checkbox" id="weekly_6" /><span id="weekly_span_6"> <%=iseng?"Sat":"周六" %></span></label>
 
   </div> 
    
    </div>
    </td>
</tr>



<tr>
    <td> <input type="radio"  value="monthly"   id="rbl_monthly"   name="rpt"/>
        
            <%=iseng?"Monthly":"按月" %>   
         
         
    </td>

    <td onclick=" $('#rbl_monthly').click() ">
        <div id="select_monthly"  >
          <%=iseng?"Repeat every":"重复每" %> <input id="monthly_every"  style="width:50px; border:0px; border-bottom:solid 1px #666; text-align:center"  value="1"/>  <%=iseng?"months":"月" %> .
<div class="monthday">
<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>

    </td>
</tr>




<tr>
    <td>
<input type="radio"  value="annually"   id="rbl_annually"  name="rpt"/> 
          <%=iseng?"Annually":"按年" %>   
        
    </td>
    <td  onclick=" $('#rbl_annually').click() ">

        <div id="select_annually" >
           <%=iseng?"Repleat every year":"重复每年" %>  
       </div>
       
    </td>
</tr>

<tr>
    <td>
  &nbsp;&nbsp;&nbsp;&nbsp;   <%=iseng?"Repeat Range":"重复范围" %>  
</td>

<td>
         <div id="range" >
 
<label for="repeat_indefinitely"><input type="radio" name="repeat_range" id="repeat_indefinitely" /> <%=iseng?" Repeat indefinitely":"无结束日期" %>   </label><br />
<label for="repeat_until"><input type="radio" name="repeat_range" id="repeat_until" /><%=iseng?" Repeat until":"结束日期" %>   </label> <input id="repeat_until_value" onclick="laydate();"   style="width:150px; border:0px; border-bottom:solid 1px #666; text-align:center" class="_dt" value="<%=nextyear %>" /><br />
<label for="repeat_times"><input type="radio" name="repeat_range" id="repeat_times" /><%=iseng?" Repeat":"重复" %>   </label> <input id="repeat_times_value"  style="width:50px; border:0px; border-bottom:solid 1px #666; text-align:center" value="10" /> <%=iseng?" times":"次结束" %> <br />
</div>

</td>
    </tr>

  

        </table>

 


<span style="display:none">
    <select id="repeat"    >
            <option value="norepeat">No Repeat</option>
            <option value="daily">Daily</option>
            <option value="weekly">Weekly</option>
            <option value="monthly">Month</option>
            <option value="annually">Annually</option>
     </select>
   
   <input type="text" id="tip"  name="tip" value="<%=iseng?"No Repeat":"无需重复" %>   "/>

 </span>



   <script src="../Javascript/addbookoccur.js"></script>
 

     

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

     

    function setrepeat()
    {
        
        v=$("input[type=radio]:checked").val();
        
        $("#repeat").val(v);


        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=="none")
        {
            _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>

<!-- Recurrence section ends here -->

    <div class="text-center">

        <asp:HiddenField ID="Recurrence" runat="server" />

       

        <asp:Button ID="ButtonSave"  
              
             runat="server" CssClass="btn btn-primary btn-sm btn-flat" 
             Text="提交" OnClick="ButtonSave_Click" />

         <asp:Button ID="ButtonDel"  CssClass="btn btn-danger btn-sm btn-flat"  Visible="false" runat="server" Text="删除整个系列" OnClick="DelSave_Click" />

  </div>
    

    <asp:HiddenField ID="hf_roomid" runat="server" />
 
        
    </form>
</body>
</html>
