Link to entries filtered by ships, hulls and competitors.
authorCMDR furrycat <elite@furrycat.net>
Tue, 26 Jan 2016 14:17:43 +0000 (09:17 -0500)
committerCMDR furrycat <elite@furrycat.net>
Tue, 26 Jan 2016 14:17:43 +0000 (09:17 -0500)
lib/competitor.php
lib/entry.php
lib/hull.php
lib/ship.php

index 53aa136..c625eb1 100644 (file)
     return false;
   }
 
+  function show_competitor($competitor) {
+    $sq = new ShipQuery;
+    $sq->joinWith('Ship.Hull');
+    $ships = $sq->findByCompetitorId($competitor->getId());
+    if (! count($ships)) return;
+
+    foreach ($ships as $ship) {
+      $hull_name = $ship->getHull()->getLink();
+      $ship_name = $ship->getLink();
+      echo "<p>Ship: $ship_name ($hull_name)</p>\n";
+      $eq = new EntryQuery;
+      $eq->joinWith('Entry.Race');
+      $eq->joinWith('Entry.Ship');
+      $eq->joinWith('Ship.Hull');
+      $entries = $eq->orderById()->findByShip($ship);
+      if (! count($entries)) continue;
+
+      foreach ($entries as $entry) {
+        $entry_link = $entry->getLink();
+        $race_name = $entry->getRace()->getLink();
+        echo "<p>Entry $entry_link in <strong>$race_name</strong></p>\n";
+      }
+    }
+  }
+
   function module_competitor($action) {
     if ($_POST['add_competitor']) {
       if (add_competitor($_POST["cmdr_name"], $_POST["forum_name"])) unset($_POST);
     }
 
     $q = new CompetitorQuery;
+    if ($action) $q->filterById($action);
     $competitors = $q->orderByCmdrName()->find();
     if (! count($competitors)) echo "<p>No competitors</p>\n";
     foreach ($competitors as $competitor) {
@@ -33,6 +59,7 @@
       $forum = $competitor->getForumName();
       if ($forum && $forum != $cmdr) echo " ($forum)";
       "</p>\n";
+      if ($action) show_competitor($competitor);
     }
 
     echo "<hr>\n";
index a203cda..419b6a7 100644 (file)
       foreach ($entries as $entry) {
         $entry_link = $entry->getLink();
         $race_name = $entry->getRace()->getLink();
+        $hull_name = $entry->getShip()->getHull()->getLink();
         $ship_name = $entry->getShip()->getLink();
         $cmdr_name = $entry->getShip()->getCompetitor()->getLink();
-        echo "<p>CMDR <strong>$cmdr_name</strong> flying <strong>$ship_name</strong> in <strong>$race_name</strong> [$entry_link]</p>\n";
+        echo "<p>CMDR <strong>$cmdr_name</strong> flying $hull_name <strong>$ship_name</strong> in <strong>$race_name</strong> [$entry_link]</p>\n";
       }
     }
     echo "<hr>\n";
index d8919c3..4619b43 100644 (file)
     return false;
   }
 
+  function show_hull($hull) {
+    $sq = new ShipQuery;
+    $sq->joinWith('Ship.Competitor');
+    $ships = $sq->findByHullId($hull->getId());
+    if (! count($ships)) return;
+
+    foreach ($ships as $ship) {
+      $cmdr_name = $ship->getCompetitor()->getLink();
+      $ship_name = $ship->getLink();
+      echo "<p>Ship: $ship_name flown by CMDR $cmdr_name</p>\n";
+      $eq = new EntryQuery;
+      $eq->joinWith('Entry.Race');
+      $entries = $eq->orderById()->findByShip($ship);
+      if (! count($entries)) continue;
+
+      foreach ($entries as $entry) {
+        $entry_link = $entry->getLink();
+        $race_name = $entry->getRace()->getLink();
+        echo "<p>Entry $entry_link in <strong>$race_name</strong></p>\n";
+      }
+    }
+  }
+
   function module_hull($action) {
     if ($_POST['add_hull']) {
       if (add_hull($_POST["name"])) unset($_POST);
     }
 
     $q = new HullQuery;
+    if ($action) $q->filterById($action);
     $hulls = $q->find();
     if (! count($hulls)) echo "<p>No hulls</p>\n";
     foreach ($hulls as $hull) {
       $name = $hull->getName();
       echo "<p><strong>$name</strong></p>\n";
+      if ($action) show_hull($hull);
     }
 
     echo "<hr>\n";
index 7c0547a..979c7fb 100644 (file)
     return false;
   }
 
+  function show_ship($ship) {
+    $eq = new EntryQuery;
+    $eq->joinWith('Entry.Race');
+    $eq->joinWith('Entry.Ship');
+    $eq->joinWith('Ship.Hull');
+    $entries = $eq->orderById()->findByShip($ship);
+    if (! count($entries)) return;
+
+    foreach ($entries as $entry) {
+      $entry_link = $entry->getLink();
+      $race_name = $entry->getRace()->getLink();
+      echo "<p>Entry $entry_link in <strong>$race_name</strong></p>\n";
+    }
+  }
+
   function module_ship($action) {
     if ($_POST['add_ship']) {
       if (add_ship($_POST["competitor_id"], $_POST["hull_id"], $_POST["name"])) unset($_POST);
@@ -28,6 +43,7 @@
     $q = new ShipQuery;
     $q->joinWith("Ship.Competitor");
     $q->joinWith("Ship.Hull");
+    if ($action) $q->filterById($action);
     $ships = $q->orderByName()->find();
     if (! count($ships)) echo "<p>No ships</p>\n";
     foreach ($ships as $ship) {
@@ -36,7 +52,8 @@
       $hull_name = $hull->getLink();
       $competitor = $ship->getCompetitor();
       $cmdr_name = $competitor->getLink();
-      echo "<p><strong>$name</strong> ($hull_name) CMDR $cmdr_name</p>\n";
+      echo "<p><strong>$name</strong> ($hull_name) flown by CMDR $cmdr_name</p>\n";
+      if ($action) show_ship($ship);
     }
 
     echo "<hr>\n";