| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
?><td colspan="5"> |
| 6 |
<div class="propertyhive_meta_box"> |
| 7 |
<div class="options_group"> |
| 8 |
<p class="form-field"> |
| 9 |
<label for="date_description">Description</label> |
| 10 |
<input type="text" id="date_description" class="short" value="<?php echo isset( $_POST['description'] ) ? esc_html(ph_clean($_POST['description'])) : ''; ?>"> |
| 11 |
</p> |
| 12 |
<p class="form-field"> |
| 13 |
<label for="key_date_status">Status</label> |
| 14 |
<?php |
| 15 |
$output = '<select id="key_date_status" name="key_date_status">'; |
| 16 |
|
| 17 |
foreach ( array( 'pending', 'booked', 'complete', 'on_hold', 'cancelled' ) as $status ) |
| 18 |
{ |
| 19 |
$selected_value = isset( $_POST['status'] ) ? strtolower($_POST['status']) : ''; |
| 20 |
if ( in_array($selected_value, array('overdue', 'upcoming') ) ) |
| 21 |
{ |
| 22 |
$selected_value = 'pending'; |
| 23 |
} |
| 24 |
$output .= '<option value="' . esc_attr($status) . '"'; |
| 25 |
$output .= selected($status, $selected_value, false ); |
| 26 |
$output .= '>' . esc_html(ucwords(str_replace("_", " ", $status))) . '</option>'; |
| 27 |
} |
| 28 |
|
| 29 |
$output .= '</select>'; |
| 30 |
|
| 31 |
echo $output; |
| 32 |
?> |
| 33 |
</p> |
| 34 |
<p class="form-field"> |
| 35 |
<?php |
| 36 |
$due_date_time = isset( $_POST['due_date_time'] ) ? strtotime($_POST['due_date_time']) : ''; |
| 37 |
?> |
| 38 |
<label for="date_due_quick_edit">Due Date</label> |
| 39 |
<input type="date" class="small" name="date_due_quick_edit" id="date_due_quick_edit" value="<?php echo esc_attr(date('Y-m-d', $due_date_time)); ?>" placeholder=""> |
| 40 |
|
| 41 |
<select id="date_due_hours_quick_edit" name="date_due_hours_quick_edit" class="select short" style="width:55px">'; |
| 42 |
<?php |
| 43 |
for ( $i = 0; $i < 23; ++$i ) |
| 44 |
{ |
| 45 |
$j = str_pad($i, 2, '0', STR_PAD_LEFT); |
| 46 |
echo '<option value="' . esc_attr($j) . '"'; |
| 47 |
if ( date('H', $due_date_time) == $j ) { echo ' selected'; } |
| 48 |
echo '>' . esc_html($j) . '</option>'; |
| 49 |
} |
| 50 |
?> |
| 51 |
</select> |
| 52 |
: |
| 53 |
<select id="date_due_minutes_quick_edit" name="date_due_minutes_quick_edit" class="select short" style="width:55px"> |
| 54 |
<?php |
| 55 |
for ( $i = 0; $i < 60; $i+=5 ) |
| 56 |
{ |
| 57 |
$j = str_pad($i, 2, '0', STR_PAD_LEFT); |
| 58 |
echo '<option value="' . esc_attr($j) . '"'; |
| 59 |
if ( date('i', $due_date_time) == $j ) { echo ' selected'; } |
| 60 |
echo '>' . esc_html($j) . '</option>'; |
| 61 |
} |
| 62 |
?> |
| 63 |
</select> |
| 64 |
</p> |
| 65 |
<p class="form-field"> |
| 66 |
<label for="date_type"><?php echo esc_html(__('Key Date Type', 'propertyhive')); ?></label> |
| 67 |
<select id="date_type" name="date_type" class="select short"> |
| 68 |
<?php |
| 69 |
$key_date_type_terms = get_terms( 'management_key_date_type', array( |
| 70 |
'hide_empty' => false, |
| 71 |
'parent' => 0 |
| 72 |
) ); |
| 73 |
$recurrence_rules = get_option( 'propertyhive_key_date_type', array() ); |
| 74 |
$recurrence_rules = is_array( $recurrence_rules ) ? $recurrence_rules : array(); |
| 75 |
|
| 76 |
$parent_post_type = get_post_type( $post_id ); |
| 77 |
if ( !empty( $key_date_type_terms ) && !is_wp_error( $key_date_type_terms ) ) |
| 78 |
{ |
| 79 |
foreach ($key_date_type_terms as $key_date_type_term) |
| 80 |
{ |
| 81 |
$recurrence_type = isset($recurrence_rules[$key_date_type_term->term_id]) ? $recurrence_rules[$key_date_type_term->term_id]['recurrence_type'] : ''; |
| 82 |
if ( $parent_post_type == 'tenancy' || ( $parent_post_type == 'property' && $recurrence_type == 'property_management' ) ) |
| 83 |
{ |
| 84 |
echo '<option value="' . esc_attr($key_date_type_term->term_id) . '"'; |
| 85 |
if ( isset( $_POST['type'] ) && $_POST['type'] == $key_date_type_term->term_id ) { echo ' selected'; } |
| 86 |
echo '>' . esc_html($key_date_type_term->name) . '</option>'; |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
?> |
| 91 |
</select> |
| 92 |
</p> |
| 93 |
<p class="form-field"> |
| 94 |
<label for="date_notes_quick_edit">Notes</label> |
| 95 |
<textarea id="date_notes_quick_edit" class="short"><?php echo ( isset( $_POST['notes'] ) && $_POST['notes'] != '-' ) ? stripslashes( sanitize_textarea_field($_POST['notes']) ) : ''; ?></textarea> |
| 96 |
</p> |
| 97 |
<?php |
| 98 |
if ( isset($recurrence_rules[$_POST['type']]) && isset( $recurrence_rules[$_POST['type']]['recurrence_rule'] ) ) |
| 99 |
{ |
| 100 |
$recurrence = array(); |
| 101 |
|
| 102 |
foreach (explode(';', $recurrence_rules[$_POST['type']]['recurrence_rule']) as $key_value_pair){ |
| 103 |
list($key, $value) = explode('=', $key_value_pair); |
| 104 |
$recurrence[strtolower($key)] = $value; |
| 105 |
} |
| 106 |
|
| 107 |
if ( isset($recurrence['freq']) && $recurrence['freq'] != 'ONCE' ) |
| 108 |
{ |
| 109 |
?> |
| 110 |
<p id="next_key_date_checkbox" class="form-field hidden"> |
| 111 |
<label for="book_next_key_date"><?php echo esc_html(__('Book Next ' . ( isset( $_POST['description'] ) ? esc_html(ph_clean($_POST['description'])) : 'Key Date' ) . '?', 'propertyhive')); ?></label> |
| 112 |
<input type="checkbox" id="book_next_key_date" > |
| 113 |
</p> |
| 114 |
<?php |
| 115 |
$next_key_date = ''; |
| 116 |
$next_key_date_hours = '00'; |
| 117 |
$next_key_date_minutes = '00'; |
| 118 |
|
| 119 |
$interval = isset($recurrence['interval']) ? $recurrence['interval'] : '1'; |
| 120 |
switch( $recurrence['freq'] ) |
| 121 |
{ |
| 122 |
case 'DAILY': |
| 123 |
$frequency = 'day'; |
| 124 |
break; |
| 125 |
case 'WEEKLY': |
| 126 |
$frequency = 'week'; |
| 127 |
break; |
| 128 |
case 'MONTHLY': |
| 129 |
$frequency = 'month'; |
| 130 |
break; |
| 131 |
case 'YEARLY': |
| 132 |
$frequency = 'year'; |
| 133 |
break; |
| 134 |
} |
| 135 |
|
| 136 |
if ( isset($frequency) ) |
| 137 |
{ |
| 138 |
$next_key_timestamp = strtotime('+' . $interval . ' ' . $frequency, $due_date_time); |
| 139 |
$next_key_date = date('Y-m-d', $next_key_timestamp); |
| 140 |
$next_key_date_hours = date('H', $next_key_timestamp); |
| 141 |
$next_key_date_minutes = date('i', $next_key_timestamp); |
| 142 |
} |
| 143 |
?> |
| 144 |
<p id="next_key_date_field" class="form-field hidden"> |
| 145 |
<label for="next_key_date"> </label> |
| 146 |
<input type="date" class="small" name="next_key_date" id="next_key_date" value="<?php echo esc_attr($next_key_date); ?>" placeholder=""> |
| 147 |
|
| 148 |
<select id="next_key_date_hours" name="next_key_date_hours" class="select short" style="width:55px">'; |
| 149 |
<?php |
| 150 |
for ( $i = 0; $i < 23; ++$i ) |
| 151 |
{ |
| 152 |
$j = str_pad($i, 2, '0', STR_PAD_LEFT); |
| 153 |
echo '<option value="' . esc_attr($j) . '"'; |
| 154 |
if ( $next_key_date_hours == $j ) { echo ' selected'; } |
| 155 |
echo '>' . esc_html($j) . '</option>'; |
| 156 |
} |
| 157 |
?> |
| 158 |
</select> |
| 159 |
: |
| 160 |
<select id="next_key_date_minutes" name="next_key_date_minutes" class="select short" style="width:55px"> |
| 161 |
<?php |
| 162 |
for ( $i = 0; $i < 60; $i+=5 ) |
| 163 |
{ |
| 164 |
$j = str_pad($i, 2, '0', STR_PAD_LEFT); |
| 165 |
echo '<option value="' . esc_attr($j) . '"'; |
| 166 |
if ( $next_key_date_minutes == $j ) { echo ' selected'; } |
| 167 |
echo '>' . esc_html($j) . '</option>'; |
| 168 |
} |
| 169 |
?> |
| 170 |
</select> |
| 171 |
</p> |
| 172 |
<?php |
| 173 |
} |
| 174 |
} |
| 175 |
?> |
| 176 |
<button type="button" id="<?php echo esc_attr((int)$_POST['date_post_id']); ?>" class="button button-primary save-quick-edit">Update</button> |
| 177 |
<button type="button" id="<?php echo esc_attr((int)$_POST['date_post_id']); ?>" class="button cancel-quick-edit">Cancel</button> |
| 178 |
</div> |
| 179 |
</div> |
| 180 |
</td> |
| 181 |
|