<!doctype html>
<html class="no-js">
<head>

  <include file="Common/head" />
  <style type="text/css">
    a.am-text-secondary:visited{color:#3bb4f2;}
    a.am-text-danger:visited{color:#dd514c;}
    .am-btn-default {background-color: #fff;}
    th {text-align:center;}
    tr td{text-align:center;}
    select{padding: 4px;border: 1px solid #ccc;}
    .am-popup-bd {background:#fff;}
    .am-popup-bd img {max-width: 100%}
    .am-u-sm-2 {border-top: 1px solid #ddd;margin-top: 10px;}
    .am-u-sm-10 {border-left: 1px solid #ddd;margin-top: 10px;}
    .am-table>tbody>tr>td.user-info {padding: 1px;text-align: left;}
    .am-table>tbody>tr>td.user-info img{height: 42px}
    myred{color:#dd514c;}
    mygreen {color:#1aad19;}
    mygery {color:#999;}
    .wxgreen {color:#1aad19;}
    .search-div.am-input-group .am-form-field{width:120px;float: right;}
    .search-div select {float: right;}
    .ttt-switch {margin: 0 auto;}
    .am-form select{
      font-size: 1.2rem;
      border-color: #e6e6e6;
      width: unset;
      padding: .5em 2em .5em 1em;
      margin: 0 auto;
    }
    .am-table>tbody>tr>td.td-img {
      padding: 1px;
      text-align: left;
      padding-left: 10px;
    }
    .am-table>tbody>tr>td.td-img img {
      height: 56px;width: 56px;
    }
    .am-table>tbody>tr>td.td-img a {
      display: inline-block;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      width: 13vw;
      cursor: pointer;
    }
    .am-table>thead>tr>th {
      border-bottom: 0;
    }
    .am-table>tbody>tr:first-child>td {
      border-top: 0;
    }
    .am-table>thead.am-thead-hide>tr>th {
      padding: 0;
    }
    p {
      margin: 0;
    }
    .am-table>tbody>tr>td {
      vertical-align: middle;
      font-size: 1.4rem;
      line-height: 1.6rem;
      color: #444;
      background-color: #fdfdfd;
    }
    .format-price>p {
      display: table;
      width: 100%;
      text-align: right;
    }
    .format-price>p>span {
      display: table-cell;
      width: 50%;
      text-align: right;
    }
    .am-filter>.am-input-group:not(:first-child) {
      padding-top: 1.25rem;
    }
    .am-input-group-label.toumin {
      background-color: rgba(0,0,0,0);
      border: 0;
    }
    input[type=datetime-local].am-form-field {
      height: 33px;
    }
    .am-btn {
      font-size: 1.4rem;
    }
  </style>
  <style type="text/css">
    .shade_div {
      width:100%;
      height:100%;
      background-color:#000;
      filter:alpha(opacity=50);
      -moz-opacity:0.5;
      opacity:0.5;
      position:absolute;
      left:0px;
      top:0px;
      display:none;
      z-index:1000;
    }
    .float_div {
      width:200px;
      height:400px;
      position:absolute;
      background-color: #FFF;
      top:200px;
      left:50%;
      margin-left:-140px;
      display:none;
      z-index:1500;
    }
  </style>
</head>
<body>
<include file="Common/header" />

<div class="am-cf admin">

  <include file="Common/sidebar" nav="order" navv="order_list"/>

  <div class="content-page" style="background: white;">

    <div class="content" style="background: white;">
      <div class="admin-content-body">
        <div class="am-cf am-padding">
          <!-- Start right Content here -->
          <div class="content">


          </div>
          <!-- Start content -->
          <div class="content">
            <div class="am-cf am-padding">
              <strong class="am-text-primary am-text-lg">订单管理</strong> /
              <small>订单列表</small>
            </div>
            <ul class="am-nav am-nav-pills" style="margin: 0 1.5rem;">
              <li class="sts" data-sts=""><a href="javascript:;">所有订单</a></li>
              <li class="sts" data-sts="1"><a href="javascript:;">待付款</a></li>
              <li class="sts" data-sts="2"><a href="javascript:;">已下单</a></li>
              <li class="sts" data-sts="3"><a href="javascript:;">已关闭</a></li>
            </ul>
            <script type="text/javascript">
                $(function(){
                    var sts = "{$_GET['sts']}";
                    $('.sts[data-sts="'+sts+'"]').addClass('am-active');
                    $('.sts').on('click',function(){
                        location.href = "{:U('Order/order_list')}?sts="+$(this).data('sts');
                    });
                });
            </script>

            <hr style="margin-top:0px;">

            <form action="{:U('Order/order_list')}" class="am-panel am-panel-default" style="margin:1.5rem;" id="form1">
              <input type="hidden" name="op">
              <div class="am-panel-bd am-filter">
                <div class="am-input-group am-input-group-sm" style="max-width: 820px;">
                  <span class="am-input-group-label">订单号</span>
                  <input type="text" name="order_sn" value="{$_GET['order_sn']}" class="am-form-field">
                  <span class="am-input-group-label toumin"></span>
                  <span class="am-input-group-label">用户名</span>
                  <input type="text" name="nickname" value="{$_GET['nickname']}" class="am-form-field">
                  <span class="am-input-group-label toumin"></span>
                  <span class="am-input-group-label">收货人/电话</span>
                  <input type="text" name="address" value="{$_GET['address']}" class="am-form-field">
                </div>
                <div class="am-input-group am-input-group-sm" style="max-width: 400px;">
                  <span class="am-input-group-label">下单时间</span>
                  <input type="datetime-local" name="ctstar" value="{$_GET['ctstar']}" class="am-form-field">
                  <span class="am-input-group-label">至</span>
                  <input type="datetime-local" name="ctend" value="{$_GET['ctend']}" class="am-form-field">
                </div>
                <div class="am-input-group am-input-group-sm">
                  <button class="am-btn am-btn-primary submit" type="button">搜索</button>&nbsp;
                  <a class="am-btn am-btn-secondary" href="{:U('order_list')}">清空</a>&nbsp;
                </div>
              </div>
              <script type="text/javascript">
                  $(function(){
                      $('.submit').on('click',function(){
                          $('input[name=op]').val('');
                          $('#form1').submit();
                      });
                      $('.export').on('click',function(){
                          $('input[name=op]').val('export');
                          $('#form1').submit();
                      });
                      $("input[name=ctstar]").on('click',function(){
                          if($(this).val() == ''){
                              $(this).val("{:date('Y-m-d\\T00:00')}");
                          }
                      });
                      $("input[name=ctend]").on('click',function(){
                          if($(this).val() == ''){
                              $(this).val("{:date('Y-m-d\\T00:00',strtotime("+1 day"))}");
                          }
                      });
                  });
              </script>
            </form>

            <div class="am-g">
              <div class="am-u-sm-12">
                <div class="am-scrollable-horizontal">
                  <table class="am-table am-text-nowrap am-table-radius">
                    <thead>
                    <tr style="background-color: #f9f9f9;">
                      <th width="20%" style="text-align: left;">订单信息（共{$count}条记录）</th>
                      <th width="10%">价格</th>
                      <th width="10%">客户</th>
                      <th width="10%">价格总计</th>

                      <th width="10%">状态</th>
                      <th width="10%">&nbsp;</th>
                    </tr>
                    </thead>
                  </table>
                  <if condition="!$list">
                    <table class="am-table am-text-nowrap am-table-radius am-table-bordered">
                      <tbody><tr><td>这里没有数据</td></tr></tbody>
                    </table>
                  </if>
                  <volist name="list" id="vo" key="k">
                    <table class="am-table am-text-nowrap am-table-radius am-table-bordered">
                      <thead class="am-thead-hide">
                      <tr>
                        <th width="20%"></th>
                        <th width="10%"></th>
                        <th width="10%"></th>
                        <th width="10%"></th>
                        <th width="10%"></th>
                        <th width="10%"></th>
                      </tr>
                      </thead>
                      <tbody>
                      <tr>
                        <td colspan="10" style="text-align: left;border-top: 0;background-color: #f9f9f9;">
                          <span>订单编号：{$vo.order_sn}</span><span style="margin-left:10px">下单时间：{:cdate(0,$vo['create_time'])}</span>
			&nbsp;
			<?php if ($vo['order_type'] == 1) : ?>
		    		<span class="am-badge am-badge-primary">外卖订单</span>
		    	<?php elseif ($vo['order_type'] == 2) : ?>	    
				<span class="am-badge am-badge-primary">食堂订单</span>
		    	<?php endif;?>
                        </td>
                      </tr>
                      <volist name="vo.goods" id="vp">
                        <tr>
                          <td class="td-img">

                            <a href="{:U('Goods/goods')}?id={$vp.goods_id}" target="_blank">{$vp.title}</a>
                          </td>
                          <td style="text-align: left;border-left: 0;">
                            <p>售价：{:cmoney($vp['price'])}元&nbsp;&nbsp;&nbsp;&nbsp;数量：{:cmoney($vp['goods_num'])}件</p>
                          </td>
                          <if condition="$i eq 1">
                            <td rowspan="{:count($vo['goods'])}">
                              <p><a href="{:U('Users/userList')}?search={$vo.uid}" target="_blank">{$vo.nickname}</a></p>
                              <p>{$vo.address_name}</p>
                              <p>{$vo.address_phone}</p>
                            </td>
                            <td rowspan="{:count($vo['goods'])}" class="format-price">

                              <?php if($vo['order_type']==1){?>
                              <span>配送费：</span><?php echo $vo['delivery'] ?>元
                              <br>
                              <span>餐盒费：</span><?php echo $vo['boxes'] ?>元
                              <br>
                              <?php } ?>

                              <span>应收款：</span>{$vo.price}元
                            </td>

                            <td rowspan="{:count($vo['goods'])}">
                              <?php
                      switch ($vo['status']) {
                            case 1: echo '<span class="am-badge am-badge-primary">待付款</span>'; break;
                              case 2: echo '<span class="am-badge am-badge-primary">已下单</span>'; break;
                              case 3: echo '<span class="am-badge am-badge-warning">已关闭</span>'; break;
                              case 7: echo '<span class="am-badge am-badge-success">已退款</span>'; break;
                              default: break;
                              }
                              ?>
                              <br>
                              <?php if ($info['is_business'] == 3) : ?>
                              <?php
                      switch ($vo['order_type']) {
                            case 1: echo '<span class="am-badge am-badge-success">外卖</span>'; break;
                              case 2: echo '<span class="am-badge am-badge-primary">店内</span>'; break;
                              default: break;
                              }
                              ?>
                              <?php endif;?>
                            </td>

                            <td style="padding:.45rem;" rowspan="{:count($vo['goods'])}">
                              <a onclick="content(`{$vo['admin_id']}`,`{$vo['order_sn']}`)" class="am-btn am-btn-default">打印订单</a>
                              <a href="{:U('Order/detail')}?order_sn={$vo.order_sn}" class="am-btn am-btn-default">查看详情</a>
                            </td>
                          </if>
                        </tr>
                      </volist>
                      </tbody>
                    </table>
                  </volist>

                </div>
                <div class="am-cf">
                  <div class="am-fr">
                    {$page}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- content end -->

      </div>



    </div>
  </div>

</div>
<include file="Common/footer" />

<script type="text/javascript">
    $(function(){
        // 重置密码
        $(".reset_link").on("click",function(){
            var id=$(this).attr('data-id');
            var name=$(this).attr("data-name");
            var bool = confirm("确认重置管理员“"+name+"”的密码吗？");
            if (bool) {
                $("#float_id").val(id);
                $("#float_name").html(name);
                $("#shade_div").show();
                $("#float_div").show();
            };
        });
        $("#btclose").on("click",function(){
            $("#shade_div").hide();
            $("#float_div").hide();
        });
        // 删除
        $(".del_link").on("click",function(){
            var name=$(this).attr("data-name");
            var the_link=$(this).attr("data-url");
            var bool = confirm("确认删除管理员“"+name+"”吗？");
            if (bool) {
                location.href = the_link;
            };
        });
    });
    function content(admin_id,order_sn){
        var admin_id1= admin_id;
        var order_sn1 = order_sn;
        $.ajax({
            type:'get',
            url:'/canyin/api/api/content?t=' + new Date().getTime(),
            data:{
                admin_id:admin_id1,
                order_sn:order_sn1,
            },
            dataType:'json',
            async: false,
            success:function(data){
                        alert(""+data.Message);
            },error:function(data){

                alert("数据加载失败");
            }
        });
    }
</script>
</body>

</html>