summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/admin/views/giglog_admin_page.php26
-rw-r--r--includes/concert.php18
2 files changed, 23 insertions, 21 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index 0f8fe76..447dcb2 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -180,27 +180,21 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
/**
* @return null|string
*/
- private function getpublishstatus(int $concert_id)
+ private function getpublishstatus(GiglogAdmin_Concert $concert) : string
{
- 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");
+ $now = new DateTime();
+ $new_entry = $now->diff($concert->created())->days <= 10;
+ if ($new_entry) {
+ return '<span style="color:green">NEW</span>';
+ }
+ else {
+ return '';
}
-
- if ($dd <= 10) return ('<span style="color:green">NEW</span>');
}
private function get_concerts(): string
{
- global $wpdb;
-
$content = '<table class="assignit">';
// $content .= '</tr><th>CITY</th><th>ID</th><th>BAND</th><th>VENUE</th><th>DATE</th></tr>';
@@ -245,9 +239,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
//$content .= DATE_FORMAT($fdate,'%d.%b.%Y');
$content .= '<td>' . $newformat . '</td>';
- $content .= '<td>' . /* $concert->isnew() */ '' . '</td>';
-
- $roles = $concert->roles();
+ $content .= '<td>' . $this->getpublishstatus($concert) . '</td>';
$content .= '<td>' . $this->assign_role_for_user_form('photo1', $concert) . '</td>';
$content .= '<td>' . $this->assign_role_for_user_form('photo2', $concert) . '</td>';
diff --git a/includes/concert.php b/includes/concert.php
index dce15f0..c0c13ee 100644
--- a/includes/concert.php
+++ b/includes/concert.php
@@ -20,6 +20,8 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
private ?string $eventlink;
private ?int $status;
private array $roles;
+ private ?DateTimeImmutable $created;
+ private ?DateTimeImmutable $updated;
public const STATUS_NONE = 0;
public const STATUS_ACCRED_REQ = 1;
@@ -43,6 +45,8 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
$this->eventlink = isset($attrs->wpgconcert_event) ? $attrs->wpgconcert_event : NULL;
$this->status = isset($attrs->wpgconcert_status) ? $attrs->wpgconcert_status : 0;
$this->roles = isset($attrs->wpgconcert_roles) ? json_decode($attrs->wpgconcert_roles, true) : [];
+ $this->created = isset($attrs->created) ? new DateTimeImmutable($attrs->created) : NULL;
+ $this->updated = isset($attrs->updated) ? new DateTimeImmutable($attrs->updated) : NULL;
if ( isset( $attrs->venue ) ) {
if (isset($attrs->wpgvenue_name) && isset($attrs->wpgvenue_city)) {
@@ -74,8 +78,7 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
{
global $wpdb;
- $query = 'SELECT wpg_concerts.*, wpg_venues.wpgvenue_name, wpg_venues.wpgvenue_city '
- . 'FROM wpg_concerts '
+ $query = 'SELECT * FROM wpg_concerts '
. 'LEFT JOIN wpg_venues ON wpg_concerts.venue = wpg_venues.id '
. 'WHERE ' . $wpdb->prepare('wpg_concerts.id = %d', $id);
@@ -197,8 +200,7 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
{
global $wpdb;
- $query = 'SELECT wpg_concerts.*, wpg_venues.wpgvenue_name, wpg_venues.wpgvenue_city '
- . 'FROM wpg_concerts '
+ $query = 'SELECT * FROM wpg_concerts '
. 'INNER JOIN wpg_venues ON wpg_concerts.venue = wpg_venues.id ';
$where = [];
@@ -304,6 +306,14 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
{
$this->roles = array_filter($this->roles, fn($u) => $u != $username);
}
+
+ public function created() : DateTimeImmutable {
+ return $this->created;
+ }
+
+ public function updated() : DateTimeImmutable {
+ return $this->updated;
+ }
}
}
?>