function rendez_vous_single_get_the_dates($view = 'single')
{
    // First add organizer
    $all_attendees = (array) rendez_vous()->item->attendees;
    if (!in_array(rendez_vous()->item->organizer, $all_attendees)) {
        $all_attendees = array_merge(array(rendez_vous()->item->organizer), $all_attendees);
    }
    // Then remove current_user as we want him to be in last position
    if ('edit' != $view) {
        if (!rendez_vous_single_date_set() && bp_loggedin_user_id()) {
            $attendees = array_diff($all_attendees, array(bp_loggedin_user_id()));
        } else {
            $attendees = $all_attendees;
        }
    } else {
        $attendees = $all_attendees;
    }
    $days = rendez_vous()->item->days;
    if (empty($days)) {
        return false;
    }
    ksort($days);
    $header = array_keys($days);
    $output = '<table id="rendez-vous-attendees-prefs">';
    $output .= '<thead>';
    $output .= '<tr><th>&nbsp;</th>';
    foreach ($header as $date) {
        $output .= '<th class="rendez-vous-date">';
        if (is_long($date)) {
            $output .= '<div class="date">' . date_i18n(get_option('date_format'), $date) . '</div>';
            $output .= '<div class="time">' . date_i18n(get_option('time_format'), $date) . '</div>';
        } else {
            $output .= '<div class="none">' . esc_html__('None', 'rendez-vous') . '</div>';
        }
        $output .= '</th>';
    }
    $output .= '</tr></thead>';
    $output .= '<tbody>';
    //rows
    foreach ($attendees as $attendee) {
        $user_link = trailingslashit(bp_core_get_user_domain($attendee));
        $user_name = bp_core_get_user_displayname($attendee);
        $tr_class = $attendee == bp_loggedin_user_id() ? 'edited' : false;
        $output .= '<tr class="' . $tr_class . '"><td>';
        if ('edit' == $view) {
            // Make sure the organizer is not removed from attendees
            if ($attendee == rendez_vous()->item->organizer) {
                $output .= '<input type="hidden" name="_rendez_vous_edit[attendees][]" value="' . $attendee . '"/>';
            } else {
                $output .= '<input type="checkbox" name="_rendez_vous_edit[attendees][]" value="' . $attendee . '" checked="true"/>&nbsp;';
            }
        }
        $output .= '<a href="' . esc_url($user_link) . '" title="' . esc_attr($user_name) . '">' . bp_core_fetch_avatar(array('object' => 'user', 'item_id' => $attendee, 'type' => 'thumb', 'class' => 'mini', 'width' => 20, 'height' => 20)) . ' ' . $user_name . '</a></td>';
        foreach ($header as $date) {
            $class = in_array($attendee, $days[$date]) ? 'active' : 'inactive';
            if ('none' == $date) {
                $class .= ' impossible';
            }
            $output .= '<td class="' . $class . '">&nbsp;</td>';
        }
        $output .= '</tr>';
    }
    $ending_rows = array('total' => '<td>' . esc_html__('Total', 'rendez-vous') . '</td>');
    if ('edit' != $view) {
        $ending_rows['editable_row'] = '<td><a href="' . esc_url(bp_loggedin_user_domain()) . '" title="' . esc_attr(bp_get_loggedin_user_username()) . '">' . bp_core_fetch_avatar(array('object' => 'user', 'item_id' => bp_loggedin_user_id(), 'type' => 'thumb', 'class' => 'mini', 'width' => 20, 'height' => 20)) . ' ' . esc_html(bp_get_loggedin_user_fullname()) . '</a></td>';
        // Set definitive date
    } else {
        $ending_rows['editable_row'] = '<td id="rendez-vous-set">' . esc_html__('Set date', 'rendez-vous') . '</td>';
    }
    foreach ($header as $date) {
        $checked = checked(true, in_array(bp_loggedin_user_id(), $days[$date]), false);
        $ending_rows['total'] .= '<td><strong>' . count($days[$date]) . '</strong></td>';
        // Let the user set his prefs
        if ('edit' != $view) {
            $class = false;
            if ('none' == $date) {
                $class = ' class="none-resets-cb"';
            }
            $ending_rows['editable_row'] .= '<td><input type="checkbox" name="_rendez_vous_prefs[days][' . bp_loggedin_user_id() . '][]" value="' . $date . '" ' . $checked . $class . '/></td>';
            // Let the organizer choose the definitive date
        } else {
            $def_date = !empty(rendez_vous()->item->def_date) ? rendez_vous()->item->def_date : false;
            if ('none' != $date) {
                $ending_rows['editable_row'] .= '<td><input type="radio" name="_rendez_vous_edit[def_date]" value="' . $date . '" ' . checked($date, $def_date, false) . '/></td>';
            } else {
                $ending_rows['editable_row'] .= '<td></td>';
            }
        }
    }
    if ('edit' != $view) {
        // Date is set, changes cannot be done anymore
        if (!rendez_vous_single_date_set()) {
            if ('private' == rendez_vous()->item->privacy) {
                // If private, display the row only if current user is an attendee or the author
                if (bp_loggedin_user_id() == rendez_vous()->item->organizer || in_array(bp_loggedin_user_id(), $all_attendees)) {
                    $output .= '<tr class="edited">' . $ending_rows['editable_row'] . '</tr>';
                }
            } else {
                if (current_user_can('subscribe_rendez_vous')) {
                    $output .= '<tr class="edited">' . $ending_rows['editable_row'] . '</tr>';
                }
            }
            // Display totals
            $output .= '<tr>' . $ending_rows['total'] . '</tr>';
        }
    } else {
        // Display totals
        $output .= '<tr>' . $ending_rows['total'] . '</tr>';
        // Display the radio to set the date
        if ('draft' != rendez_vous()->item->status) {
            $output .= '<tr>' . $ending_rows['editable_row'] . '</tr>';
        }
    }
    $output .= '</tbody>';
    $output .= '</table>';
    if (!is_user_logged_in() && 'publish' == rendez_vous()->item->status && !rendez_vous_single_date_set()) {
        $output .= '<div id="message" class="info"><p>' . __('If you want to set your preferences about this rendez-vous, please log in.', 'rendez-vous') . '</p></div>';
    }
    return apply_filters('rendez_vous_single_get_the_dates', $output, $view);
}
/**
 * Single screen content
 *
 * @package Rendez Vous
 * @subpackage Parts
 *
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_single_content()
{
    // Make sure embed url are processed
    add_filter('embed_post_id', 'rendez_vous_single_get_the_id');
    ?>
	<form action="<?php 
    echo esc_url(rendez_vous_single_the_form_action());
    ?>
" method="post" id="rendez-vous-single-form" class="standard-form">

		<label for="rendez-vous-single-description"><?php 
    esc_html_e('Description', 'rendez-vous');
    ?>
</label>
		<div id="rendez-vous-single-description"><?php 
    rendez_vous_single_the_description();
    ?>
</div>

		<label for="rendez-vous-single-venue"><?php 
    esc_html_e('Venue', 'rendez-vous');
    ?>
</label>
		<div id="rendez-vous-single-venue"><?php 
    rendez_vous_single_the_venue();
    ?>
</div>

		<?php 
    if (rendez_vous_single_has_type()) {
        ?>

			<label for="rendez-vous-single-type"><?php 
        esc_html_e('Type', 'rendez-vous');
        ?>
</label>
			<div id="rendez-vous-single-type"><?php 
        rendez_vous_single_the_type();
        ?>
</div>

		<?php 
    }
    ?>

		<?php 
    if (rendez_vous_single_date_set()) {
        ?>

			<label for="rendez-vous-single-date"><?php 
        esc_html_e('Fixed to:', 'rendez-vous');
        ?>
</label>
			<div id="rendez-vous-single-date"><?php 
        rendez_vous_single_the_date();
        ?>
</div>

		<?php 
    }
    ?>

		<label for="rendez-vous-single-duration"><?php 
    esc_html_e('Duration (hours)', 'rendez-vous');
    ?>
</label>
		<div id="rendez-vous-single-duration"><?php 
    rendez_vous_single_the_duration();
    ?>
</div>

		<hr/>

		<h4><?php 
    esc_html_e('Attendees', 'rendez-vous');
    ?>
</h4>

		<?php 
    rendez_vous_single_the_dates('single');
    ?>

		<?php 
    if (rendez_vous_single_has_report()) {
        ?>

			<hr/>

			<label for="rendez-vous-single-report"><?php 
        esc_html_e('Notes/Report', 'rendez-vous');
        ?>
</label>
			<div id="rendez-vous-single-report"><?php 
        rendez_vous_single_the_report();
        ?>
</div>

		<?php 
    }
    ?>

		<input type="hidden" value="<?php 
    rendez_vous_single_the_id();
    ?>
" name="_rendez_vous_prefs[id]"/>
		<input type="hidden" value="<?php 
    rendez_vous_single_the_action('single');
    ?>
" name="_rendez_vous_prefs[action]"/>
		<?php 
    wp_nonce_field('rendez_vous_prefs');
    ?>

		<?php 
    if (!rendez_vous_single_date_set()) {
        rendez_vous_single_the_submit('single');
    }
    ?>
	</form>
	<?php 
    // Stop processing embeds
    remove_filter('embed_post_id', 'rendez_vous_single_get_the_id');
}