<?php include_once(mvc::$cfg['PATH_TPL'].'public/headBase.php');?>
<link rel="stylesheet" type="text/css" href="<?php echo mvc::$cfg['ADMIN_URL'];?>static/css/jquery.autocomplete.css">
<link rel="stylesheet" type="text/css" href="<?php echo mvc::$cfg['ADMIN_URL'];?>static/css/order.css?ver=<?php echo mvc::$cfg['VER']['css'];?>">
<link rel="stylesheet" type="text/css" href="<?php echo mvc::$cfg['ADMIN_URL'];?>static/css/check_box.css?ver=<?php echo mvc::$cfg['VER']['css'];?>">
<div class="marauto iframes-left-main" id="SearchProduct">
    <div class="Clear"></div>
    <form action="<?php echo mvc::$cfg['ADMIN_URI'];?>order/orderList" method="get" target="ListFrame" id="BasicS">
        <!-- <form action="" method="get" target="_blank"> -->
        <input type="hidden" name="checkedId" id="hidden-order-id" />
        <table class="table table-bordered table-hover" id="SearchTable">
            <tr>
                <th class="right" width="80px" width="100px">订单状态：</th>
                <td>
                    <select name="status" class="form-control" id="Make" class="w150" style="float:left">
                        <option value="all">--全部--</option>
                        <option value="creat">等待付款</option>
                        <option value="paied">等待发货</option>
                        <option value="send">等待收货</option>
                        <option value="cancel">已取消</option>
                        <option value="completed">已完成</option>
                        <option value="refund">售后中</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="right" width="80px">订单号：</th>
                <td>
                    <input type="text" class="form-control" id="orderId" name="orderId" size="23" />
                </td>
            </tr>
            <tr>
                <th  class="right" width="80px">配件名称：</th>
                <td>
                    <input type="text" class="form-control" id="keyWord" name="keyWord" size="23" />
                </td>
            </tr>
            <tr>
                <th class="right" width="80px">配件ID：</th>
                <td>
                    <input type="text" class="form-control" id="proId" name="proId" size="23" />
                </td>
            </tr>
            <tr>
                <th class="right" width="80px">用户名称：</th>
                <td>
                    <input type="text" class="form-control" name="userName" id="user" size="23" />
                </td>
            </tr>
            <tr>
                <th class="right" width="80px">店铺名称：</th>
                <td>
                    <input type="text" class="form-control" id="shop" name="shopName" size="23" />
                    <input type="hidden" name="shopId" id="shopId">
                </td>
            </tr>
            <tr>
                <th class="right" width="80px">下单时间：</th>
                <td>
                    <input type="text" id="addTime" class="form-control time-box" name="addTime" size="23" />
                    <span>-</span>
                    <input type="text" id="endTime" class="form-control time-box" name="endTime" size="23" />
                    <!-- <input type="hidden" name="shopId" id="shopId"> -->
                </td>
            </tr>
            <tr>
                <th class="right" width="80px">排序条件：</th>
                <td>
                    <select name="orderBy" class="form-control">
                        <option value="tdesc">下单时间降序</option>
                        <option value="tasc">下单时间升序</option>
                        <option value="mdesc">订单金额降序</option>
                        <option value="masc">订单金额升序</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="right" width="80px">显示列：</th>
                <td style="position: relative;">
                    <input type="hidden" name="showColumn" class="showColumn_input">
                    <input class="form-control showColumn_textarea" readonly value="订单编号,订单状态,店铺,订单金额">
                    <div id="showColumn" class="pull-right"></div>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" class="btn btn-primary" value="搜 索" onclick="$('#hidden-order-id').val('');" class="BigBtn" />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="reset" class="btn btn-default" value="重置" onclick="ResetAll()" />
                </td>
            </tr>
        </table>
    </form>
        <div class="searchCheck">
            <form id="orderCheckForm">
                <div id="orderCheckTable">
                    <table class="table">
                        <thead>
                            <tr>
                                <th width="240px">已选订单</th>
                                <th width="76px">移除</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
                <div class="changeStatus-remark hidden">
                <span>状态修改原因</span>
                <textarea class="form-control" rows="3" name="remark" placeholder="请填写状态变更原因"></textarea>
                </div>
            </form>           
            <div class="checkFoot">
            <button type="button" class="btn btn-primary" onclick="ORDER.viewOnclick();return false;">已选</button>
            <button type="button" class="btn btn-primary" onclick="ORDER.clearAll();return false;">清空</button>
            <button type="button" class="btn btn-danger" onclick="ORDER.cancelOrder();return false;">取消订单</button>
            </div>
        </div>
    </div>
