48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Exports;
|
||
|
|
|
||
|
|
use App\Exports\Sheets\LoveQuarterIncomDetail;
|
||
|
|
use App\Exports\Sheets\LoveQuarterIncome;
|
||
|
|
use App\Exports\Sheets\SaasLoveQuarterIncome;
|
||
|
|
use App\Exports\Sheets\SaasQuarterIncome;
|
||
|
|
use App\Exports\Sheets\SaasQuarterIncomeDetail;
|
||
|
|
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||
|
|
|
||
|
|
class ReportQuarterExport implements WithMultipleSheets
|
||
|
|
{
|
||
|
|
|
||
|
|
protected $date_arr;
|
||
|
|
public function __construct($year)
|
||
|
|
{
|
||
|
|
$date_arr = [];
|
||
|
|
for ($i = 1; $i <= 12; $i++) {
|
||
|
|
$start_date = date('Y-'.$i.'-01', strtotime($year));
|
||
|
|
$end_date = date("Y-m-d", strtotime('+1 month', strtotime($start_date)));
|
||
|
|
if ($i <= 3 ) {
|
||
|
|
$date_arr[0][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||
|
|
}elseif ($i > 3 && $i <= 6) {
|
||
|
|
$date_arr[1][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||
|
|
}elseif ($i > 6 && $i <= 9) {
|
||
|
|
$date_arr[2][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||
|
|
}else {
|
||
|
|
$date_arr[3][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
$this->date_arr = $date_arr;
|
||
|
|
}
|
||
|
|
public function sheets(): array
|
||
|
|
{
|
||
|
|
$sheets = [];
|
||
|
|
foreach ($this->date_arr as $key=>$date_arr) {
|
||
|
|
$sheets[] = new SaasLoveQuarterIncome($key, $date_arr);
|
||
|
|
$sheets[] = new SaasQuarterIncome($key, $date_arr);
|
||
|
|
$sheets[] = new SaasQuarterIncomeDetail($key, $date_arr);
|
||
|
|
$sheets[] = new LoveQuarterIncome($key, $date_arr);
|
||
|
|
$sheets[] = new LoveQuarterIncomDetail($key, $date_arr);
|
||
|
|
}
|
||
|
|
return $sheets;
|
||
|
|
}
|
||
|
|
}
|