<%@ Page Language="C#" AutoEventWireup="true"  CodeBehind="RecurrentEventEdit.aspx.cs" Inherits="Calendar_RecurrentEventEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>  <%=iseng?"Set repet rule":"周期会议设定" %></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/patch.css" rel="stylesheet" />
 
     
   <style>
        select.form-control,  input.form-control {
            color:#1970c0;
        }
   </style>


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

        .monthday label {
         display:inline-block; width:48px;
        }
        label {
         font-weight:bold;
        }
    </style>

</head>
<body  style="margin:20px; color:#1970c0; font-weight:bold;">
    <form id="form1" runat="server">
   
        <div style="display:none">
        <asp:TextBox runat="server" ID="txt_needupdate"></asp:TextBox>
        <input type="text" id="tip" name="tip" />
        </div>
        <table class="table table-condensed">
        <tr>
            <td width="120px">  <%=iseng?"Subject":"主题" %>:</td>
            <td><asp:TextBox ID="TextBoxName" CssClass="form-control flat bdc " runat="server"  ></asp:TextBox></td>
        </tr>
        <tr>
            <td> <%=iseng?"Begin":"开始时间" %>:</td>
            <td><asp:TextBox ID="TextBoxStart"  CssClass="form-control flat bdc"  runat="server" ></asp:TextBox></td>
        </tr>
        <tr>
            <td> <%=iseng?"End":"结束时间" %>:</td>
            <td><asp:TextBox ID="TextBoxEnd"  CssClass="form-control flat bdc" runat="server" ></asp:TextBox></td>
        </tr>

            <tr>
                <td>
 <%=iseng?"Repeat":"重复周期" %>:
                </td>

                <td>

       <input type="radio" onclick="setrepeatevent();"  id="radio_norepeat"  class="rpt"  name="rpt" value="norepeat" /> <%=iseng?"No Repeat":"不循环" %> &nbsp;&nbsp;&nbsp;&nbsp;
       <input type="radio"   onclick="setrepeatevent();"    id="radio_daily"  class="rpt"  name="rpt" value="daily" />  <%=iseng?"Daily":"按天" %>&nbsp;&nbsp;&nbsp;&nbsp;
       <input type="radio"  onclick="setrepeatevent();"    id="radio_weekly"  class="rpt"  name="rpt" value="weekly" />  <%=iseng?"Weekly":"按周" %>&nbsp;&nbsp;&nbsp;&nbsp;
       <input type="radio"  onclick="setrepeatevent();"    id="radio_monthly"  class="rpt"  name="rpt" value="monthly" /> <%=iseng?"Monthly":"按月" %>     &nbsp;&nbsp;&nbsp;&nbsp;     
       <input type="radio"  onclick="setrepeatevent();"    id="radio_annually"  class="rpt"   name="rpt" value="annually" />  <%=iseng?"Annually":"按年" %>   &nbsp;&nbsp;&nbsp;&nbsp;       
                    
                    
                    
                    
                    
                    
                    
                    
                   
                    
                    
                    
                    
          <select id="repeat"  style="display:none">
            <option value="norepeat">不循环</option>
            <option value="daily">按天</option>
            <option value="weekly">按周</option>
            <option value="monthly">按月</option>
            <option value="annually">按年</option>
        </select>           
                    
                    
                    
                    <script>

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

                    </script>


             </td>
            </tr>
            
   </table>

     
  <div style="border-bottom:solid 1px #e0e0e0;  margin-top:-10px; margin-bottom:20px; height:1px;"></div>
 
<script src="../Javascript/recurrence.js" type="text/javascript"></script>
        
     


<div style="margin-left:120px;">

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

<div id="select_daily" style="display:none">
   <%=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>

<div id="select_weekly" style="display:none">
  <%=iseng?"Repeat every":"重复周期 每" %>  <input id="weekly_every"  style="width:50px; border:0px; border-bottom:solid 1px #666; text-align:center" value="1" /> <%=iseng?"weeks":"周" %>.
<br />



      <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>

<div id="select_monthly" style="display:none">
  <%=iseng?"Repeat every":"重复周期 每" %>  <input id="monthly_every"  style="width:50px; border:0px; border-bottom:solid 1px #666; text-align:center"  value="1" />  <%=iseng?"months":"月" %> .
<br />  




    <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>

<div id="select_annually" style="display:none">
     <%=iseng?"Repleat every year":"重复每年" %>  
</div>

<div id="range" style="display:none">
<div style="border-bottom:1px solid #e0e0e0; margin-top:5px; margin-bottom:5px;"></div>
<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"     style="width:150px; border:0px; border-bottom:solid 1px #666; text-align:center" 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" />  <%=iseng?" times":"次结束" %> 。<br />
</div>



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

//alert(r.config.type);
if(r.config.type=="disabled")
{
    $(".rpt").prop("disabled",true);
    $("#radio_norepeat").prop("checked",true);
}


if(r.config.type=="norepeat")
{
    $("#radio_norepeat").prop("checked",true);
    
}


if(r.config.type=="daily")
{
    $("#radio_daily").prop("checked",true);
    
}


if(r.config.type=="weekly")
{
    $("#radio_weekly").prop("checked",true);
    
}


    
if(r.config.type=="monthly")
{
    $("#radio_month").prop("checked",true);
    
}


       
if(r.config.type=="annually")
{
    $("#radio_annually").prop("checked",true);
    
}

















    
function setrepeat()
{
        
    v=$("input[type=radio]:checked").val();
        
  
    var _until="";
          
    if ($("#repeat_indefinitely").prop("checked")) {
        _until = "无结束日期";
    }

    if ($("#repeat_until").prop("checked")) {
            
        _until = " 结束日期 "+$("#repeat_until_value").val();
    }

    if ($("#repeat_times").prop("checked")) {            
        _until=" 重复 " + $("#repeat_times_value").val()+" 次";
    }

         


    var _tip=$("#tip");
    if(v=="norepeat")
    {
        _tip.val("无需重复");
        return true;
    }




    if(v=="daily")
    { 
        _tip.val("重复每 "+$("#daily_every").val()+" 天," +_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("请选择周重复日期");
            return false;
        }
             

        _tip.val("重复每 "+$("#weekly_every").val()+" 周. 在 "+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("请选择月重复的日期");
            return false;
        }

        _tip.val("重复每 "+$("#monthly_every").val()+" 月. 在 "+txt +","+_until);
        return true;
        
    }





        
    if(v=="annually")
    {
         
        _tip.val("重复每年, " +_until);
        return true;
        
    }


    return true;





}


</script>


</div>


 





    <div style="margin-top:10px; text-align:center">
       
        <asp:Button ID="ButtonSave" runat="server" Text="保存" CssClass="btn btn-primary flat btn-sm" OnClick="ButtonSave_Click" />

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


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