| 1 |
<div class="wrap propertyhive"> |
| 2 |
|
| 3 |
<h1>Matching Properties For <?php echo get_the_title($contact_id); ?> (<?php echo count($properties); ?>)</h1> |
| 4 |
|
| 5 |
<form method="post" id="mainform" action="" enctype="multipart/form-data"> |
| 6 |
|
| 7 |
<div id="poststuff"> |
| 8 |
|
| 9 |
<?php |
| 10 |
$percentage_lower = get_option( 'propertyhive_applicant_match_price_range_percentage_lower', '' ); |
| 11 |
$percentage_higher = get_option( 'propertyhive_applicant_match_price_range_percentage_higher', '' ); |
| 12 |
|
| 13 |
echo '<div style="background:#F3F3F3; border:1px solid #DDD; padding:20px;"> |
| 14 |
|
| 15 |
<h3 style="padding-top:0; margin-top:0;">Applicant Requirements</h3>'; |
| 16 |
if ( |
| 17 |
isset($applicant_profile['department']) && $applicant_profile['department'] == 'residential-sales' && |
| 18 |
isset($applicant_profile['max_price_actual']) && $applicant_profile['max_price_actual'] != '' && $applicant_profile['max_price_actual'] != 0 |
| 19 |
) |
| 20 |
{ |
| 21 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 22 |
<strong>Maximum Price:</strong><br> |
| 23 |
£' . number_format($applicant_profile['max_price']) . ' |
| 24 |
</div>'; |
| 25 |
} |
| 26 |
if ( |
| 27 |
isset($applicant_profile['department']) && $applicant_profile['department'] == 'residential-sales' |
| 28 |
) |
| 29 |
{ |
| 30 |
if ( $percentage_lower != '' && $percentage_higher != '' ) |
| 31 |
{ |
| 32 |
$match_price_range_lower = ''; |
| 33 |
if ( !isset($applicant_profile['match_price_range_lower_actual']) || ( isset($applicant_profile['match_price_range_lower_actual']) && $applicant_profile['match_price_range_lower_actual'] == '' ) ) |
| 34 |
{ |
| 35 |
if ( isset($applicant_profile['max_price_actual']) && $applicant_profile['max_price_actual'] != '' ) |
| 36 |
{ |
| 37 |
$match_price_range_lower = $applicant_profile['max_price_actual'] - ( $applicant_profile['max_price_actual'] * ( $percentage_lower / 100 ) ); |
| 38 |
} |
| 39 |
} |
| 40 |
else |
| 41 |
{ |
| 42 |
$match_price_range_lower = $applicant_profile['match_price_range_lower_actual']; |
| 43 |
} |
| 44 |
|
| 45 |
$match_price_range_higher = ''; |
| 46 |
if ( !isset($applicant_profile['match_price_range_higher_actual']) || ( isset($applicant_profile['match_price_range_higher_actual']) && $applicant_profile['match_price_range_higher_actual'] == '' ) ) |
| 47 |
{ |
| 48 |
if ( isset($applicant_profile['max_price_actual']) && $applicant_profile['max_price_actual'] != '' ) |
| 49 |
{ |
| 50 |
$match_price_range_higher = $applicant_profile['max_price_actual'] + ( $applicant_profile['max_price_actual'] * ( $percentage_higher / 100 ) ); |
| 51 |
} |
| 52 |
} |
| 53 |
else |
| 54 |
{ |
| 55 |
$match_price_range_higher = $applicant_profile['match_price_range_higher_actual']; |
| 56 |
} |
| 57 |
|
| 58 |
if ( |
| 59 |
$match_price_range_lower != '' && $match_price_range_higher != '' |
| 60 |
) |
| 61 |
{ |
| 62 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 63 |
<strong>Match Price Range:</strong><br> |
| 64 |
£' . number_format($match_price_range_lower) . ' to £' . number_format($match_price_range_higher) . ' |
| 65 |
</div>'; |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
if ( |
| 70 |
isset($applicant_profile['department']) && $applicant_profile['department'] == 'residential-lettings' && |
| 71 |
isset($applicant_profile['max_price_actual']) && $applicant_profile['max_price_actual'] != '' && $applicant_profile['max_price_actual'] != 0 |
| 72 |
) |
| 73 |
{ |
| 74 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 75 |
<strong>Maximum Rent:</strong><br> |
| 76 |
£' . number_format($applicant_profile['max_rent']) . ' ' . $applicant_profile['rent_frequency'] . ' |
| 77 |
</div>'; |
| 78 |
} |
| 79 |
if ( |
| 80 |
isset($applicant_profile['department']) && |
| 81 |
( $applicant_profile['department'] == 'residential-sales' || $applicant_profile['department'] == 'residential-lettings' ) |
| 82 |
) |
| 83 |
{ |
| 84 |
if ( isset($applicant_profile['min_beds']) && $applicant_profile['min_beds'] != '' && $applicant_profile['min_beds'] != 0 ) |
| 85 |
{ |
| 86 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 87 |
<strong>Minimum Beds:</strong><br> |
| 88 |
' . $applicant_profile['min_beds'] . ' |
| 89 |
</div>'; |
| 90 |
} |
| 91 |
if ( isset($applicant_profile['property_types']) && is_array($applicant_profile['property_types']) && !empty($applicant_profile['property_types']) ) |
| 92 |
{ |
| 93 |
$terms = get_terms('property_type', array('hide_empty' => false, 'fields' => 'names', 'include' => $applicant_profile['property_types'])); |
| 94 |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) |
| 95 |
{ |
| 96 |
$sliced_terms = array_slice( $terms, 0, 2 ); |
| 97 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 98 |
<strong>Property Types:</strong><br> |
| 99 |
' . implode(", ", $sliced_terms) . ( (count($terms) > 2) ? '<span title="' . addslashes( implode(", ", $terms) ) .'"> + ' . (count($terms) - 2) . ' more</span>' : '' ) . ' |
| 100 |
</div>'; |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
if ( |
| 105 |
isset($applicant_profile['department']) && |
| 106 |
( $applicant_profile['department'] == 'commercial' ) |
| 107 |
) |
| 108 |
{ |
| 109 |
if ( isset($applicant_profile['available_as']) && is_array($applicant_profile['available_as']) && !empty($applicant_profile['available_as']) ) |
| 110 |
{ |
| 111 |
$available_as = array(); |
| 112 |
if ( in_array('sale', $applicant_profile['available_as']) ) |
| 113 |
{ |
| 114 |
$available_as[] = 'For Sale'; |
| 115 |
} |
| 116 |
if ( in_array('rent', $applicant_profile['available_as']) ) |
| 117 |
{ |
| 118 |
$available_as[] = 'To Rent'; |
| 119 |
} |
| 120 |
|
| 121 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 122 |
<strong>Available As:</strong><br> |
| 123 |
' . implode(", ", $available_as) .' |
| 124 |
</div>'; |
| 125 |
} |
| 126 |
|
| 127 |
if ( |
| 128 |
(isset($applicant_profile['min_floor_area_actual']) && $applicant_profile['min_floor_area_actual'] != '') |
| 129 |
|| |
| 130 |
(isset($applicant_profile['max_floor_area_actual']) && $applicant_profile['max_floor_area_actual'] != '') |
| 131 |
) |
| 132 |
{ |
| 133 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 134 |
<strong>Floor Area:</strong><br>'; |
| 135 |
$sizes = array('min' => '', 'max'); |
| 136 |
if ( isset($applicant_profile['min_floor_area_actual']) && $applicant_profile['min_floor_area_actual'] != '' ) |
| 137 |
{ |
| 138 |
$sizes['min'] = $applicant_profile['min_floor_area_actual']; |
| 139 |
} |
| 140 |
if ( isset($applicant_profile['max_floor_area_actual']) && $applicant_profile['max_floor_area_actual'] != '' ) |
| 141 |
{ |
| 142 |
$sizes['max'] = $applicant_profile['max_floor_area_actual']; |
| 143 |
} |
| 144 |
if ( $sizes['min'] != '' && $sizes['max'] != '' ) |
| 145 |
{ |
| 146 |
echo number_format($sizes['min']) . ' - ' . number_format($sizes['max']) . ' Sq Ft'; |
| 147 |
} |
| 148 |
if ( $sizes['min'] != '' && $sizes['max'] == '' ) |
| 149 |
{ |
| 150 |
echo 'From ' . number_format($sizes['min']) . ' Sq Ft'; |
| 151 |
} |
| 152 |
if ( $sizes['min'] == '' && $sizes['max'] != '' ) |
| 153 |
{ |
| 154 |
echo 'Up To ' . number_format($sizes['max']) . ' Sq Ft'; |
| 155 |
} |
| 156 |
echo '</div>'; |
| 157 |
} |
| 158 |
|
| 159 |
if ( isset($applicant_profile['commercial_property_types']) && is_array($applicant_profile['commercial_property_types']) && !empty($applicant_profile['commercial_property_types']) ) |
| 160 |
{ |
| 161 |
$terms = get_terms('commercial_property_type', array('hide_empty' => false, 'fields' => 'names', 'include' => $applicant_profile['commercial_property_types'])); |
| 162 |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) |
| 163 |
{ |
| 164 |
$sliced_terms = array_slice( $terms, 0, 2 ); |
| 165 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 166 |
<strong>Property Types:</strong><br> |
| 167 |
' . implode(", ", $sliced_terms) . ( (count($terms) > 2) ? '<span title="' . addslashes( implode(", ", $terms) ) .'"> + ' . (count($terms) - 2) . ' more</span>' : '' ) . ' |
| 168 |
</div>'; |
| 169 |
} |
| 170 |
} |
| 171 |
} |
| 172 |
if ( isset($applicant_profile['locations']) && is_array($applicant_profile['locations']) && !empty($applicant_profile['locations']) ) |
| 173 |
{ |
| 174 |
$terms = get_terms('location', array('hide_empty' => false, 'fields' => 'names', 'include' => $applicant_profile['locations'])); |
| 175 |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) |
| 176 |
{ |
| 177 |
$sliced_terms = array_slice( $terms, 0, 2 ); |
| 178 |
echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top"> |
| 179 |
<strong>Locations:</strong><br> |
| 180 |
' . implode(", ", $sliced_terms) . ( (count($terms) > 2) ? ' <span title="' . addslashes( implode(", ", $terms) ) .'">+ ' . (count($terms) - 2) . ' more</span>' : '' ) . ' |
| 181 |
</div>'; |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
if ( isset($applicant_profile['notes']) && $applicant_profile['notes'] != '' ) |
| 186 |
{ |
| 187 |
echo '<div style="display:inline-block; width:100%; vertical-align:top; margin-top:15px;"> |
| 188 |
<strong>Additional Requirement Notes:</strong><br> |
| 189 |
' . nl2br( strip_tags( $applicant_profile['notes'] ) ) . ' |
| 190 |
</div>'; |
| 191 |
} |
| 192 |
|
| 193 |
echo '</div>'; |
| 194 |
?> |
| 195 |
|
| 196 |
<?php |
| 197 |
if ( !empty($properties) ) |
| 198 |
{ |
| 199 |
foreach ( $properties as $property ) |
| 200 |
{ |
| 201 |
$previously_sent = array(); |
| 202 |
if ( isset($applicant_profile_match_history[$property->id]) && is_array($applicant_profile_match_history[$property->id]) && !empty($applicant_profile_match_history[$property->id]) ) |
| 203 |
{ |
| 204 |
$previously_sent = $applicant_profile_match_history[$property->id]; |
| 205 |
} |
| 206 |
|
| 207 |
$on_market_change_date = $property->_on_market_change_date; |
| 208 |
$price_change_date = $property->_price_change_date; |
| 209 |
|
| 210 |
echo '<div id="matching_applicant_' . $contact_id . '_property_' . $property->id . '" style="padding:20px 0; border-bottom:1px solid #CCC;">'; |
| 211 |
|
| 212 |
echo '<div style="float:left; width:18%;">'; |
| 213 |
|
| 214 |
$image_url = $property->get_main_photo_src(); |
| 215 |
if ( $image_url !== FALSE ) |
| 216 |
{ |
| 217 |
echo '<a href="' . get_edit_post_link( $property->id ) . '" target="_blank"><img src="' . $image_url . '" style="max-width:100%; margin:0 auto; display:block;" alt="' . addslashes($property->get_formatted_summary_address()) . '"></a>'; |
| 218 |
} |
| 219 |
|
| 220 |
echo '</div>'; |
| 221 |
|
| 222 |
echo '<div style="float:right; width:80%;">'; |
| 223 |
|
| 224 |
echo '<h3 style="margin:0; padding:0; margin-bottom:9px;"><a href="' . get_edit_post_link( $property->id ) . '" target="_blank">' . $property->get_formatted_summary_address() . '</a></h3>'; |
| 225 |
|
| 226 |
echo '<div style="margin-bottom:7px; font-size:15px;"> |
| 227 |
<strong>' . ( ($property->_department == 'residential-lettings') ? __('Rent', 'propertyhive') : __('Price', 'propertyhive') ) . ': ' . $property->price_qualifier . ' ' . $property->get_formatted_price() . '</strong> |
| 228 |
| '; |
| 229 |
if ($property->department != 'commercial') |
| 230 |
{ |
| 231 |
echo $property->bedrooms . ' bed | '; |
| 232 |
} |
| 233 |
else |
| 234 |
{ |
| 235 |
$floor_area = $property->get_formatted_floor_area(); |
| 236 |
if ( $floor_area != '' ) |
| 237 |
{ |
| 238 |
echo $floor_area . ' | '; |
| 239 |
} |
| 240 |
} |
| 241 |
$property_type = $property->get_property_type(); |
| 242 |
if ( $property_type != '' ) |
| 243 |
{ |
| 244 |
echo $property_type . ' | '; |
| 245 |
} |
| 246 |
echo ' ' . $property->get_availability() . ' |
| 247 |
</div>'; |
| 248 |
|
| 249 |
echo '<div style="margin-bottom:7px;">' . strip_tags(get_the_excerpt($property->id)) . '</div>'; |
| 250 |
|
| 251 |
echo '<div style="background:#F8F8F8; padding:12px 11px; line-height:1.7em; border:1px solid #DDD; font-weight:700"> |
| 252 |
|
| 253 |
<label><input type="checkbox" name="email_property_id[]" value="' . $property->id . '" '; |
| 254 |
|
| 255 |
$post_tip = ''; |
| 256 |
if ( strpos($email_address, '@') === FALSE ) |
| 257 |
{ |
| 258 |
echo ' disabled title="Invalid email address: ' . $email_address . '"'; |
| 259 |
$post_tip = 'Invalid email address: ' . $email_address; |
| 260 |
} |
| 261 |
elseif ( $do_not_email ) |
| 262 |
{ |
| 263 |
echo ' disabled title="Contact via email not permitted - Set under contact details"'; |
| 264 |
$post_tip = 'Contact via email not permitted - Set under contact details'; |
| 265 |
} |
| 266 |
else |
| 267 |
{ |
| 268 |
if ( !empty($previously_sent) ) |
| 269 |
{ |
| 270 |
$post_tip = 'Sent previously via ' . $previously_sent[count($previously_sent) - 1]['method'] . ' on ' . date("jS F Y", strtotime($previously_sent[count($previously_sent) - 1]['date'])); |
| 271 |
|
| 272 |
if ( |
| 273 |
$on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] || |
| 274 |
$price_change_date > $previously_sent[count($previously_sent) - 1]['date'] |
| 275 |
) |
| 276 |
{ |
| 277 |
if ( $price_change_date > $previously_sent[count($previously_sent) - 1]['date'] ) |
| 278 |
{ |
| 279 |
$post_tip .= ', however a price change occurred on ' . date("jS F Y", strtotime($price_change_date)); |
| 280 |
} |
| 281 |
elseif ( $on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] ) |
| 282 |
{ |
| 283 |
$post_tip .= ', however a change to the on market status occurred on ' . date("jS F Y", strtotime($on_market_change_date)); |
| 284 |
} |
| 285 |
echo ' checked'; |
| 286 |
} |
| 287 |
} |
| 288 |
else |
| 289 |
{ |
| 290 |
echo ' checked'; |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
echo '> Email Property To Applicant<span style="font-weight:400;">' . ( ($post_tip != '') ? ' - ' . $post_tip : '' ) . '</span></label> |
| 295 |
|
| 296 |
<br>'; |
| 297 |
|
| 298 |
do_action( 'propertyhive_applicant_match_send_methods', $contact_id, $applicant_profile_id, $property->id ); |
| 299 |
|
| 300 |
echo '<label><input type="checkbox" name="not_interested_property_id[]" value="' . $property->id . '"> Property Not Suitable</label> |
| 301 |
|
| 302 |
</div>'; |
| 303 |
|
| 304 |
echo '</div>'; |
| 305 |
|
| 306 |
echo '<div style="clear:both"></div>'; |
| 307 |
|
| 308 |
echo '</div>'; |
| 309 |
} |
| 310 |
} |
| 311 |
?> |
| 312 |
|
| 313 |
<p class="submit"> |
| 314 |
|
| 315 |
<input name="save" class="button-primary" type="submit" value="<?php echo __( 'Continue', 'propertyhive' ); ?>" /> |
| 316 |
|
| 317 |
<a href="<?php echo get_edit_post_link((int)$_GET['contact_id']); ?>" class="button"><?php _e( 'Cancel', 'propertyhive' ); ?></a> |
| 318 |
|
| 319 |
<input type="hidden" name="step" value="one" /> |
| 320 |
<?php wp_nonce_field( 'propertyhive-matching-properties' ); ?> |
| 321 |
|
| 322 |
</p> |
| 323 |
|
| 324 |
<p> |
| 325 |
<?php echo __( "If you've opted to email any of the properties you'll have the ability to edit the contents of the email in the next step.", 'propertyhive' ); ?> |
| 326 |
</p> |
| 327 |
|
| 328 |
</div> |
| 329 |
|
| 330 |
</form> |
| 331 |
|
| 332 |
</div> |
| 333 |
|
| 334 |
<script> |
| 335 |
|
| 336 |
jQuery('body').on('change', 'input[name=\'not_interested_property_id[]\']', function() |
| 337 |
{ |
| 338 |
var property_id = jQuery(this).val(); |
| 339 |
|
| 340 |
jQuery('input[name=\'email_property_id[]\'][value=\'' + property_id + '\']').attr('checked', false); |
| 341 |
|
| 342 |
opacity = 0.4; |
| 343 |
if ( !jQuery(this).is(':checked') ) |
| 344 |
{ |
| 345 |
opacity = 1; |
| 346 |
} |
| 347 |
jQuery('#matching_applicant_<?php echo $contact_id; ?>_property_' + property_id).animate({ |
| 348 |
opacity: opacity |
| 349 |
}, |
| 350 |
{ |
| 351 |
duration: 250 |
| 352 |
}); |
| 353 |
|
| 354 |
return false; |
| 355 |
}); |
| 356 |
|
| 357 |
</script> |