{% extends "main.html" %}
{%load static%}
{% block content %}

<div class="w-full xxlg1:w-[75%]">
    <div class="w-full h-fit bg-white rounded-md shadow-md p-5">
        <h1 class="text-secondosiblue text-[30px] font-semibold">{% if request.user.is_superuser %}Daily Reports{% else %} My Daily Reports{% endif%}</h1>

        <!-- FILTERING -->
        <div
            class="w-full py-4 px-3 bg-gray-200 rounded-md shadow-md mt-4 flex flex-col l:flex-row justify-between gap-3 items-center">
            <div class="w-full l:w-fit flex justify-start items-center gap-5">
                <div class="relative h-fit w-full l:w-fit flex items-center">
                    <input type="text" placeholder="Enter Staff Username"
                        class="py-2 px-3 border border-gray-300 rounded-md outline-none w-full l:w-[300px] h-[40px] relative">
                    <button
                        class="text-gray-500 text-xl outline-none border-none cursor-pointer absolute right-2 bg-white">
                        <i class="fa fa-search"></i>
                    </button>
                </div>
            </div>
            <div class="w-full l:w-fit">
                <a href="{% url 'adddailyreport' %}" class="w-full l:w-fit">
                    <button
                        class="w-full l:w-fit text-base px-3 py-2 bg-osiblue text-white outline-none border border-osiblue rounded-md cursor-pointer hover:bg-white hover:text-osiblue duration-300">Add
                        Daily Report</button>
                </a>
            </div>
        </div>

        <!-- DAILY REPORTS -->
        {% for report in dailyreports %}
        <div class="mt-5 w-full h-fit">
            <div class="daily-report w-full border-x border-t border-gray-300 rounded-t-md ">
                <!-- TABLE HEADER -->
                <div
                    class="w-full flex justify-between items-center h-fit border-b border-gray-300 rounded-t-md px-4 py-3">
                    <div class="w-fit h-full flex justify-start items-center">
                        <p class="text-secondosiblue text-base s:text-xl font-light"><span
                                class="font-semibold text-secondosiblue">{{report.staff.user.first_name}}
                                {{report.user.staff.last_name}}</span> {{report.date}} - {{report.time}}</p>
                    </div>
                    <div>
                        <button
                            class="showReportButton w-fit h-fit px-3 py-2 bg-green-700 text-white border border-green-700 cursor-pointer hover:bg-white hover:text-green-700 rounded-md shadow-md duration-300">
                            <i class="fa fa-arrow-down"></i>
                        </button>
                        <button
                            class="w-fit h-fit px-3 py-2 bg-osiblue text-white border border-osiblue cursor-pointer hover:bg-white hover:text-osiblue rounded-md shadow-md duration-300">
                            <i class="fa fa-print"></i>
                        </button>
                    </div>
                </div>

                <!-- TABLE BODY -->
                <div class="w-full hidden reportContainer">
                    <!-- 1st row -->
                    <div class="w-full h-fit flex justify-between items-center border-b border-gray-300">
                        <div class="w-full h-full p-5 text-gray-500">
                            {{ report.text|linebreaks }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% endfor %}

    </div>
</div>


<!-- POPUP MODAL -->
<div class="w-full h-full bg-black bg-opacity-40 z-20 fixed justify-center items-center hidden inset-0" id="popUpModal">
    <div class="w-[95%] md:w-fit h-fit bg-white rounded-md p-9 relative">
        <button class="absolute top-3 right-5 text-slate-800 text-xl cursor-pointer outline-none border-none"
            id="closeModalButton">
            <i class="fa fa-close"></i>
        </button>
        <iframe id="popupModalFrame" frameborder="0"></iframe>
    </div>
</div>


<!---------------------- JS SCRIPTS -------------------->

<!-- TO DISPLAY THE DAILY REPORT CONTENT -->
<script type="text/javascript" src='{% static "js/daily-reports.js" %}'></script>


{% endblock content %}