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

<?php

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

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


$m->where("user_id", $_SESSION['user_id']);
$m->where ("branch_id", $_SESSION['branch']);
$m->where("page_id", 54);
$access = $m->get("users_privilege_detail");


$branch=$_SESSION['branch'];
$class_id=$_REQUEST['class_id'];
$section_id=$_REQUEST['section'];

$soft_link;


if($_SESSION['parents_link']!=NULL){
  $soft_link=$_SESSION['parents_link'];
} else {
  $soft_link=Parents_Portal;
}


  $sql = "SELECT * FROM  eduportal_parents_access WHERE branch_id='$branch' and status='0'";
  $from;
  $to;

  if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {
        $from=date("Y-m-d",strtotime($_REQUEST['from']));  

      }else {
        $from=date("Y-m-01");  
      }
     
      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {
        $to=date("Y-m-d",strtotime($_REQUEST['to']));
      }else {
        $to=date("Y-m-t");  
      } 

    $sql .= " and portal_access_date BETWEEN '" .$from. "' AND '" .$to. "' ";
 $WorkAssignListings = $m->query($sql); 
 //print_r($sql);
//}

 ?>

<!DOCTYPE html>
<html lang="en">
  <head>
   
    <title> View Students | 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">
            <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;">        
      
          <div class="panel-heading">

            
            <h3>List of Parents IDs <span style="font-size: 16px;"> (<?php echo count($WorkAssignListings);?> records) </span>       </h3>             
          </div>
<div style="">

   
        
      <div class="clearfix"></div>
    </div>
             
          <?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> Record is added successfully...
            </div>
          <?php  unset($_SESSION['addsuccess']); }?>



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


<form action="parents_id.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&from=<?php echo $_GET['from'];?>&to=<?php echo $_GET['to'];?>">

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

          

                 <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col1">
                 <div class="form-group ">

                 <label class="required"> From Date</label>
                 <input name="from"  id="from" value="<?php echo $from;?>" type="date" class="form-control"  >
                       
                  </div>
                  </div>                      
             

                  <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col2">

                       <div class="form-group ">

                          <label class="required"> To Date</label>
                              <input name="to" id="to" value="<?php echo $to;?>" type="date" class="form-control"  >
                       
                          </div>
                  </div>  
                 
                  
                  
                  <div class="col-md-1 " style="padding:8px;">
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 24px;">Search</button>
                </div>
              </div> 
              
               <div class="col-md-1 " style="padding:8px;margin-top: 25px;">
                <div class="form-group ">
                <a target="_blank" title="Print Parent Ids Report" href="print_parent_ids.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&session=<?php echo $_GET['session'];?>&from=<?php echo $from;?>&to=<?php echo $to['session'];?>&8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1" class="fa fa-print btn btn-primary" style="padding: 9px;float: right;">&nbsp;Print</a>
                </div>
              </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="ParentsAccessSMS">

          <?php if ($brid[0]['sms_service']=="0") { ?>

             <input type="submit" name="portal" style="" onClick=" return confirmation()" class="pull-right btn btn-success"  value="Send Parents Portal Link To Selected"  />


          <input type="submit" name="app" style="" onClick=" return confirmation()" class="pull-right btn btn-success"  value="Send Mobile App Link To Selected"  />
            

        <?php } else { ?>

          <input type="submit" disabled name="portal" style="" onClick=" return confirmation()" class="pull-right btn btn-success"  value="Send Parents Portal Link To Selected"  />


          <input type="submit" disabled name="app" style="" onClick=" return confirmation()" class="pull-right btn btn-success"  value="Send Mobile App Link To Selected"  />

      <?php  } ?>



           

          
     
          


