<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php
 $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);


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

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

    $m->where("branch_id", $_SESSION['branch']);
  $branch=$m->get("edu_branch_config");


  $m->where("term_id", $_REQUEST['term_id']);
  $m->where("branch_id", $_SESSION['branch']);
  $TermName=$m->get("eduportal_exam_terms");

  $m->where("session_id", $session);  
  $sessionName=$m->get("edu_session_config");

  $m->where("branch_id", $_SESSION['branch']);
  $signatures = $m->get("eduportal_upload_acadmic_signature");

 ?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Print Date Sheet</title>
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<script type="text/javascript">
 // window.print();
</script>
<style type="text/css">



.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}

tr th {border:1px solid black;text-align:center;background-color:lightgray;font-size:14px;}
tr td {border-bottom:1px solid black;border-left:1px solid black;font-size:14px;padding:3px;}
  

@media print {
    #Header, #Footer { display: none !important; }
}
@media screen
   {
      p.bodyText {font-family:verdana, arial, sans-serif;}
   }

   @media print
   {
      p.bodyText {font-family:georgia, times, serif;}
   }
   @media screen, print
   {
      p.bodyText {font-size:10pt}
   }
   @media print {
  a[href]:after {
    content: none !important;
  }
}
</style>
</head>
<body>



<div style="text-align:center;font-size:25px;font-weight:bold;margin:0 auto;"><?php echo $branch[0]['Branch_Name'];?> </div> 


<div style="text-align:center;font-size:14px;"><?php echo $branch[0]['Branch_Location']." Cell: ".$branch[0]['Owner_no'];?> </div>

<div style="text-align:center;font-size:25px;font-weight:bold;margin:0 auto;">Date Sheet For (<?php echo $TermName[0]['term_title'];?>)</div>
<hr style="width:100%;">

<!-- <div style="width:33%; float:left; "> <b> Class:</b> <?php echo $className[0]['Class_Name'];?> </div>

<div style="width:33%; float:left; "> <b> Section:</b> <?php echo $sectionName[0]['section_name'];?> </div> -->



<br>

<p>Session: <?php echo $sessionName[0]['session_year'];?></p>
  <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 date("d-M-Y",strtotime($dateDats['date_exm']));?> <br><?php echo $days[0]['day_name'];?>

              </th>
            
        <?php } ?>

              
                
                
                
            </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 as day, eduportal_subject_config as sub  WHERE sub.subject_id=day.subject_id and day.detail_sheet_id='$shid' and day.branch_id='$branchId' and day.day_id='$dayid' and day.date_exm='$dateexam'";
    // print_r($sqll);
       $SubjectData = $m->query($sqll);*/

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

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

            ?>

           
            <td style="text-align: center; border-right: 1px solid black;">
              
              <?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>";
                }
                 
              ?>


                 <div class="form-group ">
                 
     
                  
                </div>

            </td>
          <?php } ?>
                 
    



              </tr>


 <?php  }  ?>


        
           
        </tbody>
        
    </table>
    <br><br><br><br>
    <?php if ($_SESSION['branch']==81) { ?>

        <div style="width:100%;font-size:13px;text-align:center;float:left;margin-top:5px;">

        <img src="images/ume-al-qura-new.PNG" style="height:350px;width:100%;" />

        </div>

   <?php } else { ?>

     <p style="text-align:center;">
        <?php echo $brid[0]['datesheet_instructions'];?>
    </p>

    <?php } ?>

    <p style="float: right;margin: -60px 50px 0px 0px;">
    <?php if($signatures[0]['teacher_exam_signature']!=NULL){ ?>
                        
            <img src="<?php echo DOMAIN;?>Production/signatures/<?php echo $signatures[0]['teacher_exam_signature'];?>" id="preview" class="img-thumbnail" style="width:130px;height:110px;"   />

         <?php } ?>
    </p>
    <br><br>
    <p style="text-align: right;">Controller Of Examination: _______________________________</p>
</body>
</html>
