Example #1
0
function training_render_add_registrants_metabox($post)
{
    wp_enqueue_script('datatables');
    wp_enqueue_style('datatables');
    wp_enqueue_script('cc_datatables');
    $training_key = get_post_meta($post->ID, 'training_key', true);
    if ($training_key == "") {
        echo "Please set a <strong>Training Key </strong> first.";
        return;
    }
    $trainingClient = new TrainingClient();
    $registrants = $trainingClient->getRegistrants($training_key);
    //    dd($registrants);
    if (empty($registrants)) {
        $message = "<p class='error'>There are currently no registrants in the system.</p>";
    } else {
        $message = "<p>Below is a list of current registrants for this Training Session.</p>";
    }
    //    echo "<h2>Registrants</h2>";
    echo $message;
    if (count($registrants) > 0) {
        echo "<div class='upcomming-data-table'>";
        echo '<table data-order=\'[[ 3, "desc" ]]\'>';
        echo '<thead>';
        echo '<tr>';
        echo '<th>First Name</th>';
        echo '<th>Last Name</th>';
        echo '<th>Email</th>';
        echo '<th>Status</th>';
        echo '<th>Date</th>';
        echo '<th>Zone</th>';
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';
        foreach ($registrants as $registrant) {
            //				dd($webinar);
            //            $start = date('Y-m-d', strtotime($webinar->times[0]['startTime']));
            //            $end = date('Y-m-d', strtotime($webinar->times[0]['endTime']));
            $time_zone = explode('/', $registrant->timeZone);
            echo '<tr>';
            echo '<td>' . $registrant->firstName . '</td>';
            echo '<td>' . $registrant->lastName . '</td>';
            echo '<td>' . $registrant->email . '</td>';
            echo '<td>' . strtolower($registrant->status) . '</td>';
            echo '<td class="date">' . date('Y-m-d', strtotime($registrant->registrationDate)) . '</td>';
            echo '<td>' . str_replace('_', ' ', $time_zone[1]) . '</td>';
            echo '</tr>';
        }
        echo '</tbody>';
        echo '</table>';
        echo '</div>';
    }
}