
<?php  include("sessioncheck.php"); ?>
<?php 
/* 
| Developed by: Tauseef Ahmad
| Last Upate: 01-19-2021 08:45 PM
| Facebook: www.facebook.com/ahmadlogs
| Twitter: www.twitter.com/ahmadlogs
| YouTube: https://www.youtube.com/channel/UCOXYfOHgu-C-UfGyDcu5sYw/
| Blog: https://ahmadlogs.wordpress.com/
 */ 
 
 
include_once 'Zoom_Api.php';
//generateJWTKey();
$zoom_meeting = new Zoom_Api();

$data = array();
$data['topic']    = 'Introduction CompuTech Company';
$data['start_date'] = date("Y-m-d h:i:s", strtotime('tomorrow'));
$data['duration']   = 30;
$data['type']     = 2;
$data['password']   = "12345";

try {
  $response = $zoom_meeting->createMeeting($data);
  
/* echo "<pre>";
 print_r($response);
 echo "<pre>";*/
  
  /*echo "Meeting ID: ". $response->id;
  echo "<br>";
  echo "Topic: "  . $response->topic;
  echo "<br>";
  echo "Join URL: ". $response->join_url ."<a href='". $response->join_url ."'>Open URL</a>";
  echo "<br>";
  echo "Meeting Password: ". $response->password;*/
    
  
} catch (Exception $ex) {
    echo $ex;
}


?>
<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Add Live Classes | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
  
<script type="text/javascript">

  $('select').selectpicker();


function getsec(id){

            if (window.XMLHttpRequest) {

              // code for IE7+, Firefox, Chrome, Opera, Safari

              xmlhttp=new XMLHttpRequest();

            } else { // code for IE6, IE5

              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

            }

            xmlhttp.onreadystatechange=function() {

              if (xmlhttp.readyState==4 && xmlhttp.status==200) {

                document.getElementById("txt_section").innerHTML=xmlhttp.responseText;
                // alert(xmlhttp.responseText);

              }

            }

            xmlhttp.open("GET","get_sect_multi.php?class_id="+id,true);

            xmlhttp.send();




          }

function getSubCat(id){
  //alert(id);

    if (window.XMLHttpRequest) {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {

        document.getElementById("subcatgory").innerHTML=xmlhttp.responseText;
       //alert(xmlhttp.responseText);

      }

    }
    xmlhttp.open("GET","get_exp_subcategory.php?id="+id,true);
    xmlhttp.send();
  }
</script> 
  </head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>


  <!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"> -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.css" />

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script>


<!-- <script>
$(document).ready(function(){
  
    $("#div1").fadeOut();
    $("#div2").fadeOut("slow");
    $("#div3").fadeOut(3000);
 
});
</script> -->
  <style>
#snackbar {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #1E90FF;
  color: #fff;
  text-align: right;
  border-radius: 2px;
  padding: 16px;
  position: fixed;
  z-index: 1;
  left: 80%;
  bottom: 30px;
  font-size: 17px;
}

#snackbar.show {
  visibility: visible;
  -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
  from {bottom: 0; opacity: 0;} 
  to {bottom: 30px; opacity: 1;}
}

@keyframes fadein {
  from {bottom: 0; opacity: 0;}
  to {bottom: 30px; opacity: 1;}
}

@-webkit-keyframes fadeout {
  from {bottom: 30px; opacity: 1;} 
  to {bottom: 0; opacity: 0;}
}

