<?php 
	/*	Template Name: Training Schedule  */
?>

<?php

get_header();

$is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );

?>		

<div id="main-content">

<?php if ( ! $is_page_builder_used ) : ?>

	<div class="container">
		<div id="content-area" class="clearfix">
			<div id="left-area">

<?php endif; ?>

			<?php while ( have_posts() ) : the_post(); ?>

				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

				<?php if ( ! $is_page_builder_used ) : ?>

					<h1 class="entry-title main_title"><?php the_title(); ?></h1>
				<?php
					$thumb = '';

					$width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );

					$height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
					$classtext = 'et_featured_image';
					$titletext = get_the_title();
					$thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
					$thumb = $thumbnail["thumb"];

					if ( 'on' === et_get_option( 'divi_page_thumbnails', 'false' ) && '' !== $thumb )
						print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height );
				?>

				<?php endif; ?>

					<div class="entry-content tshead">
                    	
                        <div class="et_pb_with_border et_pb_section et_pb_section_0 et_pb_with_background et_section_regular">
				
				
				
				
					<div class="et_pb_row et_pb_row_0">
				<div class="et_pb_column et_pb_column_4_4 et_pb_column_0    et_pb_css_mix_blend_mode_passthrough et-last-child">
				
				
				<div class="et_pb_module et_pb_text et_pb_text_0 et_pb_bg_layout_light  et_pb_text_align_left">
				
				
				<div class="et_pb_text_inner">
					<h1>Training Schedule</h1>
				</div>
			</div> <!-- .et_pb_text -->
			</div> <!-- .et_pb_column -->
				
				
			</div> <!-- .et_pb_row -->
				
				
			</div> <!-- .et_pb_section -->	
            
            
            <div class="et_pb_section et_pb_section_1">
            	<div class="et_pb_row et_pb_row_1">
                	<div class="et_pb_column et_pb_column_4_4 et_pb_column_0 et_pb_css_mix_blend_mode_passthrough et-last-child">
                    	<table class="t1">
                        	<thead>
                            	<tr>
                            		<th>
                                    	<h4>Select your preferred delivery Method</h3>
                                    </th>
                                    <th>
                                    	<input type="radio" name="delivery_method" value="Classroom" checked/><span> Classroom</span>
                                    </th>
                                     <th>
                                    	<input type="radio" name="delivery_method" value="In-House" /><span> In-House</span>
                                    </th>
                            	</tr>
                            </thead>
                        </table>
                        <table class="t2">
                        	<tbody>
                            	<tr>
                            		<td>
                                    	<h4><?php the_field("heading","option");?></h4>
                                   
                                    	<select>
                                        <?php while(have_rows("Locations","option")): the_row();?>
                                        <option><?php the_sub_field("location","option");?></option>
                                        <?php endwhile;?>
                                        </select>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        
                        <table class="ts">
                        	
                        	<tbody>
                            
    <?php
		$parm = $_GET['place'];
		if($parm == "All Places"){$parm="";}
        $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'product_cat' => 'training-schedule', 'orderby' => 'ASC','meta_key'=> 'place','meta_value'=> $parm );
        $loop = new WP_Query( $args );
		if($loop->have_posts()){
        while ( $loop->have_posts() ) : $loop->the_post(); global $product; 
		$stock = get_post_meta( $post->ID, '_stock', true );
		?>
           		<tr>				<td><h5 class="pt"><?php the_title();?></h5></td>
                                	<td><h5 class="place"><?php echo get_field("place");?></h5></td>
                                    <td><h5 class="date"><?php echo get_field("class_date");?></h5><p class="avail <?php if($stock>0){echo"gr";}else{echo"rd";}?>">Places Available </p></td>
                                    <td><h5 class="days"><?php echo get_field("time_duration");?> Days</h5></td>
                                    <td><h5 class="price"><?php echo $product->get_price_html(); ?></h5></td>
                                    <script>
										//$pdm = jQuery('input[name=delivery_method]:checked').val();
									</script>
                                    <td><a class="enquire" href="javascript:void(0)" onclick="window.location.href='<?php echo get_permalink(267);?>?id=<?php echo $product->get_id();?>&dm='+jQuery('input[name=delivery_method]:checked').val();">Enquire</a></td>
                                    <td><a class="book" href="<?php if($stock>0){echo "javascript:void(0)";}else{echo "javascript:void(0)";}?>"><input type="hidden" value="<?php echo $product->get_id();?>" class="n_id" /><input type="hidden" value="1" class="flag" />Book Now</a><img src="<?php echo get_template_directory_uri();?>/images/bx_loader.gif" alt="loader" class="lod" /></td>
                                </tr>

                

    <?php endwhile;}else{ ?>
    	<h3><?php echo "oops! no courses for the selectd location ";?></h3>
    <?php } wp_reset_query(); ?>

                            
                         
                               <?php /*?> <tr>
                                	<td><h3 class="place">Durban</h3></td>
                                    <td><h4 class="date">Tue 8th May 18</h4><p class="avail">Places Available</p></td>
                                    <td><h4 class="days">5 Days</h4></td>
                                    <td><h4 class="price">R1999</h4></td>
                                    <td><a class="enquire" href="#">Enquire</a></td>
                                    <td><a class="book" href="#">Book Now</a></td>
                                </tr>
                                <tr>
                                	<td><h3 class="place">Cape Town</h3></td>
                                    <td><h4 class="date">Tue 8th May 18</h4><p class="avail">Places Available</p></td>
                                    <td><h4 class="days">5 Days</h4></td>
                                    <td><h4 class="price">R1999</h4></td>
                                    <td><a class="enquire" href="#">Enquire</a></td>
                                    <td><a class="book" href="#">Book Now</a></td>
                                </tr>
                                 <tr>
                                	<td><h3 class="place">Pretoria</h3></td>
                                    <td><h4 class="date">Tue 8th May 18</h4><p class="avail">Places Available</p></td>
                                    <td><h4 class="days">5 Days</h4></td>
                                    <td><h4 class="price">R1999</h4></td>
                                    <td><a class="enquire" href="#">Enquire</a></td>
                                    <td><a class="book" href="#">Book Now</a></td>
                                </tr><?php */?>
                                
                            </tbody>
                        </table>
                    </div>
                </div>
            	
            </div>
					
					</div> <!-- .entry-content -->

				<?php
					if ( ! $is_page_builder_used && comments_open() && 'on' === et_get_option( 'divi_show_pagescomments', 'false' ) ) comments_template( '', true );
				?>

				</article> <!-- .et_pb_post -->

			<?php endwhile; ?>

<?php if ( ! $is_page_builder_used ) : ?>

			</div> <!-- #left-area -->

			<?php get_sidebar(); ?>
            
            <?php get_footer( 'shop' );?>
		</div> <!-- #content-area -->
	</div> <!-- .container -->

<?php endif; ?>

</div> <!-- #main-content -->

<?php

get_footer();
