/** * Build the html_table object to represent details * @return html_table */ public function html_table() { global $OUTPUT, $doShowPrintableVersion; $strNotAvail = get_string('notavailable'); $table = new html_table(); $table->attributes['class'] .= ' attendanceregister_userlist table table-condensed table-bordered table-striped table-hover'; /// Header $table->head = array(get_string('count', 'attendanceregister'), get_string('fullname', 'attendanceregister'), get_string('total_time_online', 'attendanceregister')); $table->align = array('left', 'left', 'right'); if ($this->register->offlinesessions) { $table->head[] = get_string('total_time_offline', 'attendanceregister'); $table->align[] = 'right'; $table->head[] = get_string('grandtotal_time', 'attendanceregister'); $table->align[] = 'right'; } $table->head[] = get_string('last_session_logout', 'attendanceregister'); $table->align[] = 'left'; /// Table Rows if ($this->users) { $rowcount = 0; foreach ($this->users as $user) { $rowcount++; $userAggregate = null; if (isset($this->usersSummaryAggregates[$user->id])) { $userAggregate = $this->usersSummaryAggregates[$user->id]; } // Basic columns $linkUrl = attendanceregister_makeUrl($this->register, $user->id); $fullnameWithLink = '<a href="' . $linkUrl . '">' . fullname($user) . '</a>'; $onlineDuration = $userAggregate ? $userAggregate->onlineTotalDuration : null; $onlineDurationStr = attendanceregister_format_duration($onlineDuration); $tableRow = new html_table_row(array($rowcount, $fullnameWithLink, $onlineDurationStr)); // Add class for zebra stripes $tableRow->attributes['class'] .= $rowcount % 2 ? ' attendanceregister_oddrow' : ' attendanceregister_evenrow'; // Optional columns if ($this->register->offlinesessions) { $offlineDuration = $userAggregate ? $userAggregate->offlineTotalDuration : null; $offlineDurationStr = attendanceregister_format_duration($offlineDuration); $tableCell = new html_table_cell($offlineDurationStr); $tableRow->cells[] = $tableCell; $grandtotalDuration = $userAggregate ? $userAggregate->grandTotalDuration : null; $grandtotalDurationStr = attendanceregister_format_duration($grandtotalDuration); $tableCell = new html_table_cell($grandtotalDurationStr); $tableRow->cells[] = $tableCell; } $lastSessionLogoutStr = $userAggregate ? attendanceregister__formatDateTime($userAggregate->lastSassionLogout) : get_string('no_session', 'attendanceregister'); $tableCell = new html_table_cell($lastSessionLogoutStr); $tableRow->cells[] = $tableCell; $table->data[] = $tableRow; } } else { // No User $row = new html_table_row(); $labelCell = new html_table_cell(); $labelCell->colspan = count($table->head); $labelCell->text = get_string('no_tracked_user', 'attendanceregister'); $row->cells[] = $labelCell; $table->data[] = $row; } return $table; }
/** * Build the html_table object to represent details * @return html_table */ public function html_table() { global $OUTPUT, $doShowPrintableVersion; $table = new html_table(); $table->attributes['class'] .= ' attendanceregister_sessionlist table table-condensed table-bordered table-striped table-hover'; /// Header $table->head = array(get_string('count', 'attendanceregister'), get_string('start', 'attendanceregister'), get_string('end', 'attendanceregister'), get_string('online_offline', 'attendanceregister')); $table->align = array('left', 'left', 'left', 'right'); if ($this->register->offlinesessions) { $table->head[] = get_string('online_offline', 'attendanceregister'); $table->align[] = 'center'; if ($this->register->offlinespecifycourse) { $table->head[] = get_string('ref_course', 'attendanceregister'); $table->align[] = 'left'; } if ($this->register->offlinecomments) { $table->head[] = get_string('comments', 'attendanceregister'); $table->align[] = 'left'; } } /// Table rows if ($this->userSessions) { $stronline = get_string('online', 'attendanceregister'); $stroffline = get_string('offline', 'attendanceregister'); // Iterate sessions $rowcount = 0; foreach ($this->userSessions as $session) { $rowcount++; // Rowcount column $rowcountStr = (string) $rowcount; // Offline Delete button (if Session is offline and the current user may delete this user's offline sessions) if (!$session->onlinesess && $this->userCapabilites->canDeleteThisUserOfflineSession($session->userid)) { $deleteUrl = attendanceregister_makeUrl($this->register, $session->userid, null, ATTENDANCEREGISTER_ACTION_DELETE_OFFLINE_SESSION, array('session' => $session->id)); $confirmAction = new confirm_action(get_string('are_you_sure_to_delete_offline_session', 'attendanceregister')); $rowcountStr .= ' ' . $OUTPUT->action_icon($deleteUrl, new pix_icon('t/delete', get_string('delete')), $confirmAction); } // Duration $duration = attendanceregister_format_duration($session->duration); // Basic columns $tableRow = new html_table_row(array($rowcountStr, attendanceregister__formatDateTime($session->login), attendanceregister__formatDateTime($session->logout), $duration)); // Add class for zebra stripes $tableRow->attributes['class'] .= $rowcount % 2 ? ' attendanceregister_oddrow' : ' attendanceregister_evenrow'; // Optional columns if ($this->register->offlinesessions) { // Offline/Online $onlineOfflineStr = $session->onlinesess ? $stronline : $stroffline; // if saved by other if ($session->addedbyuserid) { // Retrieve the other user, if any, or unknown $a = attendanceregister__otherUserFullnameOrUnknown($session->addedbyuserid); $addedByStr = get_string('session_added_by_another_user', 'attendanceregister', $a); $onlineOfflineStr = html_writer::tag('a', $onlineOfflineStr . '*', array('title' => $addedByStr, 'class' => 'addedbyother')); } $tableCell = new html_table_cell($onlineOfflineStr); $tableCell->attributes['class'] .= $session->onlinesess ? ' online_label' : ' offline_label'; $tableRow->attributes['class'] .= $session->onlinesess ? ' success' : ''; $tableRow->cells[] = $tableCell; // Ref.Course if ($this->register->offlinespecifycourse) { if ($session->onlinesess) { $refCourseName = ''; } else { if ($session->refcourse) { $refCourse = $this->trackedCourses->courses[$session->refcourse]; // In Printable Version show fullname (shortname), otherwise only shortname if ($doShowPrintableVersion) { $refCourseName = $refCourse->fullname . ' (' . $refCourse->shortname . ')'; } else { $refCourseName = $refCourse->shortname; } } else { $refCourseName = get_string('not_specified', 'attendanceregister'); } } $tableCell = new html_table_cell($refCourseName); $tableRow->cells[] = $tableCell; } // Offline Comments if ($this->register->offlinecomments) { if (!$session->onlinesess && $session->comments) { // Shorten the comments (if !printable) if (!$doShowPrintableVersion) { $comment = attendanceregister__shorten_comment($session->comments); } else { $comment = $session->comments; } } else { $comment = ''; } $tableCell = new html_table_cell($comment); $tableRow->cells[] = $tableCell; } } $table->data[] = $tableRow; } } else { // No Session $row = new html_table_row(); $labelCell = new html_table_cell(); $labelCell->colspan = count($table->head); $labelCell->text = get_string('no_session_for_this_user', 'attendanceregister'); $row->cells[] = $labelCell; $table->data[] = $row; } return $table; }
/** * Build the html_table object to represent summary * @return html_table */ public function html_table() { global $OUTPUT, $doShowPrintableVersion; $table = new html_table(); $table->attributes['class'] .= ' attendanceregister_usersummary table table-condensed table-bordered table-striped table-hover'; // Header $table->head[] = get_string('user_sessions_summary', 'attendanceregister'); $table->headspan = array(3); // Previous Site-wise Login (is Moodle's _last_ login) $row = new html_table_row(); $labelCell = new html_table_cell(); $labelCell->colspan = 2; $labelCell->text = get_string('prev_site_login', 'attendanceregister'); $row->cells[] = $labelCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister__formatDateTime($this->user->lastlogin); $row->cells[] = $valueCell; $table->data[] = $row; // Last Site-wise Login (is Moodle's _current_ login) $row = new html_table_row(); $labelCell = new html_table_cell(); $labelCell->colspan = 2; $labelCell->text = get_string('last_site_login', 'attendanceregister'); $row->cells[] = $labelCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister__formatDateTime($this->user->currentlogin); $row->cells[] = $valueCell; $table->data[] = $row; // Last Site-wise access $row = new html_table_row(); $labelCell = new html_table_cell(); $labelCell->colspan = 2; $labelCell->text = get_string('last_site_access', 'attendanceregister'); $row->cells[] = $labelCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister__formatDateTime($this->user->lastaccess); $row->cells[] = $valueCell; $table->data[] = $row; // Last Calculated Session Logout $row = new html_table_row(); $labelCell = new html_table_cell(); $labelCell->colspan = 2; $labelCell->text = get_string('last_calc_online_session_logout', 'attendanceregister'); $row->cells[] = $labelCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister__formatDateTime($this->lastSassionLogout); $row->cells[] = $valueCell; $table->data[] = $row; // Separator $table->data[] = 'hr'; // Online Total $row = new html_table_row(); $row->attributes['class'] .= ' attendanceregister_onlinesubtotal success'; $labelCell = new html_table_cell(); $labelCell->colspan = 2; $labelCell->text = get_string('online_sessions_total_duration', 'attendanceregister'); $row->cells[] = $labelCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister_format_duration($this->onlineTotalDuration); $row->cells[] = $valueCell; $table->data[] = $row; // Offline if ($this->offlineTotalDuration) { // Separator $table->data[] = 'hr'; // Offline per RefCourse (if any) foreach ($this->perCourseOfflineSessions as $refCourseId => $courseOfflineSessions) { $row = new html_table_row(); $row->attributes['class'] .= ''; $labelCell = new html_table_cell(); $labelCell->text = get_string('offline_refcourse_duration', 'attendanceregister'); $row->cells[] = $labelCell; $courseCell = new html_table_cell(); if ($refCourseId) { $courseCell->text = $this->userSessions->trackedCourses->courses[$refCourseId]->fullname; } else { $courseCell->text = get_string('not_specified', 'attendanceregister'); } $row->cells[] = $courseCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister_format_duration($courseOfflineSessions); $row->cells[] = $valueCell; $table->data[] = $row; } // Offline no-RefCourse (if any) if ($this->noCourseOfflineSessions) { $row = new html_table_row(); $row->attributes['class'] .= ''; $labelCell = new html_table_cell(); $labelCell->text = get_string('offline_refcourse_duration', 'attendanceregister'); $row->cells[] = $labelCell; $courseCell = new html_table_cell(); $courseCell->text = get_string('no_refcourse', 'attendanceregister'); $row->cells[] = $courseCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister_format_duration($this->noCourseOfflineSessions); $row->cells[] = $valueCell; $table->data[] = $row; } // Offline Total (if any) $row = new html_table_row(); $row->attributes['class'] .= ' attendanceregister_offlinesubtotal'; $labelCell = new html_table_cell(); $labelCell->colspan = 2; $labelCell->text = get_string('offline_sessions_total_duration', 'attendanceregister'); $row->cells[] = $labelCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister_format_duration($this->offlineTotalDuration); $row->cells[] = $valueCell; $table->data[] = $row; // GrandTotal $row = new html_table_row(); $row->attributes['class'] .= ' attendanceregister_grandtotal active'; $labelCell = new html_table_cell(); $labelCell->colspan = 2; $labelCell->text = get_string('sessions_grandtotal_duration', 'attendanceregister'); $row->cells[] = $labelCell; $valueCell = new html_table_cell(); $valueCell->text = attendanceregister_format_duration($this->grandTotalDuration); $row->cells[] = $valueCell; $table->data[] = $row; } return $table; }