PluginProbe
Property Hive / 2.2.3
Property Hive v2.2.3
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-applicants.php

html-admin-matching-applicants.php in Property Hive 2.2.3, at includes/admin/views/html-admin-matching-applicants.php

357 lines 18.1 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 Applicants For <?php echo esc_html($property->get_formatted_full_address()); ?> (<?php echo count($applicants); ?>)</h1>
10
11 <form method="post" id="mainform" action="" enctype="multipart/form-data">
12
13 <div id="poststuff">
14
15 <?php
16 if ( !empty($applicants) )
17 {
18 $select_all_actions = array(
19 'email' => __( 'Email', 'propertyhive' ),
20 'not_interested' => __( 'Not Suitable', 'propertyhive' )
21 );
22
23 $select_all_actions = apply_filters( 'propertyhive_matching_select_all_actions', $select_all_actions );
24 ?>
25 <div class="select-actions" style="padding-bottom:15px">
26 <span style="display:inline-block; vertical-align:middle;"><?php echo esc_html(__( 'Select', 'propertyhive' )); ?>:</span> <?php
27 foreach ( $select_all_actions as $key => $value )
28 {
29 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> ';
30 }
31 ?>
32 <a href="javascript:;" class="button" id="select_none" style="display:inline-block; vertical-align:middle;">None</a>
33 </div>
34 <?php
35 echo '<table width="100%">';
36
37 $columns = array(
38 'name' => 'Name',
39 'contact_details' => 'Contact Details',
40 'requirements' => 'Requirements'
41 );
42
43 $columns = apply_filters( 'propertyhive_matching_applicants_row_headings', $columns );
44
45 echo '<thead>
46 <tr>';
47 foreach ( $columns as $key => $column )
48 {
49 echo '<th style="text-align:left">' . esc_html($column) . '</th>';
50 }
51 echo '
52 <th style="text-align:left">Actions</th>
53 </tr>
54 </thead>
55 <tbody>
56 ';
57
58 $percentage_lower = get_option( 'propertyhive_applicant_match_price_range_percentage_lower', '' );
59 $percentage_higher = get_option( 'propertyhive_applicant_match_price_range_percentage_higher', '' );
60
61 foreach ( $applicants as $applicant )
62 {
63 $previously_sent = array();
64
65 $currency = '&pound;';
66 if ( isset($applicant['applicant_profile']['currency']) && !empty($applicant['applicant_profile']['currency']) )
67 {
68 $PH_Countries = new PH_Countries();
69 $selected_currency = $PH_Countries->get_currency($applicant['applicant_profile']['currency']);
70 if ( $selected_currency !== false )
71 {
72 $currency = $selected_currency['currency_symbol'];
73 }
74 }
75
76 $applicant_profile_match_history = get_post_meta( $applicant['contact_id'], '_applicant_profile_' . $applicant['applicant_profile']['applicant_profile_id'] . '_match_history', TRUE );
77 if ( isset($applicant_profile_match_history[$property->id]) && is_array($applicant_profile_match_history[$property->id]) && !empty($applicant_profile_match_history[$property->id]) )
78 {
79 $previously_sent = $applicant_profile_match_history[$property->id];
80 }
81
82 $email_address = get_post_meta( $applicant['contact_id'], '_email_address', TRUE );
83 $forbidden_contact_methods = get_post_meta( $applicant['contact_id'], '_forbidden_contact_methods', TRUE );
84 $do_not_email = false;
85 if ( is_array($forbidden_contact_methods) && in_array('email', $forbidden_contact_methods) )
86 {
87 $do_not_email = true;
88 }
89
90 $requirements = array();
91 if (
92 isset($applicant['applicant_profile']['department']) &&
93 ( $applicant['applicant_profile']['department'] == 'residential-sales' || ph_get_custom_department_based_on($applicant['applicant_profile']['department']) == 'residential-sales'
94 )
95 )
96 {
97 if ( isset($applicant['applicant_profile']['max_price']) && $applicant['applicant_profile']['max_price'] != '' )
98 {
99 $requirements[] = array(
100 'label' => __( 'Maximum Price', 'propertyhive' ),
101 'value' => $currency . ph_display_price_field($applicant['applicant_profile']['max_price']),
102 );
103 }
104 if ( $percentage_lower != '' && $percentage_higher != '' )
105 {
106 $match_price_range_lower = '';
107 if (
108 !isset($applicant['applicant_profile']['match_price_range_lower_actual']) ||
109 ( isset($applicant['applicant_profile']['match_price_range_lower_actual']) && $applicant['applicant_profile']['match_price_range_lower_actual'] == '' )
110 )
111 {
112 if ( isset($applicant['applicant_profile']['max_price']) && $applicant['applicant_profile']['max_price'] != '' )
113 {
114 $match_price_range_lower = $applicant['applicant_profile']['max_price'] - ( $applicant['applicant_profile']['max_price'] * ( $percentage_lower / 100 ) );
115 }
116 }
117 else
118 {
119 $match_price_range_lower = $applicant['applicant_profile']['match_price_range_lower'];
120 }
121
122 $match_price_range_higher = '';
123 if (
124 !isset($applicant['applicant_profile']['match_price_range_higher_actual']) ||
125 ( isset($applicant['applicant_profile']['match_price_range_higher_actual']) && $applicant['applicant_profile']['match_price_range_higher_actual'] == '' )
126 )
127 {
128 if ( isset($applicant['applicant_profile']['max_price']) && $applicant['applicant_profile']['max_price'] != '' )
129 {
130 $match_price_range_higher = $applicant['applicant_profile']['max_price'] + ( $applicant['applicant_profile']['max_price'] * ( $percentage_higher / 100 ) );
131 }
132 }
133 else
134 {
135 $match_price_range_higher = $applicant['applicant_profile']['match_price_range_higher'];
136 }
137
138 if (
139 $match_price_range_lower != '' && $match_price_range_higher != ''
140 )
141 {
142 $requirements[] = array(
143 'label' => __( 'Maximum Price Range', 'propertyhive' ),
144 'value' => $currency . ph_display_price_field($match_price_range_lower) . ' to ' . $currency . ph_display_price_field($match_price_range_higher),
145 );
146 }
147 }
148 }
149
150 if (
151 isset($applicant['applicant_profile']['department']) &&
152 ( $applicant['applicant_profile']['department'] == 'residential-lettings' || ph_get_custom_department_based_on($applicant['applicant_profile']['department']) == 'residential-lettings'
153 )
154 )
155 {
156 if ( isset($applicant['applicant_profile']['max_rent']) && $applicant['applicant_profile']['max_rent'] != '' )
157 {
158 $requirements[] = array(
159 'label' => __( 'Maximum Rent', 'propertyhive' ),
160 'value' => $currency . ph_display_price_field($applicant['applicant_profile']['max_rent']) . ' ' . $applicant['applicant_profile']['rent_frequency']
161 );
162 }
163 }
164
165 if ( isset($applicant['applicant_profile']['min_beds']) && $applicant['applicant_profile']['min_beds'] != '' )
166 {
167 $requirements[] = array(
168 'label' => __( 'Minimum Beds', 'propertyhive' ),
169 'value' => $applicant['applicant_profile']['min_beds'],
170 );
171 }
172
173 if ( isset($applicant['applicant_profile']['property_types']) && is_array($applicant['applicant_profile']['property_types']) && !empty($applicant['applicant_profile']['property_types']) )
174 {
175 //$requirements[] = 'Max Price: ' . $applicant['applicant_profile']['max_price'];
176 }
177
178 if ( get_option('propertyhive_applicant_locations_type') == 'text' && isset($applicant['applicant_profile']['location_text']) && $applicant['applicant_profile']['location_text'] != '')
179 {
180 $location_value = $applicant['applicant_profile']['location_text'];
181
182 if ( isset($applicant['applicant_profile']['location_radius']) && $applicant['applicant_profile']['location_radius'] != '' )
183 {
184 $location_value .= ' (Within '. $applicant['applicant_profile']['location_radius'] .' Miles)';
185 }
186
187 $requirements[] = array(
188 'label' => __( 'Location', 'propertyhive' ),
189 'value' => $location_value,
190 );
191 }
192
193 $requirements = apply_filters( 'propertyhive_applicant_requirements_display', $requirements, $applicant['contact_id'], $applicant['applicant_profile'] );
194
195 if ( isset($applicant['applicant_profile']['notes']) && $applicant['applicant_profile']['notes'] != '' )
196 {
197 $requirements[] = array(
198 'label' => __( 'Notes', 'propertyhive' ),
199 'value' => nl2br( strip_tags($applicant['applicant_profile']['notes']) ),
200 );
201 }
202
203 $requirements_output = '';
204 if ( empty($requirements) )
205 {
206 $requirements_output = '-';
207 }
208 else
209 {
210 foreach ( $requirements as $requirement )
211 {
212 $requirements_output .= $requirement['label'] . ': ' . $requirement['value'] . '<br>';
213 }
214 }
215
216 $columns = array(
217 'name' => '<strong><a href="' . esc_url(get_edit_post_link($applicant['contact_id'])) . '" target="_blank">' . esc_html(get_the_title($applicant['contact_id'])) . '</a>' . ( ( isset($applicant['applicant_profile']['grading']) && $applicant['applicant_profile']['grading'] == 'hot' ) ? '<br><span style="color:#C00;">('. esc_html(__( 'Hot Applicant', 'propertyhive' )) . ')</span>' : '' ) . '</strong>',
218 'contact_details' => 'T: ' . esc_html(get_post_meta( $applicant['contact_id'], '_telephone_number', TRUE )) . '<br>E: ' . esc_html($email_address),
219 'requirements' => $requirements_output,
220 );
221
222 $columns = apply_filters( 'propertyhive_matching_applicants_row_data', $columns, $applicant, $property->id );
223
224 echo '<tr id="matching_contact_' . (int)$applicant['contact_id'] . '_applicant_profile_' . (int)$applicant['applicant_profile']['applicant_profile_id'] . '">';
225 foreach ( $columns as $key => $column )
226 {
227 echo '<td style="border-bottom:1px solid #CCC; padding:5px 0;">' . $column . '</td>';
228 }
229 echo '<td style="border-bottom:1px solid #CCC; padding:5px 0;">';
230
231 echo '<label><input type="checkbox" name="email_contact_applicant_profile_id[]" value="' . (int)$applicant['contact_id'] . '|' . (int)$applicant['applicant_profile']['applicant_profile_id'] . '" ';
232
233 $post_tip = '';
234 if ( strpos($email_address, '@') === FALSE )
235 {
236 echo ' disabled title="Invalid email address: ' . esc_attr($email_address) . '"';
237 //$post_tip = 'Invalid email address: ' . $email_address;
238 }
239 elseif ( $do_not_email )
240 {
241 echo ' disabled title="Contact via email not permitted - Set under contact details"';
242 //$post_tip = 'Contact via email not permitted - Set under contact details';
243 }
244 else
245 {
246 if ( !empty($previously_sent) )
247 {
248 $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']));
249
250 if (
251 $on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] ||
252 $price_change_date > $previously_sent[count($previously_sent) - 1]['date']
253 )
254 {
255 if ( $price_change_date > $previously_sent[count($previously_sent) - 1]['date'] )
256 {
257 $post_tip .= ', however a price change occurred on ' . date("jS F Y", strtotime($price_change_date));
258 }
259 elseif ( $on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] )
260 {
261 $post_tip .= ', however a change to the on market status occurred on ' . date("jS F Y", strtotime($on_market_change_date));
262 }
263 echo ' checked';
264 }
265 }
266 else
267 {
268 echo ' checked';
269 }
270 }
271
272 echo '> Email Property To Applicant<span style="font-weight:400;">' . ( ($post_tip != '') ? ' - ' . esc_html($post_tip) : '' ) . '</span></label>
273
274 <br>';
275
276 do_action( 'propertyhive_property_match_send_methods', $applicant['contact_id'], $applicant['applicant_profile']['applicant_profile_id'], $property->id );
277
278 echo '<label><input type="checkbox" name="not_interested_contact_applicant_profile_id[]" value="' . (int)$applicant['contact_id'] . '|' . (int)$applicant['applicant_profile']['applicant_profile_id'] . '"> Property Not Suitable</label>';
279
280 echo '</td>';
281 echo '</tr>';
282 }
283
284 echo '
285 </tbody>
286 </table>
287 ';
288 }
289 else
290 {
291 echo __( 'No matching applicants found', 'propertyhive' );
292 }
293 ?>
294
295 <p class="submit">
296
297 <input name="save" class="button-primary" type="submit" value="<?php echo esc_html(__( 'Continue', 'propertyhive' )); ?>" />
298
299 <a href="<?php echo esc_url(get_edit_post_link((int)$_GET['property_id'])); ?>" class="button"><?php echo esc_html(__( 'Cancel', 'propertyhive' )); ?></a>
300
301 <input type="hidden" name="step" value="one" />
302 <?php wp_nonce_field( 'propertyhive-matching-applicants' ); ?>
303
304 </p>
305
306 <p>
307 <?php echo esc_html(__( "If you've opted to email any of the applicants you'll have the ability to edit the contents of the email in the next step.", 'propertyhive' )); ?>
308 </p>
309
310 </div>
311
312 </form>
313
314 </div>
315
316 <script>
317
318 jQuery(document).ready(function()
319 {
320 jQuery('body').on('change', 'input[name=\'not_interested_contact_applicant_profile_id[]\']', function()
321 {
322 var applicant_contact_profile_id = jQuery(this).val();
323 var applicant_contact_profile_id_split = applicant_contact_profile_id.split('|');
324
325 jQuery('input[name=\'email_contact_applicant_profile_id[]\'][value=\'' + applicant_contact_profile_id + '\']').attr('checked', false);
326
327 opacity = 0.4;
328 if ( !jQuery(this).is(':checked') )
329 {
330 opacity = 1;
331 }
332 jQuery('#matching_contact_' + applicant_contact_profile_id_split[0] + '_applicant_profile_' + applicant_contact_profile_id_split[1]).animate({
333 opacity: opacity
334 },
335 {
336 duration: 250
337 });
338
339 return false;
340 });
341
342 jQuery('.select-actions a').click(function(e)
343 {
344 e.preventDefault();
345
346 var id = jQuery(this).attr('id').replace("select_all_", "");
347
348 jQuery('input[name$=\'_contact_applicant_profile_id[]\']').prop('checked', false);
349
350 if ( id != 'select_none' )
351 {
352 jQuery('input[name=\'' + id + '_contact_applicant_profile_id[]\']').prop('checked', 'checked');
353 }
354 });
355 });
356
357 </script>