| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 | @extends('master')
@section('title', 'Admin')
@section('description', '')
@section('keywords', '')
@section('content')
<script>
    let rt = {};
    rt.adjustCount = 0;
    rt.firstRowValues = [];
    rt.MOBILE_SCREEN_WIDTH = 480;
    function reset() {
        rt.tableContainer = document.querySelector(".table-container");
        rt.initialState = rt.tableContainer.innerHTML;
        rt.table = document.querySelector(".responsive-table > tbody");
        rt.tableTitle = document.querySelector(".table-title");
        rt.firstRow = document.querySelector(".responsive-table tr:first-of-type");
        rt.firstRowValues = [];
    }
    reset();
    function getFirstRowValues() {
        for (let cell = 0; cell < rt.firstRow.children.length; cell++) {
            rt.firstRowValues.push(rt.firstRow.children[cell].textContent);
        }
    }
    function concatFirstRowValuesWithMainValues() {
        for (let row = 1; row < rt.table.children.length; row++) {
            for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
                rt.table.children[row].children[cell].textContent =
                rt.firstRowValues[cell] +
                ": " +
                rt.table.children[row].children[cell].textContent;
            }
        }
    }
    function consolidateCells() {
        for (let row = 1; row < rt.table.children.length; row++) {
            let rowValues = [];
            for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
                // Saving row values.
                rowValues.push(rt.table.children[row].children[cell].textContent);
            }
            rt.table.children[row].children[0].innerHTML = "";
            for (let value = 0; value < rowValues.length; value++) {
                // Inserting row values into first cell.
                let newValueFragment = document.createElement("div");
                let newValueFragmentContent = document.createTextNode(rowValues[value]);
                newValueFragment.appendChild(newValueFragmentContent);
                rt.table.children[row].children[0].appendChild(newValueFragment);
            }
        }
    }
    function removeExtraCells() {
        for (let row = 1; row < rt.table.children.length; row++) {
            for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
                // rt.table.children[row].children[cell].remove();
            }
            while (rt.table.children[row].children.length > 1) {
                rt.table.children[row].lastElementChild.remove();
            }
        }
    }
    function addTitleToTable() {
        rt.table.children[0].innerHTML = "<th>" + rt.tableTitle.textContent + "</th>";
        rt.tableTitle.remove();
    }
    function adjustTable() {
        rt.table.parentElement.classList.add("mobile");
        getFirstRowValues();
        concatFirstRowValuesWithMainValues();
        consolidateCells();
        removeExtraCells();
        addTitleToTable();
    }
    function restoreTable() {
        rt.tableContainer.innerHTML = rt.initialState;
        reset(); // Rebinding newly drawn elements.
        rt.table.parentElement.classList.remove("mobile");
    }
    document.addEventListener("DOMContentLoaded", () => {
        if (window.innerWidth <= rt.MOBILE_SCREEN_WIDTH) {
            rt.adjustCount++;
            adjustTable();
        }
    });
    window.addEventListener("resize", () => {
        if (window.innerWidth < rt.MOBILE_SCREEN_WIDTH) {
            if (!rt.adjustCount) {
                rt.adjustCount++;
                adjustTable();
            }
        } else {
            restoreTable();
            rt.adjustCount = 0;
        }
    });
    function Conform_Delete() {
        return confirm("Are you sure want to delete this timeshare?");
    }
