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-contact-tenancies-meta-box.php

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

213 lines 13.1 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' => '_applicant_contact_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 contact; 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 'property' => __( 'Property', '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_contact_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-contact-tenancies-grid" class="button" value="Filter">
116 </div>
117 <div class='tablenav-pages one-page'>
118 <span class="displaying-num"><?php echo esc_html($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 $property_id = $the_tenancy->_property_id;
151 // 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.
152 $property = new PH_Property((int)$property_id);
153
154 // 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.
155 $edit_link = get_edit_post_link( get_the_ID() );
156
157 // 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.
158 $column_data = array(
159 'dates' => '<a href="' . esc_url($edit_link) . '" target="' . esc_attr(apply_filters('propertyhive_subgrid_link_target', '')) . '">
160 Start Date: ' . ( $the_tenancy->_start_date != '' ? esc_html(gmdate( "d/m/Y", strtotime( $the_tenancy->_start_date ) )) : '-' ) . '<br>
161 End Date: ' . ( $the_tenancy->_end_date != '' ? esc_html(gmdate( "d/m/Y", strtotime( $the_tenancy->_end_date ) )) : '-' ) . '
162 </a>',
163 'property' => esc_html($property->get_formatted_full_address()),
164 'rent' => esc_html($the_tenancy->get_formatted_rent()),
165 'status' => esc_html($the_tenancy->get_status()),
166 );
167
168 // 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.
169 $row_classes = array( 'status-' . $the_tenancy->get_status() );
170 // 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.
171 $row_classes = apply_filters( 'propertyhive_contact_tenancies_row_classes', $row_classes, get_the_ID(), $the_tenancy );
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 $row_classes = is_array($row_classes) ? array_map( 'sanitize_html_class', array_map( 'strtolower', $row_classes ) ) : array();
174 ?>
175 <tr class="<?php echo esc_attr(implode(" ", $row_classes)); ?>" >
176 <?php
177 // 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.
178 $column_i = 0;
179 // 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.
180 foreach ( $columns as $column_key => $column )
181 {
182 echo '<td class="' . esc_attr($column_key) . ' column-' . esc_attr($column_key) . ($column_i == 0 ? ' column-primary' : '') . '" data-colname="' . esc_attr($column) . '">';
183
184 if ( isset( $column_data[$column_key] ) )
185 {
186 // 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.
187 echo $column_data[$column_key];
188 }
189
190 do_action( 'propertyhive_contact_tenancies_custom_column', $column_key );
191
192 if ( $column_i == 0 ) { echo '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html(__('Show more details', 'propertyhive' )) . '</span></button>'; }
193
194 echo '</td>';
195 ++$column_i;
196 }
197 ?>
198 </tr>
199 <?php
200 }
201 }
202 else
203 {
204 ?>
205 <tr class="no-items">
206 <td class="colspanchange" colspan="4"><?php echo esc_html(__( 'No tenancies found', 'propertyhive' )); ?></td>
207 </tr>
208 <?php
209 }
210 wp_reset_postdata();
211 ?>
212 </tbody>
213 </table>