<?php

/**
 * Template Name: Conference
 *
 * @package UIU_CSE
 */
get_header(); ?>


<?php while (have_posts()) : the_post();

    $auth_token = get_field('auth_token', 'option');
    $client_id = get_field('client_id', 'option');
    $conference_api = get_field('conference_api', 'option');

    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => $conference_api,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => '{
            "employee_id" : " ",
            "year" : " ",
            "auth_token" : "' . $auth_token . '",
            "user_login_id" : "' . $client_id . '"
        }',
        CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
        ),
    ));

    $response = curl_exec($curl);
    curl_close($curl);
    $response = json_decode($response, true);

?>

    <main id="main" class="site-main" role="main">

        <div class="">


            <section class="container-fluid">

                <div class="banner-img-holder">
                    <div class="banner-overlay">

                    </div>

                    <img class="banner-img" src="<?php echo get_the_post_thumbnail_url(); ?>" alt="">

                    <div class="banner-title">
                        <h1>
                            Research at <br> Department of <br>
                            Computer Science &amp; Engineering
                        </h1>
                    </div>

                </div>


            </section>

            <section id="breadcrumb" class="container">
                <div>
                    <span class="crumbs">Department of CSE > Research > Journals</span>
                </div>
            </section>

        </div>

        <div class="row container">
            <div class="col-md-3 col-sidebar">

                <div class="generic-para sidebar-links">
                    <h3>Research</h3>
                    <ul>
                        <li class="active"><a href="#">Conference Papers</a></li>
                        <li><a href="#">Journals</a></li>
                        <li><a href="#">Journals</a></li>
                        <li><a href="#">Journals</a></li>
                        <li><a href="#">Journals</a></li>
                    </ul>
                </div>

            </div>
            <div class="col-md-9 col-content">

                <div class="sections">
                    <section id="conference-papers-section" class="container generic-content" data-theme="light">
                        <div class="generic-para shadowed">
                            <h3>Conference Papers</h3>
                            <?php

                            $uniqueTitles = [];

                            // Iterate through the data and remove duplicates
                            foreach ($response as &$item) {
                                $conferenceList = &$item['ConferenceList'];
                                foreach ($conferenceList as &$conference) {
                                    $paperTitle = $conference['PaperTitle'];
                                    if (!in_array($paperTitle, $uniqueTitles)) {
                                        $uniqueTitles[] = $paperTitle;
                                    } else {
                                        // Remove duplicate entry
                                        $conference = null;
                                    }
                                }
                                // Remove null entries from the conference list
                                $conferenceList = array_filter($conferenceList);
                            }

                            // $uniqueTitles = [];
                            // $result = [];

                            // foreach ($response as $item) {
                            //     $conferenceList = $item['ConferenceList'];
                            //     foreach ($conferenceList as $conference) {
                            //         $title = $conference['PaperTitle'];
                            //         if (!in_array($title, $uniqueTitles)) {
                            //             $uniqueTitles[] = $title;
                            //             $result[] = $conference;
                            //         }
                            //     }
                            // }


                            foreach ($response as $item) {
                                // Access individual elements of each response

                                if ($item['ConferenceList']) {
                                    echo "<div class='paper-details'>";
                                    echo "<span class='paper-year'>{$item['Year']}</span>";
                                    // Iterate over the JournalList array within each item
                                    foreach ($item['ConferenceList'] as $conference) {
                                        // Access individual elements of each journal
                                        echo "<a href='{$conference['Link']}'>";
                                        echo "<h2 class='paper-title'>{$conference['PaperTitle']}</h2>";
                                        echo "</a>";
                                        echo "<p class='paper-tags'>";
                                        // $conferenceKeyword = explode(',', $conference['Keyword']);
                                        foreach ($conference['KeyWords'] as $keyword) {
                                            if ($keyword) {
                                                echo "<span class='tag'>{$keyword}</span>";
                                            }
                                        }
                                        echo "</p>";
                                        echo "<p class='paper-event'><i>Conference: </i> {$conference['ConferenceName']}</p>";
                                        echo "<p class='paper-contributors'>";
                                        echo "<i>Authors: </i>";
                                        // Iterate over the Author array within each journal
                                        foreach ($conference['Author'] as $author) {
                                            // Process or output the values as needed
                                            echo " {$author['AuthorName']},";
                                        }
                                        echo "</p>";
                                    }
                                    echo "</div>";
                                }
                            }
                            ?>

                        </div>
                    </section>
                </div>
            </div>
        </div>
    </main>
    <!-- #main -->


    <script>
        var myHeaders = new Headers();
        myHeaders.append("Content-Type", "application/json");

        var raw = JSON.stringify({
            "employee_id": "",
            "user_login_id": "api_user",
            "auth_token": "api_user20230419045143",
            "page": 1,
            "limit": 3
        });

        var requestOptions = {
            method: 'POST',
            headers: myHeaders,
            body: raw,
            redirect: 'follow'
        };

        // fetch("https://ucamapi.uiu.ac.bd/api/EmployeeConference", requestOptions)
        //     .then(response => response.text())
        //     .then(result => console.log(result))
        //     .catch(error => console.log('error', error));
    </script>



