public function GetOutput($Db)
 {
     global $sort, $ord, $cols;
     // req for sorting
     $Journal = new eveApiJournal($Db);
     $full_url = FULL_URL;
     // TODO
     $time_start = microtime_float();
     $acct = isset($_GET['div']) ? $_GET['div'] + 999 : 1000;
     if (!$Journal->fetch(CHAR_ID, USER_ID, API_KEY, CORP_MODE, $acct)) {
         $this->Output = $Journal->Error;
         return false;
     }
     $time_end = microtime_float();
     $time_api = $time_end - $time_start;
     $this->Updated = APITime($Journal);
     $this->Title = "Journal for " . USER_NAME;
     /////////////////////////////////////////////////
     $ord = "ASC";
     $cols = array("date", "type", "amount", "balance", "description", "reason");
     $sort = null;
     $this->Output .= sort_ctrl();
     if (!$sort) {
         $sort = "date";
         $ord = "DESC";
     }
     $this->Output .= div_select($acct);
     if (count($Journal->entries) > 0) {
         $this->Output .= number_format((int) $Journal->entries[0]["balance"], 2) . " ISK<br><br>";
         $this->Output .= count($Journal->entries) . " entries<br>";
         $this->Output .= "<table class=\"fancy journal\" style=\"font-size:83%;\" border=1>";
         $this->Output .= "<tr>";
         foreach ($cols as $col) {
             $this->Output .= "<th>";
             if (!isset($nosorting)) {
                 $this->Output .= "<a href=\"{$full_url}&view=journal&sort={$col}&order=" . ($sort == $col && $ord == "ASC" ? "DESC" : "ASC") . "\">";
             }
             $this->Output .= $col;
             if (!isset($nosorting)) {
                 $this->Output .= "</a>";
             }
             $this->Output .= "</th>";
         }
         $this->Output .= "</tr>";
         $entries = $Journal->entries;
         if ($sort != null && array_key_exists($sort, $entries[0])) {
             usort($entries, "globl_sortfunc");
         }
         $alt = " class=\"main\"";
         foreach ($entries as $entry) {
             if ($alt == " class=\"main\"") {
                 $alt = " class=\"alt\"";
             } else {
                 $alt = " class=\"main\"";
             }
             $this->Output .= "<tr{$alt}>";
             $this->Output .= "<th scope=\"row\">" . str_replace(" ", "&nbsp;", $entry["date"]) . "&nbsp;</th>";
             $this->Output .= "<td>" . str_replace(" ", "&nbsp;", $entry["typeNice"]) . "</td>";
             $this->Output .= "<td align=right style=\"color: " . ($entry["amount"] > -1 ? "#007700" : "#BB0000") . ";\">&nbsp;" . number_format($entry["amount"], 2) . "&nbsp;ISK</td>";
             $this->Output .= "<td align=right>&nbsp;" . number_format($entry["balance"], 2) . "&nbsp;ISK&nbsp;&nbsp;</td>";
             $this->Output .= "<td>" . $entry["description"] . "</td>";
             $this->Output .= "<td nowrap=\"nowrap\" width=\"400\">" . $entry["reason"] . "&nbsp;</td>";
             $this->Output .= "</tr>\n";
         }
         $this->Output .= "</table>";
     } else {
         $this->Output .= (CORP_MODE ? "Division" : "Character") . " has no Journal activity in the last 3 months.<br>";
     }
     $this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start);
     return true;
 }
 public function GetOutput($Db)
 {
     global $sort, $ord, $cols;
     // req for sorting
     $Transactions = new eveApiTransactions($Db);
     $full_url = FULL_URL;
     // TODO
     $time_start = microtime_float();
     $acct = isset($_GET['div']) ? $_GET['div'] + 999 : 1000;
     if (!$Transactions->fetch(CHAR_ID, USER_ID, API_KEY, CORP_MODE, $acct)) {
         $this->Output = $Transactions->Error;
         return false;
     }
     $time_end = microtime_float();
     $time_api = $time_end - $time_start;
     $this->Updated = APITime($Transactions);
     $this->Title = "Transactions for " . USER_NAME;
     /////////////////////////////////////////////////
     $result = $Transactions->entries;
     $ord = "ASC";
     $cols = array("date", "type", "price", "quantity", "total", "client", "station");
     $sort = null;
     $this->Output .= sort_ctrl();
     if (!$sort) {
         $sort = "date";
         $ord = "DESC";
     }
     $this->Output .= div_select($acct);
     if (count($result) > 0) {
         $this->Output .= "<br>" . count($result) . " entries<br>";
         $this->Output .= "<table class=\"fancy trans\" style=\"font-size:83%;\" border=1>";
         $this->Output .= "<tr>";
         foreach ($cols as $col) {
             $this->Output .= "<th>";
             if (!isset($nosorting)) {
                 $this->Output .= "<a href=\"{$full_url}&view=transactions&sort={$col}&order=" . ($sort == $col && $ord == "ASC" ? "DESC" : "ASC") . "\">";
             }
             $this->Output .= $col;
             if (!isset($nosorting)) {
                 $this->Output .= "</a>";
             }
             $this->Output .= "</th>";
         }
         $ids = array();
         foreach ($result as &$entry) {
             $ids[] = (string) $entry['clientID'];
         }
         $ids = array_unique($ids);
         $redIDS = GetRedIDS($ids, $Db);
         if (isset($redIDS[0]) && $redIDS[0] == 0) {
             $redIDS = array();
         }
         $this->Output .= "</tr>";
         //("date","type","price","total","client","station"
         if ($sort != null && array_key_exists($sort, $result[0])) {
             usort($result, "globl_sortfunc");
         }
         $alt = " class=\"main\"";
         $alt_b = false;
         foreach ($result as $entry) {
             $alt_b = !$alt_b;
             $this->Output .= "<tr ";
             if (in_array($entry['clientID'], $redIDS)) {
                 if ($alt_b) {
                     $this->Output .= " class=\"redAlt";
                 } else {
                     $this->Output .= " class=\"redMain";
                 }
             } else {
                 if ($alt_b) {
                     $this->Output .= " class=\"alt";
                 } else {
                     $this->Output .= " class=\"main";
                 }
             }
             $this->Output .= ($entry["corp"] && !CORP_MODE ? " corp_entry_row" : "") . "\">";
             $this->Output .= "<th scope=\"row\">" . str_replace(" ", "&nbsp;", $entry["date"]) . "&nbsp;</th>";
             $this->Output .= "<td>" . str_replace(" ", "&nbsp;", $entry["type"]) . "</td>";
             $this->Output .= "<td align=right >" . number_format($entry["price"], 2) . "&nbsp;ISK</td>";
             $this->Output .= "<td align=center> " . $entry["quantity"] . "</td>";
             $this->Output .= "<td align=right style=\"color: " . ($entry["total"] > -1 ? "#007700" : "#BB0000") . ";\">&nbsp;" . number_format($entry["total"], 2) . "&nbsp;ISK</td>";
             $this->Output .= "<td>&nbsp;" . $entry["client"] . "&nbsp;&nbsp;</td>";
             $this->Output .= "<td width=\"*\">" . $entry["station"] . "&nbsp;</td>";
             $this->Output .= "</tr>\n";
         }
         $this->Output .= "</table>";
     } else {
         $this->Output .= (CORP_MODE ? "Division" : "Character") . " has no recent transactions.<br><br>";
     }
     $this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start);
     return true;
 }