Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/utilities/NotificationLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use craft\base\Utility;
use craft\helpers\DateTimeHelper;
use DateTime;
use DateTimeZone;
use doublesecretagency\notifier\records\Log;
use Exception;

Expand Down Expand Up @@ -131,15 +132,17 @@ private static function _getLogs(string $date): array
$dayLog = [];

// Get system timezone
$timeZone = Craft::$app->timeZone;
$systemTimeZone = new DateTimeZone(Craft::$app->timeZone);
$dateObj = new DateTime($date, $systemTimeZone);

// Convert dateCreated to the system timezone
$dateCreated = "DATE(CONVERT_TZ(dateCreated, 'UTC', '{$timeZone}'))";
// Start and end of the day in system timezone
$startOfDay = (clone $dateObj)->setTime(0, 0, 0)->format('Y-m-d H:i:s');
$endOfDay = (clone $dateObj)->setTime(23, 59, 59)->format('Y-m-d H:i:s');

// Get all envelopes on selected day
$envelopes = Log::find()
->where([$dateCreated => $date])
->andWhere(['type' => 'envelope'])
->where(['type' => 'envelope'])
->andWhere(['between', 'dateCreated', $startOfDay, $endOfDay])
->orderBy('id')
->all();

Expand Down