PYBS (Personel Yönetim Bilgi Sistemi) / Ramsa/panels/root-panel.php
root-panel.php 169 satır • 8.39 KB
<?php
// panels/root-panel.php
session_start();

// Yetki kontrolü
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'root') {
    header("Location: ../index.php");
    exit;
}

include '../includes/header.php';
include '../includes/menu.php';

// --- VERİLERİ ÇEK ---

// 1. Personel Sayısı (Root Hariç)
$sql_personel = "SELECT COUNT(*) FROM kullanicilar WHERE durum = 1 AND rol != 'root'";
$toplam_personel = $pdo->query($sql_personel)->fetchColumn();

// 2. Bekleyen İzinler
$sql_izin = "SELECT COUNT(*) FROM izin_talepleri WHERE durum = 'beklemede'";
$bekleyen_izin = $pdo->query($sql_izin)->fetchColumn();

// 3. Bekleyen Mesailer
$sql_mesai = "SELECT COUNT(*) FROM mesai_hareketleri WHERE durum = 'beklemede'";
$bekleyen_mesai = $pdo->query($sql_mesai)->fetchColumn();

// 4. Güvenlik Olayları (Bugün)
$bugun = date('Y-m-d');
$sql_log = "SELECT COUNT(*) FROM sistem_loglari WHERE islem_tipi = 'guvenlik_uyarisi' AND DATE(tarih) = CURDATE()";
$guvenlik_olayi = $pdo->query($sql_log)->fetchColumn();
?>

<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4 mt-2">
        <h3 class="m-0 text-dark fw-bold">Yönetim Paneli</h3>
        <span class="badge bg-secondary"><?php echo date("d.m.Y"); ?></span>
    </div>

    <div class="row g-3 mb-4">
        
        <div class="col-12 col-sm-6 col-xl-3">
            <a href="../modules/personel-yonetimi.php" class="text-decoration-none">
                <div class="card stat-card text-white bg-primary h-100" style="cursor: pointer;">
                    <div class="card-body d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="card-title text-uppercase mb-1" style="opacity: 0.8;">Personel</h6>
                            <h2 class="mb-0 fw-bold"><?php echo $toplam_personel; ?></h2>
                        </div>
                        <i class="fas fa-users fa-3x" style="opacity: 0.3;"></i>
                    </div>
                    <div class="card-footer bg-transparent border-0 small d-flex justify-content-between align-items-center" style="background: rgba(0,0,0,0.1);">
                        <span>Aktif Çalışan Listesi</span>
                        <i class="fas fa-arrow-circle-right"></i>
                    </div>
                </div>
            </a>
        </div>

        <div class="col-12 col-sm-6 col-xl-3">
            <a href="../modules/tum-izinler.php" class="text-decoration-none">
                <div class="card stat-card text-white bg-warning h-100" style="cursor: pointer;">
                    <div class="card-body d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="card-title text-uppercase mb-1 text-dark" style="opacity: 0.7;">İzin Talebi</h6>
                            <h2 class="mb-0 fw-bold text-dark"><?php echo $bekleyen_izin; ?></h2>
                        </div>
                        <i class="fas fa-file-contract fa-3x text-dark" style="opacity: 0.2;"></i>
                    </div>
                    <div class="card-footer bg-transparent border-0 small d-flex justify-content-between align-items-center text-dark" style="background: rgba(0,0,0,0.05);">
                        <span>Onay Bekleyen İzinler</span>
                        <i class="fas fa-arrow-circle-right"></i>
                    </div>
                </div>
            </a>
        </div>

        <div class="col-12 col-sm-6 col-xl-3">
            <a href="../modules/tum-mesailer.php" class="text-decoration-none">
                <div class="card stat-card text-white bg-success h-100" style="cursor: pointer;">
                    <div class="card-body d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="card-title text-uppercase mb-1" style="opacity: 0.8;">Mesai Talebi</h6>
                            <h2 class="mb-0 fw-bold"><?php echo $bekleyen_mesai; ?></h2>
                        </div>
                        <i class="fas fa-business-time fa-3x" style="opacity: 0.3;"></i>
                    </div>
                    <div class="card-footer bg-transparent border-0 small d-flex justify-content-between align-items-center" style="background: rgba(0,0,0,0.1);">
                        <span>Onay Bekleyen Mesailer</span>
                        <i class="fas fa-arrow-circle-right"></i>
                    </div>
                </div>
            </a>
        </div>

        <div class="col-12 col-sm-6 col-xl-3">
            <a href="../modules/log-izleme.php?islem_tipi=guvenlik_uyarisi&baslangic=<?php echo $bugun; ?>&bitis=<?php echo $bugun; ?>" class="text-decoration-none">
                <div class="card stat-card text-white bg-danger h-100" style="cursor: pointer;">
                    <div class="card-body d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="card-title text-uppercase mb-1" style="opacity: 0.8;">Güvenlik</h6>
                            <h2 class="mb-0 fw-bold"><?php echo $guvenlik_olayi; ?></h2>
                        </div>
                        <i class="fas fa-shield-virus fa-3x" style="opacity: 0.3;"></i>
                    </div>
                    <div class="card-footer bg-transparent border-0 small d-flex justify-content-between align-items-center" style="background: rgba(0,0,0,0.1);">
                        <span>Bugünkü Riskli Olay</span>
                        <i class="fas fa-arrow-circle-right"></i>
                    </div>
                </div>
            </a>
        </div>

    </div>

    <div class="row g-4">
        <div class="col-lg-6">
            <div class="card-box p-4 h-100">
                <div class="d-flex align-items-center mb-3">
                    <div class="bg-primary text-white rounded-circle p-3 me-3">
                        <i class="fas fa-user-plus fa-lg"></i>
                    </div>
                    <div>
                        <h5 class="mb-0 fw-bold">Hızlı Personel Ekle</h5>
                        <small class="text-muted">Yeni personel veya yönetici kaydı</small>
                    </div>
                </div>
                <p class="text-muted">Sisteme yeni giriş yapacak personeli buradan tanımlayabilirsiniz. TC ve Telefon bilgileri gereklidir.</p>
                <a href="../modules/personel-ekle.php" class="btn btn-outline-primary w-100">Kayıt Ekranına Git <i class="fas fa-arrow-right ms-2"></i></a>
            </div>
        </div>

        <div class="col-lg-6">
            <div class="card-box p-4 h-100">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <h5 class="mb-0 fw-bold"><i class="fas fa-history text-warning me-2"></i> Son Sistem Logları</h5>
                    <a href="../modules/log-izleme.php" class="btn btn-sm btn-light">Tümü</a>
                </div>
                <div class="table-responsive">
                    <table class="table table-hover table-sm align-middle">
                        <thead class="table-light">
                            <tr>
                                <th>Kullanıcı</th>
                                <th>İşlem</th>
                                <th>Saat</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $loglar = $pdo->query("SELECT k.kullanici_adi, l.aciklama, l.tarih 
                                                   FROM sistem_loglari l 
                                                   LEFT JOIN kullanicilar k ON l.kullanici_id = k.id 
                                                   ORDER BY l.id DESC LIMIT 5")->fetchAll();
                            foreach($loglar as $log): ?>
                            <tr>
                                <td class="fw-bold text-primary"><?php echo $log['kullanici_adi'] ?: 'Sistem'; ?></td>
                                <td class="small text-muted"><?php echo mb_substr($log['aciklama'], 0, 40); ?>...</td>
                                <td class="small"><?php echo date('H:i', strtotime($log['tarih'])); ?></td>
                            </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<?php include '../includes/footer.php'; ?>