|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/assetradar.outerorbittech.com/tl/ | |
|
Path: /home2/outerorb/assetradar.outerorbittech.com/tl/team_items.php
Size: 4.08 KB
Permissions: 0666
<?php
require_once __DIR__ . '/../inc/auth.php';
require_login();
$u = current_user();
require_tl();
include __DIR__ . '/../inc/header.php';
include __DIR__ . '/tl_menu.php';
$team_id = (int)$u['team_id'];
$items = $mysqli->query('SELECT i.*, u.name as assigned_name FROM items i JOIN users u ON i.assigned_to=u.id WHERE u.team_id=' . $team_id);
?>
<div class="container mt-4">
<h4>Team Items</h4>
<div class="mb-2 d-flex flex-wrap gap-2 align-items-center">
<input type="text" id="searchInput" class="form-control w-auto" placeholder="Search..." style="max-width:200px;">
<select id="conditionFilter" class="form-select w-auto" style="max-width:160px;">
<option value="">All Conditions</option>
<option value="Working">Working</option>
<option value="Damaged">Damaged</option>
</select>
</div>
<table class="table" id="teamItemsTable">
<thead><tr><th>Asset Tag</th><th>Name</th><th>Condition</th><th>Assigned To</th></tr></thead>
<tbody>
<?php while($it = $items->fetch_assoc()): ?>
<tr>
<td><?php echo esc($it['asset_tag']); ?></td>
<td><?php echo esc($it['item_name']); ?></td>
<td><?php echo esc($it['condition_status']); ?></td>
<td><?php echo esc($it['assigned_name']); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center" id="itemsPagination"></ul>
</nav>
<script>
// Simple client-side search, filter, and pagination
const searchInput = document.getElementById('searchInput');
const conditionFilter = document.getElementById('conditionFilter');
const table = document.getElementById('teamItemsTable');
const pagination = document.getElementById('itemsPagination');
const rows = Array.from(table.tBodies[0].rows);
const perPage = 10;
let currentPage = 1;
searchInput.addEventListener('input', updateTable);
conditionFilter.addEventListener('change', updateTable);
function updateTable() {
const search = searchInput.value.toLowerCase();
const cond = conditionFilter.value;
let filtered = rows.filter(row => {
let txt = row.innerText.toLowerCase();
let condVal = row.cells[2].innerText;
let show = (!search || txt.includes(search));
if (cond && condVal !== cond) show = false;
return show;
});
// Pagination
let totalPages = Math.ceil(filtered.length / perPage);
if (currentPage > totalPages) currentPage = 1;
rows.forEach(r => r.style.display = 'none');
filtered.slice((currentPage-1)*perPage, currentPage*perPage).forEach(r => r.style.display = '');
// Render pagination
pagination.innerHTML = '';
for (let i=1; i<=totalPages; i++) {
let li = document.createElement('li');
li.className = 'page-item' + (i===currentPage?' active':'');
let a = document.createElement('a');
a.className = 'page-link';
a.href = '#';
a.textContent = i;
a.onclick = (e) => { e.preventDefault(); currentPage=i; updateTable(); };
li.appendChild(a);
pagination.appendChild(li);
}
}
updateTable();
// Simple client-side search and filter
const searchInput = document.getElementById('searchInput');
const conditionFilter = document.getElementById('conditionFilter');
const table = document.getElementById('teamItemsTable');
searchInput.addEventListener('input', filterTable);
conditionFilter.addEventListener('change', filterTable);
function filterTable() {
const search = searchInput.value.toLowerCase();
const cond = conditionFilter.value;
for (const row of table.tBodies[0].rows) {
let txt = row.innerText.toLowerCase();
let show = (!search || txt.includes(search));
let condVal = row.cells[2].innerText;
if (cond && condVal !== cond) show = false;
row.style.display = show ? '' : 'none';
}
}
</script>
</div>
<?php include __DIR__ . '/../inc/footer.php'; ?>