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/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: dashboard.php

Path: /home2/outerorb/assetradar.outerorbittech.com/tl/dashboard.php

Size: 6.69 KB

Permissions: 0666

<?php
require_once __DIR__ . '/../inc/auth.php';
require_login();
$u = current_user();
if ($u['role_slug'] !== 'tl') header('Location: ' . BASE_URL . '/index.php');
include __DIR__ . '/../inc/header.php';
include __DIR__ . '/tl_menu.php';

// Team queries
$team_id = (int)$u['team_id'];
$members = $mysqli->query('SELECT id,name,email FROM users WHERE team_id=' . $team_id . ' AND deleted=0');
$my_items = $mysqli->query('SELECT * FROM items WHERE assigned_to='.(int)$u['id']);
$team_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);
$my_tickets = $mysqli->query('SELECT * FROM tickets WHERE user_id='.(int)$u['id']);
$team_tickets = $mysqli->query('SELECT t.*, u.name as reporter FROM tickets t JOIN users u ON t.user_id=u.id WHERE u.team_id=' . $team_id);
// Recent team tickets (last 5)
$recent_team_tickets = $mysqli->query("SELECT t.id, t.item_name, t.issue_type, t.status FROM tickets t JOIN users u ON t.user_id=u.id WHERE u.team_id=$team_id ORDER BY t.created_at DESC LIMIT 5");
// Team items needing attention
$attention_team_items = $mysqli->query("SELECT i.id, i.asset_tag, i.item_name, i.condition_status, i.warranty_to AS warranty_expiry FROM items i JOIN users u ON i.assigned_to=u.id WHERE u.team_id=$team_id AND (i.condition_status='Damaged' OR (i.warranty_to IS NOT NULL AND i.warranty_to <= DATE_ADD(CURDATE(), INTERVAL 30 DAY))) ORDER BY i.warranty_to ASC LIMIT 5");
?>
<?php if (isset($_GET['success']) && $_GET['success'] == 1): ?>
  <div class="alert alert-success">Issue reported successfully!</div>
<?php endif; ?>

<div class="container mt-4">
  <div class="row g-3">
    <div class="col-12 col-sm-6 col-lg-3">
      <div class="card shadow-sm h-100 mb-2 mb-lg-0">
        <div class="card-body text-center">
          <h6 class="card-title">My Items</h6>
          <p class="card-text"><strong><?php echo $my_items->num_rows; ?></strong> items assigned to you.</p>
          <a href="my_items.php" class="btn btn-primary btn-sm w-100">View My Items</a>
        </div>
      </div>
    </div>
    <div class="col-12 col-sm-6 col-lg-3">
      <div class="card shadow-sm h-100 mb-2 mb-lg-0">
        <div class="card-body text-center">
          <h6 class="card-title">Team Items</h6>
          <p class="card-text"><strong><?php echo $team_items->num_rows; ?></strong> items assigned to team members.</p>
          <a href="team_items.php" class="btn btn-primary btn-sm w-100">View Team Items</a>
        </div>
      </div>
    </div>
    <div class="col-12 col-sm-6 col-lg-3">
      <div class="card shadow-sm h-100 mb-2 mb-lg-0">
        <div class="card-body text-center">
          <h6 class="card-title">My Tickets</h6>
          <p class="card-text"><strong><?php echo $my_tickets->num_rows; ?></strong> tickets reported by you.</p>
          <a href="my_tickets.php" class="btn btn-primary btn-sm w-100">View My Tickets</a>
        </div>
      </div>
    </div>
    <div class="col-12 col-sm-6 col-lg-3">
      <div class="card shadow-sm h-100 mb-2 mb-lg-0">
        <div class="card-body text-center">
          <h6 class="card-title">Team Tickets</h6>
          <p class="card-text"><strong><?php echo $team_tickets->num_rows; ?></strong> tickets reported by team members.</p>
          <a href="team_tickets.php" class="btn btn-primary btn-sm w-100">View Team Tickets</a>
        </div>
      </div>
    </div>
  </div>

  <div class="card p-3 card-hero mt-4">
    <h5>Team Summary</h5>
    <p>Team: <strong><?php echo esc($u['team_name']); ?></strong></p>
    <p>Members: <strong><?php echo $members->num_rows; ?></strong></p>
  </div>
