123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <?php
- /*
- * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
- */
-
- $nameTools= 'Cours';
- $langFile = array ('registration', 'index','trad4all', 'tracking');
- $cidReset=true;
- require ('../inc/global.inc.php');
-
- $this_section = "session_my_space";
-
- api_block_anonymous_users();
- $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
- Display :: display_header($nameTools);
-
-
- $tbl_course = Database :: get_main_table(MAIN_COURSE_TABLE);
- $tbl_user_course = Database :: get_main_table(MAIN_COURSE_USER_TABLE);
- $tbl_user = Database :: get_main_table(MAIN_USER_TABLE);
- $tbl_session_course = Database :: get_main_table(MAIN_SESSION_COURSE_TABLE);
- $tbl_session = Database :: get_main_table(MAIN_SESSION_TABLE);
-
- /*
- ===============================================================================
- FUNCTION
- ===============================================================================
- */
-
- function exportCsv($a_header,$a_data)
- {
- global $archiveDirName;
- $fileName = 'courses.csv';
- $archivePath = api_get_path(SYS_PATH).$archiveDirName.'/';
- $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
-
- if(!$open = fopen($archivePath.$fileName,'w+'))
- {
- $message = get_lang('noOpen');
- }
- else
- {
- $info = '';
-
- foreach($a_header as $header)
- {
- $info .= $header.';';
- }
- $info .= "\r\n";
-
-
- foreach($a_data as $data)
- {
- foreach($data as $infos)
- {
- $info .= $infos.';';
- }
- $info .= "\r\n";
- }
-
- fwrite($open,$info);
- fclose($open);
- chmod($fileName,0777);
-
- header("Location:".$archiveURL.$fileName);
- }
-
- return $message;
- }
- /*
- ===============================================================================
- MAIN CODE
- ===============================================================================
- */
- if(isset($_GET["user_id"]) && $_GET["user_id"]!=""){
-
- $i_user_id=$_GET["user_id"];
-
- //We want to display the course where this user is a coach
- if(isset($_GET["type"]) && $_GET["type"]=="coach"){
-
- $sqlCourse="SELECT title,code " .
- "FROM $tbl_course as course, $tbl_session_course as src " .
- "WHERE course.code=src.course_code AND id_coach='$i_user_id'";
-
- }
-
- //It's a teacher
- else{
- $sqlCourse = " SELECT title,code
- FROM $tbl_course as course, $tbl_user_course as cru
- WHERE course.code=cru.course_code AND cru.user_id='$i_user_id' AND cru.status='1'
- ORDER BY title ASC
- ";
- }
- }
- else{
- $sqlCourse = " SELECT title,code
- FROM $tbl_course as course
- ORDER BY title ASC
- ";
- }
-
- $resultCourse = api_sql_query($sqlCourse);
-
- $a_header[]=get_lang('Title');
- $a_header[]=get_lang('Tutor');
- $a_header[]=get_lang('Teachers');
-
- if(mysql_num_rows($resultCourse)>0)
- {
- echo '<table class="data_table">
- <tr>
- <th>
- '.get_lang('Title').'
- </th>
- <th>
- '.get_lang('Tutor').'
- </th>
- <th>
- '.get_lang('Teachers').'
- </th>
- </tr>
- ';
- while($a_course= mysql_fetch_array($resultCourse))
- {
- $sqlCoach = "SELECT CONCAT(user.firstname,' ',user.lastname) as tutor_name
- FROM $tbl_user
- INNER JOIN $tbl_session_course as sessionCourse
- ON sessionCourse.course_code = '".$a_course['code']."'
- AND sessionCourse.id_coach = user.user_id
- ";
- $resultCoach = api_sql_query($sqlCoach);
- $a_coach = mysql_fetch_array($resultCoach);
-
- /*$sqlFormateur = " SELECT CONCAT(user.firstname,' ',user.lastname) as formateur_name
- FROM $tbl_user
- INNER JOIN $tbl_session_course as sessionCourse
- ON sessionCourse.course_code = '".$a_course['code']."'
- INNER JOIN $tbl_session AS session
- ON session.id = sessionCourse.id_session
- AND session.id_coach = user.user_id
- ";*/
- $sqlFormateur = " SELECT CONCAT(user.firstname,' ',user.lastname) as formateur_name
- FROM $tbl_user as user, $tbl_user_course as cru
- WHERE user.user_id=cru.user_id AND cru.status='1' AND cru.course_code='".$a_course['code']."'
- ";
- $resultFormateur = api_sql_query($sqlFormateur);
- $a_formateur = mysql_fetch_array($resultFormateur);
-
- if($i%2==0){
- $s_css_class="row_odd";
-
- if($i%20==0 && $i!=0){
- echo '<tr>
- <th>
- '.get_lang('Title').'
- </th>
- <th>
- '.get_lang('Tutor').'
- </th>
- <th>
- '.get_lang('Teachers').'
- </th>
- </tr>';
- }
-
- }
- else{
- $s_css_class="row_even";
- }
-
- $i++;
- echo '<tr class="'.$s_css_class.'">
- <td>
- '.$a_course['title'].'</td>
- <td>
- '.$a_coach['tutor_name'].'
- </td>
- <td>
- '.$a_formateur['formateur_name'].'
- </td>
- </tr>
- ';
- $a_data[$index]["title"]=$a_course['title'];
- $a_data[$index]["tutor_name"]=$a_coach['tutor_name'];
- $a_data[$index]["formateur_name"]=$a_formateur['formateur_name'];
-
- $index++;
- }
- echo '</table>';
- }
- else
- {
- echo get_lang('NoCourse');
- }
- if(isset($_POST['export'])){
-
- exportCsv($a_header,$a_data);
-
- }
-
- echo "<br /><br />";
- echo "<form method='post' action='cours.php'>
- <input type='submit' name='export' value='".get_lang('exportExcel')."'/>
- <form>";
-
-
- /*
- ==============================================================================
- FOOTER
- ==============================================================================
- */
- Display :: display_footer();
- ?>
|