From 7b2acc35a03cec9928e9ce86c9a3195429ccd306 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 1 Apr 2021 19:47:09 +0200 Subject: Move rendering of concert assignment table. Moved it to the admin page for now. May move it further to a partial or something later. There's quite a bit of cleanup needed. It still refers to some utility functions in the old shortcode module. --- includes/admin/views/giglog_admin_page.php | 205 ++++++++++++++++++++++++++++- includes/venue.php | 10 ++ 2 files changed, 213 insertions(+), 2 deletions(-) (limited to 'includes') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 9f9786c..ec397f4 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -17,16 +17,217 @@ */ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { + require_once __DIR__ . '/../../venue.php'; + class GiglogAdmin_AdminPage { static function render_html() { ?>

Giglog Admin

-

-

+ +

The available slots are marked with the green checkbox. + If you click on it, it will be assigned to you and if you no longer + wish to cover that concert, click on the red icon and you will be + unassigned. A mail should be sent to the admin when this happens, + but in order for the accreditation request to be sent, you have to + mail live@eternal-terror.com with the template containing concert + information. There might be some exceptions, but those are discussed + case by case. So whenever you want a concert, assign yourself and send + the template no later than 3 weeks before the concert.

+ +

Admin will try to keep the concert status updated so that you know + what the accreditation status is. You will get personal message if this + is really close to the concert date.

+ +

+

