<?php include('includes/config.php');?>
<?php include('includes/session_check.php');?>
<?php




if($_REQUEST['student']!=NULL){


       $db->where("status", '0');
       $db->where("student_id", $_REQUEST['student']);
       $WorkAssignListVal = $db->get("edu_student_details");

      }

        $db->where("class_id", $WorkAssignListVal[0]['class_id']);
        $class=$db->get("edu_class_config");

         $db->where("section_id", $WorkAssignListVal[0]['section_id']);
        $section=$db->get("edu_adm_section_detail");

      


     $default;
    
    if($_GET["month"]!=NULL ){
      $default= $_GET["month"];
    }
    else{
      $default= date("m");
    }
  
      $db->where("Month_Id", $default);
      $month_name=$db->get("eduportal_month_config");
 
     ?>



<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Student Profile | EduPortal</title>

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    
    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
<style>


.thStyle{background-color:gray;color:white;}

tr th {padding:1.5%;border:1px solid white;}
tr td {padding:1%;}


@media only screen and (max-width: 768px) {

/* For mobile phones: */
.popup_style{margin-top:20%;}

}
</style>


    
  </head>
<script type="text/javascript">
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
{
return false;
}
return true;
}
function alpha(e) {
var k;
document.all ? k = e.keyCode : k = e.which;
return ((k > 64 && k < 91) || (k > 96 && k < 123) || (k == 8) || (k == 32));
}


</script>  

<script>
function showResult(str) {
  if (str.length==0) { 
    document.getElementById("livesearch").innerHTML="";
    document.getElementById("livesearch").style.border="0px";
    return;
  }
  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 (this.readyState==4 && this.status==200) {
      document.getElementById("livesearch").innerHTML=this.responseText;
      document.getElementById("livesearch").style.border="1px solid #A5ACB2";
      //alert(this.responseText);
    }
  }
  xmlhttp.open("GET","livesearch.php?q="+str,true);
  xmlhttp.send();
}
</script>


<script>
  function confirmation(id,b) {
    var txt;
    var r = confirm("Are you sure you want to delete this record ?");
    if (r == true) {
        delete_student(id,b);
    } else {
        return false;
    }
    
  }
</script>


<script>  



function PayFullFee() {

 //alert("786");
 // others fee parameters
 var adm=document.getElementById("adm").value;
 var pap=document.getElementById("pap").value;
 var lab=document.getElementById("lab").value;
 var lib=document.getElementById("lib").value;
 var other=document.getElementById("other").value;
//alert(adm);
// general parameters to submit the fee
 var student=document.getElementById("student").value;
 var fine=document.getElementById("fine").value;
 var challan_id=document.getElementById("challan_id").value;
 var fee_recv_sms=document.getElementById("fee_recv_sms").value;
 var std_name=document.getElementById("std_name").value;
 var std_no=document.getElementById("std_no").value;
 var totalAmount=document.getElementById("totalAmount").value;
//alert(totalAmount);


 others=parseFloat(adm)+parseFloat(pap)+parseFloat(lab)+parseFloat(lib)+parseFloat(other);
 var collected=parseFloat(others)+parseFloat(totalAmount);

 // alert(others+"==="+totalAmount);

   if (window.XMLHttpRequest) {
      xmlhttp=new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  xmlhttp.onreadystatechange=function() {

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

       if(xmlhttp.responseText=="1" || xmlhttp.responseText==1){
         
          document.getElementById("paynow").style.display="none";
          document.getElementById("pay").style.display="none";
          document.getElementById("fullpaid").style.display="block";

       }// ending main if condition 

      }

    }


  xmlhttp.open("GET","PayFullFee.php?action=PayChallan&adm="+adm+"&paper="+pap+"&lab="+lab+"&lib="+lib+"&other="+other+"&collected="+collected+"&challan_id="+challan_id+"&fee_recv_sms="+fee_recv_sms+"&student="+student+"&fine="+fine+"&std_name="+std_name+"&std_no="+std_no+"&totalAmount="+totalAmount,true);
  //xmlhttp.open("GET","PayFullFee.php",true);

  xmlhttp.send();

}


 </script>
  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
        <?php include('includes/sidebar.php');?>
          <?php include('includes/header.php');?>
          <div class="left_col scroll-view">
           
            <!-- /menu footer buttons -->
            <div class="sidebar-footer hidden-small">
              <a data-toggle="tooltip" data-placement="top" title="Settings">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="FullScreen">
                <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="Lock">
                <span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="Logout" href="login.html">
                <span class="glyphicon glyphicon-off" aria-hidden="true"></span>
              </a>
            </div>
            <!-- /menu footer buttons -->
          </div>
        </div>

       
        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
              <div class="title_left">
                <h3>Student Profile</h3>
              </div>

              <div class="title_right">
                <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
                  <div class="input-group">
                    <input type="text" class="form-control" placeholder="Search for...">
                    <span class="input-group-btn">
                      <button class="btn btn-default" type="button">Go!</button>
                    </span>
                  </div>
                </div>
              </div>
            </div>
            
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Student Report</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <div class="col-md-3 col-sm-3 col-xs-12 profile_left">
                      <div class="profile_img">
                        <div id="crop-avatar">
                          <!-- Current avatar -->
                           <?php if($WorkAssignListVal[0]['image']!=NULL){ ?>
      
      <img src="<?php echo DOMAIN;?>AgentPanel/students_pics/<?php echo $WorkAssignListVal[0]['image'];?>" id="preview" class="img-thumbnail" style="width:180px;height:190px;"   />

   <?php }else { ?>   

       <img src="<?php echo DOMAIN;?>AgentPanel/img/upload.png" id="preview" height="170px" class="img-thumbnail" width="180px"  />


   <?php } ?>
                        </div>
                      </div>
                      <h3 class="tdStyle" width="60%"> <?php  if($WorkAssignListVal[0]['first_name']!=NULL){echo $WorkAssignListVal[0]['first_name'];}else {echo "--";};?></h3>

                      <ul class="list-unstyled user_data">
                        <li><b>Roll No: </b> <?php  if($WorkAssignListVal[0]['candidate_roll_no']!=NULL){echo $WorkAssignListVal[0]['candidate_roll_no'];}else {echo "--";};?>
                        </li>

                        <li>
                          <b>Class: </b> <?php  if($class[0]['Class_Name']!=NULL){echo $class[0]['Class_Name'];}else {echo "--";};?>
                        </li>

                         <li>
                          <b>Section: </b> <?php  if($section[0]['section_name']!=NULL){echo $section[0]['section_name'];}else {echo "--";};?>
                        </li>

                        <li>
                          <b>Cell No: </b> <?php  if($WorkAssignListVal[0]['cell_no']!=NULL){echo $WorkAssignListVal[0]['cell_no'];}else {echo "--";};?>
                        </li>
                      </ul>

                      <a class="btn btn-success"><i class="fa fa-edit m-right-xs"></i>Edit Profile</a>
                      <br />

                      <!-- start skills -->
                      <h4>Skills</h4>
                      <ul class="list-unstyled user_data">
                        <li>
                          <p>Web Applications</p>
                          <div class="progress progress_sm">
                            <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="50"></div>
                          </div>
                        </li>
                        <li>
                          <p>Website Design</p>
                          <div class="progress progress_sm">
                            <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="70"></div>
                          </div>
                        </li>
                        <li>
                          <p>Automation & Testing</p>
                          <div class="progress progress_sm">
                            <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="30"></div>
                          </div>
                        </li>
                        <li>
                          <p>UI / UX</p>
                          <div class="progress progress_sm">
                            <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="50"></div>
                          </div>
                        </li>
                      </ul>
                      <!-- end of skills -->

                    </div>
                    <div class="col-md-9 col-sm-9 col-xs-12">

                      <div class="profile_title">
                        <div class="col-md-6">
                          <h2>User Activity Report</h2>
                        </div>
                        <div class="col-md-6">
                          <div id="reportrange" class="pull-right" style="margin-top: 5px; background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #E6E9ED">
                            <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
                            <span>December 30, 2014 - January 28, 2015</span> <b class="caret"></b>
                          </div>
                        </div>
                      </div>
                      <!-- start of user-activity-graph -->
                     <!--  <div id="graph_bar" style="width:100%; height:280px;"></div> -->
                      <!-- end of user-activity-graph -->

                      <div class="" role="tabpanel" data-example-id="togglable-tabs">
                        <ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
                          <li role="presentation" class="active"><a href="#tab_content1" id="home-tab" role="tab" data-toggle="tab" aria-expanded="true">Fee History</a>
                          </li>
                          <li role="presentation" class=""><a href="#tab_content2" role="tab" id="profile-tab" data-toggle="tab" aria-expanded="false">Result</a>
                          </li>
                          <li role="presentation" class=""><a href="#tab_content3" role="tab" id="profile-tab2" data-toggle="tab" aria-expanded="false">attendance</a>
                          </li>
                        </ul>
                       
