PluginProbe
Property Hive / 2.2.6
Property Hive v2.2.6
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 / views / html-admin-matching-properties.php

html-admin-matching-properties.php in Property Hive 2.2.6, at includes/admin/views/html-admin-matching-properties.php

471 lines 23.0 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
7 <div class="wrap propertyhive">
8
9 <h1>Matching Properties For <?php echo esc_html(get_the_title($contact_id)); ?> (<?php echo count($properties); ?>)</h1>
10
11 <form method="post" id="mainform" action="" enctype="multipart/form-data">
12
13 <div id="poststuff">
14
15 <?php
16 $percentage_lower = get_option( 'propertyhive_applicant_match_price_range_percentage_lower', '' );
17 $percentage_higher = get_option( 'propertyhive_applicant_match_price_range_percentage_higher', '' );
18
19 $currency = '&pound;';
20 if ( isset($applicant_profile['currency']) && !empty($applicant_profile['currency']) )
21 {
22 $PH_Countries = new PH_Countries();
23 $selected_currency = $PH_Countries->get_currency($applicant_profile['currency']);
24 if ( $selected_currency !== false )
25 {
26 $currency = $selected_currency['currency_symbol'];
27 }
28 }
29
30 echo '<div style="background:#F3F3F3; border:1px solid #DDD; padding:20px;">
31
32 <h3 style="padding-top:0; margin-top:0;">' . esc_html( __('Applicant Requirements', 'propertyhive') ) . '</h3>';
33
34 $requirements = array();
35
36 if (
37 isset($applicant_profile['department']) &&
38 ( $applicant_profile['department'] == 'residential-sales' || ph_get_custom_department_based_on($applicant_profile['department']) == 'residential-sales' ) &&
39 isset($applicant_profile['max_price_actual']) &&
40 $applicant_profile['max_price_actual'] != '' &&
41 $applicant_profile['max_price_actual'] != 0
42 )
43 {
44 $requirements[] = array(
45 'label' => __( 'Maximum Price', 'propertyhive' ),
46 'value' => $currency . ph_display_price_field($applicant_profile['max_price']),
47 );
48 }
49 if (
50 isset($applicant_profile['department']) &&
51 ( $applicant_profile['department'] == 'residential-sales' || ph_get_custom_department_based_on($applicant_profile['department']) == 'residential-sales'
52 )
53 )
54 {
55 if ( $percentage_lower != '' && $percentage_higher != '' )
56 {
57 $match_price_range_lower = '';
58 $match_price_range_lower_display = '';
59 if (
60 !isset($applicant_profile['match_price_range_lower_actual']) ||
61 ( isset($applicant_profile['match_price_range_lower_actual']) && $applicant_profile['match_price_range_lower_actual'] == '' )
62 )
63 {
64 if ( isset($applicant_profile['max_price']) && $applicant_profile['max_price'] != '' )
65 {
66 $match_price_range_lower = $applicant_profile['max_price'] - ( $applicant_profile['max_price'] * ( $percentage_lower / 100 ) );
67 }
68 }
69 else
70 {
71 $match_price_range_lower = $applicant_profile['match_price_range_lower'];
72 }
73
74 $match_price_range_higher = '';
75 if (
76 !isset($applicant_profile['match_price_range_higher_actual']) ||
77 ( isset($applicant_profile['match_price_range_higher_actual']) && $applicant_profile['match_price_range_higher_actual'] == '' )
78 )
79 {
80 if ( isset($applicant_profile['max_price']) && $applicant_profile['max_price'] != '' )
81 {
82 $match_price_range_higher = $applicant_profile['max_price'] + ( $applicant_profile['max_price'] * ( $percentage_higher / 100 ) );
83 }
84 }
85 else
86 {
87 $match_price_range_higher = $applicant_profile['match_price_range_higher'];
88 }
89
90 if (
91 $match_price_range_lower != '' && $match_price_range_higher != ''
92 )
93 {
94 $requirements[] = array(
95 'label' => __( 'Match Price Range', 'propertyhive' ),
96 'value' => $currency . ph_display_price_field($match_price_range_lower) . ' to ' . $currency . ph_display_price_field($match_price_range_higher),
97 );
98 }
99 }
100 }
101 if (
102 isset($applicant_profile['department']) && ( $applicant_profile['department'] == 'residential-lettings' || ph_get_custom_department_based_on($applicant_profile['department']) == 'residential-lettings' ) &&
103 isset($applicant_profile['max_price_actual']) && $applicant_profile['max_price_actual'] != '' && $applicant_profile['max_price_actual'] != 0
104 )
105 {
106 $requirements[] = array(
107 'label' => __( 'Maximum Rent', 'propertyhive' ),
108 'value' => $currency . ph_display_price_field($applicant_profile['max_rent']) . ' ' . $applicant_profile['rent_frequency'],
109 );
110 }
111 if (
112 isset($applicant_profile['department']) &&
113 (
114 $applicant_profile['department'] == 'residential-sales' ||
115 $applicant_profile['department'] == 'residential-lettings' ||
116 ph_get_custom_department_based_on($applicant_profile['department']) == 'residential-sales' ||
117 ph_get_custom_department_based_on($applicant_profile['department']) == 'residential-lettings'
118 )
119 )
120 {
121 if ( isset($applicant_profile['min_beds']) && $applicant_profile['min_beds'] != '' && $applicant_profile['min_beds'] != 0 )
122 {
123 $requirements[] = array(
124 'label' => __( 'Minimum Beds', 'propertyhive' ),
125 'value' => $applicant_profile['min_beds'],
126 );
127 }
128 if ( isset($applicant_profile['property_types']) && is_array($applicant_profile['property_types']) && !empty($applicant_profile['property_types']) )
129 {
130 $terms = get_terms('property_type', array('hide_empty' => false, 'fields' => 'names', 'include' => $applicant_profile['property_types']));
131 if ( ! empty( $terms ) && ! is_wp_error( $terms ) )
132 {
133 $sliced_terms = array_slice( $terms, 0, 2 );
134
135 $requirements[] = array(
136 'label' => __( 'Property Types', 'propertyhive' ),
137 'value' => implode(", ", $sliced_terms) . ( (count($terms) > 2) ? '<span title="' . addslashes( implode(", ", $terms) ) .'"> + ' . (count($terms) - 2) . ' more</span>' : '' ),
138 );
139 }
140 }
141 }
142 if (
143 isset($applicant_profile['department']) &&
144 ( $applicant_profile['department'] == 'commercial' || ph_get_custom_department_based_on($applicant_profile['department']) == 'commercial' )
145 )
146 {
147 if ( isset($applicant_profile['available_as']) && is_array($applicant_profile['available_as']) && !empty($applicant_profile['available_as']) )
148 {
149 $available_as = array();
150 if ( in_array('sale', $applicant_profile['available_as']) )
151 {
152 $available_as[] = 'For Sale';
153 }
154 if ( in_array('rent', $applicant_profile['available_as']) )
155 {
156 $available_as[] = 'To Rent';
157 }
158
159 $requirements[] = array(
160 'label' => __( 'Available As', 'propertyhive' ),
161 'value' => implode(", ", $available_as),
162 );
163 }
164
165 if (
166 (isset($applicant_profile['min_floor_area_actual']) && $applicant_profile['min_floor_area_actual'] != '')
167 ||
168 (isset($applicant_profile['max_floor_area_actual']) && $applicant_profile['max_floor_area_actual'] != '')
169 )
170 {
171 $sizes = array('min' => '', 'max' => '');
172 $value = '';
173 if ( isset($applicant_profile['min_floor_area_actual']) && $applicant_profile['min_floor_area_actual'] != '' )
174 {
175 $sizes['min'] = $applicant_profile['min_floor_area_actual'];
176 }
177 if ( isset($applicant_profile['max_floor_area_actual']) && $applicant_profile['max_floor_area_actual'] != '' )
178 {
179 $sizes['max'] = $applicant_profile['max_floor_area_actual'];
180 }
181 if ( $sizes['min'] != '' && $sizes['max'] != '' )
182 {
183 $value = number_format($sizes['min']) . ' - ' . number_format($sizes['max']) . ' Sq Ft';
184 }
185 if ( $sizes['min'] != '' && $sizes['max'] == '' )
186 {
187 $value = 'From ' . number_format($sizes['min']) . ' Sq Ft';
188 }
189 if ( $sizes['min'] == '' && $sizes['max'] != '' )
190 {
191 $value = 'Up To ' . number_format($sizes['max']) . ' Sq Ft';
192 }
193
194 if ( $value != '' )
195 {
196 $requirements[] = array(
197 'label' => __( 'Floor Area', 'propertyhive' ),
198 'value' => $value,
199 );
200 }
201 }
202
203 if ( isset($applicant_profile['commercial_property_types']) && is_array($applicant_profile['commercial_property_types']) && !empty($applicant_profile['commercial_property_types']) )
204 {
205 $terms = get_terms('commercial_property_type', array('hide_empty' => false, 'fields' => 'names', 'include' => $applicant_profile['commercial_property_types']));
206 if ( ! empty( $terms ) && ! is_wp_error( $terms ) )
207 {
208 $sliced_terms = array_slice( $terms, 0, 2 );
209
210 $requirements[] = array(
211 'label' => __( 'Property Types', 'propertyhive' ),
212 'value' => implode(", ", $sliced_terms) . ( (count($terms) > 2) ? '<span title="' . addslashes( implode(", ", $terms) ) .'"> + ' . (count($terms) - 2) . ' more</span>' : '' ),
213 );
214 }
215 }
216 }
217 if ( get_option('propertyhive_applicant_locations_type') != 'text' )
218 {
219 if ( isset($applicant_profile['locations']) && is_array($applicant_profile['locations']) && !empty($applicant_profile['locations']) )
220 {
221 $terms = get_terms('location', array('hide_empty' => false, 'fields' => 'names', 'include' => $applicant_profile['locations']));
222 if ( ! empty( $terms ) && ! is_wp_error( $terms ) )
223 {
224 $sliced_terms = array_slice( $terms, 0, 2 );
225
226 $requirements[] = array(
227 'label' => __( 'Locations', 'propertyhive' ),
228 'value' => implode(", ", $sliced_terms) . ( (count($terms) > 2) ? ' <span title="' . addslashes( implode(", ", $terms) ) .'">+ ' . (count($terms) - 2) . ' more</span>' : '' ),
229 );
230 }
231 }
232 }
233 else
234 {
235 if ( isset($applicant_profile['location_text']) && trim($applicant_profile['location_text']) != '' )
236 {
237 $location_value = trim($applicant_profile['location_text']);
238
239 if ( isset($applicant_profile['location_radius']) && $applicant_profile['location_radius'] != '' )
240 {
241 $location_value .= ' (Within '. $applicant_profile['location_radius'] .' Miles)';
242 }
243
244 $requirements[] = array(
245 'label' => __( 'Location', 'propertyhive' ),
246 'value' => $location_value,
247 );
248 }
249 }
250
251 $requirements = apply_filters( 'propertyhive_applicant_requirements_display', $requirements, $contact_id, $applicant_profile );
252
253 if ( !empty($requirements) )
254 {
255 foreach ( $requirements as $requirement )
256 {
257 echo '<div style="display:inline-block; width:23%; margin-right:2%; vertical-align:top">
258 <strong>' . esc_html($requirement['label']) . ':</strong><br>
259 ' . $requirement['value'] . '
260 </div>';
261 }
262 }
263
264 if ( isset($applicant_profile['notes']) && $applicant_profile['notes'] != '' )
265 {
266 echo '<div style="display:inline-block; width:100%; vertical-align:top; margin-top:15px;">
267 <strong>Additional Requirement Notes:</strong><br>
268 ' . nl2br( strip_tags( $applicant_profile['notes'] ) ) . '
269 </div>';
270 }
271
272 echo '</div>';
273 ?>
274
275 <?php
276 if ( !empty($properties) )
277 {
278 $select_all_actions = array(
279 'email' => __( 'Email', 'propertyhive' ),
280 'not_interested' => __( 'Not Suitable', 'propertyhive' )
281 );
282
283 $select_all_actions = apply_filters( 'propertyhive_matching_select_all_actions', $select_all_actions );
284 ?>
285 <div class="select-actions" style="padding-top:15px">
286 <span style="display:inline-block; vertical-align:middle;"><?php echo esc_html(__( 'Select', 'propertyhive' )); ?>:</span> <?php
287 foreach ( $select_all_actions as $key => $value )
288 {
289 echo '<a href="javascript:;" class="button" id="select_all_' . esc_attr(sanitize_title($key)) . '" style="display:inline-block; vertical-align:middle;">All - ' . esc_html($value) . '</a> ';
290 }
291 ?>
292 <a href="javascript:;" class="button" id="select_none" style="display:inline-block; vertical-align:middle;">None</a>
293 </div>
294
295 <?php
296 foreach ( $properties as $property )
297 {
298 $previously_sent = array();
299 if ( isset($applicant_profile_match_history[$property->id]) && is_array($applicant_profile_match_history[$property->id]) && !empty($applicant_profile_match_history[$property->id]) )
300 {
301 $previously_sent = $applicant_profile_match_history[$property->id];
302 }
303
304 $on_market_change_date = $property->_on_market_change_date;
305 $price_change_date = $property->_price_change_date;
306
307 echo '<div id="matching_applicant_' . (int)$contact_id . '_property_' . (int)$property->id . '" style="padding:20px 0; border-bottom:1px solid #CCC;">';
308
309 echo '<div style="float:left; width:18%;">';
310
311 $image_url = $property->get_main_photo_src();
312 if ( $image_url !== FALSE )
313 {
314 echo '<a href="' . esc_url(get_edit_post_link( $property->id )) . '" target="_blank"><img src="' . esc_url($image_url) . '" style="max-width:100%; margin:0 auto; display:block;" alt="' . esc_attr($property->get_formatted_summary_address()) . '"></a>';
315 }
316
317 echo '</div>';
318
319 echo '<div style="float:right; width:80%;">';
320
321 echo '<h3 style="margin:0; padding:0; margin-bottom:9px;"><a href="' . esc_url(get_edit_post_link( $property->id )) . '" target="_blank">' . esc_html($property->get_formatted_summary_address()) . '</a></h3>';
322
323 echo '<div style="margin-bottom:7px; font-size:15px;">
324 <strong>' . esc_html(( ($property->_department == 'residential-lettings') ? __('Rent', 'propertyhive') : __('Price', 'propertyhive') )) . ': ' . esc_html($property->price_qualifier) . ' ' . $property->get_formatted_price() . '</strong>
325 | ';
326 if ($property->department != 'commercial' || ph_get_custom_department_based_on($property->department) == 'commercial')
327 {
328 echo $property->bedrooms . ' bed | ';
329 }
330 else
331 {
332 $floor_area = $property->get_formatted_floor_area();
333 if ( $floor_area != '' )
334 {
335 echo $floor_area . ' | ';
336 }
337 }
338 $property_type = $property->get_property_type();
339 if ( $property_type != '' )
340 {
341 echo esc_html($property_type) . ' | ';
342 }
343 echo ' ' . esc_html($property->get_availability()) . '
344 </div>';
345
346 echo '<div style="margin-bottom:7px;">' . esc_html(strip_tags(get_the_excerpt($property->id))) . '</div>';
347
348 echo '<div style="background:#F8F8F8; padding:12px 11px; line-height:1.7em; border:1px solid #DDD; font-weight:700">
349
350 <label><input type="checkbox" name="email_property_id[]" value="' . (int)$property->id . '" ';
351
352 $post_tip = '';
353 if ( strpos($email_address, '@') === FALSE )
354 {
355 echo ' disabled title="Invalid email address: ' . esc_attr($email_address) . '"';
356 $post_tip = 'Invalid email address: ' . $email_address;
357 }
358 elseif ( $do_not_email )
359 {
360 echo ' disabled title="Contact via email not permitted - Set under contact details"';
361 $post_tip = 'Contact via email not permitted - Set under contact details';
362 }
363 else
364 {
365 if ( !empty($previously_sent) )
366 {
367 $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']));
368
369 if (
370 $on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] ||
371 $price_change_date > $previously_sent[count($previously_sent) - 1]['date']
372 )
373 {
374 if ( $price_change_date > $previously_sent[count($previously_sent) - 1]['date'] )
375 {
376 $post_tip .= ', however a price change occurred on ' . date("jS F Y", strtotime($price_change_date));
377 }
378 elseif ( $on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] )
379 {
380 $post_tip .= ', however a change to the on market status occurred on ' . date("jS F Y", strtotime($on_market_change_date));
381 }
382 echo ' checked';
383 }
384 }
385 else
386 {
387 echo ' checked';
388 }
389 }
390
391 echo '> Email Property To Applicant<span style="font-weight:400;">' . ( ($post_tip != '') ? ' - ' . esc_html($post_tip) : '' ) . '</span></label>
392
393 <br>';
394
395 do_action( 'propertyhive_applicant_match_send_methods', $contact_id, $applicant_profile_id, $property->id );
396
397 echo '<label><input type="checkbox" name="not_interested_property_id[]" value="' . (int)$property->id . '"> Property Not Suitable</label>
398
399 </div>';
400
401 echo '</div>';
402
403 echo '<div style="clear:both"></div>';
404
405 echo '</div>';
406 }
407 }
408 ?>
409
410 <p class="submit">
411
412 <input name="save" class="button-primary" type="submit" value="<?php echo esc_html(__( 'Continue', 'propertyhive' )); ?>" />
413
414 <a href="<?php echo esc_url(get_edit_post_link((int)$_GET['contact_id'])); ?>" class="button"><?php echo esc_html(__( 'Cancel', 'propertyhive' )); ?></a>
415
416 <input type="hidden" name="step" value="one" />
417 <?php wp_nonce_field( 'propertyhive-matching-properties' ); ?>
418
419 </p>
420
421 <p>
422 <?php echo esc_html(__( "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' )); ?>
423 </p>
424
425 </div>
426
427 </form>
428
429 </div>
430
431 <script>
432
433 jQuery(document).ready(function()
434 {
435 jQuery('body').on('change', 'input[name=\'not_interested_property_id[]\']', function()
436 {
437 var property_id = jQuery(this).val();
438
439 jQuery('input[name=\'email_property_id[]\'][value=\'' + property_id + '\']').attr('checked', false);
440
441 opacity = 0.4;
442 if ( !jQuery(this).is(':checked') )
443 {
444 opacity = 1;
445 }
446 jQuery('#matching_applicant_<?php echo (int)$contact_id; ?>_property_' + property_id).animate({
447 opacity: opacity
448 },
449 {
450 duration: 250
451 });
452
453 return false;
454 });
455
456 jQuery('.select-actions a').click(function(e)
457 {
458 e.preventDefault();
459
460 var id = jQuery(this).attr('id').replace("select_all_", "");
461
462 jQuery('input[name$=\'_property_id[]\']').prop('checked', false);
463
464 if ( id != 'select_none' )
465 {
466 jQuery('input[name=\'' + id + '_property_id[]\']').prop('checked', 'checked');
467 }
468 });
469 });
470
471 </script>