<?php
/*
Template Name: Filter
*/
?>

<?php get_header('filter'); ?>

<header class="cd-header">
<h1><?php the_title(); ?></h1>
</header>

<main class="cd-main-content">
<div class="cd-tab-filter-wrapper">
<div class="cd-tab-filter">
<ul class="cd-filters">

<li class="placeholder">
<a data-type="all" href="#">Wszystko</a>
</li>
<li class="filter" data-filter=".k13"><a class="selected" href="#">Wszystko</a></li>
<?php
$tax = 'kategorie';
$terms = get_terms( $tax, $args = array(
'hide_empty' => false, 'orderby' => 'slug', 'order' => 'ASC', 'parent' => 13
));
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach( $terms as $term ) {
$term_link = get_term_link( $term );
?>
<li class="filter k<?php echo $term->term_id; ?>" data-filter=".k<?php echo $term->term_id; ?>"><a href="#"><?php echo $term->name; ?></a></li>
<?php }} ?>

</ul>
</div>


</div>

<section class="cd-gallery">
<ul>

<div class="container">
<div class="row row-eq-height">

<?php $query = new WP_Query( array( 'post_type'=>'kompetencje', 'posts_per_page'=>-1, 'orderby' => 'title', 'order' => 'asc'));?>
<?php while ($query -> have_posts()) : $query -> the_post();
?>

<div class="col-md-4 col-sm-6 col-xs-12 col-12">

<a id="filtry" href="#kompetencja-<?php the_ID(); ?>" data-toggle="modal">
<li class="<?php $categories = get_the_terms( $post->ID, 'kategorie' ); foreach( $categories as $category ) { echo 'k'. $category->term_id . ' '; } ?> mix">
<?php the_title(); ?> ›
</li>
</a>
</div>

<div id="kompetencja-<?php the_ID(); ?>" class="modal fade" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<div class="container">
<div class="row">
<div class="col-md-11 col-sm-11 col-xs-12">
<h3 class="modal-title"><?php the_title(); ?></h3>
</div>
<div class="col-md-1 col-sm-1 col-xs-12" id="kompclose">
<button class="close" type="button" data-dismiss="modal"><i class="fa fa-times" aria-hidden="true"></i></button>
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="container">
<div class="row levels">

<div class="accordionr" id="accordion-<?php the_ID(); ?>">

<div class="card">
<div class="card-header one" id="heading-a<?php the_ID(); ?>">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse-a<?php the_ID(); ?>" aria-expanded="false" aria-controls="collapse-a<?php the_ID(); ?>">Poziom 1.</button>
</h5>
</div>

<div id="collapse-a<?php the_ID(); ?>" class="collapse" aria-labelledby="heading-a<?php the_ID(); ?>" data-parent="#accordion-<?php the_ID(); ?>">
<div class="card-body">
<?php the_content(); ?>
</div>
</div>
</div>

<div class="card">
<div class="card-header two" id="heading-b<?php the_ID(); ?>">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse-b<?php the_ID(); ?>" aria-expanded="false" aria-controls="collapse-b<?php the_ID(); ?>">Poziom 2.</button>
</h5>
</div>
<div id="collapse-b<?php the_ID(); ?>" class="collapse" aria-labelledby="heading-b<?php the_ID(); ?>" data-parent="#accordion-<?php the_ID(); ?>">
<div class="card-body">
<?php
$content = get_post_meta(get_the_ID(), 'wo_blue_box' , true );
$content = htmlspecialchars_decode($content);
$content = wpautop( $content );
echo $content;
?>
</div>
</div>
</div>

<div class="card">
<div class="card-header three" id="heading-c<?php the_ID(); ?>">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse-c<?php the_ID(); ?>" aria-expanded="false" aria-controls="collapse-c<?php the_ID(); ?>">Poziom 3.</button>
</h5>
</div>
<div id="collapse-c<?php the_ID(); ?>" class="collapse" aria-labelledby="heading-c<?php the_ID(); ?>" data-parent="#accordion-<?php the_ID(); ?>">
<div class="card-body">
<?php
$content = get_post_meta(get_the_ID(), 'wo_blue_box2' , true );
$content = htmlspecialchars_decode($content);
$content = wpautop( $content );
echo $content;
?>
</div>
</div>
</div>

</div>

<div class="col-md-12 levels2">
<a href="<?php the_permalink() ?>" target="_blank" title="<?php the_title(); ?>">otwórz w nowej karcie <i style="margin-left:5px" class="fas fa-sign-out-alt"></i></a>
</div>

</div>
</div>
</div>
</div>
</div>
</div>

<?php endwhile; ?>

</div>
</div>

</ul>
<div class="cd-fail-message">Brak kompetencji dla wybranych kryteriów</div>
</section>

<div class="cd-filter" id="checkbox-container">
<form>

<div class="cd-filter-block">

<h3>Poziomy kompetencji</h3>
<ul class="cd-filter-content cd-filters list">

<?php echo get_theme_mod('opis22'); ?>

</ul>
</div>

</form>

<a href="#filtruj" class="cd-close"><i class="fa fa-times" aria-hidden="true"></i>
</a>
</div> <!-- cd-filter -->

<a href="#filtruj" id="filtrujabc" class="cd-filter-trigger">informacje</a>

</main>

<?php get_footer('filter'); ?>