{layout:default} {class:Shop.Admin.statis.sales}
<lbhead>
    <title><%=Tag("销售报表")%>-<%=site.title%></title>
</lbhead>
<lbfile>
    <link href="<%=site.AdminAssetsPath %>/plugins/daterangepicker/daterangepicker.css" rel="stylesheet">
</lbfile>
<lbpath>
    <h3 class="text-themecolor m-b-0 m-t-0"><%=Tag("销售报表") %></h3>
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=MenuJump&pid=0"><%=Tag("管理首页")%></a></li>
        <li class="breadcrumb-item active"><%=Tag("销售报表")%></li>
    </ol>
</lbpath>
<lbbody>
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <form action="javascript:SaveObj();" novalidate>
                    <div class="row m-b-20">
                        <div class="col-md-12">
                            <%if (PageReturnMsg == ""){%>
                            <button type="submit" class="btn btn-success"><i class="ti-check"></i> <%=Tag("提交")%></button>
                            <button class="btn btn-info" onclick="Export();"><i class="ti-export"></i> <%=Tag("导出")%></button>
                            <%}%>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="daterange"><%=Tag("选择日期")%>：</label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <select name="dateType" id="dateType" class="form-control"><option value="0" <%=dateType == 0?"selected":""%>><%=Tag("订购日期")%></option><option value="1" <%=dateType == 1?"selected":""%>><%=Tag("付款日期")%></option><option value="2" <%=dateType == 2?"selected":""%>><%=Tag("发货日期")%></option></select>
                            </div>
                            <input type="text" name="daterange" id="daterange" class="form-control">
                            <div class="input-group-append">
                                <span class="input-group-text">
                                    <span class="ti-calendar"></span>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Pay_id"><%=Tag("支付方式")%>：</label>
                        <select name="Pay_id" id="Pay_id" class="form-control">
                            <option value="0"><%=Tag("全部")%></option>
                            <%foreach (DB.LebiShop.Lebi_Pay pay in pays){%>
                            <option value="<%=pay.id %>" <%=Pay_id == pay.id?"selected":"" %>><%=Shop.Bussiness.Language.Content(pay.Name, CurrentLanguage.Code)%></option>
                            <%} %>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="Transport_id"><%=Tag("配送方式")%>：</label>
                        <select name="Transport_id" id="Transport_id" class="form-control">
                            <option value="0"><%=Tag("全部")%></option>
                            <%foreach (DB.LebiShop.Lebi_Transport transport in transports){%>
                            <option value="<%=transport.id %>" <%=Transport_id == transport.id?"selected":"" %>><%=transport.Name%></option>
                            <%} %>
                        </select>
                    </div>
                </form>
            </div>
            <%if (display == 1){ %>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table m-t-10 table-hover no-wrap">
                        <thead>
                            <tr>
                                <th>&nbsp;</th>
                                <th><%=Tag("销售数量")%></th>
                                <th><%=Tag("订单金额")%></th>
                                <th><%=Tag("商品金额")%></th>
                                <th><%=Tag("运费")%></th>
                                <th><%=Tag("税金")%></th>
                                <th><%=Tag("成本")%></th>
                                <th><%=Tag("利润")%></th>
                            </tr>
                        </thead>
                        <tbody id="monthparts"></tbody>
                    </table>
                </div>
            </div>
            <%} %>
        </div>
    </div>
</lbbody>
<lbscripts>
    {MOD:DateRangePicker}
    <%if (display == 1){ %>
    <script>
        function getmonthparts() {
            $.ajax({
                type: "POST",
                url: "sales_part.aspx?dateType=<%=dateType %>&dateFrom=<%=dateFrom %>&dateTo=<%=dateTo %>&Pay_id=<%=Pay_id %>&Transport_id=<%=Transport_id%>",
                data: '',
                success: function (res) {
                    $("#monthparts").html(res);
                }
            });
        }
        $(function () {
            getmonthparts();
        });
    </script>
    <%} %>
    <script>
        function SaveObj() {
            var dateType = $("#dateType").val();
            var dateFrom = "";
            var dateTo = "";
            var daterange = $("#daterange").val();
            if (daterange.indexOf(" - ") >-1){
                dateFrom = daterange.split(" - ")[0];
                dateTo = daterange.split(" - ")[1];
            }
            var Pay_id = $("#Pay_id").val();
            var Transport_id = $("#Transport_id").val();
            if (dateFrom == "" || dateTo == "") {
                MsgBox(1, "<%=Tag("请选择订购日期")%>", "")
            }
            window.location = "?display=1&dateType=" + dateType + "&dateFrom=" + dateFrom + "&dateTo=" + dateTo + "&Pay_id=" + Pay_id + "&Transport_id=" + Transport_id;
        }
        function Export() {
            var dateType = $("#dateType").val();
            var dateFrom = $("#dateFrom").val();
            var dateTo = $("#dateTo").val();
            var Pay_id = $("#Pay_id").val(); 
            var Transport_id = $("#Transport_id").val();
            if (dateFrom == "" || dateTo == "") {
                MsgBox(1, "<%=Tag("请选择订购日期")%>", "")
            }
            MsgBox(1, "<%=Tag("正在处理，请等待")%>", "<%=site.AdminPath %>/ajax/export.aspx?__Action=Statis_Sales&dateType=" + dateType + "&dateFrom=" + dateFrom + "&dateTo=" + dateTo + "&Pay_id=" + Pay_id + "&Transport_id=" + Transport_id)
        }
    </script>
</lbscripts>