<script type="text/javascript" src="<?php echo mvc::$cfg['ADMIN_URL'];?>static/js/order.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<script type="text/javascript" src="<?php echo mvc::$cfg['ADMIN_URL'];?>static/js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="<?php echo mvc::$cfg['ADMIN_URL'];?>static/js/check_box.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<script type="text/javascript">
    var params = <?php echo json_encode($params,JSON_UNESCAPED_UNICODE)?>;
    var data = <?php echo json_encode($data,JSON_UNESCAPED_UNICODE)?>;
    var a = new check_box(params, data);
    $('.check_box_text_list').addClass('hidden');
    $('.check_box_text button').addClass('hidden');
    function putIntoCheckColumn(value,obj,ev){
        var val=ev.getCheckVal();
        var nameArr=ev.getCheckName();
        $('.showColumn_input').val(val.join(","));
        if(nameArr.join(",")=='')
        {
            var newtxt = '订单编号,订单状态,店铺,订单金额';
        }
        else
        {
            var newtxt = nameArr.join(",");
        }
        $('.showColumn_textarea').val(newtxt);
    }
    $('.showColumn_textarea').click(function(e){
        $('.check_box_content').toggleClass('hidden');
        var e = e || window.event; //浏览器兼容性 
        e.stopPropagation();
    })
</script>
<script type="text/javascript">
var AutoShopArr=<?php echo json_encode($shopArr);?>;
$(function() {
    ORDER.AjaxProCheck('','');
    //父级自动完成
     $("#shop").autocomplete(AutoShopArr, {
        minChars: 0,
        max: 500,
        matchContains : true,
        formatItem: function(row) {
            return row.shop_name;
        },
        formatMatch: function(row) {
            return row.shop_name;
        },
        formatResult: function(row) {
            return row.shop_name;
        },
    }).result(function(event, data, formatted){
        $('#shopId').val(data.shop_id);
    });
    $('#shop').blur(function(){
        if($(this).val()==''){
            $('#shopId').val('');
        }
    })
         //开始时间时间
    var start = laydate.render({
        elem: '#addTime',
        type: 'date',
        min: '1900-1-1 00:00:00',
        max: '2099-6-16 23:59:59',
        trigger: 'click', //采用click弹出
        done: function (value, date, endDate) {
            end.config.min = {
                year: date.year,
                month: date.month - 1,
                date: date.date,
                hours: date.hours,
                minutes: date.minutes,
                seconds: date.seconds
            }; //开始日选好后，重置结束日的最小日期
            end.config.value = {
                year: date.year,
                month: date.month - 1,
                date: date.date,
                hours: date.hours,
                minutes: date.minutes,
                seconds: date.seconds
            }; //将结束日的初始值设定为开始日
        }
    });
    //结束时间
    var end = laydate.render({
        elem: '#endTime',
        min: '1900-1-1 00:00:00',
        max: '2099-6-16 23:59:59',
        type: 'date',
        trigger: 'click', //采用click弹出
        done: function (value, date, endDate) {
            if(value!==''){
                start.config.max = {
                    year: date.year,
                    month: date.month - 1,
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
                }; //结束日选好后，重置开始日的最大日期
            }
        }
    });
    $(window.parent.document).contents().find('#layer_box').on('hidden.bs.modal', function (e) {
      $(window.parent.document).contents().find('#mask_layer').hide();
    })
    $(window.parent.document).contents().find('#layer_box').on('shown.bs.modal', function (e) {
        $('.modal-backdrop').hide();
        $(window.parent.document).contents().find('#mask_layer').show();
    })
    $(window.parent.document).contents().find('#layer_box').on('show.bs.modal', function (e) {
        var trItem=$('#orderCheckTable tbody tr').length;
        if(trItem==0) return false;       
        $('.modal-backdrop').hide();
        $(window.parent.document).contents().find('#mask_layer').show();
    })
});
</script>