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

<?php
$branch=$_SESSION['branch'];

$sql = "SELECT * FROM eduportal_library_details where branch_id='$branch' ";


$books = $m->query($sql);
 //print_r($categories);
 
     ?>

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


<script>

  function HideDate1(str){
  
  if(str=="1"){
    
    document.getElementById("from").style.display="block";
    document.getElementById("to").style.display="block";
    document.getElementById("col1").style.display="block";
    document.getElementById("col2").style.display="block";
  }
  else {
    
    document.getElementById("from").style.display="none";
    document.getElementById("to").style.display="none";
    document.getElementById("col1").style.display="none";
    document.getElementById("col2").style.display="none";
  }
}

</script>

<script type="text/javascript">
  
  function checkboxes(){
  
var chk_arr =  document.getElementsByName("students[]");
var chklength = chk_arr.length;             
var students;
var count=0;
//alert(chk_arr);
  for(k=0;k< chklength;k++)
  {
      
      if(chk_arr[k].checked){
         var vl=chk_arr[k].value.split(",");
         students=students+","+vl[1];
        count++;  
        
    }

  } 
   // alert(students);
if(count>0){

  window.location="messages.php?students="+students;
}else {
  
  alert("Please choose any students from checkboxes...");

}
  
}




  function checkboxes_urdu(){
  
    var chk_arr =  document.getElementsByName("students[]");
    var chklength = chk_arr.length;             
    var students;
    var count=0;
    //alert(chk_arr);
      for(k=0;k< chklength;k++)
      {
          
          if(chk_arr[k].checked){
             var vl=chk_arr[k].value.split(",");
             students=students+","+vl[1];
            count++;  
            
        }

      } 
       // alert(students);
    if(count>0){

      window.location="newurdusms.php?students="+students;
    }else {
      
      alert("Please choose any students from checkboxes...");

    }
      
}


</script>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
            <div class="right_col" role="main">

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

<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">


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



      <form class="" action="manage_students.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">
          <div class="panel-heading"><?php echo count($books);?> Books Records <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" />


      <a href="add_book.php" style="float: right;" class="btn btn-success">Add Book</a>

      <a href="print_library_book_list.php" style="float: right;" class="btn btn-success">Print List</a>







          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

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


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student record is added successfully...
            </div>
          <?php  unset($_SESSION['addsuccess']); }?>

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


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student has been re-enrolled successfully...
            </div>
          <?php  unset($_SESSION['reEnroll']); }?>



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


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


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

 

<form action="manage_students.php" enctype="multipart/form-data" method="post">


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

<div style="">

 



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

              
                <th width="5%">S.No</th>
                <th width="8%">Book Title</th>
                <th width="8%">Book Number</th>
                <th width="8%">ISBN Number</th>
                <th width="8%"> Publisher </th>
                <th width="8%"> Author </th>
                <th width="8%"> Subject </th>
                <th width="8%"> Rack Number </th>
                <th width="8%"> Qty </th>
                <th width="8%"> Available </th>
                <th width="8%"> Book Price </th>
                <th width="8%"> Post Date </th>
                <th width="8%">Action </th>
          
               
                
            </tr>
        </thead>
        <tbody>

     <?php 

      $count=1;
      foreach($books as $book)
      { 

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

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

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

        <tr>

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

          <td style="padding: 2px;" > <?php echo $book['book_title'];?></td>

          <td style="padding: 2px;" > <?php echo $book['book_number'];?></td>

          <td style="padding: 2px;" > <?php echo $book['ISBN_number'];?></td>

          <td style="padding: 2px;" > <?php echo $book['publisher'];?></td>

          <td style="padding: 2px;" > <?php echo $book['author'];?></td>

          <td style="padding: 2px;" > <?php echo $book['subject'];?></td>

          <td style="padding: 2px;" > <?php echo $book['rack_number'];?></td>

          <td style="padding: 2px;" > <?php echo $book['qty'];?></td>

          <td style="padding: 2px;" > <?php if ($book['qty'] > 0) {

            echo "YES";

           } else {

           echo "NO";

            } ?></td>

          <td style="padding: 2px;" > <?php echo $book['book_price'];?></td>

          <td style="padding: 2px;" > <?php echo $book['post_date'];?></td>

          <td>        
            

              <a style="padding: 0px 5px; font-size:14px;"  href="add_book.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&book=<?php echo $book['library_id'];?>" style="cursor:pointer;"  class="btn btn-success"> <i class="fa fa-pencil" aria-hidden="true"></i></a>

              

        <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?library_id=<?php echo $book['library_id'];?>&action=Deletelibrary" 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>


        <a data-toggle="modal" data-target="#viewDescription<?php echo $book['library_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-info">
                 <i class="fa fa-eye"></i> Description                  
         </a>


<!-- library book Description Popup start -->


<div id="viewDescription<?php echo $book['library_id'];?>" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content" style="width: 175%; margin-left: -200px;">
<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 Name (<?php echo $book['book_title']; ?>)  </h4>

</div>

<div class="modal-body">

<p><?php echo $book['description'];?></p>

</div>

</div>

</div>
</div>

<!-- Library book description popup ending -->

 
        
        </td>
          

      
      
      
              

    

  

  </tr> <?php   } ?>
 
        </tbody>
        
    </table>

  </div>

    </form>

    <br><br>


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

        </div> 
        </div>


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


     
        <!-- /page content -->


 <!-- jQuery -->
    <script src="js/ajax_functions.js"></script>
  <?php include('RootMe/js_linksscript.php');?> 
  <!-- Links for Datatable-->

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
 <script>
        
  $(document).ready(function() {
    $('#listofstudents').DataTable({
      "pageLength": 100
    });
    } 
  );

  $("#checkAll").change(function () {

      $("input:checkbox").prop('checked', $(this).prop("checked"));
  });


</script>
  
  </body>
</html>