@keyframes fadeout {
  from {bottom: 30px; opacity: 1;}
  to {bottom: 0; opacity: 0;}
}
</style>
  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="row" style="background-color: white;">
           
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
   
      

                                    <!-- page content -->
        
          <div class="">
            <div class="page-title">
              <div class="title_left">
                
              </div>

             
            </div>
            <div class="clearfix"></div>
      <h3 style="margin-left: 15px;">Add Live Class</h3>
            <div class="row">
          
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
            
                  <div class="x_content">
          
     
      <form action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left" >
  <?php
  
  $month;
   if(!isset($_GET['liveClsup'])){?>
        <input type="hidden" name="action" value="add_LiveClass" />
        <input type="hidden" name="meeting_id" value="<?php echo $response->join_url;?>">
  <?php $month=date("m");}else {

          $query="select * from eduportal_expense_detail where expense_id =".$_GET['liveClsup'];
          $expdata = $m->query($query);

          $month=$expdata[0]['month_id'];
?>
              <input type="hidden" name="action" value="update_expenses" />
              <input type="hidden" name="expense_id"  value="<?php echo $_GET['liveClsup'];?>">

  <?php } ?>        
          
        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email"> Class Title <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input class="form-control col-md-7 col-xs-12" type="text"  name="class_title" placeholder="" value="<?php echo $expdata[0]['expense_details']; ?>">
                        </div>

                      </div>

              <?php

 
      if($expdata[0]['expense_date']!="" && $expdata[0]['expense_date']!=NULL ) {
        $dates=date("Y-m-d",strtotime($expdata[0]['expense_date']));  

      }else {
        $dates=date("Y-m-d");  
      }
   
                  
                  ?>

              <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Class Date <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="date" id="owner_email" name="class_date" required class="form-control col-md-7 col-xs-12" value="<?php echo $dates; ?>">
                        </div>

                      </div>              
                   

           <div class="item form-group">
                        
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Time <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                         
                           <input class="form-control col-md-7 col-xs-12" type="time" name="class_time" placeholder="" value="<?php echo $expdata[0]['expense_details']; ?>">
                        </div>
                    </div>

          

                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email"> Class <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12 ">
                          <select name="class_id" onChange="getsec(this.value)" class="form-control" >
                     <option value="All">All</option> 
                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("edu_class_config");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>


                            <?php
                    } ?>

                    </select>
                      
                    </div>
            
                      </div>


                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Section <span class="required">*</span> 
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                           <select name="section[]" id="txt_section" class="form-control" multiple >
                      
                   <?php
                              if($_REQUEST['section']!='')
                              { 

                              $m->where("class_id", $_REQUEST['class_id']);    

                              $secondLevel = $m->get("edu_adm_section_detail");
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>
                                <option <?php if($_REQUEST['section']==$secondLevel_val['section_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['section_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['section_name'])); ?></option>

                              <?php }   ?>
                                
                          <?php } ?>

                    </select>
                        </div>

                      </div>

         <!--             <select class="selectpicker" multiple data-live-search="true">
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Relish</option>
</select> -->
                      
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Description  <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input class="form-control col-md-7 col-xs-12" name="description" required autocomplete="off" type="text" value="<?php echo $expdata[0]['expense_amount']; ?>">
                        </div>
                      </div>


                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Youtube Link  <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input class="form-control col-md-7 col-xs-12" name="youtube_link" required autocomplete="off" type="text" value="<?php echo $expdata[0]['youtube_link']; ?>">
                        </div>
                      </div>


                      <div class="ln_solid" style="border-top:none;"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          
                          <button id="send" type="submit" class="btn btn-primary" >Submit</button>
                          <button type="submit" class="btn btn-primary" >Cancel</button>

                        </div>
                      </div>

                    </form>
              
          </div>
                </div>
              </div>
            </div>
          </div>
       
        

        <!-- /page content -->



  </div>
  <div class="clearfix"></div>
</section>           

<?php


$sql = "SELECT * FROM eduportal_add_live_classes as b  ";
$from;
$to;

$branch=$_SESSION['branch'];

 
      if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {
        $from=date("Y-m-d",strtotime($_REQUEST['from']));  

      }else {
        $from=date("Y-m-01");  
      }
     
      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {
        $to=date("Y-m-d",strtotime($_REQUEST['to']));
      }else {
        $to=date("Y-m-t");  
      } 
      
     
    $sql .= "where b.branch_id='$branch' and b.class_date BETWEEN '" .$from. "' AND '" .$to. "' order by liveClass_id desc";


// echo $sql;

$LiveClasses = $m->query($sql);
 //print_r($LiveClasses);
 
     ?>




     <div class="t col-md-12 col-sm-12 col-xs-12">
                <h3>Live Classes List<small> (<?php echo count($LiveClasses);?> records)</small></h3>
              </div>

              
          
          
 <!--    
<form action="add_LiveClass.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&from=<?php echo $_GET['from'];?>&to=<?php echo $_GET['to'];?>">

                
                
          <div class="col-md-12">      
                 <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col1">
                 <div class="form-group ">

                 <label class="required"> From Date</label>
                 <input name="from"  id="from" value="<?php echo $from;?>" type="date" class="form-control"  >
                       
                  </div>
                  </div>                      
             

                  <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col2">

                       <div class="form-group ">

                          <label class="required"> To Date</label>
                              <input name="to" id="to" value="<?php echo $to;?>" type="date" class="form-control"  >
                       
                          </div>
                  </div>  
                  
                  
                  <div class="col-md-1 " style="padding:8px;">
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 24px;">Search</button>
                </div>
              </div> 
              
               <div class="col-md-3 " style="padding:8px;">
                <div class="form-group ">
                <a href="print_expense_report.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&from=<?php echo $_GET['from'];?>&to=<?php echo $_GET['to'];?>&customer=<?php echo $_GET['customer'];?>" target="_blank" class=" btn btn-primary" style="margin-top: 24px;"> Print Report </a>
                </div>
              </div> 
        </div>            
 </form> -->
