Skip to content

Commit f461509

Browse files
committed
assets
1 parent 3f11e24 commit f461509

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<p align="center"><img src="https://verbb.imgix.net/plugins/events/events-icon.svg" width="100" height="100" alt="Events icon"></p>
1+
<p align="center"><img src="https://assets.verbb.io/plugins/events/events-icon.svg" width="100" height="100" alt="Events icon"></p>
22
<h1 align="center">Events for Craft CMS</h1>
33

44
Events is a Craft CMS plugin for a a full-featured event management and ticketing plugin for Craft Commerce. Sell tickets to events, create tickets, manage attendees and more.

docs/template-guides/pdf-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Below we've prepared a ready-to-go template, complete with provided CSS to get y
192192
<body>
193193
{% for ticket in tickets.all() %}
194194
<div class="ticket">
195-
<img class="ticket-img" src="https://verbb.imgix.net/plugins/events/ticket-trans-notext.jpg" />
195+
<img class="ticket-img" src="https://assets.verbb.io/plugins/events/ticket-trans-notext.jpg" />
196196
197197
<div id="event-info">
198198
<span class="label">EVENT</span>

src/migrations/m240921_000000_events3.php

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use craft\db\Migration;
1414
use craft\db\Query;
1515
use craft\db\Table;
16+
use craft\helpers\App;
1617
use craft\helpers\Json;
1718
use craft\helpers\MigrationHelper;
1819
use craft\migrations\BaseContentRefactorMigration;
@@ -21,6 +22,7 @@
2122

2223
use Exception;
2324
use ReflectionClass;
25+
use DateTime;
2426

2527
use yii\db\Expression;
2628

@@ -31,6 +33,9 @@ class m240921_000000_events3 extends Migration
3133

3234
public function safeUp(): bool
3335
{
36+
// Increase memory limit for this migration
37+
App::maxPowerCaptain();
38+
3439
$this->update(Table::ELEMENTS, ['type' => LegacyTicket::class], ['type' => Ticket::class]);
3540
$this->update(Table::ELEMENTS, ['type' => LegacyTicketType::class], ['type' => TicketType::class]);
3641

@@ -174,7 +179,7 @@ public function safeUp(): bool
174179
}
175180

176181
// Move columns to legacy
177-
$this->update('{{%events_purchased_tickets}}', ['legacyTicketId' => new Expression('ticketId')]);
182+
$this->update('{{%events_purchased_tickets}}', ['legacyTicketId' => new Expression('"ticketId"')]);
178183
$this->update('{{%events_purchased_tickets}}', ['ticketId' => null]);
179184

180185
// Setup Indexes
@@ -264,7 +269,7 @@ public function safeUp(): bool
264269
$purchasedTicketIds = (new Query())
265270
->select(['id'])
266271
->from('{{%events_purchased_tickets}}')
267-
->where(['legacyTicketId' => $ticketId])
272+
->where(['legacyTicketId' => (string)$ticketId])
268273
->column();
269274

270275
if ($purchasedTicketIds) {
@@ -327,16 +332,36 @@ public function safeUp(): bool
327332
->all();
328333

329334
foreach ($events as $event) {
335+
$startDate = $event['startDate'] ?? null;
336+
$endDate = $event['endDate'] ?? null;
337+
338+
// Fix invalid date combinations
339+
if (!$startDate && !$endDate) {
340+
// Both null: set to 1/1/1970 12am-1am
341+
$startDate = '1970-01-01 00:00:00';
342+
$endDate = '1970-01-01 01:00:00';
343+
} else if (!$startDate) {
344+
// Start date null: set to end date - 1 hour
345+
$endDateObj = new DateTime($endDate);
346+
$endDateObj->modify('-1 hour');
347+
$startDate = $endDateObj->format('Y-m-d H:i:s');
348+
} else if (!$endDate || strtotime($endDate) < strtotime($startDate)) {
349+
// End date null or before start: set to start date + 1 hour
350+
$startDateObj = new DateTime($startDate);
351+
$startDateObj->modify('+1 hour');
352+
$endDate = $startDateObj->format('Y-m-d H:i:s');
353+
}
354+
330355
// Find or create (in case we run this again)
331356
$session = Session::find()
332357
->eventId($event['id'])
333-
->startDate($event['startDate'])
334-
->endDate($event['endDate'])
358+
->startDate($startDate)
359+
->endDate($endDate)
335360
->one() ?? new Session();
336361

337362
$session->setAttributes([
338-
'startDate' => $event['startDate'],
339-
'endDate' => $event['endDate'],
363+
'startDate' => $startDate,
364+
'endDate' => $endDate,
340365
'allDay' => (bool)$event['allDay'],
341366
], false);
342367

@@ -447,7 +472,7 @@ public function safeUp(): bool
447472
'legacyTicketTypeId' => $legacyTicket['typeId'],
448473
], ['id' => $ticketType->id]);
449474

450-
$this->update('{{%events_purchased_tickets}}', ['ticketTypeId' => $ticketType->id], ['legacyTicketId' => $legacyTicket['id']]);
475+
$this->update('{{%events_purchased_tickets}}', ['ticketTypeId' => $ticketType->id], ['legacyTicketId' => (string)$legacyTicket['id']]);
451476
}
452477

453478

@@ -469,13 +494,13 @@ public function safeUp(): bool
469494
}
470495

471496
$legacyTicketId = (new Query())
472-
->select(['legacyTicketId'])
497+
->select(['"legacyTicketId"'])
473498
->from('{{%events_ticket_types}}')
474499
->where(['id' => $ticketType->id])
475500
->scalar();
476501

477502
$legacyTicketTypeId = (new Query())
478-
->select(['typeId'])
503+
->select(['"typeId"'])
479504
->from('{{%events_legacy_tickets}}')
480505
->where(['id' => $legacyTicketId])
481506
->scalar();
@@ -485,7 +510,7 @@ public function safeUp(): bool
485510
'legacyTicketTypeId' => $legacyTicketTypeId,
486511
], ['id' => $ticket->id]);
487512

488-
$this->update('{{%events_purchased_tickets}}', ['ticketId' => $ticket->id], ['legacyTicketId' => $legacyTicketId]);
513+
$this->update('{{%events_purchased_tickets}}', ['ticketId' => $ticket->id], ['legacyTicketId' => (string)$legacyTicketId]);
489514
}
490515
}
491516

0 commit comments

Comments
 (0)