<?php

use Dipper\Excel\Facades\Excel;
use Illuminate\Support\Facades\Storage;
use App\Domains\Export\Services\ExportService;
use App\Domains\Stats\Exports\CompanyYearReportExport;

require_once realpath(dirname(__FILE__) . '/TestCase.php');

$disk = 'public';

for ($i = 2017; $i <= 2020; $i++) {
    $conditions = [
        "limit" => 0,
        "type" => [0, 1],
        "year" => "2018",
        "sell_starttime" => "$i-01-01 00:00:00",
        "sell_endtime" => "$i-12-31 23:59:59",
    ];
    $filename = "${i}销售在2018年报表.xlsx";
    $export = new CompanyYearReportExport($conditions);
    Excel::store($export, $filename, 'public');
    $url = Storage::disk($disk)->url($filename);
    echo $url . PHP_EOL;

    for ($j = 1; $j <= 12; $j++) {
        $conditions = [
            "limit" => 0,
            "type" => [0, 1],
            "month" => "2019-$j",
            "sell_starttime" => "$i-01-01 00:00:00",
            "sell_endtime" => "$i-12-31 23:59:59",
        ];
        
        $filename = "${i}销售在2019-${j}月报表.xlsx";
        $export = new CompanyYearReportExport($conditions);
        Excel::store($export, $filename, 'public');
        $url = Storage::disk($disk)->url($filename);
        echo $url . PHP_EOL;
    }
    

    $conditions = [
        "limit" => 0,
        "type" => [0, 1],
        "year" => "2020",
        "sell_starttime" => "$i-01-01 00:00:00",
        "sell_endtime" => "$i-12-31 23:59:59",
    ];
    $filename = "${i}销售在2020年报表.xlsx";
    $export = new CompanyYearReportExport($conditions);
    Excel::store($export, $filename, 'public');
    $url = Storage::disk($disk)->url($filename);
    echo $url . PHP_EOL;
}