<?php  if(isset($_SESSION['addsuccessexp'])){?>

<div id="snackbar"><script> toastFunction();</script> Your Recored is Sucessfully Added</div>

<?php  unset($_SESSION['addsuccessexp']); }?>


          
          <?php  if(isset($_SESSION['upsuccessexp1'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Record is updated successfully...
            </div>


          <?php  unset($_SESSION['upsuccessexp1']); }?>
          

          <?php  if(isset($_SESSION['deleteexp1'])){?>


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Danger!</strong> Record is deleted successfully...
            </div>


          <?php  unset($_SESSION['deleteexp1']); }
          ?>

<table id="datatable" class="table table-striped table-bordered"style="background-color: white;">
                      <thead>
                        <tr>
                          <th width="1%">S.No</th>
                           <th width="10%">Class Title</th>
                          <th width="10%">Class Date</th>
                          <th width="8%">Time</th>
                          <th width="10%">Class </th>
                          <!-- <th width="10%">Section </th> -->
                          <th width="20%">Description </th>
                          <th width="8%">Lecture</th>
                          <th width="10%">Action</th>
                         

                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;
$date= date("Y-m-d");

foreach($LiveClasses as $LiveClass){

  $m->where("class_id", $LiveClass['class_id']);
  $className=$m->get("edu_class_config");

  $m->where("liveClass_id", $LiveClass['liveClass_id']);
  $sec=$m->get("eduportal_add_live_classes_section");

  $m->where("section_id", $sec[0]['section_id']);
  $sectionName=$m->get("edu_adm_section_detail");

//print_r($sec);
?>
                        <tr>
                          <td style="text-align:center;"><?php echo $count; $count++;?></td>
                          <td><?php echo $LiveClass['class_title'];?></td>
                          <td><?php echo date("d-M-Y",strtotime($LiveClass['class_date']));?></td>
                          <td><?php echo $LiveClass['class_time'];?></td>
                          <td><?php echo $className[0]['Class_Name'];?></td>
                          <!-- <td><?php echo $sectionName[0]['section_name'];?></td> -->
                          <td><?php echo $LiveClass['description'];?></td>
                          <td><a style="padding: 0px 5px; font-size:14px;" href="<?php echo $LiveClass['meeting_id'];?>" class="btn btn-success" target="_blank">Start</a></td>
                                                  

                          <td>
           <a data-toggle="modal" data-target="#EditLink<?php echo $LiveClass['liveClass_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-success">
                 Edit
                 </a>  



        <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?liveCls=<?php echo $LiveClass['liveClass_id'];?>&action=DeleteLiveClass" style="padding: 0px 5px; font-size:14px;" onClick="return confirm('Are you sure you want to delete this record');"  class="btn btn-danger">Delete </a>


        <!-- Employee Edit Salary Popup start -->


      <div id="EditLink<?php echo $LiveClass['liveClass_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header" style="border-bottom:none;">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title" style="text-align:center;"> Edit OF (<?php echo $LiveClass['class_title']." - ".date("d-M-Y",strtotime($LiveClass['class_date'])); ?>)  </h4>
            </div>

            <div class="modal-body">

<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post"  enctype="multipart/form-data">

           <input type="hidden" name="action" value="EditLink"> 
           <input type="hidden" id="date"  name="linkID" value="<?php echo $LiveClass['liveClass_id']; ?>" />              
                         
                         

                <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  Youtube Link </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $LiveClass['youtube_link'];?>"  class="form-control field" name="youtube_link"/>
                      </div>
                </div>

                 <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  Zoom Invite Link </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $LiveClass['Invite_Link'];?>"  class="form-control field" name="Invite_Link"/>
                      </div>
                </div>

                   

            <div class="modal-footer">

            <button type="submit" style="margin: 30px;" class="btn btn-primary" name="submit" >Submit </button>    

            </div>
                 </form>

          </div>

          </div>

        </div>
      </div>

      <!-- Employee Edit Salary popup ending -->
                          </td>

                        </tr>
<?php } ?>
                      

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

            </div>
          </div>
        </div>
        <!-- /page content -->
  

    
  <?php include('RootMe/js_linksscript.php');?>
  <script src="js/ajax_functions.js"></script>
  </body>
</html>
<script>
function toastFunction() {
  var x = document.getElementById("snackbar");
  x.className = "show";
  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>