PluginProbe
Property Hive / 2.3.1
Property Hive v2.3.1
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 1.4.61 All 261 releases
propertyhive / includes / admin / reports / class-ph-report-incomplete-properties.php

class-ph-report-incomplete-properties.php in Property Hive 2.3.1, at includes/admin/reports/class-ph-report-incomplete-properties.php

387 lines 15.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:set WordPress.Security.ValidatedSanitizedInput customSanitizingFunctions[] ph_clean
3 // ph_clean() recursively sanitizes text; presence, shape and unslashing checks remain separate.
4
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 /**
11 * PH_Report_Incomplete_Properties
12 *
13 * @author PropertyHive
14 * @category Admin
15 * @package PropertyHive/Admin/Reports
16 * @version 1.0.0
17 */
18 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy public global class PH_Report_Incomplete_Properties; preserving the existing PH_* class name is required for plugin and extension compatibility.
19 class PH_Report_Incomplete_Properties extends PH_Admin_Report {
20
21 /**
22 * Output the report.
23 */
24 public function output_report() {
25 ?>
26
27 <style type="text/css">
28
29 .chart-with-sidebar { padding:12px 12px 12px 249px; background:#FFF; border:1px solid #DDD; min-height:300px; }
30 .chart-sidebar { width:225px; margin-left:-237px; float:left; }
31 .chart-main { }
32
33 </style>
34
35 <br>
36
37 <div class="chart-with-sidebar">
38
39 <div class="chart-sidebar">
40
41 <form method="post" action="">
42
43 <label for="missing">Show Properties Missing:</label>
44 <select name="missing" id="missing" style="width:100%;">
45 <option value="">One or more items</option>
46 <option value="_photos"<?php
47 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
48 if ( isset($_POST['missing']) && $_POST['missing'] == '_photos' ) { echo ' selected'; } ?>>Photos</option>
49 <option value="_floorplans"<?php
50 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
51 if ( isset($_POST['missing']) && $_POST['missing'] == '_floorplans' ) { echo ' selected'; } ?>>Floorplans</option>
52 <option value="_epcs"<?php
53 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
54 if ( isset($_POST['missing']) && $_POST['missing'] == '_epcs' ) { echo ' selected'; } ?>>EPCS</option>
55 <option value="_brochures"<?php
56 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
57 if ( isset($_POST['missing']) && $_POST['missing'] == '_brochures' ) { echo ' selected'; } ?>>Brochures</option>
58 <option value="_virtual_tours"<?php
59 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
60 if ( isset($_POST['missing']) && $_POST['missing'] == '_virtual_tours' ) { echo ' selected'; } ?>>Virtual Tours</option>
61 <option value="summary"<?php
62 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
63 if ( isset($_POST['missing']) && $_POST['missing'] == 'summary' ) { echo ' selected'; } ?>>Summary Description</option>
64 <option value="_latitude"<?php
65 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
66 if ( isset($_POST['missing']) && $_POST['missing'] == '_latitude' ) { echo ' selected'; } ?>>Map Co-ordinates</option>
67 </select>
68
69 <br><br>
70
71 <label for="department">Department:</label>
72 <select name="department" id="department" style="width:100%;">
73 <option value="">All</option>
74
75 <?php
76 $departments = ph_get_departments();
77
78 foreach ( $departments as $key => $value )
79 {
80 if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' )
81 {
82 echo '<option value="' . esc_attr($key) . '"';
83 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
84 if ( isset($_POST['department']) && $_POST['department'] == $key ) { echo ' selected'; }
85 echo '>' . esc_html($value) . '</option>';
86 }
87 }
88 ?>
89 </select>
90
91 <br><br>
92
93 <label for="on_market">Market Status:</label>
94 <select name="on_market" id="on_market" style="width:100%;">
95 <option value=""<?php
96 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
97 if ( isset($_POST['on_market']) && $_POST['on_market'] == '' ) { echo ' selected'; } ?>>On Market Properties Only</option>
98 <option value="all"<?php
99 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
100 if ( isset($_POST['on_market']) && $_POST['on_market'] == 'all' ) { echo ' selected'; } ?>>All Properties</option>
101 </select>
102
103 <br><br>
104
105 <label for="metric_two">Office:</label>
106 <select name="office_id" id="office_id" style="width:100%;">
107 <option value="">All Offices</option>
108 <?php
109 $args = array(
110 'post_type' => 'office',
111 'orderby' => 'post_title',
112 'order' => 'ASC',
113 'nopaging' => true,
114 );
115
116 $office_query = new WP_Query( $args );
117
118 if ( $office_query->have_posts() )
119 {
120 while ( $office_query->have_posts() )
121 {
122 $office_query->the_post();
123 ?>
124 <option value="<?php
125 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
126 echo esc_attr(get_the_ID()); ?>"<?php if ( isset($_POST['office_id']) && ($_POST['office_id'] == get_the_ID()) ) { echo ' selected'; } ?>><?php echo esc_html(get_the_title(get_the_ID())); ?></option>
127 <?php
128 }
129 }
130
131 wp_reset_postdata();
132 ?>
133 </select>
134
135 <br><br>
136 <input type="submit" value="Update" class="button button-primary">
137
138 </form>
139
140 </div>
141
142 <div class="chart-main">
143
144 <?php
145 $args = array(
146 'post_type' => 'property',
147 'nopaging' => true,
148 'fields' => 'ids',
149 );
150
151 $meta_query = array('relation' => 'AND');
152
153 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
154 if ( isset($_POST['on_market']) && $_POST['on_market'] == 'all' )
155 {
156
157 }
158 else
159 {
160 $meta_query[] = array(
161 'key' => '_on_market',
162 'value' => 'yes',
163 );
164 }
165
166 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
167 if ( isset($_POST['department']) && is_string( $_POST['department'] ) && $_POST['department'] != '' )
168 {
169 $meta_query[] = array(
170 'key' => '_department',
171 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
172 'value' => ph_clean( wp_unslash( $_POST['department'] ) ),
173 );
174 }
175
176 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
177 if ( isset($_POST['office_id']) && is_scalar( $_POST['office_id'] ) && $_POST['office_id'] != '' )
178 {
179 $meta_query[] = array(
180 'key' => '_office_id',
181 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
182 'value' => (int)$_POST['office_id']
183 );
184 }
185
186 // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Incomplete-property report must filter existing department, office and market metadata before inspecting all matching properties; the query retrieves IDs only.
187 $args['meta_query'] = $meta_query;
188
189 $property_query = new WP_Query( $args );
190
191 if ( $property_query->have_posts() )
192 {
193 echo '<table>
194 <tr>
195 <th style="text-align:left;">Property Address</th>
196 <th style="text-align:left;">Missing</th>
197 </tr>';
198 while ( $property_query->have_posts() )
199 {
200 $property_query->the_post();
201
202 $property = new PH_Property( get_the_ID() );
203
204 $missing = array();
205
206 if (
207 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
208 (isset($_POST['missing']) && $_POST['missing'] == '_photos') ||
209 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
210 (isset($_POST['missing']) && $_POST['missing'] == '') ||
211 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
212 !isset($_POST['missing'])
213 )
214 {
215 $photo = $property->get_main_photo_src();
216 if ( $photo === false )
217 {
218 $missing[] = 'Photos';
219 }
220 }
221
222 if (
223 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
224 (isset($_POST['missing']) && $_POST['missing'] == '_floorplans') ||
225 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
226 (isset($_POST['missing']) && $_POST['missing'] == '') ||
227 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
228 !isset($_POST['missing'])
229 )
230 {
231 if ( get_option('propertyhive_brochures_stored_as', '') == 'urls' )
232 {
233 $floorplans = $property->_floorplan_urls;
234 if (isset($floorplans) && is_array($floorplans) && !empty($floorplans) && isset($floorplans[0]) && isset($floorplans[0]['url']))
235 {
236
237 }
238 else
239 {
240 $missing[] = 'Floorplans';
241 }
242 }
243 else
244 {
245 $floorplans = $property->get_floorplan_attachment_ids();
246 if ( $floorplans === false || ( is_array($floorplans) && empty($floorplans) ) )
247 {
248 $missing[] = 'Floorplans';
249 }
250 }
251 }
252
253 if (
254 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
255 (isset($_POST['missing']) && $_POST['missing'] == '_epcs') ||
256 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
257 (isset($_POST['missing']) && $_POST['missing'] == '') ||
258 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
259 !isset($_POST['missing'])
260 )
261 {
262 if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
263 {
264 $epcs = $property->_epc_urls;
265 if (isset($epcs) && is_array($epcs) && !empty($epcs) && isset($epcs[0]) && isset($epcs[0]['url']))
266 {
267
268 }
269 else
270 {
271 $missing[] = 'EPCs';
272 }
273 }
274 else
275 {
276 $epcs = $property->get_epc_attachment_ids();
277 if ( $epcs === false || ( is_array($epcs) && empty($epcs) ) )
278 {
279 $missing[] = 'EPCs';
280 }
281 }
282 }
283
284 if (
285 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
286 (isset($_POST['missing']) && $_POST['missing'] == '_brochures') ||
287 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
288 (isset($_POST['missing']) && $_POST['missing'] == '') ||
289 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
290 !isset($_POST['missing'])
291 )
292 {
293 if ( get_option('propertyhive_brochures_stored_as', '') == 'urls' )
294 {
295 $brochures = $property->_brochure_urls;
296 if (isset($brochures) && is_array($brochures) && !empty($brochures) && isset($brochures[0]) && isset($brochures[0]['url']))
297 {
298
299 }
300 else
301 {
302 $missing[] = 'Brochures';
303 }
304 }
305 else
306 {
307 $brochures = $property->get_epc_attachment_ids();
308 if ( $brochures === false || ( is_array($brochures) && empty($brochures) ) )
309 {
310 $missing[] = 'Brochures';
311 }
312 }
313 }
314
315 if (
316 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
317 (isset($_POST['missing']) && $_POST['missing'] == '_virtual_tours') ||
318 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
319 (isset($_POST['missing']) && $_POST['missing'] == '') ||
320 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
321 !isset($_POST['missing'])
322 )
323 {
324 $virtual_tours = $property->get_virtual_tour_urls();
325 if ( $virtual_tours === false || ( is_array($virtual_tours) && empty($virtual_tours) ) )
326 {
327 $missing[] = 'Virtual Tours';
328 }
329 }
330
331 if (
332 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
333 (isset($_POST['missing']) && $_POST['missing'] == 'summary') ||
334 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
335 (isset($_POST['missing']) && $_POST['missing'] == '') ||
336 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
337 !isset($_POST['missing'])
338 )
339 {
340 $summary = $property->post_excerpt;
341 if ( $summary === false || $summary == '' )
342 {
343 $missing[] = 'Summary';
344 }
345 }
346
347 if (
348 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
349 (isset($_POST['missing']) && $_POST['missing'] == '_latitude') ||
350 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
351 (isset($_POST['missing']) && $_POST['missing'] == '') ||
352 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Read-only report filters and form display on the authorized CRM reports screen.
353 !isset($_POST['missing'])
354 )
355 {
356 $latitude = $property->latitude;
357 if ( $latitude === false || $latitude == '' )
358 {
359 $missing[] = 'Map Co-ordinates';
360 }
361 }
362
363 if ( !empty($missing) )
364 {
365 echo '<tr>';
366
367 echo '<td><a href="' . esc_url(get_edit_post_link( get_the_ID() )) . '">' . esc_html($property->get_formatted_full_address()) . '</a></td>';
368
369 echo '<td>' . esc_html(implode(", ", $missing)) . '</td>';
370
371 echo '</tr>';
372 }
373 }
374 echo '</table>';
375 }
376 wp_reset_postdata();
377 ?>
378
379 </div>
380
381 </div>
382
383 <?php
384 }
385
386 }
387