<?php get_header();
$current_language = pll_current_language();
$the_cat = get_the_terms(get_the_ID(), 'department_category');
if ($the_cat && !is_wp_error($the_cat)) {
    $term_id = $the_cat[0]->term_id;
    $category_name = $the_cat[0]->name;
    $category_link = get_term_link($term_id, 'department_category');
}

?>
    <style>
        .carousel-inner .carousel-item .carousel-caption {
            position: absolute;
            max-width: 50%;
            max-height: max-content;
            top: 70%;
            left: 10%;
            transform: translateY(-50%);
            background-color: rgba(255, 255, 255, 0.7);
            padding: 15px;
            color: rgb(0, 0, 0);
            display: inline-block;
            text-align: left;
        }

        .carousel-caption p {
            font-size: 20px;
            font-weight: 600;
            display: inline;
        }

        .carousel-fade .carousel-item {
            opacity: 0;
            transition: transform 5s ease, opacity .5s linear;
        }
    </style>
    <div id="carouselExample" class="carousel slide department-slider carousel-fade" data-bs-ride="carousel"
         style="margin-top:110px;">
        <div class="carousel-inner">
            <?php
            $args = array(
                'post_type' => 'slider',
                'posts_per_page' => 10,
                'lang' => $current_language
            );

            $query = new WP_Query($args);
            if ($query->have_posts()) :
                $first = true;
                while ($query->have_posts()) : $query->the_post();
                    set_query_var('is_first', $first);
                    get_template_part('template/slider', get_post_format());
                    $first = false;
                endwhile;
                wp_reset_postdata();
            else :
                ?>
                <p><?php esc_html_e('No post found.', 'your-text-domain'); ?></p>
            <?php endif; ?>

        </div>
        <button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="visually-hidden">Previous</span>
        </button>
        <button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="visually-hidden">Next</span>
        </button>
    </div>

    <!-- Profile -->
    <section class="container">
        <div class="container profile">
            <div class="row my-5">
                <div class="col-lg-4 col-md-12 col-sm-12 d-none">
                    <div class="text-center bg-light shadow rounded" style="height: 550px">
                        <div class="">
                            <div class="img p-4" style="height:400px ">
                                <img class="rounded w-100 h-100"
                                     src="../public/upload/profiles/202304111514BA-6150.jpg"
                                     onerror="this.onerror=null;this.src='../public/upload/user-dummy.jpg';"/>
                            </div>

                        </div>
                        <div class="text-center px-3 pb-3 bg-light rounded" style="height: 150px">
                            <div class="border-top pt-3">
                                <a href="../faculty-member-head/details/310.html"
                                   class="text-dark fw-bold fs-5 mb-0 lh-sm faculty-title">Lieutenant Colonel Md
                                    Sarwar-Bin-Quasem, BPM, psc, AC</a>
                                <p class="fw-bold common-font-color fs-6 mb-1 pt-2">Chairman</p>

                                <p class="fs-6 mb-0 fw-bold"></p>

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

                </div>
                <div class="col-lg-12 col-md-12 col-sm-12">
                    <div class="bg-light p-3 rounded shadow about-message-content" style="height: 550px">
                        <div class="">
                            <h2 class="fs-3 fw-bold border-bottom pb-3 mb-3 common-font-color">
                                <?= get_the_title() ?>
                            </h2>
                            <div class="text-justify fs-6">
                                <?php the_content(); ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </section>

    <!-- Our Faculty -->
    <section class="container mb-5">
        <div class="d-flex justify-content-between align-items-end">
            <h1 class="text-uppercase mb-0 home-content-heading">
                Faculty Members
            </h1>
            <!--<a href="1/all-faculties.html"
               class="text-uppercase text-decoration-none fw-bold common-font-color">All</a>-->
        </div>
        <div class="position-relative w-100 common-bg-color mt-1" style="height: 4px;">
        </div>
        <div class="row">

            <?php
            $args = array(
                'post_type' => 'dept_member',
                'tax_query' => array(
                    'relation' => 'AND',
                    array(
                        'taxonomy' => 'department_category',
                        'field'    => 'term_id',
                        'terms'    => $term_id,
                    ),
                    array(
                        'taxonomy' => 'member_category',
                        'field'    => 'term_id',
                        'terms'    => array(74, 73),
                        'operator' => 'NOT IN',
                    ),
                ),
                'posts_per_page' => -1,
                'lang' => $current_language
            );

            $query = new WP_Query($args);
            if ($query->have_posts()) :?>

                <?php
                //$first = true;
                while ($query->have_posts()) : $query->the_post();
                    //set_query_var('is_first', $first);
                    get_template_part('template/faculty_member', get_post_format());
                    //$first = false;
                endwhile;
                wp_reset_postdata();
            else :
                ?>


                <p><?php esc_html_e('No post found.', 'your-text-domain'); ?></p>
            <?php endif; ?>

        </div>
    </section>
    <div class="text-center mt-5">
        <a href="<?php echo esc_url($category_link); ?>" type="button"
           class="btn shadow about-btn text-white px-5 py-2">All Faculty Members</a>
    </div>




    <!-- Notice & Events -->
    <section class="my-5">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="d-flex justify-content-between align-items-end">
                        <h1 class="text-uppercase mb-0 home-content-heading">
                            Notices
                        </h1>
                        <?php $current_language = pll_current_language();
                        if ($current_language == 'en') { ?>
                            <a href="<?php echo get_site_url(); ?>/notice"
                               class="text-uppercase text-decoration-none fw-bold common-font-color">All</a>
                        <?php } elseif ($current_language == 'bn') { ?>
                            <a href="<?php echo get_site_url(); ?>/bn/notice"
                               class="text-uppercase text-decoration-none fw-bold common-font-color">সকল</a>
                        <?php } ?>
                    </div>

                    <div class="position-relative w-100 common-bg-color mt-1" style="height: 4px;">
                    </div>
                    <div class="row mx-0 upcoming-events ">
                        <?php
                        $args = array(
                            'post_type' => 'notice',
                            'tax_query' => array(
                                array(
                                    'taxonomy' => 'department_category',
                                    'field'    => 'term_id',
                                    'terms'    => $term_id,
                                ),
                            ),
                            'posts_per_page' => 5,
                            'lang' => $current_language
                        );
                        $loop = new WP_Query($args);
                        if ($loop->have_posts()) {
                            while ($loop->have_posts()) {
                                $loop->the_post();
                                get_template_part('template/dept_wise_notice', get_post_format());
                            }
                        } else {
                            echo '<p>No Notice found.</p>';
                        }
                        wp_reset_postdata();
                        ?>



                    </div>
                </div>


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

    <!-- Notice & Events -->


    <!-- Lab -->


<?php get_footer(); ?>