/** * Statistics * * @todo Optimize */ function statistik($filter = '') { // count number of spots on each course $countPladser = 0; $countOptagne = 0; $db1 = new DB_Sql(); $sql = "SELECT id, pladser FROM kortkursus\r\n WHERE published=1\r\n AND tilmeldingsmulighed = 'Ja'\r\n AND DATE_FORMAT(dato_start, '%Y') >= 2005"; if (!empty($filter)) { $sql .= "\tAND gruppe_id = " . (int) $filter; } $sql .= " ORDER BY dato_start ASC"; $db1->query($sql); while ($db1->nextRecord()) { $countPladser += $db1->f('pladser'); $kursus = new VIH_Model_KortKursus($db1->f('id')); $countOptagne += $kursus->getOptagnePladser(); } if ($countPladser == 0) { $countPladser = 1; } $percent = round($countOptagne / $countPladser * 100, 0); return array('pladser' => $countPladser, 'percent' => $percent, 'optagne' => $countOptagne); }