<div class="card-box">
<div class="col-12">
    <div class="card-box-header">
        <h5>
            <i class="fa fa-print icon_hover" onclick="window.print()" style="font-size:18px;cursor:pointer;margin-right:8px;"></i>
            <i class="fa-solid fa-ruler text-success"></i> Unit Master
        </h5>
        <a href="<?php echo site_url('unit/create'); ?>" class="btn btn-primary btn-sm">
            <i class="fa-solid fa-plus me-1"></i> Add Unit
        </a>
    </div>
    <div class="print-title" style="display:none;">Unit Master</div>
    <div class="table-responsive">
        <table id="unit_detailview" class="table table-bordered table-hover dt-table mb-0">
            <thead>
                <tr>
                    <th width="60">Sr.</th>
                    <th>Unit Name</th>
                    <th width="120" class="text-center">Status</th>
                    <th width="160" class="text-center">Action</th>
                </tr>
            </thead>
            <tbody>
                <?php if(!empty($unitdata)): $sr = 1; foreach($unitdata as $row): ?>
                <tr>
                    <td><?php echo $sr++; ?></td>
                    <td><?php echo htmlspecialchars($row->unit_name); ?></td>
                    <td class="text-center">
                        <?php if($row->status == 1): ?>
                            <span class="badge-active"><i class="fa-solid fa-circle-check me-1"></i>Active</span>
                        <?php else: ?>
                            <span class="badge-inactive"><i class="fa-solid fa-circle-xmark me-1"></i>Inactive</span>
                        <?php endif; ?>
                    </td>
                    <td class="text-center">
                        <a href="<?php echo site_url('unit/edit/'.$row->id); ?>" class="btn btn-sm btn-edit me-1"><i class="fa-solid fa-pen-to-square"></i></a>
                        <!--<a href="<?php echo site_url('unit/delete/'.$row->id); ?>" class="btn btn-sm btn-delete btn-delete-confirm"><i class="fa-solid fa-trash"></i></a>-->
                    </td>
                </tr>
                <?php endforeach; else: ?>
                <tr><td colspan="4" class="text-center py-4 text-muted">No units found. <a href="<?php echo site_url('unit/create'); ?>">Add first</a></td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
</div>