mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 04:02:15 +01:00
Fixed timezones in detailed export reports
This commit is contained in:
@@ -177,6 +177,8 @@ class TimeEntryController extends Controller
|
|||||||
if ($format === ExportFormat::PDF && ! $this->canAccessPremiumFeatures($organization)) {
|
if ($format === ExportFormat::PDF && ! $this->canAccessPremiumFeatures($organization)) {
|
||||||
throw new FeatureIsNotAvailableInFreePlanApiException;
|
throw new FeatureIsNotAvailableInFreePlanApiException;
|
||||||
}
|
}
|
||||||
|
$user = $this->user();
|
||||||
|
$timezone = $user->timezone;
|
||||||
|
|
||||||
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member);
|
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member);
|
||||||
$timeEntriesQuery->with([
|
$timeEntriesQuery->with([
|
||||||
@@ -190,7 +192,7 @@ class TimeEntryController extends Controller
|
|||||||
$folderPath = 'exports';
|
$folderPath = 'exports';
|
||||||
$path = $folderPath.'/'.$filename;
|
$path = $folderPath.'/'.$filename;
|
||||||
if ($format === ExportFormat::CSV) {
|
if ($format === ExportFormat::CSV) {
|
||||||
$export = new TimeEntriesDetailedCsvExport(config('filesystems.private'), $folderPath, $filename, $timeEntriesQuery, 1000);
|
$export = new TimeEntriesDetailedCsvExport(config('filesystems.private'), $folderPath, $filename, $timeEntriesQuery, 1000, $timezone);
|
||||||
$export->export();
|
$export->export();
|
||||||
} elseif ($format === ExportFormat::PDF) {
|
} elseif ($format === ExportFormat::PDF) {
|
||||||
if (config('services.gotenberg.url') === null) {
|
if (config('services.gotenberg.url') === null) {
|
||||||
@@ -224,7 +226,7 @@ class TimeEntryController extends Controller
|
|||||||
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
||||||
} else {
|
} else {
|
||||||
Excel::store(
|
Excel::store(
|
||||||
new TimeEntriesDetailedExport($timeEntriesQuery, $format),
|
new TimeEntriesDetailedExport($timeEntriesQuery, $format, $timezone),
|
||||||
$path,
|
$path,
|
||||||
config('filesystems.private'),
|
config('filesystems.private'),
|
||||||
$format->getExportPackageType(),
|
$format->getExportPackageType(),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Service\ReportExport;
|
|||||||
|
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Service\IntervalService;
|
use App\Service\IntervalService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,6 +30,15 @@ class TimeEntriesDetailedCsvExport extends CsvExport
|
|||||||
|
|
||||||
protected const string CARBON_FORMAT = 'Y-m-d H:i:s';
|
protected const string CARBON_FORMAT = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
|
private string $timezone;
|
||||||
|
|
||||||
|
public function __construct(string $disk, string $folderPath, string $filename, Builder $builder, int $chunk, string $timezone)
|
||||||
|
{
|
||||||
|
parent::__construct($disk, $folderPath, $filename, $builder, $chunk);
|
||||||
|
|
||||||
|
$this->timezone = $timezone;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TimeEntry $model
|
* @param TimeEntry $model
|
||||||
*/
|
*/
|
||||||
@@ -43,8 +53,8 @@ class TimeEntriesDetailedCsvExport extends CsvExport
|
|||||||
'Project' => $model->project?->name,
|
'Project' => $model->project?->name,
|
||||||
'Client' => $model->client?->name,
|
'Client' => $model->client?->name,
|
||||||
'User' => $model->user->name,
|
'User' => $model->user->name,
|
||||||
'Start' => $model->start,
|
'Start' => $model->start->timezone($this->timezone),
|
||||||
'End' => $model->end,
|
'End' => $model->end->timezone($this->timezone),
|
||||||
'Duration' => $duration !== null ? $interval->format($model->getDuration()) : null,
|
'Duration' => $duration !== null ? $interval->format($model->getDuration()) : null,
|
||||||
'Duration (decimal)' => $duration?->totalHours,
|
'Duration (decimal)' => $duration?->totalHours,
|
||||||
'Billable' => $model->billable ? 'Yes' : 'No',
|
'Billable' => $model->billable ? 'Yes' : 'No',
|
||||||
|
|||||||
@@ -35,13 +35,16 @@ class TimeEntriesDetailedExport implements FromQuery, ShouldAutoSize, WithColumn
|
|||||||
|
|
||||||
private ExportFormat $exportFormat;
|
private ExportFormat $exportFormat;
|
||||||
|
|
||||||
|
private string $timezone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder<TimeEntry> $builder
|
* @param Builder<TimeEntry> $builder
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $builder, ExportFormat $exportFormat)
|
public function __construct(Builder $builder, ExportFormat $exportFormat, string $timezone)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
$this->exportFormat = $exportFormat;
|
$this->exportFormat = $exportFormat;
|
||||||
|
$this->timezone = $timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,7 +124,7 @@ class TimeEntriesDetailedExport implements FromQuery, ShouldAutoSize, WithColumn
|
|||||||
$model->client?->name,
|
$model->client?->name,
|
||||||
$model->user->name,
|
$model->user->name,
|
||||||
Date::dateTimeToExcel($model->start),
|
Date::dateTimeToExcel($model->start),
|
||||||
$model->end !== null ? Date::dateTimeToExcel($model->end) : null,
|
$model->end !== null ? Date::dateTimeToExcel($model->end->timezone($this->timezone)) : null,
|
||||||
$duration !== null ? $interval->format($duration) : null,
|
$duration !== null ? $interval->format($duration) : null,
|
||||||
$duration?->totalHours,
|
$duration?->totalHours,
|
||||||
$model->billable ? 'Yes' : 'No',
|
$model->billable ? 'Yes' : 'No',
|
||||||
@@ -134,8 +137,8 @@ class TimeEntriesDetailedExport implements FromQuery, ShouldAutoSize, WithColumn
|
|||||||
$model->project?->name,
|
$model->project?->name,
|
||||||
$model->client?->name,
|
$model->client?->name,
|
||||||
$model->user->name,
|
$model->user->name,
|
||||||
$model->start->format('Y-m-d H:i:s'),
|
$model->start->timezone($this->timezone)->format('Y-m-d H:i:s'),
|
||||||
$model->end?->format('Y-m-d H:i:s'),
|
$model->end?->timezone($this->timezone)?->format('Y-m-d H:i:s'),
|
||||||
$duration !== null ? (int) floor($duration->totalHours).':'.$duration->format('%I:%S') : null,
|
$duration !== null ? (int) floor($duration->totalHours).':'.$duration->format('%I:%S') : null,
|
||||||
$duration?->totalHours,
|
$duration?->totalHours,
|
||||||
$model->billable ? 'Yes' : 'No',
|
$model->billable ? 'Yes' : 'No',
|
||||||
|
|||||||
Reference in New Issue
Block a user