<?php $title='Ingredient Stock (Print)'; ob_start(); ?>
<style>
body{font-size:12px;}
@media print{ .no-print{display:none;} }
table{width:100%; border-collapse:collapse;}
th,td{border:1px solid #999; padding:2px 4px;}
</style>
<div class="no-print"><button onclick="window.print()">Print</button> <a href="/samanta_crm/stock/ingredients">Back</a></div>
<h3>Ingredient Stock</h3>
<table>
<thead><tr><th>ID</th><th>Ingredient</th><th>Unit</th><th>Location</th><th>Qty</th></tr></thead>
<tbody>
<?php foreach($stock as $r): $main = isset($r['main_stock'])? (int)round($r['main_stock']) : (int)round($r['stock']); $rollback= isset($r['rollback_stock'])? (int)round($r['rollback_stock']):0; ?>
<tr><td><?=$r['id']?></td><td><?=htmlspecialchars($r['name'])?></td><td><?=htmlspecialchars($r['unit'])?></td><td>MAIN</td><td><?=$main?></td></tr>
<?php if(isset($r['rollback_stock'])): ?><tr><td><?=$r['id']?></td><td><?=htmlspecialchars($r['name'])?></td><td><?=htmlspecialchars($r['unit'])?></td><td>ROLLBACK</td><td><?=$rollback?></td></tr><?php endif; ?>
<?php endforeach; ?>
</tbody></table>
<?php $content=ob_get_clean(); require __DIR__.'/../layout.php'; ?>