<?php if(isset($filterData) && $filterData): ?>

<div class="panel panel-default filter-panel collapse <?php echo $filterData['hasFilters'] ? 'in' : ''; ?>" id="filter-collapse">
	<div class="panel-heading">
		<h4 class="panel-title"><?php echo trans('clumsy::titles.filters'); ?></h4>
	</div>
	<table class="table filter-box">
		<tbody>
			<?php foreach($filterData['data'] as $column => $items): ?>
				<tr>
					<th><?php echo $filterData['names'][$column]; ?></th>
					<td>
					<?php echo Form::dropdown('filter_'.str_replace('.',':',$column),
                            ' ',
                            $items,
                            $filterData['selected'][$column],
                            array('field' => array('data-name' => str_replace('.',':',$column), 'multiple' => 'multiple', 'data-placeholder' => ' '))
                        );; ?>

					</td>
				</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
	<div class="panel-footer">
		<div class="pull-right">
			<button id="filter-clear-btn" class="click-once btn btn-default">
			<?php echo trans('clumsy::buttons.clear'); ?>

			</button>
			<button id="filter-submit-btn" class="click-once btn btn-primary" disabled>
			<?php echo trans('clumsy::buttons.apply'); ?></button>
		</div>
		<div class="clearfix"></div>
		<?php echo Form::open(array('url' => route('clumsy.filter', $resource), 'id' => 'filter-form')); ?>

		    <?php if(isset($filterData['selected'])): ?>
		        <?php foreach($filterData['selected'] as $column => $values): ?>
		            <?php if($values != null): ?>
		                <?php foreach($values as $value): ?>
		                    <?php echo Form::hidden(str_replace('.', ':', $column).'[]', $value); ?>

		                <?php endforeach; ?>
		            <?php endif; ?>
		        <?php endforeach; ?>
		    <?php endif; ?>
			<?php if($is_child): ?>
		    	<?php echo Form::hidden('query_string', http_build_query(array('show' => $resource)), array('class' => 'filter-nested')); ?>

		    	<?php echo Form::hidden('parent_id', $id, array('class' => 'filter-nested')); ?>

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

    </div>
</div>

<?php endif; ?>