'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[]=array('url' => 'session_list.php','name' => get_lang('SessionList'));
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_class = Database::get_main_table(TABLE_MAIN_CLASS);
$tbl_class_rel_user = Database::get_main_table(TABLE_MAIN_CLASS_USER);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$id_session = (int)$_GET['id_session'];
$sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
FROM '.$tbl_session.' LEFT JOIN '.$tbl_user.' ON id_coach = user_id
WHERE '.$tbl_session.'.id='.$id_session;
$rs = Database::query($sql);
$session = Database::store_result($rs);
$session = $session[0];
if(!api_is_platform_admin() && $session['session_admin_id']!=$_user['user_id']) {
api_not_allowed(true);
}
$sql = 'SELECT name FROM '.$tbl_session_category.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs = Database::query($sql);
$session_category = '';
if(Database::num_rows($rs)>0) {
$rows_session_category = Database::store_result($rs);
$rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name'];
}
if($_GET['action'] == 'delete') {
$idChecked = $_GET['idChecked'];
if(is_array($idChecked)) {
$my_temp = array();
foreach ($idChecked as $id){
$my_temp[]= Database::escape_string($id);// forcing the escape_string
}
$idChecked = $my_temp;
$idChecked="'".implode("','",$idChecked)."'";
Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)");
$nbr_affected_rows=Database::affected_rows();
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)");
Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
}
if(!empty($_GET['class'])){
Database::query("DELETE FROM $tbl_session_rel_class WHERE session_id='$id_session' AND class_id=".Database::escape_string($_GET['class']));
$nbr_affected_rows=Database::affected_rows();
Database::query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$id_session'");
}
if (!empty($_GET['user'])) {
Database::query("DELETE FROM $tbl_session_rel_user WHERE relation_type<>".SESSION_RELATION_TYPE_RRHH." AND id_session='$id_session' AND id_user=".intval($_GET['user']));
$nbr_affected_rows=Database::affected_rows();
Database::query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'");
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND id_user=".intval($_GET['user']));
$nbr_affected_rows=Database::affected_rows();
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'");
}
}
Display::display_header($tool_name);
if (!empty($_GET['warn'])) {
Display::display_warning_message(urldecode($_GET['warn']));
}
api_display_tool_title($tool_name);
?>
|
|
|
|
|
'.get_lang('NoCoursesForThisSession').' |
';
}
else {
// select the courses
$sql = "SELECT code,title,visual_code, nbr_users
FROM $tbl_course,$tbl_session_rel_course
WHERE course_code = code
AND id_session='$id_session'
ORDER BY title";
$result=Database::query($sql);
$courses=Database::store_result($result);
foreach($courses as $course){
//select the number of users
$sql = " SELECT count(*) FROM $tbl_session_rel_user sru, $tbl_session_rel_course_rel_user srcru
WHERE srcru.id_user = sru.id_user AND srcru.id_session = sru.id_session AND srcru.course_code = '".Database::escape_string($course['code'])."'
AND sru.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND srcru.id_session = '".intval($id_session)."'";
$rs = Database::query($sql);
$course['nbr_users'] = Database::result($rs,0,0);
// Get coachs of the courses in session
$sql = "SELECT user.lastname,user.firstname,user.username FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
WHERE session_rcru.id_user = user.user_id AND session_rcru.id_session = '".intval($id_session)."' AND session_rcru.course_code ='".Database::escape_string($course['code'])."' AND session_rcru.status=2";
$rs = Database::query($sql);
$coachs = array();
if (Database::num_rows($rs) > 0) {
while($info_coach = Database::fetch_array($rs)) {
$coachs[] = api_get_person_name($info_coach['firstname'], $info_coach['lastname']).' ('.$info_coach['username'].')';
}
} else {
$coach = get_lang('None');
}
if (count($coachs) > 0) {
$coach = implode('
',$coachs);
} else {
$coach = get_lang('None');
}
$orig_param = '&origin=resume_session';
//hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
echo '
'.$course['title'].' ('.$course['visual_code'].') |
'.$coach.' |
'.$course['nbr_users'].' |
'.Display::return_icon('course_home.gif', get_lang('Course')).'
'.Display::return_icon('statistics.gif', get_lang('Tracking')).'
'.Display::return_icon('edit.gif', get_lang('Edit')).'
'.Display::return_icon('delete.gif', get_lang('Delete')).'
|
';
}
}
?>
|
'.get_lang('NoUsersForThisSession').' |
';
}
else {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
$sql = 'SELECT '.$tbl_user.'.user_id, lastname, firstname, username '.
' FROM '.$tbl_user.
' INNER JOIN '.$tbl_session_rel_user.
' ON '.$tbl_user.'.user_id = '.$tbl_session_rel_user.'.id_user AND '.$tbl_session_rel_user.'.relation_type<>'.SESSION_RELATION_TYPE_RRHH.
' AND '.$tbl_session_rel_user.'.id_session = '.$id_session.$order_clause;
$result=Database::query($sql);
$users=Database::store_result($result);
$orig_param = '&origin=resume_session&id_session='.$id_session; // change breadcrumb in destination page
foreach($users as $user){
$user_link = '';
if (!empty($user['user_id'])) {
$user_link = ''.api_htmlentities(api_get_person_name($user['firstname'], $user['lastname']),ENT_QUOTES,$charset).' ('.$user['username'].')';
}
echo '
'.$user_link.'
|
'.Display::return_icon('statistics.gif', get_lang('Reporting')).'
'.Display::return_icon('course.gif', get_lang('BlockCoursesForThisUser')).'
'.Display::return_icon('delete.gif', get_lang('Delete')).'
|
';
}
}
?>