</div>

<div class="row mt-4">
  <div class="col-md-6 mb-4">
    <div class="card p-3 h-100">
      <h6 class="mb-3">Recent Team Tickets</h6>
      <table class="table table-sm mb-0">
        <thead><tr><th>ID</th><th>Item</th><th>Issue</th><th>Status</th></tr></thead>
        <tbody>
        <?php while($t = $recent_team_tickets->fetch_assoc()): ?>
          <tr>
            <td><a href="team_tickets.php?id=<?php echo $t['id']; ?>" class="btn btn-link btn-sm">#<?php echo $t['id']; ?></a></td>
            <td><?php echo esc($t['item_name']); ?></td>
            <td><?php echo esc($t['issue_type']); ?></td>
            <td><?php echo esc($t['status']); ?></td>
          </tr>
        <?php endwhile; ?>
        </tbody>
      </table>
    </div>
  </div>
  <div class="col-md-6 mb-4">
    <div class="card p-3 h-100">
      <h6 class="mb-3">Team Items Needing Attention</h6>
      <table class="table table-sm mb-0">
        <thead><tr><th>Tag</th><th>Name</th><th>Status</th><th>Warranty Expiry</th></tr></thead>
        <tbody>
        <?php while($i = $attention_team_items->fetch_assoc()): ?>
          <tr>
            <td><?php echo esc($i['asset_tag']); ?></td>
            <td><?php echo esc($i['item_name']); ?></td>
            <td><?php echo esc($i['condition_status']); ?></td>
            <td><?php echo $i['warranty_expiry'] ? esc($i['warranty_expiry']) : '-'; ?></td>
          </tr>
        <?php endwhile; ?>
        </tbody>
      </table>
    </div>
  </div>
</div>


<!-- Chart.js CDN -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<div class="row mt-4">
  <div class="col-md-6 mb-4">
    <div class="card p-3">
      <h6 class="mb-3">Team Asset Status</h6>
      <canvas id="teamAssetChart" height="180"></canvas>
    </div>
  </div>
  <div class="col-md-6 mb-4">
    <div class="card p-3">
      <h6 class="mb-3">Team Ticket Status</h6>
      <canvas id="teamTicketChart" height="180"></canvas>
    </div>
  </div>
</div>

<script>
// Team asset status chart
const teamAssetData = {
  labels: ['Assigned', 'Damaged'],
  datasets: [{
    data: [<?php echo $team_items->num_rows; ?>, <?php 
      $damaged = 0;
      $team_items->data_seek(0);
      while($row = $team_items->fetch_assoc()) {
        if ($row['condition_status'] === 'Damaged') $damaged++;
      }
      echo $damaged;
    ?>],
    backgroundColor: ['#4f46e5', '#ef4444'],
    borderWidth: 1
  }]
};
new Chart(document.getElementById('teamAssetChart'), {
  type: 'pie',
  data: teamAssetData,
  options: {
    responsive: true,
    plugins: { legend: { position: 'bottom' } }
  }
});

// Team ticket status chart
fetch('team_tickets.php?chart_status=1')
  .then(res => res.json())
  .then(data => {
    new Chart(document.getElementById('teamTicketChart'), {
      type: 'doughnut',
      data: {
        labels: data.labels,
        datasets: [{
          data: data.counts,
          backgroundColor: ['#f59e42', '#4f46e5', '#10b981', '#ef4444'],
          borderWidth: 1
        }]
      },
      options: {
        responsive: true,
        plugins: { legend: { position: 'bottom' } }
      }
    });
  });
</script>

<?php include __DIR__ . '/../inc/footer.php'; ?>

← Back to Directory Edit File 🔒 Chmod

WP File Manager