| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
$meta_query = array( |
| 7 |
array( |
| 8 |
'key' => '_applicant_contact_id', |
| 9 |
'value' => $post_id |
| 10 |
), |
| 11 |
); |
| 12 |
|
| 13 |
if ( isset($selected_status) && !empty($selected_status) ) |
| 14 |
{ |
| 15 |
$meta_query[] = array( |
| 16 |
'key' => '_status', |
| 17 |
'value' => $selected_status, |
| 18 |
); |
| 19 |
} |
| 20 |
|
| 21 |
$args = array( |
| 22 |
'post_type' => 'offer', |
| 23 |
'nopaging' => true, |
| 24 |
'orderby' => 'meta_value', |
| 25 |
'order' => 'DESC', |
| 26 |
'meta_key' => '_offer_date_time', |
| 27 |
'post_status' => 'publish', |
| 28 |
'meta_query' => $meta_query, |
| 29 |
); |
| 30 |
$offers_query = new WP_Query( $args ); |
| 31 |
$offers_count = $offers_query->found_posts; |
| 32 |
|
| 33 |
$columns = array( |
| 34 |
'date' => __( 'Offer Date', 'propertyhive' ), |
| 35 |
'property' => __( 'Property', 'propertyhive' ), |
| 36 |
'property_owner' => __( 'Property Owner', 'propertyhive' ), |
| 37 |
'amount' => __( 'Offer Amount', 'propertyhive' ), |
| 38 |
'status' => __( 'Status', 'propertyhive' ), |
| 39 |
); |
| 40 |
|
| 41 |
$columns = apply_filters( 'propertyhive_contact_offers_columns', $columns ); |
| 42 |
?> |
| 43 |
|
| 44 |
<div class="tablenav top"> |
| 45 |
<div class="alignleft actions"> |
| 46 |
<select name="_status" id="_offer_status_filter"> |
| 47 |
<option value=""><?php echo esc_html(__( 'All Statuses', 'propertyhive' )); ?></option> |
| 48 |
<?php |
| 49 |
$offer_statuses = ph_get_offer_statuses(); |
| 50 |
|
| 51 |
foreach ( $offer_statuses as $status => $display_status ) |
| 52 |
{ |
| 53 |
?> |
| 54 |
<option value="<?php echo esc_attr($status); ?>" <?php selected( $status, $selected_status ); ?>><?php echo esc_html($display_status); ?></option> |
| 55 |
<?php |
| 56 |
} |
| 57 |
?> |
| 58 |
</select> |
| 59 |
<input type="button" name="filter_action" id="filter-contact-offers-grid" class="button" value="Filter"> |
| 60 |
<a href="" name="export_action" id="export-contact-offers-grid" class="button">Export</a> |
| 61 |
</div> |
| 62 |
<div class='tablenav-pages one-page'> |
| 63 |
<span class="displaying-num"><?php echo esc_html($offers_count); ?> item<?php echo $offers_count != 1 ? 's' : ''; ?></span> |
| 64 |
</div> |
| 65 |
<br class="clear" /> |
| 66 |
</div> |
| 67 |
<table class="wp-list-table widefat fixed striped posts"> |
| 68 |
<thead> |
| 69 |
<tr> |
| 70 |
<?php |
| 71 |
$column_i = 0; |
| 72 |
foreach ( $columns as $column_key => $column ) |
| 73 |
{ |
| 74 |
?> |
| 75 |
<th scope="col" id='<?php echo esc_attr($column_key); ?>' class='manage-column column-<?php echo esc_attr($column_key); echo ($column_i == 0 ? ' column-primary' : ''); ?>'><?php echo esc_html($column); ?></th> |
| 76 |
<?php |
| 77 |
++$column_i; |
| 78 |
} |
| 79 |
?> |
| 80 |
</tr> |
| 81 |
</thead> |
| 82 |
<tbody id="the-list"> |
| 83 |
<?php |
| 84 |
if ( $offers_query->have_posts() ) |
| 85 |
{ |
| 86 |
while ( $offers_query->have_posts() ) |
| 87 |
{ |
| 88 |
$offers_query->the_post(); |
| 89 |
$the_offer = new PH_Offer( get_the_ID() ); |
| 90 |
|
| 91 |
$edit_link = get_edit_post_link( get_the_ID() ); |
| 92 |
|
| 93 |
$column_data = array( |
| 94 |
'date' => '<a href="' . esc_url($edit_link) . '" target="' . esc_attr(apply_filters('propertyhive_subgrid_link_target', '')) . '" data-offer-id="' . esc_attr(get_the_ID()) . '">' . esc_html(date("jS F Y", strtotime($the_offer->_offer_date_time))) . '</a>', |
| 95 |
'property' => $the_offer->get_property_address(), |
| 96 |
'property_owner' => $the_offer->get_property_owners(), |
| 97 |
'amount' => esc_html($the_offer->get_formatted_amount()), |
| 98 |
'status' => esc_html(__( ucwords(str_replace("_", " ", $the_offer->_status)), 'propertyhive' )), |
| 99 |
); |
| 100 |
|
| 101 |
$row_classes = array( 'status-' . $the_offer->_status ); |
| 102 |
$row_classes = apply_filters( 'propertyhive_contact_offers_row_classes', $row_classes, get_the_ID(), $the_offer ); |
| 103 |
$row_classes = is_array($row_classes) ? array_map( 'sanitize_html_class', array_map( 'strtolower', $row_classes ) ) : array(); |
| 104 |
?> |
| 105 |
<tr class="<?php echo esc_attr(implode(" ", $row_classes)); ?>" > |
| 106 |
<?php |
| 107 |
$column_i = 0; |
| 108 |
foreach ( $columns as $column_key => $column ) |
| 109 |
{ |
| 110 |
echo '<td class="' . esc_attr($column_key) . ' column-' . esc_attr($column_key) . ($column_i == 0 ? ' column-primary' : '') . '" data-colname="' . esc_attr($column) . '">'; |
| 111 |
|
| 112 |
if ( isset( $column_data[$column_key] ) ) |
| 113 |
{ |
| 114 |
echo $column_data[$column_key]; |
| 115 |
} |
| 116 |
|
| 117 |
do_action( 'propertyhive_contact_offers_custom_column', $column_key ); |
| 118 |
|
| 119 |
if ( $column_i == 0 ) { echo '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html(__('Show more details', 'propertyhive' )) . '</span></button>'; } |
| 120 |
|
| 121 |
echo '</td>'; |
| 122 |
++$column_i; |
| 123 |
} |
| 124 |
?> |
| 125 |
</tr> |
| 126 |
<?php |
| 127 |
} |
| 128 |
} |
| 129 |
else |
| 130 |
{ |
| 131 |
?> |
| 132 |
<tr class="no-items"> |
| 133 |
<td class="colspanchange" colspan="<?php echo count($columns); ?>"><?php echo esc_html(__( 'No offers found', 'propertyhive' )); ?></td> |
| 134 |
</tr> |
| 135 |
<?php |
| 136 |
} |
| 137 |
wp_reset_postdata(); |
| 138 |
?> |
| 139 |
</tbody> |
| 140 |
</table> |