| 1 |
<?php |
| 2 |
/** |
| 3 |
* PropertyHive Admin Generate Applicant List Class. |
| 4 |
* |
| 5 |
* @author PropertyHive |
| 6 |
* @category Admin |
| 7 |
* @package PropertyHive/Admin |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 12 |
|
| 13 |
if ( ! class_exists( 'PH_Admin_Applicant_List' ) ) : |
| 14 |
|
| 15 |
/** |
| 16 |
* PH_Admin_Applicant_List |
| 17 |
*/ |
| 18 |
class PH_Admin_Applicant_List { |
| 19 |
|
| 20 |
/** |
| 21 |
* Handles the display of the main Property Hive reports page in admin. |
| 22 |
* |
| 23 |
* @access public |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public static function output() { |
| 27 |
|
| 28 |
$property_types = array(); |
| 29 |
$locations = array(); |
| 30 |
?> |
| 31 |
<div class="wrap propertyhive"> |
| 32 |
|
| 33 |
<h1>Generate Applicant List</h1> |
| 34 |
|
| 35 |
<form method="post" id="mainform" action="" enctype="multipart/form-data" class="applicant-list-form"> |
| 36 |
|
| 37 |
<input type="hidden" name="submitted" value="1"> |
| 38 |
|
| 39 |
<div id="poststuff" class="propertyhive_meta_box"> |
| 40 |
|
| 41 |
<p class="form-field"> |
| 42 |
<label>Looking For</label> |
| 43 |
<select name="department"> |
| 44 |
<?php |
| 45 |
|
| 46 |
$departments = ph_get_departments(); |
| 47 |
|
| 48 |
$department_options = array(); |
| 49 |
foreach ( $departments as $key => $value ) |
| 50 |
{ |
| 51 |
if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' ) |
| 52 |
{ |
| 53 |
$department_options[$key] = $value; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
foreach ( $department_options as $key => $department ) |
| 58 |
{ |
| 59 |
echo '<option value="' . $key . '"'; |
| 60 |
if ( isset($_POST['department']) && $_POST['department'] == $key ) |
| 61 |
{ |
| 62 |
echo ' selected'; |
| 63 |
} |
| 64 |
elseif ( !isset($_POST['department']) && $key == get_option( 'propertyhive_primary_department' ) ) |
| 65 |
{ |
| 66 |
echo ' selected'; |
| 67 |
} |
| 68 |
echo '>' . $department . '</option>'; |
| 69 |
} |
| 70 |
?> |
| 71 |
|
| 72 |
</select> |
| 73 |
</p> |
| 74 |
|
| 75 |
<p class="form-field sales-only"> |
| 76 |
<label>Price</label> |
| 77 |
<input type="text" name="maximum_price" value="<?php if ( isset($_POST['maximum_price']) ) { echo esc_attr( $_POST['maximum_price'] ); } ?>"> |
| 78 |
</p> |
| 79 |
|
| 80 |
<p class="form-field lettings-only"> |
| 81 |
<label>Rent (PCM)</label> |
| 82 |
<input type="text" name="maximum_rent" value="<?php if ( isset($_POST['maximum_rent']) ) { echo esc_attr( $_POST['maximum_rent'] ); } ?>"> |
| 83 |
</p> |
| 84 |
|
| 85 |
<p class="form-field residential-only"> |
| 86 |
<label>Bedrooms</label> |
| 87 |
<input type="number" name="minimum_bedrooms" class="short" value="<?php if ( isset($_POST['minimum_bedrooms']) ) { echo esc_attr( $_POST['minimum_bedrooms'] ); } ?>"> |
| 88 |
</p> |
| 89 |
|
| 90 |
<p class="form-field residential-only"> |
| 91 |
<label>Property Types</label> |
| 92 |
<select id="property_types" name="property_types[]" multiple="multiple" data-placeholder="Start typing to add property types..." class="multiselect attribute_values"> |
| 93 |
<?php |
| 94 |
$options = array( '' => '' ); |
| 95 |
$args = array( |
| 96 |
'hide_empty' => false, |
| 97 |
'parent' => 0 |
| 98 |
); |
| 99 |
$terms = get_terms( 'property_type', $args ); |
| 100 |
|
| 101 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 102 |
{ |
| 103 |
foreach ($terms as $term) |
| 104 |
{ |
| 105 |
$property_types[$term->term_id] = esc_html( $term->name ); |
| 106 |
|
| 107 |
echo '<option value="' . esc_attr( $term->term_id ) . '"'; |
| 108 |
if ( isset($_POST['property_types']) && in_array( $term->term_id, $_POST['property_types'] ) ) |
| 109 |
{ |
| 110 |
echo ' selected'; |
| 111 |
} |
| 112 |
echo '>' . esc_html( $term->name ) . '</option>'; |
| 113 |
|
| 114 |
$args = array( |
| 115 |
'hide_empty' => false, |
| 116 |
'parent' => $term->term_id |
| 117 |
); |
| 118 |
$subterms = get_terms( 'property_type', $args ); |
| 119 |
|
| 120 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 121 |
{ |
| 122 |
foreach ($subterms as $term) |
| 123 |
{ |
| 124 |
$property_types[$term->term_id] = esc_html( $term->name ); |
| 125 |
|
| 126 |
echo '<option value="' . esc_attr( $term->term_id ) . '"'; |
| 127 |
if ( isset($_POST['property_types']) && in_array( $term->term_id, $_POST['property_types'] ) ) |
| 128 |
{ |
| 129 |
echo ' selected'; |
| 130 |
} |
| 131 |
echo '>- ' . esc_html( $term->name ) . '</option>'; |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
} |
| 136 |
?> |
| 137 |
</select> |
| 138 |
</p> |
| 139 |
|
| 140 |
<p class="form-field"> |
| 141 |
<label>Location</label> |
| 142 |
<select id="locations" name="locations[]" multiple="multiple" data-placeholder="Start typing to add locations..." class="multiselect attribute_values"> |
| 143 |
<?php |
| 144 |
$options = array( '' => '' ); |
| 145 |
$args = array( |
| 146 |
'hide_empty' => false, |
| 147 |
'parent' => 0 |
| 148 |
); |
| 149 |
$terms = get_terms( 'location', $args ); |
| 150 |
|
| 151 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 152 |
{ |
| 153 |
foreach ($terms as $term) |
| 154 |
{ |
| 155 |
$locations[$term->term_id] = esc_html( $term->name ); |
| 156 |
|
| 157 |
echo '<option value="' . esc_attr( $term->term_id ) . '"'; |
| 158 |
if ( isset($_POST['locations']) && in_array( $term->term_id, $_POST['locations'] ) ) |
| 159 |
{ |
| 160 |
echo ' selected'; |
| 161 |
} |
| 162 |
echo '>' . esc_html( $term->name ) . '</option>'; |
| 163 |
|
| 164 |
$args = array( |
| 165 |
'hide_empty' => false, |
| 166 |
'parent' => $term->term_id |
| 167 |
); |
| 168 |
$subterms = get_terms( 'location', $args ); |
| 169 |
|
| 170 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 171 |
{ |
| 172 |
foreach ($subterms as $term) |
| 173 |
{ |
| 174 |
$locations[$term->term_id] = esc_html( $term->name ); |
| 175 |
|
| 176 |
echo '<option value="' . esc_attr( $term->term_id ) . '"'; |
| 177 |
if ( isset($_POST['locations']) && in_array( $term->term_id, $_POST['locations'] ) ) |
| 178 |
{ |
| 179 |
echo ' selected'; |
| 180 |
} |
| 181 |
echo '>- ' . esc_html( $term->name ) . '</option>'; |
| 182 |
|
| 183 |
$args = array( |
| 184 |
'hide_empty' => false, |
| 185 |
'parent' => $term->term_id |
| 186 |
); |
| 187 |
$subsubterms = get_terms( 'location', $args ); |
| 188 |
|
| 189 |
if ( !empty( $subsubterms ) && !is_wp_error( $subsubterms ) ) |
| 190 |
{ |
| 191 |
foreach ($subsubterms as $term) |
| 192 |
{ |
| 193 |
$locations[$term->term_id] = esc_html( $term->name ); |
| 194 |
|
| 195 |
echo '<option value="' . esc_attr( $term->term_id ) . '"'; |
| 196 |
if ( isset($_POST['locations']) && in_array( $term->term_id, $_POST['locations'] ) ) |
| 197 |
{ |
| 198 |
echo ' selected'; |
| 199 |
} |
| 200 |
echo '>- - ' . esc_html( $term->name ) . '</option>'; |
| 201 |
} |
| 202 |
} |
| 203 |
} |
| 204 |
} |
| 205 |
} |
| 206 |
} |
| 207 |
?> |
| 208 |
</select> |
| 209 |
</p> |
| 210 |
|
| 211 |
<p class="form-field"> |
| 212 |
<input type="submit" value="<?php echo __( 'Generate Applicant List', 'propertyhive' ); ?>" class="button-primary"> |
| 213 |
</p> |
| 214 |
|
| 215 |
</div> |
| 216 |
|
| 217 |
</form> |
| 218 |
|
| 219 |
<div class="applicant-list-results"> |
| 220 |
|
| 221 |
<?php |
| 222 |
if ( isset($_POST['submitted']) && $_POST['submitted'] == '1' ) |
| 223 |
{ |
| 224 |
$search_property_types = array(); |
| 225 |
if ( isset($_POST['department']) && ( $_POST['department'] == 'residential-sales' || $_POST['department'] == 'residential-lettings' ) ) |
| 226 |
{ |
| 227 |
if ( isset($_POST['property_types']) && is_array($_POST['property_types']) && !empty($_POST['property_types']) ) |
| 228 |
{ |
| 229 |
foreach ( $_POST['property_types'] as $property_type ) |
| 230 |
{ |
| 231 |
$search_property_types[] = (int)$property_type; |
| 232 |
|
| 233 |
$args = array( |
| 234 |
'hide_empty' => false, |
| 235 |
'parent' => $property_type |
| 236 |
); |
| 237 |
$terms = get_terms( 'property_type', $args ); |
| 238 |
|
| 239 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 240 |
{ |
| 241 |
foreach ($terms as $term) |
| 242 |
{ |
| 243 |
$search_property_types[] = $term->term_id; |
| 244 |
|
| 245 |
$args = array( |
| 246 |
'hide_empty' => false, |
| 247 |
'parent' => $term->term_id |
| 248 |
); |
| 249 |
$subterms = get_terms( 'property_type', $args ); |
| 250 |
|
| 251 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 252 |
{ |
| 253 |
foreach ($subterms as $term) |
| 254 |
{ |
| 255 |
$search_property_types[] = $term->term_id; |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
} |
| 260 |
} |
| 261 |
} |
| 262 |
$search_property_types = array_unique($search_property_types); |
| 263 |
} |
| 264 |
|
| 265 |
$search_locations = array(); |
| 266 |
if ( isset($_POST['locations']) && is_array($_POST['locations']) && !empty($_POST['locations']) ) |
| 267 |
{ |
| 268 |
foreach ( $_POST['locations'] as $location ) |
| 269 |
{ |
| 270 |
$search_locations[] = (int)$location; |
| 271 |
|
| 272 |
$args = array( |
| 273 |
'hide_empty' => false, |
| 274 |
'parent' => $location |
| 275 |
); |
| 276 |
$terms = get_terms( 'location', $args ); |
| 277 |
|
| 278 |
if ( !empty( $terms ) && !is_wp_error( $terms ) ) |
| 279 |
{ |
| 280 |
foreach ($terms as $term) |
| 281 |
{ |
| 282 |
$search_locations[] = $term->term_id; |
| 283 |
|
| 284 |
$args = array( |
| 285 |
'hide_empty' => false, |
| 286 |
'parent' => $term->term_id |
| 287 |
); |
| 288 |
$subterms = get_terms( 'location', $args ); |
| 289 |
|
| 290 |
if ( !empty( $subterms ) && !is_wp_error( $subterms ) ) |
| 291 |
{ |
| 292 |
foreach ($subterms as $term) |
| 293 |
{ |
| 294 |
$search_locations[] = $term->term_id; |
| 295 |
} |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
} |
| 300 |
} |
| 301 |
$search_locations = array_unique($search_locations); |
| 302 |
|
| 303 |
$args = array( |
| 304 |
'post_type' => 'contact', |
| 305 |
'nopaging' => true, |
| 306 |
); |
| 307 |
|
| 308 |
$args['meta_query'] = array(); |
| 309 |
|
| 310 |
$args['meta_query'][] = array( |
| 311 |
'key' => '_contact_types', |
| 312 |
'value' => 'applicant', |
| 313 |
'compare' => 'LIKE' |
| 314 |
); |
| 315 |
|
| 316 |
$applicant_query = new WP_Query($args); |
| 317 |
|
| 318 |
$results = array(); |
| 319 |
|
| 320 |
if ( $applicant_query->have_posts() ) |
| 321 |
{ |
| 322 |
while ( $applicant_query->have_posts() ) |
| 323 |
{ |
| 324 |
$applicant_query->the_post(); |
| 325 |
|
| 326 |
$num_applicant_profiles = get_post_meta( get_the_ID(), '_applicant_profiles', TRUE ); |
| 327 |
if ( $num_applicant_profiles == '' ) |
| 328 |
{ |
| 329 |
$num_applicant_profiles = 0; |
| 330 |
} |
| 331 |
|
| 332 |
for ( $i = 0; $i < $num_applicant_profiles; ++$i ) |
| 333 |
{ |
| 334 |
$profile = get_post_meta( get_the_ID(), '_applicant_profile_' . $i, TRUE ); |
| 335 |
|
| 336 |
$match = true; |
| 337 |
|
| 338 |
if ( !isset($profile['send_matching_properties']) || ( isset($profile['send_matching_properties']) && $profile['send_matching_properties'] != 'yes' ) ) |
| 339 |
{ |
| 340 |
$match = false; |
| 341 |
} |
| 342 |
|
| 343 |
if ( isset($_POST['department']) ) |
| 344 |
{ |
| 345 |
if ( isset($profile['department']) && $profile['department'] != ph_clean($_POST['department']) ) |
| 346 |
{ |
| 347 |
$match = false; |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
if ( isset($_POST['department']) && $_POST['department'] == 'residential-sales' ) |
| 352 |
{ |
| 353 |
if ( isset($_POST['maximum_price']) && ph_clean($_POST['maximum_price']) != '' ) |
| 354 |
{ |
| 355 |
$price = preg_replace("/[^0-9]/", '', ph_clean($_POST['maximum_price'])); |
| 356 |
|
| 357 |
if ( isset($profile['max_price_actual']) && $profile['max_price_actual'] != '' && $profile['max_price_actual'] != 0 && $profile['max_price_actual'] < $price ) |
| 358 |
{ |
| 359 |
$match = false; |
| 360 |
} |
| 361 |
} |
| 362 |
} |
| 363 |
if ( isset($_POST['department']) && $_POST['department'] == 'residential-lettings' ) |
| 364 |
{ |
| 365 |
if ( isset($_POST['maximum_rent']) && ph_clean($_POST['maximum_rent']) != '' ) |
| 366 |
{ |
| 367 |
$price = preg_replace("/[^0-9]/", '', ph_clean($_POST['maximum_rent'])); |
| 368 |
|
| 369 |
if ( isset($profile['max_rent_actual']) && $profile['max_rent_actual'] != '' && $profile['max_rent_actual'] != 0 && $profile['max_rent_actual'] < $price ) |
| 370 |
{ |
| 371 |
$match = false; |
| 372 |
} |
| 373 |
} |
| 374 |
} |
| 375 |
if ( isset($_POST['department']) && ( $_POST['department'] == 'residential-sales' || $_POST['department'] == 'residential-lettings' ) ) |
| 376 |
{ |
| 377 |
if ( isset($_POST['minimum_bedrooms']) && ph_clean($_POST['minimum_bedrooms']) != '' ) |
| 378 |
{ |
| 379 |
$beds = preg_replace("/[^0-9]/", '', ph_clean($_POST['minimum_bedrooms'])); |
| 380 |
|
| 381 |
if ( isset($profile['min_beds']) && $profile['min_beds'] != '' && $profile['min_beds'] != 0 && $profile['min_beds'] > $beds ) |
| 382 |
{ |
| 383 |
$match = false; |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
// Property Types |
| 388 |
if ( isset($_POST['property_types']) && is_array($_POST['property_types']) && !empty($_POST['property_types']) ) |
| 389 |
{ |
| 390 |
$found_type = false; |
| 391 |
foreach ( $search_property_types as $search_property_type ) |
| 392 |
{ |
| 393 |
if ( isset($profile['property_types']) && is_array($profile['property_types']) && in_array($search_property_type, $profile['property_types']) ) |
| 394 |
{ |
| 395 |
$found_type = true; |
| 396 |
} |
| 397 |
} |
| 398 |
|
| 399 |
if ( !$found_type ) |
| 400 |
{ |
| 401 |
$match = false; |
| 402 |
} |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
if ( isset($_POST['locations']) && is_array($_POST['locations']) && !empty($_POST['locations']) ) |
| 407 |
{ |
| 408 |
$found_type = false; |
| 409 |
foreach ( $search_locations as $search_location ) |
| 410 |
{ |
| 411 |
if ( isset($profile['locations']) && is_array($profile['locations']) && in_array($search_location, $profile['locations']) ) |
| 412 |
{ |
| 413 |
$found_type = true; |
| 414 |
} |
| 415 |
} |
| 416 |
|
| 417 |
if ( !$found_type ) |
| 418 |
{ |
| 419 |
$match = false; |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
if ( $match ) |
| 424 |
{ |
| 425 |
$contact_details = array(); |
| 426 |
if ( get_post_meta( get_the_ID(), '_telephone_number', TRUE ) != '' ) |
| 427 |
{ |
| 428 |
$contact_details[] = 'T: ' . get_post_meta( get_the_ID(), '_telephone_number', TRUE ); |
| 429 |
} |
| 430 |
if ( get_post_meta( get_the_ID(), '_email_address', TRUE ) != '' ) |
| 431 |
{ |
| 432 |
$contact_details[] = 'E: ' . get_post_meta( get_the_ID(), '_email_address', TRUE ); |
| 433 |
} |
| 434 |
$results[] = array( |
| 435 |
'name' => get_the_title(), |
| 436 |
'edit_link' => get_edit_post_link(get_the_ID()), |
| 437 |
'contact_details' => implode("<br>", $contact_details), |
| 438 |
'profile' => $profile |
| 439 |
); |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
} |
| 444 |
|
| 445 |
wp_reset_postdata(); |
| 446 |
?> |
| 447 |
<br> |
| 448 |
<div class="applicant-list-results"> |
| 449 |
<h3><?php echo number_format(count($results)); ?> Applicants Found Matching Your Criteria</h3> |
| 450 |
<table width="100%" cellpadding="8" cellspacing="0"> |
| 451 |
<thead> |
| 452 |
<tr> |
| 453 |
<th style="text-align:left;">Applicant Name</th> |
| 454 |
<th style="text-align:left;">Contact Details</th> |
| 455 |
<th style="text-align:left;">Requirements</th> |
| 456 |
</tr> |
| 457 |
</thead> |
| 458 |
<tbody> |
| 459 |
<?php |
| 460 |
if ( !empty($results) ) |
| 461 |
{ |
| 462 |
foreach ( $results as $result ) |
| 463 |
{ |
| 464 |
?> |
| 465 |
<tr> |
| 466 |
<td><a href="<?php echo $result['edit_link'] ?>" target="_blank"><?php echo $result['name']; ?></a></td> |
| 467 |
<td><?php echo ( ( $result['contact_details'] != '' ) ? $result['contact_details'] : '-' ); ?></td> |
| 468 |
<td><?php |
| 469 |
if ( isset($result['profile']['department']) ) |
| 470 |
{ |
| 471 |
switch ( $result['profile']['department'] ) |
| 472 |
{ |
| 473 |
case "residential-sales": |
| 474 |
{ |
| 475 |
$output = array(); |
| 476 |
if ( isset($result['profile']['max_price']) && $result['profile']['max_price'] != '' && $result['profile']['max_price'] != 0 ) |
| 477 |
{ |
| 478 |
$output[] = '<strong>Max Price:</strong> £' . number_format($result['profile']['max_price']); |
| 479 |
} |
| 480 |
if ( isset($result['profile']['min_beds']) && $result['profile']['min_beds'] != '' && $result['profile']['min_beds'] != 0 ) |
| 481 |
{ |
| 482 |
$output[] = '<strong>Min Beds:</strong> ' . number_format($result['profile']['min_beds']); |
| 483 |
} |
| 484 |
if ( isset($result['profile']['property_types']) && is_array($result['profile']['property_types']) && !empty($result['profile']['property_types']) ) |
| 485 |
{ |
| 486 |
$output_types = array(); |
| 487 |
foreach ( $result['profile']['property_types'] as $profile_type ) |
| 488 |
{ |
| 489 |
$output_types[] = $property_types[$profile_type]; |
| 490 |
} |
| 491 |
$output[] = '<strong>Property Types:</strong> ' . implode(", ", $output_types); |
| 492 |
} |
| 493 |
if ( isset($result['profile']['locations']) && is_array($result['profile']['locations']) && !empty($result['profile']['locations']) ) |
| 494 |
{ |
| 495 |
$output_locations = array(); |
| 496 |
foreach ( $result['profile']['locations'] as $profile_location ) |
| 497 |
{ |
| 498 |
$output_locations[] = $locations[$profile_location]; |
| 499 |
} |
| 500 |
$output[] = '<strong>Locations:</strong> ' . implode(", ", $output_locations); |
| 501 |
} |
| 502 |
if ( isset($result['profile']['notes']) && $result['profile']['notes'] != '' ) |
| 503 |
{ |
| 504 |
$output[] = '<strong>Additional Requirements:</strong> ' . nl2br($result['profile']['notes']); |
| 505 |
} |
| 506 |
echo( !empty($output) ? implode("<br>", $output) : '-' ); |
| 507 |
break; |
| 508 |
} |
| 509 |
case "residential-lettings": |
| 510 |
{ |
| 511 |
$output = array(); |
| 512 |
if ( isset($result['profile']['max_rent']) && $result['profile']['max_rent'] != '' && $result['profile']['max_rent'] != 0 ) |
| 513 |
{ |
| 514 |
$output[] = '<strong>Max Rent:</strong> £' . number_format($result['profile']['max_rent']) . $result['profile']['rent_frequency']; |
| 515 |
} |
| 516 |
if ( isset($result['profile']['min_beds']) && $result['profile']['min_beds'] != '' && $result['profile']['min_beds'] != 0 ) |
| 517 |
{ |
| 518 |
$output[] = '<strong>Min Beds:</strong> ' . number_format($result['profile']['min_beds']); |
| 519 |
} |
| 520 |
if ( isset($result['profile']['property_types']) && is_array($result['profile']['property_types']) && !empty($result['profile']['property_types']) ) |
| 521 |
{ |
| 522 |
$output_types = array(); |
| 523 |
foreach ( $result['profile']['property_types'] as $profile_type ) |
| 524 |
{ |
| 525 |
$output_types[] = $property_types[$profile_type]; |
| 526 |
} |
| 527 |
$output[] = '<strong>Property Types:</strong> ' . implode(", ", $output_types); |
| 528 |
} |
| 529 |
if ( isset($result['profile']['locations']) && is_array($result['profile']['locations']) && !empty($result['profile']['locations']) ) |
| 530 |
{ |
| 531 |
$output_locations = array(); |
| 532 |
foreach ( $result['profile']['locations'] as $profile_location ) |
| 533 |
{ |
| 534 |
$output_locations[] = $locations[$profile_location]; |
| 535 |
} |
| 536 |
$output[] = '<strong>Locations:</strong> ' . implode(", ", $output_locations); |
| 537 |
} |
| 538 |
if ( isset($result['profile']['notes']) && $result['profile']['notes'] != '' ) |
| 539 |
{ |
| 540 |
$output[] = '<strong>Additional Requirements:</strong> ' . nl2br($result['profile']['notes']); |
| 541 |
} |
| 542 |
echo( !empty($output) ? implode("<br>", $output) : '-' ); |
| 543 |
break; |
| 544 |
} |
| 545 |
case "commercial": |
| 546 |
{ |
| 547 |
$output = array(); |
| 548 |
/*if ( isset($result['profile']['max_price']) && $result['profile']['max_price'] != '' && $result['profile']['max_price'] != 0 ) |
| 549 |
{ |
| 550 |
$output[] = '<strong>Max Price:</strong> £' . number_format($result['profile']['max_price']); |
| 551 |
} |
| 552 |
if ( isset($result['profile']['min_beds']) && $result['profile']['min_beds'] != '' && $result['profile']['min_beds'] != 0 ) |
| 553 |
{ |
| 554 |
$output[] = '<strong>Min Beds:</strong> ' . number_format($result['profile']['min_beds']); |
| 555 |
} |
| 556 |
if ( isset($result['profile']['property_types']) && is_array($result['profile']['property_types']) && !empty($result['profile']['property_types']) ) |
| 557 |
{ |
| 558 |
$output_types = array(); |
| 559 |
foreach ( $result['profile']['property_types'] as $profile_type ) |
| 560 |
{ |
| 561 |
$output_types[] = $property_types[$profile_type]; |
| 562 |
} |
| 563 |
$output[] = '<strong>Property Types:</strong> ' . implode(", ", $output_types); |
| 564 |
}*/ |
| 565 |
if ( isset($result['profile']['locations']) && is_array($result['profile']['locations']) && !empty($result['profile']['locations']) ) |
| 566 |
{ |
| 567 |
$output_locations = array(); |
| 568 |
foreach ( $result['profile']['locations'] as $profile_location ) |
| 569 |
{ |
| 570 |
$output_locations[] = $locations[$profile_location]; |
| 571 |
} |
| 572 |
$output[] = '<strong>Locations:</strong> ' . implode(", ", $output_locations); |
| 573 |
} |
| 574 |
if ( isset($result['profile']['notes']) && $result['profile']['notes'] != '' ) |
| 575 |
{ |
| 576 |
$output[] = '<strong>Additional Requirements:</strong> ' . nl2br($result['profile']['notes']); |
| 577 |
} |
| 578 |
echo( !empty($output) ? implode("<br>", $output) : '-' ); |
| 579 |
break; |
| 580 |
} |
| 581 |
} |
| 582 |
} |
| 583 |
?></td> |
| 584 |
</tr> |
| 585 |
<?php |
| 586 |
} |
| 587 |
} |
| 588 |
else |
| 589 |
{ |
| 590 |
?> |
| 591 |
<tr> |
| 592 |
<td colspan="3" style="text-align:center"><?php echo __( 'No matching applicants found', 'propertyhive' ); ?></td> |
| 593 |
</tr> |
| 594 |
<?php |
| 595 |
} |
| 596 |
?> |
| 597 |
</tbody> |
| 598 |
</table> |
| 599 |
</div> |
| 600 |
<?php |
| 601 |
} |
| 602 |
?> |
| 603 |
|
| 604 |
</div> |
| 605 |
|
| 606 |
</div> |
| 607 |
<script> |
| 608 |
|
| 609 |
function toggleDepartmentFields() |
| 610 |
{ |
| 611 |
if (jQuery('#mainform').length > 0) |
| 612 |
{ |
| 613 |
// There may be multiple forms on the page so treat each one individually |
| 614 |
jQuery('#mainform').each(function() |
| 615 |
{ |
| 616 |
var selectedDepartment = "residential-sales"; // TODO: Use default from settings |
| 617 |
|
| 618 |
var selected = jQuery(this).find('[name=\'department\']'); |
| 619 |
|
| 620 |
jQuery(this).find('.sales-only').hide(); |
| 621 |
jQuery(this).find('.lettings-only').hide(); |
| 622 |
jQuery(this).find('.residential-only').hide(); |
| 623 |
jQuery(this).find('.commercial-only').hide(); |
| 624 |
|
| 625 |
if (selected.length > 0) |
| 626 |
{ |
| 627 |
selectedDepartment = selected.val(); |
| 628 |
|
| 629 |
// controls won't always be display:block so we should get the |
| 630 |
// first visible component (that isnt sales/lettings-only) and |
| 631 |
// use that display |
| 632 |
var display = 'block'; |
| 633 |
|
| 634 |
if (selectedDepartment == 'residential-sales') |
| 635 |
{ |
| 636 |
jQuery(this).find('.sales-only').css('display', display); |
| 637 |
jQuery(this).find('.residential-only').css('display', display); |
| 638 |
} |
| 639 |
else if (selectedDepartment == 'residential-lettings') |
| 640 |
{ |
| 641 |
jQuery(this).find('.lettings-only').css('display', display); |
| 642 |
jQuery(this).find('.residential-only').css('display', display); |
| 643 |
} |
| 644 |
else if (selectedDepartment == 'commercial') |
| 645 |
{ |
| 646 |
jQuery(this).find('.commercial-only').css('display', display); |
| 647 |
} |
| 648 |
} |
| 649 |
}); |
| 650 |
} |
| 651 |
} |
| 652 |
|
| 653 |
jQuery( function(jQuery) { |
| 654 |
|
| 655 |
// Multiselect |
| 656 |
jQuery("#mainform select.multiselect").chosen(); |
| 657 |
|
| 658 |
toggleDepartmentFields(); |
| 659 |
|
| 660 |
jQuery('#mainform [name=\'department\']').change(function() |
| 661 |
{ |
| 662 |
toggleDepartmentFields(); |
| 663 |
}); |
| 664 |
|
| 665 |
}); |
| 666 |
|
| 667 |
jQuery(window).resize(function() { |
| 668 |
toggleDepartmentFields(); |
| 669 |
}); |
| 670 |
|
| 671 |
</script> |
| 672 |
<?php |
| 673 |
} |
| 674 |
|
| 675 |
} |
| 676 |
|
| 677 |
endif; |