<?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;
?> 

  
                
              <!--================================
                                     Result-view Page-Start
                               ===============================-->
        <section class="result-view-page">
            <div class="container results_padding">
               

<?php
    global $query_string;
    $query_args = explode("&", $query_string);
    $search_query = array();

    foreach($query_args as $key => $string) {
      $query_split = explode("=", $string);
      $search_query[$query_split[0]] = urldecode($query_split[1]);
    } // foreach
    $the_query = new WP_Query(array(
    'post_type' => 'results',  // Replace with your custom post type name
));
    //$the_query = new WP_Query($test_query);
    if ( $the_query->have_posts() ) : 
    ?>
    <!-- the loop -->

   
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
	
	 <div class="row">
                    <div class="col-lg-12 col-md-12">
					<?php $results = $codedokan['results_title']; if($results){ ?>
					
                        <div class="sec-content">
                            <h1 class="sec-title">
                              <?php echo $results; ?> - <?php echo get_post_meta(get_the_ID(),'exam_name', true); ?>
                            </h1>
                            <div class="secIcon">
                                <img src="<?php echo get_template_directory_uri(); ?>/assets/images/heading-line.png" alt="">
                            </div>
                        </div>
						<?php } ?>
                    </div>
                </div>


	
                <div class="row">
                    <div class="col-lg-12">
                        <div class="result-viewContent">
                            <div class="table-responsive">
                                <table class="table ">
                                   
                                    <tbody class="view-result">
                                        <tr>
                                            <td> <?php echo $codedokan['results_roll']; ?> </td>
                                            <td> <?php echo get_post_meta(get_the_ID(),'class_roll', true); ?> </td>
                                            <td> <?php echo $codedokan['results_name']; ?> </td>
                                            <td> <?php echo get_post_meta(get_the_ID(),'results_student_name', true); ?> </td>
                                              
                                        </tr>
                            
                                        <tr>
                                            <td> <?php echo $codedokan['results_registration']; ?> </td>
                                            <td> <?php echo get_post_meta(get_the_ID(),'class_registration', true); ?> </td>
                                            <td>  <?php echo $codedokan['results_class']; ?> </td>
                                            <td> <?php echo get_post_meta(get_the_ID(),'class_name', true); ?> </td>
                                              
                                        </tr>
                                        <tr>
                                            <td> <?php echo $codedokan['results_group']; ?>  </td>
                                            <td> <?php echo get_post_meta(get_the_ID(),'group_name', true); ?> </td>
                                            <td> <?php echo $codedokan['exam_name']; ?> </td>
                                            <td> <?php echo get_post_meta(get_the_ID(),'exam_name', true); ?> </td>
                                              
                                        </tr>

                            
                
                                        <tr>
                                            <td> <?php echo $codedokan['results_gpa']; ?> </td>
                                            <td> <strong> <?php echo get_post_meta(get_the_ID(),'gpa_mark', true); ?> </strong> </td>
											<td> <?php echo $codedokan['results_results']; ?> </td>
                                            <td> <strong> <?php echo get_post_meta(get_the_ID(),'results', true); ?> </strong> </td>
                                          
                                        </tr>
                
                
                                 
       
       
                                    </tbody>
                                </table>
                           </div>

                           <?php $grade_sheet = $codedokan['grade_sheet']; if($grade_sheet){ ?>
						   <h1 class="grade-title">  
                              <?php echo $grade_sheet; ?>
                            </h1>

                           <div class="table-responsive">
                            <table class="table">
                              <thead class="viw-top">
                                    <tr>
                                      <th scope="col"> <?php echo $codedokan['subject_code']; ?> </th>
                                     <th scope="col"> <?php echo $codedokan['subject_name']; ?> </th>
                                     <th scope="col"> <?php echo $codedokan['grade_number']; ?> </th>
                                     
                                    </tr>
                                </thead> 
                                <tbody class="view-result">
                                   <?php $results = get_post_meta( get_the_ID(), 'results_group', true ); 
					if($results){
					?>
					
					<?php foreach ( (array) $results as $key => $result ) { 
							$subject_code = $subject_name = $grade_mark = '';
							
							if ( isset( $result['subject_code'] ) ) {
								$subject_code = esc_html( $result['subject_code'] );
							}
							if ( isset( $result['subject_name'] ) ) {
								$subject_name = esc_html( $result['subject_name'] );
							}
							if ( isset( $result['grade_mark'] ) ) {
								$grade_mark = esc_html( $result['grade_mark'] );
							}
							?>
									
									<tr>
                                        <td> <?php echo $subject_code; ?> </td>
                                        <td> <?php echo $subject_name; ?> </td>
                                        <td> <?php echo $grade_mark; ?> </td>                                  
                                    </tr>
                                     
    <?php } ?> <?php } ?>
                                      
                                   
                          
            
            
                             
   
   
                                </tbody>
                            </table>
                       </div>
					    <?php } ?>
       
                        </div>
						
						<div style="text-align: center; font-style: italic;"><?php echo $codedokan['published_date'];?> : <?php echo get_the_time("j-m-Y"); ?> </div>
						
                    </div>
                </div>
				
				
				<?php endwhile; ?>

    <!-- end of the loop -->

    <?php wp_reset_postdata(); ?>

<?php else : ?>


    <div class="result-page">
            <div class="container">
                <div class="col-lg-12 col-md-12">
                   
                    <div class="result-content">
                     
                        <form class="codedokan" action="<?php bloginfo('url'); ?>" method="get">
                            <input type="text" placeholder="<?php echo $codedokan['results_input_text']; ?>" value="<?php the_search_query(); ?>" name="s" required>
							<input type="hidden" name="post_type" value="results" />     
                            
                            <button type="submit"><i class="fa fa-search"></i>  <?php echo $codedokan['results_submit_text']; ?> </button>
                           
					    </form>
                    </div>
                    
					 <p style="text-align:center; margin-top : 20px"><?php _e( 'Sorry, no Results Found, Please Try Again.' ); ?></p>
					 
                    
                </div>
            </div>
            
        </div>
		
		


 
 
 
<?php endif; ?> 
            </div>
        </section>
  
                             <!--================================
                                     Result-Page-End
                               ===============================-->
                     
    
		 
<?php
get_footer();
?>    