. */ 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.

'; $select .= ''; foreach ( GiglogAdmin_Venue::all_venues() AS $venue ) { if($invenue==$venue ->id() ) $select .= ''; } $select .= ''; return($select); } static function get_allbands($inband) { $select = ''; return($select); } static function get_countries() { $select = ''; return($select); } static function get_filters() { $cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities()); $selected_city = filter_input(INPUT_POST, "selectcity", FILTER_SANITIZE_SPECIAL_CHARS) || $cities[0]; $select = '
FILTER DATA: '; if ( $selected_city != "ALL" ) { //second drop down for venue $venues = GiglogAdmin_Venue::venues_in_city($selected_city); $venue_list = array_merge( [0, "ALL"], array_map( function($v) { return [$v->id(), $v->name()]; }, $venues)); $selected_venue = filter_input(INPUT_POST, "selectvenue", FILTER_SANITIZE_SPECIAL_CHARS) || $venues[0]; $select .= ''; } //option to select own concerts only $select .= '' .''.GiglogAdmin_AdminPage::get_allbands($c->band()).'
' .''.GiglogAdmin_AdminPage::get_allvenues($c->venue()).'
' .'
' .'
' .'
'; // actions differ if we update or create a concert, hence two buttons needed if ($editing) { $content.='

'; } else { $content.='

'; } $content.='
'; $content.='

' .'
' .''.GiglogAdmin_AdminPage::get_countries().'
' .'

' .'
'; $content.='

' .'
' .'
' .'