get_results('select distinct wpgvenue_city from wpg_venues'); + $select= '
'; + //second drop down for venue + + $vquery = "select id, wpgvenue_name from wpg_venues"; + $vquery.= " where wpgvenue_city='".$_POST["selectcity"]."'"; + $resultsv = $wpdb->get_results($vquery); + $select.= '
'; + return $select; + } + + static function get_concerts() + { + $hf_user = wp_get_current_user(); + $hf_username = $hf_user->user_login; + $roles = ( array ) $hf_user->roles; + global $wpdb; + + $content = ''; + // $content .= ''; + + $content .= ' + + + '; + + // Use the submitted "city" if any. Otherwise, use the default/static value. + $cty = filter_input( INPUT_POST, 'selectcity' ); + $cty = $cty ? $cty: 'ALL'; + + $venue = filter_input( INPUT_POST, 'selectvenue' ); + $venue = $venue ? $venue : '0'; + + + $query = "SELECT wpgc.id, wpgb.wpgband_name as band, wpgv.wpgvenue_name as venue, wpgc.wpgconcert_date, wpgc.wpgconcert_tickets, wpgc.wpgconcert_event, wpgv.wpgvenue_city, wpgv.wpgvenue_webpage, wpgps.wpgs_name + FROM wpg_concerts wpgc, wpg_bands wpgb, wpg_venues wpgv, wpg_pressstatus wpgps, wpg_concertlogs wpgcl + where wpgc.band=wpgb.id + and wpgc.venue = wpgv.id + and wpgconcert_date >= CURDATE() + and wpgps.id = wpgcl.wpgcl_status + and wpgcl.wpgcl_concertid=wpgc.id"; + + $query .= ($cty == "ALL") ? "" : " and wpgv.wpgvenue_city='" .$cty ."'"; + $query .= ($venue == "0") ? "" : " and wpgv.id='" .$venue ."'"; + $query .=" order by wpgv.wpgvenue_city, wpgconcert_date" ; + $results = $wpdb->get_results($query); + + $lastType = ''; + foreach ( $results AS $row ) { + $content .= ''; + + if($lastType != '' && $lastType != $row->wpgvenue_city) { + $content .= ''; + } + + if ($lastType == '' ) { + $content .= ''; + } + // Modify these to match the database structure + // $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $fdate = strtotime($row->wpgconcert_date); + $newformat = date('d.M.Y',$fdate); + + //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); + $content .= ''; + $content .= ''; //.giglogadmin_getpublishstatus($row->id ).''; + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $lastType = $row->wpgvenue_city; + } + $content .= '
CITYIDBANDVENUEDATE
CITYBANDVENUEDATE PHOTO1PHOTO2TEXT1TEXT2STATUS
'.$row->wpgvenue_city.'
'.$row->wpgvenue_city.'
' . $row->id. '' . $row->band. '' . $row->venue. '' .$newformat. ''.giglogadmin_returnuser('photo1', $row->id ).''.giglogadmin_returnuser('photo2', $row->id ).''.giglogadmin_returnuser('rev1', $row->id ).''.giglogadmin_returnuser('rev2', $row->id ).''.$row -> wpgs_name; + if (current_user_can('administrator')) //($hf_username == 'etadmin') + $content .= '
+
'; + $content .= '
'; + + if(isset($_POST['assignitem'])) + { + echo (giglogadmin_assignconcert($_POST['pid'],$_POST['cid'])); + + $url2=$_SERVER['REQUEST_URI']; + header("Refresh: 1; URL=$url2"); //reload page + } + + if(isset($_POST['unassignitem'])) + { + echo (giglogadmin_unassignconcert($_POST['pid'],$_POST['cid'])); + + $url3=$_SERVER['REQUEST_URI']; + header("Refresh: 1; URL=$url3"); //reload page + } + + if(isset($_POST['reqsent'])) + { + echo (giglogadmin_assignconcert($_POST['pid'],$_POST['cid'])); + $usql = "UPDATE wpg_concertlogs SET wpgcl_status=2 WHERE wpgcl_concertid=".$_POST['cid']; + $uresults = $wpdb->get_results($usql); + $url2=$_SERVER['REQUEST_URI']; + header("Refresh: 1; URL=$url2"); //reload page + } + + if(isset($_POST['phok'])) + { + $usql = "UPDATE wpg_concertlogs SET wpgcl_status=3 WHERE wpgcl_concertid=".$_POST['cid']; + $uresults = $wpdb->get_results($usql); + + $url2=$_SERVER['REQUEST_URI']; + header("Refresh: 1; URL=$url2"); //reload page + } + + if(isset($_POST['txtok'])) + { + $usql = "UPDATE wpg_concertlogs SET wpgcl_status=4 WHERE wpgcl_concertid=".$_POST['cid']; + $uresults = $wpdb->get_results($usql); + + $url2=$_SERVER['REQUEST_URI']; + header("Refresh: 1; URL=$url2"); //reload page + } + + if(isset($_POST['allok'])) + { + $usql = "UPDATE wpg_concertlogs SET wpgcl_status=5 WHERE wpgcl_concertid=".$_POST['cid']; + $uresults = $wpdb->get_results($usql); + + $url2=$_SERVER['REQUEST_URI']; + header("Refresh: 1; URL=$url2"); //reload page + } + + if(isset($_POST['rej'])) + { + $usql = "UPDATE wpg_concertlogs SET wpgcl_status=6 WHERE wpgcl_concertid=".$_POST['cid']; + $uresults = $wpdb->get_results($usql); + + $url2=$_SERVER['REQUEST_URI']; + header("Refresh: 1; URL=$url2"); //reload page + } + + // return the table + return $content; + } } } ?> diff --git a/includes/venue.php b/includes/venue.php index 8edb136..de144fd 100644 --- a/includes/venue.php +++ b/includes/venue.php @@ -48,5 +48,15 @@ if ( !class_exists('GiglogAdmin_Venue') ) { return array_map(function ($r) { return $r->wpgvenue_city; }, $results); } + + static function venues_in_city($city) + { + global $wpdb; + $q = $wpdb->prepare( + "select id, wpgvenue_name from wpg_venues where wpgvenue_city=?", $city); + $results = $wpdb->get_results($q); + + return array_map(function ($r) { return [$r->id, $r->wpgvenue_name]; }, $results); + } } } -- cgit v1.2.3