<%@include file="/WEB-INF/common/layouts/common.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <title>订单列表</title>
    <style type="text/css">
        input {
            width: 150px;
        }

        input, select {
            margin-top: 2px;
            margin-bottom: 2px;
        }
    </style>
</head>
<body>
<%-- <div class="row${fluid}">
    <div class="span6">
        <h2 class="page-title">CmOrder列表</h2>
    </div>
    <div class="span6 header_buttons">
        <a href="${ctx}/cmorder?action=create" class="btn blue pull-right"><i class="icon-plus"></i></a>
    </div>
</div> --%>

<!-- 面包屑 begin -->
<div class="row-fluid">
    <div class="span12">
        <ul class="breadcrumb">
            <!-- <li><a href="/house365-hmc-web/">首页</a> <span class="divider"></span></li> -->
            <li class="active"><span class="divider" style="color:#26a0da;font-weight:bold;">/</span>订单列表</li>
        </ul>
    </div>
</div>
<!-- 面包屑 begin -->

<div class="page-container">
    <div class="row${fluid}">
        <div class="span12">
            <form id="filterForm" class="form-inline filterForm" action="${ctx}/cmorder" method="get">
                <input type="text" name="search_EQ_id" value="${param['search_EQ_id']}" style="height:20px;"
                       class="m-wrap small" placeholder="订单号" title="订单号">
                <input type="text" name="search_EQ_userPhone" value="${param['search_EQ_userPhone']}"
                       style="height:20px;"
                       class="m-wrap small" placeholder="会员手机" title="会员手机">
                <input type="text" name="search_LIKE_goodsName" value="${param['search_LIKE_goodsName']}"
                       style="height:20px;"
                       class="m-wrap small" placeholder="商品名称" title="商品名称">
                <select name="search_EQ_goodsType" id="search_good_type_select" value="">
                    <option value="">全部商品类型</option>
                    <option value="0">实物商品</option>
                    <option value="1">虚拟商品</option>
                    <option value="2">第三方商品</option>
                </select>
                <c:if test="${1 eq userRole}">
                    <select class="span2" style="width:220px;height: 20px" name="search_EQ_cityKey" id="citySelect">
                        <option value="">不限(站点)</option>
                        <option value="zbu" <c:if
                                test="${param['search_EQ_cityKey'] eq 'zbu' }"> selected="selected"</c:if>>事业部
                        </option>
                        <c:forEach items="${cityList}" var="city">
                            <option value="<c:out value="${city.code}"/>" <c:if
                                    test="${param['search_EQ_cityKey'] eq city.code }"> selected="selected"</c:if>>
                                <c:out value="${city.name}"/></option>
                        </c:forEach>
                    </select>
                </c:if>
                <!-- <select name="search_EQ_city" id="search_good_city_select" value="">
                    <option value="">全部组织</option>
                    <option value="1">南京</option>
                    <option value="2">北京</option>
                </select> -->
                <select name="search_EQ_orderStatus" id="search_deliver_type_select" value="">
                    <option value="">全部配送状态</option>
                    <option value="1">已完成</option>
                    <option value="0">未配送</option>
                </select>
                <input type="text" class="span2 date datetime-picker"
                       placeholder="开始时间" value="${param['search_GTE_createTime']}"
                       name="search_GTE_createTime" title="开始时间">
                <input type="text"
                       class="span2 date datetime-picker" placeholder="结束时间" title="结束时间"
                       value="${param['search_LTE_andCreateTime']}"
                       name="search_LTE_andCreateTime">
                <%-- <div class="buttons pull-right"  style="margin-left:15px;">
                    <a href="${ctx}/cmorder?action=create" class="btn blue pull-right" title="新增"><i class="icon-plus"></i></a>
                </div> --%>
                <!-- <div class="buttons pull-right" >
                    <a href="javascript:void(0);" onclick="deleteById('')" class="btn blue pull-right" title="删除"><i class="icon-minus"></i></a>
                </div> -->
                <div class="buttons pull-right" style="margin:3px 30px 0 0;">
                    <i class="icon-search icon-2x pointer" onclick="$('#filterForm').submit();" title="搜索"></i>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <i class="icon-file icon-2x pointer"
                       onclick="$('#filterForm').attr('action','${ctx}/cmorder/exportExcel');$('#filterForm').submit();$('#filterForm').attr('action','${ctx}/cmorder');"
                       title="导出Excel"></i>
                </div>
            </form>
        </div>
    </div>
    <table class="table table-striped table-advance table-hover">
        <thead>
        <tr>
            <th width="40" style="text-align:center"><input id="memberCheckAll" type="checkbox"
                                                            onclick="checkAll(this)"/></th>
            <th width="100">订单编号</th>
            <th width="100">商品名称</th>
            <th width="100">商品类型</th>
            <th width="100">会员ID</th>
            <th width="100">登录名</th>
            <th width="100">会员手机</th>
            <th width="100">状态</th>
            <th width="100">组织</th>
            <th width="100">下单时间</th>
            <th width="150">操作</th>
        </tr>
        </thead>
        <c:forEach items="${cmOrders}" var="cmOrder">
            <tr>
                <td nowrap="nowrap" style="text-align:center">
                    <input type="checkbox" name="memberCheck" value="${cmOrder.id}" onclick="checkMember(this)"/>
                </td>
                <td nowrap="nowrap">
                    <c:out value="${cmOrder.id}"/>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${null ne cmOrder.goodsName && '' ne cmOrder.goodsName}">
                        <c:out value="${cmOrder.goodsName}"/>
                    </c:if>
                    <c:if test="${null eq cmOrder.goodsName || '' eq cmOrder.goodsName}">
                        &nbsp;
                    </c:if>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${cmOrder.goodsType eq 1}">
                        虚拟
                    </c:if>
                    <c:if test="${cmOrder.goodsType eq 2}">
                        第三方
                    </c:if>
                    <c:if test="${cmOrder.goodsType eq 0}">
                        实物
                    </c:if>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${null ne cmOrder.userId && '' ne cmOrder.userId}">
                        <c:out value="${cmOrder.userId}"/>
                    </c:if>
                    <c:if test="${null eq cmOrder.userId || '' eq cmOrder.userId}">
                        &nbsp;
                    </c:if>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${null ne cmOrder.userName && '' ne cmOrder.userName}">
                        <c:out value="${cmOrder.userName}"/>
                    </c:if>
                    <c:if test="${null eq cmOrder.userName || '' eq cmOrder.userName}">
                        &nbsp;
                    </c:if>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${null ne cmOrder.userPhone && '' ne cmOrder.userPhone}">
                        <c:out value="${cmOrder.userPhone}"/>
                    </c:if>
                    <c:if test="${null eq cmOrder.userPhone || '' eq cmOrder.userPhone}">
                        &nbsp;
                    </c:if>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${cmOrder.goodsType eq '1'}">
                        已完成
                    </c:if>
                    <c:if test="${cmOrder.goodsType eq '2'}">
                        已完成
                    </c:if>
                    <c:if test="${cmOrder.goodsType eq '0'}">
                        <c:choose>
                            <c:when test="${cmOrder.orderStatus eq '0'}">
                                <span class="inline">未配送</span>
                            </c:when>
                            <c:when test="${cmOrder.orderStatus eq '1'}">
                                <span class="inline">已完成</span>
                            </c:when>
                            <c:otherwise>
                                <span class="inline">---</span>
                            </c:otherwise>
                        </c:choose>
                    </c:if>

                </td>
                <td nowrap="nowrap">
                    <c:if test="${null ne cmOrder.cityName && '' ne cmOrder.cityName}">
                        <c:out value="${cmOrder.cityName}"/>
                    </c:if>
                    <c:if test="${null eq cmOrder.cityName || '' eq cmOrder.cityName}">
                        &nbsp;
                    </c:if>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${null ne cmOrder.createTime && '' ne cmOrder.createTime}">
                        <f:formatDate value='${cmOrder.createTime}' pattern='yyyy-MM-dd HH:mm:ss'/>
                    </c:if>
                    <c:if test="${null eq cmOrder.createTime || '' eq cmOrder.createTime}">
                        &nbsp;
                    </c:if>
                </td>
                <td nowrap="nowrap">
                    <c:if test="${cmOrder.goodsType eq 1}">
                        <i class="icon-edit pointer icon-large" title="查看"
                           onclick="window.location='${ctx}/cmorder/virtualorder/${cmOrder.id}'"></i>
                        &nbsp;&nbsp;
                    </c:if>
                    <c:if test="${cmOrder.goodsType eq 0}">
                        <i class="icon-edit pointer icon-large" title="查看"
                           onclick="window.location='${ctx}/cmorder/order/${cmOrder.id}'"></i>
                        &nbsp;&nbsp;
                    </c:if>
                    <c:if test="${cmOrder.goodsType eq 2}">
                        <i class="icon-edit pointer icon-large" title="查看"
                           onclick="window.location='${ctx}/cmorder/virtualorder/${cmOrder.id}'"></i>
                        &nbsp;&nbsp;
                    </c:if>
                        <%-- <i
                           <i class="icon-edit pointer icon-large"
                           onclick="window.location='${ctx}/cmorder/${cmOrder.id}?action=edit'"></i>
                           title="删除"
                           class="icon-minus pointer icon-large"
                           onclick="deleteById('${cmOrder.id}')"> </i> --%>
                </td>
                    <%--

                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.userId && '' ne cmOrder.userId}">
                                <c:out value="${cmOrder.userId}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.userId || '' eq cmOrder.userId}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.userName && '' ne cmOrder.userName}">
                                <c:out value="${cmOrder.userName}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.userName || '' eq cmOrder.userName}">
                                &nbsp;
                            </c:if>
                    </td>

                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.deliverType && '' ne cmOrder.deliverType}">
                                <c:out value="${cmOrder.deliverType}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.deliverType || '' eq cmOrder.deliverType}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.receiverName && '' ne cmOrder.receiverName}">
                                <c:out value="${cmOrder.receiverName}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.receiverName || '' eq cmOrder.receiverName}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.receiverPhone && '' ne cmOrder.receiverPhone}">
                                <c:out value="${cmOrder.receiverPhone}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.receiverPhone || '' eq cmOrder.receiverPhone}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.receiverArea && '' ne cmOrder.receiverArea}">
                                <c:out value="${cmOrder.receiverArea}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.receiverArea || '' eq cmOrder.receiverArea}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.receiverDetailAddress && '' ne cmOrder.receiverDetailAddress}">
                                <c:out value="${cmOrder.receiverDetailAddress}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.receiverDetailAddress || '' eq cmOrder.receiverDetailAddress}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.receiverZipCode && '' ne cmOrder.receiverZipCode}">
                                <c:out value="${cmOrder.receiverZipCode}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.receiverZipCode || '' eq cmOrder.receiverZipCode}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.credits && '' ne cmOrder.credits}">
                                <c:out value="${cmOrder.credits}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.credits || '' eq cmOrder.credits}">
                                &nbsp;
                            </c:if>
                    </td>

                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.expressCompany && '' ne cmOrder.expressCompany}">
                                <c:out value="${cmOrder.expressCompany}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.expressCompany || '' eq cmOrder.expressCompany}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.oerderNumber && '' ne cmOrder.oerderNumber}">
                                <c:out value="${cmOrder.oerderNumber}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.oerderNumber || '' eq cmOrder.oerderNumber}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.cityId && '' ne cmOrder.cityId}">
                                <c:out value="${cmOrder.cityId}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.cityId || '' eq cmOrder.cityId}">
                                &nbsp;
                            </c:if>
                    </td>

                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.isDeleted && '' ne cmOrder.isDeleted}">
                                <c:out value="${cmOrder.isDeleted}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.isDeleted || '' eq cmOrder.isDeleted}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.goodsId && '' ne cmOrder.goodsId}">
                                <c:out value="${cmOrder.goodsId}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.goodsId || '' eq cmOrder.goodsId}">
                                &nbsp;
                            </c:if>
                    </td>

                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.goodsAmount && '' ne cmOrder.goodsAmount}">
                                <c:out value="${cmOrder.goodsAmount}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.goodsAmount || '' eq cmOrder.goodsAmount}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.goodsPicture && '' ne cmOrder.goodsPicture}">
                                <c:out value="${cmOrder.goodsPicture}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.goodsPicture || '' eq cmOrder.goodsPicture}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.goodsCreditAmount && '' ne cmOrder.goodsCreditAmount}">
                                <c:out value="${cmOrder.goodsCreditAmount}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.goodsCreditAmount || '' eq cmOrder.goodsCreditAmount}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.goodsTotalCreditAmount && '' ne cmOrder.goodsTotalCreditAmount}">
                                <c:out value="${cmOrder.goodsTotalCreditAmount}" />
                            </c:if>
                            <c:if test="${null eq cmOrder.goodsTotalCreditAmount || '' eq cmOrder.goodsTotalCreditAmount}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.deliverTime && '' ne cmOrder.deliverTime}">
                                <f:formatDate value='${cmOrder.deliverTime}' pattern='yyyy-MM-dd HH:mm:ss' />
                            </c:if>
                            <c:if test="${null eq cmOrder.deliverTime || '' eq cmOrder.deliverTime}">
                                &nbsp;
                            </c:if>
                    </td>
                    <td nowrap="nowrap">
                            <c:if test="${null ne cmOrder.receiveTime && '' ne cmOrder.receiveTime}">
                                <f:formatDate value='${cmOrder.receiveTime}' pattern='yyyy-MM-dd HH:mm:ss' />
                            </c:if>
                            <c:if test="${null eq cmOrder.receiveTime || '' eq cmOrder.receiveTime}">
                                &nbsp;
                            </c:if>
                    </td>
                     --%>
            </tr>
        </c:forEach>
    </table>
    <div class="row${fluid}">
        <house365:pagination page="${page}"/>
    </div>
