{% extends 'admin/base.html.twig' %} 
 
{% block title %}Dashboard{% endblock %} 
 
{% block javascripts %} 
 
<script> 
 
    $(document).ready(function(){ 
 
        $("#adminReport").submit(function () { 
            $(".submitBtn").attr("disabled", true).html('<i class="fa fa-spinner fa-spin"></i>'); 
            return true; 
        }); 
 
    }); 
 
 
</script> 
{% endblock %} 
 
    {% block body %} 
 
<div class="container-fluid content p-5"> 
    <div class="row"> 
            <h2> Courses of : {% if app.request.query.get('q') %} {{ app.request.query.get('q') }} {% else %} {{ currentDay|date('d/m/Y') }} {% endif %}</h2> 
            <form class="ml-auto mb-4"> 
                <div class="input-group"> 
                    <div class="input-group-prepend"> 
                        <span class="input-group-text" id="dateInput">See another day</span> 
                    </div> 
                    <input type="date" id="date" name="q" 
                           value="{{ app.request.query.get('q') ?  app.request.query.get('q') : currentDay|date('d/m/Y') }}" 
                           min="{{ currentDay|date('d/m/Y') }}" max="31/12/2100" 
                           aria-describedby="dateInput" 
                    > 
                    <div class="input-group-append"> 
                        <button type="submit" class="btn btn-primary mb-2">See</button> 
                    </div> 
                </div> 
            </form> 
 
            <div class="table-responsive scrollme"> 
                <small><em class="text-secondary">{% trans %}Ceci est un tableau, faite défiler sur la droite pour voir le reste des informations{% endtrans %}</em></small> 
                <table class="table table-striped"> 
                    <thead class="thead-dark"> 
                    <tr> 
                        <th scope="col">الجدول</th> 
                        <th scope="col">المعلم</th> 
                        <th scope="col">الطالب</th> 
                        <th scope="col">الفصل</th> 
                        <th scope="col">أعطى المعلم الدرس ؟</th> 
                        <th scope="col">دقائق الضائعة في هذا الدرس</th> 
                        <th scope="col">هل عوض دقائق ؟ كم</th> 
                        <th scope="col">كم تبقى كتعويض لهذا الإشتراك <br> أو لهذه المجموعة ؟</th> 
                        <th scope="col">ملاحظات</th> 
                        {% if is_granted('ROLE_AR') %} 
                            <th scope="col">تنبيه للطالب المتأخر</th> 
                        {% endif %} 
                        {% if is_granted('ROLE_ADMIN') %} 
                            <th scope="col">خصم</th> 
                        {% endif %} 
                        {% if is_granted('ROLE_AR') %} 
                            <th scope="col">تعديل</th> 
                        {% endif %} 
                        <th scope="col">Last update</th> 
                    </tr> 
                    </thead> 
                    <form id="adminReport" action="{{ path('admin_course_tracking')}}" method="post"> 
                        <tbody> 
                        {% for course in coursesOfTheDay %} 
                            <tr> 
                                <th scope="row">{{ course.courseDate|date('H:i') }} 
                                    <br><small>{{ course.absenceLogRelated ? 'هذا درس تعويض' : '' }}</small> 
                                </th> 
                                <td>{{ course.teacherSchedule.teacher.userId.fullname }} 
                                    <br> 
                                    <small><a href="{{ path('admin_teacher_switch', {'id': course.id}) }}">غير إلى معلم بديل</a></small> 
                                </td> 
                                <td> 
                                    {% if course.subscriptionOrder %} 
                                        <a target="_blank" href="{{ path('admin_subscription_show', {'id': course.subscriptionOrder.id}) }}">{{ course.subscriptionOrder.participant ? course.subscriptionOrder.participant.fullname : course.subscriptionOrder.user.fullname }}</a> 
                                        {% if course.subscriptionOrder.participant %} 
                                            {% if course.subscriptionOrder.participant.isChild == true   %} 
                                                {% if course.subscriptionOrder.participant.age < 5 %} 
                                                    <i class="fas fa-baby text-warning"></i> 
                                                    {% if course.subscriptionOrder.participant.age < 3 %} 
                                                        <br> 
                                                        <i class="fas fa-exclamation-circle text-danger"></i> <small>{% trans %}Cet enfant à moins de 3 ans{% endtrans %}</small> 
                                                    {% endif %} 
                                                    {% else %} 
                                                        <i class="fas fa-child"></i> 
                                                {% endif %} 
                                            {% endif %} 
                                        {% endif %} 
                                    {% elseif course.sessionGroup %} 
                                        <a target="_blank" href="{{ path('admin_session_student_index', {'id': course.sessionGroup.id}) }}">{{ course.sessionGroup.displayNameEn }}</a> 
                                        <br> 
                                        <small>درس مجموعة</small> 
                                    {% elseif course.videoRegistration %} 
                                        <a target="_blank" href="{{ path('video_courses_registration_show', {'id': course.videoRegistration.id}) }}">{{ course.videoRegistration.participant ? course.videoRegistration.participant.fullname : course.videoRegistration.user.fullname }}</a> 
                                        <br> 
                                        <small> درس فيديو</small> 
                                    {% elseif course.ticketOrder %} 
                                        <a target="_blank" href="{{ path('admin_ticketOrder_show', {'id': course.ticketOrder.id}) }}">{{ course.ticketOrder.participant ? course.ticketOrder.participant.fullname : course.ticketOrder.user.fullname }}</a> 
                                        <br> 
                                        <small>🚨 Ticket</small> 
                                    {% elseif course.userTestLevel %} 
                                        <a target="_blank" href="{{ path('user_placement_test_show', {'id': course.userTestLevel.id}) }}">{{ course.userTestLevel.participant ? course.userTestLevel.participant.fullname : course.userTestLevel.user.fullname }}</a> 
                                        <br> 
                                        <small>🚨 Level Test</small> 
                                    {% endif %} 
                                </td> 
                                <td> 
                                    {% if course.teacherSchedule.room %} 
                                        {{ course.teacherSchedule.room.name }} <br> 
                                        <i class="fas fa-external-link-alt"></i> <a target="_blank" href="{{ course.teacherSchedule.room.urlWithPassword }}"><small>{% trans %}Accès direct (sans mot de passe){% endtrans %}</small> </a> 
                                        <br> 
                                        <i class="fas fa-external-link-alt"></i> <a target="_blank" href="{{ course.teacherSchedule.room.urlWithoutPassword }}"><small>{% trans %}Accès classique (avec mot de passe) :{% endtrans %} <strong>{{ course.teacherSchedule.room.roomPassword }}</strong></small> </a> 
                                        {% else %} 
                                        ATTENTION: NO ROOM FOR THIS SCHEDULE!! 
                                    {% endif %} 
                                </td> 
                                <td> 
                                    {% if course.isDone == true %} 
                                        <i class="fas fa-check text-success"></i> 
                                    {% elseif course.isCanceled == true %} 
                                        <i class="fas fa-times text-danger"></i> 
                                    {% else %} 
                                        {% if is_granted('ROLE_AR') %} 
                                            <div class="form-check"> 
                                                <input class="form-check-input" type="checkbox" value="{{ course.id }}" id="{{ course.id }}"  name="done[{{ course.id }}]"> 
                                                <label for="{{ course.id }}" class="text-success font-weight-bold">نعم</label> 
                                            </div> 
                                            <div class="form-check"> 
                                                <input onclick="return confirm('متأكدة أن المعلم غاب؟');" class="form-check-input" type="checkbox" value="{{ course.id }}" id="{{ course.id }}"  name="notDone[{{ course.id }}]"> 
                                                <label for="{{ course.id }}" class="text-danger font-weight-bold">لا</label> 
                                            </div> 
                                            <div class="form-check"> 
                                                <input class="form-check-input" type="checkbox" value="{{ course.id }}" id="{{ course.id }}"  name="studentAbsent[{{ course.id }}]"> 
                                                <label for="{{ course.id }}" class="text-warning font-weight-bold">انتظار</label> 
                                            </div> 
                                        {% endif %} 
                                    {% endif %} 
                                </td> 
 
                                {% if course.isDone == true or course.isCanceled == true %} 
                                    <td> 
                                        {{ course.LostMinutes ? course.LostMinutes : '' }} 
                                    </td> 
                                    <td> 
                                        {{ course.catchUpMinutes ? course.catchUpMinutes : '' }} 
                                    </td> 
                                    <td> 
                                        {{ course.isWaiting == true ? 'الطالب كان غائب' : '' }} 
                                    </td> 
                                    <td> 
                                        {{ course.comment ? course.comment : '' }} 
                                    </td> 
                                    <td></td> 
                                {% else %} 
                                    <td> 
                                        {% if is_granted('ROLE_AR') %} 
                                            <input type="number" name="lostMinutes[{{ course.id }}]" min="0" max="45" value=""> 
                                        {% endif %} 
                                    </td> 
                                    <td> 
                                        {% if is_granted('ROLE_AR') %} 
                                            <input type="number" name="catchupMinutes[{{ course.id }}]" min="0" max="45" value=""> 
                                        {% endif %} 
                                    </td> 
                                    <td> 
                                        {% if course.subscriptionOrder %} 
                                            {{ course.subscriptionOrder.totalLostMinutes ? course.subscriptionOrder.totalLostMinutes : '' }} 
                                        {% endif %} 
                                        {% if course.sessionGroup %} 
                                            {{ course.sessionGroup.totalLostMinutes ? course.sessionGroup.totalLostMinutes : '' }} 
                                        {% endif %} 
                                    </td> 
                                    <td> 
                                        {% if is_granted('ROLE_AR') %} 
                                            {{ course.comment ? 'ملاحظات مسجلة: '~ course.comment : '' }} 
                                            <div class="form-row"> 
                                                {{ course.comment ? 'سجل ملاحظات زائدة : ': ' ' }} 
                                                <input class="form-control" type="text" name="comment[{{ course.id }}]" value=""> 
                                            </div> 
                                        {% endif %} 
                                    </td> 
                                    {% if is_granted('ROLE_AR') %} 
                                        <td> 
                                            {% if course.subscriptionOrder %} 
                                                <a href="{{ path('subscription_warning_late_student', {'id': course.subscriptionOrder.id}) }}"  class="btn btn-danger">ارسلي التنبه</a> 
 
                                            {% endif %} 
                                            {% if course.userTestLevel %} 
                                                <a methods="post" href="{{ path('admin_placement_test_alert', {'id': course.userTestLevel.id, 'course' : course.id}) }}" class="btn btn-danger">ارسلي التنبه</a> 
                                            {% endif %} 
                                        </td> 
                                    {% endif %} 
                                {% endif %} 
                                {% if is_granted('ROLE_ADMIN') %} 
                                    <td {{ course.teacherSchedule.teacher.currency == 'USD' ? 'class="alert alert-info"' : '' }}> 
                                        {% if course.penalty %} 
                                            {{ course.penalty }} {{ course.teacherSchedule.teacher.currency }} 
                                        {% else %} 
                                            <input type="number" name="penalty[{{ course.id }}]" min="0" max="100" step="any" value=""> 
                                        {% endif %} 
                                    </td> 
                                {% endif %} 
                                {% if is_granted('ROLE_AR') %} 
                                    <td> 
                                        {% if course.isDone == true or course.isCanceled == true %} 
                                            <a href="{{ path('admin_course_tracking_edit', {'id': course.id }) }}"><i class="fas fa-edit"></i></a> 
                                        {% endif %} 
                                    </td> 
                                {% endif %} 
                                <td> 
                                    {% if course.updateBy %} 
                                        <small> 
                                            Update by {{ course.updateBy }} <br> 
                                            at {{ course.updateAt|date('d/m/Y H:i') }} 
                                        </small> 
                                    {% endif %} 
                                </td> 
                            </tr> 
                        {% else %} 
                            <tr> 
                                <td colspan="13" class="text-center">Pas de cours aujourd'hui</td> 
                            </tr> 
                        {% endfor %} 
                        </tbody> 
                        {% if is_granted('ROLE_AR') %} 
                            <tfoot> 
                            <td colspan="12" class="text-center"> 
                                <button type="submit" name="submitReportTracking" class="btn btn-success submitBtn">ارسلي التقرير</button> 
                            </td> 
                            </tfoot> 
                        {% endif %} 
                    </form> 
                </table> 
            </div> 
 
 
    </div> 
</div> 
 
</div> 
{% endblock %}