
<?php $__env->startSection('content'); ?>
    <div class="page-header">
        <h1><?php echo $title; ?></h1>
    </div>

    <div class="panel panel-default">
        <?php /* PANEL HEADING */ ?>
        <div class="panel-heading">
            <b>
                Showing <?php echo $resources->getFrom(); ?> - <?php echo $resources->getTo(); ?> of <?php echo $resources->getTotal(); ?> total <?php echo $title; ?>
            </b>
            <?php if ($is_admin): ?>
                <div class="pull-right">
                    <?php echo HTML::link('/'.$section->furl.'/create', 'Create A New '.$section, ['class' => 'btn btn-primary btn-xs']); ?>
                </div>
            <?php endif; ?>
            <div class="pull-right">
               <?php echo Form::open(['route' => ['filters.destroy', $section->furl], 'method' => 'delete', 'role' => 'form']); ?>
                    <?php echo Form::submit('Reset Filters', ['class' => 'btn btn-primary btn-xs']); ?>
                <?php echo Form::close(); ?>
            </div>
        </div>

        <?php /* FILTERS */ ?>
        <?php echo $__env->make($filters_view, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

        <?php /* CONTENT */ ?>
        <table class="table table-striped">
            <thead>
                <tr>
                    <?php foreach ($columns as $column): ?>
                        <th>
                            <?php if ($column->field == $order_by): ?>
                                <a href="<?php echo URL::to('/filters/'.$section->furl.'/'.$column->field.'/'.($order_direction == 'asc' ? 'desc' : 'asc')); ?>" data-method="put">
                                    <span class="glyphicon glyphicon-chevron-<?php if($order_direction == 'asc'): ?><?php echo 'up'; ?><?php elseif($order_direction == 'desc'): ?><?php echo 'down'; ?><?php endif; ?>"></span>
                                    <?php echo $column; ?>
                                </a>
                            <?php else: ?>
                                <a href="<?php echo URL::to('/filters/'.$section->furl.'/'.$column->field.'/asc'); ?>" data-method="put"><?php echo $column; ?></a>
                            <?php endif; ?>
                        </th>
                    <?php endforeach; ?>
                    <?php if ($is_admin): ?>
                        <th>Actions</th>
                    <?php endif; ?>
                </tr>
            </thead>
            <tbody>
                <?php if (count($resources)): ?>
                    <?php foreach ($resources as $resource): ?>
                        <tr>
                            <?php foreach ($columns as $column): ?>
                                <td>
                                    <?php if (in_array($column->field, ['state_id', 'country_id'])): ?>
                                        <a href="<?php echo $resource->showLink(); ?>">
                                            <?php echo $resource->{str_replace('_id', '', $column->field)}; ?>
                                        </a>
                                    <?php elseif ($column->type == 'select'): ?>
                                        <?php if (isset($resource->{str_replace('_id', '', $column->field)})): ?>
                                            <a href="<?php echo $resource->{str_replace('_id', '', $column->field)}->showLink(); ?>">
                                                <?php echo $resource->{str_replace('_id', '', $column->field)}; ?>
                                            </a>
                                        <?php else: ?>
                                            N/A
                                        <?php endif; ?>
                                    <?php else: ?>
                                        <a href="<?php echo $resource->showLink(); ?>">
                                            <?php echo $resource->{$column->field}; ?>
                                        </a>
                                    <?php endif; ?>
                                </td>
                            <?php endforeach; ?>
                            <?php if ($is_admin): ?>
                                <td>
                                    <a href="<?php echo $resource->editLink(); ?>"><span class="glyphicon glyphicon-edit"></span></a>
                                    <a href="<?php echo $resource->deleteLink(); ?>" data-method="delete"><span class="glyphicon glyphicon-trash"></span></a>
                                </td>
                            <?php endif; ?>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
                        <tr><td colspan="<?php echo count($columns); ?>">No Results</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>


    <div class="row text-center">
        <?php echo $resources->links(); ?>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>