PluginProbe
Property Hive / 2.4.0
Property Hive v2.4.0
2.4.0 2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 All 262 releases
propertyhive / includes / admin / views / html-property-tenancies-meta-box.php

html-property-tenancies-meta-box.php in Property Hive 2.4.0, at includes/admin/views/html-property-tenancies-meta-box.php

208 lines 12.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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' => '_property_id',
10 'value' => $post_id,
11 ),
12 );
13
14 if ( isset($selected_status) && !empty($selected_status) )
15 {
16 switch ( $selected_status )
17 {
18 case 'pending':
19 {
20 // 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.
21 $meta_query[] = array(
22 'key' => '_start_date',
23 'value' => gmdate('Y-m-d'),
24 'type' => 'date',
25 'compare' => '>',
26 );
27 break;
28 }
29 case 'current':
30 {
31 // 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.
32 $meta_query[] = array(
33 'relation' => 'OR',
34 array(
35 array(
36 'key' => '_start_date',
37 'value' => gmdate('Y-m-d'),
38 'type' => 'date',
39 'compare' => '<=',
40 ),
41 array(
42 'key' => '_end_date',
43 'value' => gmdate('Y-m-d'),
44 'type' => 'date',
45 'compare' => '>=',
46 )
47 ),
48 array(
49 array(
50 'key' => '_start_date',
51 'value' => gmdate('Y-m-d'),
52 'type' => 'date',
53 'compare' => '<=',
54 ),
55 array(
56 'key' => '_end_date',
57 'value' => '',
58 'compare' => '=',
59 )
60 )
61 );
62 break;
63 }
64 case 'finished':
65 {
66 // 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.
67 $meta_query[] = array(
68 'key' => '_end_date',
69 'value' => gmdate('Y-m-d'),
70 'type' => 'date',
71 'compare' => '<',
72 );
73 break;
74 }
75 }
76 }
77
78 // 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.
79 $args = array(
80 'post_type' => 'tenancy',
81 'nopaging' => true,
82 'orderby' => 'meta_value',
83 'order' => 'DESC',
84 // 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.
85 'meta_key' => '_start_date',
86 'post_status' => 'publish',
87 // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Required relationship/status metadata restricts this grid to the selected property; retain existing result and status-filter semantics.
88 'meta_query' => $meta_query
89 );
90 // 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.
91 $tenancies_query = new WP_Query( $args );
92 // 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.
93 $tenancies_count = $tenancies_query->found_posts;
94
95 // 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.
96 $columns = array(
97 'dates' => __( 'Start / End Dates', 'propertyhive' ),
98 'tenants' => __( 'Tenants(s)', 'propertyhive' ),
99 'rent' => __( 'Rent', 'propertyhive' ),
100 'status' => __( 'Status', 'propertyhive' ),
101 );
102
103 // 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.
104 $columns = apply_filters( 'propertyhive_property_tenancies_columns', $columns );
105 ?>
106
107 <div class="tablenav top">
108 <div class="alignleft actions">
109 <select name="_status" id="_tenancy_status_filter">
110 <option value="">All Statuses</option>
111 <option value="pending" <?php echo ( isset($selected_status) && $selected_status == 'pending' ) ? 'selected' : ''; ?>>Pending</option>
112 <option value="current" <?php echo ( isset($selected_status) && $selected_status == 'current' ) ? 'selected' : ''; ?>> Current</option>
113 <option value="finished" <?php echo ( isset($selected_status) && $selected_status == 'finished' ) ? 'selected' : ''; ?>> Finished</option>
114 </select>
115 <input type="button" name="filter_action" id="filter-property-tenancies-grid" class="button" value="Filter">
116 </div>
117 <div class='tablenav-pages one-page'>
118 <span class="displaying-num"><?php echo esc_attr($tenancies_count); ?> item<?php echo $tenancies_count != 1 ? 's' : ''; ?></span>
119 </div>
120 <br class="clear" />
121 </div>
122 <table class="wp-list-table widefat fixed striped posts">
123 <thead>
124 <tr>
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 ?>
132 <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>
133 <?php
134 ++$column_i;
135 }
136 ?>
137 </tr>
138 </thead>
139 <tbody id="the-list">
140 <?php
141 if ( $tenancies_query->have_posts() )
142 {
143 while ( $tenancies_query->have_posts() )
144 {
145 $tenancies_query->the_post();
146 // 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.
147 $the_tenancy = new PH_Tenancy( get_the_ID() );
148
149 // 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.
150 $edit_link = get_edit_post_link( get_the_ID() );
151
152 // 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.
153 $column_data = array(
154 'dates' => '<a href="' . esc_url($edit_link) . '" target="' . esc_attr(apply_filters('propertyhive_subgrid_link_target', '')) . '">
155 Start Date: ' . ( $the_tenancy->_start_date != '' ? esc_html(gmdate( "d/m/Y", strtotime( $the_tenancy->_start_date ) )) : '-' ) . '<br>
156 End Date: ' . ( $the_tenancy->_end_date != '' ? esc_html(gmdate( "d/m/Y", strtotime( $the_tenancy->_end_date ) )) : '-' ) . '
157 </a>',
158 'tenants' => $the_tenancy->get_tenants( true, true ),
159 'rent' => esc_html($the_tenancy->get_formatted_rent()),
160 'status' => esc_html($the_tenancy->get_status()),
161 );
162
163 // 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.
164 $row_classes = array( 'status-' . $the_tenancy->get_status() );
165 // 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.
166 $row_classes = apply_filters( 'propertyhive_property_tenancies_row_classes', $row_classes, get_the_ID(), $the_tenancy );
167 // 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.
168 $row_classes = is_array($row_classes) ? array_map( 'sanitize_html_class', array_map( 'strtolower', $row_classes ) ) : array();
169 ?>
170 <tr class="<?php echo esc_attr(implode(" ", $row_classes)); ?>" >
171 <?php
172 // 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.
173 $column_i = 0;
174 // 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.
175 foreach ( $columns as $column_key => $column )
176 {
177 echo '<td class="' . esc_attr($column_key) . ' column-' . esc_attr($column_key) . ($column_i == 0 ? ' column-primary' : '') . '" data-colname="' . esc_attr($column) . '">';
178
179 if ( isset( $column_data[$column_key] ) )
180 {
181 // 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.
182 echo $column_data[$column_key];
183 }
184
185 do_action( 'propertyhive_property_tenancies_custom_column', $column_key );
186
187 if ( $column_i == 0 ) { echo '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html(__('Show more details', 'propertyhive' )) . '</span></button>'; }
188
189 echo '</td>';
190 ++$column_i;
191 }
192 ?>
193 </tr>
194 <?php
195 }
196 }
197 else
198 {
199 ?>
200 <tr class="no-items">
201 <td class="colspanchange" colspan="4"><?php echo esc_html(__( 'No tenancies found', 'propertyhive' )); ?></td>
202 </tr>
203 <?php
204 }
205 wp_reset_postdata();
206 ?>
207 </tbody>
208 </table>