<?php require dirname(__DIR__).'/app/core.php';$id=(int)($_GET['id']??0);$a=['id'=>0,'serial_number'=>'','owned_by'=>'sefiso','owner_client_id'=>'','model'=>'InMetro','asset_condition'=>'new','designation'=>'For sale','current_location'=>'Receiving','recertification_expiration_date'=>'','notes'=>''];if($id){$s=$pdo->prepare('SELECT * FROM afguards WHERE id=?');$s->execute([$id]);$a=$s->fetch()?:exit('Not found');}$clients=$pdo->query('SELECT c.id,c.name,co.name country FROM clients c JOIN countries co ON co.code=c.country_code ORDER BY c.name')->fetchAll();$title=$id?'Edit Sensor':'Add Sensor';require dirname(__DIR__).'/views/head.php';?><h1><?=e($title)?></h1><form class="panel" method="post" action="<?=e(u('asset-save.php'))?>"><input type="hidden" name="csrf" value="<?=e(token())?>"><input type="hidden" name="id" value="<?=$id?>"><div class="grid"><label><span>Serial</span><input id="serial_number" name="serial_number" maxlength="12" value="<?=e($a['serial_number'])?>" required></label><label><span>Owned By</span><select name="owned_by"><option value="sefiso" <?=$a['owned_by']==='sefiso'?'selected':''?>>Sefiso</option><option value="client" <?=$a['owned_by']==='client'?'selected':''?>>Client</option></select></label><label><span>Client</span><select name="owner_client_id"><option value="">None</option><?php foreach($clients as $c):?><option value="<?=$c['id']?>" <?=(int)$a['owner_client_id']===(int)$c['id']?'selected':''?>><?=e($c['name'].' — '.$c['country'])?></option><?php endforeach;?></select></label><label><span>Model</span><select name="model"><?php foreach(['InMetro','Offshore'] as $v):?><option <?=$a['model']===$v?'selected':''?>><?=$v?></option><?php endforeach;?></select></label><label><span>Condition</span><select name="asset_condition"><?php foreach(['new','used','scrap'] as $v):?><option <?=$a['asset_condition']===$v?'selected':''?>><?=$v?></option><?php endforeach;?></select></label><label><span>Designation</span><select name="designation"><option value="">None</option><?php foreach(['For sale','Rental','Loan','Recertification','Interim Recert','Recalibration'] as $v):?><option <?=$a['designation']===$v?'selected':''?>><?=$v?></option><?php endforeach;?></select></label><label><span>Location</span><select name="current_location"><?php foreach(['SERM1','Receiving','Laboratory','Shipping','GmbH','Lost'] as $v):?><option <?=$a['current_location']===$v?'selected':''?>><?=$v?></option><?php endforeach;?></select></label><label><span>Annual Expiration</span><input type="date" name="recertification_expiration_date" value="<?=e($a['recertification_expiration_date'])?>"></label><label class="full"><span>Notes</span><textarea name="notes"><?=e($a['notes'])?></textarea></label></div><div class="toolbar"><button>Save</button><a class="btn secondary" href="<?=e(u('assets.php'))?>">Cancel</a></div></form><?php require dirname(__DIR__).'/views/foot.php';?>