<?php
/**
 * Created by PhpStorm.
 * User: 陈武杰
 * Date: 2021/1/13
 * Time: 17:34
 */

namespace App\Admin\Controllers\DataCenter;
use App\Admin\Controllers\Chart\OrderChart;
use App\Admin\Controllers\Sta;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\Dashboard;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\InfoBox;


class FinancialOrderOverview
{
    public function index(Content $content)
    {
        return $content
            ->title('欢迎进入后台管理系统')
            ->description('后台数据中心')
            ->row('<h1 text-align="center">订单走势</h1>')
            ->row(function (Row $row) {
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('今日支付金额', 'dropbox', '', 'green', FinancialSta::getTodayPay()));
                });
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('昨日支付金额', 'dropbox', '', 'green', FinancialSta::getYesterdayPay()));
                });
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('近七日支付金额', 'dropbox', '', 'green', FinancialSta::getSevenDayPay()));
                });
                $row->column(3, function (Column $column) {
                    $column->append(infoBox('近三十日支付金额', 'dropbox', '', 'green', FinancialSta::getOneMonthPay()));
                });
            })
            ->row(function (Row $row){
                (new FinancialOrderChart())->chart($row);
            });
    }

}
/**
 * 消息框
 * @param $name
 * @param $icon
 * @param $link
 * @param $color
 * @param $info
 * @return string HTML
 */

function infoBox($name, $icon, $link, $color, $info)
{
    return (new InfoBox($name, $icon, $color, $link, $info))->render();
}
