| 1 |
<?php |
| 2 |
/** |
| 3 |
* Owner viewings page within My Account |
| 4 |
* |
| 5 |
* This template can be overridden by copying it to yourtheme/propertyhive/account/owner-viewings.php. |
| 6 |
* |
| 7 |
* @author PropertyHive |
| 8 |
* @package PropertyHive/Templates |
| 9 |
* @version 1.0.0 |
| 10 |
*/ |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
?> |
| 17 |
|
| 18 |
<div class="propertyhive-owner-viewings"> |
| 19 |
|
| 20 |
<h4>Upcoming Viewings</h4> |
| 21 |
|
| 22 |
<?php |
| 23 |
if ( !empty($upcoming_viewings) ) |
| 24 |
{ |
| 25 |
echo ' |
| 26 |
<table class="viewings-table upcoming-viewings-table" width="100%"> |
| 27 |
<tr> |
| 28 |
<th> </th> |
| 29 |
<th>' . esc_html(__( 'Viewing Date/Time', 'propertyhive' )) . '</th> |
| 30 |
<th>' . esc_html(__( 'Property', 'propertyhive' )) . '</th> |
| 31 |
</tr> |
| 32 |
'; |
| 33 |
foreach ($upcoming_viewings as $viewing) |
| 34 |
{ |
| 35 |
$property = new PH_Property( (int)$viewing->property_id ); |
| 36 |
|
| 37 |
$link_prefix = ( ( $property->on_market == 'yes' ) ? '<a href="' . esc_url(get_permalink( $viewing->property_id )) . '">' : '' ); |
| 38 |
$link_suffix = ( ( $property->on_market == 'yes' ) ? '</a>' : '' ); |
| 39 |
|
| 40 |
$date_prefix = ( ( $viewing->status == 'cancelled' ) ? '<span style="text-decoration:line-through">' : '' ); |
| 41 |
$date_suffix = ( ( $viewing->status == 'cancelled' ) ? '</span> (' . esc_html(__( 'Cancelled', 'propertyhive' )) . ')' : '' ); |
| 42 |
|
| 43 |
if ( $viewing->status == 'cancelled' && $viewing->cancelled_reason_public == 'yes' && $viewing->cancelled_reason != '' ) |
| 44 |
{ |
| 45 |
$date_suffix .= '<br>' . esc_html(__( 'Reason Cancelled', 'propertyhive' )) . ':<br>' . nl2br(esc_html($viewing->cancelled_reason)); |
| 46 |
} |
| 47 |
|
| 48 |
$image = $property->get_main_photo_src(); |
| 49 |
|
| 50 |
echo '<tr> |
| 51 |
<td>' . ( ( $image !== false ) ? $link_prefix . '<img src="' . esc_url($image) . '" width="75" alt="' . esc_attr(get_the_title( $viewing->property_id )) . '">' : '' ) . $link_suffix . '</td> |
| 52 |
<td>' . $date_prefix . esc_html(date( "H:i jS M Y", strtotime( $viewing->start_date_time ) )) . $date_suffix . '</td> |
| 53 |
<td>' . $link_prefix . esc_html(get_the_title( $viewing->property_id )) . $link_suffix . '<br>' . $property->get_formatted_price() . '</td> |
| 54 |
</tr>'; |
| 55 |
} |
| 56 |
echo '</table>'; |
| 57 |
} |
| 58 |
else |
| 59 |
{ |
| 60 |
echo '<p class="propertyhive-info">' . esc_html(__( 'No upcoming viewings scheduled', 'propertyhive' )) . '</p>'; |
| 61 |
} |
| 62 |
?> |
| 63 |
|
| 64 |
<h4>Past Viewings</h4> |
| 65 |
|
| 66 |
<?php |
| 67 |
if ( !empty($past_viewings) ) |
| 68 |
{ |
| 69 |
echo ' |
| 70 |
<table class="viewings-table upcoming-viewings-table" width="100%"> |
| 71 |
<tr> |
| 72 |
<th> </th> |
| 73 |
<th>' . esc_html(__( 'Viewing Date/Time', 'propertyhive' )) . '</th> |
| 74 |
<th>' . esc_html(__( 'Property', 'propertyhive' )) . '</th> |
| 75 |
</tr> |
| 76 |
'; |
| 77 |
foreach ($past_viewings as $viewing) |
| 78 |
{ |
| 79 |
$property = new PH_Property( (int)$viewing->property_id ); |
| 80 |
|
| 81 |
$link_prefix = ( ( $property->on_market == 'yes' ) ? '<a href="' . esc_url(get_permalink( $viewing->property_id )) . '">' : '' ); |
| 82 |
$link_suffix = ( ( $property->on_market == 'yes' ) ? '</a>' : '' ); |
| 83 |
|
| 84 |
$date_prefix = ( ( $viewing->status == 'cancelled' ) ? '<span style="text-decoration:line-through">' : '' ); |
| 85 |
$date_suffix = ( ( $viewing->status == 'cancelled' ) ? '</span> (' . esc_html(__( 'Cancelled', 'propertyhive' )) . ')' : '' ); |
| 86 |
|
| 87 |
if ( $viewing->status == 'cancelled' && $viewing->cancelled_reason_public == 'yes' && $viewing->cancelled_reason != '' ) |
| 88 |
{ |
| 89 |
$date_suffix .= '<br>' . esc_html(__( 'Reason Cancelled', 'propertyhive' )) . ':<br>' . nl2br(esc_html($viewing->cancelled_reason)); |
| 90 |
} |
| 91 |
|
| 92 |
$image = $property->get_main_photo_src(); |
| 93 |
|
| 94 |
echo '<tr> |
| 95 |
<td>' . ( ( $image !== false ) ? $link_prefix . '<img src="' . esc_url($image) . '" width="75" alt="' . esc_attr(get_the_title( $viewing->property_id )) . '">' : '' ) . $link_suffix . '</td> |
| 96 |
<td>' . $date_prefix . esc_html(date( "H:i jS M Y", strtotime( $viewing->start_date_time ) )) . $date_suffix . '</td> |
| 97 |
<td>' . $link_prefix . esc_html(get_the_title( $viewing->property_id )) . $link_suffix . '<br>' . $property->get_formatted_price() . '</td> |
| 98 |
</tr>'; |
| 99 |
} |
| 100 |
echo '</table>'; |
| 101 |
} |
| 102 |
else |
| 103 |
{ |
| 104 |
echo '<p class="propertyhive-info">' . esc_html(__( 'No past viewings', 'propertyhive' )) . '</p>'; |
| 105 |
} |
| 106 |
?> |
| 107 |
|
| 108 |
</div> |
| 109 |
|