<?php

/* ========================================================================
 * $Id: index.php 3033 2020-07-08 13:43:26Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# design
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $pagedata=array();
    $pagedata['title']='管理首页';
    $pagedata['infos']=array();
    $pagedata['infos'][]=array(
      'name'=>'今日订单总数',
      'num'=>$G['this']->data()->open('orders')->rows("1"),
      'icon'=>'fa fa-sitemap',
      'href'=>'#',
      'bg'=>'bg-aqua',
    );
    
    $today=date('Y-m-d');
    $todaytime=strtotime($today);
    
    $options=array();
    $amt=0;
    $T=$G['this']->data()->open('orders')->record("addtime>=$todaytime");
    foreach($T as $rs){
      $amt+=$rs['price'];
    }
    $pagedata['infos'][]=array(
      'name'=>'今日订单总金额',
      'num'=>$amt,
      'icon'=>'fa fa-users',
      'href'=>'#',
      'bg'=>'bg-green',
    );
    $pagedata['infos'][]=array(
      'name'=>'商品数量',
      'num'=>$G['this']->data()->open('products')->rows("1"),
      'icon'=>'fa fa-heart',
      'href'=>'#',
      'bg'=>'bg-yellow',
    );
    $pagedata['infos'][]=array(
      'name'=>'分类数量',
      'num'=>$G['this']->data()->open('categorys')->rows("1"),
      'icon'=>'fa fa-envelope-o',
      'href'=>'#',
      'bg'=>'bg-red',
    );
    $pagedata['licence']=onez('bs.app.shipments')->licence('info');
    $A['pagedata']=$pagedata;
    
    
    $datatable=$this->load('datatable');
    


    $datatable->set('fields','id');

    $datatable->add('订单号','token');
    $datatable->add('名称','subject');
    $datatable->add('IP','ip');
    $datatable->add('支付金额','price');
    $datatable->add('支付时间','addtime',array('type'=>'time',));
    $datatable->add('支付方式','paytype',array('function'=>function($rs){
      global $G;
      $T=$G['this']->data()->open('bs.pay.setting')->one("token='$rs[paytype]'");
      return $T['name'];
    }));
    $datatable->add('状态','status');
    $datatable->output($A['pagedata'],array(
      'table'=>'orders',

      'where'=>"1 order by id desc",
      'pagesize'=>20,
    ));
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));

?>
<section class="content" style="margin-bottom:-30px">
<div class="row">
  <div class="col-lg-3 col-xs-6" v-for="item in pagedata.infos">
    <!-- small box -->
    <div class="small-box" :class="item.bg||'bg-aqua'">
      <div class="inner">
        <h3>{{item.num}}</h3>
        <p>{{item.name}}</p>
      </div>
      <div class="icon">
        <i :class="item.icon"></i>
      </div>
      <a :href="item.href" class="small-box-footer">查看详情 <i class="fa fa-arrow-circle-right"></i></a>
    </div>
  </div>
  <!-- ./col -->
</div>
<div class="box box-info">
  <div class="box-header with-border">
    <h3 class="box-title">授权信息</h3>
  </div>
  <div class="box-body" v-html="pagedata.licence">
    
  </div>
</div>
</section>
<?php 
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));