<?php include('parent/callMe.php');?>
<?php include('Sessioncheck.php');?>
<?php 

//getting branch details 


$branch=getBranch($m);

$classID=$_REQUEST['class_id'];
$sectionID=$_REQUEST['section'];
$branchID=$_SESSION['branch'];
$sessionID=$_REQUEST['session'];
$monthId=date("m");

if($sectionID=="All"){

$sql = " select * from  edu_student_details as std where std.status='0' and std.session_id='$sessionID' and std.class_id='$classID' AND std.branch_id=".$_SESSION['branch']; 
 
$WorkAssignListings = $m->query($sql);

} else {

  $sql = " select * from  edu_student_details as std where std.status='0' and std.session_id='$sessionID' and std.class_id='$classID' and std.section_id='$sectionID' AND std.branch_id=".$_SESSION['branch']; 
 
$WorkAssignListings = $m->query($sql);

}

//print_r($sql);

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

if($sectionID=="All"){
  
  $sql3 = " select * from  eduportal_datesheet_details as detail, eduportal_datesheet_subject_day as day where detail.class_id='$classID' and detail.Dsheet_detail_id=day.detail_sheet_id and detail.branch_id='$branchID' order by day.id ASC";
//print_r($sql3);
 $subjects = $m->query($sql3);

} else {

  $sql3 = " select * from  eduportal_datesheet_details as detail, eduportal_datesheet_subject_day as day where detail.class_id='$classID' and detail.Dsheet_detail_id=day.detail_sheet_id and detail.section_id='$sectionID' AND detail.branch_id='$branchID' order by day.id ASC";

  $subjects = $m->query($sql3);
}

// print_r($sql3);


 

?>
 <!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">
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<title>Print Date Sheet</title>
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<script type="text/javascript">
 window.print();
</script>
<style> 

.section{width:95%; height:auto;float:left;border-right: 2px solid black;border-right-style:dotted;padding-right:2.5%;margin-left:2%;}
.box{
  width:100%;height:14.5cm;padding:0.5%;
}  
   
tr th {background-color:gray; text-align:center;font-size:14px;border:1px solid gray;}
tr td {border-bottom:1px solid gray;border-left:1px solid gray;padding:.7%;}



.tdalign{text-align:center;border:1px solid black;}
  

body {
  background: rgb(204,204,204);
  font-weight:bold; 
}
page {
  background: white;
  display: block;
  margin: 0 auto;
  margin-bottom: 0.5cm;
  border:1px solid black;
  box-shadow: 0 0 0.5cm rgba(0,0,0,0.5);
  padding:1%;
  height: 21cm; 
}
page[size="A4"] {  
  width: 21cm;
  height: 29.7cm; 
}
page[size="A4"][layout="landscape"] {
  width: 29.7cm;
  height: 21cm;  
}
page[size="A3"] {
  width: 29.7cm;
  height: 42cm;
}
page[size="A3"][layout="landscape"] {
  width: 42cm;
  height: 29.7cm;  
}
page[size="A5"] {
  width: 14.8cm;
  height: 21cm;
}
page[size="A5"][layout="landscape"] {
  width: 21cm;
  height: 14.8cm;  
}
@media print {
  body, page {
    margin: 0;
    box-shadow: none;
    border:none;
  }
}
  </style>

</head>
<body>

<?php 
$WorkAssignValue=$WorkAssignListings;

