if (!empty($departmentids)) {
                $departmentids .= "," . $departmentuser->userid;
            } else {
                $departmentids .= $departmentuser->userid;
            }
        }
        $sqlsearch = " AND userid in ({$departmentids}) ";
    } else {
        $sqlsearch = "AND 1 = 0";
    }
    $userids = $DB->get_records_sql_menu("SELECT userid, userid as id\n        FROM\n            {company_users}\n        WHERE\n            companyid = :companyid\n            " . $sqlsearch, $params);
    switch ($format) {
        case 'csv':
            user_download_csv($userids, $fields, !$companyid);
        case 'ods':
            user_download_ods($userids, $fields, !$companyid);
        case 'xls':
            user_download_xls($userids, $fields, !$companyid);
    }
    die;
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('download', 'admin'));
// Get url of ourselves.
$url = new moodle_url('/blocks/iomad_company_admin/user_bulk_download.php', array('companyid' => $companyid));
// Show download options menu.
echo $OUTPUT->box_start();
echo '<ul>';
echo '<li><a href="' . $url->out(true, array('format' => 'csv')) . '">' . get_string('downloadtext') . '</a></li>';
echo '<li><a href="' . $url->out(true, array('format' => 'ods')) . '">' . get_string('downloadods') . '</a></li>';
echo '<li><a href="' . $url->out(true, array('format' => 'xls')) . '">' . get_string('downloadexcel') . '</a></li>';
Esempio n. 2
0
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
if (empty($SESSION->bulk_users)) {
    redirect($return);
}
if ($format) {
    $fields = array('id' => 'id', 'username' => 'username', 'email' => 'email', 'firstname' => 'firstname', 'lastname' => 'lastname', 'idnumber' => 'idnumber', 'institution' => 'institution', 'department' => 'department', 'phone1' => 'phone1', 'phone2' => 'phone2', 'city' => 'city', 'url' => 'url', 'icq' => 'icq', 'skype' => 'skype', 'aim' => 'aim', 'yahoo' => 'yahoo', 'msn' => 'msn', 'country' => 'country');
    if ($extrafields = $DB->get_records('user_info_field')) {
        foreach ($extrafields as $n => $v) {
            $fields['profile_field_' . $v->shortname] = 'profile_field_' . $v->shortname;
        }
    }
    switch ($format) {
        case 'csv':
            user_download_csv($fields);
        case 'ods':
            user_download_ods($fields);
        case 'xls':
            user_download_xls($fields);
    }
    die;
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('download', 'admin'));
echo $OUTPUT->box_start();
echo '<ul>';
echo '<li><a href="user_bulk_download.php?format=csv">' . get_string('downloadtext') . '</a></li>';
echo '<li><a href="user_bulk_download.php?format=ods">' . get_string('downloadods') . '</a></li>';
echo '<li><a href="user_bulk_download.php?format=xls">' . get_string('downloadexcel') . '</a></li>';
echo '</ul>';
echo $OUTPUT->box_end();
echo $OUTPUT->continue_button($return);
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
// if (empty($SESSION->bulk_users)) {
// redirect($return);
// }
if ($format) {
    $fields = array('id' => 'id', 'username' => 'username', 'email' => 'email', 'firstname' => 'firstname', 'lastname' => 'lastname', 'idnumber' => 'idnumber', 'institution' => 'institution', 'phone1' => 'phone1', 'phone2' => 'phone2', 'city' => 'city', 'url' => 'url', 'icq' => 'icq', 'skype' => 'skype', 'aim' => 'aim', 'yahoo' => 'yahoo', 'msn' => 'msn', 'country' => 'country');
    if ($extrafields = $DB->get_records('user_info_field')) {
        foreach ($extrafields as $n => $v) {
            $fields['profile_field_' . $v->shortname] = 'profile_field_' . $v->shortname;
        }
    }
    switch ($format) {
        case 'csv':
            user_download_csv($fields, $extrafields);
        case 'ods':
            user_download_ods($fields, $extrafields);
        case 'xls':
            user_download_xls($fields, $extrafields);
    }
    die;
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('download', 'admin'));
echo $OUTPUT->box_start();
echo '<ul>';
echo '<li><a href="user_bulk_download_list.php?format=csv">' . get_string('downloadtext') . '</a></li>';
echo '<li><a href="user_bulk_download_list.php?format=ods">' . get_string('downloadods') . '</a></li>';
echo '<li><a href="user_bulk_download_list.php?format=xls">' . get_string('downloadexcel') . '</a></li>';
echo '</ul>';
echo $OUTPUT->box_end();
echo $OUTPUT->continue_button($return);