Skip to content

Commit

Permalink
export filename based on user territory timezone #3053
Browse files Browse the repository at this point in the history
  • Loading branch information
numew authored and hmeneuvrier committed Sep 18, 2024
1 parent 3846e8a commit 7db7a87
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Messenger/MessageHandler/ListExportMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Service\Mailer\NotificationMailerRegistry;
use App\Service\Mailer\NotificationMailerType;
use App\Service\Signalement\Export\SignalementExportLoader;
use App\Service\TimezoneProvider;
use PhpOffice\PhpSpreadsheet\Writer\Csv;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -42,7 +43,8 @@ public function __invoke(ListExportMessage $listExportMessage): void
}

if (isset($writer)) {
$datetimeStr = (new \DateTimeImmutable())->format('Ymd-Hi');
$timezone = $user->getTerritory()?->getTimezone() ?? TimezoneProvider::TIMEZONE_EUROPE_PARIS;
$datetimeStr = (new \DateTimeImmutable())->setTimezone(new \DateTimeZone($timezone))->format('Ymd-Hi');
$filename = 'export-histologe-'.$listExportMessage->getUserId().'-'.$datetimeStr.'.'.$format;
$tmpFilepath = $this->parameterBag->get('uploads_tmp_dir').$filename;
$writer->save($tmpFilepath);
Expand Down

0 comments on commit 7db7a87

Please sign in to comment.