<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php

$pageName = basename($_SERVER['PHP_SELF']);

 $m->where("page_name", $pageName);
 $pageNameAccess=$m->get("eduportal_modules_pages_detail");


$m->where("user_id", $_SESSION['user_id']);
$m->where ("branch_id", $_SESSION['branch']);
$m->where("page_id", $pageNameAccess[0]['page_id']);
$access = $m->get("users_privilege_detail");



 $WorkAssignListings = $m->get("eduportal_days_config");

$termID=$_REQUEST['term_id'];
$branchId=$_SESSION['branch'];
 $clssec="SELECT * FROM eduportal_datesheet_config as confg, eduportal_datesheet_details as detail WHERE confg.term_id='$termID' and confg.datesheet_id=detail.datesheet_ids and confg.branch_id='$branchId' ORDER BY detail.Dsheet_detail_id ASC";

//print_r($clssec);

 $classSection = $m->query($clssec);
     
$class_id=$_REQUEST['class_id'];
$section=$_REQUEST['section'];
$detailid=$classSection[0]['Dsheet_detail_id'];

$sql = "SELECT * FROM  eduportal_datesheet_subject_day WHERE detail_sheet_id='$detailid' and branch_id='$branchId' ORDER BY id ASC";
//print_r($sql);
$WorkAssignListings5 = $m->query($sql);


$sessionIDs;
 
  if($_GET["session"]!=NULL ){

      $sessionIDs= $_GET["session"];
    }
    else{
      $sessionIDs= $_SESSION['current_session'];
    }

 ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>View Date Sheet | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   
<style>

.tdStyle{border-bottom:1px solid lightgray;}
.thStyle{background-color:#00AFEF;color:white;}

</style>
  </head>
  <script type="text/javascript">
    


          function getterm(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("term_id").innerHTML=xmlhttp.responseText;
               //  alert(xmlhttp.responseText);

              }

            }

            xmlhttp.open("GET","get_term.php?session_id="+id,true);

            xmlhttp.send();

          }


  </script>

