<?php
include("../db.php");
header("Access-Control-Allow-Origin: * ");

date_default_timezone_set("Asia/Kolkata");

	      $teacher_id=$_REQUEST['teacher_id'];

	
	 $current_date = date('d-m-Y');
        // $arr=$db->getRows("select * from assignment where added_by='".$Added_by."' and date='$date' and session='$session' and school_id= '$school_id' and status='1'");
         
   //     $sql = $db->getRows("select * from liveclass_meet where date >= '$current_date' and teacher_id='$teacher_id'");


        $sql = $db->getRows("select * from liveclass_meet where teacher_id='$teacher_id' ORDER BY id DESC");

    //   echo $sql;
// 	$result = mysql_query($sql);
//   while ($row = mysql_fetch_assoc($result)) 	
	foreach($sql as $row)
	{
	 
	 $d = $row["date"];
	 $t = $row["time"];



        if (strtotime($current_date) <= strtotime($d)) {

        }else{
            continue;
        }



        $livetime = strtotime("$d $t");
	 $curtime  = time();
	 $difference = $curtime - $livetime;

if($difference >= -300 && $difference <= 2400) {
    $flag = 1;
}
else {
    $flag = 0;
}
    	$jsonn[]=array("id" =>$row['id'],"teacher_id" =>$row['teacher_id'],"class" =>$row['class'],"section" =>$row['section'],"endtime"=>$row['endtime'],"duration"=>$row['duration'],
            "date" =>$row['date'],"time" =>$row['time'],"chapter" =>$row['chapter'],"topic" =>$row['topic'],"url" =>$row['url'],"zoom_id"=>$row['zoom_meeting_id'], "status" =>$row['status'], "flag"=>$flag);
    	
 	    $json['status']=1;
		$json['msg']="successful";
		$json['data']=$jsonn;

	    
	}
	

	if(is_array($jsonn) && count($jsonn)>0)
	{  
		echo json_encode($json);    
			
	}else
	{		
	 	echo json_encode(array('status' => 0, 'msg'=>'data not found..!'));
	}
