#39 - cr fixes
This commit is contained in:
parent
96192c0f2c
commit
e2c3c3b708
@ -7,6 +7,7 @@ namespace Toby\Domain;
|
|||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||||
|
use Toby\Eloquent\Models\User;
|
||||||
|
|
||||||
class TimesheetExport implements WithMultipleSheets
|
class TimesheetExport implements WithMultipleSheets
|
||||||
{
|
{
|
||||||
@ -15,13 +16,9 @@ class TimesheetExport implements WithMultipleSheets
|
|||||||
|
|
||||||
public function sheets(): array
|
public function sheets(): array
|
||||||
{
|
{
|
||||||
$sheets = [];
|
return $this->users
|
||||||
|
->map(fn(User $user) => new TimesheetPerUserSheet($user, $this->month))
|
||||||
foreach ($this->users as $user) {
|
->toArray();
|
||||||
$sheets[] = new TimesheetPerUserSheet($user, $this->month);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sheets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function forUsers(Collection $users): static
|
public function forUsers(Collection $users): static
|
||||||
|
@ -35,6 +35,8 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
|||||||
use RegistersEventListeners;
|
use RegistersEventListeners;
|
||||||
|
|
||||||
protected const HOURS_PER_DAY = 8;
|
protected const HOURS_PER_DAY = 8;
|
||||||
|
protected const START_HOUR = 8;
|
||||||
|
protected const END_HOUR = 16;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected User $user,
|
protected User $user,
|
||||||
@ -79,8 +81,8 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
|||||||
$row = [
|
$row = [
|
||||||
Date::dateTimeToExcel($day),
|
Date::dateTimeToExcel($day),
|
||||||
$day->translatedFormat("l"),
|
$day->translatedFormat("l"),
|
||||||
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(8)) : null,
|
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(static::START_HOUR)) : null,
|
||||||
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(16)) : null,
|
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(static::END_HOUR)) : null,
|
||||||
$workedThisDay ? static::HOURS_PER_DAY : null,
|
$workedThisDay ? static::HOURS_PER_DAY : null,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\DefaultValueBinder;
|
||||||
use Maatwebsite\Excel\Excel;
|
use Maatwebsite\Excel\Excel;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -75,7 +76,7 @@ return [
|
|||||||
"pdf" => Excel::DOMPDF,
|
"pdf" => Excel::DOMPDF,
|
||||||
],
|
],
|
||||||
"value_binder" => [
|
"value_binder" => [
|
||||||
"default" => Maatwebsite\Excel\DefaultValueBinder::class,
|
"default" => DefaultValueBinder::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
"cache" => [
|
"cache" => [
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a
|
<a
|
||||||
:href="`timesheet/${selectedMonth.value}`"
|
:href="`/timesheet/${selectedMonth.value}`"
|
||||||
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
Pobierz plik excel
|
Pobierz plik excel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user