<?php $pageTitle='Provider Rates';require __DIR__.'/../lib/bootstrap.php';require_login(array('provider'));$src=db_one("SELECT id FROM rate_sources WHERE owner_user_id=? AND source_type='provider'",array(user()['id']));if($_SERVER['REQUEST_METHOD']==='POST'&&verify_csrf()){if(!$src){db_exec("INSERT INTO rate_sources(name,source_type,owner_user_id,status,created_at) VALUES(?, 'provider', ?, 'active', NOW())",array(user()['name'],user()['id']));$src=db_one("SELECT id FROM rate_sources WHERE owner_user_id=?",array(user()['id']));}$amount=(float)$_POST['amount'];$fee=(float)$_POST['fee'];$rate=(float)$_POST['rate'];db_exec("INSERT INTO rate_quotes(source_id,from_currency,to_currency,send_amount,rate,fee_amount,recipient_amount,delivery_label,data_method,status,captured_at,expires_at) VALUES(?,?,?,?,?,?,?,?,?,'pending',NOW(),DATE_ADD(NOW(),INTERVAL 30 MINUTE))",array($src['id'],$_POST['from_currency'],$_POST['to_currency'],$amount,$rate,$fee,($amount-$fee)*$rate,$_POST['delivery_label'],'provider'));flash('success','Rate submitted for validation.');redirect('provider/rates.php');}require __DIR__.'/../blocks/app-header.php';require __DIR__.'/../blocks/dashboard-open.php';?><div class="dash-head"><h1>Rates & availability</h1></div><div class="card form-card"><h3>Submit an indicative listing</h3><form method="post"><?=csrf_field()?><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>Reference amount</label><input class="form-control" type="number" name="amount" value="25000" 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" value="0"></div><div class="form-group"><label>Response / delivery</label><input class="form-control" name="delivery_label" value="Same-day response"></div></div><button class="dark-btn">Submit for approval</button></form></div><?php require __DIR__.'/../blocks/dashboard-close.php';require __DIR__.'/../blocks/app-footer.php';?>