<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="10%"> Id/Cell No </th>
                <th width="10%">Password</th>
                <th width="10%">View Children</th>
                <th width="15%">Parents Portal</th>
                <th width="15%">Mobile App</th>
                <th width="10%">Action</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['parents_cellno'];
      //echo $cell_number;
      /*$m->where("class_id", $WorkAssignListVal['class_id']);
      $Class_Name=$m->get("edu_class_config");
*/
       /*$m->where("cell_no", $WorkAssignListVal['parents_cellno']);
       $student=$m->get("edu_student_details");*/

      //echo $student[0]['student_id'];

       $sql = "SELECT std.student_id,std.ref_no,std.first_name,std.last_name,std.cell_no,std.status,std.branch_id,std.class_id,std.section_id,std.session_id,std.family_code FROM edu_student_details as std WHERE std.cell_no='$cell_number'";
       //print_r($sql);

       $student = $m->query($sql);
     
      ?>

        <tr>
        	<input type="hidden" name="last_name<?php echo $WorkAssignListVal['parents_id'];?>" value="<?php echo  $WorkAssignListVal['parents_name'];?>">
        	<input type="hidden" name="cell_no<?php echo $WorkAssignListVal['parents_id'];?>" value="<?php echo  $WorkAssignListVal['parents_cellno'];?>">
        	<input type="hidden" name="parent_password<?php echo $WorkAssignListVal['parents_id'];?>" value="<?php echo  $WorkAssignListVal['password'];?>">

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

          <td style="padding: 2px;" > <?php echo $WorkAssignListVal['parents_name'];?></td>
          <td> <?php echo $WorkAssignListVal['parents_cellno'];?></td>
          <td style="padding: 2px;" > <?php echo $WorkAssignListVal['password'];?></td>
          <td style="text-align:center;"> 
        <a style="padding: 0px 5px;" href="viewChildren.php?parentchild=<?php echo $student[0]['student_id'];?>" class="iframePupop btn btn-success" >
          View
        </a>
         </td>
                
          
          <td style="text-align:center;"> 


       

       <a style="padding: 0px 5px;" href="portal_link_popup.php?parentId=<?php echo $WorkAssignListVal['parents_id'];?>&portallink=<?php echo $soft_link;?>" class="iframePupop btn btn-success" >
          Send Portal Link
        </a>
        </td>  
       

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


      

       <a style="padding: 0px 5px;" href="app_link_popup.php?parentId=<?php echo $WorkAssignListVal['parents_id'];?>&portallink=<?php echo $soft_link;?>" class="iframePupop btn btn-success" >
          Mobile App Link
        </a>

       </td>

       <td>
         <?php if ($access[0]['edit_access']!=NULL) { ?>

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

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

        </a>
      <?php } ?>

      <?php if ($access[0]['delete_access']!=NULL) { ?>

         <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?id=<?php echo $WorkAssignListVal['parents_id'];?>&action=DeleteParentId" 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>
         
      <?php } ?>

       </td>

        <!-- Student Result popup start -->


      <div id="EditParentAccess<?php echo $WorkAssignListVal['parents_id'];?>" 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;"> Reasons of Delete (<?php echo $WorkAssignListVal['first_name']." - ".$WorkAssignListVal[0]['user_lname']; ?>)  </h4>
            </div>

            <div class="modal-body">

</form>


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

           <input type="hidden" name="action" value="updateParentAccess">      
           <input type="hidden" name="parents_id" value="<?php echo $WorkAssignListVal['parents_id']; ?>">
           
                   <div class="col-md-12" style="padding:8px;"  id="">

                       <div class="form-group ">

                          <label class="required"> Parents Name</label>
                              <input name="parents_name"  id="" value="<?php echo $WorkAssignListVal['parents_name'];?>" autocomplete="off" type="text" class="form-control"/>
                       
                          </div>
                  </div> 


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

                       <div class="form-group ">

                          <label class="required"> Cell No</label>
                              <input name="parents_cellno"  id="" value="<?php echo $WorkAssignListVal['parents_cellno'];?>" autocomplete="off" type="text" class="form-control"/>
                       
                          </div>
                  </div>                         
                  

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

                       <div class="form-group ">

                          <label class="required"> Password</label>
                              <input name="password"  id="" value="<?php echo $WorkAssignListVal['password'];?>" autocomplete="off" type="text" class="form-control"/>
                       
                          </div>
                  </div>                     
      
            <div class="modal-footer">

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


            </div>



                 </form>

          </div>

          </div>

        </div>
      </div>

      <!-- Student result popup ending -->

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

              </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": 1500
    });
    } 
  );

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

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

 </script>



  <link rel="stylesheet" href="colorbox.css" />

<script src="jquery.colorbox.js"></script>

 <script>

$(document).ready(function(){

$(".iframePupop").colorbox({iframe:true, width:"80%", height:"85%"});

});

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