<% layout('layouts/boilerplate') %>
    <!-- <script src="https://cdn.tiny.cloud/1/9rpfmnglpt10wzitgh0d0zn5ru3343oti9q4hfwl9of7mwpu/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script> -->
    <div class="row">
        <div class="col-md-6 offset-md-3">
            <form action="/admin/config" method="POST" enctype="multipart/form-data">
                <div class="card shadow  py-3 px-3 mb-3">
                    <div class="card-header bg-white">
                        <h4>System Settings</h4>
                    </div>
                    <div class="card-body">
                        <div class="alert alert-warning">Please be aware these settings will affect the entire booking system for all users and organisers.</div>
                        <input type="hidden" name="configId" value="<%= config._id %>">
                        <div class="mb-3">
                            <label for="siteName">System Name</label>
                            <input type="text" class="form-control" name="siteName" id="siteName" value="<%= config.siteName %>" required>
                        </div>
                        <div class="input-group">
                            <label for="siteLogo">System Logo</label>
                            <div class="input-group">
                                <input class="form-control" type="file" id="siteLogo" name="image" accept="image/png, image/jpeg">
                                <a title="Clear current image" class="btn btn-outline-secondary" href="#" onclick="document.getElementById('delImg').submit()" type="button"><i class="bi bi-trash"></i></a>
                            </div>
                            <div class="form-text">Do not upload an image if you do not wish to change the current image.</div>

                        </div>
                        <div class="mb-3">
                            <label for="techContactName">Technical Contact Name</label>
                            <input type="text" class="form-control" name="techContactName" id="techContactName" value="<%= config.techContactName %>">
                        </div>
                        <div class="mb-3">
                            <label for="techContactEmail">Technical Contact E-mail</label>
                            <input type="email" name="techContactEmail" class="form-control" id="techContactEmail" value="<%= config.techContactEmail %>">
                        </div>
                        <div class="mb-3 input-group" title="Discord Webhook">
                            <span class="input-group-text"><i class="bi bi-discord me-2"></i> Webhook</span>
                            <input type="url" name="webhooks[discord]" id="discordWebhook" value="<%= config.webhooks?.discord %>" class="form-control">
                            <div class="form-text">Link the website into a Discord Webhook to automatically post event adverts.</div>
                        </div>
                        <div class="mb-3 row">
                            <div class="col">
                                <label for="hostingCharge">Hosting Registration Fee</label>
                                <div class="input-group">
                                    <span class="input-group-text">Â£</span>
                                    <input class="form-control form-control-sm mt-0" type="number" id="hostingCharge" name="hostingCharge" value="<%= config.hostingCharge %>"></div>
                                </div>
                            
                            <div class="col">
                                <label for="hostingPaypal">PayPal Email for Hosting Fees</label>
                                <input class="form-control" type="email" name="hostingPaypal" id="hostingPaypal" value="<%= config.hostingPaypal %>">
                            </div>
                        </div>
                        <div class="mb-3">
                            <label for="archiveDate">Period of time before archiving event date</label>
                            <select class="form-select" name="archivePeriod" id="archiveData">
                                <option value="30" <%= config.archivePeriod == '30' ? 'selected' : '' %>>1 Month</option>
                                <option value="90" <%= config.archivePeriod == '90' ? 'selected' : '' %>>3 Months</option>
                                <option value="180" <%= config.archivePeriod == '180' ? 'selected' : '' %>>6 Months</option>
                                <option value="365" <%= config.archivePeriod == '365' ? 'selected' : '' %>>1 Year</option>
                            </select>
                            <div class="form-text">
                                From this point available event data is limited to non confidential data
                            </div>
                        </div>
                        <div class="mb-3">
                            <label for="siteDescription">System Description</label>
                            <textarea name="siteDescription" class="form-control" id="siteDescription" cols="30" rows="10"><%= config.siteDescription %></textarea>
                        </div>
                        <button type="submit" class="btn btn-success">Update</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <form action="/admin/config?_method=DELETE" method="POST" id="delImg"></form>
<script src="/js/tinymce.js"></script>