summaryrefslogtreecommitdiffstats
path: root/includes/admin/views/giglog_admin_page.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-05-09 15:42:58 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-05-09 15:42:58 +0200
commitd116e23de0efcd528226acf6dbe4c7cbc5c5698b (patch)
treea2249944821123a35de6e593c713c06648900c9d /includes/admin/views/giglog_admin_page.php
parent883fbfab5dd0f7fabfed008341acaa63f365b1dc (diff)
downloadgigologadmin-d116e23de0efcd528226acf6dbe4c7cbc5c5698b.tar.gz
gigologadmin-d116e23de0efcd528226acf6dbe4c7cbc5c5698b.tar.bz2
gigologadmin-d116e23de0efcd528226acf6dbe4c7cbc5c5698b.zip
Include info from venue in concerts.
This makes the concert a full object containing all relevant info, while we can still segment the data in the db. Instead of this: $concert = GiglogAdmin_Concert::get($concert_id); $venue = GiglogAdmin_Venue::get($concert->venue()); echo "{$concert->name()} @ {$venue->name()} : {$concert->cdate()}" You can now do: $concert = GiglogAdmin_Concert::get($concert_id); echo "{$concert->name()} @ {$concert->venue()->name()} : {$concert->cdate()}" And yeah, renamed Concert::find_cid() to Concert::get() and changed it's semantics somewhat. It now either returns the given concert if it exists, or NULL if it does not. Simpler function; simpler to use.
Diffstat (limited to 'includes/admin/views/giglog_admin_page.php')
-rw-r--r--includes/admin/views/giglog_admin_page.php14
1 files changed, 9 insertions, 5 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index b78b4db..2971a22 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -36,13 +36,17 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
echo(GiglogAdmin_AdminPage::editforms()); //not sure why it doesn't show without the echo?
}
- static function get_allvenues( ?int $invenue ): string
+ static function get_allvenues( ?GiglogAdmin_Venue $invenue ): string
{
$select = '<select name="selectvenueadmin">';
$select .= '<option value="">Please Select..</option>';
foreach ( GiglogAdmin_Venue::all_venues() AS $venue ) {
- if($invenue==$venue ->id() ) $select .= '<option value="' . $venue -> id(). '" selected="selected">'.$venue->name();
- else $select .= '<option value="' . $venue->id() . '">'. $venue->name();
+ if($invenue && $invenue->id() == $venue->id() ) {
+ $select .= '<option value="' . $venue->id(). '" selected="selected">'.$venue->name();
+ }
+ else {
+ $select .= '<option value="' . $venue->id() . '">'. $venue->name();
+ }
$select .='</option>';
}
$select .= '</select>';
@@ -131,7 +135,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
$editing = filter_input(INPUT_POST, "edit") == "EDIT";
if ($editing && !empty($cid)) //A bit overdoing with the checks if concert ID is empty both here and in find_cid. But based on that, things are NULL or not. Better ideas?
- $c = GiglogAdmin_Concert::find_cid($cid);
+ $c = GiglogAdmin_Concert::get($cid);
else
$c = new GiglogAdmin_Concert();
@@ -140,7 +144,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
.'<div class="concertitems"><strong>CONCERT DETAILS</strong><br><br><fieldset>'
.'<input type="hidden" name="pid" value="' .$c->id(). '" />'
.'<label for="cname">Concert Name:</label><textarea id="cname" name="cname" value="'.$c->cname().'">'.$c->cname().'</textarea><br>'
- .'<label for="venue">Venue:</label>'.GiglogAdmin_AdminPage::get_allvenues($c->venue()).'<br>'
+ .'<label for="venue">Venue:</label>' . GiglogAdmin_AdminPage::get_allvenues($c->venue()) . '<br>'
.'<label for="cdate">Date:</label><input type="date" id="cdate" name="cdate" value="'.$c->cdate().'"><br>'
.'<label for="ticket">Tickets:</label><input type="text" id="ticket" name="ticket" value="'.$c->tickets().'"><br>'
.'<label for="eventurl">Event link:</label><input type="text" id="eventurl" name="eventurl" value="'.$c->eventlink().'"><br>'