if ($sgs->date_restriction() && time() > $sgs->get_date()) {
        $error = get_string('dateexpired', BLOCK_SG_LANG_TABLE);
    } else {
        $groupingid = $sgs->get_grouping_id();
        $sgrouping = new skills_grouping($courseid);
        // If user is in group - display error.
        if ($sgrouping->check_for_user_in_grouping($USER->id) !== false) {
            $error = get_string('alreadyingroup', BLOCK_SG_LANG_TABLE);
        }
    }
}
set_header();
echo $OUTPUT->header();
display_header();
display_group_view();
display_buttons();
load_yui_modules($courseid, $groupingid, $error);
echo $OUTPUT->footer();
/**
 * This function set the page header -> JS/CSS includes.
 *
 */
function set_header()
{
    global $PAGE;
    $PAGE->requires->css('/blocks/skills_group/css/skills_group.css');
    $PAGE->requires->js_module(get_js_module_info('gallery-datatable-selection'));
    $PAGE->requires->js_module(get_js_module_info('gallery-datatable-paginator'));
    $PAGE->requires->js_module(get_js_module_info('gallery-paginator-view'));
    $PAGE->requires->strings_for_js(array('groupsloading', 'emptygroups', 'groupsloaderror', 'groupjoinsuccess', 'groupjoinerror'), BLOCK_SG_LANG_TABLE);
}
function display_entry_row($row)
{
    echo "<tr>\n";
    echo "<td>&nbsp;</td>\n";
    // reservation name, with a link to the view_entry page
    echo "<td>";
    echo "<a href=\"view_entry.php?id=" . $row['id'] . "\">" . htmlspecialchars($row['name']) . "</a></td>\n";
    // create_by, area and room names
    echo "<td>" . htmlspecialchars($row['create_by']) . "</td>\n";
    echo "<td>" . htmlspecialchars($row['area_name']) . "</td>\n";
    echo "<td>" . htmlspecialchars($row['room_name']) . "</td>\n";
    // start date, with a link to the day.php
    $link = getdate($row['start_time']);
    echo "<td>";
    // <span> for sorting
    echo "<span title=\"" . $row['start_time'] . "\"></span>";
    echo "<a href=\"day.php?day={$link['mday']}&amp;month={$link['mon']}&amp;year={$link['year']}&amp;area=" . $row['area_id'] . "\">";
    if (empty($row['enable_periods'])) {
        $link_str = time_date_string($row['start_time']);
    } else {
        list(, $link_str) = period_date_string($row['start_time']);
    }
    echo "{$link_str}</a></td>";
    // action buttons
    echo "<td>\n";
    display_buttons($row, FALSE);
    echo "</td>\n";
    echo "</tr>\n";
}
function display_entry_row($row)
{
    echo "<tr>\n";
    echo "<td class=\"control\">&nbsp;</td>\n";
    // reservation name, with a link to the view_entry page
    echo "<td>";
    echo "<a href=\"view_entry/id:" . $row['id'] . "\">" . htmlspecialchars($row['name']) . "</a></td>\n";
    // create_by, area and room names
    echo "<td>" . htmlspecialchars($row['create_by']) . "</td>\n";
    echo "<td>" . htmlspecialchars($row['area_name']) . "</td>\n";
    echo "<td>" . htmlspecialchars($row['room_name']) . "</td>\n";
    // start date, with a link to the day.php
    $link = getdate($row['start_time']);
    echo "<td>";
    $url = formatURLFull($link[year], $link[mon], $link[mday], $row['area_id'], NULL);
    echo "<a href=\"day/{$url}\">";
    if (empty($row['enable_periods'])) {
        $link_str = time_date_string($row['start_time']);
    } else {
        list(, $link_str) = period_date_string($row['start_time']);
    }
    echo "{$link_str}</a></td>";
    // action buttons
    echo "<td>\n";
    display_buttons($row, FALSE);
    echo "</td>\n";
    echo "</tr>\n";
}