Browse Source

Add missing files in f25743cb1cdf7673e91a5f6661691ac059c3e7cc - refs BT#15394 #2801

Angel Fernando Quiroz Campos 6 years ago
parent
commit
8df1d47084
2 changed files with 118 additions and 0 deletions
  1. 52 0
      main/calendar/planification.php
  2. 66 0
      main/template/default/agenda/planification.tpl

+ 52 - 0
main/calendar/planification.php

@@ -0,0 +1,52 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
+
+$cidReset = true;
+
+require_once __DIR__.'/../inc/global.inc.php';
+
+api_block_anonymous_users();
+
+$current_course_tool = TOOL_CALENDAR_EVENT;
+$this_section = SECTION_MYAGENDA;
+
+$timezone = new DateTimeZone(api_get_timezone());
+$now = new DateTime('now', $timezone);
+$currentYear = (int) $now->format('Y');
+
+$searchYear = isset($_GET['year']) ? (int) $_GET['year'] : $currentYear;
+
+$userInfo = api_get_user_info();
+$userId = $userInfo['id'];
+
+$sessions = [];
+
+if (api_is_drh()) {
+    $count = SessionManager::get_sessions_followed_by_drh($userId, null, null, true);
+} else {
+    $count = UserManager::get_sessions_by_category($userId, false, true, true, true);
+}
+
+$sessionsList = UserManager::getSubscribedSessionsByYear($userInfo, $searchYear);
+
+if ($count > 50) {
+    $message = Display::return_message('TooMuchSessionsInPlanification', 'warning');
+
+    api_not_allowed(true, $message);
+}
+
+$sessions = UserManager::getSessionsCalendarByYear($sessionsList, $searchYear);
+
+$colors = ChamiloApi::getColorPalette(false, true, count($sessions));
+
+$toolName = get_lang('ViewSessionsPlanification');
+
+$template = new Template($toolName);
+$template->assign('student_id', $userId);
+$template->assign('search_year', $searchYear);
+$template->assign('colors', $colors);
+$template->assign('sessions', $sessions);
+$layout = $template->get_template('agenda/planification.tpl');
+$template->display($layout);

+ 66 - 0
main/template/default/agenda/planification.tpl

@@ -0,0 +1,66 @@
+{% extends 'layout/layout_1_col.tpl'|get_template %}
+
+{% set user_id = student_id == _u.id ? 0 : student_id %}
+
+{% block content %}
+    <nav aria-label="...">
+        <ul class="pager">
+            <li class="previous">
+                <a href="{{ _p.web_self ~ '?' ~ {"year": search_year - 1, "user": user_id }|url_encode }}">
+                    <span aria-hidden="true">&larr;</span> {{ search_year - 1 }}
+                </a>
+            </li>
+            <li class="current">
+                {{ search_year }}
+            </li>
+            <li class="next">
+                <a href="{{ _p.web_self ~ '?' ~ {"year": search_year + 1, "user": user_id }|url_encode }}">
+                    {{ search_year + 1 }} <span aria-hidden="true">&rarr;</span>
+                </a>
+            </li>
+        </ul>
+    </nav>
+    {% if sessions|length > 0 %}
+        <div class="table-responsive" id="calendar-session-planification">
+            <table class="table table-bordered table-condensed">
+                <thead>
+                <tr>
+                    <th class="col-session">{{ 'Session'|get_lang }}</th>
+                    {% for i in 1..52 %}
+                        <th class="col-week text-center"><span>{{ i }}</span></th>
+                    {% endfor %}
+                </tr>
+                </thead>
+                <tbody>
+                {% for session in sessions %}
+                    <tr>
+                        <td class="col-session" title="{{  session.name }}">
+                            <a href="{{ _p.web ~ 'session/' ~ session.id ~ '/about/' }}">
+                                {{  session.name }}
+                            </a>
+                        </td>
+
+                        {% if session.start > 0 %}
+                            <td class="col-week" colspan="{{ session.start }}">&nbsp;</td>
+                        {% endif %}
+
+                        <td class="col-week text-center {{ session.start_in_last_year or session.no_start ? 'in_last_year' : '' }} {{ session.end_in_next_year or session.no_end ? 'in_next_year' : '' }}"
+                            colspan="{{ session.duration }}" title="{{ session.human_date }}"
+                            style="background-color: {{ colors[loop.index0] }}">
+                            <span class="sr-only">{{ session.human_date }}</span>
+                        </td>
+
+                        {% if session.duration + session.start < 52 %}
+                            <td class="col-week" colspan="{{ 52 - session.duration - session.start }}">&nbsp;</td>
+                        {% endif %}
+                    </tr>
+                {% endfor %}
+                </tbody>
+            </table>
+        </div>
+    {% else %}
+        <div class="alert alert-warning">
+            {{ 'ThereIsNotStillASession'|get_lang }}
+        </div>
+    {% endif %}
+{% endblock %}