{% extends 'layouts/admin.twig' %}

{% block content %}

    <ul class="breadcrumbs el">
        <li><a href="/admin/">Admin</a> /</li>
        <li class="end">Subscriptions</li>
    </ul>

    <h1>{{ title }}</h1>

    <ul class="tabnav el">
        <li class="{{ selected_tab == 'manage' ? 'selected' : '' }}">
            <a href="{{ route('admin-subscriptions') }}">All</a>
        </li>
    </ul>


    {% include 'admin/messages.twig' %}

    <table id="js_manage_subscriptions">

        <thead>
            <tr>
                <th>#</th>
                <th>Items</th>
                <th>Member</th>
                <th>Status</th>
                <th>Every</th>
                <th>Interval</th>
                <th>Similar<br />subscriptions</th>
                <th>Max number<br />of issues</th>
                <th>Next issue</th>
                <th>Actions</th>
            </tr>
        </thead>

    </table>

    <hr />

    <script>

    $(document).ready(function() {
        $('#js_manage_subscriptions').DataTable( {
            "processing": true,
            "serverSide": true,
            "ajax": "/admin/subscriptions/data",
            "paging": true,
            "pageLength": 10,
            "searching": false,
            "lengthChange": false,
            "columns": [
                { "data": "id" },
                { "data": "items" },
                { "data": "member" },
                { "data": "status" },
                { "data": "interval_multiplier" },
                { "data": "interval" },
                { "data": "similar_subscriptions" },
                { "data": "max_number_of_issues" },
                { "data": "next_issue_date" },
                { "data": "actions",
                    "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                        $(nTd).html(" <a href='" + oData.actions.edit + "'>Edit</a> ");
                    }
                },
            ],
            createdRow: function( row, data, dataIndex ) {
                if (data.similar_subscriptions) {
                    $(row).addClass("label-warning");
                }
            }
        })
    } );

    </script>

{% endblock %}

