{% extends 'base.html.twig' %}

{% block body %}
    <h1>Ürün Listesi</h1>
    <ul>
        <li>
            <a href="{{ path('product_new') }}">Yeni Ürün Ekle</a>
        </li>
        <li>
            <input type="text" name="q" id="q" placeholder="Arama Yap"/>
            <button type="button" id="btnSearch" class="buttonSubmit">Arama Yap</button>
            <script type="text/javascript">
                $(document).ready(function(){
                    $("#btnSearch").click(function(){
                        window.location="{{ path('product_index') }}?q="+$("#q").val();
                    });
                });
            </script>
        </li>
    </ul>
    <table>
        <thead>
        <tr>
            <th>Id</th>
            <th>Ürün Adı</th>
            <th>Ürün Grubu</th>
            <th>Mac Adresi</th>
            <th>Email</th>
            <th>Başlangıç Tarihi</th>
            <th>Bitiş Tarihi</th>
            <th>İşlemler</th>
        </tr>
        </thead>
        <tbody>
        {% for product in products %}
            <tr>
                <td><a href="{{ path('product_show', { 'id': product.id }) }}">{{ product.id }}</a></td>
                <td>{{ product.name }}</td>
                <td>{{ product.productGroup.name }}</td>
                <td>{{ product.mac.value }}</td>
                <td>{{ product.person.email }}</td>
                <td>{{ product.startDate|date('d.m.Y') }}</td>
                <td>{{ product.endDate|date('d.m.Y') }}</td>
                <td>
                    <ul>
                        <li>
                            <a href="{{ path('product_show', { 'id': product.id }) }}">Göster</a>
                        </li>
                        <li>
                            <a href="{{ path('product_edit', { 'id': product.id }) }}">Düzenle</a>
                        </li>
                    </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <ul>
        <li style="float: right;padding: 10px"><a href="{{ path("product_index") }}?page={{ page!=null?page+1:"#" }}">Sonraki Sayfa</a> </li>
        {% if page!=1 %}
            <li style="float: right;padding: 10px"><a href="{{ path("product_index") }}?page={{ page!=null?page-1:"#" }}">Önceki Sayfa</a> </li>
        {% endif %}

    </ul>

{% endblock %}
