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

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

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


 $branch=$_SESSION['branch'];
    
     $session1;
      if($_REQUEST['session']!=NULL){

       $session1=$_REQUEST['session'];
     }else {
       $session1=$_SESSION['current_session'];
     }

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

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

      }
     // print_r($WorkAssignListVal)

      $m->where("student_id", $WorkAssignListVal[0]['student_id']);
      /*$m->where("class_id", $WorkAssignListVal[0]['class_id']);*/
      $m->where("session_id", $_SESSION['current_session']);
      $m->where("branch_id", $_SESSION['branch']);
      $details2 = $m->get("eduportal_student_fee_structure");
 
        $m->where("class_id", $WorkAssignListVal[0]['class_id']);
        $class=$m->get("edu_class_config");

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

        $m->where("session_id", $WorkAssignListVal[0]['session_id']);
        $session=$m->get("edu_session_config");

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

  // settings month details

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

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

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



 <!-- jQuery -->
    <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="dashboard.php">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
                   
                 Issue Book Return
                       
                               <br><br>
                               
          <div class="" style="background-color: white;">
           
<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">


    <?php if ($video[0]['video_url']!=NULL) { ?>
  
  <a href="watch_video.php?videourl=<?php echo $video[0]['video_url'];?>" target="_blank" class="btn btn-success" style="padding: 10px 10px; font-size:14px;color:white;float: right;"><i class="fa fa-play"></i>&nbsp;&nbsp;Watch Demo</a>

<?php } ?>

<br><br><br>

 <div class="" style="margin-top:10px;">
      
        <div class="panel panel-default">
             <div class="panel-heading" id="std_section">
      

            <div class="col-md-6">  
            
              <form>
                <input type="text" class="form-control" placeholder="Please Search Student With Name | Registration No for Book Issue / Return" onkeyup="showResult1(this.value)" value="<?php echo $_GET['qr'];?>">
                <div id="livesearch1"></div>
              </form>
            
              <br>
             </div>      
           <div class="col-md-6"> 
              <span style="float:right;margin-top: -7px;">
              <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />


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

</div>




<div class="panel-body">

<div class="container">
  <div class="row">

   <div class="col-md-11" style="background-color: white;">

      <!-- Nav tabs -->
      <div class="card">
                <ul class="nav nav-tabs" role="tablist">

                 <li  class="active" role="presentation"><a href="#Fee<?php echo $WorkAssignListVal[0]['student_id'];?>" aria-controls="home" role="tab" data-toggle="tab">Student Information</a></li>

                 <li  class="" role="presentation"><a href="#studentbookhistory<?php echo $WorkAssignListVal[0]['student_id'];?>" aria-controls="home" role="tab" data-toggle="tab">Student Book History</a></li>
                                                
            
                </ul>

                <!-- Tab panes -->
                <div class="tab-content">

