201 lines
7.9 KiB
PHP
201 lines
7.9 KiB
PHP
<style>
|
|
.dark-header thead th {
|
|
background-color: #343a40;
|
|
/* Dark gray background */
|
|
color: white;
|
|
/* White text color */
|
|
}
|
|
</style>
|
|
|
|
<div class="container">
|
|
<h2 class="text-left">Report <a class="btn btn-primary d-none" href="/admin/report/csv?format=csv&date=<?php echo $data['date']; ?>">Export</a></h2>
|
|
<div class="row mt-2 mb-2">
|
|
<div class="col-md-10 col-md-offset-1">
|
|
<form action="?" method="GET" class="form-inline">
|
|
<div class="input-group mr-2 mb-2">
|
|
<label class="mr-2" for="date">Date</label>
|
|
<input id="date" type="date" name="date" class="form-control" placeholder="" value="<?php echo htmlspecialchars($data['date'] ?? ''); ?>">
|
|
</div>
|
|
<div class="input-group mr-2 mb-2">
|
|
<label class="mr-2" for="start_date">Start</label>
|
|
<input id="start_date" type="date" name="start_date" class="form-control" placeholder=""
|
|
value="<?php echo htmlspecialchars($data['start_date'] ?? ''); ?>">
|
|
</div>
|
|
<div class="input-group mr-2 mb-2">
|
|
<label class="mr-2" for="end_date">End</label>
|
|
<input id="end_date" type="date" name="end_date" class="form-control" placeholder=""
|
|
value="<?php echo htmlspecialchars($data['end_date'] ?? ''); ?>">
|
|
</div>
|
|
<div class="input-group mr-2 mb-2">
|
|
<label class="mr-2" for="project">Project</label>
|
|
<input id="project" type="text" name="project" class="form-control" placeholder="Fuzzy project search..."
|
|
value="<?php echo htmlspecialchars($data['project'] ?? ''); ?>">
|
|
</div>
|
|
<span class="input-group-btn mb-2">
|
|
<button class="btn btn-primary mr-2" type="submit">Search</button>
|
|
<a class="btn btn-secondary" href="/admin/report">Clear</a>
|
|
</span>
|
|
<div class="text-muted small ml-2 mb-2">
|
|
Tip: If a start or end date is provided, the single Date filter is ignored.
|
|
</div>
|
|
</form>
|
|
</div><!-- /.col-md-10 -->
|
|
</div><!-- /.row -->
|
|
<!-- Table Responsive Wrapper -->
|
|
<div class="table-responsive">
|
|
<table class="table table-hover dark-header">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Project</th>
|
|
<th>Date</th>
|
|
<th>Type</th>
|
|
|
|
|
|
<!-- <th>New Lead</th>
|
|
<th>Outbound Dial</th>
|
|
<th>Pickup</th>
|
|
<th>Conversation</th>
|
|
<th>Booked Appointment</th>
|
|
<th>Callback Request</th> -->
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<?php foreach ($data['data'] as $key => $value) {
|
|
echo ' <tr>';
|
|
// echo ' <td>' . $value->id . ' <br/><a class=" text-info" href="/admin/project/edit/' . $value->id . '">edit</a> <a class="text-danger" href="/admin/project/delete/' . $value->id . '">delete</a></td>';
|
|
// echo ' <td>' . $value->id . ' <br/><a class="text-danger" href="/admin/project/delete/' . $value->id . '">delete</a></td>';
|
|
echo ' <td>' . $value->id . ' </td>';
|
|
echo ' <td>' . $value->project . ' </td>';
|
|
echo ' <td>' . $value->date . ' </td>';
|
|
echo ' <td>' . $value->type . ' </td>';
|
|
|
|
|
|
// echo ' <td>' . $value->new_lead . ' </td>';
|
|
// echo ' <td>' . $value->outbound_dial . ' </td>';
|
|
// echo ' <td>' . $value->pickup . ' </td>';
|
|
// echo ' <td>' . $value->conversation . ' </td>';
|
|
// echo ' <td>' . $value->booked_appointment . ' </td>';
|
|
// echo ' <td>' . $value->callback_request . ' </td>';
|
|
echo ' <td>
|
|
<form action="/admin/report/webhook/send/'. $value->id .'" method="POST">
|
|
|
|
<button class="btn btn-primary" type = "submit">
|
|
Send Webhook
|
|
</button>
|
|
</form>
|
|
</td>
|
|
';
|
|
|
|
echo '</tr>';
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
|
|
<?php
|
|
// Retrieve parameters
|
|
$total = $data['total'];
|
|
$currentPage = $data['page'];
|
|
$perPage = 10;
|
|
|
|
// Calculate the number of pages
|
|
$totalPages = ceil($total / $perPage);
|
|
|
|
// Define a range of pages to show at any given time
|
|
$range = 2; // This can be adjusted as needed
|
|
|
|
$startPage = ($currentPage - $range) > 0 ? ($currentPage - $range) : 1;
|
|
$endPage = ($currentPage + $range) < $totalPages ? ($currentPage + $range) : $totalPages;
|
|
|
|
?>
|
|
<!-- Pagination -->
|
|
<nav aria-label="Page navigation">
|
|
<ul class="pagination">
|
|
<?php
|
|
// Preserve filters in pagination links
|
|
$queryParams = [];
|
|
if (!empty($data['date'])) {
|
|
$queryParams['date'] = $data['date'];
|
|
}
|
|
if (!empty($data['start_date'])) {
|
|
$queryParams['start_date'] = $data['start_date'];
|
|
}
|
|
if (!empty($data['end_date'])) {
|
|
$queryParams['end_date'] = $data['end_date'];
|
|
}
|
|
if (!empty($data['project'])) {
|
|
$queryParams['project'] = $data['project'];
|
|
}
|
|
$queryString = !empty($queryParams) ? '&' . http_build_query($queryParams) : '';
|
|
?>
|
|
<li class="ml-2">
|
|
<a href="?page=1<?= $queryString ?>" aria-label="Previous">
|
|
<span aria-hidden="true">««</span>
|
|
</a>
|
|
</li>
|
|
<li class="ml-2">
|
|
<a href="?page=<?= ($currentPage - 1) > 0 ? $currentPage - 1 : 1 ?><?= $queryString ?>" aria-label="Previous">
|
|
<span aria-hidden="true">«</span>
|
|
</a>
|
|
</li>
|
|
<?php
|
|
for ($i = $startPage; $i <= $endPage; $i++) {
|
|
echo '<li class="ml-2' . ($currentPage == $i ? ' active' : '') . '"><a href="?page=' . $i . $queryString . '">' . $i . '</a></li>';
|
|
}
|
|
?>
|
|
<li class="ml-2">
|
|
<a href="?page=<?= ($currentPage + 1) < $totalPages ? $currentPage + 1 : $totalPages ?><?= $queryString ?>" aria-label="Next">
|
|
<span aria-hidden="true">»</span>
|
|
</a>
|
|
</li>
|
|
<li class="ml-2">
|
|
<a href="?page=<?= $totalPages ?><?= $queryString ?>" aria-label="Next">
|
|
<span aria-hidden="true">»»</span>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
|
function send(element, url, data) {
|
|
|
|
// Get the selected value (Yes or No)
|
|
var projectId = $(element).attr("data-id");
|
|
var selectedValue = $(element).val();
|
|
console.log(projectId)
|
|
console.log(selectedValue)
|
|
if (selectedValue == "On") {
|
|
var values = "Off"
|
|
}
|
|
if (selectedValue == "Off") {
|
|
var values = "On"
|
|
}
|
|
// Make an AJAX request to update the database
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/alert-toggle', // Replace with the actual path to your update script
|
|
data: {
|
|
projectId: projectId,
|
|
selectedValue: values
|
|
},
|
|
success: function(response) {
|
|
// Handle the response from the server (if needed)
|
|
console.log(response);
|
|
window.location.reload()
|
|
},
|
|
error: function(error) {
|
|
console.error('Error updating data:', error);
|
|
}
|
|
});
|
|
};
|
|
|
|
</script>
|