/**
  * creates sports venue
  * 
  * @param Entity\SportsVenueImpl $sportsVenue
  * @throws RDException
  */
 public function save($sportsVenue)
 {
     if ($sportsVenue->isPersistent()) {
         //update
         $q = "UPDATE sports_venue\n                set sports_venue.name = ?,\n              address = ?,\n              is_indoor = ?\n              WHERE sports_venue_id = ?;";
         //create prepared statement from query
         $stmt = $this->dbConnection->prepare($q);
         //bind parameters to prepared statement
         $sportsVenueName = $sportsVenue->getName();
         $address = $sportsVenue->getAddress();
         $isIndoor = $sportsVenue->getIsIndoor() ? 1 : 0;
         $sportsVenueId = $sportsVenue->getId();
         $stmt->bindParam(1, $sportsVenueName, \PDO::PARAM_STR);
         $stmt->bindParam(2, $address, \PDO::PARAM_STR);
         $stmt->bindParam(3, $isIndoor, \PDO::PARAM_INT);
         $stmt->bindParam(4, $sportsVenueId, \PDO::PARAM_INT);
         if ($stmt->execute()) {
             echo 'venue created successfully';
         } else {
             throw new RDException('Error creating venue');
         }
     } else {
         //insert
         //create Query
         $q = "INSERT INTO sports_venue (sports_venue.name, address, is_indoor) VALUES(?, ?, ?);";
         //create prepared statement from query
         $stmt = $this->dbConnection->prepare($q);
         //bind parameters to prepared statement
         $sportsVenueName = $sportsVenue->getName();
         $address = $sportsVenue->getAddress();
         $isIndoor = $sportsVenue->getIsIndoor() ? 1 : 0;
         $stmt->bindParam(1, $sportsVenueName, \PDO::PARAM_STR);
         $stmt->bindParam(2, $address, \PDO::PARAM_STR);
         $stmt->bindParam(3, $isIndoor, \PDO::PARAM_INT);
         if ($stmt->execute()) {
             $sportsVenue->setId($this->dbConnection->lastInsertId());
             echo 'venue created successfully';
         } else {
             throw new RDException('venue creating match');
         }
     }
 }
Example #2
0
 /**
  * Create a new SportsVenue object, given the set of initial attribute values.
  * @param name the name of the sports venue
  * @param address the address of the sports venue
  * @param isIndoor is the sports venue an indoor venue?
  * @return a new SportsVenue object instance with the given attribute values
  * @throws RDException in case name is null
  */
 public function createSportsVenue($name = null, $address = null, $isIndoor = null)
 {
     $aSportsVenue = new Entity\SportsVenueImpl();
     // if ($name != null && $address != null && $isIndoor != null) {
     $aSportsVenue->setName($name);
     $aSportsVenue->setAddress($address);
     $aSportsVenue->setIsIndoor($isIndoor);
     //}
     return $aSportsVenue;
 }
Example #3
0
 public function updateSportsVenue($venueID, $newName = null, $isIndoor = null, $address = null)
 {
     $sportsVenueModel = new Entity\SportsVenueImpl();
     $sportsVenueModel->setID($venueID);
     $sportsVenueIter = $this->objectLayer->findSportsVenue($sportsVenueModel);
     if ($sportsVenueIter->size() <= 0) {
         throw new RDException("Sports Venue not found");
     } else {
         $sportsVenue = $sportsVenueIter->current();
         if ($newName != null) {
             $sportsVenue->setName($newName);
         }
         if ($isIndoor != null) {
             $sportsVenue->setIsIndoor($isIndoor);
         }
         if ($address != null) {
             $sportsVenue->setAddress($address);
         }
         $this->objectLayer->storeSportsVenue($sportsVenue);
     }
 }
Example #4
0
spl_autoload_register(function ($class_name) {
    include '/Users/montanawong/Sites/RecDawgs/src/' . str_replace('\\', '/', $class_name) . '.php';
});
use edu\uga\cs\recdawgs\presentation as Presentation;
use edu\uga\cs\recdawgs\entity\impl as Entity;
if (!isset($_POST) || !isset($_POST['sportsVenueId'])) {
    $errorMsg = urlencode("Sports Venue not found.");
    header("Location: sportsVenues.php?status={$errorMsg}");
}
?>

<body>
<div class="container">
<?php 
$sportsVenueId = $_POST['sportsVenueId'];
$sportsVenueModel = new Entity\SportsVenueImpl();
$sportsVenueModel->setId($sportsVenueId);
$sportsVenueUI = new Presentation\SportsVenueUI();
echo $sportsVenueUI->listSportsVenueInfo($sportsVenueModel);
echo "<h2>Leagues used in</h2>";
echo $sportsVenueUI->listLeaguesUsedIn(null, $sportsVenueId);
?>

<br/><br/>
<?php 
//if admin allow update and deletion of sports venues and assignment to league
if ($_SESSION['userType'] == 1) {
    echo $sportsVenueUI->listAddToLeagueButton($sportsVenueId);
    echo "<h3>Update Sports Venue</h3><br/><form action = 'updateSportsVenue.php' method = 'post' >\n    <input type = 'hidden' name = 'sportsVenueId' value = '{$sportsVenueId}'>\n        <input type ='submit' value ='Update the Sports Venue'>\n</form >";
}
if ($_SESSION['userType'] == 1) {