<%@ page language="C#" autoeventwireup="true" masterpagefile="~/Member/MyShopMasterPage.master" inherits="Member_ClientRelation_RemindManage, WebApp_deploy" title="预约提醒管理" enableeventvalidation="false" %>

<asp:Content ID="contacter" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script src="../../Js/Function.js" type="text/javascript"></script>
    <script src="../../Js/My97DatePicker/config.js" type="text/javascript"></script>
    <script src="../../Js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        function pickedFunc() {
            $dp.$('<%=txtRemindTime.ClientID %>').value = $dp.cal.getNewDateStr('yyyy-MM-dd HH:mm:ss');
        }
        //开始时间
        function pickedFuncBegin() {
            $dp.$('<%=txtBeginTime.ClientID %>').value = $dp.cal.getNewDateStr('yyyy-MM-dd HH:mm:ss');
        }
        //结束时间
        function pickedFuncEnd() {
            $dp.$('<%=txtEndTime.ClientID %>').value = $dp.cal.getNewDateStr('yyyy-MM-dd HH:mm:ss');
        }
    </script>
    <script type="text/javascript">
        //切换选项卡                
        function setButtonActive(flags) {
            var _flag = parseInt(flags);
            var ulObj = document.getElementById("M1");
            for (var i = 0; i < ulObj.childNodes.length; i++) {
                ulObj.childNodes[i].className = "";
            }
            if (ulObj.childNodes.length > 2)
            { _flag = _flag * 2 + 1; }
            ulObj.childNodes[_flag].className = "active";
        }   
    </script>
    <div class="pageTitle" style="line-height: 30px; vertical-align: middle;">
        &nbsp;&nbsp;&nbsp;&nbsp;预约提醒记录管理</div>
    <div id="MainMenu">
        <div class="TabMenu">
            <!--一级导航-->
            <ul id="M1">
                <li class="active"><a href="RemindManage.aspx?TabMenu=tabMnage">
                    <asp:Label ID="lblManage" runat="server" Text="预约提醒管理" />
                </a></li>
                <li><a href="RemindManage.aspx?TabMenu=tabAdd&action=addinfo">
                    <asp:Label ID="lblAddOrEdit" runat="server" Text="添加预约提醒" />
                </a></li>
            </ul>
        </div>
        <div class="TabText">
            <%--预约提醒记录 begin--%>
            <asp:PlaceHolder ID="phManage" runat="server">
                <table class="SearchTableStyle">
                    <tr>
                        <th colspan="3" style="float: left; text-align: left">
                            &nbsp;<b>高级查询：</b>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;具体时间：
                        </td>
                        <td>
                            &nbsp;开始时间：<asp:TextBox ID="txtBeginTime" runat="server" onfocus="WdatePicker()"
                                CssClass="Wdate"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;结束时间：<asp:TextBox ID="txtEndTime" runat="server" onfocus="WdatePicker()" CssClass="Wdate"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 30%">
                            &nbsp;处理情况：
                            <asp:DropDownList ID="ddlStatus" runat="server">
                                <asp:ListItem Value="">全部</asp:ListItem>
                                <asp:ListItem Value="0">未处理</asp:ListItem>
                                <asp:ListItem Value="1">已处理</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td style="width: 30%">
                            &nbsp;客户名称：<asp:TextBox ID="txtSearchClientName" runat="server" Width="120px"></asp:TextBox>
                        </td>
                        <td style="width: 30%">
                            &nbsp;
                            <asp:Button ID="SeachBut" runat="server" Text="查询" OnClick="SeachBut_Click" />
                        </td>
                    </tr>
                    <tr>
                        <th colspan="3" style="float: left; text-align: left">
                            &nbsp;<b>快速查询：</b>
                        </th>
                    </tr>
                    <tr>
                        <td colspan="3">
                            &nbsp;预约提醒时间：
                            <asp:DropDownList ID="ddlDate" runat="server" AutoPostBack="true" OnSelectedIndexChanged="SeachBut_Click">
                                <asp:ListItem Value="">全部</asp:ListItem>
                                <asp:ListItem Value="10">十天内</asp:ListItem>
                                <asp:ListItem Value="30">一个月内</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
                <asp:GridView ID="gvManage" CssClass="tableHead" runat="server" AutoGenerateColumns="false"
                    AllowPaging="True" OnRowDataBound="gvManage_RowDataBound" OnPageIndexChanging="gvManage_PageIndexChanging"
                    PageSize="10">
                    <Columns>
                        <asp:TemplateField HeaderText="选择">
                            <ItemTemplate>
                                <input type="checkbox" id="RemindIdSelect" name="RemindIdSelect" value='<%# Eval("RemindId") %>' />
                            </ItemTemplate>
                            <HeaderTemplate>
                                <input type="checkbox" id="chkAll" onclick="SelectAllCheckboxes(this,'RemindIdSelect')" />选择
                            </HeaderTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="提醒时间" DataField="RemindTime" />
                        <asp:BoundField HeaderText="客户名称" DataField="ClientName" />
                        <asp:TemplateField HeaderText="提醒方式">
                            <ItemTemplate>
                                <asp:Image ID="imgEmail" ImageUrl="~/Images/Client/mail_gray.gif" runat="server" />
                                <asp:Image ID="imgMobile" ImageUrl="~/Images/Client/phone_gray.gif" runat="server" />
                                <%-- <img src="../../Images/Client/mail_gray.gif" id="imgEmail" runat="server" alt="邮件提醒" />
                                <img src="../../Images/Client/phone_gray.gif" id="imgMobile" runat="server" alt="手机短信提醒" />--%>
                                <asp:HiddenField ID="hfEmail" runat="server" Value='<%# Eval("RemindByEmail") %>' />
                                <asp:HiddenField ID="hfMobile" runat="server" Value='<%# Eval("RemindBySms") %>' />
                                <asp:HiddenField ID="hfTip" runat="server" Value='<%# Eval("RemindByTips") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="创建人" DataField="Creater" />
                        <asp:TemplateField HeaderText="处理情况">
                            <ItemTemplate>
                                <asp:Label ID="lblStatus" runat="server" Text='<%# GetResult(Eval("Status").ToString())%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtnCheck" CommandName="CheckInfo" CommandArgument='<%# Eval("RemindId")%>'
                                    OnCommand="Button_Command" runat="server">查看</asp:LinkButton>
                                <asp:LinkButton ID="lbtnUPStatus" CommandName="EditInfoStatus" CommandArgument='<%#Eval("RemindId")%>'
                                    OnCommand="Button_Command" runat="server">标记为已处理</asp:LinkButton>
                                <asp:LinkButton ID="lbtnUpdate" CommandName="EditInfo" CommandArgument='<%#Eval("RemindId")%>'
                                    OnCommand="Button_Command" runat="server">修改</asp:LinkButton>
                                <asp:LinkButton ID="lbtnDelete" CommandName="DelInfo" CommandArgument='<%# Eval("RemindId") %>'
                                    OnCommand="Button_Command" runat="server" OnClientClick="return confirm('确定要删除该信息吗？');">删除</asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <table class="tableHead" width="100%">
                            <tr>
                                <th>
                                    提醒时间
                                </th>
                                <th>
                                    客户名称
                                </th>
                                <th>
                                    提醒方式
                                </th>
                                <th>
                                    创建人
                                </th>
                                <th>
                                    处理情况
                                </th>
                                <th>
                                    操作
                                </th>
                            </tr>
                            <td colspan="6" style="text-align: center">
                                没有符合条件的联系人数据！
                            </td>
                        </table>
                    </EmptyDataTemplate>
                </asp:GridView>
                <div style="text-align: center;">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Literal ID="ltrPagePanel" runat="server"></asp:Literal>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                </div>
                <div>
                    &nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnMoreDelete" CommandName="MoreDelete" OnCommand="Button_Command"
                        runat="server" Text="批量删除" />
                </div>
            </asp:PlaceHolder>
            <%--预约提醒记录 end--%>
            <%--查看预约提醒 begin--%>
            <asp:PlaceHolder ID="phCheck" runat="server" Visible="false">
                <br />
                <table class="ShopOrderStyle">
                    <caption>
                        &nbsp;&nbsp;&nbsp;&nbsp;预约提醒的详细信息
                    </caption>
                    <tr>
                        <td class="OrderTitle">
                            客户名称：
                        </td>
                        <td>
                            <asp:Label ID="lblClientName" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            预约联系方式
                        </td>
                        <td>
                            <asp:Label ID="lblRelationType" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            客户方联系人：
                        </td>
                        <td>
                            <asp:Label ID="lblCorrelativeContacter" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            主动提醒方式：
                        </td>
                        <td>
                            <asp:Label ID="lblRemindFashion" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            提醒内容：
                        </td>
                        <td>
                            <asp:Label ID="lblRemindContent" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            预约创建时间：
                        </td>
                        <td>
                            <asp:Label ID="lblCreateTime" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            预约提醒时间：
                        </td>
                        <td>
                            <asp:Label ID="lblRemindTime" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            创建人：
                        </td>
                        <td>
                            <asp:Label ID="lblCreater" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            处理结果：
                        </td>
                        <td>
                            <asp:Label ID="lblResult" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center" style="text-align: center">
                            <input type="button" id="btn" onclick="history.back()" value="返回" />
                        </td>
                    </tr>
                </table>
            </asp:PlaceHolder>
            <%--查看预约提醒 begin--%>
            <%--添加/修改预约提醒 begin--%>
            <asp:PlaceHolder ID="phAddOrEdit" runat="server" Visible="false">
                <br />
                <table class="ShopOrderStyle">
                    <caption>
                        <asp:HiddenField ID="hfClientName" runat="server" />
                        <asp:HiddenField ID="hfRemindID" Value="" runat="server" />
                        <asp:HiddenField ID="hfContacterID" Value="" runat="server" />
                    </caption>
                    <tr>
                        <td class="OrderTitle">
                            客户名称：
                        </td>
                        <td>
                            <asp:TextBox ID="txtClientName" runat="server" Enabled="false"></asp:TextBox>[<a
                                onclick="javascript:void(0);" style="cursor: pointer;" id="showClient" runat="server"><span
                                    style="color: Red">选择客户名称</span></a>]<span style="color: Red">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            预约联系方式
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlRelationType" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            客户方联系人：
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlCorrelativeContacter" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            主动提醒方式：
                        </td>
                        <td>
                            <asp:CheckBox ID="ckbRemindByEmail" runat="server" Text="邮件提醒" />
                            <asp:CheckBox ID="ckbRemindBySms" runat="server" Text="手机短信提醒" />
                            <%--<asp:CheckBox ID="ckbRemindByTips" runat="server" Text="冒泡提示提醒" />--%>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            提醒内容：
                        </td>
                        <td>
                            <asp:TextBox ID="txtRemindContent" runat="server" TextMode="MultiLine" Height="120px"
                                Width="260px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="OrderTitle">
                            预约提醒时间：
                        </td>
                        <td>
                            <asp:TextBox ID="txtRemindTime" runat="server" onfocus="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss',onpicked:pickedFunc})"
                                CssClass="Wdate"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center" style="text-align: center; line-height: 40px;">
                            <asp:Button ID="btnSave" OnClick="btnSave_Click" OnClientClick="return checkPass();"
                                runat="server" Text="保存预约提醒记录" />&nbsp;&nbsp;
                            <asp:Button ID="btnBack" runat="server" Text="返回预约提醒记录管理" OnClick="btnBack_Click" />
                        </td>
                    </tr>
                </table>
            </asp:PlaceHolder>
            <%--添加/修改预约提醒 end--%>
            <br />
        </div>
    </div>
    <script type="text/javascript">        setButtonActive('<%=m_flag %>');</script>
    <script type="text/javascript">
        //客户名称
        function checkKehu() {
            var kehu = $("#<%=txtClientName.ClientID %>"); //客户名称
            if (kehu.val().length == 0) {
                alert("请选择客户名称!");
                return false;
            }
            var kehuhf = $("#<%=hfClientName.ClientID %>"); //客户名称
            kehuhf.attr("value", kehu.val());
            getContValue(); //联系人
            return true;
        }
        //预约提醒时间
        function checkRemindtime() {
            var remindtime = $("#<%=txtRemindTime.ClientID %>"); //预约提醒时间
            if (remindtime.val().length == 0) {
                alert("预约提醒时间不能为空!");
                remindtime.focus();
                return false;
            }
            return true;
        }
        function checkPass() {
            if (checkKehu() && checkRemindtime()) {
                return true;
            } else {
                return false;
            }
        }
    </script>
    <script type="text/javascript">
        //选择客户名称
        function SelectKehu(kh) {
            var arr = showModalDialog('ClientList.aspx?TypeSelectClientName=clientname&ClientOwner=' +<%= user.UserID %> + '&DefaultValue=' + document.getElementById(kh).value, '', 'dialogWidth:600px; dialogHeight:450px; help: no; scroll: yes; status: no');
            if (arr != null) {
                var temparray = arr.split('|');
                if (temparray != null && temparray.length > 2) {
                    document.getElementById(kh).value = temparray[0];//客户名称
                     //客户名称、客户类型、客户ID
                    GetContact(temparray[0],temparray[1],temparray[2]); //选择客户添加对应的联系人
                }
            }
        }
        //选择客户添加对应的联系人
        function GetContact(kehuName,clienttype,kehuid) {
            var objSelect = document.getElementById("<%=ddlCorrelativeContacter.ClientID %>");
            objSelect.options.length = 0; //清空下拉列表值
            $.post("../../WebService/ClientService.ashx", { 'Action': 'GetContacter', 'ClientName': kehuName }, function (data, state) {
                if (state == "success") {
                    if (data.toString() != "") {
                        var d = eval(data);
                        $.each(d.table1, function (i) {
                            var strName = d.table1[i].TrueName; //文本值
                            var strValue = d.table1[i].ContacterID; //Value值
                            var objOption = new Option(strName, strValue); // 建立Option对象
                            if ($('#<%=hfContacterID.ClientID %>').val() == strValue) {
                                objOption.selected = 'selected';
                            }
                            objSelect.options.add(objOption);
                        });
                    }else{
                        alert("该客户的联系人不存在，请添加该客户的联系人！");
                        if (clienttype=="ClientType_qy") {
                            window.location.href = "ContacterManage.aspx?TabMenu=tabAdd&action=addinfo&clientname=" + kehuName;
                        }else if(clienttype=="ClientType_gr"){
                            window.location.href = "ClientManage.aspx?TabMenu=Addpsn&action=editinfo&clientID=" + kehuid;
                        }
                        return;
                    }
                }
            });
        }

        //联系人
        function getContValue() {
            var ID = $("#<%=hfContacterID.ClientID %>"); //联系人ID
            var objSelect = document.getElementById("<%=ddlCorrelativeContacter.ClientID %>");
            for (var i = 0; i < objSelect.options.length; i++) {
                if (objSelect[i].selected == true) {
                    ID.attr("value", objSelect[i].value);
                }
            }
        }
        $(function () {
            //修改：ActionTab == "editinfo"
            var editac = "<%=ActionTab %>";
            if (editac == "editinfo") {
                var kehuhf = $("#<%=hfClientName.ClientID %>"); //客户名称
                GetContact(kehuhf.val()); //选择客户添加对应的联系人
            }
        });
    </script>
</asp:Content>
