<?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", $pageNameAccess[0]['page_id']);
$access = $m->get("users_privilege_detail");

$sql = " select * from  eduportal_branch_locality where branch_id=".$_SESSION['branch']." order by locality_name asc";

$WorkAssignListings = $m->query($sql);


if(isset($_GET['locality'])){
  
  $sql = "select * from  eduportal_branch_locality where locality_id=".$_GET['locality']." order by locality_name asc";
  $localities = $m->query($sql);

}
  ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Locality | 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; 
               Manage Localities
                  <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="#" enctype="multipart/form-data" method="get">
        <div class="">
          <h3 style="float: left;">List View Localities <small>(<?php echo count($WorkAssignListings);?> Records)</small> </h3>

            

          <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="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

     
          
          <?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> One record is updated successfully...
            </div>


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

  

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

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

             <div id="error"  class="alert alert-warning alert-dismissible">
                      <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                       <strong>Warning !</strong> You have already saved the challan of this month !!!
              </div>

           </div>

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

        





<div style="float:left;" class="col-md-6">

 
    <table  class="table table-striped table-bordered" style="width:100%">
          
          <thead>
            <tr>
                <th width="15%"   style="text-align:center;">S.No</th>
                <th width="68%">Locality Name</th>
                <th width="17%"> Action </th>

            </tr>
        </thead>
        <tbody>


   
     
     <?php 

     $count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $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;">
                 <?php echo $count;  $count++;?>

               </td>

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

              <td>

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

              <a style="padding: 0px 5px; font-size:14px;"  href="manage_localities.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&locality=<?php echo $WorkAssignListVal['locality_id'];?>" style="cursor:pointer;"  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?locality=<?php echo $WorkAssignListVal['locality_id'];?>&action=DeleteLocality" 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>




              </tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>


</div>




<div style="float:left;" class="col-md-6">

    <table style="width:100%">
          
         <tr>
          <td width="100%" style="padding-left:2%; padding-right:2%;" >

<?php if(!isset($_GET['locality'])){?>

        <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="AddLocality">
              <div class="form-group col-xs-12">

                  <label for=""> Add New Locality </label>
                  <input type="text"  name="locality_name" placeholder="Enter Locality Name..." autocomplete="off" required maxlength="100" style="width: 100%;height: 34px;" autofocus="autofocus" required>
                   
                 
                  <div class="clearfix"></div>
                  <br><br>
                  <input type="submit" class="btn btn-primary" value="Save Locality" >
              
              </div>

        </form>

<?php } else {?>


        <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="UpdateLocality">
              <input type="hidden" name="locality_id" value="<?php echo $localities[0]['locality_id'];?>">
              <div class="form-group">

                  <label for=""> Locality Name </label>
                  <input type="text" style="width: 100%;height: 34px;" value="<?php echo $localities[0]['locality_name'];?>" name="locality_name" autofocus="autofocus" autocomplete="off" required maxlength="100" required>
                   
                  <br><br>

                  <label for=""> Add Locality Date </label>
                  <input type="date" name="locality_date" value="<?php echo $localities[0]['locality_date'];?>" style="width: 100%;height: 34px;">
                  <div class="clearfix"></div>
                  <br><br>
                  
                  <div class="clearfix"></div>
              
                  <input type="submit" class="btn btn-primary" value="Update Record" >
              
              </div>

        </form>




<?php }?>





                </td>
                
          </tr>
        
  </table>


</div>



    <br><br>


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

           
          </div>
        </div>

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

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