<?php $__env->startSection('styles'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('/css/bootstrap-toggle.min.css')); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('pagetitle'); ?>
	Bookings <small>overview</small>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('crumbs'); ?>
	<li class="active">
		<i class="fa fa-ticket"></i> Presentation Booking
	</li>
<?php $__env->stopSection(); ?>

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

    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title pull-left"><i class="fa fa-th fa-fw"></i> Booking Panel</h3>
                    <p class="pull-right">
                        <?php if(Auth::user()->hasRole(['site-admin', 'super-user'])): ?>
                    	   <a href="<?php echo e(url('admin/bookings/create')); ?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> Add Booking</a>
                        <?php endif; ?>
                    </p>
                    <div class="clearfix"></div>
                </div>
                <div class="panel-body pages">
                    <?php if(isset($bookings)): ?>
                        <?php if(sizeof($bookings) == 0): ?>
                            <div class="alert alert-info">Booking list is currently empty. </div>
                        <?php else: ?>
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover table-striped">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Name</th>
                                            <th>Address</th>
                                            <th>Contact Details</th>
                                            <th>Existing Client</th>
                                            <th>Completed</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    	<?php foreach($bookings as $key => $b): ?>
        	                                <tr id="<?php echo e($b->id); ?>">
                                                <td><?php echo e($key +1); ?></td>
        	                                    <td><?php echo e($b->firstname); ?> <?php echo e($b->lastname); ?></td>
                                                <td>
                                                    <?php echo e($b->address1); ?><br/>
                                                    <?php echo e($b->address2); ?><br/>
                                                    <?php echo e($b->town); ?>

                                                    <?php echo e($b->country); ?>

                                                    <?php echo e($b->postcode); ?>

                                                </td>
                                                <td>
                                                    <?php echo e($b->phone); ?><br/>
                                                    <?php echo e($b->email); ?>

                                                </td>
                                                <td><span class="label <?php if(!$b->existing_client): ?>label-default <?php else: ?> label-success <?php endif; ?>"><?php if(!$b->existing_client): ?> No <?php else: ?> Yes <?php endif; ?></span></td>
                                                <td data-id="<?php echo e($b->id); ?>">
                                                <input class="toggle-one" type="checkbox" data-onstyle="success" data-offstyle="danger" <?php if($b->completed): ?>checked <?php endif; ?> data-on="Yes" data-off="No" name="active"></td>
        	                                </tr>
                                        <?php endforeach; ?>
                                    </tbody>
                                </table>
                                <div class="text-cetner">
                                    <?php echo e($bookings->render()); ?>

                                </div>
                            </div>
                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                        <?php endif; ?>
                    <?php else: ?>
                        <div class="alert alert-info">
                            There are currently no bookings at this time.
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <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="myModalLabel">Confirm Deletion</h4>
                </div>
                <div class="modal-body">
                    <div class="alert alert-info">
                        <p>Are you sure you wan to delete this Booking?</p>
                    </div>
                </div>
                <div class="modal-footer">
                    
                    <?php echo Form::open(['method' => 'DELETE', 'id' => 'pageDelete', 'route' => ['admin.bookings.destroy', 'test']]); ?>

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

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

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

<?php $__env->startSection('scripts'); ?>
    <script type="text/javascript" src="<?php echo e(asset('/js/bootstrap-toggle.min.js')); ?>"></script>
    <script>
        $(function() {
            $('.toggle-one').bootstrapToggle();

            $('.toggle').click(function(){
                var togglevalue = $(this).hasClass('off'); // true or false
                var token = $('input[name=_token]').val();

                var id = $(this).parent().data('id');
                
                $.ajax({
                    url: '/ajaxcall/updatebooking/'+id,
                    type: 'post',
                    data: {_token: token, id: togglevalue},
                    dataType: 'json',
                    success: function (data) {
                        console.log(data);
                    }
                });
            });
          })
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.masters.base', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>