<?php require dirname(__DIR__).'/app/core.php';require_login();$rows=$pdo->query("SELECT a.*,c.name client FROM afguards a LEFT JOIN clients c ON c.id=a.owner_client_id ORDER BY serial_number")->fetchAll();$title='Assets';require dirname(__DIR__).'/views/head.php';?><h1>Assets</h1><?php if(can_write()):?><div class="toolbar"><a class="btn" href="asset-form.php">Add Sensor</a><a class="btn" href="#import">Import CSV</a><a class="btn secondary" href="asset-export.php">Export CSV</a></div><?php endif;?><div class="wrap"><table><tr><th>Serial</th><th>Owner</th><th>Client</th><th>Model</th><th>Condition</th><th>Designation</th><th>Location</th><?php if(can_write()):?><th>Action</th><?php endif;?></tr><?php foreach($rows as $a):?><tr><td><?=e($a['serial_number'])?></td><td><?=e($a['owned_by'])?></td><td><?=e($a['client']??'—')?></td><td><?=e($a['model'])?></td><td><?=e($a['asset_condition'])?></td><td><?=e($a['designation']??'—')?></td><td><?=e($a['current_location'])?></td><?php if(can_write()):?><td><a href="asset-form.php?id=<?=$a['id']?>">Edit</a></td><?php endif;?></tr><?php endforeach;?></table></div><?php if(can_write()):?><section class="panel" id="import"><h2>Import Assets</h2><form method="post" enctype="multipart/form-data" action="asset-import.php"><input type="hidden" name="csrf" value="<?=e(token())?>"><input type="file" name="csv" accept=".csv" required><button>Import CSV</button></form></section><?php endif;?><?php require dirname(__DIR__).'/views/foot.php';?>