| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 7 |
$meta_query = array( |
| 8 |
array( |
| 9 |
'key' => '_applicant_contact_id', |
| 10 |
'value' => $post_id |
| 11 |
), |
| 12 |
); |
| 13 |
|
| 14 |
if ( isset($selected_status) && !empty($selected_status) ) |
| 15 |
{ |
| 16 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 17 |
$meta_query[] = array( |
| 18 |
'key' => '_status', |
| 19 |
'value' => $selected_status, |
| 20 |
); |
| 21 |
} |
| 22 |
|
| 23 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 24 |
$args = array( |
| 25 |
'post_type' => 'sale', |
| 26 |
'nopaging' => true, |
| 27 |
'orderby' => 'meta_value', |
| 28 |
'order' => 'DESC', |
| 29 |
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- The CRM grid orders all linked records by their stored event date; keep metadata ordering for existing display and export parity. |
| 30 |
'meta_key' => '_sale_date_time', |
| 31 |
'post_status' => 'publish', |
| 32 |
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Required relationship/status metadata restricts this grid to the selected contact; retain existing result and status-filter semantics. |
| 33 |
'meta_query' => $meta_query, |
| 34 |
); |
| 35 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 36 |
$sales_query = new WP_Query( $args ); |
| 37 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 38 |
$sales_count = $sales_query->found_posts; |
| 39 |
|
| 40 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 41 |
$columns = array( |
| 42 |
'date' => __( 'Sale Date', 'propertyhive' ), |
| 43 |
'property' => __( 'Property', 'propertyhive' ), |
| 44 |
'property_owner' => __( 'Property Owner', 'propertyhive' ), |
| 45 |
'amount' => __( 'Sale Amount', 'propertyhive' ), |
| 46 |
'status' => __( 'Status', 'propertyhive' ), |
| 47 |
); |
| 48 |
|
| 49 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 50 |
$columns = apply_filters( 'propertyhive_contact_sales_columns', $columns ); |
| 51 |
?> |
| 52 |
|
| 53 |
<div class="tablenav top"> |
| 54 |
<div class="alignleft actions"> |
| 55 |
<select name="_status" id="_sale_status_filter"> |
| 56 |
<option value=""><?php echo esc_html(__( 'All Statuses', 'propertyhive' )); ?></option> |
| 57 |
<?php |
| 58 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 59 |
$sale_statuses = ph_get_sale_statuses(); |
| 60 |
|
| 61 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 62 |
foreach ( $sale_statuses as $status => $display_status ) |
| 63 |
{ |
| 64 |
?> |
| 65 |
<option value="<?php echo esc_attr($status); ?>" <?php selected( $status, $selected_status ); ?>><?php echo esc_html($display_status); ?></option> |
| 66 |
<?php |
| 67 |
} |
| 68 |
?> |
| 69 |
</select> |
| 70 |
<input type="button" name="filter_action" id="filter-contact-sales-grid" class="button" value="Filter"> |
| 71 |
<a href="" name="export_action" id="export-contact-sales-grid" class="button">Export</a> |
| 72 |
</div> |
| 73 |
<div class='tablenav-pages one-page'> |
| 74 |
<span class="displaying-num"><?php echo esc_html($sales_count); ?> item<?php echo $sales_count != 1 ? 's' : ''; ?></span> |
| 75 |
</div> |
| 76 |
<br class="clear" /> |
| 77 |
</div> |
| 78 |
<table class="wp-list-table widefat fixed striped posts"> |
| 79 |
<thead> |
| 80 |
<tr> |
| 81 |
<?php |
| 82 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 83 |
$column_i = 0; |
| 84 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 85 |
foreach ( $columns as $column_key => $column ) |
| 86 |
{ |
| 87 |
?> |
| 88 |
<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> |
| 89 |
<?php |
| 90 |
++$column_i; |
| 91 |
} |
| 92 |
?> |
| 93 |
</tr> |
| 94 |
</thead> |
| 95 |
<tbody id="the-list"> |
| 96 |
<?php |
| 97 |
if ( $sales_query->have_posts() ) |
| 98 |
{ |
| 99 |
while ( $sales_query->have_posts() ) |
| 100 |
{ |
| 101 |
$sales_query->the_post(); |
| 102 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 103 |
$the_sale = new PH_Sale( get_the_ID() ); |
| 104 |
|
| 105 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 106 |
$edit_link = get_edit_post_link( get_the_ID() ); |
| 107 |
|
| 108 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 109 |
$column_data = array( |
| 110 |
'date' => '<a href="' . esc_url($edit_link) . '" target="' . esc_attr(apply_filters('propertyhive_subgrid_link_target', '')) . '" data-sale-id="' . esc_attr(get_the_ID()) . '">' . esc_html(gmdate("jS F Y", strtotime($the_sale->_sale_date_time))) . '</a>', |
| 111 |
'property' => $the_sale->get_property_address(), |
| 112 |
'property_owner' => $the_sale->get_property_owners(), |
| 113 |
'amount' => esc_html($the_sale->get_formatted_amount()), |
| 114 |
'status' => esc_html(propertyhive_get_status_label( $the_sale->_status )), |
| 115 |
); |
| 116 |
|
| 117 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 118 |
$row_classes = array( 'status-' . $the_sale->_status ); |
| 119 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 120 |
$row_classes = apply_filters( 'propertyhive_contact_sales_row_classes', $row_classes, get_the_ID(), $the_sale ); |
| 121 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 122 |
$row_classes = is_array($row_classes) ? array_map( 'sanitize_html_class', array_map( 'strtolower', $row_classes ) ) : array(); |
| 123 |
?> |
| 124 |
<tr class="<?php echo esc_attr(implode(" ", $row_classes)); ?>" > |
| 125 |
<?php |
| 126 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 127 |
$column_i = 0; |
| 128 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable in an admin view; PHPCS analyzes the view file standalone even though WordPress includes it inside a method/function scope. |
| 129 |
foreach ( $columns as $column_key => $column ) |
| 130 |
{ |
| 131 |
echo '<td class="' . esc_attr($column_key) . ' column-' . esc_attr($column_key) . ($column_i == 0 ? ' column-primary' : '') . '" data-colname="' . esc_attr($column) . '">'; |
| 132 |
|
| 133 |
if ( isset( $column_data[$column_key] ) ) |
| 134 |
{ |
| 135 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Core cells are escaped HTML assembled above or by the reviewed PH model formatters; preserve trusted PHP contact-detail filter markup and links. |
| 136 |
echo $column_data[$column_key]; |
| 137 |
} |
| 138 |
|
| 139 |
do_action( 'propertyhive_contact_sales_custom_column', $column_key ); |
| 140 |
|
| 141 |
if ( $column_i == 0 ) { echo '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html(__('Show more details', 'propertyhive' )) . '</span></button>'; } |
| 142 |
|
| 143 |
echo '</td>'; |
| 144 |
++$column_i; |
| 145 |
} |
| 146 |
?> |
| 147 |
</tr> |
| 148 |
<?php |
| 149 |
} |
| 150 |
} |
| 151 |
else |
| 152 |
{ |
| 153 |
?> |
| 154 |
<tr class="no-items"> |
| 155 |
<td class="colspanchange" colspan="<?php echo count($columns); ?>"><?php echo esc_html(__( 'No sales found', 'propertyhive' )); ?></td> |
| 156 |
</tr> |
| 157 |
<?php |
| 158 |
} |
| 159 |
wp_reset_postdata(); |
| 160 |
?> |
| 161 |
</tbody> |
| 162 |
</table> |