<?php 
require("../connection.php");
include("../user.php");
$user_id = $_SESSION['user'];
$username = $_SESSION['user_name'];

$branch = $_REQUEST['id'];

$asset_id = mysqli_query($con, "SELECT * FROM `item_master` WHERE division='$branch' AND status=0");

if (mysqli_num_rows($asset_id) > 0) {
?>
    <div class="col col-md-3">
        <label for="text-input" class="form-control-label">Asset ID</label><span style="color:red;">*</span>
    </div>
    <div class="col-12 col-md-9">
        <select id="asset_code" name="asset_code" onchange="asse_code(this.value)" class="form-control" autocomplete="off" required>
            <option value="" selected disabled>Select asset code</option>
            <?php 
            while($asset = mysqli_fetch_array($asset_id)) {
            ?>
                <option value="<?php echo $asset['id']; ?>">
                    <?php echo $asset['category'] . '-' . $asset['category_description']; ?>
                </option>
            <?php } ?>
        </select>
    </div>
<?php 
} else {
    // No items found
?>
    <div class="col-12 col-md-12">
        <div class="alert alert-warning">No assets found for this branch.</div>
    </div>
<?php 
}
?>