for($k=0;$k<count($WorkAssignValue);$k++){



  $fee_fine;
  if(date("Y-m-d")>$WorkAssignValue[$k]['challan_duedate']){

  $fee_fine=$branch[0]['late_fee_fine'];
   }
   else {

  $fee_fine=0;

   }



  $total_fee=intVal($other_fee)+intVal($WorkAssignValue[$k]['tutionfee'])+intVal($WorkAssignValue[$k]['transportfee'])+intVal($WorkAssignValue[$k]['balance'])+intVal($WorkAssignValue[$k]['misc_fee']);


         $m->where("student_id", $WorkAssignValue[$k]['student_id']);
         $discount=$m->get("eduportal_student_fee_structure");

$studentID=$WorkAssignValue[$k]['student_id'];
$qry = "select * from  eduportal_monthly_challan where classs_id='$classID' and session_id='$sessionID' and month_id='$monthId' and student_id='$studentID' and branch_id=".$_SESSION['branch'];
//print_r($qry);
$fees = $m->query($qry);
?>

<page size="A4">

<div style="width:100%;">
<?php 

 $array1=array("Institute Copy","Student Copy");

for($i=0;$i<1;$i++){ ?>

<div class="box" >

<div class="section" style="<?php if($i==1){echo 'border-right:none;';}?>">
   
   
  <div style="">
        
        <div style="width: 15%;float: left;">
            <img src="<?php echo DOMAIN.AgentDirectory;?>img/<?php echo $branch[0]['logo']; ?>" style="height:80px;width:90px;" />    
        </div>
        <div style="width:85%;font-size:30px;float: right;margin-top: 25px;text-align:center;"><?php echo $branch[0]['Branch_Name'];?>
          <p style="font-size:13px; text-align:center;">  <?php echo $branch[0]['Branch_Location'];?> </p>
            <?php if($WorkAssignValue[$k]['image']!=NULL){ ?>

            <img src="<?php echo DOMAIN;?>Production/students_pics/<?php echo $WorkAssignValue[$k]['image'];?>" id="preview" class="img-thumbnail" style="width: 85px;height: 91px;margin-top: -93px;float: right;"   />

         <?php }else { ?>   

             <img src="<?php echo DOMAIN;?>Production/images/studenticon.png" id="preview" class="img-thumbnail" style="width: 85px;height: 91px;margin-top: -93px;float: right;" />


         <?php } ?>
        </div>

      </div>
      

     <div style="font-size:12px;text-align:center;color: white;">  <strong> <u> . </u>  </strong> </div>



<p style="text-align: center;margin-top: 4px;">Roll No Slip</p>

   

   <table width="100%" style="font-size:12px;" cellspacing="0">  
   
   
      <tr>  
         <td width="20%" style="border:none;"> Name   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['first_name'];?>  </td>
         
         <td width="20%" style="border:none;"> Father   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['last_name'];?>  </td>

      </tr>
 
    
  <tr>  
     <td width="20%" style="border:none;"> Class </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;"> <?php 
      if($_REQUEST['class_id']!=NULL) {
     echo getClassName($m,$_GET['class_id']);
       } else {
     echo getClassName($m,$WorkAssignValue[$k]['class_id']);
       }?></td>
     
     <td width="20%" style="border:none;"> Section  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo getSectionName($m,$WorkAssignValue[$k]['section_id']);?>  </td>

  </tr>

  
       
  <tr>  

   
     <td width="20%" style="border:none;">  Roll No  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['candidate_roll_no'];?>  </td>

     <td width="20%" style="border:none;">  Fee Status </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;"> 


       <?php 

       foreach ($fees as $details) {
         

       if($details['paid_status']==0 || $details['paid_status']=="0"){ ?>    

                  

                          Unpaid 

                          

                 <?php } else { ?>    


                  

                          Paid 

                          


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

     
      

   
   </table>

   <h3 style="text-align: center;">Date Sheet for (<?php echo $TermName[0]['term_title'];?>)</h3>

   <table width="100%" style="font-size:12px;margin-top:0%;" cellspacing="0">  
   

      <tr>  
         <th width=""> Subjects </th>
         <th width=""> Day </th>
         <th width="" style="text-align:center;border-right:1px solid gray;">  Date </th>
      </tr>

<?php foreach ($subjects as $subject) { 

  $m->where("branch_id", $_SESSION['branch']);
  $m->where("subject_id", $subject['subject_id']);
  $subjectName=$m->get("eduportal_subject_config");

 
  $m->where("day_id", $subject['day_id']);
  $dayName=$m->get("eduportal_days_config");

  ?> 

      <tr>      
         <td width=""> <?php echo $subjectName[0]['subject']; ?></td>
         <td width=""> <?php echo $dayName[0]['day_name']; ?></td>
         <td width="" style="text-align:center;border-right:1px solid gray;"> <?php echo date("d-M-Y",strtotime($subject['date_exm']));?></td>
      </tr>   
     
<?php } ?>

     
 

   </table>


   

</div>
 
<!-- ending section  -->



  </div>  <!-- ending box  -->



  <?php } ?>


</div>



<div style="float:left;width:100%;">
<hr>

<?php 
// now updating the value of k variable to print each next student in same page
$k+=1;


  

if($k<count($WorkAssignValue)){

 $array1=array("Institute Copy","Student Copy");

for($i=0;$i<1;$i++){ ?>

<div class="box" >

<div class="section" style="<?php if($i==1){echo 'border-right:none;';}?>">
   
     <div style="">
        
        <div style="width: 15%;float: left;">
            <img src="<?php echo DOMAIN.AgentDirectory;?>img/<?php echo $branch[0]['logo']; ?>" style="height:80px;width:90px;" />    
        </div>
        <div style="width:85%;font-size:30px;float: right;margin-top: 25px;text-align:center;"><?php echo $branch[0]['Branch_Name'];?>
      
          <?php if($WorkAssignValue[$k]['image']!=NULL){ ?>

            <img src="<?php echo DOMAIN;?>Production/students_pics/<?php echo $WorkAssignValue[$k]['image'];?>" id="preview" class="img-thumbnail" style="width: 80px;height: 80px;margin-top: -27px;float: right;"   />

         <?php }else { ?>   

             <img src="<?php echo DOMAIN;?>Production/images/studenticon.png" id="preview" class="img-thumbnail" style="width: 80px;height: 80px;margin-top: -27px;float: right;" />


         <?php } ?>
        </div>

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

 <br>
    <div style="font-size:1px;text-align:center;color: white;">  <strong> <u>. </u>  </strong> </div>


    <p style="text-align: center;margin-top: -3px;">Roll No Slip</p>
   <table width="100%" style="font-size:12px;" cellspacing="0">  
   
   
      <tr>  
         <td width="20%" style="border:none;"> Name   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['first_name'];?>  </td>
         
         <td width="20%" style="border:none;"> Father   </td>
         <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['last_name'];?>  </td>

      </tr>
 
    
  <tr>  
     <td width="20%" style="border:none;"> Class </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;"> <?php 
      if($_REQUEST['class_id']!=NULL) {
     echo getClassName($m,$_GET['class_id']);
       } else {
     echo getClassName($m,$WorkAssignValue[$k]['class_id']);
       }?></td>
     
     <td width="20%" style="border:none;"> Section  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo getSectionName($m,$WorkAssignValue[$k]['section_id']);?>  </td>

  </tr>

  
       
  <tr>  

   
     <td width="20%" style="border:none;">  Roll No  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">  <?php echo $WorkAssignValue[$k]['candidate_roll_no'];?>  </td>

     <td width="20%" style="border:none;">  Fee Status  </td>
     <td width="30%" style="border-bottom: 1px solid black;text-align:center;border-left:none;">   <?php 

       foreach ($fees as $details) {
         

       if($details['paid_status']==0 || $details['paid_status']=="0"){ ?>                      

                          Unpaid                           

                 <?php } else { ?>                      

                          Paid                          


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

   </table>

   <h3 style="text-align: center;">Date Sheet for (<?php echo $TermName[0]['term_title'];?>)</h3>

   <table width="100%" style="font-size:12px;margin-top:0%;" cellspacing="0">  
   

      <tr>  
         <th width=""> Subjects </th>
         <th width=""> Day </th>
         <th width="" style="text-align:center;border-right:1px solid gray;">  Date </th>
      </tr>

<?php foreach ($subjects as $subject) { 

  $m->where("branch_id", $_SESSION['branch']);
  $m->where("subject_id", $subject['subject_id']);
  $subjectName=$m->get("eduportal_subject_config");

 
  $m->where("day_id", $subject['day_id']);
  $dayName=$m->get("eduportal_days_config");

  ?> 

      <tr>      
         <td width=""> <?php echo $subjectName[0]['subject']; ?></td>
         <td width=""> <?php echo $dayName[0]['day_name']; ?></td>
         <td width="" style="text-align:center;border-right:1px solid gray;"> <?php echo date("d-M-Y",strtotime($subject['date_exm']));?></td>
      </tr>   
     
<?php } ?>   
 

   </table>  
</div>
 
<!-- ending section  -->

  </div>  <!-- ending box  -->

  <?php } 
}// ending if condition

  ?>

</div>

</page>
<br><br>
<?php } ?>

</body>
</html>
