<?php
$bosa_travel_agency_organizationoneID = get_theme_mod( 'bosa_travel_agency_organizations_image_one', '' );
$bosa_travel_agency_organizationcategoryone = get_theme_mod( 'bosa_travel_agency_organization_category_one', '' );

$bosa_travel_agency_organizationtwoID = get_theme_mod( 'bosa_travel_agency_organizations_image_two','');
$bosa_travel_agency_organizationcategorytwo = get_theme_mod( 'bosa_travel_agency_organization_category_two', '' );

$bosa_travel_agency_organizationthreeID = get_theme_mod( 'bosa_travel_agency_organizations_image_three', '' );
$bosa_travel_agency_organizationcategorythree = get_theme_mod( 'bosa_travel_agency_organization_category_three', '' );

$bosa_travel_agency_organizationfourID = get_theme_mod( 'bosa_travel_agency_organizations_image_four', '' );
$bosa_travel_agency_organizationcategoryfour = get_theme_mod( 'bosa_travel_agency_organization_category_four', '' );

$bosa_travel_agency_organizationfiveID = get_theme_mod( 'bosa_travel_agency_organizations_image_five', '' );
$bosa_travel_agency_organizationcategoryfive = get_theme_mod( 'bosa_travel_agency_organization_category_five', '' );

$bosa_travel_agency_organizationsixID = get_theme_mod( 'bosa_travel_agency_organizations_image_six', '' );
$bosa_travel_agency_organizationcategorysix = get_theme_mod( 'bosa_travel_agency_organization_category_six', '' );


$bosa_travel_agency_organization_array = array();
$bosa_travel_agency_has_organizations = false;
if( !empty( $bosa_travel_agency_organizationoneID ) || !empty( $bosa_travel_agency_organizationcategoryone ) ){
	$bosa_travel_agency_organization_one  = wp_get_attachment_image_src( $bosa_travel_agency_organizationoneID ,'bosa-travel-agency-420-300');
 	if ( is_array(  $bosa_travel_agency_organization_one ) ){
 		$bosa_travel_agency_has_organizations = true;
   	 	$bosa_travel_agency_organizations_one = $bosa_travel_agency_organization_one[0];
   	 	$bosa_travel_agency_organization_array['image_one'] ['ID'] = $bosa_travel_agency_organizations_one;	 	
  	}
  	if ( !empty($bosa_travel_agency_organizationcategoryone) ){
 		$bosa_travel_agency_has_organizations = true;
   	 	$bosa_travel_agency_organization_array['image_one']['category'] = $bosa_travel_agency_organizationcategoryone;	
  	}
}
if( !empty( $bosa_travel_agency_organizationtwoID ) || !empty( $bosa_travel_agency_organizationcategorytwo ) ){
	$bosa_travel_agency_organization_two = wp_get_attachment_image_src( $bosa_travel_agency_organizationtwoID,'bosa-travel-agency-420-300');
	if ( is_array(  $bosa_travel_agency_organization_two ) ){
		$bosa_travel_agency_has_organizations = true;	
        $bosa_travel_agency_organizations_two = $bosa_travel_agency_organization_two[0];
        $bosa_travel_agency_organization_array['image_two'] ['ID']= $bosa_travel_agency_organizations_two; 
	}
	if ( !empty($bosa_travel_agency_organizationcategorytwo) ){
		$bosa_travel_agency_has_organizations = true;
	 	$bosa_travel_agency_organization_array['image_two']['category'] = $bosa_travel_agency_organizationcategorytwo;	
  	}
}
if( !empty( $bosa_travel_agency_organizationthreeID ) || !empty( $bosa_travel_agency_organizationcategorythree ) ){	
	$bosa_travel_agency_organization_three = wp_get_attachment_image_src( $bosa_travel_agency_organizationthreeID,'bosa-travel-agency-420-300');
	if ( is_array(  $bosa_travel_agency_organization_three ) ){
		$bosa_travel_agency_has_organizations = true;
      	$bosa_travel_agency_organizations_three = $bosa_travel_agency_organization_three[0];
      	$bosa_travel_agency_organization_array['image_three'] ['ID']= $bosa_travel_agency_organizations_three;		
  	}
  	if ( !empty($bosa_travel_agency_organizationcategorythree) ){
		$bosa_travel_agency_has_organizations = true;
	 	$bosa_travel_agency_organization_array['image_three'] ['category'] = $bosa_travel_agency_organizationcategorythree;	
  	}
}
if( !empty( $bosa_travel_agency_organizationfourID ) || !empty( $bosa_travel_agency_organizationcategoryfour ) ){	
	$bosa_travel_agency_organization_four = wp_get_attachment_image_src( $bosa_travel_agency_organizationfourID,'bosa-travel-agency-420-300');
	if ( is_array(  $bosa_travel_agency_organization_four ) ){
		$bosa_travel_agency_has_organizations = true;
      	$bosa_travel_agency_organizations_four = $bosa_travel_agency_organization_four[0];
      	$bosa_travel_agency_organization_array['image_four'] ['ID'] = $bosa_travel_agency_organizations_four;	
  	}
  	if ( !empty($bosa_travel_agency_organizationcategoryfour) ){
		$bosa_travel_agency_has_organizations = true;
	 	$bosa_travel_agency_organization_array['image_four'] ['category'] = $bosa_travel_agency_organizationcategoryfour;	
  	}
}
if( !empty( $bosa_travel_agency_organizationfiveID ) || !empty( $bosa_travel_agency_organizationcategoryfive ) ){	
	$bosa_travel_agency_organization_five = wp_get_attachment_image_src( $bosa_travel_agency_organizationfiveID,'bosa-travel-agency-420-300');
	if ( is_array(  $bosa_travel_agency_organization_five ) ){
		$bosa_travel_agency_has_organizations = true;
      	$bosa_travel_agency_organizations_five = $bosa_travel_agency_organization_five[0];
      	$bosa_travel_agency_organization_array['image_five'] ['ID'] = $bosa_travel_agency_organizations_five;	
  	}
  	if ( !empty($bosa_travel_agency_organizationcategoryfive) ){
		$bosa_travel_agency_has_organizations = true;
	 	$bosa_travel_agency_organization_array['image_five'] ['category'] = $bosa_travel_agency_organizationcategoryfive;	
  	}
}
if( !empty( $bosa_travel_agency_organizationsixID ) || !empty( $bosa_travel_agency_organizationcategorysix ) ){	
	$bosa_travel_agency_organization_six = wp_get_attachment_image_src( $bosa_travel_agency_organizationsixID,'bosa-travel-agency-420-300');
	if ( is_array(  $bosa_travel_agency_organization_six ) ){
		$bosa_travel_agency_has_organizations = true;
      	$bosa_travel_agency_organizations_six = $bosa_travel_agency_organization_six[0];
      	$bosa_travel_agency_organization_array['image_six'] ['ID'] = $bosa_travel_agency_organizations_six;	
  	}
  	if ( !empty($bosa_travel_agency_organizationcategorysix) ){
		$bosa_travel_agency_has_organizations = true;
	 	$bosa_travel_agency_organization_array['image_six'] ['category'] = $bosa_travel_agency_organizationcategorysix;	
  	}
}

