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

<?php $__env->startSection('content'); ?>
<!-- Blank Header -->
<div class="content-header">
    <div class="header-section">
        <h1>Inscriptions</h1>
    </div>
</div>
<!-- END Blank Header -->
<ul class="breadcrumb breadcrumb-top">
    <li><a href="<?php echo route('admin'); ?>">Admin</a></li>
    <li>Inscriptions</li>
</ul>

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

<?php if(!Registration::count()): ?>
<p>
    <em>Aucune inscription pour le moment.</em>
</p>
<?php else: ?>
<div class="block full">
    <div class="block-content-full">
	    <div class="text-center">
	        <a href="<?php echo URL::route($_ENV['admin-url'].'.registrations.export'); ?>" class="btn btn-large btn-success" style="margin:20px 0;">Exporter les inscriptions</a>
        </div>
        <div class="table-responsive">
            <table id="inscriptions" class="table table-vcenter table-striped table-bordered table-hover">
                <thead>
                    <tr>
                      <th>#</th>
					  <th>Nom</th>
					  <th>Prénom</th>
					  <th>Email</th>
					  <th>Ville</th>
					  <th>Nom second participant</th>
					  <th>Prénom second participant</th>
					  <th>Commentaire</th>
					  <th></th>
                    </tr>
                </thead>
                <tbody>
	               <?php foreach(Registration::all() as $r): ?>
                   <tr>
	                  <td><?php echo $r->id; ?></td>
					  <td><?php echo $r->surname; ?></td>
					  <td><?php echo $r->firstname; ?></td>
					  <td><?php echo $r->email; ?></td>
					  <td><?php echo $r->city; ?></td>
					  <td><?php echo $r->surname_second; ?></td>
					  <td><?php echo $r->firstname_second; ?></td>
					  <td><?php echo $r->comment; ?></td>
					  <td class="text-center">
						  <span class="btn btn-danger btn-xs delete-registration" data-id="<?php echo $r->id; ?>"><i class="fa fa-trash"></i></span>
					  </td>
                   </tr>
                   <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
@parent
<!-- Load and execute javascript code used only in this page -->
<script>
$(function(){
    App.datatables();
    /* Initialize Datatables */
    $('#inscriptions').dataTable({
        "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 8 ] } ],
        "iDisplayLength": 100,
        //"aLengthMenu": [[50, 100, -1], [50, 100, "All"]],
        "aaSorting": [[ 0, "desc" ]]
    });
    /* Add Bootstrap classes to select and input elements added by datatables above the table */
    $('.dataTables_filter input').addClass('form-control').attr('placeholder', 'Rechercher');
    $('.dataTables_length select').addClass('form-control');
    
    $(document).on('click','.delete-registration',function(){
	    var registration_id = $(this).attr('data-id');
	    if(confirm("Etes-vous sûr de vouloir supprimer cette inscription?")){
		    $.ajax({
			    method: "POST",
			    url: "<?php echo URL::route($_ENV['admin-url'].'.registrations.delete'); ?>",
			    data:{
				    registration_id: registration_id,
			    }
		    }).done(function(result){
			    if(result == 'ok'){
				    window.location.href = "<?php echo URL::route($_ENV['admin-url'].'.registrations.index'); ?>";
			    }
		    });
	    }
    })
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make($_ENV['admin-url'].'.layouts.main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>