<?php

/**
 * Theme Name: ESchool
 * Theme URI: http://demo.com/eschool
 * Author: demo.com
 * Author URI: http://demo.com
 * Description: Themes Is WordPress Theme Market
 * @package eschool
 */
get_header();
global $codedokan;
?> 



<?php				
						$obj = get_queried_object();
						$categroy_name = $obj->name;
						?>
						
						
					
					
                            
                	 
                <!--================================
                        Archive-Page-Start
                ===============================-->

            <div class="archive-page">
			
				<div class="row">              
                        <div class="col-lg-12 col-md-12">
                            <div class="video-p-title">
                               <?php echo $categroy_name;?> 
                                <div class="icon-class">
                                    <img src="<?php echo get_template_directory_uri(); ?>/assets/images/icon-image.png" alt="">
                                </div>
                            
                            </div>
                        </div>
                    </div>
					
					
					<?php
								$term = get_queried_object();
                                $cat_name = $term->name;    
                                $cat_slug = $term->slug; 								
							?>
							<?php   
									$args = array( 
										'post_type' => 'routine',
										'posts_per_page' => 1,
										'order' => 'ASC',
										  'tax_query' => array(
											'relation' => 'OR',     
											array(
												'taxonomy' => 'routinecat',
												'field'    => 'slug',
												'terms'    => $cat_slug,
											),
								
											) 
										); 
									$loop = new WP_Query( $args );
									while ( $loop->have_posts() ) : $loop->the_post(); ?>
									
									
                <div class="container">
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                     <tr>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'routine_day', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_one', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_two', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_three', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_four', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_five', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_six', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_seven', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_eight', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_nine', true); ?> </th>
                                   <th scope="col"> <?php echo get_post_meta(get_the_ID(),'schedule_ten', true); ?> </th>

                                  
                                 </tr>
                                </thead>
                                <tbody>

                                    
								 <?php $routines = get_post_meta( get_the_ID(), 'routine_group', true ); 
					if($routines){
					?>
					
					<?php foreach ( (array) $routines as $key => $routine ) { 
							$day_name = $subject_name_one = $subject_name_two = $subject_name_three = $subject_name_four = $subject_name_five = $subject_name_six = $subject_name_seven = $subject_name_eight = $subject_name_nine = $subject_name_ten =  '';
							
							if ( isset( $routine['day_name'] ) ) {
								$day_name = esc_html( $routine['day_name'] );
							}
							if ( isset( $routine['subject_name_one'] ) ) {
								$subject_name_one = esc_html( $routine['subject_name_one'] );
							}
							if ( isset( $routine['subject_name_two'] ) ) {
								$subject_name_two = esc_html( $routine['subject_name_two'] );
							}
							if ( isset( $routine['subject_name_three'] ) ) {
								$subject_name_three = esc_html( $routine['subject_name_three'] );
							}
							if ( isset( $routine['subject_name_four'] ) ) {
								$subject_name_four = esc_html( $routine['subject_name_four'] );
							}
							if ( isset( $routine['subject_name_five'] ) ) {
								$subject_name_five = esc_html( $routine['subject_name_five'] );
							}
							if ( isset( $routine['subject_name_six'] ) ) {
								$subject_name_six = esc_html( $routine['subject_name_six'] );
							}
							if ( isset( $routine['subject_name_seven'] ) ) {
								$subject_name_seven = esc_html( $routine['subject_name_seven'] );
							}
							if ( isset( $routine['subject_name_eight'] ) ) {
								$subject_name_eight = esc_html( $routine['subject_name_eight'] );
							}
							if ( isset( $routine['subject_name_nine'] ) ) {
								$subject_name_nine = esc_html( $routine['subject_name_nine'] );
							}
							if ( isset( $routine['subject_name_ten'] ) ) {
								$subject_name_ten = esc_html( $routine['subject_name_ten'] );
							}
							
							
							
							
							?>
							
									
								 <tr>
                                   <th class="wrpper" scope="row"> <?php echo $day_name; ?> </th>
         
                                    <td class="wrpper">  <?php echo $subject_name_one; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_two; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_three; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_four; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_five; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_six; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_seven; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_eight; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_nine; ?> </td>
                                    <td class="wrpper">  <?php echo $subject_name_ten; ?> </td>

                                 </tr>
								 
								 
								 
								 <?php } ?> <?php } ?>
								 
								 
                
                                </tbody>
                            </table>
                    </div>

                    
                   <div class="col-lg-12 col-md-12"><?php wp_bootstrap_pagination(); ?></div>
						</div>

<?php endwhile; ?> 

                </div>
            </div>
                <!--================================
                        Archive-Page-End
                ===============================-->
        
                    
 
<?php
get_footer();
?>    