<?php

//
//   Template Name: Page Contact
//

/**
 * The template for displaying all pages
 *
 * This is the template that displays all pages by default. Please note that
 * this is the WordPress construct of pages: specifically, posts with a post
 * type of `page`.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package ljn
 */

get_header();
$fields = get_fields();
$titre = $fields['titre'] ?? '';
$image = $fields['image'] ?? 0;
$agences = ljn_get_option('agences');
$telephone = ljn_get_option('telephone');
$email = ljn_get_option('email');
$contacts = ljn_get_option('contacts');

?>


<main id="main relative">
	<section class="section-cover-contact  w-full relative flex flex-col lg:flex-row">
		<div class="lg:basis-7/12 xl:basis-7/12 2xl:basis-8/12 sticky top-0 h-[300px] md:h-[450px] lg:h-screen ">
			<?php if (isset($image) && $image > 0) : ?>
				<?php echo wp_get_attachment_image($image, 'full', false, array('loading' => 'lazy', 'class' => 'scroll-appear absolute top-0 left-0 w-full h-full object-cover object-center')); ?>
			<?php endif; ?>
		</div>
		<div class="relative lg:basis-5/12 xl:basis-5/12 2xl:basis-4/12 p-12 xl:pl-24 xl:py-24  bg-beige flex flex-col justify-center text-left">
			<div class="flex flex-col gap-12 2xl:gap-20  scroll-appear">
				<div>
					<?php if (!empty($titre)) : ?>
						<h3 class="text-red mb-1 uppercase font-medium"><?php echo $titre ?></h3>
					<?php endif; ?>
					<div class="font-serif text-lg xl:text-2xl">
						<?php if (!empty($telephone)) : ?>
							<div>
								<a href=" tel:<?php echo str_replace(' ', '', $telephone) ?>">
									<?php echo $telephone ?>
								</a>
							</div>
						<?php endif; ?>
						<?php if (!empty($email)) : ?>
							<div>
								<a href="mailto:<?php echo $email ?>"><?php echo $email ?></a>
							</div>
						<?php endif; ?>
					</div>
				</div>
				<?php if (is_array($contacts) && sizeof($contacts) > 0) : ?>
					<?php foreach ($contacts as $contact) : ?>
						<div>
							<?php if (!empty($contact['titre'])) : ?>
								<h3 class="text-red mb-1 uppercase font-medium"><?php echo $contact['titre'] ?></h3>

								<?php if (is_array($contact['lien']) && sizeof($contact['lien']) > 0) : ?>
									<?php foreach ($contact['lien'] as $lien) : ?>
										<div class="font-serif text-lg xl:text-2xl">
											<?php if (!empty($lien['tel'])) : ?>
												<div>
													<a href=" tel:<?php echo str_replace(' ', '', $$lien['tel']) ?>">
														<?php echo $lien['tel'] ?>
													</a>
												</div>
											<?php endif; ?>
											<?php if (!empty($lien['email'])) : ?>
												<div>
													<a href="mailto:<?php echo $lien['email'] ?>"><?php echo $lien['email'] ?></a>
												</div>
											<?php endif; ?>
										</div>

									<?php endforeach; ?>
								<?php endif; ?>



							<?php endif; ?>
						</div>
					<?php endforeach; ?>
				<?php endif; ?>

				<?php if (is_array($agences) && sizeof($agences) > 0) : ?>

					<?php foreach ($agences as $agence) : ?>
						<address class="not-italic text-green font-medium">
							<h3 class="uppercase mb-1"><?php echo $agence['titre'] ?></h3>
							<div class=""><?php echo $agence['description'] ?></div>
						</address>
					<?php endforeach; ?>
				<?php endif; ?>
			</div>
		</div>

	</section>
</main><!-- #main -->






<?php
get_footer();
