<%@ Page Language="C#" Debug="true" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Course.Admin_Course_CsOrderList" Codebehind="KS.CsOrderList.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.APPCode" %>

<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" runat="Server">
    <style>
        .categorynav {line-height: 25px;width: 97%;margin: 0 auto;margin-bottom: 10px;border: 1px solid #DEEFFA;background-color: #F7FBFE;padding: 5px 0px 5px 10px;height: 100%;overflow: hidden;}
        ul, li {padding: 0px;margin: 0px;}
        .categorynav li {width: 160px;float: left;}
    </style>
    <script>
        function SetDate() {
            var today = new Date();
            if ($("#showdate").is(":hidden")) {
                $("#showdate").show();
                $('#<%=TxtBeginDate.ClientID%>').val(today.getFullYear() + '-' + (today.getMonth() + 1) + '-01');
                $('#<%=TxtEndDate.ClientID%>').val(today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate());
            }
            else {
                $("#showdate").hide();
                $('#<%=TxtBeginDate.ClientID%>').val('');
                $('#<%=TxtEndDate.ClientID%>').val('');
            }
        }
        function keyWordFocus() {
            if (jQuery("#<%=this.KeyWord.ClientID %>").val() == '请输入关键字！') {
                jQuery("#<%=this.KeyWord.ClientID %>").val('');
            }
        }
        function keyWordBlur() {
            if (jQuery("#<%=this.KeyWord.ClientID %>").val() == '') {
                jQuery("#<%=this.KeyWord.ClientID %>").val('请输入关键字！');
            }
        }
    </script>
    <asp:Panel ID="ListPanel" runat="server" Width="100%">
        <div class="listedit">
            <ul>
                <input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);" /><label>全选</label>
                <asp:LinkButton ID="delclassbutton" runat="server" OnClientClick="return(GetIDS('del'));" OnClick="delclassbutton_Click" CssClass="button">删除订单</asp:LinkButton>  
            </ul>
        </div>
        <div class="content-area mt20">
            <div class="tabs_header">
                <div class="fr headOperation ">
                    <ul>
                        <li id="p1" class="fl"><asp:LinkButton ID="addclassbutton" runat="server" OnClick="addclassbutton_Click" CssClass="button">开通课程</asp:LinkButton></li>
                        <li id="p18" class="fl"><asp:LinkButton ID="ExcelBtn" runat="server" Text="本页导出Excel" OnClick="ExcelBtn_Click" CssClass="button">本页导出Excel</asp:LinkButton></li>
                        <li id="p18" class="fl"><asp:LinkButton ID="WordBtn" runat="server" Text="本页导出Word" OnClick="WordBtn_Click" CssClass="button">本页导出Word</asp:LinkButton></li>
                        <li id="p18" class="fl"><a href="KS.CsOrderExportExcel.aspx" class="button">按条件导出Excel或Word</a></li>
                    </ul>
                </div>
                <ul class="tabs">
                    <li <%=KSCMS.S("showType")==""?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx"><span>课程订单</span></a></li>
                    <li <%=KSCMS.S("showType")=="1"?" class='active'":string.Empty %>><a href="KS.CsOrderList.aspx?showType=1"><span>班级订单</span></a></li>
                    <li <%=KSCMS.S("showType")=="2"?" class='active'":string.Empty %>><a href="KS.CsOrderList.aspx?showType=2"><span>套餐订单</span></a></li>
                </ul>
            </div>
			<div class="quickSearch clearfix" style="border-bottom:0;">
                <div class="longquickSearch">
                    <div class="quickSelect">
                        <asp:DropDownList ID="DrpPaymentPlat" runat="server" style="margin-right:8px;">
                            <asp:ListItem Value="-1">-选择支付方式-</asp:ListItem>
                            <asp:ListItem Value="0"> 余额支付</asp:ListItem>
                        </asp:DropDownList>
                        <asp:DropDownList ID="DropDownList3" runat="server" style="margin-right:8px;">
                            <asp:ListItem Value="0">订单来源</asp:ListItem>
                            <asp:ListItem Value="1">PC端</asp:ListItem>
                            <asp:ListItem Value="2">手机端</asp:ListItem>
                            <asp:ListItem Value="3">微信</asp:ListItem> 
                            <asp:ListItem Value="4">APP</asp:ListItem> 
                            <asp:ListItem Value="5">小程序</asp:ListItem> 
                        </asp:DropDownList>
                        <asp:DropDownList ID="DrpSearchType" runat="server">
                            <asp:ListItem Value="1">订单编号</asp:ListItem>
                            <asp:ListItem Value="2">课程名称</asp:ListItem>
                            <asp:ListItem Value="3">购买学员</asp:ListItem>
                            <asp:ListItem Value="4">姓名</asp:ListItem>
                            <asp:ListItem Value="5">联系电话</asp:ListItem>
                        </asp:DropDownList>
                    </div>
                </div>
                <div class="longliwrap">
                    <div class="SearchBox fl">
                        <asp:TextBox onfocus="keyWordFocus();" onblur="keyWordBlur();" Style="color: #ccc" Text="请输入关键字！" CssClass="textbox" ID="KeyWord" runat="server" Width="180px"></asp:TextBox>
                        <b class="link-color" onclick="SetDate()">日期范围？</b>
                        <span id="showdate" <%if (this.TxtBeginDate.Text == ""){ %> style="display: none" <%} %>>
                            <asp:TextBox ID="TxtBeginDate" placeholder="格式：YYYY-MM-DD" Width="160px" runat="server" onclick="WdatePicker({dateFmt:&#39;yyyy-MM-dd&#39;});" CssClass="textbox Wdate"></asp:TextBox>至
                            <asp:TextBox ID="TxtEndDate" placeholder="格式：YYYY-MM-DD" Width="160px" runat="server" onclick="WdatePicker({dateFmt:&#39;yyyy-MM-dd&#39;});" CssClass="textbox Wdate"></asp:TextBox>
                        </span>
                        <asp:Button ID="Button1" runat="server" Text="搜索" CssClass="button" OnClick="Button1_Click" />
                    </div>    
                    <div class="property">
                        <div class="name button ml15">筛选</div>
                        <div class="propertyBox">
                            <ul class="clearfix">
                                <span class="screen fl">订单查看：</span>
                                <li <%=KSCMS.S("Status")=="1"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=1&showType=<%=showType%>">今日订单</a></li>
                            </ul>
                            <ul class="clearfix">
                                <span class="screen fl">付款状态：</span>
                                <li <%=KSCMS.S("Status")=="2"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=2&showType=<%=showType%>"><span>未付款</span></a></li>
                                <li <%=KSCMS.S("Status")=="3"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=3&showType=<%=showType%>"><span>已付款</span></a></li>
                                <li <%=KSCMS.S("Status")=="4"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=4&showType=<%=showType%>"><span>已结清</span></a></li>
                                <li <%=KSCMS.S("Status")=="5"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=5&showType=<%=showType%>"><span>待退款</span></a></li>
                                <li <%=KSCMS.S("Status")=="6"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=6&showType=<%=showType%>"><span>已退款</span></a></li>
                                <li <%=KSCMS.S("Status")=="13"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=13&showType=<%=showType%>"><span>已关闭</span></a></li>
                            </ul>
                            <ul class="clearfix">
                                <span class="screen fl">发货状态：</span>
                                <li <%=KSCMS.S("Status")=="7"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=7&showType=<%=showType%>"><span>待发货</span></a></li>
                                <li <%=KSCMS.S("Status")=="8"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=8&showType=<%=showType%>"><span>已发货</span></a></li>
                                <li <%=KSCMS.S("Status")=="9"?" class='active'":string.Empty %>><a href="KS.CsOrderList.Aspx?Status=9&showType=<%=showType%>"><span>已收货</span></a></li>
                            </ul>
                            <%if (showType == 0)
                             { %>
                            <ul class="clearfix">
                                <span class="screen fl">促销类型：</span>
                                <li <%=KSCMS.S("Promotion") == "0" ? " class='active'" : string.Empty %>><a href="KS.CsOrderList.Aspx?Promotion=0&showType=<%=showType%>"><span>普通订单</span></a></li>
                                <li <%=KSCMS.S("Promotion") == "1" ? " class='active'" : string.Empty %>><a href="KS.CsOrderList.Aspx?Promotion=1&showType=<%=showType%>"><span>抢购订单</span></a></li>
                                <li <%=KSCMS.S("Promotion") == "2" ? " class='active'" : string.Empty %>><a href="KS.CsOrderList.Aspx?Promotion=2&showType=<%=showType%>"><span>团购订单</span></a></li>
                                <li <%=KSCMS.S("Promotion") == "3" ? " class='active'" : string.Empty %>><a href="KS.CsOrderList.Aspx?Promotion=3&showType=<%=showType%>"><span>纯积分兑换</span></a></li>
                                <li <%=KSCMS.S("Promotion") == "4" ? " class='active'" : string.Empty %>><a href="KS.CsOrderList.Aspx?Promotion=4&showType=<%=showType%>"><span>积分+价格订单</span></a></li>
                            </ul>
                            <%} %>
                        </div>
                    </div>
                </div>
                <div style="display: <%# bool.Parse((Repeater1.Items.Count>0).ToString())?"":"none"%>" class="fr allPrice l_height36 longliwrap">
					<%if(Status != 5) {%>
                        <span class="f14 grayFont">所有合计：</span>
                        <span class="f16 redFont">¥<%=TotalPrice() %></span>
                        <span class="f14 grayFont ml30">已付：</span>
                        <span class="f16 redFont">¥<%=TotalPrice(1) %></span>
                        <span class="f14 grayFont ml30">未付：</span>
                        <span class="f16 redFont">¥<%=TotalPrice(2) %></span>
                    <%} else{%>
                        <span class="f14 grayFont ml30">退款合计：</span>
                        <span class="f16 redFont">¥<%=TotalPrice() %></span>
                    <%} %>
                </div>
            </div>
            
            <script>
                function buy_price(id) {
                    jQuery("#a" + id).toggle();
                }
                function open_order(id) {
                    jQuery("#b" + id).toggle();
                }
                function buyok(id) {
                    var p = jQuery("#price_" + id).val();

                    if (p <= 0) {
                        alert("修改价格必须大于0");
                    } else {
                        jQuery.ajax({
                            url: "?action=buyprice&id=" + id + "&p=" + p + "&math=" + Math.random(), success: function (d) {
                                if (d == "ok") {
                                    location.reload()
                                } else {
                                    alert("修改失败");
                                }
                            }
                        });
                    }
                }

                function openok(id) {
                    if (confirm("确认开通该订单")) {
                        jQuery.ajax({
                            url: "?action=kt&id=" + id + "&math=" + Math.random(), success: function (d) {

                                if (d == "ok") {

                                    location.reload();
                                }
                            }
                        });
                    }
                }
        		function closeok(id) {
                    if (confirm("确认关闭该订单")) {
                        jQuery.ajax({
                            url: "?action=close&id=" + id + "&math=" + Math.random(), success: function (d) {
                                if (d == "ok") {
                                    location.reload();
                                }
                            }
                        });
                    }
                }

                function settle(orderid) {
                    if (confirm("确认结清该订单")) {
                        jQuery.ajax({
                            url: "?action=settle&orderid=" + orderid + "&math=" + Math.random(), success: function (d) {
                                if (d == "ok") {
                                    location.reload()
                                }
                            }
                        });
                    }
                }

                var box='';
                function showOrderDetail(logdeliverid,orderid){
                    var w=800;
                    box=jQuery.dialog.open("Course/KS.CosShowDelivery.aspx?logdeliverid="+logdeliverid+"&orderid="+orderid,{ 
                        title:'查看详情记录',
                        width:w,
                        height:415,

                        cancelVal: '取消',
                        max:false,
                        min:false,
                        cancel: true /*为true等价于function(){}*/ 
                    });
                }

                function returns(id) {
                    parent.openWin("订单退款处理", "<%=KSCMS.GetInstallDir()+MyCache.GetCacheConfig(4)%>/course/KS.RetrunCourse.aspx?action=returns&id=" + id, true, 800, 490);
                }
            </script>
            <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand" OnItemDataBound="Repeater1_ItemDataBound">
                <HeaderTemplate>
                    
                </HeaderTemplate>
                <ItemTemplate>
                    <div class="oTable">
                        <ul class="oTr clearfix">
                            <li style="width:4%;"><input type="checkbox" <%# Convert.ToString(Eval("Status"))== "0" ?string.Empty: "style='display:none'"%> name="ids" id="ids" value="<%#Eval("ID") %>" /></li>
                            <li><span class="mr20 f12">下单时间：<%# Eval("InputTime") %></span><span class="ml20 mr20"></span><span class="mr20 f12">订单编号：<%#Eval("Orderid") %></span><span class="mr20 f12">支付时间：<%#Eval("paytime") %></span></li>
                            <li class="fr">
                                <span class="mr20 f12">订单来源：<%# Utils.OrderDeviceName(Utils.StrToInt(Eval("OrderDevice"))) %></span>
                                <span class="ml20 mr20 f12" style="cursor: pointer" onmousedown='parent.openWin("查看用户详情","Course/KS.CsShowUser.aspx?id=<%# Eval("id") %>",false);return false;'>
									购买学员：<%# Eval("UserName") %>
                                </span>
                                <span class="ml20 mr20 f12">  
                                    支付方式：<%#Kesion.Course.CourseOrderService.GetPayStatusType( Utils.StrToInt(Eval("paystatus")),Utils.StrToInt(Eval("PaymentPlatId").ToString()),Utils.StrToInt(Eval("id")),Eval("courseOrder").ToString())%>
                                </span>
                                <span class="ml20 mr20 f12">  
									是否开票：<%#Utils.StrToInt(Eval("IsInvoice")) ==0 ? "不需要" :(Utils.StrToInt(Eval("IsInvoice")) == 1 && Utils.StrToInt(Eval("Invoiced")) == 0) ? "未开票": "已开票" %>
                                </span>
                             <span class="ml20 mr20 f12" style="display:<%# Utils.StrToInt(Eval("orderflag"))==0?"":"none"%>">
                                    类型：<%#Kesion.Course.Course.GetCoursePromotionStr(Utils.StrToInt(Eval("OrderPromotion")),10000)%>
                                </span>
                            </li> 
                        </ul>
                        <div class="oTbody">
                         <asp:Repeater ID="Repeater2" runat="server" OnItemDataBound="Repeater2_ItemDataBound">
                         <ItemTemplate>
                        		<ul class="oTrDate clearfix">
                                    <li class="oTableCenter" style="width:4%;"></li>
                                    <li <%#Eval("orderflag").ToString()=="2"?"":"class='oTableCenter'" %> style="width:24%; text-align:left;justify-content: normal;">
                                        <img onerror="this.src='<%=MyCache.GetCacheShopConfig(9) %>';" src="<%#Eval("photourl") %>" width='90' height='60' class="fl"/>
                                        <span class="CaptionName"><a href="<%#  Kesion.APPCode.Public.GetCosUrl(Utils.StrToInt(Eval("OrderFlag")),Utils.StrToInt(Eval("OrderType")),Utils.StrToInt(Eval("CourseID")),ref cosType,Utils.StrToInt(Eval("isBundleSale")), Utils.StrToInt(Eval("bindtype"))) %>" target="_blank"><%#Eval("cname") %></a></span>
                                        <div class="Caption" <%#Eval("orderflag").ToString()=="2"?"":"style='display:none;'" %>>
                                            <asp:Repeater ID="Repeater3" runat="server" >
                                                <ItemTemplate>
                                                    <div class="kb_box">
                                                        <div style="display:none"><%# Kesion.APPCode.Public.GetBindUrl(Utils.StrToInt(Eval("BindType")),Utils.StrToInt(Eval("CourseID")),ref bindCosType) %></div>
                                                        <font class="redFont">【<%#bindCosType %>】</font><a href="<%# Kesion.APPCode.Public.GetBindUrl(Utils.StrToInt(Eval("BindType")),Utils.StrToInt(Eval("CourseID")),ref bindCosType) %>" target="_blank" title="<%# Eval("Cname") %> "><%# Eval("Cname") %></a>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </div>
                                    </li>                                           
                                    <li class="oTableCenter" style="width:7%;">
                                        <span><%#Public.ReturnShopPrice(Convert.ToString(Eval("CoursePrice"))) %></span>
                                    </li>
                                 </ul>
                            </ItemTemplate>
                            </asp:Repeater>
                            </div>
                            <div class="oTrfooter clearfix">                    
                                <ul class="fl ml15">
                                	<li class="Lheight36">
                                        <font class="f16 redFont"><%# Utils.StrToInt(Eval("scoretf").ToString())==0?Utils.StrToInt(Eval("orderscore").ToString())>0?Eval("orderscore").ToString()+"积分"+(Utils.StrToDecimal(Eval("OrderTotalPrice"))>0?@"+"+Public.ReturnShopPrice(Convert.ToString(Eval("OrderTotalPrice"))):""):""+"¥"+Kesion.APPCode.Public.ReturnShopPrice(Utils.StrToDecimal(Eval("OrderTotalPrice"))):Eval("orderscore").ToString()+"积分" %></font>
                                        <%# Eval("status").ToString()=="0"?"<span class='button ml15' onclick='buy_price("+Eval("id").ToString()+")'>改价</span>":""%>
                                        <label class="ml20" id="a<%#Eval("id") %>" style="display: none">
                                            <input class="textbox" style="width: 150px; min-height:34px;" name="" id="price_<%#Eval("id") %>" value="<%#Public.ReturnShopPrice(Convert.ToString(Eval("OrderTotalPrice"))) %>" />
                                            <span onclick="buyok('<%# Eval("id") %>')" class="button button_on">修改</span>
                                        </label>
                                    </li>                            
                                    <li class="stateBox Lheight36">
                                        <%#Kesion.Course.CourseOrderService.GetCosOrderStatus(Utils.StrToInt(Eval("Status")),Utils.StrToInt(Eval("DeliverStatus")),Utils.StrToInt(Eval("IsSendNote")),Utils.StrToInt(Eval("IsInvoice")) ) %>
                                    </li>
                                </ul>
                                <ul class="fr">
                                    
                                    <li class="orderOperation">
                                        <input type="button" class="mr15 button" value="开通" <%# Utils.StrToInt(Eval("status"))==0?"":"style='display:none'"%> onclick='openok(<%# Eval("id").ToString()%>)'/>
                                        <input type="button" class="mr15 button" value="关闭" <%# Utils.StrToInt(Eval("status"))==1?"":"style='display:none'"%> onclick='closeok(<%# Eval("id").ToString()%>)'/>
                                        <input type="button" class="mr15 button" value="发货" <%# Utils.StrToInt(Eval("Status")) == 1?(Utils.StrToInt(Eval("IsInvoice"))>0||Utils.StrToInt(Eval("IsSendNote"))>0)&& Utils.StrToInt(Eval("DeliverStatus")) == 0?"":"style='display:none'":"style='display:none'"%>  onclick='top.openWin("录入发货信息,订单号<%#Eval("orderid")%>","Course/KS.CosDelivery.aspx?orderid=<%# Eval("orderid")%>" ,true,750,400);doNone(event)'  >
                                        <input type="button" class="mr15 button" value="发票" <%# (Utils.StrToInt(Eval("Status")) == 1&&Utils.StrToInt(Eval("Invoiced")) == 1)?" style='display:none'":(Utils.StrToInt(Eval("Status")) == 1 && Utils.StrToInt(Eval("IsInvoice")) == 1 && Utils.StrToInt(Eval("Invoiced")) == 0) ?string.Empty:" style='display:none'"%> onclick='  top.openWin("录入开发票信息","Course/KS.CosInvoice.aspx?orderid=<%# Eval("orderid")%>    " ,true,750,400);doNone(event)' >
                                        <input type="button" class="mr15 button" value="快递" <%#Utils.StrToInt(Eval("Status"))>0?Utils.StrToInt(Eval("Status"))==100?" style='display:none'":(Utils.StrToInt(Eval("IsInvoice"))>0||Utils.StrToInt(Eval("IsSendNote"))>0)&& Utils.StrToInt(Eval("DeliverStatus"))> 0?"":"style='display:none'":" style='display:none'" %> onclick="window.open('KS.CosPrintExpress.aspx?id=<%# Eval("id") %>    ');doNone(event)"  />
                                        <input type="button" class="mr15 button" value="退款"  onclick="location.href='KS.CosOrderReturn.aspx'" <%# (Kesion.Course.Course.Received(Utils.StrToInt(Eval("status")),Utils.StrToInt(Eval("paystatus")),Utils.StrToDateTime(Eval("paytime")))=="1"&& Utils.StrToInt(DataFactory.GetOnlyValue("select count(ID) from KS_CosOrderReturn where orderid ='" + Eval("orderid").ToString() + "'")) !=0)?"":"style='display:none'"%> />
                                        <a href="KS.CsOrderShow.aspx?id=<%#Eval("ID") %>" class="mr15 button">查看详情</a>
                                        <asp:LinkButton CssClass="mr15 button" ToolTip="删除" runat="server" ID="LinkButton1" Visible='<%# Utils.StrToInt(Eval("status")) > 0? false:true %>' CommandArgument='<%#Eval("id") %>' OnClientClick="return(confirm('确定删除该订单吗?'));" CommandName="del">删除</asp:LinkButton>
                                    </li>
                                </ul>
                        	</div>
                    </div>       
                </ItemTemplate>
                <FooterTemplate>
                    <div style="display: <%# bool.Parse((Repeater1.Items.Count==0).ToString())?"":"none"%>">
                        <div class="empty">没有任何订单</div>
                    </div>
                </FooterTemplate>
            </asp:Repeater>
            <KS:Page ID="Page1" runat="server" />
            <asp:Panel ID="Panel1" runat="server" Height="30px" Width="100%">
                <script type="text/javascript">
                    showtips('<span class="state"><strong>操作说明：</strong><br /></span>订单号"F"开头是平台的订单，订单号"C"开头的是教师的订单，订单号是"SF"开头的是机构的订单,这里除了学习卡和VIP或者用户组免费的不算。<br /> ');
                </script>
            </asp:Panel>
        </div>
    </asp:Panel>

</asp:Content>
