<?php get_header(); ?>
    <!-- Single -->
	<?php 
	    // Single 
	    if (have_posts()):
		while (have_posts()): the_post(); 
		    global $post;
			$strFile = get_post_meta($post -> ID, $key = 'podcast_file', true);
			$sizeFile = get_post_meta($post -> ID, $key = 'size_file', true);
		?>
		
		<div class="press_page">
	    	<div class="bread_in">
	            <?php // Top before content
		        	the_title( '<h1 class="press_heading">', '</h1>' ); 
		        	dimox_breadcrumbs(); 
	        	?>
        	</div>
    	</div>
		
		<section id="listing" class="clear">
	    <div class="press_container">
		
            <div class="before_table clear">
			    <div class="search_something">
				
			        <div class="some_input clear">
				    	<span><?php echo __('Cari File', 'prestasi'); ?></span> <input type="text" name="keyword" placeholder="<?php echo esc_attr(__( 'Ketikkan Sesuatu ...', 'prestasi')); ?>" id="keyword" onkeyup="fetch()"></input>
					</div>
					
					<div class="some_result" id="datafetch"><span class="se_down"><?php re_search_download(); ?></span></div>
					
					<div class="some_cat clear">
				    	<div class="head_cat"><?php echo __('Kategori Download', 'prestasi'); ?></div>
						
			    		<?php 
					    	$taxonomy = 'cat-download';
							$args =  array(
							    'hide_empty' => true,
								'orderby'    => 'name',
								'order'      => 'ASC'
							);
							$terms = get_terms( $taxonomy , $args );
							foreach( $terms as $term ) {
								$term_link = get_term_link( $term, 'cat-download');
								echo '<div class="cat_term clear"><a href="' . $term_link . '">'. $term->name . ' <span style="float: right">' . $term->count . ' File</span></a></div>';
							}
						?>
						
					</div>
					
                </div>
				
				<div class="result_list">
				
				    <div class="down_table">
				        <div class=" clear">
						    <table class="press_tab">
						    	<tr class="top_tab">
								    <td width="200"><h3><?php echo __('Nama File', 'prestasi'); ?></h3></td>
									<td><h3><?php echo __('Keterangan', 'prestasi'); ?></h3></td>
									<td><h3><?php echo __('Kategori', 'prestasi'); ?></h3></td>
									<td><h3><?php echo __('Type', 'prestasi'); ?></h3></td>
									<td></td>
								</tr>
								<tr>
								    <td class="tdrow"><strong><?php the_title(); ?></strong></td>
									<td class="tdrow"><?php the_content(); ?></td>
									<td class="tdcol">
									    <?php
									        $terms = get_the_terms( $post->ID , 'cat-download' );
									        if ( $terms != null ){
												foreach( $terms as $term ) {
													$term_link = get_term_link( $term, 'cat-download');
													echo '<a href="' . $term_link . '">' . $term->name . '</a> ';
													unset($term); 
												} 
											} 
										?>
									</td>
									<td class="tdcol">
									    <?php 
										    $terms = get_the_terms( $post->ID , 'type-file' );
											if ( $terms != null ){
												foreach( $terms as $term ) {
													$term_link = get_term_link( $term, 'type-file');
													echo $term->name;
													unset($term); 
												} 
											} 
										?> 
									</td>
									<td class="tdcol"> 
									    <a download="<?php echo esc_attr( $strFile ); ?>" href="<?php echo esc_attr( $strFile ); ?>"><?php echo __('Download', 'prestasi'); ?></a><br/>
			    		                <span><?php echo __('Size : ', 'prestasi'); ?><?php echo esc_attr( $sizeFile ); ?></span>
									</td>
								</tr>
								
							</table>
						</div>
			        </div>
					
				</div>
				
		    </div>
		</div>
	    </section>
		
		<?php 
		endwhile; 
	    endif; 
	?>
	
<?php get_footer(); ?>