<?php $pageTitle='Capture Rate';require __DIR__.'/../lib/bootstrap.php';require_login(array('operator','admin'));if($_SERVER['REQUEST_METHOD']==='POST'&&verify_csrf()){$amount=(float)$_POST['send_amount'];$fee=(float)$_POST['fee_amount'];$rate=(float)$_POST['rate'];$prev=db_one("SELECT rate FROM rate_quotes WHERE source_id=? AND from_currency=? AND to_currency=? ORDER BY id DESC LIMIT 1",array($_POST['source_id'],$_POST['from_currency'],$_POST['to_currency']));$status='pending';$note='';if($prev&&$prev['rate']>0&&abs($rate-$prev['rate'])/$prev['rate']>.03){$note='Anomaly: movement exceeds 3% from previous quote.';}db_exec("INSERT INTO rate_quotes(source_id,from_currency,to_currency,send_amount,rate,fee_amount,recipient_amount,delivery_label,data_method,status,validation_note,captured_by,captured_at,expires_at) VALUES(?,?,?,?,?,?,?,?,? ,?,?,?,NOW(),DATE_ADD(NOW(),INTERVAL 30 MINUTE))",array($_POST['source_id'],$_POST['from_currency'],$_POST['to_currency'],$amount,$rate,$fee,($amount-$fee)*$rate,$_POST['delivery_label'],'manual',$status,$note,user()['id']));flash('success','Quote captured and sent to validation.');redirect('operations/capture.php');}$sources=db_all("SELECT id,name FROM rate_sources WHERE status='active' ORDER BY name");require __DIR__.'/../blocks/app-header.php';require __DIR__.'/../blocks/dashboard-open.php';?><div class="dash-head"><h1>Capture standardized quote</h1></div><div class="card form-card"><form method="post"><?=csrf_field()?><div class="form-group"><label>Source</label><select class="form-control" name="source_id" required><?php foreach($sources as $s):?><option value="<?=e($s['id'])?>"><?=e($s['name'])?></option><?php endforeach;?></select></div><div class="form-row"><div class="form-group"><label>From</label><input class="form-control" name="from_currency" value="USD" required></div><div class="form-group"><label>To</label><input class="form-control" name="to_currency" value="NGN" required></div></div><div class="form-row"><div class="form-group"><label>Send amount</label><input class="form-control" type="number" name="send_amount" value="1000" required></div><div class="form-group"><label>Rate</label><input class="form-control" type="number" step="0.0001" name="rate" required></div></div><div class="form-row"><div class="form-group"><label>Fee</label><input class="form-control" type="number" step="0.01" name="fee_amount" value="0"></div><div class="form-group"><label>Delivery</label><input class="form-control" name="delivery_label" value="Minutes–hours"></div></div><button class="dark-btn">Save to validation queue</button></form></div><?php require __DIR__.'/../blocks/dashboard-close.php';require __DIR__.'/../blocks/app-footer.php';?>