<script src="js/ajax_functions.js"></script> 


  <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">

            <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
                   
             View Date Sheet
           
                   <br><br>
                   
          <div class="row" style="background-color: white;">
           
     <h3>View Date Sheet </h3>

   

    <form class="form-style-7" action="view_datesheet.php" method="Get">

  
              
   <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
 

                   <select name="session" id="session" class="form-control" onChange="getterm(this.value)" >

                              <option value="">Select Session</option>
                       
                        <?php
  
                      $match;
                      if(!isset($_REQUEST['session'])){
                        $match=$_SESSION['current_session'];
                      }else { $match=$_REQUEST['session']; }
                     
   
                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($match==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></option>


                                <?php
                        } ?>

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


                <div class="col-md-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Term</label>
                    <select name="term_id" id="term_id"  data-placeholder="Select" class="chosen-multi-select inputfield form-control" >
                    <option value="">Select Term</option>

                    <?php
                    $m->where("session_id", $sessionIDs);
                    $m->where("branch_id", $_SESSION['branch']);                                     
                    $WorkAssignList = $m->get("eduportal_datesheet_config");

                    foreach($WorkAssignList as $WorkAssignListVal)
                    {

                    $m->where("session_id", $sessionIDs);
                    $m->where("branch_id", $_SESSION['branch']);
                    $m->orderBy("term_title","asc");
                    $m->where("term_id", $WorkAssignListVal['term_id']);                    
                    $TermTitle = $m->get("eduportal_exam_terms");
                     ?>

                       <option <?php if($_REQUEST['term_id']==$WorkAssignListVal['term_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['term_id']; ?>"><?php echo $TermTitle[0]['term_title']; ?></option>

                            <?php
                    } ?>

                </select>

                  
                </div>
              </div> 



              <div class="col-md-4 " style="padding:2px;">
    
        
                <div class="form-group ">
                   
                <button id="month"  type="submit" class="btn btn-primary" style="margin-top: 27px;">Search</button>
              <?php   if(isset($_REQUEST['term_id'])) { ?>
                <a href="print_view_datesheet.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&term_id=<?php echo $_REQUEST['term_id'];?>" id="subuser"target="_blank" class="btn btn-primary" style="margin-top: 27px;">Print </a>

               
                <?php if ($access[0]['edit_access']!=NULL) { ?> 
                  
                <a href="edit_datesheet.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&term_id=<?php echo $_REQUEST['term_id'];?>&session=<?php echo $_REQUEST['session'];?>&Edit=edit" id="subuser"target="_blank" class="btn btn-primary" style="margin-top: 27px;">Edit </a>

              <?php } ?>

                <!-- <a href="<?php echo DOMAIN;?>Production/includes/InsertMe.php?term_id=<?php echo $_REQUEST['term_id'];?>&session=<?php echo $_REQUEST['session'];?>&action=DeleteDateSheet" class="btn btn-danger" style="margin-top: 27px;">Delete </a> -->
                <?php if ($access[0]['delete_access']!=NULL) { ?>

                <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?term_id=<?php echo $_REQUEST['term_id'];?>&session=<?php echo $_REQUEST['session'];?>&action=DeleteDateSheet" style="margin-top: 27px;" onClick="return confirm('Are you sure you want to delete this record');"  class="btn btn-danger">Delete </a>

              <?php } } ?>
                </div>
       
              </div>
             
</form>
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

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

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


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


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

      

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


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


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



<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="LectureTime"> 

<input type="hidden" value="<?php echo $_REQUEST['class_id']; ?>" name="class_id" />
<input type="hidden" value="<?php echo $_REQUEST['section']; ?>" name="section" />


<div style="overflow-x:auto;">

<table id="listofstudents" class="table table-striped table-bordered" style="width:100%;background-color: white;">
        <thead>
            <tr>

          
                <th width="">Class</th>

               <?php 
                  
                  foreach ($WorkAssignListings5 as $dateDats) {  

                   $m->where("day_id", $dateDats['day_id']);
                  $days = $m->get("eduportal_days_config");                  
                             
        ?>         
     
             <th width="" class="center" style="text-align: center;"><?php echo $dateDats['date_exm'];?> <br><?php echo $days[0]['day_name'];?>

              </th>
            
        <?php } ?>

           <th width="3%"></th>

              
                
                
                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 

     $count=1;
     $number1;
      foreach($classSection as $classSec)
      { 
        
      
       //$m->where("active_inactive", 0);
       $m->where("branch_id", $_SESSION['branch']);
       $m->where("class_id", $classSec['class_id']);
       $className = $m->get("edu_class_config");


       $m->where("branch_id", $_SESSION['branch']);
       $m->where("section_id", $classSec['section_id']);
       $sectionName = $m->get("edu_adm_section_detail");

      ?>
 
        <tr>
            
      
        <td> <?php echo $className[0]['Class_Name'];?><br><?php echo $sectionName[0]['section_name'];?></td>

       <?php
        

          for ($x = 1; $x <= count($WorkAssignListings5); $x++) { 

            $row=$classSec['class_id'].$x;


       $shid=$classSec['Dsheet_detail_id'];
       $dayid=$WorkAssignListings5[$x-1]['day_id'];
       $dateexam=$WorkAssignListings5[$x-1]['date_exm'];
       
      

     $sqll = "SELECT * FROM  eduportal_datesheet_subject_day WHERE detail_sheet_id='$shid' and branch_id='$branchId' and day_id='$dayid' and date_exm='$dateexam'";
     //print_r($sqll);
       $SubjectData = $m->query($sqll);

      // $StudentsMarks=json_decode($SubjectData[0]['subject_id'], true);

       $StudentsMarks =(explode(",",$SubjectData[0]['subject_id']));

            ?>

           
            <td style="text-align: center;">
              
              <?php foreach ($StudentsMarks as $Subject) {

                $m->where("branch_id", $_SESSION['branch']);
                $m->where("subject_id", $Subject);
                $subName = $m->get("eduportal_subject_config");
 
              echo "<b>".$subName[0]['subject']."</b><br>";
 }
                 
              ?>


                
            </td>
          <?php } ?>
                 
    
          <td>

            <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?termid=<?php echo $_REQUEST['term_id'];?>&sessionid=<?php echo $_REQUEST['session'];?>&class_id=<?php echo $classSec['class_id'];?>&action=DeleteClassWiseDateSheet" style="padding: 0px 5px; font-size:14px;" onClick="return confirm('Are you sure you want to delete this record');"  class="btn btn-danger"><i class="fa fa-remove"></i> </a>

          </td>


              </tr>


 <?php  }  ?>



           
        </tbody>
        
    </table>

  </div>

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

    <br><br>


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

           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
     
  <?php include('RootMe/js_linksscript.php');?>


   

<!-- <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> -->
 <!-- jQuery -->
    


     <!-- searchable dropdown -->
    
    <link href="autosearch_select/select2.css" rel="stylesheet">
    <link href="autosearch_select/select2-default.css" rel="stylesheet">
    <script src="autosearch_select/select2.min.js"></script>
    
    <script>
    $(function() {
    $('.chosen-select').select2( { width:'100%', maximumSelectionSize: 1 } );
    $(document).ready(function() {
    $(".chosen-multi-select").select2( { width:'100%', } ); }); }); function slideout(){ setTimeout(function(){
    $(".alert-success").fadeOut("slow", function () { });
    $(".alert-danger").fadeOut("slow", function () { }); }, 4000);}
    </script>


  </body>
</html>
