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


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

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


?>

<?php
$branch=$_SESSION['branch'];
$cls=$_REQUEST['class_id'];
$soft_link;

if($_SESSION['parents_link']){
  $soft_link=$_SESSION['parents_link'];
}else {
  $soft_link="parents.eduportal-pk.com";
}

  $sql = "SELECT cell_no, last_name, class_id, section_id, student_id FROM  edu_student_details  WHERE branch_id='$branch' and status='0' and class_id='$cls' group by cell_no";
  //print_r($sql);
  $WorkAssignListings = $m->query($sql); 

 ?>

<!DOCTYPE html>
<html lang="en">
  <head>
   
    <title> View Parents  | EduPortal </title>
     <?php include('RootMe/css_links.php');?> 
  </head>
  
  <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; 
             Parent's ID's
          <br><br>
          
            <div class="row" style="background-color: white;">
  

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

<form class="" action="parents_access.php" enctype="multipart/form-data" method="get">
        
         
<div class="panel-body">

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


 <div class="col-md-3 col-xs-12" style="padding: 8px;">
<div class="form-group ">
  <label class="required">Session</label>
<select name="session" class="form-control" >

    <!-- <option value="">All</option> -->


<?php

$match;
if(!isset($_REQUEST['session'])){
  $match=$_SESSION['current_session'];
}else { $match=$_REQUEST['session']; }


$WorkAssignList = $m->get("edu_session_config");
foreach($WorkAssignList as $WorkAssignListVal)
{ ?>

 <option <?php if($match==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></option>


      <?php
} ?>

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

            
<div class="col-md-3 col-xs-12" style="padding: 8px;">
<div class="form-group ">
  <label class="required">Class</label>


    <select name="class_id" class="form-control" >
     <option value="">Select Class</option> 
    <?php
    $m->where("branch_id", $_SESSION['branch']);
    $WorkAssignList = $m->get("edu_class_config");
    foreach($WorkAssignList as $WorkAssignListVal)
    { ?>

       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>


            <?php
    } ?>

    </select>

  
</div>
</div>
            

<div class="col-md-1" style="padding:2px;">
<div class="form-group ">
   <input type="hidden" name="addaccountAdmin" value="1">
<button type="submit" class="btn btn-primary" style="margin-top:29px;">Search</button>
</div>
</div>

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


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

    <input type="hidden" name="action" value="CreateParentsLoginIDs">

<a href="parents_list.php?kkljadf;lkjasfklhadsfhadklsfdvhadsfjasfjuadshfkljdfhdkfjadhfadfjldjfdfkdfh&class_id=<?php echo $_REQUEST['class_id'];?>" class="btn btn-primary pull-right">Print Parents List</a>    
         
<input type="submit" name="submit" style="" onClick=" return confirmation()" class="pull-right btn btn-primary"  value="Create Login IDs"  />

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

              
                <th width="5%">S.No</th>
                <th width="15%">Parents Name</th>
                <th width="">Child Class</th>
                <th width="10%"> Cell No </th>
                <th width="10%">No Of Children</th>
                <th width="10%"> View Children </th>
                <th width="10%">Access</th>
                <th width="5%">
                <label class="container1"><input  type="checkbox" id="checkAll"/><span class="checkmark" style="margin-top: -17px;"></span></label>
                </th>
                
                                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 
$count=1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 
      $cell_number=$WorkAssignListVal['cell_no'];
        
   

  $m->where ("parents_cellno", $WorkAssignListVal['cell_no']);
  $m->where("branch_id", $_SESSION['branch']);
  $Already_Added =  $m->get ('eduportal_parents_access');

  if(count($Already_Added)>0) { 

     continue;
  }
     
      ?>

        <tr>

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

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


        <a data-toggle="modal" data-target="#parentchild<?php echo $WorkAssignListVal['student_id'];?>" style="padding: 0px 5px; font-size:14px; width: 80px;"  class="btn btn-success">
          View
        </a> 


      <!-- Modal -->
      <div id="parentchild<?php echo $WorkAssignListVal['student_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content" style="width: 900px;margin-left: -25%;">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title"> List Of Parents Child </h4>
            </div>


            <div class="modal-body">

            </div>


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

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


              <tr>  

                <th class="thStyle" style="text-align: center;padding:1%;"> Student Name  </th>
                <th class="thStyle" style="text-align: center;padding:1%;"> Father Name </th>
                <th class="thStyle" style="text-align: center;padding:1%;"> Class/Sec </th>
                <th class="thStyle" style="text-align: center;padding:1%;"> Roll No </th>
                <th class="thStyle" style="text-align: center;padding:1%;"> Cell No </th>
              
              </tr>
<?php 


  

 $m->where("status", 0);
 $m->where("branch_id", $_SESSION['branch']);
 $m->where("cell_no", $cell_number);
 $childs = $m->get("edu_student_details"); 
//print_r($childs);

 foreach ($childs as $child) {


  

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

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

?>            
              <tr>  

                <td> <?php echo $child['first_name'];?> </td> 
                <td> <?php echo $child['last_name'];?> </td>
                <td> <?php echo $class[0]['Class_Name']."-".$section[0]['section_name'];?> </td> 
                <td> <?php echo $child['candidate_roll_no'];?> </td>
                <td> <?php echo $child['cell_no'];?> </td>
              </tr>

<?php   } ?>

          
 
             </table>

          </div>

          <br><br>


            <div class="modal-footer">

             <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


            </div>



          </div>

        </div>
      </div>

      <!-- ending modal -->



               </td>
          <td > 
<?php 
        $m->where ("parents_cellno", $WorkAssignListVal['cell_no']);
        $m->where("branch_id", $_SESSION['branch']);
        $Already_Added =  $m->get ('eduportal_parents_access');
       
        if(count($Already_Added)>0) { ?>

           <a style="padding: 0px 5px; font-size:14px; width: 80px;" href="#" class="btn btn-success">
                    Yes
            </a> 
<?php } else { ?>
       
          <a  style="padding: 0px 5px; font-size:14px; width: 80px;" href="#" class="btn btn-danger">
                  No
          </a>
    <?php } ?>
          </td>
        

          <input type="hidden" name="last_name<?php echo $WorkAssignListVal['student_id'];?>" value="<?php echo $WorkAssignListVal['last_name'];?>" />
          <input type="hidden" name="cell_no<?php echo $WorkAssignListVal['student_id'];?>"  value="<?php echo $WorkAssignListVal['cell_no']; ?>" />


          <input type="hidden" name="link"  value="<?php echo $soft_link;?>" />



          <input type="hidden" name="parent_password<?php echo $WorkAssignListVal['student_id'];?>"  value="<?php if($Already_Added[0]['password']==NULL){ echo randomPassword($m); } else { echo $Already_Added[0]['password']; }?>" />


    <td style="padding: 2px;">
      <label class="container1">
      <input type="checkbox" name="checkboxes[]" value="<?php echo $WorkAssignListVal['student_id'];?>"><span class="checkmark"></span>
      </label>

    </td>

              </tr>

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

</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>
