<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">

<!DOCTYPE html>
<html>

<head>
    <title>My Schedule</title>

    

</head>

<body>

    <div class="container">

        <div class="top-bar">

            <h1>Weekly Schedule</h1>

            <a href="/" class="back-btn">Back to course selection</a>

        </div>

        <h3 class="credits">
            Total Credits: {{ total_credits }}
        </h3>

        <form method="GET" action="/schedule" class="semester-form">

            <!-- Semester Selector -->

            <form method="GET" action="/schedule">

                <label>Select Semester:</label>

                <select name="semester">

                    <option value="All">All Semesters</option>

                    <option value="Fall2026" {% if request.args.get("semester")=="Fall2026" %}selected{% endif %}>
                        Fall 2026
                    </option>

                    <option value="Spring2027" {% if request.args.get("semester")=="Spring2027" %}selected{% endif %}>
                        Spring 2027
                    </option>

                    <option value="Fall2027" {% if request.args.get("semester")=="Fall2027" %}selected{% endif %}>
                        Fall 2027
                    </option>

                    <option value="Spring2028" {% if request.args.get("semester")=="Spring2028" %}selected{% endif %}>
                        Spring 2028
                    </option>

                    <option value="Fall2028" {% if request.args.get("semester")=="Fall2028" %}selected{% endif %}>
                        Fall 2028
                    </option>

                    <option value="Spring2029" {% if request.args.get("semester")=="Spring2029" %}selected{% endif %}>
                        Spring 2029
                    </option>

                    <option value="Fall2029" {% if request.args.get("semester")=="Fall2029" %}selected{% endif %}>
                        Fall 2029
                    </option>

                    <option value="Spring2030" {% if request.args.get("semester")=="Spring2030" %}selected{% endif %}>
                        Spring 2030
                    </option>

                </select>

                <button type="submit">View Schedule</button>

            </form>



            <!--
    <h2>
        Semester: {{ request.args.get("semester") }}
    </h2>
    -->



            {% for semester, calendar_data in semester_calendars.items() %}

            <h2>{{ semester }}</h2>

            <table>

                <tr>
                    <th>Time</th>
                    <th>Mon</th>
                    <th>Tue</th>
                    <th>Wed</th>
                    <th>Thu</th>
                    <th>Fri</th>
                </tr>

                {% for time in time_slots %}

                <tr>

                    <td>{{ time }}</td>

                    {% for day in ["Mon","Tue","Wed","Thu","Fri"] %}

                    <td>

                        {% for course in calendar_data %}

                        {% set slot = datetime.strptime(time,"%H:%M") %}
                        {% set start = datetime.strptime(course.start,"%H:%M") %}
                        {% set end = datetime.strptime(course.end,"%H:%M") %}

                        {% if day in course.days and start <= slot < end %} <div
                            class="{{ 'conflict' if course.conflict else 'course' }}">

                            <strong>{{ course.code }}</strong><br>

                            {{ course.start }} - {{ course.end }}<br>

                            Status: {{ course.status }}

                            <br>

                            <form action="{{ url_for('complete_course', enrollment_id=course.id) }}" method="POST">

                                <select name="grade" required>
                                    <option value="">Select Grade</option>
                                    <option value="A">A</option>
                                    <option value="B">B</option>
                                    <option value="C">C</option>
                                    <option value="D">D</option>
                                    <option value="F">F</option>
                                </select>

                                <button type="submit">Mark Completed</button>

                            </form>

                            <a style="font-size:10px;" href="/inprogress/{{ course.id }}">In Progress</a>

                            <a href="/remove/{{ course.id }}"
                                onclick="return confirm('Are you sure you want to remove this course?')">
                                Remove
                            </a>

    </div>

    {% endif %}

    {% endfor %}

    </td>

    {% endfor %}

    </tr>

    {% endfor %}

    </table>

    <br><br>

    {% endfor %}

    </div>

</body>

</html>