<?php $__env->startSection('titulo', 'Lista de Barrios'); ?>

<?php $__env->startSection('css'); ?>
	<style type="text/css">
		th{cursor:pointer}
	</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('botonera'); ?>
	<li class="form-group">
		<?php if(strstr(Auth::user()->permisos['municipios'], 'c') || Auth::user()->id == 1): ?>
			<a href="<?php echo URL::to('/barrio/create'); ?>" class="btn btn-primary">Agregar un nuevo barrio</a>
		<?php endif; ?>
	</li>
	<li class="form-group">
		<a href="<?php echo URL::to('/admin'); ?>" class="btn btn-warning btn-right">Salir</a>
	</li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
	<?php echo $__env->make('alerts.request', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<table class="table table-striped table-bordered table-hover table-condensed">
		<thead>
			<tr>
				<th id="departamentos.id">
					Id Dep
					<span class="glyphicon" aria-hidden="true"></span>
				</th>
				<th id="departamentos.nombre">
					<span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span>
					Dep Nombre
				</th>
				<th id="municipios.id">
					Id Mun
					<span class="glyphicon" aria-hidden="true"></span>
				</th>
				<th id="municipios.nombre">
					<span class="glyphicon" aria-hidden="true"></span>
					Mun Nombre
				</th>
				<th id="barrios.id">
					Id
					<span class="glyphicon" aria-hidden="true"></span>
				</th>
				<th id="barrios.nombre">
					<span class="glyphicon" aria-hidden="true"></span>
					Nombre
				</th>
				<td>Operaciones</td>
			</tr>
		</thead>
		<tbody>
			<?php echo $__env->make('barrio.forms.tbody', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
		</tbody>
	</table>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
	<script type="text/javascript">
	$(document).ready(function(){
		var d='glyphicon-chevron-down';
		var u='glyphicon-chevron-up';
		var xhr=null;
		$('th').click(function(){
			var t=$(this);
			var s = t.find('span');
			t.siblings().find('span').removeClass(u + ' ' + d);
			if(s.hasClass(d)){
				s.removeClass(d).addClass(u);
				var o = 'desc';
			}
			else{
				s.removeClass(u).addClass(d);
				var o = 'asc';
			}
			if(xhr)xhr.abort();
			xhr=$.ajax({
				headers:{'X-CSRF-TOKEN':'<?php echo e(csrf_token()); ?>'},
				url:'barrio',
				data:{
					campo:t.attr('id'),
					orden:o,
				},
				beforeSend:function(){
					$('tbody').html('<tr><td colspan="7">Cargando ...</td></tr>');
				},
				success:function(r){
					$('tbody').html(r);
				}
			});

		});

		<?php echo $__env->make('componentes.script-mostrar-modal-request', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;
		
	});
	</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin-bloqueo-vista', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>