<?php endwhile; // end of the loop.
?>
<style>
    #fine-print {
        text-align: center;
        margin: 10px auto;
        height: 50px;
        border-top: 1px solid #F68B1F;
    }

    #fine-print p {
        font-size: 12px;
        display: inline-flex;
    }

    #fine-print ul {
        display: inline;
    }

    #fine-print ul>li {
        display: inline;
        padding: 10px;
        font-size: 12px;
        letter-spacing: 1px;
    }

    .banner-img-holder {
        width: 100vw;
        height: 400px;
        margin-bottom: 60px !important;
    }

    .banner-overlay {
        position: relative;
        top: 0px;
        bottom: 0px;
        height: 400px;
        width: 100vw;
        background-color: rgba(50, 52, 63, 0.4588235294);
        z-index: 1;
    }

    .banner-img {
        position: relative;
        top: -400px;
        width: 100%;
        height: 100%;
        -o-object-fit: cover;
        object-fit: cover;
        -o-object-position: center;
        object-position: center;
        filter: greyscale(80%) !important;
    }

    .banner-title {
        position: relative;
        top: -800px;
        height: 400px;
        width: 100vw;
        z-index: 2;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .banner-title h1 {
        margin-top: 50px !important;
        font-family: "Open Sans", sans-serif;
        font-weight: 800;
        line-height: 140%;
        color: #fff;
        text-align: center;
    }

    #breadcrumb {
        padding-top: 20px;
    }

    #breadcrumb div {
        margin-left: 20px !important;
    }

    .crumbs {
        font-size: 14px;
        font-weight: 400;
        margin: 30px 0px;
        padding-bottom: 5px;
        letter-spacing: 2px;
        color: #333 !important;
        border-bottom: 1px solid #333;
    }

    .sidebar-links {
        margin: 10px 0px !important;
        border-radius: 4px;
        border: 1px solid rgba(51, 51, 51, 0.1921568627);
    }

    .sidebar-links h3 {
        font-size: 30px !important;
        font-family: "Open Sans", sans-serif !important;
        width: 100%;
        text-align: center !important;
        text-transform: uppercase;
        padding-bottom: 15px !important;
        border-bottom: 1px solid #117cf7 !important;
    }

    .sidebar-links ul li {
        height: 30px !important;
        padding: 5px 10px !important;
        font-size: 14px;
        list-style: none;
        border-bottom: 1px solid rgba(51, 51, 51, 0.231372549);
    }

    .sidebar-links ul li a:link,
    .sidebar-links ul li a:visited {
        color: #117cf7;
    }

    .sidebar-links ul li a:hover {
        text-decoration: none;
        color: #333;
    }

    .sidebar-links ul li.active a:link,
    .sidebar-links ul li.active a:visited {
        color: #865994;
        font-weight: 600;
    }

    .generic-content-block {
        padding: 40px 10px !important;
    }

    .generic-header {
        width: 100%;
        margin: 30px auto !important;
    }

    .generic-header h1 {
        font-weight: 600;
        text-align: center;
        text-transform: uppercase;
    }

    .personnel-img {
        width: 300px;
        height: 300px;
        margin: 30px auto;
    }

    .personnel-img img {
        border-radius: 4px;
        box-shadow: 4px 6px 18px 12px rgba(51, 51, 51, 0.1490196078);
        width: 100%;
        height: 100%;
        -o-object-fit: cover;
        object-fit: cover;
        -o-object-position: center;
        object-position: center;
    }

    .shadowed {
        border-radius: 4px;
        box-shadow: 4px 6px 18px 12px rgba(51, 51, 51, 0.1490196078);
    }

    .generic-para {
        text-align: left;
        padding: 20px !important;
    }

    .generic-para ol {
        margin: 10px 30px !important;
    }

    .generic-para img {
        border-radius: 4px;
        height: 240px;
        width: 100%;
        -o-object-fit: cover;
        object-fit: cover;
        -o-object-position: center;
        object-position: center;
    }

    .generic-para h2 {
        text-align: center;
        letter-spacing: 1px;
    }

    .generic-para h3 {
        font-family: "DM Serif Text", serif;
        margin: 20px 0px !important;
        text-align: left;
        border-bottom: 3px solid #117cf7;
    }

    .generic-para p {
        text-align: justify;
        margin: 30px 0px !important;
        font-size: 16px !important;
        line-height: 22px;
    }

    .prof-name {
        color: #485680;
        font-weight: 700;
        font-size: 18px;
    }

    .prof-deg {
        font-style: italic;
        font-weight: 400;
    }

    .prof-des {
        font-size: 18px;
        font-weight: 700;
    }

    .area {
        margin: 10px 0px;
        border: 1px solid rgba(51, 51, 51, 0.3803921569);
        border-radius: 8px;
        height: 120px;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .alignnone {
        width: 150px !important;
        height: auto !important;
        margin: 20px auto !important;
    }

    #all-faculties h2,
    #all-events h2,
    #all-news h2 {
        color: #000 !important;
        margin-top: 40px;
        margin-bottom: 20px;
        font-weight: 800;
    }

    #all-faculties hr,
    #all-events hr,
    #all-news hr {
        border: 1px solid rgba(51, 51, 51, 0.3882352941);
    }

    #all-faculties .faculty-stub,
    #all-events .faculty-stub,
    #all-news .faculty-stub {
        width: 100%;
        padding: 5px;
        box-shadow: 2px 2px 10px 6px rgba(0, 0, 0, 0.137254902);
        margin: 30px auto !important;
    }

    #all-faculties .stub-img-holder,
    #all-events .stub-img-holder,
    #all-news .stub-img-holder {
        border-radius: 4px !important;
        height: 160px;
        overflow: hidden;
    }

    #all-faculties .stub-img-holder img,
    #all-events .stub-img-holder img,
    #all-news .stub-img-holder img {
        border-radius: 0px !important;
        height: 100%;
        width: 100%;
        -o-object-fit: cover;
        object-fit: cover;
        -o-object-position: center;
        object-position: center;
    }

    #all-faculties .archive-faculty-details,
    #all-events .archive-faculty-details,
    #all-news .archive-faculty-details {
        height: 100px;
        padding: 0px 10px;
    }

    #all-faculties .archive-faculty-details .faculty-degree,
    #all-events .archive-faculty-details .faculty-degree,
    #all-news .archive-faculty-details .faculty-degree {
        display: inline-block;
        color: rgba(89, 107, 161, 0.5647058824);
        font-weight: 800;
        font-size: 14px;
    }

    #all-faculties .archive-faculty-details .faculty-designation,
    #all-events .archive-faculty-details .faculty-designation,
    #all-news .archive-faculty-details .faculty-designation {
        display: block;
        color: rgba(0, 0, 0, 0.5647058824);
        font-weight: 800;
        font-size: 14px;
    }

    #all-faculties .archive-faculty-details h3,
    #all-events .archive-faculty-details h3,
    #all-news .archive-faculty-details h3 {
        font-size: 18px;
        line-height: 22px;
        font-family: "Open Sans", sans-serif;
        color: #2F4858 !important;
        margin: 10px auto;
    }

    .faculty-grp-img {
        height: auto !important;
        width: 100% !important;
        margin: 0px auto !important;
    }

    .paper-details {
        padding: 30px 0px;
        border-bottom: 1px solid rgba(51, 51, 51, 0.1764705882);
    }

    .paper-details .paper-title {
        font-size: 18px !important;
        text-align: left !important;
        margin: 10px 0px !important;
        text-decoration: underline;
    }

    .paper-details .paper-year {
        font-size: 14px;
        display: block;
        color: rgba(51, 51, 51, 0.4509803922);
    }

    .paper-details p {
        margin: 5px !important;
        font-size: 14px !important;
    }

    .paper-details .paper-contributors {
        color: #222222 !important;
    }

    .paper-details .paper-tags {
        margin: 20px 0px !important;
    }

    .paper-details .paper-tags .tag {
        font-size: 14px;
        border: 1px solid rgba(17, 124, 247, 0.431372549);
        padding: 3px 8px !important;
        border-radius: 10px;
    }

    /*# sourceMappingURL=journal-cse.css.map */
</style>
<?php get_footer(); ?>