<?php


?>

<fieldset class="field-order-paper-publications">
	<?php foreach ($this->choices as $index => $brochurePost) : ?>
		<?php

		$thematique = getPostMainThematique($brochurePost['ID']);
		$thematiqueCover = get_field('taxonomy_pictures', "thematiques_" . $thematique->term_id);
		$brochure_pdf_link = get_field('brochure_pdf', $brochurePost['ID']);
		if (!$brochure_pdf_link) continue;

		?>

		<div class=" gchoice brochure-order-field">
			<div class="thematique-tag thematique-tag--<?php echo $thematique->slug ?>">
				<?php if ($thematiqueCover && $thematiqueCover['icon']) : ?>
					<img class="thematique-icon" src="<?php echo $thematiqueCover['icon']['url'] ?>" alt="">
				<?php endif; ?>
				<p>
					<?php echo $thematique->name ?>
				</p>
			</div>

			<legend class="brochure-legend gform-field-label gform-field-label--type-inline"><?php echo $brochure_pdf_link['title'] ?></legend>

			<a class="preview-brochure" href="<?php echo get_the_permalink($brochurePost['ID']) ?>" target="_blank"><?php echo __("Voir la brochure", "homegrade-theme__texte-fonctionnel") ?></a>
			<div class="inputs-container">
				<?php
				$ID_FR = apply_filters('wpml_object_id', $brochurePost['ID'], 'brochures', false, 'fr');
				$ID_NL = apply_filters('wpml_object_id', $brochurePost['ID'], 'brochures', false, 'nl');

				?>

				<div class="publications-amount-fr">
					<label id="publications-amount__label-fr" for="<?php echo 'input_' . $id . '[]' ?>" title="<?php echo __("Quantité désiré de brochures en Français", "homegrade-theme__texte-fonctionnel") ?>">fr</label>
					<input type="number" size="1" min="0" name="<?php echo 'input_' . $id . '[]' ?>" />
				</div>
				<div class="publications-amount publications-amount-nl">
					<label id="publications-amount__label-nl" for="<?php echo 'input_' . $id . '[]' ?>" title="<?php echo __("Quantité désiré de brochures en Néerlandais", "homegrade-theme__texte-fonctionnel") ?>">nl</label>
					<input type="number" size="1" min="0" name="<?php echo 'input_' . $id . '[]' ?>" />
				</div>
				<input type="hidden" name="<?php echo 'input_' . $id . '[]' ?>" value="<?php echo $ID_FR ?>" />
				<input type="hidden" name="<?php echo 'input_' . $id . '[]' ?>" value="<?php echo $ID_NL ?>" />
			</div>
		</div>


		<div class="gchoice brochure-order-field">



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