Example #1
0
 /**
  * @return string HTML
  */
 public function displayMovie(\model\MovieSuggestion $mov, $tables)
 {
     $name = $mov->getName();
     $time = $mov->getTime();
     $display = "<h3>Följande tider är lediga att boka på Zekes bar</h3>";
     if (empty($tables) === false) {
         $display .= "<ul class='list-group'>";
         foreach ($tables as $table) {
             $display .= "<li class='list-group-item'>Det finns ett ledigt bord mellan klockan " . $table . " efter att ha sett filmen {$name} klockan {$time}</li>";
         }
         $display .= "</ul>";
     }
     if (empty($tables)) {
         $display .= "Det fanns inga tider!  (╯°□°)╯︵ ┻━┻) ";
     }
     $display .= "<a href='?'>Tillbaka</a>";
     return $display;
 }
Example #2
0
 /**
  * @return array of strings
  */
 public function getTablesAfterMovie(\model\MovieSuggestion $movie, $url)
 {
     $tables = array();
     $restaurantPage = $this->makeRequest($url);
     $dom = $this->getDomDocument($restaurantPage);
     $xpath = new \DOMXPath($dom);
     $freeTables = $xpath->query('//input[@type="radio"]');
     foreach ($freeTables as $table) {
         /**
          * First three letters of the radio buttons value represent the day
          * Last four represent the time interval (XXYY is XX to YY)
          */
         $value = $table->getAttribute('value');
         if (substr($value, 0, 3) === "fre" && $movie->getDay() === "Friday") {
             if (intval(substr($value, 3, 2)) > intval($movie->getTime())) {
                 $tables[] = substr($value, 3, 2) . " och " . substr($value, 5, 2);
             }
         }
         if (substr($value, 0, 3) === "lor" && $movie->getDay() === "Saturday") {
             if (intval(substr($value, 3, 2)) > intval($movie->getTime())) {
                 $tables[] = substr($value, 3, 2) . " och " . substr($value, 5, 2);
             }
         }
         if (substr($value, 0, 3) === "son" && $movie->getDay() === "Sunday") {
             if (intval(substr($value, 3, 2)) > intval($movie->getTime())) {
                 $tables[] = substr($value, 3, 2) . " och " . substr($value, 5, 2);
             }
         }
     }
     return $tables;
 }