Adding PDF export to the group overview page see BT#6985

1.9.x
Julio Montoya 11 years ago
parent d9c1b917e0
commit f227d91644
  1. 4
      main/group/group.php
  2. 55
      main/group/group_overview.php
  3. 61
      main/inc/lib/groupmanager.lib.php

@ -183,6 +183,8 @@ if (api_is_allowed_to_edit(false, true)) {
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="../user/user.php?'.api_get_cidreq().'">'. echo '<a href="../user/user.php?'.api_get_cidreq().'">'.
Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>';
@ -220,7 +222,7 @@ if (api_get_setting('allow_group_categories') == 'true') {
} }
} else { } else {
$group_list = GroupManager::get_group_list(); $group_list = GroupManager::get_group_list();
GroupManager ::process_groups($group_list); GroupManager::process_groups($group_list);
} }
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {

@ -42,6 +42,11 @@ if (isset($_GET['action'])) {
Export::export_table_csv($data); Export::export_table_csv($data);
exit; exit;
break; break;
case 'export_pdf':
$overview = GroupManager::getOverview($courseId, $keyword);
$pdf = new PDF();
$pdf ->content_to_pdf($overview);
break;
case 'export': case 'export':
$groupId = isset($_GET['id']) ? intval($_GET['id']) : null; $groupId = isset($_GET['id']) ? intval($_GET['id']) : null;
$groups = GroupManager::get_group_list(); $groups = GroupManager::get_group_list();
@ -101,6 +106,7 @@ echo '<div class="actions">';
Display::return_icon('new_group.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('new_group.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group.php?'.api_get_cidreq().'">'. echo '<a href="group.php?'.api_get_cidreq().'">'.
Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
if (api_get_setting('allow_group_categories') == 'true') { if (api_get_setting('allow_group_categories') == 'true') {
echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'. echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>';
@ -114,6 +120,9 @@ echo '<div class="actions">';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=csv">'. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=csv">'.
Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'. echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
@ -123,51 +132,7 @@ echo '<div class="actions">';
$form->display(); $form->display();
echo '</div>'; echo '</div>';
$categories = GroupManager::get_categories(); echo GroupManager::getOverview($courseId, $keyword);
foreach ($categories as $category) {
if (api_get_setting('allow_group_categories') == 'true') {
echo '<h2>'.$category['title'].'</h2>';
}
if (!empty($keyword)) {
$groups = GroupManager::getGroupListFilterByName($keyword, $category['id'], $courseId);
} else {
$groups = GroupManager::get_group_list($category['id']);
}
echo '<ul>';
if (!empty($groups)) {
foreach ($groups as $group) {
echo '<li>';
echo Display::tag('h3', Security::remove_XSS($group['name']));
$users = GroupManager::getTutors($group['id']);
if (!empty($users)) {
echo '<ul>';
echo Display::tag('h4', get_lang('Tutors'));
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
//$username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES);
echo '<li title="'.$user_info['username'].'">'.$user_info['complete_name_with_username'].'</li>';
}
echo '</ul>';
}
$users = GroupManager::getStudents($group['id']);
if (!empty($users)) {
echo '<ul>';
echo Display::tag('h4', get_lang('Students'));
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
echo '<li title="'.$user_info['username'].'">'.$user_info['complete_name_with_username'].'</li>';
}
echo '</ul>';
}
echo '</li>';
}
}
echo '</ul>';
}
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
Display::display_footer(); Display::display_footer();

@ -2355,4 +2355,65 @@ class GroupManager
</li> </li>
</ul>'; </ul>';
} }
/**
* @param int $courseId
* @param string $keyword
* @return string
*/
public static function getOverview($courseId, $keyword = null)
{
$content = null;
$categories = GroupManager::get_categories();
if (!empty($categories)) {
foreach ($categories as $category) {
if (api_get_setting('allow_group_categories') == 'true') {
$content .= '<h2>'.$category['title'].'</h2>';
}
if (!empty($keyword)) {
$groups = GroupManager::getGroupListFilterByName($keyword, $category['id'], $courseId);
} else {
$groups = GroupManager::get_group_list($category['id']);
}
$content .= '<ul>';
if (!empty($groups)) {
foreach ($groups as $group) {
$content .= '<li>';
$content .= Display::tag('h3', Security::remove_XSS($group['name']));
$users = GroupManager::getTutors($group['id']);
if (!empty($users)) {
$content .= '<ul>';
$content .= "<li>".Display::tag('h4', get_lang('Tutors'))."</li><ul>";
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
$content .= '<li title="'.$user_info['username'].'">'.$user_info['complete_name_with_username'].'</li>';
}
$content .= '</ul>';
$content .= '</ul>';
}
$users = GroupManager::getStudents($group['id']);
if (!empty($users)) {
$content .= '<ul>';
$content .= "<li>".Display::tag('h4', get_lang('Students'))."</li><ul>";
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
$content .= '<li title="'.$user_info['username'].'">'.$user_info['complete_name_with_username'].'</li>';
}
$content .= '</ul>';
$content .= '</ul>';
}
$content .= '</li>';
}
}
$content .= '</ul>';
}
}
return $content;
}
} }

Loading…
Cancel
Save