</div>
<script type="text/javascript">

    //全选
    function checkAll(btn) {
        if (btn.checked) {
            for (i = 0; i < document.all("memberCheck").length; i++) {
                document.all("memberCheck")[i].checked = "checked";
            }
        }
        else {
            for (i = 0; i < document.all("memberCheck").length; i++) {
                document.all("memberCheck")[i].checked = "";
            }
        }
    }

    //单选
    function checkMember(btn) {
        if (btn.checked) {
            var checkAll = true;
            for (i = 0; i < document.all("memberCheck").length; i++) {
                if (document.all("memberCheck")[i].checked == false) {
                    checkAll = false;
                }
            }

            if (checkAll) {
                document.getElementById("memberCheckAll").checked = true;
            }
        }
        else {
            document.getElementById("memberCheckAll").checked = false;
        }
    }

    var deleteById = function (selectedId) {
        /*
         id为空则是多选  判断是否为空
         为空 提示选择
         不为空 确认后删除
         不为空单选确认后删除
         */
        if (selectedId == "") {
            for (i = 0; i < document.getElementsByName('memberCheck').length; i++) {
                if (document.getElementsByName('memberCheck')[i].checked) {
                    selectedId += document.getElementsByName('memberCheck')[i].value + ",";
                }
            }

            var str = "";
            if (selectedId != "") {
                str = selectedId.split(",");

                if (str[str.length - 1] == "") {
                    selectedId = selectedId.substring(0, selectedId.length - 1);
                }
            }
        }

        if (selectedId == "") {
            House365Util.createModal("删除公告", "请至少选择一条公告!", function () {
            });
        }
        else {
            House365Util.createModal("删除公告", "确定要删除该公告？", function () {
                $.ajax({
                    url: '${ctx}/cmorder/' + selectedId,
                    type: "DELETE",
                    success: function () {
                        window.location.reload();
                    }
                });
            });
        }

    };

    $(function () {

        $("#search_good_type_select").val("${param['search_EQ_goodsType']}");
        $('#search_good_type_select').trigger("chosen:updated");

        $("#search_deliver_type_select").val("${param['search_EQ_orderStatus']}");
        $('#search_deliver_type_select').trigger("chosen:updated");


    });


</script>
</body>
</html>
