<?php require_once('config.php'); ?>
<?php include('header.php'); ?>
<?php $_SESSION['return_url'] = $_SERVER['REQUEST_URI']; ?>
<div id="page">
<?php include('bar-menu.php'); ?>
<?php include('fixed-header.php'); ?>


<?php
// Get the event ID from the URL parameter
if (!isset($_GET['event_id'])) {
    // handle error, event_id is not set
    exit;
}
$event_id = $_GET['event_id'];

// Insert a new row into tceventview
$stmt = $pdo->prepare("INSERT INTO tceventview (tceventview_tcevent_id, tceventview_time) VALUES (?, NOW())");
$stmt->execute([$event_id]);

// Select the event details
$stmt = $pdo->prepare("SELECT tcevent_name, agegroup_name, eventcategory_name, tcevent_about, tcevent_highlight, tcevent_terms, tcevent_startdatetime, tcevent_enddatetime, tcevent_youtubelink, tcevent_imgone, tcevent_imgtwo, tcevent_imgthree, tcevent_imgfour, tcevent_imgfive, tcevent_eventstatus_id, eventstatus_name,
GROUP_CONCAT(DISTINCT CONCAT(artist.artist_name, '##', artist.artist_image) SEPARATOR ', ') AS artists, 
GROUP_CONCAT(DISTINCT city_name SEPARATOR ', ') AS cities, 
GROUP_CONCAT(DISTINCT language_name SEPARATOR ', ') AS languages 
FROM tcevent
INNER JOIN agegroup ON tcevent_agegroup_id = agegroup.agegroup_id
INNER JOIN eventcategory ON tcevent_eventcategory_id = eventcategory.eventcategory_id
LEFT JOIN tcevent_artist ON tcevent.tcevent_id = tcevent_artist.tcevent_id
LEFT JOIN artist ON tcevent_artist.artist_id = artist.artist_id
LEFT JOIN tcevent_city ON tcevent.tcevent_id = tcevent_city.tcevent_id
LEFT JOIN city ON tcevent_city.city_id = city.city_id
LEFT JOIN tcevent_language ON tcevent.tcevent_id = tcevent_language.tcevent_id
LEFT JOIN language ON tcevent_language.language_id = language.language_id
LEFT JOIN eventstatus ON tcevent.tcevent_eventstatus_id = eventstatus.eventstatus_id
WHERE tcevent.tcevent_id = ?
GROUP BY tcevent.tcevent_id");
$stmt->execute([$event_id]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);

// Select the shows for the event
$stmt = $pdo->prepare("SELECT tcshow_id, tcshow_name, city.city_name, venue.venue_name, tcshow_startdatetime 
                        FROM tcshow 
                        INNER JOIN city ON tcshow.tcshow_city_id = city.city_id 
                        INNER JOIN venue ON tcshow.tcshow_venue_id = venue.venue_id 
                        WHERE tcshow_tcevent_id = ? AND EXISTS 
                            (SELECT 1 FROM tcevent WHERE tcevent_id = ? AND tcevent_eventstatus_id = 2)");
$stmt->execute([$event_id, $event_id]);
$num_shows = $stmt->rowCount();
?>


<div class="page-content header-clear-medium">
<!-- Display event details -->
<title><?php echo $row['tcevent_name']; ?> | Event Tickets | TicketClap</title>
		<div class="card card-style">
			<div class="card-top my-3 mx-2">	
                <a href="#" data-menu="menu-share" class="icon icon-s bg-theme color-theme mx-2 float-end rounded-m"><i class="fa fa-share-alt"></i></a>
            </div>
			<img src="https://data-vault.ticketclap.com/events/<?php echo $row['tcevent_imgtwo']; ?>" class="rounded-sm img-fluid" alt="Event Image">
			
            <div class="content mt-4">
                <div>
                    <span class="color-highlight font-300 d-block text-uppercase font-10 pt-1"> </span>
                    <strong class="color-theme font-21 d-block mt-n2 mb-n2"><?php echo $row['tcevent_name']; ?>	</strong>
                    <span class="font-14 color-theme opacity-80 d-block pb-2 pt-2"><i class="fa-solid fa-caret-right pe-2"></i><?php echo $row['eventcategory_name']; ?></span>
                </div>
                <div class="row mb-3">
                    <div class="col-6">
                        <div class="d-flex">
                            <div class="align-self-center">
                                <i style="width:20px" class="fa fa-calendar color-teal-dark font-23 me-3 text-center"></i>
                            </div>
                            <div class="align-self-center">
                                <span class="d-block font-11 mb-n3 pb-2 color-theme opacity-80">Date/s</span>
                                <strong class="d-block font-12 pb-1 color-theme">
								<?php
									$start_time = strtotime($row['tcevent_startdatetime']);
									$start_date = date('j F Y', $start_time);
									$start_time = date('h:i a', $start_time);
								?>

								<?php if ($num_shows > 1): ?>
									Multiple
									<?php else: ?>
									<?php echo $start_date ?>
								<?php endif; ?>
								</strong>
                            </div>
                        </div>
                    </div>
					<div class="col-6">
                        <div class="d-flex">
                            <div class="align-self-center">
                                <i style="width:20px" class="fa fa-location-dot color-yellow-dark font-23 me-3 text-center"></i>
                            </div>
                            <div class="align-self-center">
                                <span class="d-block font-11 mb-n3 pb-2 color-theme opacity-80">City</span>
                                <strong class="d-block font-12 pb-1 color-theme">
								<?php
									$cities = explode(',', $row['cities']); // convert the comma-separated string to an array
									$num_cities = count($cities);
									if ($num_cities > 1) {
								?>
								Multiple
								<?php
								} else {
								?>
								<?php echo trim($cities[0]); ?>
								<?php }	?>
								</strong>
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-12 mb-2"></div>
					<div class="col-6">
                        <div class="d-flex">
                            <div class="align-self-center">
                                <i style="width:20px" class="fa fa-user-group color-green-dark font-23 me-3 text-center"></i>
                            </div>
                            <div class="align-self-center">
                                <span class="d-block font-11 mb-n3 pb-2 color-theme opacity-80">Age Group</span>
                                <strong class="d-block font-12 pb-1 color-theme"><?php echo $row['agegroup_name']; ?></strong>
                            </div>
                        </div>
                    </div>
                    <div class="col-6">
                        <div class="d-flex">
                            <div class="align-self-center">
                                <i style="width:20px" class="fa fa-circle-info color-red-dark font-23 me-3 text-center"></i>
                            </div>
                            <div class="align-self-center">
                                <span class="d-block font-11 mb-n3 pb-2 color-theme opacity-80">Language</span>
                                <strong class="d-block font-12 pb-1 color-theme"><?php echo $row['languages']; ?></strong>
                            </div>
                        </div>
                    </div>
                    
					<p class="mb-0">Status: <mark class="highlight ps-2 font-12 pe-2 bg-magenta-dark"><?php echo $row['eventstatus_name']; ?></mark></p>
					<p></p>
                </div>
				
				<div class="divider mt-0 mb-0"></div>
				<h4 class="mt-2">About</h4>
                <p class="mb-0" style="line-height:130%"><?php echo $row['tcevent_about']; ?></p>

								</div>		
								
								
														            <div class="accordion" id="accordion-1">
         
                    <button class="btn accordion-btn no-effect" data-bs-toggle="collapse" data-bs-target="#collapse1">
                    
                       Highlights
                        <i class="fa fa-chevron-down font-10 accordion-icon"></i>
                    </button>
                    <div id="collapse1" class="collapse" data-bs-parent="#accordion-1">
                        <div class="pt-1 pb-2 ps-3 pe-3" style="line-height:130%"	>
                            <?php echo $row['tcevent_highlight']; ?>
                        </div>
                    </div>



            </div>			
	<div class="divider mt-0 mb-0"></div>
								
						<div class="content mt-0">		
		<h5 class="mt-2">Artist / Performer	</h5>		
				<div class="row text-center row-cols-5 mb-0">

<?php 
$artists = explode(',', $row['artists']);
foreach($artists as $artist) {
    list($artist_name, $artist_image) = explode('##', $artist);
?>
    <a class="col" data-gallery="gallery-1" href="" title="">
        <img src="https://data-vault.ticketclap.com/artist/<?php echo $artist_image; ?>" data-src="https://data-vault.ticketclap.com/artist/<?php echo $artist_image; ?>" class="preload-img img-fluid rounded-circle" alt="img">
        <strong class="d-block font-12 pt-1 color-theme" style="line-height: 1.2;"><?php echo $artist_name; ?></strong>
		
    </a>
<?php
}
?>
	
</div>
</div>
           





 
			
			



</div>








<div class="card card-style">
	<div class="content mb-2">
		<center><h3 class="mb-3">Select Show</h3></center>

		<div class="list-group">

<!-- Display shows for the event -->
<?php while ($show = $stmt->fetch(PDO::FETCH_ASSOC)): ?>
<?php
$show_start_time = strtotime($show['tcshow_startdatetime']);
$show_start_date = date('j F Y', $show_start_time);
$show_start_time = date('h:i a', $show_start_time);
?>			


		<a href="tctier-show.php?show_id=<?php echo $show['tcshow_id']; ?>">
		<div class="card card-style gradient shadow-bg shadow-bg-l">
			<div class="content">
				<h5><i class="fa-solid fa-sm fa-calendar-day"></i> <?php echo $show_start_date; ?> &nbsp; ~ &nbsp; <i class="fa-regular fa-sm fa-clock"></i> <?php echo $show_start_time; ?></h5>
				<hr>
				<h6><?php echo $show['tcshow_name']; ?></h6>
				<p ><i class="fa-solid fa-location-dot"></i>
					 &nbsp;
					<?php echo $show['city_name']; ?> -
					<?php echo $show['venue_name']; ?>
				</p>
			</div>
		</div>
		</a>
		
		
<?php endwhile; ?>						

		</div>
	</div>  
</div>








<?php if (!empty($row['tcevent_imgthree']) || !empty($row['tcevent_imgfour']) || !empty($row['tcevent_imgfive'])): ?>
    <div class="splide single-slider slider-arrows" id="single-slider-3">
        <div class="splide__track">
            <div class="splide__list">
                <?php if (!empty($row['tcevent_imgthree'])): ?>
                    <div class="splide__slide">
                        <div data-card-height="300" class="card mx-3 rounded-m shadow-l">
                            <div class="card-bottom text-center">
                                <img class="img-fluid" src="/data-vault/events/<?php echo $row['tcevent_imgthree']; ?>" alt="Event Image">
                            </div>
                        </div>
                    </div>
                <?php endif; ?>
                <?php if (!empty($row['tcevent_imgfour'])): ?>
                    <div class="splide__slide">
                        <div data-card-height="300" class="card mx-3 rounded-m shadow-l">
                            <div class="card-bottom text-center">
                                <img class="img-fluid" src="/data-vault/events/<?php echo $row['tcevent_imgfour']; ?>" alt="Event Image">
                            </div>
                        </div>
                    </div>
                <?php endif; ?>
                <?php if (!empty($row['tcevent_imgfive'])): ?>
                    <div class="splide__slide">
                        <div data-card-height="300" class="card mx-3 rounded-m shadow-l">
                            <div class="card-bottom text-center">
                                <img class="img-fluid" src="/data-vault/events/<?php echo $row['tcevent_imgfive']; ?>" alt="Event Image">
                            </div>
                        </div>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
<?php endif; ?>















<div hidden>

        <div class="card card-style">
            <div class="content">
                <h4>Things to know<i class="fa fa-info-circle float-end font-16 pt-1 color-blue-dark"></i></h4>
            </div>

            <div class="accordion" id="accordion-1">
                <div class="mb-0">
                    <button class="btn accordion-btn no-effect" data-bs-toggle="collapse" data-bs-target="#collapse1">
                    
                       Highlights
                        <i class="fa fa-chevron-down font-10 accordion-icon"></i>
                    </button>
                    <div id="collapse1" class="collapse" data-bs-parent="#accordion-1">
                        <div class="pt-1 pb-2 ps-3 pe-3">
                            <?php echo $row['tcevent_highlight']; ?>
                        </div>
                    </div>
                </div>
                <div class="mb-0">
                    <button class="btn accordion-btn no-effect"  data-bs-toggle="collapse" data-bs-target="#collapse2">
                     
                       Terms & Rules
                        <i class="fa fa-chevron-down font-10 accordion-icon"></i>
                    </button>
                    <div id="collapse2" class="collapse"  data-bs-parent="#accordion-1">
                        <div class="pt-1 pb-2 ps-3 pe-3">
                            <?php echo $row['tcevent_terms']; ?>
                        </div>
                    </div>
                </div>

            </div>
        </div>
		
		
	
<?php
$start_time = strtotime($row['tcevent_startdatetime']);
$start_date = date('j F Y', $start_time);
$start_time = date('h:i a', $start_time);
?>
<p>Start Date: <?php echo $start_date ?></p>
<p>Start Time: <?php echo $start_time ?></p>

<?php if ($num_shows > 1): ?>
    <p>Dates: Multiple</p>
<?php else: ?>
    <p>Date: <?php echo $start_date ?></p>
<?php endif; ?>

<?php
$end_time = strtotime($row['tcevent_enddatetime']);
$end_date = date('j F Y', $end_time);
$end_time = date('h:i a', $end_time);
?>
<p>End Date: <?php echo $end_date ?></p>
<p>End Time: <?php echo $end_time ?></p>

<p>Status id: <?php echo $row['tcevent_eventstatus_id']; ?></p>
<p>Event Status: <?php echo $row['eventstatus_name']; ?></p>
<p>YouTube Link: <?php echo $row['tcevent_youtubelink']; ?></p>

<p>Images:</p>
<?php if (!empty($row['tcevent_imgone'])): ?>
    <img src="/data-vault/events/<?php echo $row['tcevent_imgone']; ?>" alt="Event Image">
<?php endif; ?>

<?php if (!empty($row['tcevent_imgtwo'])): ?>
    <img src="/data-vault/events/<?php echo $row['tcevent_imgtwo']; ?>" alt="Event Image">
<?php endif; ?>

<?php if (!empty($row['tcevent_imgthree'])): ?>
    <img src="/data-vault/events/<?php echo $row['tcevent_imgthree']; ?>" alt="Event Image">
<?php endif; ?>

<?php if (!empty($row['tcevent_imgfour'])): ?>
    <img src="/data-vault/events/<?php echo $row['tcevent_imgfour']; ?>" alt="Event Image">
<?php endif; ?>

<?php if (!empty($row['tcevent_imgfive'])): ?>
    <img src="/data-vault/events/<?php echo $row['tcevent_imgfive']; ?>" alt="Event Image">
<?php endif; ?>


<!-- Display shows for the event -->
<?php while ($show = $stmt->fetch(PDO::FETCH_ASSOC)): ?>
    <?php
        $show_start_time = strtotime($show['tcshow_startdatetime']);
        $show_start_date = date('j F Y', $show_start_time);
        $show_start_time = date('h:i a', $show_start_time);
    ?>
	    <p>Start Date: <?php echo $show_start_date; ?></p>
        <p>Start Time: <?php echo $show_start_time; ?></p>
		<h2><?php echo $show['tcshow_name']; ?></h2>
		<p>City: <?php echo $show['city_name']; ?></p>
        <p>Venue: <?php echo $show['venue_name']; ?></p>
        <a href="tctier-show.php?show_id=<?php echo $show['tcshow_id']; ?>" class="btn btn-primary">Buy Tickets</a>
	<?php endwhile; ?>	
	
	
	
</div>	
	
	

<?php include('footer.php'); ?>

</div></div>