<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.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");


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

  </head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></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; 
                Manage Route
          <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;">
   
      

                                    <!-- page content -->
        
  <div class="">
    
      <h3 style="margin-left: 15px;">Add New Route</h3>
            <div class="row">
          
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
            
                  <div class="x_content">
          
     
                    <form action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left" >
  <?php
  
  $month;
   if(!isset($_GET['routeup'])){?>
        <input type="hidden" name="action" value="add_route" />

  <?php } else {

          $query="select * from eduportal_route_details where route_id =".$_GET['routeup'];
          $routedata = $m->query($query);

         
?>
              <input type="hidden" name="action" value="update_route" />
              <input type="hidden" name="route_id"  value="<?php echo $_GET['routeup'];?>">

  <?php } ?>        
          
        <div class="item form-group">
                        
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">

                         Route Title <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input class="form-control col-md-8 col-xs-12"  name="route_title" placeholder="eg Ikhlas Pur " value="<?php echo $routedata[0]['route_title']; ?>">
                        </div>

<br><br>
                          
                         <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">

                        	Fare <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input class="form-control col-md-8 col-xs-12"  name="route_fare" placeholder="eg Volvo Bus " value="<?php echo $routedata[0]['route_fare']; ?>">
                        </div>

                      </div>              
                   
                     

                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-7">
                          
                          <button id="send" type="submit" class="btn btn-primary" >Save Record</button>
                         
                        </div>
                      </div>

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

        <!-- /page content -->



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

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

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


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




     <div class="t col-md-12 col-sm-12 col-xs-12">
                <h3>Route List<small> (<?php echo count($routes);?> records)</small></h3>
              </div>

            
          
          
    

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

<div id="snackbar"><script> toastFunction();</script> Your Recored is Sucessfully Added</div>

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


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


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


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

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


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Danger!</strong> Record is deleted successfully...
            </div>


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

<table id="datatable" class="table table-striped table-bordered"style="background-color: white;">
                      <thead>
                        <tr>
                          <th width="1%">S.No</th>
                           <th width="10%">Route Title</th>
                          <th width="10%">Route Fare</th>                          
                          <th width="8%">Action</th>
                         

                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;
$date= date("Y-m-d");

foreach($routes as $route){

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

                          <td><?php echo $route['route_title'];?></td>
                          <td><?php echo $route['route_fare'];?></td>

                          <td>        
            

            	<a style="padding: 0px 5px; font-size:14px;"  href="route.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&routeup=<?php echo $route['route_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?route_id=<?php echo $route['route_id'];?>&action=DeleteRoute" 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>

 
        
                          </td>

                        </tr>
<?php } ?>
                      

                      </tbody>
                    </table>
           
          </div>
        </div>

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

    
  <?php include('RootMe/js_linksscript.php');?>
  </body>
</html>
<script>
function toastFunction() {
  var x = document.getElementById("snackbar");
  x.className = "show";
  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>