@extends('layouts.app')
@section('title','Company Settings') @section('page_title','Company Settings')
@section('content')<div class="page-header"><div><h1>Company Settings</h1><p class="muted">Legal identity, UAE VAT settings, branding and future e-invoicing provider configuration.</p></div></div>
<div class="card"><div class="card-header"><h3>Legal Entity & Branding</h3></div><div class="card-body"><form method="post" enctype="multipart/form-data" action="{{ route('settings.update') }}">@csrf @method('put')<div class="form-grid"><div class="field"><label>Legal Name *</label><input class="control" name="legal_name" value="{{ old('legal_name',$company->legal_name) }}" required></div><div class="field"><label>Trade Name</label><input class="control" name="trade_name" value="{{ old('trade_name',$company->trade_name) }}"></div><div class="field"><label>TRN</label><input class="control" name="trn" value="{{ old('trn',$company->trn) }}"></div><div class="field"><label>Trade Licence Number</label><input class="control" name="trade_license_number" value="{{ old('trade_license_number',$company->trade_license_number) }}"></div><div class="field"><label>Email</label><input class="control" type="email" name="email" value="{{ old('email',$company->email) }}"></div><div class="field"><label>Phone</label><input class="control" name="phone" value="{{ old('phone',$company->phone) }}"></div><div class="field"><label>Website</label><input class="control" name="website" value="{{ old('website',$company->website) }}"></div><div class="field"><label>Financial Year Start</label><select class="control" name="financial_year_start_month">@foreach(range(1,12) as $m)<option value="{{ $m }}" @selected((int)old('financial_year_start_month',$company->financial_year_start_month)===$m)>{{ DateTime::createFromFormat('!m',$m)->format('F') }}</option>@endforeach</select></div><div class="field span-2"><label>Address</label><textarea class="control" name="address" rows="3">{{ old('address',$company->address) }}</textarea></div><div class="field"><label>Logo (PNG/JPG/WebP)</label><input class="control" type="file" name="logo" accept="image/png,image/jpeg,image/webp">@if($company->logo_path)<small>Current: {{ $company->logo_path }}</small>@endif</div><div class="field"><label>Stamp Image</label><input class="control" type="file" name="stamp" accept="image/png,image/jpeg,image/webp"></div><div class="field"><label>VAT Registration Date</label><input class="control" type="date" name="vat_registration_date" value="{{ old('vat_registration_date',$company->vat_registration_date?->format('Y-m-d')) }}"></div><div class="field"><label class="checkbox"><input type="checkbox" name="vat_registered" value="1" @checked(old('vat_registered',$company->vat_registered))> VAT registered</label></div><div class="field span-2"><label>Bank Details shown on invoices</label><textarea class="control" name="bank_details" rows="4">{{ old('bank_details',$company->bank_details) }}</textarea></div><div class="field span-2"><label>Default Invoice Terms</label><textarea class="control" name="invoice_terms" rows="5">{{ old('invoice_terms',$company->invoice_terms) }}</textarea></div></div><div class="form-actions"><button class="btn btn-primary">Save Company Settings</button></div></form></div></div>
<div class="card" style="margin-top:20px"><div class="card-header"><h3>UAE E-Invoicing Provider Adapter</h3></div><div class="card-body"><div class="alert alert-warning">This screen stores encrypted provider credentials. It does not claim a direct government connection. Production must remain disabled until an accredited provider adapter is installed, sandbox-tested and approved.</div><form method="post" action="{{ route('settings.einvoice') }}">@csrf @method('put')<div class="form-grid"><div class="field"><label>Provider Name *</label><input class="control" name="provider_name" value="{{ old('provider_name',$einvoice->provider_name==='unconfigured'?'':$einvoice->provider_name) }}" required></div><div class="field"><label>Environment *</label><select class="control" name="environment"><option value="sandbox" @selected(old('environment',$einvoice->environment)==='sandbox')>Sandbox</option><option value="production" @selected(old('environment',$einvoice->environment)==='production')>Production</option></select></div><div class="field"><label>Electronic Address</label><input class="control" name="electronic_address" value="{{ old('electronic_address',$einvoice->electronic_address) }}"></div><div class="field"><label>Address Scheme</label><input class="control" name="electronic_address_scheme" value="{{ old('electronic_address_scheme',$einvoice->electronic_address_scheme) }}"></div><div class="field span-2"><label>Provider Endpoint</label><input class="control" name="endpoint" placeholder="https://sandbox.provider.example/api"></div><div class="field"><label>Client ID</label><input class="control" name="client_id" autocomplete="off"></div><div class="field"><label>Client Secret</label><input class="control" type="password" name="client_secret" autocomplete="new-password"></div><div class="field"><label>API Key</label><input class="control" type="password" name="api_key" autocomplete="new-password"></div><div class="field"><label>Webhook Secret</label><input class="control" type="password" name="webhook_secret" autocomplete="new-password"></div><div class="field"><label class="checkbox"><input type="checkbox" name="is_active" value="1" @checked(old('is_active',$einvoice->is_active))> Configuration active</label></div><div class="field"><label class="checkbox"><input type="checkbox" name="production_enabled" value="1" @checked(old('production_enabled',$einvoice->production_enabled))> Explicitly enable production</label></div></div><div class="form-actions"><button class="btn btn-primary">Save Provider Configuration</button></div></form></div></div>
@endsection
