<?php $__env->startSection('title'); ?> Parking Requests <?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

<div class="col-lg-10 col-lg-offset-1">

    <?php if(Session::has('success')): ?>
        <div class='alert alert-success'><?php echo Session::get('success'); ?></div>
    <?php elseif(Session::has('delete')): ?>
        <div class='alert alert-danger'><?php echo Session::get('delete'); ?></div>
    <?php endif; ?>

    <dl>
        <dt>Apartment</dt>
        <dd><?php echo $tenant->apartment; ?></dd>
        <dt>Building</dt>
        <dd><?php echo $tenant->building->address; ?></dd>
        <dt>Nights Used</dt>
        <dd><strong><?php echo $tenant->nights_used; ?>/<?php echo $tenant->building->total_nights; ?></strong></dd>
    </dl>

    <h1><i class="fa fa-users"></i>Upcoming Parking Requests<?php /* <a href="/logout" class="btn btn-default pull-right">Logout</a> */ ?></h1>

    <a href="parking/create" class="btn btn-success margin-bottom">Add Parking Request</a>

    <div class="table-responsive">
        <table class="table table-bordered table-striped">

            <thead>
                <tr>
                    <th>License Plate</th>
                    <th>Building</th>
                    <th>Make</th>
                    <th>Model</th>
                    <th>Colour</th>
                    <th>Start Date</th>
                    <th>End Date</th>
                    <th>Date/Time Added</th>
                    <th></th>
                </tr>
            </thead>

            <tbody>
                <?php $__empty_1 = true; foreach($parking_requests as $p): $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo $p->car->license_plate; ?></td>
                        <td><?php echo $p->building->address; ?></td>
                        <td><?php echo $p->car->make; ?></td>
                        <td><?php echo $p->car->model; ?></td>
                        <td><?php echo $p->car->colour; ?></td>
                        <td><?php echo $p->start_date; ?></td>
                        <td><?php echo $p->end_date; ?></td>
                        <td><?php echo $p->created_at->format('F d, Y h:ia'); ?></td>
                        <td>
                            <button type="button" class="btn btn-danger" data-toggle="modal" style="margin-right: 3px"
                                data-target="#confirmDeleteModal"
                                data-id="<?php echo $p->id; ?>"
                                data-variable="<?php echo $p->start_date; ?> - <?php echo $p->end_date; ?>"
                                data-action="<?php echo action('ParkingController@index', array($p->building->id, $tenant->user->username)); ?>">
                                Delete
                            </button>
                        </td>
                    </tr>
                <?php endforeach; if ($__empty_1): ?>
                    <tr><td colspan="12">No parking requests</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>

<div class="modal fade" id="confirmDeleteModal" tabindex="-1" role="dialog" aria-labelledby="confirmDeleteLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="confirmDeleteLabel">Confirm Deletion</h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    Do you wish to delete parking request from <span id="confirmDeleteVariable"></span>?
                </div>
            </div>
            <div class="modal-footer">
                <?php echo Form::open(['method' => 'DELETE']); ?>

                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <?php echo Form::submit('Delete', ['class' => 'btn btn-danger']); ?>

                <?php echo Form::close(); ?>

            </div>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>