<div role="tabpanel" class="tab-pane" id="studentbookhistory<?php echo $WorkAssignListVal[0]['student_id'];?>">

	<table id="listofstudents" class="table table-striped table-bordered" style="width:100%">

		<thead>
            <tr>

              
                <th width="5%">S.No</th>
                <th width="15%">Student</th>
                <th width="10%">Class/Section</th>
                <th width="12%">Book Name</th>
                <th width="10%">Book Issue Date</th>
                <th width="10%"> Book Return DueDate </th>
                <th width="12%"> Book Return Date </th>
               <th width="3%">Status </th>
               <th width="3%">Action </th>         
               
                
            </tr>
        </thead>

        <tbody>

     <?php 

      $count=1;

      
       $m->where("branch_id", $_SESSION['branch']);
       $m->where("student_id", $_REQUEST['student']);
       $StudentBookHistoryDatas = $m->get("eduportal_library_student_book_history");

      foreach($StudentBookHistoryDatas as $StudentBookHistoryData)
      { 

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

        $m->where("section_id", $StudentBookHistoryData['section_id']);
        $section=$m->get("edu_adm_section_detail");

        $m->where("library_id", $StudentBookHistoryData['issue_book']);
        $bookName=$m->get("eduportal_library_details");
        
      ?>

        <tr>

          <td style="text-align:center; padding: 2px;"><?php echo $count++;?></td>        

          <td style="padding: 2px;" > <?php echo $WorkAssignListVal[0]['first_name'];?></td>

          <td style="text-align:center; padding: 2px;">
       <?php echo getClassName($m,$StudentBookHistoryData['class_id']);?> / <?php echo getSectionName($m,$StudentBookHistoryData['section_id']);?> </td>

      <td style="padding: 2px; text-align:left;"><?php echo $bookName[0]['book_title']; ?></td>

      <td style="padding: 2px; text-align: center;"> <?php echo date("d-M-Y",strtotime($StudentBookHistoryData['book_issue_date']));?> </td>

      <td style="padding: 2px; text-align: center;"> <?php echo date("d-M-Y",strtotime($StudentBookHistoryData['return_book_due_date']));?> </td>

      <td style="padding: 2px; text-align: center;">  <?php if ($StudentBookHistoryData['book_return_date']!=NULL) {      	
       echo date("d-M-Y",strtotime($StudentBookHistoryData['book_return_date']));}?> </td>
          
                    

    <td style="padding: 2px; text-align: center;"> 


        <?php if($StudentBookHistoryData['status']==1 || $StudentBookHistoryData['status']=="1"){ ?>    

          <a  style="padding: 0px 5px; font-size:14px;"  class="btn btn-success">
                  Return
          </a> 
          
         <?php } else { ?>    

          <a  style="padding: 0px 5px; font-size:14px;"  class="btn btn-danger">
                   No Return 
          </a> 
           <?php }   ?>

                              </td>

          <td>

             <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?book_history_id=<?php echo $StudentBookHistoryData['id_bookhistory'];?>&student=<?php echo $_REQUEST['student'];?>&action=DeleteBookHistory" 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>


<div role="tabpanel" class="tab-pane active" id="Fee<?php echo $WorkAssignListVal[0]['student_id'];?>">

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


    
            <table width="50%"  class="responsive">
                            
                                      
            <tr>
               <th class="tdStyle" width="40%"> Student Name: </th>
               <td class="tdStyle" width="60%"> <?php  if($WorkAssignListVal[0]['first_name']!=NULL){echo $WorkAssignListVal[0]['first_name'];}else {echo "--";};?> </td>
            </tr>

            <tr>
               <th class="tdStyle" width="40%"> Father Name: </th>
               <td class="tdStyle" width="60%"> <?php  if($WorkAssignListVal[0]['last_name']!=NULL){echo $WorkAssignListVal[0]['last_name'];}else {echo "--";};?> </td>
            </tr>

             <tr>
                <th class="tdStyle" width="30%"> Cell No: </th>
                <td class="tdStyle" width="70%"> <?php  if($WorkAssignListVal[0]['cell_no']!=NULL){echo $WorkAssignListVal[0]['cell_no'];}else {echo "--";};?>  </td>
            </tr>


            <tr>
               <th class="tdStyle" width="30%"> Gender: </th>
               <td class="tdStyle" width="70%"> <?php  if($WorkAssignListVal[0]['gender']!=NULL){echo $WorkAssignListVal[0]['gender'];}else {echo "--";};?> </td>
            </tr>
            <tr>
               <th class="tdStyle" width="40%"> Date of Birth: </th>
               <td class="tdStyle" width="60%"> <?php  if($WorkAssignListVal[0]['dob']!=NULL){echo $WorkAssignListVal[0]['dob'];}else {echo "--";};?> </td>
            </tr>

            
            <tr>
               <th class="tdStyle" width="40%"> Gaurdian Name: </th>
               <td class="tdStyle" width="60%"> <?php  if($WorkAssignListVal[0]['gardian_name']!=NULL){echo $WorkAssignListVal[0]['gardian_name'];}else {echo "--";};?> </td>
            </tr>
            <tr>
               <th class="tdStyle" width="40%"> Gaurdian CNIC: </th>
               <td class="tdStyle" width="60%"> <?php  if($WorkAssignListVal[0]['cnic']!=NULL){echo $WorkAssignListVal[0]['cnic'];}else {echo "--";};?> </td>
            </tr>
            <tr>
               <th class="tdStyle" width="30%"> Roll No : </th>
               <td class="tdStyle" width="70%"> <?php  if($WorkAssignListVal[0]['candidate_roll_no']!=NULL){echo $WorkAssignListVal[0]['candidate_roll_no'];}else {echo "--";};?> </td>
            </tr>

           

        </table>   
        <?php 
        if (isset($_REQUEST['student'])) { ?>
          
        
        <a style="padding:7px; font-size:14px; float: right;" data-toggle="modal" data-target="#bookissue<?php echo $_REQUEST['student'];?>" class="btn btn-success"> Issue Book </a>

               

        <a style="padding:7px; font-size:14px; float: right;" data-toggle="modal" data-target="#bookreturn<?php echo $_REQUEST['student'];?>" class="btn btn-success"> Return Book </a>
      <?php } ?>


      <div id="bookissue<?php echo $_REQUEST['student'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header" style="border-bottom:none;">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title" style="text-align:center;"> Book Issue (<?php echo $WorkAssignListVal[0]['first_name']." - ".$WorkAssignListVal[0]['user_lname']; ?>)  </h4>
            </div>

            <div class="modal-body">




<form  action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post">

           <input type="hidden" name="action" value="student_book_history"> 
           
           <input type="hidden" name="student_id" value="<?php echo $WorkAssignListVal[0]['student_id']; ?>">
           <input type="hidden" name="class_id" value="<?php echo $WorkAssignListVal[0]['class_id']; ?>">
           <input type="hidden" name="section_id" value="<?php echo $WorkAssignListVal[0]['section_id']; ?>">
           <input type="hidden" name="roll_no" value="<?php echo $WorkAssignListVal[0]['candidate_roll_no']; ?>">
           <input type="hidden" name="adm_no" value="<?php echo $WorkAssignListVal[0]['ref_no']; ?>">
           

<div class="col-md-12" style="padding: 8px;"> 

       <div class="form-group ">

          <label class="required">Book Title</label>

          <select name="book_id"  class="form-control" >
                     <option value="">Select Book</option> 
                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $books = $m->get("eduportal_library_details");
                    foreach($books as $book)
                    { ?>

                       <option <?php if($_REQUEST['library_id']==$book['library_id']){echo 'selected';}?> value="<?php echo $book['library_id']; ?>"><?php echo $book['book_title']; ?></option>


                            <?php
                    } ?>

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


           
<div class="col-md-12" style="padding: 8px;"> 

       <div class="form-group ">

          <label class="required">Book Issue Date</label>

          <input type="date" name="book_issue_date" class="form-control"
          value="<?php echo date("Y-m-d");?>"  />
        
        </div>
</div> 


<div class="col-md-12" style="padding: 8px;"> 

       <div class="form-group ">

          <label class="required">Book Return Due Date</label>

          <input type="date" name="book_return_duedate" class="form-control"
          value="<?php echo date("Y-m-d");?>"  />
        
        </div>
</div>
                   
              
                  
  <div class="col-md-12" style="padding:8px;"  id="col1">

       <div class="form-group ">

          <label> Remarks</label>
              <textarea name="issue_remarks"  id="from" value="<?php echo $_POST['issue_remarks']?>" type="text" class="form-control"></textarea>
       
          </div>
  </div>                      
      
            <div class="modal-footer">

            <button type="submit" class="btn btn-primary" name="submit" >Submit </button>
              


            </div>



                 </form>

          </div>

          </div>

        </div>
      </div>

</div>



<!-- book returen popup -->


<div id="bookreturn<?php echo $_REQUEST['student'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header" style="border-bottom:none;">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title" style="text-align:center;"> Book Return (<?php echo $WorkAssignListVal[0]['first_name']." - ".$WorkAssignListVal[0]['user_lname']; ?>)  </h4>
            </div>

            <div class="modal-body">




<form  action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post">

           <input type="hidden" name="action" value="student_book_return"> 
           
           <input type="hidden" name="student_id" value="<?php echo $WorkAssignListVal[0]['student_id']; ?>">
                     

<div class="col-md-12" style="padding: 8px;"> 

       <div class="form-group ">

          <label class="required">Return Book</label>

          <select name="return_book_id"  class="form-control" >
                     <option value="">Select Book</option> 
                    <?php

                    $m->where("student_id", $_REQUEST['student']);
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("eduportal_library_student_book_history");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    {

                    $m->where("library_id", $WorkAssignListVal['issue_book']);
                    $m->where("branch_id", $_SESSION['branch']);
                    $book = $m->get("eduportal_library_details");
                     ?>

                       <option <?php if($_REQUEST['library_id']==$WorkAssignListVal['issue_book']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['issue_book']; ?>"><?php echo $book[0]['book_title']; ?></option>


                            <?php
                    } ?>

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


           
<div class="col-md-12" style="padding: 8px;"> 

       <div class="form-group ">

          <label class="required">Book Return Date</label>

          <input type="date" name="book_return_date" class="form-control"
          value="<?php echo date("Y-m-d");?>"  />
        
        </div>
</div> 


                   
              
                  
  <div class="col-md-12" style="padding:8px;"  id="col1">

       <div class="form-group ">

          <label> Remarks</label>
              <textarea name="return_remarks"  id="from" value="<?php echo $_POST['return_remarks']?>" type="text" class="form-control"></textarea>
       
          </div>
  </div>                      
      
            <div class="modal-footer">

            <button type="submit" class="btn btn-primary" name="submit" >Submit </button>
              


            </div>



                 </form>

          </div>

          </div>

        </div>
      </div>




<!-- ending book retrun popup -->


                    </div>
                    



                </div>
      

      </div>

       </div> <!-- col 9 -->
  </div>
</div>  <!-- container -->


    <br><br>

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

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