<%@ Page Title="" Language="C#" MasterPageFile="~/whir_system/master/DialogMasterPage.master"
    AutoEventWireup="true" CodeFile="Content_Select.aspx.cs" Inherits="Whir_System_ModuleMark_Common_Content_Select" %>

<%@ Import Namespace="Whir.Language" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        $(function() {
            $("[name=_dialog] .btn-primary", parent.document)
                .click(function() {
                    var isSelect = whir.checkbox.isSelect('cb_Position');
                    if (!isSelect) {
                        TipMessage('<%="请选择".ToLang()%>');
                        return false;
                    } else {
                        var json = "[";
                        $('input[name$=cb_Position]')
                            .each(function() {
                                if ($(this).prop('checked')) {
                                    json += "{";
                                    json += "columnID : \"" + $(this).attr("columnid") + "\",";
                                    json += "columnName : \"" + $(this).attr("columnname") + "\",";
                                    json += "pID : \"" + $(this).val() + "\",";
                                    json += "title : \"" + $(this).attr("title") + "\"";
                                    json += "},";
                                }
                            });
                        json = json.substring(0, json.length - 1);
                        json += "]";
                        window.parent.addRelation(json);
                        return false; ;
                    }
                });
        });

        function clearCondition() {
            $("#Title").val("");
            $("#txtStartDate").val("");
            $("#txtEndDate").val("");
            return false;
        }
        //字符串转日期格式，strDate要转为日期格式的字符串
        function getDate(strDate) {
            var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
             function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
            return date;
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="content-wrap">
        <div class="space15"></div>
        <div class="panel">
            <div class="search">
                <table class="search_table">
                    <tr>
                        <td class="text-center"><%="标题：".ToLang()%></td>
                        <td class="text-center">
                            <input type="text" id="Title" name="Title" class="form-control" maxlength="50" />
                        </td>
                        <td class="text-center"><%="创建时间：".ToLang()%></td>
                        <td class="text-center">
                            <div class="input-group date form_datetime col-md-5" id="divStartDate">
                                <input name="txtStartDate" type="text" maxlength="30" id="txtStartDate" name="txtstartimes" class="form-control" readonly="readonly" />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-remove"></span>
                                </span>
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-time"></span>
                                </span>
                            </div>
                        </td>
                        <td class="text-center">
                            <div class="input-group date form_datetime col-md-5" id="divEndDate">
                                <input name="txtEndDate" type="text" maxlength="30" id="txtEndDate" name="txtEndDate" class="form-control" readonly="readonly" />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-remove"></span>
                                </span>
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-time"></span>
                                </span>
                            </div>
                        </td>
                        <td>&nbsp;
                            <input type="button" id="Search" name="Search" value="搜索" onclick="search()" class="btn btn-info">
                            <input type="button" class="btn btn-info" onclick="clearCondition()" value="清空">
                        </td>
                    </tr>
                   
                </table>
            </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="controller table table-bordered table-noPadding" style=" margin-top:10px">
                <tr class="trClass">
                    <th width="30">
                        &nbsp;
                    </th>
                    <th>
                        <%="所属栏目".ToLang()%>
                    </th>
                    <th>
                        <%="标题".ToLang()%>
                    </th>
                    <th width="180">
                        <%="创建时间".ToLang()%>
                    </th>
                </tr>
                <asp:Repeater ID="rptRelation" runat="server">
                    <ItemTemplate>
                        <tr>

                            <td>
                                <input type="checkbox" name="cb_Position" value='<%# Eval("Id")%>' ColumnId="<%# Eval("ColumnId") %>" ColumnName="<%# Eval("ColumnName") %>" Title="<%# Eval("Title") %>" <%# GetCbxEnabled(("Id")) %> />
                            </td>
                            <td>
                                <%# Eval("ColumnName") %><em class="list_light">[<%# Eval("ColumnId") %>]</em>
                            </td>
                            <td>
                                <asp:Literal ID="litTitle" runat="server"></asp:Literal>
                            </td>
                            <td>
                                <%# Eval("CreateDate") %>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </table>
            <div class="pages">
                <whir:WhirPager ID="AspNetPager1" runat="server" OnPageChanged="PageChanged" 
                    NumericButtonCount="5" PageSize="10"
                    UrlPaging="True" AlwaysShow="True" 
                    LayoutType="Div" CssClass="btn-group pageNumA"
                    CustomInfoClass="page_total" ShowCustomInfoSection="Left" 
                    PagingButtonsClass="btn btn-white" CurrentPageButtonClass="btn btn-primary"
                    FirstLastButtonsClass="btn btn-white first-last" PrevNextButtonsClass="btn btn-white prev-next"
                    >
                </whir:WhirPager>
            </div>
        </div>
    </div>
    <script type="text/javascript">

        $('#divStartDate').datetimepicker({ language: 'zh-CN', format: 'yyyy-mm-dd ', todayBtn: 1,  minView: 'month', maxView: 4, autoclose: 1, todayHighlight: 1, forceParse: true });

        function ValidatorUpdateDisplay(val) { }
        $('#divEndDate').datetimepicker({ language: 'zh-CN', format: 'yyyy-mm-dd ', todayBtn: 1, minView: 'month', maxView: 4, autoclose: 1, todayHighlight: 1, forceParse: true });
 
    </script>
    <script type="text/javascript">
        function search() {
            //加搜索条件
            var title = $("#Title").val();
            var startTime = $("#txtStartDate").val();
            var endTime = $("#txtEndDate").val();
            if (title == "" && startTime == "" && endTime == "") {
                whir.toastr.warning('<%="请输入搜索条件".ToLang() %>');
                return;
            } else {
                if (getDate(startTime) > getDate(endTime)) {
                    whir.toastr.warning('<%="结束时间必须大于开始时间".ToLang() %>');
                    return;
                }
            }
            var url = location.pathname + "?columnid=<%=ColumnId %>&itemid=<%=ItemId %>&exceptId=<%=ExceptId %>"; //页面地址
            
            this.location.href = url + "&ff=&title=" + title + "&starttime=" + startTime + "&endtime=" + endTime;
            return false;
        }
    </script>
</asp:Content>
