{% extends "base.html" %}
{% load static %}

{% block title %}
    Venues | 
{% endblock title %}

{% block style %}
{% endblock style %}

{% block header_buttons %}
{% endblock header_buttons %}

{% block content %}

<div class="d-flex flex-column flex-grow-1">

    <div class="m-4 mb-0 row">
        <div class="col-xl-4 col-md-8 mb-md-0 mb-4">
            <div class="input-group">
                <button type="button" data-bs-toggle="dropdown" class="btn btn-outline-company border-secondary-subtle">
                    <i class="bi bi-sort-up"></i>
                </button>
                <input type="search" name="search" id="search" class="form-control border-secondary-subtle shadow-none" placeholder="Search Venues">
                <button type="button" class="btn btn-outline-company border-secondary-subtle rounded-end" id="searchButton"><i class="bi bi-search"></i></button>
            </div>
        </div>
        <div class="col-xl-3 col-md-4">
            <div class="input-group d-flex justify-content-md-end">
                <button class="btn border-secondary-subtle btn-outline-company" id="addVenue" onclick="openVenueModal(-1);" data-bs-toggle="tooltip" data-bs-title="Add Venue" data-bs-custom-class="light-tooltip">
                    <i class="bi bi-plus-lg"></i>
                </button>
                <button class="btn border-secondary-subtle btn-outline-company me-4 rounded-end" id="importVenue" data-bs-toggle="tooltip" data-bs-title="Import Venue" data-bs-custom-class="light-tooltip">
                    <i class="bi bi-upload"></i>
                </button>

                <button class="btn border-secondary-subtle btn-outline-company rounded-start" id="ContractView" data-bs-toggle="tooltip" data-bs-title="List View" data-bs-custom-class="light-tooltip">
                    <i class="bi bi-list-task"></i>
                </button>
                <button class="btn border-secondary-subtle btn-outline-company" id="expandView" data-bs-toggle="tooltip" data-bs-title="Grid View" data-bs-custom-class="light-tooltip">
                    <i class="bi bi-grid"></i>
                </button>
            </div>

        </div>
    </div>

    <div class="row mx-4 my-2">
        <div class="col-xl-7">
            <hr>
        </div>
    </div>

    <div class="m-4 mt-0 row">
        {% for venue in venues %}
            <div class="col-xl-3 col-lg-4 col-sm-6 mb-4">
                <div class="card w-100 h-100 fluid-hover-zoom shadow-sm md-shadow-on-hover overflow-hidden flex-row">
                    <div class="card-body d-flex">
                        <div class="d-flex flex-column">
                            <h5 class="card-title text-company mb-0">{{ venue.name }}</h5>
                            <div class="fw-bold mb-3">
                                <p class="mb-0">{{ venue.type }}</p>
                            </div>
                            <div class="text-body-secondary mb-3">
                                <p class="mb-0">{{ venue.street_address }}</p>
                                <p class="mb-0">{{ venue.city }}, {{ venue.provence }}</p>
                                <p class="mb-0">{{ venue.postal_code }}</p>
                            </div>
                            <div class="text-body-secondary mb-3">
                                <p class="mb-0">{{ venue.phone_number }}</p>
                                <p class="mb-0">{{ venue.email_address }}</p>
                            </div>
                        </div>
                    </div>
                    <div class="d-flex flex-column">
                        <div class="card-badge-container">
                            <div class="card-badge"></div>
                        </div>
                        <div class="btn-group btn-group-vertical m-3 mt-auto">
                            <a class="btn btn-outline-company rounded-top-4" href="{{ venue.id }}">
                                <i class="bi bi-eye-fill"></i>
                            </a>
                            <button class="btn btn-outline-secondary rounded-bottom-4 ms-0" onclick="openVenueModal({{ venue.id }});">
                                <i class="bi bi-pencil-fill"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        {% endfor %}
    </div>
</div>

