/** * Vise forskjellig statistikk for gta */ protected function stats_show() { ess::$b->page->add_title("Statistikk"); // hent antall forsøk og vellykkede spredt på hver bydel $stats_totalt = array(); $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT b_id, MAX(time_last) max_time_last, SUM(count) sum_count, SUM(success) sum_success\n\t\t\tFROM gta_options_status\n\t\t\t\tJOIN gta_options ON optionid = gta_options.id\n\t\t\tWHERE gos_up_id = {$this->gta->up->id}\n\t\t\tGROUP BY b_id"); while ($row = $result->fetch()) { $stats_totalt[$row['b_id']] = $row; } // hent informasjon om bydelene $bydeler = $this->gta->get_bydeler_info(); echo ' <h1>Statistikk for biltyveri</h1> <div class="bg1_c small"> <h1 class="bg1">Bydeler<span class="left2"></span><span class="right2"></span></h1> <div class="bg1">'; if (count($stats_totalt) == 0) { echo ' <p>Du har ikke gjennomført noen forsøk på biltyveri.</p>'; } else { echo ' <table class="table center tablem"> <thead> <tr> <th>Bydel</th> <th>Antall forsøk</th> <th>Antall vellykkede</th> <th>Forrige forsøk</th> </tr> </thead> <tbody class="r">'; $i = 0; foreach (game::$bydeler as $bydel) { if ($bydel['active'] == 0) { continue; } if (isset($stats_totalt[$bydel['id']])) { $forsok = $stats_totalt[$bydel['id']]['sum_count']; $vellykkede = $stats_totalt[$bydel['id']]['sum_success']; $siste = ess::$b->date->get($stats_totalt[$bydel['id']]['max_time_last'])->format(); echo ' <tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '> <td class="l">' . htmlspecialchars($bydel['name']) . '</td> <td>' . $forsok . '</td> <td>' . $vellykkede . '</td> <td>' . $siste . '</td> </tr>'; } else { echo ' <tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '> <td class="l">' . htmlspecialchars($bydel['name']) . '</td> <td class="c dark" colspan="3"><i>Ingen forsøk</i></td> </tr>'; } } echo ' </tbody> </table>'; } echo ' </div> </div> <div class="bg1_c xmedium"> <h1 class="bg1">Garasjer<span class="left2"></span><span class="right2"></span></h1> <div class="bg1"> <table class="table center tablem"> <thead> <tr> <th>Bydel</th> <th>Firma</th> <th>Kapasitet</th> <th>Biler i garasjen</th> <th>Ledige plasser</th> <th>Neste frist</th> </tr> </thead> <tbody class="c">'; $i = 0; foreach ($bydeler as $b_id => $row) { $bydel = game::$bydeler[$b_id]; if ($bydel['active'] == 0) { continue; } echo ' <tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '> <td class="l">' . htmlspecialchars($bydel['name']) . '</td>'; if (!$row['ff_id']) { echo ' <td class="dark" colspan="5"><i>Ingen garasje</i></td>'; } else { $ant = $row['garage_max_cars'] - $row['cars']; if ($ant < 0) { $ant = 0; } echo ' <td><a href="&rpath;/ff/?ff_id=' . $row['ff_id'] . '">' . htmlspecialchars($row['ff_name']) . '</a></td> <td>' . game::format_num($row['garage_max_cars']) . '</td> <td>' . game::format_num($row['cars']) . '</td> <td><b>' . game::format_num($ant) . '</b></td> <td>' . ess::$b->date->get($row['garage_next_rent'])->format("d.m H:i") . '</td>'; } echo ' </tr>'; } echo ' </tbody> </table> </div> </div>'; }
/** * Hent inn GTA info */ protected function get_gta() { // hent garasjer $gta = new gta($this->up); $this->gta_garage = $gta->get_bydeler_info(); // sett opp antall biler i nåværende bydel if (!isset($this->gta_garage[$this->up->data['up_b_id']])) { $this->gta_count = 0; return; } $this->gta_count = $this->gta_garage[$this->up->data['up_b_id']]['cars']; }
<?php gta::biltyveri_prob_decrease();