/** * Add PH Header Stripe */ public function add_header_stripe($post) { global $post, $propertyhive, $property; if ($post->post_status != 'auto-draft') { if ($post->post_type == 'property') { $property = new PH_Property((int) $post->ID); echo '<div style="background:#2ea2cc; border:1px solid #0074a2; border-radius:4px; padding:10px 15px; color:#FFF;">'; echo propertyhive_get_property_thumbnail('thumbnail', 'alignleft'); echo '<h1>' . get_the_title($post->ID) . '</h1>'; echo '<h3>' . $property->get_formatted_price() . '</h3>'; echo '<div class="clear"></div>'; echo '</div>'; } } }
/** * Define our custom columns shown in admin. * @param string $column */ public function custom_columns($column) { global $post, $propertyhive, $the_property; if (empty($the_property) || $the_property->ID != $post->ID) { $the_property = new PH_Property($post->ID); } switch ($column) { case 'thumb': $thumb_src = $the_property->get_main_photo_src(); echo '<a href="' . get_edit_post_link($post->ID) . '">'; if ($thumb_src !== FALSE) { echo '<img src="' . $thumb_src . '" alt="" width="50">'; } else { // placeholder image } echo '</a>'; break; case 'address': $edit_link = get_edit_post_link($post->ID); //$title = _draft_or_post_title(); $title = $the_property->get_formatted_summary_address(); if (empty($title)) { $title = __('(no address entered)'); } $post_type_object = get_post_type_object($post->post_type); $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID); echo '<strong><a class="row-title" href="' . esc_url($edit_link) . '">' . $title . '</a>'; $post_status = get_post_status($post->ID); $post_title_output = ''; if ($post_status == 'draft' || $post_status == 'private') { $post_title_output = ucfirst($post_status); } $post_title_output = apply_filters('propertyhive_admin_property_column_post_address_output', $post_title_output); if ($post_title_output != '') { echo ' - ' . $post_title_output; } echo '</strong>'; // Excerpt view if (isset($_GET['mode']) && 'excerpt' == $_GET['mode']) { echo apply_filters('the_excerpt', $post->post_excerpt); } // Get actions $actions = array(); $actions['ref'] = 'Ref: ' . $the_property->_reference_number; //$actions['id'] = 'ID: ' . $post->ID; if ($can_edit_post && 'trash' != $post->post_status) { $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item', 'propertyhive')) . '">' . __('Edit', 'propertyhive') . '</a>'; } if (current_user_can($post_type_object->cap->delete_post, $post->ID)) { if ('trash' == $post->post_status) { $actions['untrash'] = '<a title="' . esc_attr(__('Restore this item from the Trash', 'propertyhive')) . '" href="' . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . '">' . __('Restore', 'propertyhive') . '</a>'; } elseif (EMPTY_TRASH_DAYS) { //$actions['trash'] = '<a class="submitdelete" title="' . esc_attr( __( 'Move this item to the Trash', 'propertyhive' ) ) . '" href="' . get_delete_post_link( $post->ID ) . '">' . __( 'Trash', 'propertyhive' ) . '</a>'; } if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) { $actions['delete'] = '<a class="submitdelete" title="' . esc_attr(__('Delete this item permanently', 'propertyhive')) . '" href="' . get_delete_post_link($post->ID, '', true) . '">' . __('Delete Permanently', 'propertyhive') . '</a>'; } } if ($post_type_object->public) { if (in_array($post->post_status, array('pending', 'draft', 'future'))) { if ($can_edit_post) { $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview “%s”', 'propertyhive'), $title)) . '" rel="permalink">' . __('Preview', 'propertyhive') . '</a>'; } } elseif ('trash' != $post->post_status) { $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”', 'propertyhive'), $title)) . '" rel="permalink">' . __('View', 'propertyhive') . '</a>'; } } $actions = apply_filters('post_row_actions', $actions, $post); echo '<div class="row-actions">'; $i = 0; $action_count = sizeof($actions); foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo '<span class="' . $action . '">' . $link . $sep . '</span>'; } echo '</div>'; /*get_inline_data( $post );*/ /* Custom inline data for propertyhive */ /*echo ' <div class="hidden" id="propertyhive_inline_' . $post->ID . '"> <div class="menu_order">' . $post->menu_order . '</div> </div> ';*/ break; case 'size': $floor_area = $the_property->get_formatted_floor_area(); if ($floor_area != '') { echo 'Floor Area: ' . $floor_area . '<br>'; } $site_area = $the_property->get_formatted_site_area(); if ($site_area != '') { echo 'Site Area: ' . $site_area; } if ($floor_area == '' && $site_area == '') { echo '-'; } break; case 'price': $price = $the_property->get_formatted_price(); if ($price == '') { $price = '-'; } echo $price; break; case 'status': $term_list = wp_get_post_terms($post->ID, 'availability', array("fields" => "names")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { echo $term_list[0] . '<br>'; } if (isset($the_property->_on_market) && $the_property->_on_market == 'yes') { echo 'On The Market'; } else { echo 'Not On The Market'; } if (isset($the_property->_featured) && $the_property->_featured == 'yes') { echo '<br>Featured'; } break; case 'owner': $owner_contact_id = $the_property->_owner_contact_id; if ($owner_contact_id != '' && $owner_contact_id != 0) { echo get_the_title($owner_contact_id) . '<br>'; echo '<div class="row-actions">'; echo 'T: ' . get_post_meta($owner_contact_id, '_telephone_number', TRUE) . '<br>'; echo 'E: ' . get_post_meta($owner_contact_id, '_email_address', TRUE); echo '</div>'; } break; case 'negotiator_office': $user_info = get_userdata($the_property->_negotiator_id); if ($user_info !== FALSE) { echo $user_info->display_name . '<br>'; } if ($the_property->_office_id != '') { echo get_the_title($the_property->_office_id); } break; default: break; } }
/** * Output the metabox */ public static function output($post) { global $post, $wpdb, $thepostid; $total_profiles = 0; $owner_profiles = array(); // get properties where this is the owner $args = array('post_type' => 'property', 'meta_query' => array(array('key' => '_owner_contact_id', 'value' => $post->ID, 'compare' => '='))); $property_query = new WP_Query($args); if ($property_query->have_posts()) { while ($property_query->have_posts()) { $property_query->the_post(); $owner_profiles[] = $post; ++$total_profiles; } } wp_reset_postdata(); $applicant_profiles = array(); $num_applicant_profiles = get_post_meta($thepostid, '_applicant_profiles', TRUE); if ($num_applicant_profiles == '') { $num_applicant_profiles = 0; } if ($num_applicant_profiles > 0) { $total_profiles += $num_applicant_profiles; for ($i = 0; $i < $num_applicant_profiles; ++$i) { $applicant_profiles[] = get_post_meta($thepostid, '_applicant_profile_' . $i, TRUE); } } $third_party_profiles = array(); $third_party_categories = get_post_meta($thepostid, '_third_party_categories', TRUE); if (is_array($third_party_categories) && !empty($third_party_categories)) { $ph_third_party_contacts = new PH_Third_Party_Contacts(); foreach ($third_party_categories as $third_party_category) { $third_party_profiles[] = $third_party_category; ++$total_profiles; } } echo '<div class="propertyhive_meta_box">'; echo '<div class="panel-wrap"> <div class="ph-tabs-back"></div> <ul class="contact_data_tabs ph-tabs">'; $tab = 0; foreach ($owner_profiles as $property_post) { $owner_type = __('Property Owner', 'propertyhive'); $department = get_post_meta($property_post->ID, '_department', TRUE); if ($department == 'lettings') { $owner_type = __('Property Landlord', 'propertyhive'); } echo '<li class="property_tab' . ($tab == 0 ? ' active' : '') . '"> <a href="#tab_property_data_' . $property_post->ID . '">' . $owner_type . '</a> </li>'; ++$tab; } foreach ($applicant_profiles as $key => $applicant_profile) { $label = __('New Applicant', 'propertyhive'); if (isset($applicant_profile['department']) && $applicant_profile['department'] == 'residential-sales') { $label = __('Sales Applicant', 'propertyhive'); } elseif (isset($applicant_profile['department']) && $applicant_profile['department'] == 'residential-lettings') { $label = __('Lettings Applicant', 'propertyhive'); } elseif (isset($applicant_profile['department']) && $applicant_profile['department'] == 'commercial') { $label = __('Commercial Applicant', 'propertyhive'); } echo '<li class="property_tab' . ($tab == 0 ? ' active' : '') . '"> <a href="#tab_applicant_data_' . $key . '">' . $label . '</a> </li>'; ++$tab; } foreach ($third_party_profiles as $key => $third_party_profile) { $label = __('New Third Party', 'propertyhive'); if ($third_party_profile != '' && $third_party_profile != 0) { $category_name = $ph_third_party_contacts->get_category($third_party_profile); if ($category_name !== false) { $label = $category_name; } } echo '<li class="property_tab' . ($tab == 0 ? ' active' : '') . '"> <a href="#tab_third_party_data_' . $key . '">' . $label . '</a> </li>'; ++$tab; } echo '<li class="property_tab' . ($tab == 0 ? ' active' : '') . '"> <a href="#tab_add_relationship">' . __('Add Relationship', 'propertyhive') . '</a> </li>'; echo '</ul>'; $contact_id = $thepostid; $tab = 0; foreach ($owner_profiles as $property_post) { $the_property = new PH_Property($property_post->ID); echo '<div id="tab_property_data_' . $property_post->ID . '" class="panel propertyhive_options_panel" style="' . ($tab == 0 ? 'display:block;' : 'display:none;') . '"> <div class="options_group" style="float:left; width:100%;">'; echo '<p class="form-field">'; echo '<label>' . __('Address', 'propertyhive') . '</label>'; echo $the_property->get_formatted_summary_address('<br>'); echo '</p>'; echo '<p class="form-field">'; echo '<label>' . __('Price', 'propertyhive') . '</label>'; echo $the_property->get_formatted_price(); echo '</p>'; echo '<p class="form-field">'; echo '<label>' . __('Bedrooms', 'propertyhive') . '</label>'; echo $the_property->_bedrooms; echo '</p>'; echo '<p class="form-field">'; echo '<label>' . __('Status', 'propertyhive') . '</label>'; echo $the_property->_on_market == 'yes' ? __('On Market', 'propertyhive') : __('Not On Market', 'propertyhive'); echo '</p>'; echo '<p class="form-field">'; echo '<label></label>'; echo '<a href="' . get_edit_post_link($property_post->ID) . '" class="button">' . __('View Property Record', 'propertyhive') . '</a>'; echo '</p>'; echo ' </div> </div>'; ++$tab; } foreach ($applicant_profiles as $key => $applicant_profile) { echo '<div id="tab_applicant_data_' . $key . '" class="panel propertyhive_options_panel" style="' . ($tab == 0 ? 'display:block;' : 'display:none;') . '"> <div class="options_group applicant-fields-' . $key . '" style="float:left; width:100%;">'; $departments = array(); if (get_option('propertyhive_active_departments_sales') == 'yes') { $departments['residential-sales'] = __('Residential Sales', 'propertyhive'); } if (get_option('propertyhive_active_departments_lettings') == 'yes') { $departments['residential-lettings'] = __('Residential Lettings', 'propertyhive'); } if (get_option('propertyhive_active_departments_commercial') == 'yes') { $departments['commercial'] = __('Commercial', 'propertyhive'); } $value = isset($applicant_profile['department']) && $applicant_profile['department'] != '' ? $applicant_profile['department'] : get_option('propertyhive_primary_department'); $args = array('id' => '_applicant_department_' . $key, 'label' => 'Looking For', 'value' => $value, 'options' => $departments); if (count($departments) == 1) { foreach ($departments as $department_key => $value) { $args['value'] = $department_key; } } propertyhive_wp_radio($args); echo '<div class="propertyhive-applicant-residential-sales-details-' . $key . '">'; // Price propertyhive_wp_text_input(array('id' => '_applicant_maximum_price_' . $key, 'label' => __('Maximum Price', 'propertyhive') . ' (£)', 'desc_tip' => false, 'type' => 'text', 'class' => '', 'custom_attributes' => array('style' => 'width:100%; max-width:150px;'), 'value' => isset($applicant_profile['max_price']) ? $applicant_profile['max_price'] : '')); echo '</div>'; echo '<div class="propertyhive-applicant-residential-lettings-details-' . $key . '">'; // Rent / Rent Frequency $rent_frequency = isset($applicant_profile['rent_frequency']) ? $applicant_profile['rent_frequency'] : ''; echo '<p class="form-field rent_field "> <label for="_applicant_maximum_rent_' . $key . '">' . __('Maximum Rent', 'propertyhive') . ' (£)</label> <input type="text" class="" name="_applicant_maximum_rent_' . $key . '" id="_applicant_maximum_rent_' . $key . '" value="' . (isset($applicant_profile['max_rent']) ? $applicant_profile['max_rent'] : '') . '" placeholder="" style="width:20%; max-width:150px;"> <select id="_applicant_rent_frequency_' . $key . '" name="_applicant_rent_frequency_' . $key . '" class="select short"> <option value="pw"' . ($rent_frequency == 'pw' ? ' selected' : '') . '>' . __('Per Week', 'propertyhive') . '</option> <option value="pcm"' . ($rent_frequency == 'pcm' || $rent_frequency == '' ? ' selected' : '') . '>' . __('Per Calendar Month', 'propertyhive') . '</option> <option value="pq"' . ($rent_frequency == 'pq' ? ' selected' : '') . '>' . __('Per Quarter', 'propertyhive') . '</option> <option value="pa"' . ($rent_frequency == 'pa' ? ' selected' : '') . '>' . __('Per Annum', 'propertyhive') . '</option> </select> </p>'; echo '</div>'; echo '<div class="propertyhive-applicant-residential-details-' . $key . '">'; // Bedrooms propertyhive_wp_text_input(array('id' => '_applicant_minimum_bedrooms_' . $key, 'label' => __('Minimum Bedrooms', 'propertyhive'), 'desc_tip' => false, 'type' => 'number', 'class' => '', 'custom_attributes' => array('style' => 'width:100%; max-width:75px;'), 'value' => isset($applicant_profile['min_beds']) ? $applicant_profile['min_beds'] : '')); // Residential Types ?> <p class="form-field"><label for="_applicant_property_types_<?php echo $key; ?> "><?php _e('Property Types', 'propertyhive'); ?> </label> <select id="_applicant_property_types_<?php echo $key; ?> " name="_applicant_property_types_<?php echo $key; ?> []" multiple="multiple" data-placeholder="Start typing to add property types..." class="multiselect attribute_values"> <?php $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('property_type', $args); $selected_values = array(); $term_list = isset($applicant_profile['property_types']) ? $applicant_profile['property_types'] : array(); if (is_array($term_list) && !empty($term_list)) { foreach ($term_list as $term_id) { $selected_values[] = $term_id; } } if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>' . esc_html($term->name) . '</option>'; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subterms = get_terms('property_type', $args); if (!empty($subterms) && !is_wp_error($subterms)) { foreach ($subterms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>- ' . esc_html($term->name) . '</option>'; } } } } ?> </select></p> <?php echo '</div>'; // end 'propertyhive-applicant-residential-details-' . $key echo '<div class="propertyhive-applicant-commercial-details-' . $key . '">'; $args = array('id' => '_applicant_available_as_' . $key, 'label' => 'Available As', 'value' => array('sale', 'rent'), 'options' => array('sale' => 'For Sale', 'rent' => 'To Rent')); if (isset($applicant_profile['available_as']) && is_array($applicant_profile['available_as'])) { $args['value'] = array(); foreach ($applicant_profile['available_as'] as $value) { $args['value'][] = $value; } } propertyhive_wp_checkboxes($args); // Commercial Types ?> <p class="form-field"><label for="_applicant_commercial_property_types_<?php echo $key; ?> "><?php _e('Property Types', 'propertyhive'); ?> </label> <select id="_applicant_commercial_property_types_<?php echo $key; ?> " name="_applicant_commercial_property_types_<?php echo $key; ?> []" multiple="multiple" data-placeholder="Start typing to add property types..." class="multiselect attribute_values"> <?php $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('commercial_property_type', $args); $selected_values = array(); $term_list = isset($applicant_profile['commercial_property_types']) ? $applicant_profile['commercial_property_types'] : array(); if (is_array($term_list) && !empty($term_list)) { foreach ($term_list as $term_id) { $selected_values[] = $term_id; } } if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>' . esc_html($term->name) . '</option>'; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subterms = get_terms('property_type', $args); if (!empty($subterms) && !is_wp_error($subterms)) { foreach ($subterms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>- ' . esc_html($term->name) . '</option>'; } } } } ?> </select></p> <?php echo '</div>'; // end 'propertyhive-applicant-commercial-details-' . $key // Locations ?> <p class="form-field"><label for="_applicant_locations_<?php echo $key; ?> "><?php _e('Locations', 'propertyhive'); ?> </label> <select id="_applicant_locations_<?php echo $key; ?> " name="_applicant_locations_<?php echo $key; ?> []" multiple="multiple" data-placeholder="Start typing to add location..." class="multiselect attribute_values"> <?php $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('location', $args); $selected_values = array(); $term_list = isset($applicant_profile['locations']) ? $applicant_profile['locations'] : array(); if (is_array($term_list) && !empty($term_list)) { foreach ($term_list as $term_id) { $selected_values[] = $term_id; } } if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>' . esc_html($term->name) . '</option>'; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subterms = get_terms('location', $args); if (!empty($subterms) && !is_wp_error($subterms)) { foreach ($subterms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>- ' . esc_html($term->name) . '</option>'; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subsubterms = get_terms('location', $args); if (!empty($subsubterms) && !is_wp_error($subsubterms)) { foreach ($subsubterms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>- - ' . esc_html($term->name) . '</option>'; } } } } } } ?> </select></p> <?php // Additional Requirement Notes propertyhive_wp_textarea_input(array('id' => '_applicant_requirement_notes_' . $key, 'label' => __('Additional Requirements', 'propertyhive'), 'desc_tip' => false, 'class' => '', 'value' => isset($applicant_profile['notes']) ? $applicant_profile['notes'] : '')); propertyhive_wp_checkbox(array('id' => '_send_matching_properties_' . $key, 'label' => __('Send Matching Properties', 'propertyhive'), 'desc_tip' => false, 'value' => isset($applicant_profile['send_matching_properties']) && $applicant_profile['send_matching_properties'] == 'yes' || !isset($applicant_profile['send_matching_properties']) ? 'yes' : '')); $auto_property_match = get_option('propertyhive_auto_property_match', ''); if ($auto_property_match == 'yes') { // Auto match emails are enabled. Add ability to disable on per-applicant basis propertyhive_wp_checkbox(array('id' => '_auto_match_disabled_' . $key, 'label' => __('Disable Auto-Match', 'propertyhive'), 'desc_tip' => false, 'value' => isset($applicant_profile['auto_match_disabled']) && $applicant_profile['auto_match_disabled'] == 'yes' ? 'yes' : '')); } echo ' </div> <div class="actions"> <a href="' . admin_url('admin.php?page=ph-matching-properties&contact_id=' . $contact_id . '&applicant_profile=' . $key) . '" class="button view-matching-properties-' . $key . '" ' . (isset($applicant_profile['send_matching_properties']) && $applicant_profile['send_matching_properties'] == '' ? ' disabled title="Send Matching Properties not selected"' : '') . ' >' . __('View Matching Properties', 'propertyhive') . '</a> <a href="' . wp_nonce_url(admin_url('post.php?post=' . $contact_id . '&action=edit#propertyhive-contact-relationships'), $key, 'delete_applicant_relationship') . '" class="button" onclick="var confirmBox = confirm(\'' . __('Are you sure you wish to delete this applicant relationship?', 'propertyhive') . '\'); return confirmBox;" >' . __('Delete Relationship', 'propertyhive') . '</a> <div id="view_matching_properties_' . $key . '" style="display:none;"> <div class="loading-properties" style="text-align:center;"><br><br>Loading matching properties...</div> <div class="need-to-save-changes" style="text-align:center;"><br><br>Please save your changes before viewing matching properties</div> <div class="matching-properties" id="matching_properties_' . $key . '" style="display:none;"> </div> </div> </div> </div> <script> var applicant_details_changed_' . $key . ' = false; jQuery(document).ready(function() { showHideApplicantDepartmentMetaBox_' . $key . '(); jQuery(\'input[type=\\\'radio\\\'][name=\\\'_applicant_department_' . $key . '\\\']\').change(function() { showHideApplicantDepartmentMetaBox_' . $key . '(); }); jQuery(\'.applicant-fields-' . $key . ' input, .applicant-fields-' . $key . ' select, .applicant-fields-' . $key . ' textarea\').change(function() { applicant_details_changed_' . $key . ' = true; }); jQuery(\'a.view-matching-properties-' . $key . '\').click(function(e) { if (applicant_details_changed_' . $key . ') { alert(\'You\\\'ve made changes to the requirements. Please save the changes before viewing matching properties\'); return false; } return true; }); }); function showHideApplicantDepartmentMetaBox_' . $key . '() { jQuery(\'.propertyhive-applicant-residential-details-' . $key . '\').hide(); jQuery(\'.propertyhive-applicant-residential-sales-details-' . $key . '\').hide(); jQuery(\'.propertyhive-applicant-residential-lettings-details-' . $key . '\').hide(); jQuery(\'.propertyhive-applicant-commercial-details-' . $key . '\').hide(); switch (jQuery(\'input[type=\\\'radio\\\'][name=\\\'_applicant_department_' . $key . '\\\']:checked\').val()) { case "residential-sales": { jQuery(\'.propertyhive-applicant-residential-details-' . $key . '\').show(); jQuery(\'.propertyhive-applicant-residential-sales-details-' . $key . '\').show(); break; } case "residential-lettings": { jQuery(\'.propertyhive-applicant-residential-details-' . $key . '\').show(); jQuery(\'.propertyhive-applicant-residential-lettings-details-' . $key . '\').show(); break; } case "commercial": { jQuery(\'.propertyhive-applicant-commercial-details-' . $key . '\').show(); break; } } } </script>'; ++$tab; } foreach ($third_party_profiles as $key => $category) { echo '<div id="tab_third_party_data_' . $key . '" class="panel propertyhive_options_panel" style="' . ($tab == 0 ? 'display:block;' : 'display:none;') . '"> <div class="options_group" style="float:left; width:100%;">'; echo '<p class="form-field rent_field "> <label for="_third_party_category_' . $key . '">' . __('Contact Category', 'propertyhive') . '</label> <select id="_third_party_category_' . $key . '" name="_third_party_category[]" class="select short">'; if ($category == '' || $category == 0) { echo '<option value="0"></option>'; } $categories = $ph_third_party_contacts->get_categories(); foreach ($categories as $id => $category_name) { echo '<option value="' . $id . '"'; if ($id == $category) { echo ' selected'; } echo '>' . $category_name . '</option>'; } echo '</select> </p>'; echo ' </div> </div>'; ++$tab; } echo '<div id="tab_add_relationship" class="panel propertyhive_options_panel" style="' . ($tab == 0 ? 'display:block;' : 'display:none;') . '"> <div class="options_group">'; echo '<p class="form-field">'; echo '<label>' . __('New Relationship Type', 'propertyhive') . '</label>'; echo '<a href="' . wp_nonce_url(admin_url('post.php?post=' . $thepostid . '&action=edit#propertyhive-contact-relationships'), '1', 'add_applicant_relationship') . '" class="button">' . __('New Applicant Profile', 'propertyhive') . '</a><br><br>'; echo '<a href="' . admin_url('post-new.php?post_type=property&owner_contact_id=' . $thepostid) . '" class="button">' . __('New Property Owner / Landlord', 'propertyhive') . '</a><br><br>'; echo '<a href="' . wp_nonce_url(admin_url('post.php?post=' . $thepostid . '&action=edit#propertyhive-contact-relationships'), '1', 'add_third_party_relationship') . '" class="button">' . __('New Third Party Contact', 'propertyhive') . '</a>'; echo '</p>'; echo ' </div> </div>'; echo '<div class="clear"></div> </div>'; echo '</div>'; //do_action('propertyhive_contact_relationships_fields'); }
public function register_rest_api_property_fields() { $field_array = array('department', 'latitude', 'longitude', 'price', 'price_formatted', 'currency', 'price_qualifier', 'sale_by', 'tenure', 'deposit', 'furnished', 'available_date', 'bedrooms', 'bathrooms', 'reception_rooms', 'property_type', 'parking', 'outside_space', 'featured', 'availability', 'marketing_flags', 'features', 'description', 'office'); foreach ($field_array as $field) { register_rest_field('property', $field, array('get_callback' => function ($object, $field_name, $request) { $property = new PH_Property($object['id']); switch ($field_name) { case "price": if ($property->poa != 'yes') { if ($property->department == 'residential-lettings') { return $property->rent; } else { return $property->price; } } return ''; case "price_formatted": return $property->get_formatted_price(); break; case "features": return $property->get_features(); break; case "description": return $property->get_formatted_description(); break; case "office": return array('name' => $property->office_name, 'address' => $property->office_address, 'telephone_number' => $property->office_telephone_number, 'email_address' => $property->office_email_address); break; default: return $property->{$field_name}; } }, 'update_callback' => null, 'schema' => null)); } }
/** * Output the metabox */ public static function output($post) { echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; // Get children posts/properties $args = array('post_parent' => $post->ID, 'post_type' => 'property', 'nopaging' => true, 'orderby' => 'title'); $unit_query = new WP_Query($args); if ($unit_query->have_posts()) { echo '<table style="width:100%"> <thead> <tr> <th style="text-align:left;">Unit Address</th> <th style="text-align:left;">Size</th> <th style="text-align:left;">Price</th> <th style="text-align:left;">Availability</th> </tr> </thead> <tbody>'; while ($unit_query->have_posts()) { $unit_query->the_post(); $the_property = new PH_Property(get_the_ID()); echo '<tr>'; echo '<td style="text-align:left;"><a href="' . get_edit_post_link(get_the_ID()) . '">' . $the_property->get_formatted_summary_address() . '</a></td>'; echo '<td style="text-align:left;">'; $floor_area = $the_property->get_formatted_floor_area(); if ($floor_area != '') { echo 'Floor Area: ' . $floor_area . '<br>'; } $site_area = $the_property->get_formatted_site_area(); if ($site_area != '') { echo 'Site Area: ' . $site_area; } if ($floor_area == '' && $site_area == '') { echo '-'; } echo '</td>'; echo '<td style="text-align:left;">'; $price = $the_property->get_formatted_price(); if ($price == '') { $price = '-'; } echo $price; echo '</td>'; echo '<td style="text-align:left;">'; $term_list = wp_get_post_terms($post->ID, 'availability', array("fields" => "names")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { echo $term_list[0] . '<br>'; } if (isset($the_property->_on_market) && $the_property->_on_market == 'yes') { echo 'On The Market'; } else { echo 'Not On The Market'; } if (isset($the_property->_featured) && $the_property->_featured == 'yes') { echo '<br>Featured'; } echo '</td>'; echo '</tr>'; } echo ' </tbody> </table> <br>'; } else { echo '<p>' . __('No units currently exist for this property', 'propertyhive') . '</p>'; } wp_reset_postdata(); echo '<a href="' . admin_url('post-new.php?post_type=property&post_parent=' . $post->ID) . '" class="button">' . __('Add New Unit', 'propertyhive') . '</a>'; do_action('propertyhive_property_commercial_units_fields'); echo '</div>'; echo '</div>'; }