' .'
'; return $content; } static function adminactions($concert_id) { global $wpdb; $query = "SELECT id,wpgs_name from wpg_pressstatus" ; $statuses = $wpdb->get_results($query); $select = '
' . '' . '' . '' . '' . '
'; 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 static function getpublishstatus($concert_id) { global $wpdb; $date1 = new DateTime("now"); $dsql = "select wpgcl_createddate from wpg_concertlogs where wpgcl_concertid=".$concert_id; $results = $wpdb->get_results($dsql); foreach ( $results AS $row ) { //$x = strtotime($row -> filedate); $x= date('Y-m-d H:i:s', strtotime($row -> wpgcl_createddate)); $date2 = new DateTime($x, new DateTimeZone('Europe/London')); $dd = $date2 -> diff($date1) ->format("%a"); } if ($dd <= 10) return ('NEW'); } 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 .= ''; if (current_user_can('administrator')) //($hf_username == 'etadmin') $content .= ''; $content .= ''; // Use the submitted "city" if any. Otherwise, use the default/static value. $cty = filter_input( INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS ); $cty = $cty ? $cty: 'ALL'; $venue = filter_input( INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS ); $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.= (empty($_POST['my_checkbox'])) ? "": " and (wpgcl_photo1 ='".$hf_username."' or wpgcl_photo2 ='".$hf_username."' or wpgcl_rev1 ='".$hf_username."' or wpgcl_rev2 ='".$hf_username."')"; $query .=" order by wpgv.wpgvenue_city, wpgconcert_date, wpgc.id" ; $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 .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; if (current_user_can('administrator')) { $content .= ''; } $content .= ''; $lastType = $row->wpgvenue_city; } $content .= '
CITYIDBANDVENUEDATE
CITYBANDVENUEDATE PHOTO1PHOTO2TEXT1TEXT2 STATUSAdminOptions
'.$row->wpgvenue_city.'
'.$row->wpgvenue_city.'
' . $row->id. '' . $row->band. '' . $row->venue. '' .$newformat. ''.GiglogAdmin_AdminPage::getpublishstatus($row->id ).''.GiglogAdmin_AdminPage::returnuser('photo1', $row->id ).''.GiglogAdmin_AdminPage::returnuser('photo2', $row->id ).''.GiglogAdmin_AdminPage::returnuser('rev1', $row->id ).''.GiglogAdmin_AdminPage::returnuser('rev2', $row->id ).''.$row -> wpgs_name.'' . GiglogAdmin_AdminPage::adminactions($row->id) . '
'; // return the table return $content; } static function update() { global $wpdb; if ('POST' !== $_SERVER['REQUEST_METHOD']) return; // Use the submitted "city" if any. Otherwise, use the default/static value. $cty = filter_input( INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS ); $cty = $cty ? $cty: 'ALL'; $venue = filter_input( INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS ); $venue = $venue ? $venue : '0'; if(isset($_POST['assignitem'])) { GiglogAdmin_AdminPage::assignconcert($_POST['pid'],$_POST['cid']); $url2=$_SERVER['REQUEST_URI']; header("Refresh: 1; URL=$url2"); //reload page } if(isset($_POST['unassignitem'])) { GiglogAdmin_AdminPage::unassignconcert($_POST['pid'],$_POST['cid']); $url3=$_SERVER['REQUEST_URI']; header("Refresh: 1; URL=$url3"); //reload page } //handling the admin drop down menu if(isset($_POST['selectstatus']) && $_POST['edit']!="EDIT" && !empty($_POST['cid'])) { $usql = "UPDATE wpg_concertlogs SET wpgcl_status=".$_POST['selectstatus']." WHERE wpgcl_concertid=".$_POST['cid']; $uresults = $wpdb->get_results($usql); //$url2=$_SERVER['REQUEST_URI']; //doesn't seem to be needed actually, leaving here just in case //header("Refresh: 1; URL=$url2"); //reload page } if(isset($_POST['newconcert'])) { IF (empty($_POST['selectband']) || empty($_POST['selectvenueadmin']) || empty($_POST['cdate']) || empty($_POST['ticket']) || empty($_POST['eventurl'])) echo ''; else { GiglogAdmin_Concert::find_or_create($_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); echo ''; } } if(isset($_POST['editconcert'])) { IF (empty($_POST['selectband']) || empty($_POST['selectvenueadmin']) || empty($_POST['cdate']) || empty($_POST['ticket']) || empty($_POST['eventurl'])) echo ''; else { GiglogAdmin_Concert::updatec($_POST['pid'],$_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); echo ''; } } if(isset($_POST['newband'])) { IF (empty($_POST['bandname'])) //country is not checked as it is set to Norway by default echo ''; else { GiglogAdmin_Band::create($_POST['bandname'],$_POST['selectcountry']); echo ''; } } if(isset($_POST['newvenue'])) { IF (empty($_POST['venuename']) || empty($_POST['venuecity'])) echo ''; else { GiglogAdmin_Venue::create($_POST['venuename'],$_POST['venuecity']); echo ''; } } } static function assignconcert($p1, $c) { global $wpdb; $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; $to = 'live@eternal-terror.com'; $subject = $hf_username.' has taken '.$p1. 'for a concert with id '.$c; $body = 'The email body content'; $headers = array('Content-Type: text/html; charset=UTF-8'); if ($p1 == 'photo1') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo1='".$hf_username."' WHERE wpgcl_concertid=".$c; if ($p1 == 'photo2') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo2='".$hf_username."' WHERE wpgcl_concertid=".$c; if ($p1 == 'rev1') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev1='".$hf_username."' WHERE wpgcl_concertid=".$c; if ($p1 == 'rev2') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev2='".$hf_username."' WHERE wpgcl_concertid=".$c; $uresults = $wpdb->get_results($usql); $wpdb->insert( 'wpg_logchanges', array ( 'id' => '', 'userid' => $hf_username, 'action' => 'assigned '.$p1, 'concertid' => $c)); echo ($wpdb->last_error ); wp_mail( $to, $subject, $body, $headers ); } static function unassignconcert($p1, $c) { global $wpdb; $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; $to = 'live@eternal-terror.com'; $subject = $hf_username.' has UNASSINED '.$p1. 'for a concert with id '.$c; $body = 'The email body content'; $headers = array('Content-Type: text/html; charset=UTF-8'); if ($p1 == 'photo1') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo1='' WHERE wpgcl_concertid=".$c; if ($p1 == 'photo2') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo2='' WHERE wpgcl_concertid=".$c; if ($p1 == 'rev1') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev1='' WHERE wpgcl_concertid=".$c; if ($p1 == 'rev2') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev2='' WHERE wpgcl_concertid=".$c; $uresults = $wpdb->get_results($usql); $wpdb->insert( 'wpg_logchanges', array ( 'id' => '', 'userid' => $hf_username, 'action' => 'unassigned '.$p1, 'concertid' => $c)); echo ($wpdb->last_error ); wp_mail( $to, $subject, $body, $headers ); } static function returnuser($p1, $c) { global $wpdb; $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; //PHOTO1 if ($p1 == 'photo1') { //checking if taken $vquery0 = "select wpgcl_photo1 from wpg_concertlogs where wpgcl_concertid=".$c ; $results = $wpdb->get_results($vquery0); foreach ( $results AS $row ) $x= $row -> wpgcl_photo1; if ($x !='' and $x!=$hf_username) { return ('Taken
Taken by '.$x.'
'); } else if ($x==$hf_username) //if current user return ('
'); else //not taken by anyone return ('
'); } //PHOTO2 if ($p1 == 'photo2') { $vquery0 = "select wpgcl_photo2 from wpg_concertlogs where wpgcl_concertid=".$c ; $results = $wpdb->get_results($vquery0); foreach ( $results AS $row ) $x= $row -> wpgcl_photo2; if ($x !='' and $x!=$hf_username) { return ('Taken
Taken by '.$x.'
'); } else if ($x==$hf_username) //if current user return ('
'); else //not taken by anyone return ('
'); } //TEXT1 if ($p1 == 'rev1') { $vquery0 = "select wpgcl_rev1 from wpg_concertlogs where wpgcl_concertid=".$c ; $results = $wpdb->get_results($vquery0); foreach ( $results AS $row ) $x= $row -> wpgcl_rev1; if ($x !='' and $x!=$hf_username) { return('Taken
Taken by '.$x.'
'); } else if ($x==$hf_username) //if current user return ('
'); else //not taken by anyone return ('
'); } //TEXT2 if ($p1 == 'rev2') { $vquery0 = "select wpgcl_rev2 from wpg_concertlogs where wpgcl_concertid=".$c ; $results = $wpdb->get_results($vquery0); foreach ( $results AS $row ) $x= $row -> wpgcl_rev2; if ($x !='' and $x!=$hf_username) { return('Taken
Taken by '.$x.'
'); } else if ($x==$hf_username) //if current user return ('
'); else //not taken by anyone return ('
'); } } } } ?>