"index.php", "name" => get_lang('MySpace'));
Display :: display_header($nameTools);
$formateurs = array();
if (api_is_drh() || api_is_platform_admin()) {
// followed teachers by drh
$formateurs = UserManager::get_users_followed_by_drh($_user['user_id'], COURSEMANAGER);
$menu_items = array();
$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
$menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), 32), "index.php?view=drh_students&display=yourstudents");
$menu_items[] = Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), 32);
$menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), 32), 'course.php');
$menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php');
echo '
';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
}
}
if (count($formateurs) > 0) {
echo '';
echo Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), 32), 'javascript: void(0);', array('onclick'=>'javascript: window.print();'));
echo Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32), api_get_self().'?export=xls');
echo '';
}
echo '
';
echo Display::page_subheader(get_lang('YourTeachers'));
}
if (!api_is_drh()) {
api_display_tool_title($nameTools);
}
/**
* MAIN PART
*/
if (isset($_POST['export'])) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
} else {
$is_western_name_order = api_is_western_name_order();
}
$sort_by_first_name = api_sort_by_first_name();
if (!api_is_drh() && !api_is_platform_admin()) {
$order_clause = $sort_by_first_name ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
if (isset($_GET["teacher_id"]) && $_GET["teacher_id"] != 0) {
$teacher_id = intval($_GET["teacher_id"]);
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE user_id='$teacher_id'".$order_clause;
} else {
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE status = 1".$order_clause;
}
$result_formateurs = Database::query($sql_formateurs);
if (Database::num_rows($result_formateurs) > 0) {
while ($row_formateurs = Database::fetch_array($result_formateurs)) {
$formateurs[] = $row_formateurs;
}
}
}
$time_filter = 'last_7_days';
$time_label = sprintf(get_lang('TimeSpentLastXDays'), 7);
$form = new FormValidator('time_filter');
$form->addElement('datepickerdate', 'start_date', get_lang('StartDate'), array('form_name'=>'exercise_admin'));
$form->addElement('datepickerdate', 'end_date', get_lang('EndDate'), array('form_name'=>'exercise_admin'));
$form->addRule('start_date', get_lang('InvalidDate'), 'date');
$form->addRule('end_date', get_lang('InvalidDate'), 'date');
$form->addRule(array ('start_date', 'end_date'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
$defaults = array();
$defaults['start_date'] = date('Y-m-d 12:00:00', strtotime("-7 days"));
$defaults['end_date'] = date('Y-m-d 12:00:00',time());
$start_date = $end_date = null;
if ($form->validate()) {
$values = $form->exportValues();
$start_date = $defaults['start_date'] = $values['start_date'];
$end_date = $defaults['end_date'] = $values['end_date'];
$time_filter = 'custom';
$time_label = sprintf(get_lang('TimeSpentBetweenXAndY'), $start_date, $end_date);
}
$form->setDefaults($defaults);
$form->addelement('style_submit_button', 'submit', get_lang('Filter'));
$form->display();
if ($is_western_name_order) {
echo ''.get_lang('FirstName').' | '.get_lang('LastName').' | '.$time_label.' | '.get_lang('Email').' | '.get_lang('AdminCourses').' | '.get_lang('Students').' |
';
} else {
echo ''.get_lang('LastName').' | '.get_lang('FirstName').' | '.$time_label.' | '.get_lang('Email').' | '.get_lang('AdminCourses').' | '.get_lang('Students').' |
';
}
if ($is_western_name_order) {
$header[] = get_lang('FirstName');
$header[] = get_lang('LastName');
} else {
$header[] = get_lang('LastName');
$header[] = get_lang('FirstName');
}
$header[] = $time_label;
$header[] = get_lang('Email');
$data = array();
if (count($formateurs) > 0) {
$i = 1;
foreach ($formateurs as $formateur) {
$user_id = $formateur["user_id"];
$lastname = $formateur["lastname"];
$firstname = $formateur["firstname"];
$email = $formateur["email"];
if ($i % 2 == 0) {
$css_class = "row_odd";
if ($i % 20 == 0 && $i != 0) {
if ($is_western_name_order) {
echo ''.get_lang('FirstName').' | '.get_lang('LastName').' | '.get_lang('Email').' | '.get_lang('AdminCourses').' | '.get_lang('Students').' |
';
} else {
echo ''.get_lang('LastName').' | '.get_lang('FirstName').' | '.get_lang('Email').' | '.get_lang('AdminCourses').' | '.get_lang('Students').' |
';
}
}
} else {
$css_class = "row_even";
}
$i++;
if ($is_western_name_order) {
$data[$user_id]["firstname"] = $firstname;
$data[$user_id]["lastname"] = $lastname;
} else {
$data[$user_id]["lastname"] = $lastname;
$data[$user_id]["firstname"] = $firstname;
}
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($user_id, $time_filter, $start_date, $end_date));
$data[$user_id]["timespentlastweek"] = $time_on_platform;
$data[$user_id]["email"] = $email;
if ($is_western_name_order) {
echo ''.$firstname.' | '.$lastname.' | '.$time_on_platform.' | '.$email.' | | |
';
} else {
echo ''.$lastname.' | '.$firstname.' | '.$time_on_platform.' | '.$email.' | | |
';
}
}
} else {
// No results
echo ''.get_lang("NoResults").' |
';
}
echo '
';
if (isset($_POST['export']) || (api_is_drh() && isset($_GET['export']))) {
MySpace::export_csv($header, $data, 'teachers.csv');
}
if (!api_is_drh()) {
echo "