<?php

// connect to database
include '../config/database.php';
include_once '../config/properties.php';
include_once "../resources/offering.php";

// initialize objects
$offering = new Offering();

$offering_val = $_GET['offering_id'];
$page = isset($_GET['page']) ? $_GET['page'] : 1; // page is the current page, if there's nothing set, default is page 1
$records_per_page = 5; // set records or rows of data per page
$from_record_num = ($records_per_page * $page) - $records_per_page; // calculate for the query LIMIT clause

$offering->offering_id = $offering_val;

$total_inst = $offering->offering_count_instructor();
$count_inst = $from_record_num;

$stmt_ins1 = $offering->offering_display_instructor($from_record_num, $records_per_page);
while ($row_ins1 = $stmt_ins1->fetch(PDO::FETCH_ASSOC)) {
    $count_inst++;
    extract($row_ins1);
    $html .= "<div class='md:direction-column border-bottom-dark mt-10 instructor'>";
    $html .= "<div class='d-flex x-gap-20 y-gap-20 items-center flex-wrap'>";
    $html .= "<div class='size-120'>";
    $filepath = ADMIN_HTTP_PATH . $properties['jdbc.user_image_folder'] . '/' . $user_image;
    if ($user_image == "") {
        $html .= "<img src='".DEFAULT_USER_IMAGE."' class='object-cover rounded-full' />";
    } else {
        $html .= "<img src='" . $filepath . "'  class='object-cover rounded-full' />";
    }
    $html .= "</div>";
    $html .= "<div class=''>";
    $html .= "<h5 class='text-17 lh-14 fw-500'>{$first_name} {$last_name}</h5>";
    $html .= "<div class='d-flex x-gap-20 y-gap-10 flex-wrap items-center pt-10'>";
    if ($email_id != "") {
        $html .= "<div class='d-flex items-center text-light-1'>";
        $html .= "<div class='fa fa-envelope text-13 mr-5'></div>";
        $html .= "<div class='text-13 lh-1'>" . htmlentities($email_id) . "</div>";
        $html .= "</div>";
    }
    if ($mobile_no != "") {
        $html .= "<div class='d-flex items-center text-light-1'>";
        $html .= "<div class='fa fa-phone text-13 mr-5'></div>";
        $html .= "<div class='text-13 lh-1'>{$mobile_no}</div>";
        $html .= "</div>";
    }
    $html .= "<div class='d-flex items-center x-gap-15 ml-5 text-light-1'>";
    if ($website_link != "") {
        echo "<a title='Website' href='" . $website_link . "' target='_blank'><i class='fa fa-globe'></i></a>";
    }if ($facebook_link != "") {
        echo "<a title='Facebook' href='http://www.facebook.com/" . htmlentities($facebook_link) . "' target='_blank'><i class='fa fa-facebook'></i></a>";
    } if ($linkedin_link != "") {
        echo "<a title='Linkedin' href='http://www.linkedin.com/" . htmlentities($linkedin_link) . "' target='_blank'><i class='fa fa-linkedin'></i></a>";
    } if ($twitter_link != "") {
        echo "<a title='Twitter' href='http://twitter.com/" . htmlentities($twitter_link) . "' target='_blank'><i class='fa fa-twitter'></i></a>";
    }
    $html .= "</div>";
    $html .= "</div>";
    $html .= "</div>";
    $html .= "</div>";
    $hmtl .= "<div class='mt-10'>";
    $html .= "<p>" . htmlentities($biography) . "</p>";
    $html .= "</div>";
    $html .= "</div>";

    
//
//    
//    
//    
//    echo"<div class='item post-author-info'>";
//    echo "<div class='thumb'>";
//    $filepath = '../'.ADMIN_PATH . $properties['jdbc.user_image_folder'] . '/' . $user_image;
//    if ($user_image == "" || !file_exists($filepath)) {
//        echo "<img src='wp-content/assets/images/user.png' alt='{$first_name} {$last_name}'>";
//    } else {
//        echo "<img src='" . $filepath . "' alt='{$first_name} {$last_name}' />";
//    }
//    echo "</div>";
//    echo "<div class='info'>";
//    echo "<div class='author-title-social'>";
//    echo "<div class='title-job'>";
//    echo "<h5 class='p-font'><a href='#' title='Posts by admin' rel='author'>{$first_name} {$last_name}</a></h5>";
//    echo "<div class='cat'>{$designation}</div>";
//    if ($mobile_no != "") {
//        echo "<div class='phone ";if ($email_id == "") { echo "pd-bottom-10";}echo "'>";
//        echo " <i class='fa fa-phone'></i> {$mobile_no} ";
//        echo "</div>";
//    }
//    if ($email_id != "") {
//        echo "<div class='email pd-bottom-10'>";
//        echo "<i class='fa fa-envelope'></i> ".htmlentities($email_id)." ";
//        echo "</div>";
//    }
//    echo "<span class='job-author'></span>";
//    echo "</div>";
//    echo "<ul class='social-profile'>";
//    if ($website_link != "") {
//        echo "<li><a title='Website' href='".$website_link."' target='_blank'><i class='fa fa-globe'></i></a></li>";
//    }if ($facebook_link != "") {
//        echo "<li><a title='Facebook' href='http://www.facebook.com/".htmlentities($facebook_link)."' target='_blank'><i class='fa fa-facebook'></i></a></li>";
//    } if ($linkedin_link != "") {
//        echo "<li><a title='Linkedin' href='http://www.linkedin.com/".htmlentities($linkedin_link)."' target='_blank'><i class='fa fa-linkedin'></i></a></li>";
//    } if ($twitter_link != "") {
//        echo "<li><a title='Twitter' href='http://twitter.com/".htmlentities($twitter_link)."' target='_blank'><i class='fa fa-twitter'></i></a></li>";
//    }
//    echo " </ul> ";
//    echo "</div>";
//    echo "<p>".htmlentities($biography)."</p>";
//    echo "</div>";
//    
//    echo "</div>";
}
echo json_encode(array("html" => $html));
?>