Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
edit display of single event
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crimsonstrife committed Nov 13, 2023
1 parent 3bb2a8f commit c9bfbb4
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 39 deletions.
103 changes: 64 additions & 39 deletions admin/view/event_single.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -22,8 +29,8 @@
<link rel="stylesheet" href="<?php echo getLibraryPath() . 'leaflet/leaflet.css'; ?>">
<link rel="stylesheet" href="<?php echo getLibraryPath() . 'leaflet-geosearch/geosearch.css'; ?>">
<script>
var mapLocationTitle = "<?php echo $event->getEventLocation($event_id); ?>";
var address = "<?php echo $school->getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); ?>";
var mapLocationTitle = "<?php echo $event->getEventLocation($event_id); ?>";
var address = "<?php echo $school->getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); ?>";
</script>
<div class="container-fluid px-4">
<h1 class="mt-4"><?php echo $event->getEventName($event_id); ?></h1>
Expand All @@ -35,12 +42,9 @@
Event Information
</div>
<div class="card-buttons">
<a href="<?php echo APP_URL . '/admin/dashboard.php?view=events&event=list'; ?>"
class="btn btn-primary btn-sm">Back to Events</a>
<a href="<?php echo APP_URL . '/admin/dashboard.php?view=events&event=edit&action=edit&id=' . $event_id; ?>"
class="btn btn-primary btn-sm">Edit Event</a>
<a href="<?php echo APP_URL . '/admin/dashboard.php?view=events&event=delete&id=' . $event_id; ?>"
class="btn btn-danger btn-sm">Delete Event</a>
<a href="<?php echo APP_URL . '/admin/dashboard.php?view=events&event=list'; ?>" class="btn btn-primary btn-sm">Back to Events</a>
<a href="<?php echo APP_URL . '/admin/dashboard.php?view=events&event=edit&action=edit&id=' . $event_id; ?>" class="btn btn-primary btn-sm">Edit Event</a>
<a href="<?php echo APP_URL . '/admin/dashboard.php?view=events&event=delete&id=' . $event_id; ?>" class="btn btn-danger btn-sm">Delete Event</a>
</div>
</div>
<div class="card-body">
Expand All @@ -50,31 +54,52 @@ class="btn btn-danger btn-sm">Delete Event</a>
<h3>Event Details</h3>
<div id="info" class="">
<p><strong>Event Name:</strong> <?php echo $event->getEventName($event_id); ?></p>
<p><strong>Event URL Slug:</strong> <a href="<?php echo APP_URL . '/index.php?event=' . $event->getEventSlug($event_id); ?>"><?php echo $event->getEventSlug($event_id); ?></a>
</p>
<p><strong>Event Date:</strong> <?php echo $event->getEventDate($event_id); ?></p>
<p><strong>Event Location:</strong> <?php echo $event->getEventLocation($event_id); ?></p>
<!-- Formatted School address -->
<p><strong>Event Address:</strong>
<div>
<p><strong>Event Address:</strong>
<?php
//encode the address as a url for google maps - this will be used to link to google maps per Google documentation https://developers.google.com/maps/documentation/urls/get-started
$address = $school->getFormattedSchoolAddress(intval($event->getEventLocationId($event_id)));
$address = urlencode($address);
?>
<a href="https://www.google.com/maps/search/?api=1&query=<?php echo $address; ?>" target="_blank"><?php echo $school->getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); ?></a>
</p>
</div>
<div id="map"></div>
</div>
<br>
<div>
<p><strong>Event QRCode:</strong> (Links to the event page)</p>
<div>
<!-- QRCode -->
<?php
//encode the address as a url for google maps - this will be used to link to google maps per Google documentation https://developers.google.com/maps/documentation/urls/get-started
$address = $school->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 '<img src="' . $qrCode . '" alt="QRCode" style="max-width: 200px; max-height: auto;">';
?>
<a href="https://www.google.com/maps/search/?api=1&query=<?php echo $address; ?>"
target="_blank"><?php echo $school->getFormattedSchoolAddress(intval($event->getEventLocationId($event_id))); ?></a>
</p>
</div>
</div>
<div id="map"></div>
<br>
<hr>
<br>
<div id="eventBranding">
<h3>Event Branding</h3>
<p><strong>Event Logo:</strong></p>
<img src="#" alt="Event Logo" style="max-width: 100%; max-height: 100%;">
<img src="<?php echo APP_URL . "/public/content/uploads/" . $event->getEventLogo($event_id); ?>" alt="Event Logo" style="max-width: 200px; max-height: auto;">
<p><strong>Event Banner:</strong></p>
<img src="#" alt="Event Banner" style="max-width: 100%; max-height: 100%;">
<img src="<?php echo APP_URL . "/public/content/uploads/" . $event->getEventBanner($event_id); ?>" alt="Event Banner" style="max-width: 200px; max-height: auto;">
<p><strong>School Logo:</strong></p>
<img src="#" alt="School Logo" style="max-width: 100%; max-height: 100%;">
<img src="#" alt="School Logo" style="max-width: 200px; max-height: auto;">
<p><strong>School Primary Color:</strong></p>
<div style="width: 100px; height: 100px; background-color: #000000;"></div>
</div>
Expand All @@ -94,18 +119,18 @@ class="btn btn-danger btn-sm">Delete Event</a>
<?php
if (empty($students)) {
?>
<tr>
<th>Students List</th>
</tr>
<tr>
<th>Students List</th>
</tr>
<?php
} else {
?>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Degree</th>
</tr>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Degree</th>
</tr>
<?php
}
?>
Expand All @@ -117,16 +142,16 @@ class="btn btn-danger btn-sm">Delete Event</a>
} else {
foreach ($students as $eventStudent) {
?>
<tr>
<td><?php echo $student->getStudentFirstName($eventStudent['student_id']); ?>
</td>
<td><?php echo $student->getStudentLastName($eventStudent['student_id']); ?>
</td>
<td><?php echo $student->getStudentEmail($eventStudent['student_id']); ?>
</td>
<td><?php echo $student->getStudentDegree($eventStudent['student_id']); ?>
</td>
</tr>
<tr>
<td><?php echo $student->getStudentFirstName($eventStudent['student_id']); ?>
</td>
<td><?php echo $student->getStudentLastName($eventStudent['student_id']); ?>
</td>
<td><?php echo $student->getStudentEmail($eventStudent['student_id']); ?>
</td>
<td><?php echo $student->getStudentDegree($eventStudent['student_id']); ?>
</td>
</tr>
<?php }
} ?>
</tbody>
Expand Down
41 changes: 41 additions & 0 deletions includes/classes/events.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit c9bfbb4

Please sign in to comment.