<?php
$page_title = 'View Volume Data';
require_once('includes/load.php');
page_require_level(2);

include_once('layouts/header.php');

// Retrieve volume data for categorie_id 7
$categorie_id = 7;
$sql = "SELECT part_number, name, volume FROM products WHERE categorie_id = '{$categorie_id}'";
$result = $db->query($sql);

if ($result && $db->num_rows($result) > 0) {
    $volume_data = $db->while_loop($result);
} else {
    $session->msg('w', "No volume data found for categorie_id 7.");
    $volume_data = [];
}
?>

<div class="row">
    <div class="col-md-12">
        <?php echo display_msg($msg); ?>
    </div>
</div>

<div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>
                    <span class="glyphicon glyphicon-th"></span>
                    <span>Volume Data for Categorie ID 7</span>
                </strong>
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>Part Number</th>
                            <th>Name</th>
                            <th>Volume</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if (!empty($volume_data)): ?>
                            <?php foreach ($volume_data as $data): ?>
                                <tr>
                                    <td><?php echo remove_junk($data['part_number']); ?></td>
                                    <td><?php echo remove_junk($data['name']); ?></td>
                                    <td><?php echo remove_junk($data['volume']); ?></td>
                                </tr>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <tr>
                                <td colspan="3">No data available</td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<?php include_once('layouts/footer.php'); ?>
