403Webshell
Server IP : 172.67.187.206  /  Your IP : 172.71.28.156
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 :  /Inetpub/www/supply_system/requisitions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Inetpub/www/supply_system/requisitions/history_dept.php
<?php
include_once __DIR__ . '/../config.php';
include_once __DIR__ . '/../functions.php';
include_once __DIR__ . '/../includes/auth_check.php';
// requireRole(['head_of_department']);

$page_title = "ประวัติการเบิกพัสดุของกลุ่มงาน";
$user_dept_id = getUserData('department_id');
$department_name = '';

// --- Fetch Requisitions for the head's department ---
$requisitions = [];
if ($user_dept_id) { // Ensure the user belongs to a department
    // Get department name
    $sql_dept = "SELECT dept_name FROM departments WHERE id = $user_dept_id";
    $res_dept = mysqli_query($conn, $sql_dept);
    if($res_dept && $row_dept = mysqli_fetch_assoc($res_dept)){
        $department_name = $row_dept['dept_name'];
        mysqli_free_result($res_dept);
    }

    $sql = "SELECT r.id, r.requisition_no, r.request_date, r.status, u.full_name as requester_name, r.total_value, r.approved_date
            FROM requisitions r
            JOIN users u ON r.requested_by = u.id
            WHERE r.department_id = $user_dept_id
            ORDER BY r.request_date DESC, r.id DESC";
    $result = mysqli_query($conn, $sql);
    if ($result) {
        while ($row = mysqli_fetch_assoc($result)) {
            $requisitions[] = $row;
        }
        mysqli_free_result($result);
    } else {
        echo "Error fetching requisitions: " . mysqli_error($conn);
    }
}
mysqli_close($conn);

// --- Include Header and Sidebar ---
include_once __DIR__ . '/../includes/header.php';
include_once __DIR__ . '/../includes/sidebar_head.php';
?>

<div class="container-fluid">
    <h1 class="mt-4"><?php echo $page_title; ?></h1>
    <?php if($department_name): ?>
    <h5 class="text-muted mb-3"><?php echo htmlspecialchars($department_name); ?></h5>
    <?php endif; ?>

    <div class="card mb-4">
        <div class="card-header">
            <i class="bi bi-clock-history me-1"></i>
            ประวัติการเบิก
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered table-striped table-hover">
                     <thead class="table-dark">
                        <tr>
                            <th>#</th>
                            <th>เลขที่คำขอ</th>
                            <th>วันที่ขอ</th>
                            <th>ผู้ขอเบิก</th>
                            <th>สถานะ</th>
                            <th class="text-end">มูลค่ารวม (ถ้าอนุมัติ)</th>
                            <th>วันที่อนุมัติ</th>
                            <th>ดำเนินการ</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if (!empty($requisitions)): ?>
                            <?php $counter = 1; ?>
                            <?php foreach ($requisitions as $req): ?>
                                <tr>
                                    <td><?php echo $counter++; ?></td>
                                    <td><?php echo htmlspecialchars($req['requisition_no']); ?></td>
                                    <td><?php echo formatThaiDate($req['request_date'], false); ?></td>
                                     <td><?php echo htmlspecialchars($req['requester_name']); ?></td>
                                    <td>
                                        <?php
                                            $status_badge = 'secondary';
                                            $status_text = $req['status'];
                                            switch ($req['status']) {
                                                case 'pending': $status_badge = 'warning text-dark'; $status_text = 'รอรับทราบ'; break;
                                                case 'head_approved': $status_badge = 'info text-dark'; $status_text = 'รอพัสดุอนุมัติ'; break;
                                                case 'approved': $status_badge = 'success'; $status_text = 'อนุมัติแล้ว'; break;
                                                case 'rejected': $status_badge = 'danger'; $status_text = 'ไม่อนุมัติ (พัสดุ)'; break;
                                                case 'head_rejected': $status_badge = 'danger'; $status_text = 'ไม่อนุมัติ (ผอ.)'; break;
                                            }
                                        ?>
                                        <span class="badge bg-<?php echo $status_badge; ?>"><?php echo $status_text; ?></span>
                                    </td>
                                    <td class="text-end">
                                        <?php echo ($req['status'] == 'approved') ? number_format($req['total_value'], 2) : '-'; ?>
                                    </td>
                                     <td><?php echo $req['approved_date'] ? formatThaiDate($req['approved_date'], false) : '-'; ?></td>
                                    <td>
                                        <a href="view.php?id=<?php echo $req['id']; ?>" class="btn btn-sm btn-info" title="ดูรายละเอียด">
                                            <i class="bi bi-search"></i>
                                        </a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <tr>
                                <td colspan="8" class="text-center">ไม่มีประวัติการเบิกของกลุ่มงานนี้</td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<?php
// --- Include Footer ---
include_once __DIR__ . '/../includes/footer.php';
?>

Youez - 2016 - github.com/yon3zu
LinuXploit