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

    <include file="Common/head" />
    <style type="text/css">
      .am-form{width:500px;margin-left:20px;float: left;}
      #editor {font-size: 12px;}
      .am-form label span{font-size: 13px;font-weight:normal;}
      .am-form label p{display: inline;color: #f00;}
      .am-form .am-form-inline-2 input[type=file]{width: 246px}
      .am-form .am-form-inline-3 input[type=text]{width: 160px}
      .am-form .am-form-inline-3 select{width: 160px}
      .am-form .am-form-inline-4 input[type=text]{width: 120px}
      .am-form .am-form-inline-4 select{width: 120px}
      .two-input {display: flex;}
      .am-form .am-form-inline-4 .two-input input[type=text]{width: 50px;}
      .am-form .am-form-inline-4 .two-input input[type=text]:nth-of-type(2){width: 20px;padding: 8px 2px;cursor: default;background: #fff; border-left: 0; border-right: 0;}

      .am-form input[type=file]{display:none;}
      .am-form .am-form-group img{height: 60px;min-width: 60px;max-width: 100px;margin-top: 2px;display: block;cursor: pointer;}
      input[readonly]{background-color: #fff!important;cursor: default!important;}
      .am-form-group input{
        height: 30px;font-size: 14px;margin-bottom: 10px !important;
      }
      .am-form-group select{
        height: 30px;font-size: 14px;margin-bottom: 10px !important;
      }
    </style>
  </head>
  <body>
  <include file="Common/header" />

  <div class="am-cf admin">

    <include file="Common/sidebar" nav="$nav" navv="$nav"/>
    <div class="content-page" style="background: white;">

      <div class="admin-content" style="background: white;">
        <div class="admin-content-body">
          <div class="am-cf am-padding">
            <div class="am-fl am-cf">
              <strong class="am-text-primary am-text-lg">决策支持</strong> / 
              <small>商品销售明细</small>
            </div>
          </div>
          <hr style="margin-top:0px;">
            <form action="{:U('/Smi/Support/sales_subsidiary')}" 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('/Smi/Support/sales_subsidiary')}">清空</a>&nbsp;
                  <button class="am-btn am-btn-secondary export">导出当前筛选状态的Excel</button>
                </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;数量：{$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-warning">已下单</span>'; break;
                              case 3: echo '<span class="am-badge am-badge-success">已完成</span>'; break;
                              case 4: echo '<span class="am-badge am-badge-primary">已退款</span>'; break;
                              case 5: echo '<span class="am-badge am-badge-primary">已取消</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>
    </div>
  </div>
  <include file="Common/footer" />
  </body>
  </html>