From b6cdf32a16c06219628defb680ff3c4ffc7fc88c Mon Sep 17 00:00:00 2001 From: AndreaChirulescu Date: Thu, 8 Apr 2021 21:18:38 +0200 Subject: Added function getpublishstatus to check if concert is uploaded within the past 10 days --- includes/admin/views/giglog_admin_page.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'includes/admin/views/giglog_admin_page.php') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 637820f..7970cf3 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -110,6 +110,24 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { 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() { @@ -172,7 +190,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); $content .= '' .$newformat. ''; - $content .= ''; //.giglogadmin_getpublishstatus($row->id ).''; + $content .= ''.GiglogAdmin_AdminPage::getpublishstatus($row->id ).''; $content .= ''.GiglogAdmin_AdminPage::returnuser('photo1', $row->id ).''; $content .= ''.GiglogAdmin_AdminPage::returnuser('photo2', $row->id ).''; $content .= ''.GiglogAdmin_AdminPage::returnuser('rev1', $row->id ).''; -- cgit v1.2.3