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