commit
ea6311ca62
@ -0,0 +1,176 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Show the skills report |
||||
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> |
||||
* @package chamilo.social.skill |
||||
*/ |
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
$isStudent = api_is_student(); |
||||
$isStudentBosss = api_is_student_boss(); |
||||
$isDRH = api_is_drh(); |
||||
|
||||
if (!$isStudent && !$isStudentBosss && !$isDRH) { |
||||
header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'); |
||||
die; |
||||
} |
||||
|
||||
$userId = api_get_user_id(); |
||||
|
||||
$skillTable = Database::get_main_table(TABLE_MAIN_SKILL); |
||||
$skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER); |
||||
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE); |
||||
|
||||
$tableRows = array(); |
||||
|
||||
$tpl = new Template(get_lang('Skills')); |
||||
$tplPath = null; |
||||
|
||||
$tpl->assign('allowSkillsTool', api_get_setting('allow_skills_tool') == 'true'); |
||||
$tpl->assign('allowDrhSkillsManagement', api_get_setting('allow_hr_skills_management') == 'true'); |
||||
|
||||
if ($isStudent) { |
||||
$sql = "SELECT s.name, sru.acquired_skill_at, c.title, c.directory " |
||||
. "FROM $skillTable s " |
||||
. "INNER JOIN $skillRelUserTable sru ON s.id = sru.skill_id " |
||||
. "INNER JOIN $courseTable c ON sru.course_id = c.id " |
||||
. "WHERE sru.user_id = $userId"; |
||||
|
||||
$result = Database::query($sql); |
||||
|
||||
while ($resultData = Database::fetch_assoc($result)) { |
||||
$tableRow = array( |
||||
'skillName' => $resultData['name'], |
||||
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER), |
||||
'courseImage' => Display::return_icon('course.png', null, null, ICON_SIZE_BIG, null, true), |
||||
'courseName' => $resultData['title'] |
||||
); |
||||
|
||||
if (file_exists(api_get_path(SYS_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png")) { |
||||
$tableRow['courseImage'] = api_get_path(WEB_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png"; |
||||
} |
||||
|
||||
$tableRows[] = $tableRow; |
||||
} |
||||
|
||||
$tplPath = 'skill/student_report.tpl'; |
||||
} else if ($isStudentBosss) { |
||||
$selectedStudent = isset($_REQUEST['student']) ? intval($_REQUEST['student']) : 0; |
||||
|
||||
$tableRows = array(); |
||||
|
||||
$followedStudents = UserManager::getUsersFollowedByStudentBoss($userId); |
||||
|
||||
foreach ($followedStudents as &$student) { |
||||
$student['completeName'] = api_get_person_name($student['firstname'], $student['lastname']); |
||||
} |
||||
|
||||
if ($selectedStudent > 0) { |
||||
$sql = "SELECT s.name, sru.acquired_skill_at, c.title, c.directory " |
||||
. "FROM $skillTable s " |
||||
. "INNER JOIN $skillRelUserTable sru ON s.id = sru.skill_id " |
||||
. "INNER JOIN $courseTable c ON sru.course_id = c.id " |
||||
. "WHERE sru.user_id = $selectedStudent"; |
||||
|
||||
$result = Database::query($sql); |
||||
|
||||
while ($resultData = Database::fetch_assoc($result)) { |
||||
$tableRow = array( |
||||
'completeName' => $followedStudents[$selectedStudent]['completeName'], |
||||
'skillName' => $resultData['name'], |
||||
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER), |
||||
'courseImage' => Display::return_icon('course.png', null, null, ICON_SIZE_BIG, null, true), |
||||
'courseName' => $resultData['title'] |
||||
); |
||||
|
||||
if (file_exists(api_get_path(SYS_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png")) { |
||||
$tableRow['courseImage'] = api_get_path(WEB_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png"; |
||||
} |
||||
|
||||
$tableRows[] = $tableRow; |
||||
} |
||||
} |
||||
|
||||
$tplPath = 'skill/student_boss_report.tpl'; |
||||
|
||||
$tpl->assign('followedStudents', $followedStudents); |
||||
$tpl->assign('selectedStudent', $selectedStudent); |
||||
} else if ($isDRH) { |
||||
$selectedCourse = isset($_REQUEST['course']) ? intval($_REQUEST['course']) : null; |
||||
$selectedSkill = isset($_REQUEST['skill']) ? intval($_REQUEST['skill']) : 0; |
||||
|
||||
$action = null; |
||||
|
||||
if (!empty($selectedCourse)) { |
||||
$action = 'filterByCourse'; |
||||
} else if (!empty($selectedSkill)) { |
||||
$action = 'filterBySkill'; |
||||
} |
||||
|
||||
$courses = CourseManager::get_courses_list(); |
||||
|
||||
$tableRows = array(); |
||||
$reportTitle = null; |
||||
|
||||
$objSkill = new Skill(); |
||||
$skills = $objSkill->get_all(); |
||||
|
||||
switch ($action) { |
||||
case 'filterByCourse': |
||||
$course = api_get_course_info_by_id($selectedCourse); |
||||
|
||||
$reportTitle = sprintf(get_lang('AchievedSkillInCourseX'), $course['name']); |
||||
|
||||
$tableRows = $objSkill->listAchievedByCourse($selectedCourse); |
||||
break; |
||||
case 'filterBySkill': |
||||
$skill = $objSkill->get($selectedSkill); |
||||
|
||||
$reportTitle = sprintf(get_lang('StudentsWhoAchievedTheSkillX'), $skill['name']); |
||||
|
||||
$students = UserManager::getUsersFollowedByUser( |
||||
$userId, STUDENT, false, false, false, null, null, null, null, null, null, DRH |
||||
); |
||||
|
||||
$coursesFilter = array(); |
||||
|
||||
foreach ($courses as $course) { |
||||
$coursesFilter[] = $course['id']; |
||||
} |
||||
|
||||
$tableRows = $objSkill->listUsersWhoAchieved($selectedSkill, $coursesFilter); |
||||
|
||||
break; |
||||
} |
||||
|
||||
foreach ($tableRows as &$row) { |
||||
$row['completeName'] = api_get_person_name($row['firstname'], $row['lastname']); |
||||
$row['achievedAt'] = api_format_date($row['acquired_skill_at'], DATE_FORMAT_NUMBER); |
||||
|
||||
if (file_exists(api_get_path(SYS_COURSE_PATH) . $row['c_directory'] . '/course-pic85x85.png')) { |
||||
$row['courseImage'] = api_get_path(WEB_COURSE_PATH) . $row['c_directory'] . '/course-pic85x85.png'; |
||||
} else { |
||||
$row['courseImage'] = Display::return_icon('course.png', null, null, ICON_SIZE_BIG, null, true); |
||||
} |
||||
} |
||||
|
||||
$tplPath = 'skill/drh_report.tpl'; |
||||
|
||||
$tpl->assign('action', $action); |
||||
|
||||
$tpl->assign('courses', $courses); |
||||
$tpl->assign('skills', $skills); |
||||
|
||||
$tpl->assign('selectedCourse', $selectedCourse); |
||||
$tpl->assign('selectedSkill', $selectedSkill); |
||||
|
||||
$tpl->assign('reportTitle', $reportTitle); |
||||
} |
||||
|
||||
$tpl->assign('rows', $tableRows); |
||||
|
||||
$contentTemplate = $tpl->fetch("default/" . $tplPath); |
||||
|
||||
$tpl->assign('content', $contentTemplate); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,80 @@ |
||||
{% if allowSkillsTool %} |
||||
<div class="btn-group"> |
||||
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a> |
||||
{% if allowDrhSkillsManagement %} |
||||
<a class="btn btn-default" href="{{ _p.web_main }}admin/skills_wheel.php">{{ 'ManageSkills' | get_lang }}</a> |
||||
{% endif %} |
||||
</div> |
||||
{% endif %} |
||||
|
||||
<h1 class="page-header">{{ 'Skills' | get_lang }}</h1> |
||||
|
||||
<div class="row"> |
||||
<div class="span6"> |
||||
<form class="form-inline" method="post" action="{{ _p.web_self }}"> |
||||
<label for="course">{{ 'Courses' | get_lang }}</label> |
||||
<select name="course" id="course"> |
||||
<option value="0">{{ 'Select' | get_lang }}</option> |
||||
{% for course in courses %} |
||||
<option value="{{ course.id }}" {{ (course.id == selectedCourse) ? 'selected' : '' }}>{{ course.title }}</option> |
||||
{% endfor %} |
||||
</select> |
||||
<button type="submit" class="btn">{{ 'Filter' | get_lang }}</button> |
||||
</form> |
||||
</div> |
||||
<div class="span6"> |
||||
<form class="form-inline" method="post" action="{{ _p.web_self }}"> |
||||
<label for="skill">{{ 'Skills' | get_lang }}</label> |
||||
<select name="skill" id="skill"> |
||||
<option value="0">{{ 'Select' | get_lang }}</option> |
||||
{% for skill in skills %} |
||||
<option value="{{ skill.id }}" {{ (skill.id == selectedSkill) ? 'selected' : '' }}>{{ skill.name }}</option> |
||||
{% endfor %} |
||||
</select> |
||||
<button type="submit" class="btn">{{ 'Filter' | get_lang }}</button> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
|
||||
<h2 class="page-header">{{ reportTitle }} <small>{{ reportSubTitle }}</small></h2> |
||||
|
||||
{% if rows %} |
||||
<table class="table"> |
||||
<thead> |
||||
<tr> |
||||
{% if action == 'filterByCourse' %} |
||||
<th>{{ 'Course' | get_lang }}</th> |
||||
<th>{{ 'Skill' | get_lang }}</th> |
||||
<th>{{ 'Student' | get_lang }}</th> |
||||
<th>{{ 'Date' | get_lang }}</th> |
||||
{% elseif action == 'filterBySkill' %} |
||||
<th>{{ 'Skill' | get_lang }}</th> |
||||
<th>{{ 'Student' | get_lang }}</th> |
||||
<th>{{ 'Date' | get_lang }}</th> |
||||
<th>{{ 'Course' | get_lang }}</th> |
||||
{% endif %} |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for row in rows %} |
||||
<tr> |
||||
{% if action == 'filterByCourse' %} |
||||
<td><img src="{{ row.courseImage }}" alt="{{ row.c_name }}" width="64"> {{ row.c_name }}</td> |
||||
<td>{{ row.skill_name }}</td> |
||||
<td>{{ row.completeName }}</td> |
||||
<td>{{ row.achievedAt }}</td> |
||||
{% elseif action == 'filterBySkill' %} |
||||
<td>{{ row.skill_name }}</td> |
||||
<td>{{ row.completeName }}</td> |
||||
<td>{{ row.achievedAt }}</td> |
||||
<td><img src="{{ row.courseImage }}" alt="{{ row.c_name }}" width="64"> {{ row.c_name }}</td> |
||||
{% endif %} |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
{% else %} |
||||
<div class="alert alert-info"> |
||||
{{ 'NoResults' | get_lang }} |
||||
</div> |
||||
{% endif %} |
@ -0,0 +1,45 @@ |
||||
{% if allowSkillsTool %} |
||||
<div class="btn-group"> |
||||
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a> |
||||
</div> |
||||
{% endif %} |
||||
|
||||
<h1 class="page-header">{{ 'SkillsAcquired' | get_lang }}</h1> |
||||
|
||||
<form class="form-inline" method="post" action="{{ _p.web_self }}"> |
||||
<label>{{ 'Students' | get_lang }}</label> |
||||
<select name="student" id="student"> |
||||
<option value="0">{{ 'Select' | get_lang }}</option> |
||||
{% for student in followedStudents %} |
||||
<option value="{{ student.user_id }}" {{ (student.user_id == selectedStudent) ? 'selected' : '' }}>{{ student.completeName }}</option> |
||||
{% endfor %} |
||||
</select> |
||||
<button type="submit" class="btn btn-primary">{{ 'Search' | get_lang }}</button> |
||||
</form> |
||||
|
||||
{% if rows %} |
||||
<table class="table"> |
||||
<thead> |
||||
<tr> |
||||
<th>{{ 'Student' | get_lang }}</th> |
||||
<th>{{ 'SkillsAcquired' | get_lang }}</th> |
||||
<th>{{ 'Date' | get_lang }}</th> |
||||
<th>{{ 'Course' | get_lang }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for row in rows %} |
||||
<tr> |
||||
<td>{{ row.completeName }}</td> |
||||
<td>{{ row.skillName }}</td> |
||||
<td>{{ row.achievedAt }}</td> |
||||
<td><img src="{{ row.courseImage }}" alt="{{ row.courseName }}" width="64"> {{ row.courseName }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
{% else %} |
||||
<div class="alert alert-info"> |
||||
{{ 'NoResults' | get_lang }} |
||||
</div> |
||||
{% endif %} |
@ -0,0 +1,32 @@ |
||||
{% if allowSkillsTool %} |
||||
<div class="btn-group"> |
||||
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a> |
||||
</div> |
||||
{% endif %} |
||||
|
||||
<h1 class="page-header">{{ 'SkillsAcquired' | get_lang }}</h1> |
||||
|
||||
{% if rows %} |
||||
<table class="table"> |
||||
<thead> |
||||
<tr> |
||||
<th>{{ 'Skill' | get_lang }}</th> |
||||
<th>{{ 'Date' | get_lang }}</th> |
||||
<th>{{ 'Course' | get_lang }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for row in rows %} |
||||
<tr> |
||||
<td>{{ row.skillName }}</td> |
||||
<td>{{ row.achievedAt }}</td> |
||||
<td><img src="{{ row.courseImage }}" alt="{{ row.courseName }}" width="64"> {{ row.courseName }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
{% else %} |
||||
<div class="alert alert-info"> |
||||
{{ 'NoResults' | get_lang }} |
||||
</div> |
||||
{% endif %} |
Loading…
Reference in new issue