diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php new file mode 100644 index 0000000..2a30c17 --- /dev/null +++ b/app/Http/Controllers/ReportController.php @@ -0,0 +1,63 @@ +year; $i <= date("Y"); $i++) { + for ($m = 1; $m <= 12; $m++) { + if($i == $oldesDate->year && $m < $oldesDate->month) { + continue; + } + if($i == date("Y") && $m > date("m")) { + continue; + } + $avalibleReports[] = ["year" => $i, "month" => $m]; + } + } + + return view("dashboard.reports", ["avalibleReports" => $avalibleReports]); + } + + public function spaceReport($year, $month) { + $reportData = DB::select("SELECT * FROM storage WHERE tenant = ".(int)session("current_tenant_id")." AND `year` = ".(int)$year." AND `month` = ".(int)$month.";"); + $report = "year;month;day;hour;size\n"; + foreach ($reportData as $reportLine) { + $report .= $reportLine->year.";".$reportLine->month.";".$reportLine->day.";".$reportLine->hour.";".$reportLine->size."\n"; + } + + $res = new Response(); + $res->header("Content-type", "text/csv"); + $res->header("Content-Disposition", "attachment; filename=".$year."_".$month."_space.csv"); + $res->setContent($report); + return $res; + } + + public function traficReport($year, $month) { + $reportData = DB::select("SELECT * FROM traffic WHERE tenant = ".(int)session("current_tenant_id")." AND `year` = ".(int)$year." AND `month` = ".(int)$month.";"); + $report = "year;month;day;hour;gallery;traffic\n"; + foreach ($reportData as $reportLine) { + $report .= $reportLine->year.";".$reportLine->month.";".$reportLine->day.";".$reportLine->hour.";".$reportLine->gallery.";".$reportLine->traffic."\n"; + } + + $res = new Response(); + $res->header("Content-type", "text/csv"); + $res->header("Content-Disposition", "attachment; filename=".$year."_".$month."_trafficg.csv"); + $res->setContent($report); + return $res; + } + +} diff --git a/resources/views/dashboard/reports.blade.php b/resources/views/dashboard/reports.blade.php new file mode 100644 index 0000000..4ea1d97 --- /dev/null +++ b/resources/views/dashboard/reports.blade.php @@ -0,0 +1,28 @@ +@extends('layout/template') + +@section('content') + +
+
+

Reports

+
+
+
+
+ +
+
+ + + +@endsection diff --git a/resources/views/layout/template.blade.php b/resources/views/layout/template.blade.php index a483149..662b206 100644 --- a/resources/views/layout/template.blade.php +++ b/resources/views/layout/template.blade.php @@ -25,6 +25,7 @@ diff --git a/routes/web.php b/routes/web.php index a23a4d1..839a4d5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -49,6 +49,9 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function Route::post("/s/watermark", [\App\Http\Controllers\TenantController::class, 'watermarkSave']); Route::get("/s/watermark/image", [\App\Http\Controllers\PublicController::class, "returnWatermakeFile"]); Route::get("/s/watermark/delete", [\App\Http\Controllers\TenantController::class, "deleteWatermark"]); + Route::get("s/reports", [\App\Http\Controllers\ReportController::class, "showReportList"]); + Route::get("s/reports/{year}/{month}/space", [\App\Http\Controllers\ReportController::class, "spaceReport"]); + Route::get("s/reports/{year}/{month}/traffic", [\App\Http\Controllers\ReportController::class, "traficReport"]); }); Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);