<div id="venueModal" class="modal fade">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content overflow-hidden rounded-4">
            <div class="modal-body border-bottom-0 p-0">
                <div class="card-badge-container">
                    <div class="card-badge"></div>
                </div>
                <div class="p-4">
                    <h4 class="card-title text-company fw-bold mb-4">
                        <span class="create" style="display: none">New Venue</span>
                        <span class="edit" style="display: none">Edit Venue</span>
                    </h4>
                    <ul id="newVenueTabBtns" class="nav nav-pills mb-4 border d-flex" role="tablist">
                        <li class="nav-item" role="presentation">
                            <button id="newVenueDetailsTabBtn" class="nav-link active" data-bs-toggle="pill" data-bs-target="#newVenueDetailsTab" type="button" role="tab" aria-controls="newVenueDetailsTab" aria-selected="true">Details</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button id="newVenueAddressTabBtn" class="nav-link" data-bs-toggle="pill" data-bs-target="#newVenueAddressTab" type="button" role="tab" aria-controls="newVenueAddressTab" aria-selected="false">Address</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button id="newVenueContactTabBtn" class="nav-link" data-bs-toggle="pill" data-bs-target="#newVenueContactTab" type="button" role="tab" aria-controls="newVenueContactTab" aria-selected="false">Contact</button>                            
                        </li>
                        <li class="nav-item" role="presentation">
                            <button id="newVenueSocialsTabBtn" class="nav-link" data-bs-toggle="pill" data-bs-target="#newVenueSocialsTab" type="button" role="tab" aria-controls="newVenueSocialsTab" aria-selected="false">Socials</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button id="newVenueWatersTabBtn" class="nav-link" data-bs-toggle="pill" data-bs-target="#newVenueWatersTab" type="button" role="tab" aria-controls="newVenueWatersTab" aria-selected="false">Waters</button>
                        </li>
                    </ul>
                    <div id="newVenueTabs" class="tab-content">
                        <div id="newVenueDetailsTab" class="tab-pane fade show active" role="tabpanel" aria-labelledby="newVenueDetailsTabBtn" tabindex="0">
                            <div class="row g-4 align-items-center mb-3">
                                <div class="col-12">
                                    <label for="venueName" class="form-label">Name</label>
                                    <input name="venueName" id="venueName" type="text" class="form-control" placeholder="Venue and Waters">
                                </div>
                                <div class="col-6">
                                    <label for="venueType" class="form-label">Type</label>
                                    <select name="venueType" id="venueType" class="form-select">
                                        {% for type in venue_types %}
                                            <option value="{{ type.0 }}">{{ type.1 }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                            <div>
                                <label for="venueDescription" class="form-label">Description</label>
                                <textarea name="venueDescription" id="venueDescription" type="text" class="form-control" rows="3" placeholder="A brief description of the Venues and Waters ..." style="max-height: 150px"></textarea>
                            </div>
                        </div>
                        <div id="newVenueAddressTab" class="tab-pane fade" role="tabpanel" aria-labelledby="newVenueAddressTabBtn" tabindex="0">
                            <div class="mb-3">
                                <label for="venueStreetAddress" class="form-label">Street Address</label>
                                <input name="venueStreetAddress" id="venueStreetAddress" type="text" class="form-control" placeholder="Wharncliffe Rd">
                            </div>
                            <div class="row g-4 align-items-center mb-3">
                                <div class="col-6">
                                    <label for="venueCity" class="form-label">City/Town</label>
                                    <input name="venueCity" id="venueCity" type="text" class="form-control" placeholder="Ilkeston">
                                </div>
                                <div class="col-6">
                                    <label for="venueProvence" class="form-label">Provence</label>
                                    <input name="venueProvence" id="venueProvence" type="text" class="form-control" placeholder="Derbyshire">
                                </div>
                                <div class="col-6">
                                    <label for="venuePostCode" class="form-label">Postal Code</label>
                                    <input name="venuePostCode" id="venuePostCode" type="text" class="form-control" placeholder="DE7 5GF">
                                </div>
                            </div>
                        </div>
                        <div id="newVenueContactTab" class="tab-pane fade" role="tabpanel" aria-labelledby="newVenueContactTabBtn" tabindex="0">
                            <div class="row g-4 align-items-center">
                                <div class="col-6">
                                    <label for="venuePhone" class="form-label">Phone Number</label>
                                    <input name="venuePhone" id="venuePhone" type="tel" class="form-control" placeholder="0343 507 7006">
                                </div>
                                <div class="col-6">
                                    <label for="venueEmail" class="form-label">Email Address</label>
                                    <input name="venueEmail" id="venueEmail" type="email" class="form-control" placeholder="admin@anglingtrust.net">
                                </div>
                                <div class="col-12">
                                    <label for="venueWebsite" class="form-label">Website Address</label>
                                    <input name="venueWebsite" id="venueWebsite" type="url" class="form-control" placeholder="https://anglingtrust.net/">
                                </div>
                            </div>
                        </div>
                        <div id="newVenueSocialsTab" class="tab-pane fade" role="tabpanel" aria-labelledby="newVenueSocialsTabBtn" tabindex="0">
                            <div class="row g-4 align-items-center">
                                <div class="col-12">
                                    <label for="venueTwitter" class="form-label d-flex align-items-center">
                                        <i class="bi bi-twitter me-2" style="color: #1DA1F2"></i>
                                        Twitter Link
                                    </label>
                                    <input name="venueTwitter" id="venueTwitter" type="url" class="form-control" placeholder="https://twitter.com/anglingtrust">
                                </div>
                                <div class="col-12">
                                    <label for="venueFacebook" class="form-label d-flex align-items-center">
                                        <i class="bi bi-facebook me-2" style="color: #4267B2"></i>
                                        Facebook Link
                                    </label>
                                    <input name="venueFacebook" id="venueFacebook" type="url" class="form-control" placeholder="https://www.facebook.com/AnglingTrust">
                                </div>
                                <div class="col-12">
                                    <label for="venueInstagram" class="form-label d-flex align-items-center">
                                        <i class="bi bi-instagram me-2" style="color: #D62976;"></i>
                                        Instagram Link
                                    </label>
                                    <input name="venueInstagram" id="venueInstagram" type="url" class="form-control" placeholder="https://www.instagram.com/angling_trust">
                                </div>
                            </div>
                        </div>
                        <div id="newVenueWatersTab" class="tab-pane fade" role="tabpanel" aria-labelledby="newVenueWatersTabBtn" tabindex="0">
                            <div class="pb-4 px-3 pt-0 d-flex justify-content-between align-items-center border-bottom">
                                <button class="btn btn-outline-secondary rounded-4 d-flex align-items-center">
                                    <i class="bi bi-info-lg"></i>
                                </button>
                                <button class="btn btn-outline-company rounded-4 d-flex align-items-center">
                                    <span>Add Waters</span>
                                </button>
                            </div>
                            <ul class="list-group list-group-flush overflow-y-auto" style="max-height: 450px;">
                                <li class="list-group-item d-flex justify-content-between align-items-start">
                                    <div class="ms-2 me-auto">
                                        <div class="fw-bold">Section A · Coal Wharf, Market Drayton</div>
                                        <p class="mb-0">Commercial Water</p>
                                        <p class="mb-0 text-body-secondary">Specimen Carp</p>
                                    </div>
                                    <div class="d-flex flex-column align-self-stretch">
                                        <span class="badge company-bg rounded-pill mb-4">1 · 36</span>
                                        <button class="btn btn-outline-secondary small rounded-4 mt-auto">
                                            <i class="bi bi-pencil-fill"></i>
                                        </button>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between align-items-start">
                                    <div class="ms-2 me-auto">
                                        <div class="fw-bold">Section A · Coal Wharf, Market Drayton</div>
                                        <p class="mb-0">Commercial Water</p>
                                        <p class="mb-0 text-body-secondary">Specimen Carp</p>
                                    </div>
                                    <div class="d-flex flex-column align-self-stretch">
                                        <span class="badge company-bg rounded-pill mb-4">1 · 36</span>
                                        <button class="btn btn-outline-secondary small rounded-4 mt-auto">
                                            <i class="bi bi-pencil-fill"></i>
                                        </button>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between align-items-start">
                                    <div class="ms-2 me-auto">
                                        <div class="fw-bold">Section A · Coal Wharf, Market Drayton</div>
                                        <p class="mb-0">Commercial Water</p>
                                        <p class="mb-0 text-body-secondary">Specimen Carp</p>
                                    </div>
                                    <div class="d-flex flex-column align-self-stretch">
                                        <span class="badge company-bg rounded-pill mb-4">1 · 36</span>
                                        <button class="btn btn-outline-secondary small rounded-4 mt-auto">
                                            <i class="bi bi-pencil-fill"></i>
                                        </button>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between align-items-start">
                                    <div class="ms-2 me-auto">
                                        <div class="fw-bold">Section A · Coal Wharf, Market Drayton</div>
                                        <p class="mb-0">Commercial Water</p>
                                        <p class="mb-0 text-body-secondary">Specimen Carp</p>
                                    </div>
                                    <div class="d-flex flex-column align-self-stretch">
                                        <span class="badge company-bg rounded-pill mb-4">1 · 36</span>
                                        <button class="btn btn-outline-secondary small rounded-4 mt-auto">
                                            <i class="bi bi-pencil-fill"></i>
                                        </button>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between align-items-start">
                                    <div class="ms-2 me-auto">
                                        <div class="fw-bold">Section A · Coal Wharf, Market Drayton</div>
                                        <p class="mb-0">Commercial Water</p>
                                        <p class="mb-0 text-body-secondary">Specimen Carp</p>
                                    </div>
                                    <div class="d-flex flex-column align-self-stretch">
                                        <span class="badge company-bg rounded-pill mb-4">1 · 36</span>
                                        <button class="btn btn-outline-secondary small rounded-4 mt-auto">
                                            <i class="bi bi-pencil-fill"></i>
                                        </button>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between align-items-start">
                                    <div class="ms-2 me-auto">
                                        <div class="fw-bold">Section A · Coal Wharf, Market Drayton</div>
                                        <p class="mb-0">Commercial Water</p>
                                        <p class="mb-0 text-body-secondary">Specimen Carp</p>
                                    </div>
                                    <div class="d-flex flex-column align-self-stretch">
                                        <span class="badge company-bg rounded-pill mb-4">1 · 36</span>
                                        <button class="btn btn-outline-secondary small rounded-4 mt-auto">
                                            <i class="bi bi-pencil-fill"></i>
                                        </button>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer border-top-0 p-4 pt-2">
                <button class="btn btn-secondary px-4 me-3 btn-facing-left" data-bs-dismiss="modal">Cancel</button>
                <button class="btn btn-company btn-facing-right">
                    <span class="edit" style="display: none;">Save Edit</span>
                    <span class="create" style="display: none;">Save New</span>
                </button>
            </div>
        </div>
    </div>
</div>

{% endblock content %}

{% block scripts %}
<script src="{% static 'js/mainapp/venues.js' %}"></script>
{% endblock scripts %}
