summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/admin/views/giglog_admin_page.php16
-rw-r--r--includes/concertlogs.php12
2 files changed, 17 insertions, 11 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index 8ae30c3..f84b497 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -152,22 +152,16 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
$query = "SELECT id,wpgs_name from wpg_pressstatus" ;
$statuses = $wpdb->get_results($query);
- $select =
+ return
'<form method="POST" action="">'
. '<input type="hidden" name="cid" value="' . $concert_id . '" />'
- . '<select name="selectstatus">';
-
- foreach ( $statuses AS $sts ) {
- $select .= '<option value="' . $sts->id . '">' . $sts->wpgs_name . '</option>';
- }
-
- $select .=
- '</select>'
+ . \EternalTerror\ViewHelpers\select_field(
+ 'selectstatus',
+ array_map(fn($status) => [ $status->id, $status->wpgs_name ], $statuses),
+ GiglogAdmin_Concertlogs::get_status($concert_id))
. '<input type="submit" value="SetStatus">'
. '<input type="submit" name ="edit" value="EDIT">'
. '</form>';
-
- return $select;
}
//function to calculate if the concert has been added in the past 10 days or before that and show a green NEW for the newest rows
diff --git a/includes/concertlogs.php b/includes/concertlogs.php
index 3b8083a..9546d21 100644
--- a/includes/concertlogs.php
+++ b/includes/concertlogs.php
@@ -25,5 +25,17 @@ if ( !class_exists( 'GiglogAdmin_Concertlogs' ) )
$wpdb->query($q);
}
+
+ public static function get_status(int $concert_id) : ?int
+ {
+ global $wpdb;
+
+ $q = $wpdb->prepare(
+ 'select wpgcl_status from wpg_concertlogs where id = %d',
+ $concert_id);
+ $res = $wpdb->get_results($q);
+
+ return $res ? $res[0]->wpgcl_status : null;
+ }
}
}