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>';
    }
}
 public function admin_page_display_debug()
 {
     wp_enqueue_script('datatables');
     wp_enqueue_style('datatables');
     wp_enqueue_script('cc_datatables');
     $training = new TrainingClient();
     $trainings = $training->getTrainings();
     if (empty($trainings)) {
         $message = "<p class='error'>There are no upcomming webinars at the moment.</p>";
     } else {
         $message = "<p>Below is a list of the upcoming webinars, to ensure that Citrix Connect WP is connecting to GoToWebinar.</p>";
     }
     echo "<h2>Training Debug</h2>";
     echo $message;
     if (count($trainings) > 0) {
         echo "<div class='upcomming-data-table'>";
         echo '<table data-order=\'[[ 3, "desc" ]]\'>';
         echo '<thead>';
         echo '<tr>';
         echo '<th>ID</th>';
         echo '<th>Title</th>';
         echo '<th>Start Time</th>';
         echo '<th>End Time</th>';
         echo '<th>Organizers</th>';
         echo '</tr>';
         echo '</thead>';
         echo '<tbody>';
         foreach ($trainings as $training) {
             // dd($training);
             $start = date('Y-m-d', strtotime($training->times[0]['startDate']));
             $end = date('Y-m-d', strtotime($training->times[0]['endDate']));
             $organizers_parsed = "";
             foreach ($training->organizers as $organizer) {
                 $organizers_parsed .= "<a href='mailto:" . $organizer->email . "'>" . $organizer['givenName'] . ' ' . $organizer['surname'] . "</a> ";
             }
             foreach ($training->times as $session) {
                 echo '<tr>';
                 echo '<td>' . $training->id . '</td>';
                 echo '<td>' . $training->name . '</td>';
                 echo '<td>' . date('Y-m-d', strtotime($session['startDate'])) . '</td>';
                 echo '<td>' . date('Y-m-d', strtotime($session['endDate'])) . '</td>';
                 echo '<td>' . $organizers_parsed . '</td>';
                 echo '</tr>';
             }
         }
         echo '</tbody>';
         echo '</table>';
         echo '</div>';
     }
 }
function citrix_connect_training_title($atts, $content)
{
    $a = shortcode_atts(array('default' => '', 'id' => '', 'tag' => 'h3'), $atts);
    //if the webinar id has not been set, pull it from the post
    $id = empty($a['id']) ? get_post_meta(get_the_ID(), 'webinar_key', true) : $a['id'];
    //Set the title to the default
    $title = $a['default'];
    //If the default title is blank, grab from Citrix API
    if ('' === $title) {
        //Init the webinar client
        $trainingAPI = new TrainingClient();
        $title = $trainingAPI->getTitle($id);
    }
    //Wrap the title in the given tag
    $html = "<" . $a['tag'] . ">" . esc_html($title) . "</" . $a['tag'] . ">";
    return $html;
}
 public function training_form_confirmation($confirmation, $form, $entry)
 {
     $citrix_data = $this->map_citrix_data($form['fields'], $entry);
     $training_key = $this->get_citrix_key_from_fields($form['fields'], $entry);
     // dd($citrix_data);
     // dd($training_key);
     $trainingClient = new TrainingClient();
     $response = $trainingClient->register($training_key, $citrix_data);
     if ($response['has_errors']) {
         $options = get_option('citrix-connect-training');
         $this->sendErrorEmail($response, $citrix_data, 'training');
         if (empty($options['training_error'])) {
             $errors = '';
             foreach ($response['errors'] as $error) {
                 $errors .= "<p>" . $error . "</p>";
             }
             $confirmation = $errors . "<p>Unfortunately, we were unable to register you for this course. Your registration information has been saved, and an administrator has been notified.</p>\n             <p>We will reach out to you shortly regarding your registration. Thank you for your patience.</p>";
         } else {
             $confirmation = $options['training_error'];
         }
     } else {
     }
     return $confirmation;
 }