Ejemplo n.º 1
0
<?php

require_once "../classes/Database.php";
require_once "../classes/Screening.php";
require_once "../classes/Movie.php";
require_once "../classes/Cinema.php";
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["movie"])) {
    $movieId = $_POST["movie"];
    $cinemaId = $_POST["cinema"];
    $dateFormatted = str_replace("T", " ", $_POST["date"]);
    $db = DATABASE::getInstance();
    $mysqli = $db->getConnection();
    $movie = new Movie($mysqli);
    $movie->findMovieById($movieId);
    $cinema = new Cinema($mysqli);
    $cinema->findCinemaById($cinemaId);
    $screening = new Screening($mysqli);
    $screening->setMovie($movie);
    $screening->setCinema($cinema);
    $screening->setDate($dateFormatted);
    $screening->addToDatabase();
    header("location: adminPanel.php");
}
Ejemplo n.º 2
0
<a href="index.php" class="btn btn-default">Go to the main site</a>


<?php 
require_once "classes/Database.php";
require_once "classes/Movie.php";
require_once "classes/Cinema.php";
require_once "classes/ScreeningFetcher.php";
require_once "classes/Screening.php";
require_once "includes/ticketForm.php";
if ($_SERVER["REQUEST_METHOD"] === "GET" && $_GET["type"] === "movie") {
    $id = $_GET["id"];
    $db = DATABASE::getInstance();
    $mysqli = $db->getConnection();
    $movie = new Movie($mysqli);
    $movie->findMovieById($id);
    $movieName = $movie->getName();
    $movieRating = $movie->getRating();
    $movieDesc = $movie->getDescription();
    echo "<h3>Title: {$movieName}</h3>";
    echo "<p>Rating: {$movieRating}</p>";
    echo "<h3>Description:</h3>";
    echo "<p>{$movieDesc}</p>";
    echo "<h3>Movie Screenings:</h3>";
    $fetcher = new ScreeningFetcher($db);
    $fetcher->getMovieScreenings($id);
    $screeningsArray = $fetcher->getArrayWithMovieScreenings();
    if (!empty($screeningsArray)) {
        echo "<ul>";
        foreach ($screeningsArray as $screening) {
            $cinemaName = $screening->getCinema()->getName();
Ejemplo n.º 3
0
 public function getCinemaScreenings($id)
 {
     $sqlQuery = "SELECT id, cinema_id, movie_id, date FROM screenings WHERE date > NOW() AND cinema_id = {$id} ORDER BY date ";
     $conn = parent::getConnection();
     $result = $conn->query($sqlQuery);
     if ($result->num_rows > 0) {
         while (list($id, $cinemaId, $movieId, $date) = $result->fetch_array(MYSQLI_NUM)) {
             $movie = new Movie($conn);
             $movie->findMovieById($movieId);
             $cinema = new Cinema($conn);
             $cinema->findCinemaById($cinemaId);
             $screening = new Screening($conn);
             $screening->setMovie($movie);
             $screening->setCinema($cinema);
             $screening->setDate($date);
             $screening->setId($id);
             $this->setArrayWithCinemaScreenings($screening);
         }
     }
 }