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') + +