<?php
// SECTION: "Show Meeting Info"
function dacdb_meeting_info($atts)
{
    global $fDebug, $data_path, $file_path, $options;
    $options = get_mmp_options(); // Retrieve the plugin options
    
    $meetings = '';

    $club_id = $options['dacdb_club'];

    if ($fDebug && dacdb_is_admin()) {
        $meetings .= "=================================================================<BR>";
        $meetings .= "function dacdb_meeting_info called<br>";
        $meetings .= "AccountID=" . $options['dacdb_district'] . "<br>";
        $meetings .= "ClubID=" . $options['dacdb_club'] . "<br>";
        $meetings .= "URL=" . $data_path . 'wp_club_meetings.cfm?AccountID=' . $options['dacdb_district'] . '&ClubID=' . $options['dacdb_club'] . '<br>';
        $meetings .= "=================================================================<BR>";
    }

    $xml = simplexml_load_file($data_path . 'wp_club_meetings.cfm?AccountID=' . $options['dacdb_district'] . '&ClubID=' . $options['dacdb_club'] . '&R=' . rand());
    if (strlen($xml) == 0) {
        $meetings .= 'There are no club meetings to display at this time.';
        return $meetings;
    }

    $counter = 1;
    $div  = '<div class="col">';
    foreach ($xml->meeting as $wcm) {
        $meetings .= '<div class="dac-row">';
        $meetings .= '    <div class="col">';
        $meetings .= '        <h4>' . $wcm->clubname . '</h4>';
        $meetings .= '    </div>';
        $meetings .= '</div>';

        $meetings .= '<div class="dac-row">';
        $meetings .= '  <div class="col">';
        $meetings .= '        <strong>Official Address </strong><br />';
        $meetings .= '       <div style="padding-left: 10px;">';
        if ($wcm->clubaddress != "") {
            $meetings .=    '<i>' . $wcm->clubaddress . '<br />' . $wcm->clubcity . ', ' . $wcm->clubstatecode . ' ' . $wcm->clubpostalzip . '</i>';
        }
        $meetings .= '        </div>';
        $meetings .= '      <strong>Where We Meet </strong><br/>';
        $meetings .= '      <div style="padding-left: 10px;">';
        $meetings .=            $wcm->meetingplace . '<br />';
        $meetings .=            $wcm->meetingaddress . '<br />' . $wcm->meetingcity . ', ' . $wcm->meetingstatecode . ' ' . $wcm->meetingpostalcode;
        $meetings .= '      </div>';

        $meetings .= '      <strong>When</strong><br />';
        $meetings .= '      <div style="padding-left: 10px;">';
        $meetings .=            $wcm->meetingday . 's at ' . $wcm->meetingtime . '';
        if ($wcm->latlng != "") {
            $meetings .=        '<span style="float:right;"><a href="' . $wcm->latlng . '" target="new">Map It</a></span>';
        }
        $meetings .= '      </div>';
        $meetings .= '  </div>';
        $meetings .= '</div>';
        $meetings .= '<hr>';
        $counter = $counter + 1;
    }
    return $meetings;
}
// !SECTION: "Show Meeting Info"