<?php
/**
 * The template for displaying the footer
 *
 * Contains the closing of the #content div and all content after.
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package brpfinanse
 */

	$footer_top = get_field('top_footer_box', 'option');
	$footer = get_field('footer_box', 'option');
?>

	<footer id="site-footer" class="site-footer">
		<div class="container">
			<div class="footer-1">
				<div class="row">
					<div class="col col-1">
						<div class="box-contact">
							<div class="box-title">
								<?php echo $footer_top['col_1']['title']; ?>
							</div>
							<div class="box-text">
								<p><?php echo $footer_top['col_1']['text']; ?></p>
							</div>
							<?php echo do_shortcode('[contact-form-7 id="3bcd014" title="Kontakt"]'); ?>
						</div>
					</div>
					<div class="col col-2">
						<div class="box-logo">
							<img src="/wp-content/uploads/2025/09/logo_small_white.svg" alt="">
						</div>
						<div class="box-text">
							<p><?php echo $footer_top['col_2']['title']; ?></p>
							<ol>
								<?php foreach ($footer_top['col_2']['list'] as $key => $value) : ?>
									<li><?php echo $value['text']; ?></li>
								<?php endforeach; ?>
							</ol>
						</div>
						<div class="box-info">
							<p><?php echo $footer_top['col_2']['info_text']; ?></p>
							<a href="#" class="btn_4 show-phone" data-post="<?php echo get_the_ID(); ?>">
								<?php echo $footer_top['col_2']['btn_placeholder']; ?>
							</a>

							<!-- <a class="btn_4" href="<?php echo esc_url($footer_top['col_2']['btn']['url']); ?>" target="<?php echo esc_attr($footer_top['col_2']['btn']['target'] ?: '_self'); ?>">
								<?php echo esc_html($footer_top['col_2']['btn']['title']); ?>
							</a> -->
						</div>
					</div>
				</div>
			</div>
			<div class="footer-2">
				<div class="row">
					<div class="col col-1">
						<?php if($footer['col_1']['title']): ?>
							<p><?php echo esc_html($footer['col_1']['title']); ?></p>
						<?php endif; ?>
						
						<?php if (!empty($footer['col_1']['text'])) : ?>
							<div class="col-text">
								<?php echo wp_kses_post($footer['col_1']['text']); ?>
							</div>
						<?php endif; ?>

						<div class="footer-nav">
							<?php foreach ($footer['col_1']['btns'] as $btn) : ?>
								<a href="<?php echo esc_url($btn['btn']['url']); ?>" target="<?php echo esc_attr($btn['target'] ?: '_self'); ?>">
									<?php echo esc_html($btn['btn']['title']); ?>
								</a>
							<?php endforeach; ?>
						</div>
					</div>
					<div class="col col-2">
						<ol>
							<li>
								<?php echo wp_kses_post($footer['col_2']['text']); ?>
							</li>
							<li>
								<?php echo wp_kses_post($footer['col_3']['text']); ?>
							</li>
							<li>
								<?php echo wp_kses_post($footer['col_4']['text']); ?>
							</li>
						</ol>
					</div>
					<div class="col col-3">
						<a href="<?php echo esc_url($footer['col_1']['btn']['url']); ?>" target="<?php echo esc_attr($footer['col_1']['btn']['target'] ?: '_self'); ?>">
							<?php echo esc_html($footer['col_1']['btn']['title']); ?>
						</a>
					</div>
				</div>
			</div>
		</div>
	</footer>

<?php wp_footer(); ?>

<script>
	jQuery(document).ready(function ($) {
	$('.show-phone').on('click', function (e) {
		e.preventDefault()

		var $this = $(this)
		var postId = $this.data('post')

		$.ajax({
			url: '<?php echo admin_url("admin-ajax.php"); ?>',
			type: 'POST',
			data: {
				action: 'get_full_phone',
				post_id: postId,
			},
			success: function (response) {
				if (response.success) {
					$this.replaceWith(response.data.html)
				}
			},
		})
	})
})
</script>
</body>
</html>