$bosa_travel_agency_product_cat = bosa_travel_agency_get_post_categories();

if( !get_theme_mod( 'bosa_travel_agency_disable_organizations_section', true ) && ( $bosa_travel_agency_has_organizations || get_theme_mod('bosa_travel_agency_organizations_title') || get_theme_mod('bosa_travel_agency_organizations_sub_title') ) ){ ?>
	<section class="section-organization-area">
		<?php if( get_theme_mod('bosa_travel_agency_organizations_title') || get_theme_mod('bosa_travel_agency_organizations_sub_title') ){ ?>
			<div class="section-title-wrap col-lg-6 col-md-8 offset-lg-3 offset-md-2">
				<h2 class="organization-section-title">	
					<?php echo esc_html( get_theme_mod('bosa_travel_agency_organizations_title') ); ?>
				</h2>
				<p>
					<?php echo esc_html( get_theme_mod('bosa_travel_agency_organizations_sub_title') ); ?>
				</p>
			</div>
		<?php } ?>
		<div class="content-wrap">
			<?php foreach( $bosa_travel_agency_organization_array as $bosa_travel_agency_each_organization ){ ?>
				<article class="organization-items">
					<?php if ( isset( $bosa_travel_agency_each_organization['ID'] )  && !empty( $bosa_travel_agency_each_organization['ID'] ) ){ 
							$bosa_travel_agency_cat_url = '';
							if( isset( $bosa_travel_agency_each_organization['category'] ) && !empty( $bosa_travel_agency_each_organization['category'] ) ) {
								$bosa_travel_agency_cat_url = $bosa_travel_agency_each_organization['category'];
							}
						?>
						<figure class= "featured-image">
							<a href="<?php echo esc_url( get_category_link( $bosa_travel_agency_cat_url ) ); ?>">
								<img src="<?php echo esc_url( $bosa_travel_agency_each_organization['ID'] ); ?>">
							</a>	
						</figure>
					<?php } ?>
					<?php if ( isset( $bosa_travel_agency_each_organization['category'] ) && !empty( $bosa_travel_agency_each_organization['category'] ) ){ ?>
						<h5 class="entry-title">
							<a href="<?php echo esc_url( get_category_link( $bosa_travel_agency_each_organization ['category'] ) ); ?>">
								<?php echo esc_html($bosa_travel_agency_product_cat[$bosa_travel_agency_each_organization['category'] ] ); ?>
							</a>	
						</h5>
					<?php } ?>
				</article>	
			<?php } ?>
		</div>
	</section>
<?php } 

