}
            $transaction->rollback();
        }
    }
}
$blockpage->display_header();
// Check we can actually do anything on this page.
iomad::require_capability('block/iomad_company_admin:company_view', $context);
// Get the number of companies.
$objectcount = $DB->count_records('company');
echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl);
flush();
if ($companies = company::get_companies_rs($page, $perpage)) {
    $stredit = get_string('edit');
    $strdelete = get_string('delete');
    $strusers = $blockpage->get_string('company_users');
    $strnewuser = $blockpage->get_string('newuser');
    $strmanagers = $blockpage->get_string('company_managers');
    $strcourses = $blockpage->get_string('company_courses');
    $strcreatecourse = $blockpage->get_string('newcourse');
    $strcourseusers = $blockpage->get_string('courseusers');
    $strusersdownload = $blockpage->get_string('users_download');
    $table = new html_table();
    $table->head = array("Name", "Short name", "City", "", "", "", "", "", "", "", "", "");
    $table->align = array("left", "left", "left", "center", "center", "center", "center", "center", "center", "center", "center", "center");
    $table->width = "95%";
    foreach ($companies as $company) {
        if (company_user::can_see_company($company)) {
            if (iomad::has_capability('block/iomad_company_admin:company_delete', $context)) {
                $deletebutton = "<a href=\"company_list.php?delete={$company->id}&amp;sesskey=" . sesskey() . "\">{$strdelete}</a>";
            } else {