MMCT TEAM
Server IP : 82.112.239.40  /  Your IP : 18.116.60.124
Web Server : LiteSpeed
System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
User : u641149403 ( 641149403)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u641149403/domains/cabz4you.com/public_html/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u641149403/domains/cabz4you.com/public_html/admin/routes.php
<?php
require_once 'header.php';
require_once 'navbar.php';
$sql="select * from cab_types";
$result=$conn->query($sql);
if($result->num_rows>0)
{
  while($row=$result->fetch_assoc())
  {
    $cab_types[]=$row;
  }
}

$filter = "";
$city1 = '';
$city2 = '';
if (isset($_GET['city1']) || isset($_GET['city2'])) {
    $city1 = isset($_GET['city1']) ? $_GET['city1'] : '';
    $city2 = isset($_GET['city2']) ? $_GET['city2'] : '';

    // Build the filter conditions only if the cities are not empty
    $conditions = [];
    if (!empty($city1)) {
        $conditions[] = "city1='$city1'";
    }
    if (!empty($city2)) {
        $conditions[] = "city2='$city2'";
    }

    // Join the conditions with 'AND' and append to the WHERE clause
    if (!empty($conditions)) {
        $filter = "WHERE " . implode(' AND ', $conditions);
    }
}

$sql="SELECT route.* FROM route INNER JOIN cab_route ON cab_route.route_id=route.id $filter GROUP BY route.id  ORDER BY route.id DESC";
echo $sql;
$result=$conn->query($sql);

$routedata="SELECT DISTINCT(city1) FROM route";
$route_city=$conn->query($routedata);

$routedata2="SELECT DISTINCT(city2) FROM route";
$route_city2=$conn->query($routedata2);

?>

<style>
  .modal-body select{
    height: 46px!important;
  }
  .badge-warning {
    color: #212529;
    background-color: #ffc107;
  }
  .badge-danger {
    color: #fff;
    background-color: #dc3545;
  }
  .badge-success {
    color: #fff;
    background-color: #28a745;
  }
  #tbody .badge{
    font-size: 12px;
    padding: 10px 20px;
  }
</style>
<!-- Page content -->
<div class="container-fluid pt-8">
  <div class="page-header mt-0 p-3">
    <h3 class="mb-sm-0">ROUTES</h3>
    <a href="add_route" class="btn btn-primary pull-right" >
      <i class="fa fa-plus"></i>
    </a>

  </div>
  <div id="alert2"></div>
  <!-- Table -->
  <div class="row">
    <div class="col-12">
      <div class="card shadow">
        <div class="grid-margin">
          <div class="card-body">
            <form method="get" class="row justify-content-end mb-2">
              <div class="col-md-4">
                <select class="select2" name="city1" data-placeholder="Select City">
                  <option></option>
                  <?php while($city=$route_city->fetch_assoc()){ ?>
                    <option value="<?=$city['city1']?>" <?php if($city1==$city['city1']){echo 'selected';}?>><?=$city['city1']?></option>
                  <?php } ?>
                </select>
              </div>
              <div class="col-md-4">
                <select class="select2" name="city2" data-placeholder="Select City">
                  <option></option>
                  <?php while($city_2=$route_city2->fetch_assoc()){ ?>
                    <option value="<?=$city_2['city2']?>" <?php if($city2==$city_2['city2']){echo 'selected';}?>><?=$city_2['city2']?></option>
                  <?php } ?>
                </select>
              </div>
              <div class="col-md-2">
                <input type="submit" name="search" class="btn btn-success w-100" value="Search">
              </div>
              <?php if(!empty($city1)){ ?>
              <div class="col-md-2">
                <a href="routes" class="btn btn-danger">Remove Filter</a>
              </div>
            <?php } ?>
            </form>
            <div class="table-responsive">
              <table class="table text-center table-bordered card-table table-vcenter text-nowrap align-items-center" id="example">
                <thead>
                  <tr>
                    <th>S.No</th>
                    <th>From</th>
                    <th>To</th>
                    <th>Distance</th>
                    <th>Discount</th>
                    <th>Status</th>
                    <th>Action</th>
                  </tr>
                </thead>
                <?php
                $i=1;
                while($row=$result->fetch_assoc()){
                 ?>
                 <tr>
                  <td><?=$i;?></td>
                  <td><?=$row['city1']?></td>
                  <td><?=$row['city2']?></td>
                  <td><?=$row['distance']?></td>
                  <td><?=$row['discount']?>%</td>
                  <td>
                    <?php if($row['status']==1){
                      echo '<label class="badge badge-success">Active</label>';
                    }else{
                      echo '<label class="badge badge-danger">Disabled</label>';
                    }
                    ?>
                  </td>
                  <td>
                    <a href="edit_route.php?id=<?=$row['id']?>" class="btn btn-success"><i class="fa fa-edit btn-success"></i></a>
                    <button type="button" class="btn btn-danger" value="<?=$row['id']?>" onclick="del(<?=$row['id']?>)"><i class="fa fa-trash"></i></button>
                  </td>
                </tr>
                <?php $i++;} ?>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<?php
require_once 'footer.php';
require_once 'jslinks.php';
?>
<script src="assets/js/custom.js"></script>
<script src="assets/js/datatable.js"></script>
<script>
 function del(e) {
  var verify = confirm("Do you really want to delete!!!");
  if (verify) {
   $("#global-loader").show();
   $.ajax({
    url: "ajax_route.php",
    type: "POST",
    data: {
      delete_id: e,
    },
    success: function (response) {
      $("#global-loader").fadeOut();
      if (response == "success") {
        $("#global-loader").fadeOut();
        $('#alert2').html('<div class="alert alert-success">Successfully Deleted</div>').show()
        setTimeout(function () {
          $('#alert2').hide()
        }, 1000)
      } else {
        $('#alert2').html('<div class="alert alert-danger">Something Wrong, can\'t delete.</div>').show()
        setTimeout(function () {
          $('#alert2').hide()
        }, 1000)
      }
    },
  })
 }
}
</script>

MMCT - 2023