<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
$property_id        = get_the_ID();
$property_meta_data = get_post_custom( $property_id );
$property_size      = isset( $property_meta_data['property_size'] ) ? $property_meta_data['property_size'][0] : '';
$property_land_size = isset( $property_meta_data['property_land'] ) ? $property_meta_data['property_land'][0] : '';
$property_bedrooms  = isset( $property_meta_data['property_bedrooms'] ) ? $property_meta_data['property_bedrooms'][0] : '0';
$property_bathrooms = isset( $property_meta_data['property_bathrooms'] ) ? $property_meta_data['property_bathrooms'][0] : '0';
$property_rooms     = isset( $property_meta_data['property_rooms'] ) ? $property_meta_data['property_rooms'][0] : '0';
$property_types     = get_the_terms( $property_id, 'property-type' );
$property_type_text = array();
if ( ! empty( $property_types ) ) {
	foreach ( $property_types as $property_type ) {
		array_push( $property_type_text, $property_type->name );
	}
}
;
$property_type_text = implode( ", ", $property_type_text );
$property_garage    = isset( $property_meta_data['property_garage'] ) ? $property_meta_data['property_garage'][0] : '0';
$property_year      = isset( $property_meta_data['property_year'] ) ? $property_meta_data['property_year'][0] : '';
$show_overview      = is_array( tfre_get_option( 'single_property_panels_manager' ) ) ? tfre_get_option( 'single_property_panels_manager' )['overview'] : false;
?>
<?php if ( $show_overview == true ) : ?>
	<div id="nav-overview" class="single-property-element property-info-overview">
		<div class="tfre-property-overview">
			<div class="tfre-property-header">
				<h4><?php echo esc_html__( 'Overview', 'tf-real-estate' ); ?></h4>
			</div>
			<div class="tfre-property-info">
				<?php if ( ! empty( $property_rooms ) ) : ?>
						<div class="property-rooms">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-home"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html( tfre_get_number_text( $property_rooms, esc_html__( 'Rooms:', 'tf-real-estate' ), esc_html__( 'Room:', 'tf-real-estate' ) ) ); ?></span>
									<p class="property-info-value"><?php echo esc_html( $property_rooms ); ?></p>
								</div>
							</div>
						</div>
				<?php endif; ?>
				<?php if ( ! empty( $property_bedrooms ) ) : ?>
						<div class="property-bedrooms">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-bed2"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html( tfre_get_number_text( $property_bedrooms, esc_html__( 'Bedrooms:', 'tf-real-estate' ), esc_html__( 'Bedroom:', 'tf-real-estate' ) ) ); ?></span>
									<p class="property-info-value"><?php echo esc_html( $property_bedrooms ); ?></p>
								</div>
							</div>
						</div>
				<?php endif; ?>
				<?php if ( ! empty( $property_bathrooms ) ) : ?>
						<div class="property-bathrooms">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-bath3"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html( tfre_get_number_text( $property_bathrooms, esc_html__( 'Bathrooms:', 'tf-real-estate' ), esc_html__( 'Bathroom:', 'tf-real-estate' ) ) ); ?></span>
									<p class="property-info-value"><?php echo esc_html( $property_bathrooms ); ?></p>
								</div>
							</div>
						</div>
				<?php endif; ?>

				<?php if ( ! empty( $property_garage ) ) : ?>
						<div class="property-garage">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-garade2"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html( tfre_get_number_text( $property_garage, esc_html__( 'Garages:', 'tf-real-estate' ), esc_html__( 'Garage', 'tf-real-estate' ) ) ); ?></span>
									<p class="property-info-value"><?php echo esc_html( $property_garage ); ?></p>
								</div>
							</div>
						</div>
				<?php endif; ?>

				<?php if ( ! empty( $property_size ) ) : ?>
						<div class="property-size">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-ruler"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html__( 'Size:', 'tf-real-estate' ); ?></span>
									<p class="property-info-value">
										<?php echo esc_html( tfre_get_format_number( intval( $property_size ) ) ); ?> 
										<span><?php $measurement_units = tfre_get_option_measurement_units(); echo wp_kses( $measurement_units, array( 'sup' => array() ) ); ?></span>
									</p>
								</div>
							</div>
						</div>
				<?php endif; ?>
				<?php if ( ! empty( $property_land_size ) ) : ?>
						<div class="property-size">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-land"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html__( 'Land Size:', 'tf-real-estate' ); ?></span>
									<p class="property-info-value">
										<?php echo esc_html( tfre_get_format_number( intval( $property_land_size ) ) ); ?> 
										<span><?php $measurement_units = tfre_get_option_measurement_units(); echo wp_kses( $measurement_units, array( 'sup' => array() ) ); ?></span>
									</p>
								</div>
							</div>
						</div>
				<?php endif; ?>
				<?php if ( ! empty( $property_year ) ) : ?>
						<div class="property-year-built">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-fix"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html__( 'Year Built:', 'tf-real-estate' ); ?></span>
									<p class="property-info-value">
										<?php echo esc_html( empty( tfre_get_option( 'enable_convert_year' ) ) ? $property_year : tfre_get_year_time( $property_year ) ); ?>
									</p>
								</div>
							</div>
						</div>
				<?php endif; ?>
				<?php if ( ! empty( $property_types ) ) : ?>
						<div class="property-type">
							<div class="inner">
								<div class="icon">
									<i class="icon-homeya-shapes"></i>
								</div>
								<div class="content-property-info">
									<span class="property-info-title"><?php echo esc_html__( 'Type:', 'tf-real-estate' ); ?></span>
									<p class="property-info-value"><?php echo esc_html( $property_type_text ); ?></p>
								</div>
							</div>
						</div>
				<?php endif; ?>
			</div>
		</div>
	</div>
<?php endif; ?>