<?php
$sym = setting('currency_symbol','Rs.');
$sizes = ['small'=>[38,22], 'medium'=>[50,30], 'large'=>[70,40]];
[$w,$h] = $sizes[$labelW] ?? $sizes['medium'];
?>
<!doctype html><html><head><meta charset="utf-8"><title>Barcode Labels</title><style>
@page{margin:5mm}*{box-sizing:border-box}body{margin:0;font-family:Arial,sans-serif}.sheet{display:flex;flex-wrap:wrap;gap:2mm}.label{width:<?=$w?>mm;height:<?=$h?>mm;border:1px dashed #bbb;padding:2mm;text-align:center;display:flex;flex-direction:column;justify-content:center;overflow:hidden}.name{font-size:9pt;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.barcode{font:12pt monospace;letter-spacing:1px;margin-top:2mm}.price{font-size:10pt;font-weight:700;margin-top:1mm}@media print{.no-print{display:none}.label{border:0}}
</style></head><body><div class="no-print" style="padding:10px"><button onclick="print()">Print</button></div><div class="sheet">
<?php foreach($products as $p): for($i=0;$i<$copies;$i++): ?><div class="label"><div class="name"><?=e($p['product_name'])?></div><div class="barcode"><?=e($p['barcode'])?></div><div class="price"><?=e($sym)?> <?=number_format((float)$p['selling_price'],2)?></div></div><?php endfor; endforeach; ?>
</div><script>window.addEventListener('load',()=>window.print());</script></body></html>
