<?php if( have_rows('variatii_excursie') ): ?>
	<section class="section margin-bottom pachete">
		<div class="row">
			
			<?php $cfValues = array(); //variaila pentru valorile dropdown perioada pachet ?>
			
			<?php while( have_rows('variatii_excursie') ): the_row(); ?>
				
				<?php 
					$de_la = new DateTime(get_sub_field('exc_de_la', false, false));
						$de_la = $de_la->format('d.m.Y');
					$pana_la = new DateTime(get_sub_field('exc_pana_la', false, false));
						$pana_la = $pana_la->format('d.m.Y');
					$cfValue = $de_la.' - '.$pana_la;
					array_push($cfValues, $cfValue ); //completare variabila 
				
				?>
				
				<div class="col-md-12">
					<div class="pachet" >
						<a href="#vacanta-contact" class="scroll" rel="<?php echo $cfValue; ?>">
							<span class="icon-cta btn-success">
								<span class="display-table">
									<span class="display-table-cell">
										<i class="fa fa-plus" aria-hidden="true"></i>
									</span>
								</span>
							</span>
							<span>
							
								<span class="pachet-head">
									<?php echo $de_la; ?> - <?php echo $pana_la; ?>
								</span>
								<span class="pachet-body">
									<?php the_sub_field('exc_desc'); ?>
								</span>
							
							</span>
						</a>
					</div>
				</div>		
			<?php endwhile; ?>
			
			<script>
				jQuery(document).ready(function(){
					var cfValuesJS = <?php echo json_encode($cfValues); ?>;
				
					
					var mySelect = jQuery('[name="perioada"]');
					
					jQuery.each(cfValuesJS, function(val, text) {
						mySelect.append(
							jQuery('<option></option>').val(text).html(text)
						);
					});
				
				});
				
				jQuery(document).ready(function() {
					jQuery('.pachet a').click(function() {
						var cfCurrentVal = jQuery(this).attr('rel');
						jQuery("[name='perioada']").val(cfCurrentVal);
					});
				});
				
			</script>
			
		</div>
		<div style="text-align: right;">
			<a href="#vacanta-contact" class="btn btn-danger btn-lg scroll"><?php _e('Înscrie-te acum!', 'theme'); ?></a>
		</div>
	</section>
<?php else: ?>	

	<style>
		.perioada{
			display: none;
		}
	</style>

<?php endif; ?>	