false, 'parent' => 0 ) ); $recurrence_rules = get_option( 'propertyhive_key_date_type', array() ); $recurrence_rules = is_array( $recurrence_rules ) ? $recurrence_rules : array(); $parent_post_type = get_post_type( $post_id ); $meta_query = array(); switch ( $parent_post_type ) { case 'property' : { $meta_query = array( array( 'key' => '_property_id', 'value' => $post_id, ), array( 'key' => '_tenancy_id', 'compare' => 'NOT EXISTS', ), ); break; } case 'tenancy' : { $parent_property_id = get_post_meta( $post_id, '_property_id', true ); $meta_query = array( array( 'relation' => 'OR', array( 'key' => '_tenancy_id', 'value' => $post_id, ), array( 'key' => '_property_id', 'value' => $parent_property_id, ), ), ); break; } } if ( isset($selected_status) && !empty($selected_status) ) { switch ( $selected_status ) { case 'upcoming_and_overdue': { $meta_query[] = array( 'key' => '_key_date_status', 'value' => array('pending', 'booked'), 'compare' => 'IN' ); $upcoming_threshold = new DateTime('+ ' . apply_filters( 'propertyhive_key_date_upcoming_days', 7 ) . ' DAYS'); $meta_query[] = array( 'key' => '_date_due', 'value' => $upcoming_threshold->format('Y-m-d'), 'type' => 'date', 'compare' => '<=', ); break; } case 'overdue': { $meta_query[] = array( 'key' => '_key_date_status', 'value' => array('pending', 'booked'), 'compare' => 'IN' ); $meta_query[] = array( 'key' => '_date_due', 'value' => date('Y-m-d'), 'type' => 'date', 'compare' => '<', ); break; } default: { $meta_query[] = array( 'key' => '_key_date_status', 'value' => $selected_status, ); break; } } } if ( isset($selected_type_id) && !empty($selected_type_id) ) { $meta_query[] = array( 'key' => '_key_date_type_id', 'value' => $selected_type_id, ); } $key_dates = get_posts(array ( 'post_type' => 'key_date', 'nopaging' => true, 'meta_query' => $meta_query, 'orderby' => 'meta_value', 'meta_key' => '_date_due', 'order' => 'DESC', )); ?>
| Description | Notes | Tenants | Date Due | Status |
|---|---|---|---|---|
|
description(); ?>
|
notes()) ? nl2br( esc_html($key_date->notes()) ) : '-'; ?>
|
tenancy_id) )
{
$tenancy = $key_date->tenancy();
$tenants = $tenancy->get_tenants(false, true);
}
echo !empty($tenants) ? $tenants : '-';
?>
|
date_due()->format( 'H:i' ) == '00:00' )
{
$date_format = 'jS F Y';
}
else
{
$date_format = 'H:i jS F Y';
}
?>
date_due()->format( $date_format )); ?>
|
status() ) )); ?>
|
| No key dates found | ||||
| Description | Notes | Tenants | Date Due | Status |