ESH/ambulance_mobile.php

176 lines
5.1 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include ('includes/functions.php');
include ('log_entry.php');
?>
<script src="assets/js/jquery-2.1.4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-dialog.min.css" />
<style>
.results tr[visible='false'],
.no-result{
display:none;
}
.results tr[visible='true']{
display:table-row;
}
.table{
font-size: 20px;
}
.counter{
padding:8px;
color:#ccc;
}
</style>
<body style=" background-color: #A9CCE3;">
<div class="box box-primary center"
style=" width: 100%; " >
<div class="form-group pull-right">
<br>
<br>
<center>
<b> <label for="">Search</label></b><input style=" width: 30%; " type="text" class="search form-control" placeholder="What you looking for?">
</center>
</div>
<span class="counter pull-right"></span>
<table class="table table-hover table-bordered results" style="font-size: 20px; background-color: white;">
<thead>
<tr style="font-size: 20px;">
<th>#</th>
<th colspan="2"></th>
<th class="col-md-5 col-xs-5">Ambulance</th>
<th class="col-md-4 col-xs-4">City</th>
<th class="col-md-3 col-xs-3">Driver Name</th>
</tr>
<tr class="warning no-result">
<td colspan="4"><i class="fa fa-warning"></i> No result</td>
</tr>
</thead>
<tbody>
<tr>
<?php
$sql = "SELECT * FROM ambulance_usage_details ORDER BY ambulance_usage_id DESC";
$query = mysqli_query($conn , $sql);
$i=1;
while ($p = mysqli_fetch_assoc($query)) {?>
<th scope="row"><?php echo $i ?></th>
<th>
<span>
<button onclick="editAm(<?php echo $p['ambulance_usage_id'] ?>)" class="btn btn-info"> <i class="fa-solid fa-pen"></i> </button>
</span>
</th>
<th>
<button onclick="deleteAm(<?php echo $p['ambulance_usage_id'] ?>)" class="btn btn-danger"><i class="fa-solid fa-trash"></i></button>
</th>
<td><?php echo $p['ambulance_number'] ?></td>
<td><?php echo $p['city'] ?></td>
<td><?php echo getTableFieldValue('patient_master' , 'patient_name' , 'id' , $p['ambulance_driver']) ?></td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
</div>
<script>
function editAm(flex_ambulance_id) {
location.href = "ambulance_details.php?flex_ambulance_id=" + flex_ambulance_id + "";
}
function deleteAm(id){
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: 'delete_ambulance_details.php',
data: {
ambulance_id: id
},
type: 'POST',
dataType: 'json',
success: function(data) {
if (data == 'SUCCESS') {
Swal.fire(
'Deleted!',
'Your data has been deleted.',
'success'
)
setTimeout(() => {
location.reload();
}, 2000);
return;
}
},
error: function(data) {
Swal.fire(
'Error!',
'Error Deleting Ambulance.',
'error'
)
BootstrapDialog.alert('Error Deleting Ambulance');
return;
}
});
}
})
}
$(document).ready(function() {
$(".search").keyup(function () {
var searchTerm = $(".search").val();
var listItem = $('.results tbody').children('tr');
var searchSplit = searchTerm.replace(/ /g, "'):containsi('")
$.extend($.expr[':'], {'containsi': function(elem, i, match, array){
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
$(".results tbody tr").not(":containsi('" + searchSplit + "')").each(function(e){
$(this).attr('visible','false');
});
$(".results tbody tr:containsi('" + searchSplit + "')").each(function(e){
$(this).attr('visible','true');
});
var jobCount = $('.results tbody tr[visible="true"]').length;
$('.counter').text(jobCount + ' item');
if(jobCount == '0') {$('.no-result').show();}
else {$('.no-result').hide();}
});
});
</script>
</body>