<?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>Secheduled Classes List </header>
    		 <ol class="breadcrumb page-breadcrumb pull-right">
                    <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index-2.html">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                    </li>
                    <li><a class="parent-item" href="#">Profile</a>&nbsp;<i class="fa fa-angle-right"></i></li>
                    <li class="active">Scheduled Class List</li>
             </ol>
    	</div>
    <div class="card card-topline-purple">
    	<div class="card-head">
    		<div id="example4_filter" class="dataTables_filter"><label>Search:
				<input type="search" class="form-control form-control-sm search-boxes input-sm" placeholder="" aria-controls="example4"></label>
			</div><?php echo  $link;?>
    		<div class="tools">
    			<a class="fa fa-repeat btn-color box-refresh" href="javascript:;"></a>
    			<a class="t-collapse btn-color fa fa-chevron-down" href="javascript:;"></a>
    			<a class="t-close btn-color fa fa-times" href="javascript:;"></a>
    		</div>
    	</div>
 	<div class="card-body scroll_table">
	   <div class="table-responsive">
	     <table class="table table-striped custom-table table-hover table table-bordered" style="font-family: sans-serif;font-size: 12px;">
			<thead>
				<tr>
					<th>#</th>
					<th>Status</th>
					<th>Class</th>
					<th>Subject</th>
					<th>From</th>
					<th>To</th>
					<th>Presenter</th>
					<th>Date</th>
					<th>Time start</th>
					<th>Time End</th>
					<th>Duration</th>

				</tr>
			</thead>
		   <tbody>
		   <?php if( count($list) ):$sn=1;
                $count = $this->uri->segment(4);
                foreach($list as $lists ): ?>
				<tr>
					<td ><?php echo  ucfirst($sn);?></td>
					<td>
					 <?php $json2 = json_decode($lists->info);?>
                    <?php //print_r($json2->attendee_urls);
                    foreach($json2->attendee_urls as $key=>$data){
                        $get    = explode("<=>",$data);
                        //print_r($get);
                        if($get[0]==$lists->user_id){
                            $user_id    =  $get[0];
                            //echo $lists->user_id."<br>";
                            $user_url   =  $get[1];
                        }
                    }
                    $todays_date = date("Y-m-d H:i:s");
                    //echo $todays_date."<br>";
                    $today      =   strtotime($todays_date);
                    $stars      =   strtotime($lists->class_date.' '.$lists->course_time);
                    $ends       =   strtotime($lists->class_date.' '.$lists->course_end_time);
                     //echo $ds."<br>";
                    //echo date('Y-m-d H:i:s', $ds);die;
                    ?>
                   <?php if(($today>=$stars)&&($today<$ends)){?>
                    <a href='<?=$user_url?>' class="label label-mini" style="background: linear-gradient(45deg,#FFB64D,#ffcb80);cursor:pointer;">Join Session</a>
                    <?php }else if(($today<$stars)&&($today<$ends)){?>
                        <a href='#' class="label label-info label-mini" style="cursor:pointer;">Upcoming Session</a>
                    <?php }else if ($today>=$ends){?>
                        <a href='#' class="label label-mini" style="background: linear-gradient(45deg,#FF5370,#ff869a);cursor:pointer;">Session Over</a>
                	<?php }else{?>
                        <a href='#' class="label label-mini" style="background: linear-gradient(45deg,#FF5370,#ff869a);cursor:pointer;">Status not Found </a>
                	<?php }?>

					</td>
					<td><?php echo  ucfirst($lists->class);?></td>
					<td ><?php echo  ucwords($lists->subject);?></td>
					<td><?php $d   =  explode(',',$lists->course_duration );//print_r($d);
                        echo date("d M Y", strtotime($d[0]));?></td>
					<td><?php echo date("d M Y", strtotime($d[1]));?></td>
					<td><?php echo  strtolower($lists->teacher);?></td>
					<td><?php  echo date("d M Y", strtotime($lists->class_date));?></td>
					<td><?php echo  date('h:i A', strtotime($lists->course_time));?> </td>
					<td> <?php echo  date('h:i A', strtotime($lists->course_end_time));?></td>
					<td> <?php echo  strtolower($lists->course_running_hours)." Mins";?></td>
					<!--  <td>
    					<div class="progress progress-striped progress-xs">
    						<div style="width: 80%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="80" role="progressbar" class="progress-bar progress-bar-success"></div>
    						</div>
    				</td>-->

					<!-- <td>
						<button class="btn btn-success btn-xs">
							<i class="fa fa-check"></i>
						</button>
						<button class="btn btn-primary btn-xs">
							<i class="fa fa-pencil"></i>
						</button>
						<button class="btn btn-danger btn-xs">
							<i class="fa fa-trash-o "></i>
						</button>
				     </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>
