コード例 #1
0
ファイル: Event.php プロジェクト: jonatanolofsson/solidba.se
 function attendanceStatistics()
 {
     $attending = $this->getAttendance();
     global $CONFIG, $Controller;
     if (!is_array($ig = $this->attending_groups)) {
         $ig = array();
     }
     $counter = array('yes' => array(), 'no' => array());
     $tcounter = array('yes' => 0, 'no' => 0);
     foreach ($attending as $id => $a) {
         ++$tcounter[$a['attending']];
     }
     $unknown = array();
     foreach ($ig as $gid) {
         $group = $Controller->get($gid, OVERRIDE);
         $counter['yes'][$group->Name] = 0;
         $counter['no'][$group->Name] = 0;
         $unknown[$group->Name] = count($group->memberUsers(true, true));
         if ($group) {
             foreach ($attending as $id => $a) {
                 if ($group->isMember($id)) {
                     $counter[$a['attending']][$group->ID] = @$counter[$group->Name] + 1;
                     --$unknown[$group->Name];
                 }
             }
         }
     }
     $colspan = 2 * count($ig) + 1;
     $r = '<table cellpadding="0" cellspacing="0" border="0">' . '<tr><th>' . __('Contact') . '</th>' . '<td colspan="' . $colspan . '">' . $this->contact . '</td>' . '</tr>' . '<tr><th>' . __('When') . '</th>' . '<td colspan="' . $colspan . '">' . Short::datespan($this->start, $this->end) . '</td>' . '</tr>' . '<tr><th>' . __('Last registration date') . '</th>' . '<td colspan="' . $colspan . '">' . date('Y-m-d', $this->soft_deadline) . '</td>' . '</tr>' . '<tr><th>' . __('Attending') . '</th>' . '<td>' . $tcounter['yes'] . '</td>';
     ksort($counter['yes']);
     foreach ($counter['yes'] as $g => $count) {
         $r .= '<td class="groupcol">' . $g . '</td><td>' . $count . '</td>';
     }
     $r .= '</tr><tr><th>' . __('Not attending') . '</th>' . '<td>' . $tcounter['no'] . '</td>';
     ksort($counter['no']);
     foreach ($counter['no'] as $g => $count) {
         $r .= '<td class="groupcol">' . $g . '</td><td>' . $count . '</td>';
     }
     $r .= '</tr><tr><th>' . __('Unknown') . '</th>' . '<td>' . array_sum($unknown) . '</td>';
     ksort($unknown);
     foreach ($unknown as $g => $count) {
         $r .= '<td class="groupcol">' . $g . '</td><td>' . $count . '</td>';
     }
     $r .= '</tr></table>';
     return $r;
 }