<?php

//Include the common file
require_once 'common.php';

$event = $db->fetchRowAssoc("SELECT * FROM " . cfg('base', 'table_events') . " e, " . cfg('base', 'table_event_translations') . " t  WHERE  e.event_id = ". $_GET['id'] . " AND t.language_code = '" . $site_lang . "' AND e.event_id = t.event_id");

if ($event['event_poster']) {
        $og_type = 'article';
        $og_image = cfg('base', 'site_url').'uploads/images/'.$event['event_poster'];
        $og_video_url = '';
        $og_video_type = '';
        $og_video_width = '';
        $og_video_height = '';

        $tw_card = 'article';
        $tw_video_url = '';
        $tw_video_width = '';
        $tw_video_height= '';
    } else {
        $og_type = 'article';
        $og_image = cfg('base', 'site_url').'templates/assets/img/og_logo.png';
        $og_video_url = '';
        $og_video_type = '';
        $og_video_width = '';
        $og_video_height = '';

        $tw_card = 'article';
        $tw_video_url = '';
        $tw_video_width = '';
        $tw_video_height= '';
    }

$sql = "SELECT m.mix_id, m.cover, m.author, t.mix_title FROM " . cfg('base', 'table_mixes') . " m, " . cfg('base', 'table_mix_translations') . " t WHERE t.language_code = '" . $site_lang . "' AND m.mix_id = t.mix_id AND m.mix_status =1 ORDER BY m.mix_id DESC LIMIT 0, 3";

//Mixes
$mixes = array();

foreach ($db->query($sql) as $row) {

    $mixes[] = array(
        'mix_id'                   => $row['mix_id'],
        'mix_title'               => $row['mix_title'],
        'cover'                       => $row['cover'],
        'author'                     => $row['author']
    );

}

//Navigation class
$current_extra = 'class="current"';
$current_events = 'class="current"';

//Template values
$tpl->set('title', $event['event_title']);
$tpl->set('keywords', $event['event_meta_keywords']);
$tpl->set('description', $event['event_meta_description']);
$tpl->set('content', $event['reservation_details']);
$tpl->set('og_type', $og_type);
$tpl->set('og_image', $og_image);
$tpl->set('og_video_url', $og_video_url);
$tpl->set('og_video_type', $og_video_type);
$tpl->set('og_video_width', $og_video_width);
$tpl->set('og_video_height', $og_video_height);

$tpl->set('tw_card', $tw_card);
$tpl->set('tw_video_url', $tw_video_url);
$tpl->set('tw_video_width', $tw_video_width);
$tpl->set('tw_video_height', $tw_video_height);

$tpl->set('event', $event);
$tpl->set('mixes', $mixes);

//Display navigation current class
$tpl->set('current_extra', $current_extra);
$tpl->set('current_events', $current_events);

//Display the template
$tpl->display('event');
