<%@ Page Title="修改预定" Language="C#" MasterPageFile="~/Book/Book.master" AutoEventWireup="true" CodeBehind="Editbook.aspx.cs" Inherits="Book.Book.Editbook" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cont_form" runat="server">

<style>
::-moz-placeholder { color: #aaa; }
::-webkit-input-placeholder { color:#aaa; }
:-ms-input-placeholder { color:#aaa; }
 </style>


        <script>

            document.body.onclick = function () {
                $("#result").hide();
            }

    </script>

    <asp:HiddenField runat="server" ID="hf_myemail" />
    <asp:HiddenField runat="server" ID="hf_guid" />

    <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">会议主题 Subject
        <span class="rr">*</span>
    </label>
      <div class="col-sm-10">
      <asp:TextBox runat="server" ID="txt_intro" ClientIDMode="Static"     CssClass="form-control"  /> 
      </div>
  </div>

    <br /> <br /> <br />
    <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">会议时间 Time 
        <span class="rr">*</span>
    </label>
      <div class="col-sm-10 form-inline" >
        <asp:TextBox type="text" id="txt_startdate" ClientIDMode="Static"   runat="server" CssClass="_dt form-control"  />
     会议开始时间（Start）
        <asp:DropDownList     ClientIDMode="Static"  runat="server" id="ddl_starttime" CssClass="form-control" ></asp:DropDownList>
  
   会议结束时间(End)：     
     <asp:DropDownList     ClientIDMode="Static"   runat="server" id="ddl_endtime"  CssClass="form-control"  ></asp:DropDownList>
       
           </div>
  </div>





        <br /> <br />


     <div class="form-group gchk">
    <label for="topic" class="col-sm-2 control-label">会议属性 Prop
     
    </label>
      <div class="col-sm-10">
      
         <asp:CheckBoxList ID="cb_other2" runat="server" RepeatDirection="Horizontal"  CssClass="serviceitem"  RepeatColumns="5"  Width="700px"    > 
    
    </asp:CheckBoxList>


      </div>
  </div>


       <br /> <br />

     <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">会议室与人数 Room
         <span class="rr">*</span>
     
    </label>
      <div class="col-sm-8">
      <div class="input-group">
      <asp:TextBox runat="server" ID="txt_room"  ClientIDMode="Static" 
           onfocus="openPop('room'); this.blur(); return false;" 
           onclick="openPop('room'); return false;"
          CssClass="form-control"  /> 

              <span class="input-group-addon">
    <a href="#"  onclick="openPop('room'); return false;">
        <i class="glyphicon glyphicon-th-large"></i>
     </a>
</span>
              </div> 
      </div>


         <div class="col-sm-2 form-inline" > 

             <!-- rr -->



             <div class="input-group">
          <span class="input-group-btn">
              <button type="button" class="btn btn-default btn-number" disabled="disabled" data-type="minus" data-field="quant[1]">
                  <span class="glyphicon glyphicon-minus"></span>
              </button>
          </span>
          <input type="text" id="numbers" name="quant[1]" class="form-control input-number" value="1" min="1" max="9999">
         
                  <span class="input-group-btn">
              <button type="button" class="btn btn-default btn-number" data-type="plus" data-field="quant[1]">
                  <span class="glyphicon glyphicon-plus"></span>
              </button>
          </span>
      </div>


             <!-- /rr -->








             </div>
  </div>

  




     
    
    

      <div style="<% =(pc_count=="0")?" display:none ":"" %> ">
    <br /><br /> 
    
     <div class="form-group">
    <label   class="col-sm-2 control-label">笔记本 Notepad
 
     
    </label>
         <div class="col-sm-10">
     <div class="input-group">
      <asp:TextBox runat="server" ID="txt_pc"  ClientIDMode="Static" 
          
          CssClass="form-control"  /> 

              <span class="input-group-addon">
    <a href="#"  onclick="openPop('pc'); return false;">
        <i class="glyphicon glyphicon-th-large"></i>
     </a>

</span>
              </div> 
      </div>

 
  </div>

  </div>


    

     <div style="<% =(projector_count=="0")?" display:none ":"" %> ">

    <br /><br />


    
     <div class="form-group">
    <label   class="col-sm-2 control-label">投影仪 Projector
        
     
    </label>
         <div class="col-sm-10">
     <div class="input-group">
      <asp:TextBox runat="server" ID="txt_projector"  ClientIDMode="Static" 
           
          CssClass="form-control"  /> 

              <span class="input-group-addon">
    <a href="#"  onclick="openPop('projector'); return false;">
        <i class="glyphicon glyphicon-th-large"></i>
     </a>

</span>
              </div> 
      </div>

 
  </div>

  </div>








     
     
       



     <br /> <br />

     
      <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">与会人员 Attendee
     
    </label>
      <div class="col-sm-10">
     
          <div class="input-append">
          <div class="input-group">
               
              
    <select id="sel_attend" multiple="multiple" style="width:100%;"  class="select2"></select> 
        <span class="input-group-addon">
    <a href="#"  onclick="openPop('attend'); return false;"><i class="glyphicon glyphicon-user"></i>

    </a> 
</span>
                    </div>






              




<!-- outlook style -->
<script>

    $("#sel_attend").select2().on("select2-opening", function (e) {
        e.preventDefault();
    });

</script>

               


               
              <style>

                  #result li {
                   list-style-type:none; line-height:30px;
                    width:200px;padding:3px;
                  }

                   #result li:hover {
                   list-style-type:none; line-height:30px; background-color:#2d6077;color:#ffffff;

                  }
              </style>
              
 
             <div style="position:absolute"> 
   <div id="result" style="display:none; position:relative; background-color:#ffffff; z-index:200;  left:-30px; top:0px;">
       <ul>
          
       </ul>
   </div>
</div>
   






              
              <script>


                  $(".select2-input").blur(
                      function () {
                          $("#result").hide();
                      }
                 );


                  $(".select2-input").keyup(
                      function () {
                          var _v = $(this).val();

                          if (_v != "") {
                              $.ajax({
                                  url: "data.aspx",
                                  data: { key: _v },
                                  cache: false,
                                  async: true,
                                  dataType: 'json',

                                  success: function (data) {

                                      $("#result ul").html("");

                                      var c = data.length;

                                      if (c == 0) {
                                          $("#result").hide();
                                      }

                                      for (var i = 0; i < c; i++) {
                                          $("#result ul").append("<li>" + data[i].text + "(" + data[i].id + ")</li>");
                                      }



                                      $("#result ul").on("click", "li", function () {

                                          var temp = $(this).html();
                                          displayname = temp;
                                          loginname = temp.split("(")[0];
                                          text = displayname;

                                          var DATA = $("#sel_attend").select2("data")
                                          DATA.push({ id: loginname, text: text });

                                          $("#sel_attend").select2("data", DATA);

                                          // var opt = new Option(text, loginname, false, false);

                                          // console.log(opt);

                                          // $('#sel_attend').add(opt);


                                          $("#result").hide();

                                      });

                                      $("#result").show();

                                  }



                              });



                          }
                          else {
                              $("#result").hide();

                          }



                      });

              </script>

 

               








<!-- /outlook style -->












              </div>


      </div>
  </div>

     <br /> <br />


     <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">会议资源 Resource
     
    </label>
      <div class="col-sm-10">
    
          <asp:CheckBoxList ID="cb_other1" runat="server" Width="90%"  CssClass="serviceitem"  RepeatColumns="5"  RepeatDirection="Horizontal"     > 
    
    </asp:CheckBoxList>
 



      </div>
  </div>

 

     <br /> <br />
     



      <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">特别需求 Special Require
     
    </label>
      <div class="col-sm-10">
      <asp:TextBox runat="server" ID="txt_specialrequire" Height="40"  TextMode="MultiLine" CssClass="form-control"  /> 
      </div>
  </div>

     <br /> <br /> 

      <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">邮件额外通知 Notice
     
    </label>
      <div class="col-sm-10">
      <asp:TextBox runat="server" ID="txt_notice"    CssClass="form-control"  /> 
      </div>
  </div>
    <br /><br />
    
      <div class="form-group">
    <label for="topic" class="col-sm-2 control-label">联系人 Contact </label>
      <div class="col-sm-10">
          
          <p class="form-control-static">
   
                 <asp:TextBox runat="server" ID="txt_contactname"  placeholder="姓名"  CssClass="noborder line" />  
              <asp:RequiredFieldValidator ID="RequiredFieldValidator1"  ControlToValidate="txt_contactname" runat="server" Display="Dynamic"  ErrorMessage="必须填写姓名"></asp:RequiredFieldValidator>
              
              
                <asp:TextBox runat="server" ID="txt_contactdept"   placeholder="部门"  CssClass="noborder line "/> 
              <asp:RequiredFieldValidator ID="RequiredFieldValidator2"  ControlToValidate="txt_contactdept" runat="server"  Display="Dynamic" ErrorMessage="必须填写部门"></asp:RequiredFieldValidator>
              
                <asp:TextBox runat="server" ID="txt_contacttel"  placeholder="电话"  CssClass="noborder line"  />  
              <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txt_contacttel" runat="server"  Display="Dynamic" ErrorMessage="必须填写电话"></asp:RequiredFieldValidator>
              
              
              
              
               <asp:TextBox runat="server" ID="txt_contactemail"   placeholder="邮件" CssClass="noborder line" />  
          </p>
      </div>
  </div>

     <br /> <br />


      <div class="form-group">
     
      <div class="col-sm-12  text-center">
          <asp:Button ID="btn_add" runat="server" Text="更 新"

              UseSubmitBehavior="false" 
               OnClientClick="if(!checkvalue()) return false; if(!Page_ClientValidate()) return false; this.value='请等待…';this.disabled=true; "
               
                
               CssClass="btn btn-primary btn-flat" OnClick="btn_add_Click" />

          
          <input   type="button"  class="btn btn-default"   onclick="window.location = 'mybook.aspx'" value="返 回"  />  
      </div>
  </div>




        <input id="hf_attend_text" name="hf_attend_text"  type="hidden" value="<%=_hf_attend_text%>" />
     <input id="hf_attend" name="hf_attend"  type="hidden"   value="<%=_hf_attend%>" />
     <input id="hf_roomid" name="hf_roomid"  type="hidden"  value="<%=_hf_roomid%>" />
        <input id="hf_roomname" name="hf_roomname" type="hidden"  value="<%=_hf_roomname%>" />
    <input id="hf_numbers" name="hf_numbers"   type="hidden"  value="<%=_hf_numbers%>" />
     <input id="hf_aid" name="hf_aid"   type="hidden" value="<%=_hf_aid%>" />




      <input id="hf_pcid" name="hf_pcid"  type="hidden"  value="<%=_hf_pcid%>" />
        <input id="hf_pcname" name="hf_pcname" type="hidden"  value="<%=_hf_pcname%>" />

      <input id="hf_projectorid" name="hf_projectorid"  type="hidden"  value="<%=_hf_projectorid%>" />
        <input id="hf_projectorname" name="hf_projectorname" type="hidden"  value="<%=_hf_projectorname%>" />

    <script>
        function openPop(types) {
            switch (types) {
                case "room":
                    url = "Pop_Room.aspx?";
                    break;

                case "pc":
                    url = "Pop_Pc.aspx?";
                    break;


                case "projector":
                    url = "Pop_Projector.aspx?";
                    break; 

                case "attend":
                    url = "Pop_Users.aspx?t=attend&";
                    break;

            }

            url += "dt=" + $("#txt_startdate").val() + "&";
            url += "starttime=" + $("#ddl_starttime").val() + "&";
            url += "endtime=" + $("#ddl_endtime").val();
            layer.open({
                type: 2,
                title: "请选择",
                shadeClose: true,
                shade: 0.8,
                area: ['900px', '580px'],
                content: url
            });
        }



      




        function setPopAttend(result) {
            var oldValue = $("#sel_attend").select2("data");
            var newValue = processArray(oldValue, result);
            $("#sel_attend").select2("data", newValue);
        }


        function setPopRoom(result) {
            var roomid = result.split('$')[0];
            var roomname = result.split('$')[1];
            var aid = result.split('$')[2];
            $("#hf_roomid").val(roomid);
            $("#hf_roomname").val(roomname);
            $("#txt_room").val(roomname);
            $("#hf_aid").val(aid);
        }



        function setPopPc(result) {
            var pcid = result.split('$')[0];
            var pcname = result.split('$')[1];

            $("#hf_pcid").val(pcid);
            $("#hf_pcname").val(pcname);
            $("#txt_pc").val(pcname);

        }


        function setPopProjector(result) {
            var projectorid = result.split('$')[0];
            var projectorname = result.split('$')[1];

            $("#hf_projectorid").val(projectorid);
            $("#hf_projectorname").val(projectorname);
            $("#txt_projector").val(projectorname);

        }


        $(document).ready(function () {

            $("#numbers").val($("#hf_numbers").val());
            $("#txt_room").val($("#hf_roomname").val());

            $("#txt_pc").val($("#hf_pcname").val());
            $("#txt_projector").val($("#hf_projectorname").val());
            
           

            var attendIds = "<%=_hf_attend%>".split(";");
            var attendTexts = "<%=_hf_attend_text%>".split(";");
            var dataAttend = [];
            for (var i = 0; i < attendIds.length; i++) {
                if (attendIds[i] != "") {
                    dataAttend.push({ id: attendIds[i], text: attendTexts[i] });
                }

            }



            


            $("#sel_attend").select2("data", dataAttend);



            $(".gchk input").change(function () {
            var ischeck = $(this).prop("checked");
            if (ischeck) {
                $(".gchk input").prop("checked", false);
                $(this).prop("checked", true);
              }
            });


        });






        function checkvalue() {

            var _mgr = getSelect($("#sel_attend").select2("data"));
           
            $("#hf_attend").val(_mgr);


            _mgr = getSelectText($("#sel_attend").select2("data"));
            $("#hf_attend_text").val(_mgr);


            $("#hf_numbers").val($("#numbers").val());

            if ($("#txt_intro").val() == "") {
                alert("请填写会议主题");
                return false;
            }


            if ($("#hf_roomid").val() == "" || $("#hf_roomid").val() == "0") {
                alert("请选择会议室");
                return false;
            }


            return true;
        }



        function processArray(arrSource, strResult) {
            strResults = strResult.split('!');
            var users = "";
            var loginname = "";
            var displayname = "";
            var text = "";

            for (var i = 0; i < strResults.length; i++) {
                if (strResults[i] != "") {
                    users = strResults[i].split('$');
                    loginname = users["1"];
                    displayname = users["2"];
                    text = displayname + "(" + loginname + ")";
                    arrSource.push({ id: loginname, text: text });
                }
            }

            return arrSource;

        }


        function getSelect(arrSource) {
            var result = "";
            for (var i = 0; i < arrSource.length; i++) {
                if (arrSource[i] != "") {
                    result += arrSource[i].id + ";";
                }
            }
            return result;
        }


        function getSelectText(arrSource) {
            var result = "";
            for (var i = 0; i < arrSource.length; i++) {
                if (arrSource[i] != "") {
                    result += arrSource[i].text + ";";
                }
            }
            return result;
        }
    </script>

    



     

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





</asp:Content>
