From c9bfbb4782f887624ff7c2b5346831b5db57e8d0 Mon Sep 17 00:00:00 2001 From: Patrick Barnhardt Date: Mon, 13 Nov 2023 14:18:01 -0500 Subject: [PATCH] edit display of single event setup display of branding elements for the event, also setup the QRCode system and a quick event page slug element. The QRCode will link to the current event slug. --- admin/view/event_single.php | 103 ++++++++++++++++++++------------ includes/classes/events.inc.php | 41 +++++++++++++ 2 files changed, 105 insertions(+), 39 deletions(-) diff --git a/admin/view/event_single.php b/admin/view/event_single.php index aa293b30..ec6e157e 100644 --- a/admin/view/event_single.php +++ b/admin/view/event_single.php @@ -4,6 +4,13 @@ die('Error: Invalid request'); } +use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Data\QRMatrix; +use chillerlan\QRCode\Output\QROutputInterface; + +//autoload composer dependencies +require_once __DIR__ . '/../../vendor/autoload.php'; + //event class $event = new Event(); @@ -22,8 +29,8 @@

getEventName($event_id); ?>

@@ -35,12 +42,9 @@ Event Information
- Back to Events - Edit Event - Delete Event + Back to Events + Edit Event + Delete Event
@@ -50,31 +54,52 @@ class="btn btn-danger btn-sm">Delete Event

Event Details

Event Name: getEventName($event_id); ?>

+

Event URL Slug: getEventSlug($event_id); ?> +

Event Date: getEventDate($event_id); ?>

Event Location: getEventLocation($event_id); ?>

-

Event Address: +

+

Event Address: + getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); + $address = urlencode($address); + ?> + getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); ?> +

+
+
+
+
+
+

Event QRCode: (Links to the event page)

+
+ getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); - $address = urlencode($address); + $qrCodeData = APP_URL . '/index.php?event=' . $event->getEventSlug($event_id); + $qrCodeOptions = new QROptions; + $qrCodeOptions->version = 10; + $qrCodeOptions->outputType = QRCode::OUTPUT_IMAGE_JPG; + $qrCodeOptions->scale = 20; + $qrCodeOptions->outputBase64 = false; + $qrCode = (new QRCode($qrCodeOptions))->render($qrCodeData); // per the documentation, https://php-qrcode.readthedocs.io/en/main/Usage/Quickstart.html + + //output the QRCode JPG + echo 'QRCode'; ?> - getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); ?> -

+
-
-


Event Branding

Event Logo:

- Event Logo + getEventLogo($event_id); ?>" alt="Event Logo" style="max-width: 200px; max-height: auto;">

Event Banner:

- Event Banner + getEventBanner($event_id); ?>" alt="Event Banner" style="max-width: 200px; max-height: auto;">

School Logo:

- School Logo + School Logo

School Primary Color:

@@ -94,18 +119,18 @@ class="btn btn-danger btn-sm">Delete Event - - Students List - + + Students List + - - First Name - Last Name - Email - Degree - + + First Name + Last Name + Email + Degree + @@ -117,16 +142,16 @@ class="btn btn-danger btn-sm">Delete Event } else { foreach ($students as $eventStudent) { ?> - - getStudentFirstName($eventStudent['student_id']); ?> - - getStudentLastName($eventStudent['student_id']); ?> - - getStudentEmail($eventStudent['student_id']); ?> - - getStudentDegree($eventStudent['student_id']); ?> - - + + getStudentFirstName($eventStudent['student_id']); ?> + + getStudentLastName($eventStudent['student_id']); ?> + + getStudentEmail($eventStudent['student_id']); ?> + + getStudentDegree($eventStudent['student_id']); ?> + + diff --git a/includes/classes/events.inc.php b/includes/classes/events.inc.php index 7f16aac1..41a1b7fb 100644 --- a/includes/classes/events.inc.php +++ b/includes/classes/events.inc.php @@ -640,6 +640,27 @@ public function setEventBanner(int $id, string $banner) $stmt->execute(); } + /** + * Set event logo and banner + * + * does both, helps with delays in the sql execution which appeared to keep them from adding when run back to back + * + * @param int $id event id + * @param string $logo event logo path + * @param string $banner event banner path + */ + public function setEventLogoAndBanner(int $id, string $logo, string $banner) + { + //SQL statement to set the event logo + $sql = "INSERT INTO event_branding (event_id, event_logo, event_banner) VALUES (?, ?, ?)"; + //prepare the statement + $stmt = $this->mysqli->prepare($sql); + //bind the parameters + $stmt->bind_param("iss", $id, $logo, $banner); + //execute the statement + $stmt->execute(); + } + /** * Update event logo * @@ -676,6 +697,26 @@ public function updateEventBanner(int $id, string $banner) $stmt->execute(); } + /** + * Update event logo and banner + * does both, helps with delays in the sql execution which appeared to keep them from adding when run back to back + * + * @param int $id event id + * @param string $logo event logo path + * @param string $banner event banner path + */ + public function updateEventLogoAndBanner(int $id, string $logo, string $banner) + { + //SQL statement to update the event logo + $sql = "UPDATE event_branding SET event_logo = ?, event_banner = ? WHERE event_id = ?"; + //prepare the statement + $stmt = $this->mysqli->prepare($sql); + //bind the parameters + $stmt->bind_param("ssi", $logo, $banner, $id); + //execute the statement + $stmt->execute(); + } + /** * Update event *