| 1 |
<div class="wrap propertyhive"> |
| 2 |
|
| 3 |
<h1>Matching Applicants For <?php echo $property->get_formatted_full_address(); ?> (<?php echo count($applicants); ?>)</h1> |
| 4 |
|
| 5 |
<form method="post" id="mainform" action="" enctype="multipart/form-data"> |
| 6 |
|
| 7 |
<div id="poststuff"> |
| 8 |
|
| 9 |
<?php |
| 10 |
if ( !empty($applicants) ) |
| 11 |
{ |
| 12 |
// var_dump($applicants); |
| 13 |
echo '<table width="100%">'; |
| 14 |
|
| 15 |
$columns = array( |
| 16 |
'name' => 'Name', |
| 17 |
'contact_details' => 'Contact Details', |
| 18 |
'requirements' => 'Requirements' |
| 19 |
); |
| 20 |
|
| 21 |
$columns = apply_filters( 'propertyhive_matching_applicants_row_headings', $columns ); |
| 22 |
|
| 23 |
echo '<thead> |
| 24 |
<tr>'; |
| 25 |
foreach ( $columns as $key => $column ) |
| 26 |
{ |
| 27 |
echo '<th style="text-align:left">' . $column . '</th>'; |
| 28 |
} |
| 29 |
echo ' |
| 30 |
<th style="text-align:left">Actions</th> |
| 31 |
</tr> |
| 32 |
</thead> |
| 33 |
<tbody> |
| 34 |
'; |
| 35 |
|
| 36 |
$percentage_lower = get_option( 'propertyhive_applicant_match_price_range_percentage_lower', '' ); |
| 37 |
$percentage_higher = get_option( 'propertyhive_applicant_match_price_range_percentage_higher', '' ); |
| 38 |
|
| 39 |
foreach ( $applicants as $applicant ) |
| 40 |
{ |
| 41 |
$previously_sent = array(); |
| 42 |
|
| 43 |
$applicant_profile_match_history = get_post_meta( $applicant['contact_id'], '_applicant_profile_' . $applicant['applicant_profile']['applicant_profile_id'] . '_match_history', TRUE ); |
| 44 |
if ( isset($applicant_profile_match_history[$property->id]) && is_array($applicant_profile_match_history[$property->id]) && !empty($applicant_profile_match_history[$property->id]) ) |
| 45 |
{ |
| 46 |
$previously_sent = $applicant_profile_match_history[$property->id]; |
| 47 |
} |
| 48 |
|
| 49 |
$email_address = get_post_meta( $applicant['contact_id'], '_email_address', TRUE ); |
| 50 |
$forbidden_contact_methods = get_post_meta( $applicant['contact_id'], '_forbidden_contact_methods', TRUE ); |
| 51 |
$do_not_email = false; |
| 52 |
if ( is_array($forbidden_contact_methods) && in_array('email', $forbidden_contact_methods) ) |
| 53 |
{ |
| 54 |
$do_not_email = true; |
| 55 |
} |
| 56 |
|
| 57 |
$requirements = array(); |
| 58 |
if ( isset($applicant['applicant_profile']['max_price']) && $applicant['applicant_profile']['max_price'] != '' ) |
| 59 |
{ |
| 60 |
$requirements[] = 'Max Price: £' . number_format($applicant['applicant_profile']['max_price']); |
| 61 |
} |
| 62 |
if ( $percentage_lower != '' && $percentage_higher != '' ) |
| 63 |
{ |
| 64 |
$match_price_range_lower = ''; |
| 65 |
if ( !isset($applicant['applicant_profile']['match_price_range_lower_actual']) || ( isset($applicant['applicant_profile']['match_price_range_lower_actual']) && $applicant['applicant_profile']['match_price_range_lower_actual'] == '' ) ) |
| 66 |
{ |
| 67 |
if ( isset($applicant['applicant_profile']['max_price_actual']) && $applicant['applicant_profile']['max_price_actual'] != '' ) |
| 68 |
{ |
| 69 |
$match_price_range_lower = $applicant['applicant_profile']['max_price_actual'] - ( $applicant['applicant_profile']['max_price_actual'] * ( $percentage_lower / 100 ) ); |
| 70 |
} |
| 71 |
} |
| 72 |
else |
| 73 |
{ |
| 74 |
$match_price_range_lower = $applicant['applicant_profile']['match_price_range_lower_actual']; |
| 75 |
} |
| 76 |
|
| 77 |
$match_price_range_higher = ''; |
| 78 |
if ( !isset($applicant['applicant_profile']['match_price_range_higher_actual']) || ( isset($applicant['applicant_profile']['match_price_range_higher_actual']) && $applicant['applicant_profile']['match_price_range_higher_actual'] == '' ) ) |
| 79 |
{ |
| 80 |
if ( isset($applicant['applicant_profile']['max_price_actual']) && $applicant['applicant_profile']['max_price_actual'] != '' ) |
| 81 |
{ |
| 82 |
$match_price_range_higher = $applicant['applicant_profile']['max_price_actual'] + ( $applicant['applicant_profile']['max_price_actual'] * ( $percentage_higher / 100 ) ); |
| 83 |
} |
| 84 |
} |
| 85 |
else |
| 86 |
{ |
| 87 |
$match_price_range_higher = $applicant['applicant_profile']['match_price_range_higher_actual']; |
| 88 |
} |
| 89 |
|
| 90 |
if ( |
| 91 |
$match_price_range_lower != '' && $match_price_range_higher != '' |
| 92 |
) |
| 93 |
{ |
| 94 |
$requirements[] = 'Match Price Range: £' . number_format($match_price_range_lower) . ' to £' . number_format($match_price_range_higher); |
| 95 |
} |
| 96 |
} |
| 97 |
if ( isset($applicant['applicant_profile']['min_beds']) && $applicant['applicant_profile']['min_beds'] != '' ) |
| 98 |
{ |
| 99 |
$requirements[] = 'Min Beds: ' . $applicant['applicant_profile']['min_beds']; |
| 100 |
} |
| 101 |
if ( isset($applicant['applicant_profile']['property_types']) && is_array($applicant['applicant_profile']['property_types']) && !empty($applicant['applicant_profile']['property_types']) ) |
| 102 |
{ |
| 103 |
//$requirements[] = 'Max Price: ' . $applicant['applicant_profile']['max_price']; |
| 104 |
} |
| 105 |
if ( isset($applicant['applicant_profile']['locations']) && is_array($applicant['applicant_profile']['locations']) && !empty($applicant['applicant_profile']['locations']) ) |
| 106 |
{ |
| 107 |
//$requirements[] = 'Max Price: ' . $applicant['applicant_profile']['max_price']; |
| 108 |
} |
| 109 |
if ( isset($applicant['applicant_profile']['notes']) && $applicant['applicant_profile']['notes'] != '' ) |
| 110 |
{ |
| 111 |
$requirements[] = 'Notes: ' . nl2br($applicant['applicant_profile']['notes']); |
| 112 |
} |
| 113 |
$requirements = implode("<br>", $requirements); |
| 114 |
if ( $requirements == '' ) |
| 115 |
{ |
| 116 |
$requirements = '-'; |
| 117 |
} |
| 118 |
|
| 119 |
$columns = array( |
| 120 |
'name' => '<strong><a href="' . get_edit_post_link($applicant['contact_id']) . '" target="_blank">' . get_the_title($applicant['contact_id']) . '</a>' . ( ( isset($applicant['applicant_profile']['grading']) && $applicant['applicant_profile']['grading'] == 'hot' ) ? '<br><span style="color:#C00;">('. __( 'Hot Applicant', 'propertyhive' ) . ')</span>' : '' ) . '</strong>', |
| 121 |
'contact_details' => 'T: ' . get_post_meta( $applicant['contact_id'], '_telephone_number', TRUE ) . '<br>E: ' . $email_address, |
| 122 |
'requirements' => $requirements, |
| 123 |
); |
| 124 |
|
| 125 |
$columns = apply_filters( 'propertyhive_matching_applicants_row_data', $columns, $applicant, $property->id ); |
| 126 |
|
| 127 |
echo '<tr id="matching_contact_' . $applicant['contact_id'] . '_applicant_profile_' . $applicant['applicant_profile']['applicant_profile_id'] . '">'; |
| 128 |
foreach ( $columns as $key => $column ) |
| 129 |
{ |
| 130 |
echo '<td style="border-bottom:1px solid #CCC; padding:5px 0;">' . $column . '</td>'; |
| 131 |
} |
| 132 |
echo '<td style="border-bottom:1px solid #CCC; padding:5px 0;">'; |
| 133 |
|
| 134 |
echo '<label><input type="checkbox" name="email_contact_applicant_profile_id[]" value="' . $applicant['contact_id'] . '|' . $applicant['applicant_profile']['applicant_profile_id'] . '" '; |
| 135 |
|
| 136 |
$post_tip = ''; |
| 137 |
if ( strpos($email_address, '@') === FALSE ) |
| 138 |
{ |
| 139 |
echo ' disabled title="Invalid email address: ' . $email_address . '"'; |
| 140 |
//$post_tip = 'Invalid email address: ' . $email_address; |
| 141 |
} |
| 142 |
elseif ( $do_not_email ) |
| 143 |
{ |
| 144 |
echo ' disabled title="Contact via email not permitted - Set under contact details"'; |
| 145 |
//$post_tip = 'Contact via email not permitted - Set under contact details'; |
| 146 |
} |
| 147 |
else |
| 148 |
{ |
| 149 |
if ( !empty($previously_sent) ) |
| 150 |
{ |
| 151 |
$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'])); |
| 152 |
|
| 153 |
if ( |
| 154 |
$on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] || |
| 155 |
$price_change_date > $previously_sent[count($previously_sent) - 1]['date'] |
| 156 |
) |
| 157 |
{ |
| 158 |
if ( $price_change_date > $previously_sent[count($previously_sent) - 1]['date'] ) |
| 159 |
{ |
| 160 |
$post_tip .= ', however a price change occurred on ' . date("jS F Y", strtotime($price_change_date)); |
| 161 |
} |
| 162 |
elseif ( $on_market_change_date > $previously_sent[count($previously_sent) - 1]['date'] ) |
| 163 |
{ |
| 164 |
$post_tip .= ', however a change to the on market status occurred on ' . date("jS F Y", strtotime($on_market_change_date)); |
| 165 |
} |
| 166 |
echo ' checked'; |
| 167 |
} |
| 168 |
} |
| 169 |
else |
| 170 |
{ |
| 171 |
echo ' checked'; |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
echo '> Email Property To Applicant<span style="font-weight:400;">' . ( ($post_tip != '') ? ' - ' . $post_tip : '' ) . '</span></label> |
| 176 |
|
| 177 |
<br>'; |
| 178 |
|
| 179 |
do_action( 'propertyhive_property_match_send_methods', $applicant['contact_id'], $applicant['applicant_profile']['applicant_profile_id'], $property->id ); |
| 180 |
|
| 181 |
echo '<label><input type="checkbox" name="not_interested_contact_applicant_profile_id[]" value="' . $applicant['contact_id'] . '|' . $applicant['applicant_profile']['applicant_profile_id'] . '"> Property Not Suitable</label>'; |
| 182 |
|
| 183 |
echo '</td>'; |
| 184 |
echo '</tr>'; |
| 185 |
} |
| 186 |
|
| 187 |
echo ' |
| 188 |
</tbody> |
| 189 |
</table> |
| 190 |
'; |
| 191 |
} |
| 192 |
else |
| 193 |
{ |
| 194 |
echo __( 'No matching applicants found', 'propertyhive' ); |
| 195 |
} |
| 196 |
?> |
| 197 |
|
| 198 |
<p class="submit"> |
| 199 |
|
| 200 |
<input name="save" class="button-primary" type="submit" value="<?php echo __( 'Continue', 'propertyhive' ); ?>" /> |
| 201 |
|
| 202 |
<a href="<?php echo get_edit_post_link((int)$_GET['property_id']); ?>" class="button"><?php _e( 'Cancel', 'propertyhive' ); ?></a> |
| 203 |
|
| 204 |
<input type="hidden" name="step" value="one" /> |
| 205 |
<?php wp_nonce_field( 'propertyhive-matching-applicants' ); ?> |
| 206 |
|
| 207 |
</p> |
| 208 |
|
| 209 |
<p> |
| 210 |
<?php echo __( "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' ); ?> |
| 211 |
</p> |
| 212 |
|
| 213 |
</div> |
| 214 |
|
| 215 |
</form> |
| 216 |
|
| 217 |
</div> |
| 218 |
|
| 219 |
<script> |
| 220 |
|
| 221 |
jQuery('body').on('change', 'input[name=\'not_interested_contact_applicant_profile_id[]\']', function() |
| 222 |
{ |
| 223 |
var applicant_contact_profile_id = jQuery(this).val(); |
| 224 |
var applicant_contact_profile_id_split = applicant_contact_profile_id.split('|'); |
| 225 |
|
| 226 |
jQuery('input[name=\'email_contact_applicant_profile_id[]\'][value=\'' + applicant_contact_profile_id + '\']').attr('checked', false); |
| 227 |
|
| 228 |
opacity = 0.4; |
| 229 |
if ( !jQuery(this).is(':checked') ) |
| 230 |
{ |
| 231 |
opacity = 1; |
| 232 |
} |
| 233 |
jQuery('#matching_contact_' + applicant_contact_profile_id_split[0] + '_applicant_profile_' + applicant_contact_profile_id_split[1]).animate({ |
| 234 |
opacity: opacity |
| 235 |
}, |
| 236 |
{ |
| 237 |
duration: 250 |
| 238 |
}); |
| 239 |
|
| 240 |
return false; |
| 241 |
}); |
| 242 |
|
| 243 |
</script> |