<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="SelectDataList.aspx.cs" Inherits="OAWeb.crm.promote.SelectDataList" %>

<%@ Register Src="../../UserControls/SMSEmailNav.ascx" TagName="SMSEmailNav" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" runat="server">
    <script src="/js/jquery.form.js" type="text/javascript"></script>
    <!--主体左侧-->
    <table id="plc_profile" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="main_left">
                <uc1:SMSEmailNav ID="SMSEmailNav1" runat="server" />
            </td>
            <td class="main_center">
                <!--主体-->
                <div class="page_main">
                    <div class="page_content">
                        <div class="form" style="border: solid 1px #ddd; padding: 5px;">
                            <table cellpadding="0" cellspacing="0" border="0" class="table_form">
                                <tr>
                                    <td class="title">
                                        <em style="float: left">
                                            <img src="/images/08.gif" />
                                        </em>
                                        <h1>
                                            创建推广计划 - 推广计划信息填写 - 目标对象数据选择</h1>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="select_category">
                                            <div class="category_main" style="background-color: #ffffff; border: #b1d2ff 1px solid;">
                                                <div class="data">
                                                    <iframe width="100%" id="main" name="main" frameborder="0" src="DataList.aspx?datatype=<%=HidDataType.Value %>&method=<%=hidMethod.Value %>">
                                                    </iframe>
                                                    <div style="text-align: center; border-top: #b1d2ff 1px solid; padding-top: 10px;"
                                                        id="op_select">
                                                        <asp:CheckBox ID="chkSendSet" runat="server" Text="生成后是否立即发送" />
                                                        <input id="btnAddAll" type="button" value="生成所有" class="btn_77px" />
                                                        <input id="btnAddSelect" type="button" value="生成已选" class="btn_77px" />
                                                        <asp:HiddenField ID="hidSelectIds" runat="server" />
                                                        <asp:HiddenField ID="HidDataType" runat="server" />
                                                        <asp:HiddenField ID="hidFromFilter" runat="server" />
                                                        <asp:HiddenField ID="hidMethod" runat="server" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#main").load(function () {
                var mainheight = $(this).contents().find("body").height() + 5;
                if (mainheight < 300) mainheight = 300;
                $(this).height(mainheight);
                $(".category_main").height(mainheight + $("#op_select").height() + 20);
            });
            $("#btnAddAll").click(function () {
                if (SelectAll()) {
                    CreateZhezao($(".data"), "zhezhao");
                    FormPostAjax("/crm/promote/SelectDataList.aspx?op=Save&savetype=all&Id=<%=Id %>", "ok",
                    function () { window.location.href = 'PromoteList.aspx'; },
                    function () { $("#zhezhao").remove(); });
                }
            });
            $("#btnAddSelect").click(function () {
                if (SelectChecked()) {
                    CreateZhezao($(".data"), "zhezhao");
                    FormPostAjax("/crm/promote/SelectDataList.aspx?op=Save&savetype=select&Id=<%=Id %>", "ok",
                    function () { window.location.href = 'PromoteList.aspx'; },
                    function () { $("#zhezhao").remove(); });
                }
            });
        });
        function SelectChecked() {
            var hidId = $("#<%=hidSelectIds.ClientID %>"); 
            if (hidId.val() == null || hidId.val() == "") {
                alert("请选择要生成计划的数据");
                return false;
            }
            return true;
        }
        function SelectAll() {
            if ($("#<%=hidFromFilter.ClientID %>").val() == "") {
                alert("请查找出要生成计划的数据");
                return false;
            }
            var l = $(window.frames["main"].document).find('body').find('input[name="chkItem"]').length; 
            if (l == 0) {
                alert("请查找出要生成计划的数据");
                return false;
            } 
            $("#<%=hidSelectIds.ClientID %>").val("");
            return true;
        }
    </script>
</asp:Content>
