diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-05-25 16:43:05 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-05-25 16:49:57 +0200 |
commit | 44ad0a77496b120eede51e60698e1caff093352c (patch) | |
tree | 6d9e38721100fe3e9ede6f87d2d3fcb5b7b73a07 /includes | |
parent | 543bddc03fbf9dc90429d4d77dd11affaea4f356 (diff) | |
download | gigologadmin-44ad0a77496b120eede51e60698e1caff093352c.tar.gz gigologadmin-44ad0a77496b120eede51e60698e1caff093352c.tar.bz2 gigologadmin-44ad0a77496b120eede51e60698e1caff093352c.zip |
Use select_field in adminactions form.
Also add a `get_status` method to the Concertlogs class, returning the
press status for a given concert_id.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/admin/views/giglog_admin_page.php | 16 | ||||
-rw-r--r-- | includes/concertlogs.php | 12 |
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; + } } } |