<div id="myTabContent" class="tab-content">
<div role="tabpanel" class="tab-pane fade active in" id="tab_content1" aria-labelledby="home-tab">

                            <!-- start Fee History -->
        <table border="1" width="100%" style="font-size:10px;" class="responsive">  


              <tr>  

                <th width="5%" class="thStyle"> Month  </th>
                <th width="5%" class="thStyle"> Due Date  </th>
                <th width="5%" class="thStyle"> Tuition  </th>
                <th width="5%" class="thStyle"> Balance  </th>
                <th width="5%" class="thStyle"> Fine  </th>
                <th width="5%" class="thStyle"> Total  </th>
                <th width="4%" class="thStyle"> Remaining  </th>
                <th width="7%" class="thStyle"> Challan  </th>
                <th width="7%" class="thStyle"> Status  </th>
                <th width="5%" class="thStyle"> Paid Amount </th>
                <th width="4%" class="thStyle"> Paid Date </th>
                
              </tr>

<?php 
$session1=$_SESSION['current_session'];
$db->where("student_id", $WorkAssignListVal[0]['student_id']);
$db->where("session_id", $session1);
$history = $db->get("eduportal_monthly_challan");
$ck=count($history);
$counter=0;
foreach($history as $details){
    
$counter++;
        $db->where("Month_Id", $details['month_id']);
        $month=$db->get("eduportal_month_config");

         // getting students details 

        $db->where("student_id", $WorkAssignListVal[0]['student_id']);
        $db->where("status", 0);
        $student=$db->get("edu_student_details");

  $totalAmount= $details['tutionfee']+$details['transportfee']+$details['balance']+$details['misc_fee'];   $totalAmount1=$totalAmount; 

?>            


              <tr>  

                <td> <?php echo $month[0]['Month_Name'];?> </td>
                <td> <?php echo date("d-M",strtotime($details['challan_duedate']));?> </td>
                <td> <?php echo $details['tutionfee'];?> </td>
                <td> <?php echo 0+$details['balance'];?> </td>

                
                <td> <?php 


if(date("Y-m-d")>$details['challan_duedate']){

 $totalAmount1+=$branch_details[0]['late_fee_fine'];
 echo $branch_details[0]['late_fee_fine'];
}

                ?> </td>

              <td style="text-align:center;"> <?php echo $totalAmount1; ?>   </td>
                
                <td> <?php echo $totalAmount1-($details['collected_amount']+$details['collected_fine']);?> </td>


                <td> <a href="print_voucher.php?a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156&amp;student_id=<?php echo $WorkAssignListVal[0]['student_id'];?>&month=<?php echo $month[0]['Month_Name'];?>&month_id=<?php echo $month[0]['Month_Id'];?>" target="_blank"  style="padding: 0px 5px; font-size:14px;" class="btn btn-warning">Print </a> 

                <?php if($counter==$ck && $details['paid_status']==1){ ?>

                <a data-toggle="modal" data-target="#EditPaidChallan<?php echo $details['challan_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-warning">
                  <i class="fa fa-pencil" aria-hidden="true"></i>
                  </a>
                        
                <?php } if($counter==$ck && $details['paid_status']==0){ ?>

                <a data-toggle="modal" data-target="#EditChallan<?php echo $details['challan_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-warning">
                  <i class="fa fa-pencil" aria-hidden="true"></i>
                  </a>
                        
                <?php } ?>
                
        
      <!-- Modal -->
      <div id="EditChallan<?php echo $details['challan_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title"> Edit Fee Challan   </h4>
            </div>


            <div class="modal-body">

<?php 

$sql_fee = " select * from  eduportal_class_fee_details where branch_id=".$_SESSION['branch']." AND class_id=".$WorkAssignListVal[0]['class_id'];
$class_fee = $db->query($sql_fee);


// now checking if the fee is not paid then put class standard dues on parameters...

?>

              <h4> <?php echo $student[0]['first_name'];?> <?php echo $student[0]['last_name'];?>  </b>
                (<?php echo $class[0]['Class_Name'];?>)

              </h4>


            </div>


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

  
          <div class="col-md-4" >

          <input type="hidden" name="action" value="EditChallan">
          <input type="hidden" name="challan_id" value="<?php echo $details['challan_id']; ?>">
          <input type="hidden" name="month_id" value="<?php echo $details['month_id']; ?>">
          <input type="hidden" name="class_id" value="<?php echo $student[0]['class_id']; ?>">
          <input type="hidden" name="session" value="<?php echo $student[0]['session_id']; ?>">
          <input type="hidden" name="call" value="profile">
          <input type="hidden" name="student" value="<?php echo $_GET['student']; ?>">



                <div class="form-group" >
                        
                        <label>  Tution Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $details['tutionfee']; ?>"  class="form-control field" name="tutionfee" id="tutionfee" />
                      </div>
                </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Transport Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['transportfee']; ?> "  class="form-control field" name="transportfee" id="transportfee" />
                      </div>
                  </div>


                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  <?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous';} ?>  </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['misc_fee']; ?> "  class="form-control field" name="misc_fee" id="misc_fee" />
                      </div>
                  </div>
          
          
            <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Due Date </label>
                                   
                  <?php
                  $Date = date("Y-m-d");
                  
                  ?>

      <input style="height:40px;padding-left:1%;" type="date" name="challan_duedate"  value="<?php echo $details['challan_duedate']; ?>" required  class="form-control field" id="paidDate" />

                    </div>
              </div>



                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Prev.Balance </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['balance']; ?>" name="balance"  class="form-control field" />
                      </div>
                  </div>


<?php 

if(date("Y-m-d")>$details['challan_duedate']){

 $totalAmount1+=$branch_details[0]['late_fee_fine'];
?>

              <div class="col-md-4" >
                  <div class="form-group" >
                    
                    <label>  Fine  </label>
                      <input style="height:40px;padding-left:1%;" type="text" id="fine"  value="<?php echo $branch_details[0]['late_fee_fine'];?>"  class="form-control field" name="fine" />
                  </div>
              </div>

<?php 

}else {

?>
<input type="hidden"   value="0"   name="fine" readonly/>
<?php 

}

?>


            <div class="modal-footer">

              <button type="submit" class="btn btn-primary" name="submit" >Update Fee </button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


            </div>



                 </form>

          </div>

        </div>
      </div>

      <!-- ending -->
      
        
      <!-- Eid Paid Challan Modal -->
      <div id="EditPaidChallan<?php echo $details['challan_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title"> Edit Paid Fee  </h4>
            </div>


            <div class="modal-body">

<?php 



$sql_fee = " select * from  eduportal_class_fee_details where branch_id=".$_SESSION['branch']." AND class_id=".$WorkAssignListVal[0]['class_id'];
$class_fee = $db->query($sql_fee);


// now checking if the fee is not paid then put class standard dues on parameters...



?>

              <h4> <?php echo $student[0]['first_name'];?> <?php echo $student[0]['last_name'];?>  </b>
                (<?php echo $class[0]['Class_Name'];?>)

              </h4>


            </div>


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

  
                <div class="col-md-4" >



          <input type="hidden" name="action" value="EditPaidChallan">
          <input type="hidden" name="challan_id" value="<?php echo $details['challan_id']; ?>">
          <input type="hidden" name="month_id" value="<?php echo $details['month_id']; ?>">
          <input type="hidden" name="class_id" value="<?php echo $student[0]['class_id']; ?>">
          <input type="hidden" name="session" value="<?php echo $student[0]['session_id']; ?>">
          <input type="hidden" name="call" value="profile">
          <input type="hidden" name="student" value="<?php echo $_GET['student']; ?>">



                      <div class="form-group" >
                        
                        <label>  Tution Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $details['tutionfee']; ?>"  class="form-control field" name="tutionfee" id="tutionfee" />
                      </div>
                </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Transport Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['transportfee']; ?> "  class="form-control field" name="transportfee" id="transportfee" />
                      </div>
                  </div>


                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  <?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous';} ?>  </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['misc_fee']; ?> "  class="form-control field" name="misc_fee" id="misc_fee" />
                      </div>
                  </div>
          
          
            <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Due Date </label>
                                   
                  <?php
                  $Date = date("Y-m-d");
                  $dd=date('Y-m-d', strtotime($details['paying_date']));
                  ?>

      <input style="height:40px;padding-left:1%;" type="date" name="challan_duedate"  value="<?php echo $details['challan_duedate']; ?>" required  class="form-control field" id="paidDate" />

                    </div>
              </div>


              <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Paid Date </label>
                                   
        
                            <input style="height:40px;padding-left:1%;" type="date" name="paid_date"  value="<?php echo $dd; ?>" required  class="form-control field" id="paidDate" />
                          </div>
                    </div>



                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Prev.Balance </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['balance']; ?>" name="balance"  class="form-control field" />
                      </div>
                  </div>


<?php 

if(date("Y-m-d")>$details['challan_duedate']){

 // $totalAmount1+=$branch_details[0]['late_fee_fine'];
?>

              <div class="col-md-4" >
                  <div class="form-group" >
                    
                    <label>  Fine  </label>
                      <input style="height:40px;padding-left:1%;" type="text" id="fine"  value="<?php echo $branch_details[0]['late_fee_fine'];?>"  class="form-control field" name="fine" readonly/>
                  </div>
              </div>

<?php 

}else {

?>
<input type="hidden"   value="0"   name="fine" readonly/>
<?php 

}

?>


                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Total Fee </label>
                            <input type="hidden" name="totalAmount" value="<?php echo $totalAmount1+$others_fee; ?>">
                              <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $totalAmount1+$others_fee; ?>"  class="form-control field" readonly/>
                          </div>
                    </div>




                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Paid Fee </label>
                            
                              <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['collected_amount']; ?>"  class="form-control field" name="total_paid" />
                          </div>
                    </div>

            <div class="modal-footer">

              <button type="submit" class="btn btn-primary" name="submit" >Update Fee </button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


            </div>



                 </form>

          </div>

        </div>
      </div>

      <!-- ending -->
      
                </td>


                <td>

                
             <?php if($counter==$ck && $details['paid_status']==0){ ?>    

              <a data-toggle="modal" data-target="#payChallan<?php echo $details['challan_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-warning">

                  PAY
                  
              </a> 

                 <?php } else if($counter!=$ck && $details['paid_status']==0) { ?>    


                <a data-toggle="modal" style="padding: 0px 5px; font-size:14px;"  class="btn btn-danger">Not Paid </a> 

              <?php }else{ ?>   

                <a data-toggle="modal" style="padding: 0px 5px; font-size:14px;"  class="btn btn-success">Paid </a> 
                   
                 <a data-toggle="modal" data-target="#ViewPaidFee<?php echo $details['challan_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-warning">
                  <i class="fa fa-search" aria-hidden="true"></i>
                  </a>  
                    
                 <?php } ?>   
                




 <!-- Modal -->
  <div id="ViewPaidFee<?php echo $details['challan_id'];?>" class="modal fade" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title"> View Paid Fee Details   </h4>
        </div>


        <div class="modal-body">

<?php 





$sql_fee = " select * from  eduportal_student_fee_structure where branch_id=".$_SESSION['branch']." AND student_id=".$_REQUEST['student'];
$fee_details = $db->query($sql_fee);



$paper=$fee_details[0]['std_paper_fund'];
$lab=$fee_details[0]['std_lab_fee'];
$library=$fee_details[0]['std_library_fee'];
$oth_fee=$fee_details[0]['std_processing_fee'];
$adm_fee=$fee_details[0]['std_admission_fee'];


$sql_fee = " select * from  eduportal_class_fee_details where branch_id=".$_SESSION['branch']." AND class_id=".$WorkAssignListVal[0]['class_id'];
$class_fee = $db->query($sql_fee);


// now checking if the fee is not paid then put class standard dues on parameters...


// paper fee
if($paper==NULL || $paper==""){  
  $paper=$class_fee[0]['paper_fund'];  
  }
else {

    if( substr($fee_details[0]['paper_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $paper=$fee_details[0]['std_paper_fund'];
      
    } else {$paper=0;}
}


// library fee
if($lab==NULL || $lab==""){
  
  $lab=$class_fee[0]['lab_fund'];  
  }
else {

    if( substr($fee_details[0]['lab_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $lab=$fee_details[0]['std_lab_fee'];
    } else {$lab=0;}
}



// library fee
if($library==NULL || $library==""){
  
  $library=$class_fee[0]['library_fund'];  
  }
else {

    if( substr($fee_details[0]['lib_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $library=$fee_details[0]['std_library_fee'];
    } else {$library=0;}
}

// other fee

if($oth_fee==NULL || $oth_fee==""){
  
  $oth_fee=$class_fee[0]['other_fee'];  
  }
else {

    if( substr($fee_details[0]['other_date'],0,7)==date("Y")."-".str_pad( $month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $oth_fee=$fee_details[0]['std_processing_fee'];
       } else {$oth_fee=0;}
}



// admission fee
if($adm_fee==NULL || $adm_fee==""){
  $adm_fee=$class_fee[0]['admission_fee'];  
  }
else {

    if( substr($fee_details[0]['admission_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $adm_fee=$fee_details[0]['std_admission_fee'];
      
    } else {$adm_fee=0;}
}




 $others_fee=intVal($paper)+intVal($oth_fee)+intVal($lab)+intVal($library)+intVal($adm_fee);





?>

        <h4> <?php echo $student[0]['first_name'];?> <?php echo $student[0]['last_name'];?>  </b>
          (<?php echo $class[0]['Class_Name'];?>)

        </h4>


      </div>


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

  
                <div class="col-md-4" >


                      <div class="form-group" >
                        
                        <label>  Admission Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $adm_fee; ?> "  class="form-control field" name="adm" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Paper Fund </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $paper; ?> "  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Lab Fund </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $lab; ?> "  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label> Library Fund  </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $library; ?>"  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-8" >
                      <div class="form-group" >
                        
                        <label>  Other Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $oth_fee; ?>"  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>


             <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  <?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous';} ?> Charges </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['misc_fee'];?>"  class="form-control field" name="misc" id="misc" readonly/>
                      </div>
                  </div>


                <br>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Tution Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $details['tutionfee']; ?>"  class="form-control field" id="lname" readonly/>
                      </div>
                </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Transport Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['transportfee']; ?> "  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>


                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Prev.Balance </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['balance']; ?>"  class="form-control field" readonly/>
                      </div>
                  </div>


<?php 

if(date("Y-m-d")>$details['challan_duedate']){

 $totalAmount1-=$branch_details[0]['late_fee_fine'];
?>

              <div class="col-md-4" >
                  <div class="form-group" >
                    
                    <label>  Fine  </label>
                      <input style="height:40px;padding-left:1%;" type="text" id="fine"  value="<?php echo $branch_details[0]['late_fee_fine'];?>"  class="form-control field" name="fine" readonly/>
                  </div>
              </div>

<?php 

}else {

?>
<input type="hidden"   value="0"   name="fine" readonly/>
<?php 

}

?>


                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Total </label>
                            <input type="hidden" name="totalAmount" value="<?php echo $totalAmount1+$others_fee; ?>">
                              <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $totalAmount1+$others_fee; ?>"  class="form-control field" id="total" readonly/>
                          </div>
                    </div>


                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Due Date </label>
                         
                            <input style="height:40px;padding-left:1%;" type="text" name="duedate" 
                             value="<?php echo date('d-M-Y', strtotime($details['challan_duedate'])); ?>" readonly   class="form-control field" />
                          </div>
                    </div>


                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Due Date </label>
                         
                            <input style="height:40px;padding-left:1%;" type="text" name="duedate" 
                             value="<?php echo date('d-M-Y', strtotime($details['paying_date'])); ?>" readonly   class="form-control field" />
                          </div>
                    </div>



               <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Paid Amount </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $details['collected_amount']; ?>"  class="form-control field" readonly/>
                      </div>
                </div>
   
            <div class="modal-footer">

              <!-- <button type="submit" class="btn btn-primary" name="submit" >Save </button> -->
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


            </div>



                 </form>

          </div>

        </div>
      </div>

      <!-- ending -->

   
           







  <!-- Modal -->
  <div id="payChallan<?php echo $details['challan_id'];?>" class="modal fade" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title"> Pay Student Fee   </h4>
        </div>


        <div class="modal-body">

<?php 





$sql_fee = " select * from  eduportal_student_fee_structure where branch_id=".$_SESSION['branch']." AND student_id=".$_REQUEST['student'];
$fee_details = $db->query($sql_fee);



$paper=$fee_details[0]['std_paper_fund'];
$lab=$fee_details[0]['std_lab_fee'];
$library=$fee_details[0]['std_library_fee'];
$oth_fee=$fee_details[0]['std_processing_fee'];
$adm_fee=$fee_details[0]['std_admission_fee'];


$sql_fee = " select * from  eduportal_class_fee_details where branch_id=".$_SESSION['branch']." AND class_id=".$WorkAssignListVal[0]['class_id'];
$class_fee = $db->query($sql_fee);


// now checking if the fee is not paid then put class standard dues on parameters...


// paper fee
if($paper==NULL || $paper==""){  
  $paper=$class_fee[0]['paper_fund'];  
  }
else {

    if( substr($fee_details[0]['paper_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $paper=$fee_details[0]['std_paper_fund'];
      
    } else {$paper=0;}
}


// library fee
if($lab==NULL || $lab==""){
  
  $lab=$class_fee[0]['lab_fund'];  
  }
else {

    if( substr($fee_details[0]['lab_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $lab=$fee_details[0]['std_lab_fee'];
    } else {$lab=0;}
}



// library fee
if($library==NULL || $library==""){
  
  $library=$class_fee[0]['library_fund'];  
  }
else {

    if( substr($fee_details[0]['lib_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $library=$fee_details[0]['std_library_fee'];
    } else {$library=0;}
}

// other fee

if($oth_fee==NULL || $oth_fee==""){
  
  $oth_fee=$class_fee[0]['other_fee'];  
  }
else {

    if( substr($fee_details[0]['other_date'],0,7)==date("Y")."-".str_pad( $month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $oth_fee=$fee_details[0]['std_processing_fee'];
       } else {$oth_fee=0;}
}



// admission fee
if($adm_fee==NULL || $adm_fee==""){
  $adm_fee=$class_fee[0]['admission_fee'];  
  }
else {

    if( substr($fee_details[0]['admission_date'],0,7)==date("Y")."-".str_pad($month[0]['Month_Id'],2,"0",STR_PAD_LEFT)){  
      $adm_fee=$fee_details[0]['std_admission_fee'];
      
    } else {$adm_fee=0;}
}




 $others_fee=intVal($paper)+intVal($oth_fee)+intVal($lab)+intVal($library)+intVal($adm_fee);





?>

        <h4> <?php echo $student[0]['first_name'];?> <?php echo $student[0]['last_name'];?>  </b>
          (<?php echo $class[0]['Class_Name'];?>)

        </h4>


      </div>


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

  
                <div class="col-md-4" >

                <input type="hidden" name="action" value="PayChallan">
                <input type="hidden" name="challan_id" value="<?php echo $details['challan_id']; ?>">
                <input type="hidden" name="month_id" value="<?php echo $details['month_id']; ?>">
                <input type="hidden" name="class_id" value="<?php echo $student[0]['class_id']; ?>">
                <input type="hidden" name="session" value="<?php echo $student[0]['session_id']; ?>">
                <input type="hidden" name="std_name" value="<?php echo $student[0]['first_name'];?>">
                <input type="hidden" name="std_no" value="<?php echo $student[0]['cell_no'];?>">
                <input type="hidden" name="fee_recv_sms" value="<?php echo $brid[0]['fee_recv_sms']; ?>">
                <input type="hidden" name="call" value="profile">
                <input type="hidden" name="student" value="<?php echo $_GET['student']; ?>">
                <!-- fee details  -->
                <input type="hidden" name="adm" value="<?php echo $adm_fee; ?>">
                <input type="hidden" name="paper" value="<?php echo $paper; ?>">
                <input type="hidden" name="lab" value="<?php echo $lab; ?>">
                <input type="hidden" name="lib" value="<?php echo $library; ?>">
                <input type="hidden" name="other" value="<?php echo $oth_fee; ?>">



                      <div class="form-group" >
                        
                        <label>  Admission Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $adm_fee; ?> "  class="form-control field" name="adm" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Paper Fund </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $paper; ?> "  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Lab Fund </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $lab; ?> "  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label> Library Fund  </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $library; ?>"  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>

                 <div class="col-md-8" >
                      <div class="form-group" >
                        
                        <label>  Other Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $oth_fee; ?>"  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>


             <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  <?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous';} ?> Charges </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['misc_fee'];?>"  class="form-control field" name="misc" id="misc" readonly/>
                      </div>
                  </div>


                <br>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Tution Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $details['tutionfee']; ?>"  class="form-control field" id="lname" readonly/>
                      </div>
                </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Transport Fee </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['transportfee']; ?> "  class="form-control field" name="" id="lname" readonly/>
                      </div>
                  </div>


                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Prev.Balance </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $details['balance']; ?>"  class="form-control field" readonly/>
                      </div>
                  </div>


<?php 

if(date("Y-m-d")>$details['challan_duedate']){

 $totalAmount1-=$branch_details[0]['late_fee_fine'];
?>

              <div class="col-md-4" >
                  <div class="form-group" >
                    
                    <label>  Fine  </label>
                      <input style="height:40px;padding-left:1%;" type="text" id="fine"  value="<?php echo $branch_details[0]['late_fee_fine'];?>"  class="form-control field" name="fine" readonly/>
                  </div>
              </div>

<?php 

}else {

?>
<input type="hidden"   value="0"   name="fine" readonly/>
<?php 

}

?>


                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Total </label>
                            <input type="hidden" name="totalAmount" value="<?php echo $totalAmount1+$others_fee; ?>">
                              <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $totalAmount1+$others_fee; ?>"  class="form-control field" id="total" readonly/>
                          </div>
                    </div>


                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Paid Date </label>
                         
        <?php
        $Date = date("Y-m-d");
        $days=' +'.$brid[0]['default_pay_date'].'days';


        ?>

                            <input style="height:40px;padding-left:1%;" type="date" name="paid_date"  value="<?php echo date('Y-m-d', strtotime($Date.$days)); ?>" required  class="form-control field" id="paidDate" />
                          </div>
                    </div>



                     <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Pay Amount </label>
                              <input style="height:40px;padding-left:1%;" autofocus="autofocus" onKeyUp="calculate_amount(this.value);" type="text"  required  class="form-control field" name="collected" />
                          </div>
                      </div>

          <script>

          function calculate_amount(str){

            var id = document.getElementById("total").value;   
            document.getElementById("balance").value=id-str;   


          }
          </script>



            <div class="modal-footer">

              <button type="submit" class="btn btn-primary" name="submit" >Save </button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


            </div>



                 </form>

          </div>

        </div>
      </div>

      <!-- ending -->

           
                 </td>


                <td> <?php echo 0+$details['collected_amount']+$details['collected_fine'];?> </td>
                <td> <?php  if($details['paying_date']!=NULL){ ?>
                <?php echo date("d-M",strtotime($details['paying_date']));?> 
                <?php } ?> </td>


              </tr>


<?php 

}
?>            

            
             </table>

                            <!-- end Fee History -->

                          </div>

    <div role="tabpanel" class="tab-pane fade" id="tab_content2" aria-labelledby="profile-tab">

                            <!-- start Student Result -->
             <table width="100%"  class="responsive">



          <tr>
            
            <th class="thStyle" width="20%"> Test/Term     </th>
            <th class="thStyle" width="15%"> Class/Section </th>
            <th class="thStyle" width="10%"> Total Marks </th>
            <th class="thStyle" width="8%"> Obt Marks   </th>
            <th class="thStyle" width="8%"> %           </th>
            <th class="thStyle" width="8%"> Grade       </th>
            <th class="thStyle" width="8%"> SMS  </th>
                          
          </tr>

         <?php 
         $session1=$_SESSION['current_session'];

     	 $sql = "select * from  eduportal_exam_terms where branch_id=".$_SESSION['branch']." and session_id='$session1' order by term_id asc";

     // echo $sql;
    $terms = $db->query($sql);
      $count=1;
      foreach($terms as $term)
      { 

       $b=$_SESSION['branch'];
       $trm=$term['term_id'];
       
       $query="select SUM(obtained_marks)as obt,SUM(total_marks) as tm,sms_status from eduportal_exam_marksheet where session_id='$session1' and branch_id='$b' AND term_id='$trm' AND student_id=".$WorkAssignListVal[0]['student_id'];

       $marks = $db->query($query);
     //  print_r($marks);
       

       $avg=0+$marks[0]['obt']/$marks[0]['tm']*100;
      
        if($marks[0]['tm']==NULL){
         continue;
        }
  

       $gqr="SELECT grade_id,grade_title FROM eduportal_exam_school_grades WHERE percantage_start_range <=".round($avg)." and percantage_end_range >=".round($avg)." and branch_id=".$_SESSION['branch'];
  
        $average =  $db->query($gqr); 
         
        
      ?>
 <tr>

           <td class="tdStyle" width="">
           <a data-toggle="modal" data-toggle="modal" data-target="#TermTest<?php echo $term['term_id'];?>" style="padding: 0px 5px; font-size:14px;" href ="#">

          <?php echo $term['term_title'];?>

          </a>
          </td>
          
          <td class="tdStyle" width=""> <?php echo $class[0]['Class_Name']."-".$section[0]['section_name'];?>    </td>
          <td class="tdStyle" width=""> <?php  if($marks[0]['tm']!=NULL){echo $marks[0]['tm'];}else {echo "--";};?> </td>
          <td class="tdStyle" width=""> <?php  if($marks[0]['obt']!=NULL){echo ceil($marks[0]['obt']);}else {echo "--";};?>   </td>
          <td class="tdStyle" width=""> <?php  if($avg!="NULL"){echo number_format($avg,1);}else {echo "--";};?>%            </td>
          <td class="tdStyle" width=""><?php  if($average[0]['grade_title']!=NULL){echo $average[0]['grade_title'];}else {echo "--";};?></td>
          <td class="tdStyle" width=""> <?php  if($marks[0]['sms_status']==1){ ?> 
          
          <a data-toggle="modal" data-target="#Result<?php echo $term['term_id'];?>" style="padding: 0px 5px; font-size:14px;" class="btn btn-success">

          Resend <i class="fa fa-check" aria-hidden="true"></i>

          </a>
          
            <?php }else {?> 

          
          <a data-toggle="modal" data-toggle="modal" data-target="#Result<?php echo $term['term_id'];?>" style="padding: 0px 5px; font-size:14px;" class="btn btn-warning">

          Send

          </a>

            <?php }?> 

 <!-- Modal -->
      <div id="Result<?php echo $term['term_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content popup_style">
            <div class="modal-header">
              <button type="button" class="close pull-right" data-dismiss="modal">Close</button>
              <h4 class="modal-title"> RESULT OF (<?php echo $WorkAssignListVal[0]['first_name']." - ".$WorkAssignListVal[0]['last_name']; ?>)  </h4>
            </div>

            <div class="modal-body">

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

          <input type="hidden" name="action" value="ResendResult">
          
          <input type="hidden" name="student_name" value="<?php echo $WorkAssignListVal[0]['first_name'];?>" />
          <input type="hidden" name="term_id"  value="<?php echo $term['term_id']; ?>" />
          <input type="hidden" name="session"  value="<?php echo $WorkAssignListVal[0]['session_id']; ?>" />
          <input type="hidden" name="class_id"  value="<?php echo $WorkAssignListVal[0]['class_id']; ?>" />
          <input type="hidden" name="section"  value="<?php echo $WorkAssignListVal[0]['section_id']; ?>" />
          <input type="hidden" name="limit"  value="<?php echo $brid[0]['sms_limit']; ?>" />          
          <input type="hidden" name="student"  value="<?php echo $_GET['student']; ?>" />          

          <br>

          <div class="col-md-12" >

          
                      <div class="form-group" >
                        
                        <label>  Test/Paper: </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $term['term_title']; ?>"  class="form-control field" name="term_title" readonly/>
                      </div>
          </div>

        
                <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Total Marks </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $marks[0]['tm'];?>"  class="form-control field" name="tmarks" readonly/>
                      </div>
                </div>

                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Obtained Marks </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo ceil($marks[0]['obt']); ?>"  class="form-control field" name="obt" readonly/>
                      </div>
                  </div>


                 <div class="col-md-4" >
                      <div class="form-group" >
                        
                        <label>  Percantage % </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo number_format($avg,1);?>%"  class="form-control field" readonly/>
                      </div>
                  </div>




                 <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Grade </label>
                            
                              <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $average[0]['grade_title']; ?>"  class="form-control field" name="grade" readonly/>
                          </div>
                    </div>

                     <div class="col-md-4" >
                          <div class="form-group" >
                            
                            <label>  Cell No </label>
                              <input style="height:40px;padding-left:1%;"  type="text"  required  class="form-control field" name="cell_no" value="<?php echo $WorkAssignListVal[0]['cell_no']; ?>" />
                          </div>
                      </div>



            <div class="modal-footer">

              <button type="submit" class="btn btn-primary" name="submit" >Send Result </button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


            </div>



                 </form>

          </div>

          </div>

        </div>
      </div>

      <!-- ending -->

<!-- Student Result popup start -->


      <div id="TermTest<?php echo $term['term_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content popup_style">
            <div class="modal-header">
              <button type="button" class="btn btn-default pull-right" data-dismiss="modal">Close</button>
              <h4 class="modal-title"><?php echo $WorkAssignListVal[0]['first_name']." - ".$WorkAssignListVal[0]['last_name']; ?>  </h4>
            </div>

            <div class="modal-body">

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




<table width="100%" style="font-size:18px;" cellspacing="0" >  
   
        <tr>  
         
            <th width="8%"  class="tdalign" style="border-top-left-radius:15px;">SR </th>
            <th width="35%"  class="tdalign"> SUBJECTS </th>
            <th width="10%"  class="tdalign"> TOTAL </th>
            <th width="10%"  class="tdalign"> OBTAINED </th>
            <th width="10%"  class="tdalign"> Grade </th>
      
                        
         </tr>
<?php 

              // printing all the relevant subjects of each class
                         
                 $db->where("branch_id", $_SESSION['branch']);
                 $db->where("session_id", $WorkAssignListVal[0]['session_id']);
                 $db->where("class_id", $WorkAssignListVal[0]['class_id']);
                 $db->where("section_id", $WorkAssignListVal[0]['section_id']);


                 $teacher_sbj = $db->get("eduportal_class_subjects");

                $count=1;
                
                $totalm=0;
                $totalobt=0;
                $pertg =0;
                $status;
              foreach($teacher_sbj as $teacher_sb) {


                $db->where("subject_id", $teacher_sb['subject_id']);
                $subjects = $db->get("eduportal_subject_config"); 

                $db->where("session_id", $WorkAssignListVal[0]['session_id']);
                $db->where("term_id", $term['term_id']);
                $db->where("subject_id", $teacher_sb['subject_id']);
                $db->where("student_id", $_REQUEST['student']); 
                $marks = $db->get("eduportal_exam_marksheet"); 

                 $totalm+=$marks[0]['total_marks']+0;
                $totalobt+=$marks[0]['obtained_marks']+0;

                //$pertg = $total_obt*100/$total_marks;

                $percentage = ($marks[0]['obtained_marks']/$marks[0]['total_marks'])*100;

                 $query="SELECT grade_id,grade_title FROM eduportal_exam_school_grades WHERE percantage_start_range <=".round($percentage)." and percantage_end_range >=".round($percentage)." and branch_id=".$_SESSION['branch'];
        
                  $average =  $db->query($query);
                  
                 if ($average[0]['grade_title'] == "F") {
                    $status = 1;
                 }

                ?>

   
         <tr>  
         
            <td style="padding:0%;text-align:center;"  class="tdalign"> <?php echo $count; $count++; ?> </td>
            <td style="padding:0%;"> <?php echo $subjects[0]['subject']; ?> </td>
            <td style="padding:0%;text-align:center;" class="tdalign"> <?php echo $marks[0]['total_marks']; ?> </td>
            <td style="padding:0%;text-align:center;" class="tdalign"> <?php echo $marks[0]['obtained_marks'] ?> </td>
            <td style="padding:0%;text-align:center;" class="tdalign"><?php  echo $average[0]['grade_title']; ?></td> 
            
         </tr>



   <?php }  $percentage=ceil($totalobt)/$totalm*100; 




            $query="SELECT grade_id,grade_title FROM eduportal_exam_school_grades WHERE percantage_start_range <=".round($percentage)." and percantage_end_range >=".round($percentage)." and branch_id=".$_SESSION['branch'];
  
            $average =  $db->query($query);



   ?>



      
   </table>







        <br>
                <div class="col-md-3" >
                      <div class="form-group" >
                        
                        <label>  Total </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $totalm;?>"  class="form-control field" name="tmarks" readonly/>
                      </div>
                </div>

                 <div class="col-md-3" >
                      <div class="form-group" >
                        
                        <label>  Obtained </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo ceil($totalobt); ?>"  class="form-control field" name="obt" readonly/>
                      </div>
                  </div>


                 <div class="col-md-3" >
                      <div class="form-group" >
                        
                        <label>  Percantage % </label>
                          <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo  number_format($percentage,1);?>%"  class="form-control field" readonly/>
                      </div>
                  </div>




                 <div class="col-md-3" >
                          <div class="form-group" >
                            
                            <label>  Grade </label>
                                                          
                           <?php 

                               if ($status == 1) {

                              }else {?>

                  <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $average[0]['grade_title']; ?>"  class="form-control field" name="grade" readonly/>
                   <?php  }

                  $status="";?>           
                           </div>
                </div>

                  


            <div class="modal-footer">

            


            </div>




          </div>

          </div>

        </div>
      </div>

      <!-- Student result popup ending -->







        </td>
          
          
          </tr>



    <?php }  ?>                       



          	</table>
                
                            <!-- end Student Result -->

                          </div>
       <div role="tabpanel" class="tab-pane fade" id="tab_content3" aria-labelledby="profile-tab">
                 
  
                  <!-- Attendance Search -->
  
  <form action="<?php echo DOMAIN.AgentDirectory;?>profile.php">
  <div class="col-md-4 pull-right"> 


        <div class="pull-left" style="width:70%;">
                  
             <select name="month" id="month" class="form-control"  required>

                              <option value="">Select Month</option>
                        

                        <?php
                        $WorkAssignList = $db->get("eduportal_month_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($default==$WorkAssignListVal['Month_Id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['Month_Id']; ?>"><?php echo $WorkAssignListVal['Month_Name']; ?></option>


                                <?php
                        } ?>

                    </select>
          
        </div>
<input type="hidden" value="<?php echo $_GET['qr'];?>" name="qr"/>
<input type="hidden" value="<?php echo $_REQUEST['student']; ?>" name="student"/>   
<!--
<input type="hidden" value="<?php// echo session_id().session_id().session_id().session_id(); ?>" name="<?php //echo session_id().session_id().session_id().session_id(); ?>" />-->

        <div class="pull-right"  style="width:27%;">
          <input type="submit" value="Search" class="btn-success form-control" style="background-color:black;color:white;border-radius:5px;border:none;" >
        </div>

   </div>
   </form>
      <?php

    
    ?> 
    
    
                  <!--end Attendance Search code -->

    <h3>  Attendance Report of (<?php echo $month_name[0]['Month_Name']; ?>)  </h3>

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


    <table border="1" width="100%"  class="responsive">  


    <tr>

<?php 

$days=cal_days_in_month(CAL_GREGORIAN,$default,date("Y"));
for($i=1;$i<$days+1;$i++){     

?>

 <th class="thStyle" style="padding:6px 5px;"> <?php echo $i;?>  </th>

<?php } ?>

  </tr>


    <tr>  
<?php 

$days=cal_days_in_month(CAL_GREGORIAN,$default,date("Y"));
for($i=1;$i<$days+1;$i++){

   $date=date("Y")."-".str_pad($default, 2, '0', STR_PAD_LEFT)."-".str_pad($i, 2, '0', STR_PAD_LEFT);
   $id=$_GET['student'];  
   $qr="select * from eduportal_attendance_detail where date='$date' and student_id='$id'";
   $att = $db->query($qr);
?>

 <th class="" style="padding:6px 4px;"> <?php  if($att[0]['attendance']!=NULL){echo $att[0]['attendance'];}else {echo "-";};?> </th>

<?php } ?>

  </tr>



</table>

  </div> 


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

        <!-- footer content -->
        <footer>
          <div class="pull-right">
            Gentelella - Bootstrap Admin Template by <a href="https://colorlib.com">Colorlib</a>
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
      </div>
    </div>

    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
    <!-- morris.js -->
    <script src="../vendors/raphael/raphael.min.js"></script>
    <script src="../vendors/morris.js/morris.min.js"></script>
    <!-- bootstrap-progressbar -->
    <script src="../vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
    <!-- bootstrap-daterangepicker -->
    <script src="../vendors/moment/min/moment.min.js"></script>
    <script src="../vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
    
    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>

  </body>
</html>