</script>
<div class="container-fluid">
    <div class="row mb-4 mt-5">
        <div class="col-md-10 offset-md-1">
                <div class="container mt-4">
                        <div class="row">
                            <div class="col">
                                <div class="alert alert-danger mb-0">
                                    <p class="text-danger mb-0 text-center">
                                        No results found, please try again.
                                        <a href="#" class="close">×</a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
            <h1>All Timeshare Weeks</h1>
            <form id="mainForm" method="POST" action="/search-admin-timeshares" accept-charset="UTF-8" enctype="multipart/form-data">
            @csrf
                <div class="form-row">
                    <div class="col-md-3">
                        <label>Resort name</label>
                        <select class="form-control" id="resort" name="resort">
                            <option value="select">Please Select</option>
                            @foreach($resorts as $resort)
                            <option value="{{ $resort->resort }}" {{ old('resort') ==  $resort->resort  ? 'selected' : '' }}>{{ $resort->resort }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label>Status</label>
                        <select class="form-control" id="status" name="status">
                            <option value="select">Select</option>
                            <option value="0">Unpublished Weeks</option>
                            <option value="1">Published Weeks</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label>Season</label>
                        <select class="form-control" name="season">
                            <option value="select"><span style="color:white;">Season</span></option>
                            <option value="Peak" {{ old('season') ==  'Peak' ? 'selected' : '' }}>Peak</option>
                            <option value="Peak 1" {{ old('season') ==  'Peak 1' ? 'selected' : '' }}>Peak 1</option>
                            <option value="Peak 2" {{ old('season') ==  'Peak 2' ? 'selected' : '' }}>Peak 2</option>
                            <option value="Peak 3" {{ old('season') ==  'Peak 3' ? 'selected' : '' }}>Peak 3</option>
                            <option value="Peak 4" {{ old('season') ==  'Peak 4' ? 'selected' : '' }}>Peak 4</option>
                            <option value="Red" {{ old('season') ==  'Red' ? 'selected' : '' }}>Red</option>
                            <option value="White" {{ old('season') ==  'White' ? 'selected' : '' }}>White</option>
                            <option value="Blue" {{ old('season') ==  'Blue' ? 'selected' : '' }}>Blue</option>
                            <option value="Flexi" {{ old('season') ==  'Flexi' ? 'selected' : '' }}>Flexi</option>
                            </select>
                    </div>
                    <div class="col-md-3">
                        <button class="btn btn-blue" style="margin-top: 2rem;" type="submit">
                            FILTER
                        </button>
                    </div>
                </div>
            </form>
            <hr>
        </div>
    </div>
    <div class="row">
        <div class="col-md-10 offset-md-1 table-responsive">
            <table class="table table-bordered table-hover table-striped">
                <thead>
                    <tr>
                        <th>Owner</th>
                        <th>Agent</th>
                        <th>Resort</th>
                        <th>Week</th>
                        <th>Module</th>
                        <th>Unit</th>
                        <th>Beds</th>
                        <th>Season</th>
                        <th>Region</th>
                        <th>Amount</th>
                        <th>Submitted</th>
                        <th>Publish</th>
                        <th>Status</th>
                        <!--<th>Status updated on</th>-->
                        <th>Edit</th>
                        <th>Delete</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($timeshares as $timeshare)
                    <tr>
                        <td>{{ $timeshare->owner }}</td>
                        <td>{{ $timeshare->agent }}</td>
                        <td>{{ $timeshare->resort }}</td>
                        <td>{{ $timeshare->week }}</td>
                        <td>{{ $timeshare->module }}</td>
                        <td>{{ $timeshare->unit }}</td>
                        <td>{{ $timeshare->bedrooms }}</td>
                        <td>{{ ucfirst(trans($timeshare->season)) }}</td>
                        <td>{{ ucfirst(trans($timeshare->region)) }}</td>
                        <td>R {{ number_format($timeshare->price, 2) }}</td>
                        <td>{{ $timeshare->created_at }}</td>
                        @if($timeshare->published==1)
                        <td class="text-center">
                            <a href="/publishTimeshare/{{ $timeshare->id }}">
                                <i class="fas fa-cloud-upload-alt fa-2x text-success"></i>
                            </a>
                        </td>
                        @else
                        <td class="text-center">
                            <a href="/publishTimeshare/{{ $timeshare->id }}">
                                <i class="fas fa-cloud-upload-alt fa-2x text-danger"></i>
                            </a>
                        </td>
                        @endif
                        <td>{{ $timeshare->status }}</td>
                        <!--<td>{{ date('F d, Y', strtotime($timeshare->updated_at)) }}</td>-->
                        <td class="text-center">
                            <a href="/edit-timeshare/{{ $timeshare->id }}">
                                <i class="far fa-edit blue-text fa-2x"></i>
                            </a>
                        </td>
                        <td class="text-center">
                            <a onclick="return Conform_Delete()" href="/deleteTimeshare/{{ $timeshare->id }}">
                                <i class="fas fa-times fa-2x text-danger"></i>
                            </a>
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
        <div class="col-md-6 offset-md-3 mb-4 d-flex justify-content-center">
            <?php echo $timeshares->links(); ?>
        </div>
    </div>
</div>
@stop
 |