<?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");


   $m->where("status", '0');
   $m->where("branch_id", $_SESSION['branch']); 
   $m->orderBy("user_id", 'desc');
   $WorkAssignListings = $m->get("edu_user_config");
 
     ?>


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

.tdStyle{border-bottom:1px solid lightgray;}
.thStyle{background-color:#00AFEF;color:white;}

</style>  
  </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; 
              
          Staff Access 
          <br><br>
          
          <div class="" style="background-color: white;    padding: 2%">
           
  <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>
    <br>
 
 
  <h3>Manage Employees Access</h3>

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


<div style="">

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

      <thead>
          <tr>

              <th width="5%">S.No</th>
              <th width="20%">Name</th>
              <th width="12%">Designation</th>
              <th width="12%">See Access</th>
              <th width="12%">Access</th>
              <th width="15%">User Access</th>
           
              
          </tr>
      </thead>
      <tbody>


 
     
     <?php 

     $count=1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $m->where("designation_id", $WorkAssignListVal['designation_id']);
        $designation=$m->get("eduportal_designation_config");

        $m->where("user_id", $WorkAssignListVal['user_id']);
        $useraccess=$m->get("users_privilege_detail");

      ?>

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

    <td>

    <?php echo $WorkAssignListVal['user_fname'];?>              
                       
    </td>

      
      <td> <?php echo $designation[0]['designation_name'];?> </td>
     <td>
        <a style="padding: 0px 5px; font-size:14px;" href="assign_user_access.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&id=<?php echo $WorkAssignListVal['user_id'];?>&desigID=<?php echo $WorkAssignListVal['designation_id'];?>" class="btn btn-success">Manage <i class="fa fa-pencil" aria-hidden="true"></i>
        </a>
     </td>

     <td>
   
             <?php if($WorkAssignListVal['page_access_status']==1 && $useraccess[0]['user_id']==$WorkAssignListVal['user_id'])  { ?>    

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

            <td>
   
             <?php if($WorkAssignListVal['page_access_status']==1 && $useraccess[0]['user_id']==$WorkAssignListVal['user_id']) { ?>    

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

                  Send SMS
                  
              </a> 

             <?php } ?>    
        
          <!-- Start Send Access SMS Popup code -->        
        <div id="SendAccessSMS<?php echo $WorkAssignListVal['user_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"> SMS Send (<?php echo $WorkAssignListVal['user_fname']; ?>)  </h4>
            </div>

            <div class="modal-body">
<?php

// get additional SMS in Current month

    $branch=$_SESSION['branch'];
    $monthId=date("m");
    $sessionID=date("Y");

    $qr="SELECT SUM(add_sms) as TaditionalSms FROM eduportal_branches_SMScredit_limit WHERE month_id='$monthId'  and branch_id='$branch' AND session_id=".$sessionID;

    $AdSMS = $m->query($qr);

     $total_sms_monthly_used=getCurrentMonthFeeSms($m)+getCurrentMonthResultSms($m)+getCurrentMonthOtherSms($m)+getCurrentMonthAttendanceSms($m)+0;
    $sms_credit=$brid[0]['monthly_credit']+$AdSMS[0]['TaditionalSms']-$total_sms_monthly_used;

if ($brid[0]['sms_service']=="0" && $sms_credit > 0) { ?>

  <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="UserAccessSms">
          
          <input type="hidden" name="user_fname" value="<?php echo $WorkAssignListVal['user_fname'];?>" />
          <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="user_id"  value="<?php echo $WorkAssignListVal['user_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> Email Address: </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $WorkAssignListVal['user_email']; ?>"  class="form-control field" name="user_email" />
                      </div>
             </div>

             <div class="col-md-12" >
          
                      <div class="form-group" >
                        
                        <label> Software Link: </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo DOMAIN;?>"  class="form-control field" name="link" readonly/>
                      </div>
             </div>

        
                <div class="col-md-8" >
                      <div class="form-group" >
                        
                        <label>  Update Your Password: </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $WorkAssignListVal['user_password'];?>"  class="form-control field" name="user_password"/>
                      </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['cell_no']; ?>" />
                          </div>
                      </div>



            <div class="modal-footer">

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


            </div>



                 </form>

<?php } else { ?>
      <h4>Can't Send. Because your SMS Limit has been Exceed.</h4>
<?php } ?>


          </div>

          </div>

        </div>
      </div>
                 
             <!--   End Send Access SMS Popup code   -->
            </td>
              </tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>

  </div>



    <br><br>


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

           
          </div>
        </div>

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

    


    
  <?php include('RootMe/js_linksscript.php');?>

  <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

   <script>
        
  $(document).ready(function() {
    $('#listofstudents').DataTable({
      "pageLength": 100
    });
    } 
  );

</script>
   <!-- jQuery -->
    <script src="js/ajax_functions.js"></script> 
  </body>
</html>
