<?php defined('BASEPATH')or exit("NO DIRECT ACCESS iS ALLOWED");?>

					<div class="col-md-12 padding_sidebar">
            <div class="row" style="margin-right:0px ;margin-left:0px;">
            		<div class="card-head profile-categories_bread"><header>Upcoming Sessions</header>
            		<div class="pull-left"><?php echo  $link;?></div>
                		 <ol class="breadcrumb page-breadcrumb pull-right">
                                <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="<?=site_url("Teacher")?>">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li class="active">Upcoming Classes</li>

                         </ol>
            			<div class="pull-left">
            			            <a href="#" class="btn btn-sm btn-social btn-github pull-right button_collapse">
            						<i class="fa fa-fw fa-search  text-green"></i>Search</a>

            						</div>
												<!-- <button class="btn btn-sm btn-social btn-github pull-right" onclick="loadlink();">Refresh</button> -->
                	</div>
                <div class="card card-topline-purple">
                	<div class="card-head">
                	</div>
                  <div class="table-responsive">
                     <div id="tableContainer2" class="container-tb">
                       <table class="table table_containers " >
                      <thead>
                        <tr>
                          <th>#</th>
                          <th>Class Id</th>
                          <th>Date</th>
													<th>Start At</th>
                          <th>End At</th>
                          <th>Status</th>
                          <th>Class</th>
                          <th>Subject</th>
                          <th>Subject Code</th>
													<th>Faculty</th>
													<!-- <th>Recording</th> -->
                        </tr>
                      </thead>
                       <tbody>
                       <?php if( count($list) ):$sn=1;
												$count = $this->uri->segment(4);
												foreach($list as $lists ): ?>
												<?php

												$asia_calcutta_date_start = DateTime::createFromFormat('Y-m-d H:i',date("Y-m-d H:i",strtotime($lists->class_date." ".$lists->class_start_time)),new DateTimeZone('Asia/Calcutta'));
												$user_timezone_start = clone $asia_calcutta_date_start;
												$user_timezone_start->setTimeZone(new DateTimeZone($this->session->userdata('user_timezone')));

												$asia_calcutta_date_end = DateTime::createFromFormat('Y-m-d H:i',date("Y-m-d H:i",strtotime($lists->class_date." ".$lists->class_end_time)),new DateTimeZone('Asia/Calcutta'));
												$user_timezone_end = clone $asia_calcutta_date_end;
												$user_timezone_end->setTimeZone(new DateTimeZone($this->session->userdata('user_timezone')));

												//echo 'UTC:  ' . $asia_calcutta_date->format('Y-m-d g:i A');  // UTC:  2011-04-27 2:45 AM
												//echo 'ACST: ' . $acst_date->format('Y-m-d g:i A'); // ACST: 2011-04-27 12:15 PM

												$todays_date       =   date("Y-m-d H:i");
												$today             =   strtotime($todays_date);
												$starts            =   strtotime($user_timezone_start->format('Y-m-d H:i'));
												$ends              =   strtotime($user_timezone_end->format('Y-m-d H:i'));
												$time1             =   $starts - (10 * 60);
												$less_10_min_start_time = date("Y-m-d H:i", $time1);
												$stars             =    strtotime($less_10_min_start_time);
												if(($ends>=$today)){
												?>
                        <tr <?php if(($today>=$stars)&&($today<$ends)){ ?>style="background-color:#bfcadacf;"<?php }?>>
                          <td><?php echo  ucfirst($sn);?></td>
                          <td><?php echo  $lists->class_tag_id;?></td>
                          <td><?php echo  $user_timezone_start->format('d-M-Y');?></td>
                          <td><?php echo  $user_timezone_start->format('g:i A');?></td>
                          <td><?php echo  $user_timezone_end->format('g:i A');?></td>
                          <td>

														<?php if(($today>=$stars)&&($today<$ends)){?>
                              <a href='<?=$lists->attendee_url?>' class="label label-mini" style="background: #2ecc71;cursor:pointer;" >Join Class</a>
                              <?php }else if(($today<$stars)&&($today<$ends)){?>
                                  <a href='#' class="label label-info label-mini" style="cursor:default;">Upcoming </a>
                          <?php    }else if ($today>=$ends){?>
                                  <a href='#' class="label label-mini" style="background: linear-gradient(45deg,#FF5370,#ff869a);cursor:default;">Over</a>
                          <?php    }else{?>
                                  <a href='#' class="label label-mini" style="background: linear-gradient(45deg,#FF5370,#ff869a);cursor:default;">Status not Found </a>
                          <?php    }?>

                          </td>
                         <td><?php echo     strtoupper($lists->class);?></td>
                          <td><?php echo     strtoupper($lists->subject);?></td>
                          <td><?php echo     strtoupper($lists->subject_code);?></td>
													  <td><?php echo     strtoupper($lists->presenter);?></td>

                        </tr>
                    <?php $sn++;unset($json2);unset($user_id);unset($user_url);unset($stars);unset($ends);unset($today);

									}?>
                        <?php endforeach; ?>
                        <?php else : ?>
                        <tr><td><a href="#">No Record Found</a></td></tr>
                         <?php endif; ?>
                      </tbody><?php $count++; ?>

                  </table>
                  </div>
                  </div>
            </div>
            </div>
				</div>
      </div>

				</div>


					<div class='wrap_search'>
					<div class='content content_pop'>
						<div class="col-md-12">
							  <?=form_open('Student/upcoming_classes_search');?>
								<div class="col-md-10">
									<div class="col-md-2  padding_20 emp_style">
										<select id='sel_category' class="form-control input-sm" name="subject" >
												<option value="" >Select Subject</option>
												<?php
												foreach($subject as $category1){
													echo "<option value='".$category1['id']."'>".strtoupper($category1['category_code'].$category1['class_code'].$category1['subject_code'])." | ".strtoupper($category1['subject'])."</option>";
												}
												?>
										</select>
									</div>
									<div class="col-md-2">
										<div class="col-md-12  padding_20 emp_style">
											 <input type="text" name="dates" class="form-control " id="reservation">
										</div>
								  </div>
									<div class="col-md-2">
										<div class="col-md-12  padding_20 emp_style">
											 <select name="seach_term" class="form-control ">
												<option value="or">OR</option>
												 <option value="and">AND</option>
											 </select>
										</div>
								  </div>
									<div class="col-md-2">
										<div class="col-md-12  padding_20 emp_style">
											 <select name="order_by" class="form-control ">
												 <option value="asc">Ascending</option>
												 <option value="desc">Desending</option>
											 </select>
										</div>
								  </div>
									<div class="col-md-2  btn_mrgin1 emp_style">
										<?php echo form_submit('search','search',['class'=>'btn btn-primary btn_mrgin btn-sm']);?>
									</div>
								</div>
							<?php echo form_close();?>
							</div>
					</div>
				</div>

 <script>
function loadlink(){
	console.clear();
    $('#refreshbody').load('<?php echo site_url("Student/recent-classes");?>',function () {
         $(this).unwrap();

    });
}

// loadlink(); // This will run on page load
// setInterval(function(){
//     loadlink() // this will run after every 5 seconds
// }, 15000);
</script>
