192 lines
11 KiB
PHP
192 lines
11 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Invoice Settings')
|
|
@section('page-title', 'Invoice Settings 🧾')
|
|
@section('page-subtitle', 'Customize number format, header, and invoice defaults')
|
|
|
|
@section('content')
|
|
<div class="max-w-2xl mx-auto">
|
|
<div class="flex items-center gap-3 mb-5">
|
|
<a href="{{ route('invoices.index') }}"
|
|
class="text-xs px-3 py-2 rounded-full border border-pink-200 text-gray-500 hover:bg-pink-50">
|
|
← Back to Invoices
|
|
</a>
|
|
</div>
|
|
|
|
@if(session('success'))
|
|
<div x-data="{ show: true }" x-show="show" x-init="setTimeout(() => show = false, 4000)"
|
|
class="flex items-center justify-between gap-3 bg-green-50 border border-green-200 rounded-2xl px-4 py-3 text-sm text-green-700 mb-4">
|
|
<span>{{ session('success') }}</span>
|
|
<button @click="show = false" class="text-green-500 hover:text-green-700 text-lg leading-none">✕</button>
|
|
</div>
|
|
@endif
|
|
|
|
<form action="{{ route('invoice-settings.update') }}" method="POST" enctype="multipart/form-data"
|
|
class="space-y-5">
|
|
@csrf
|
|
|
|
{{-- Number Format --}}
|
|
<div class="cat-card p-5">
|
|
<h2 class="text-sm font-bold text-gray-700 mb-4 flex items-center gap-2">🔢 Invoice Number Format</h2>
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">
|
|
Prefix <span class="text-pink-400">*</span>
|
|
</label>
|
|
<input type="text" name="invoice_prefix"
|
|
value="{{ old('invoice_prefix', $settings->invoice_prefix) }}"
|
|
class="input-soft text-sm" placeholder="INV-EA" required
|
|
id="prefix-input" oninput="updatePreview()">
|
|
<p class="text-xs text-gray-400 mt-1">e.g. <code>INV-EA</code> → <strong>INV-EA-001</strong></p>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">
|
|
Next Number <span class="text-pink-400">*</span>
|
|
</label>
|
|
<input type="number" name="invoice_next_number"
|
|
value="{{ old('invoice_next_number', $settings->invoice_next_number) }}"
|
|
class="input-soft text-sm" min="1" required
|
|
id="number-input" oninput="updatePreview()">
|
|
<p class="text-xs text-gray-400 mt-1">Used for the next new invoice</p>
|
|
</div>
|
|
</div>
|
|
<div class="mt-3 bg-pink-50 rounded-xl px-4 py-2.5 text-sm text-gray-600">
|
|
Preview: <strong class="text-pink-600" id="number-preview">
|
|
{{ rtrim(old('invoice_prefix', $settings->invoice_prefix), '-') }}-{{ str_pad((string) (old('invoice_next_number', $settings->invoice_next_number) ?? 1), 3, '0', STR_PAD_LEFT) }}
|
|
</strong>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Header / Branding --}}
|
|
<div class="cat-card p-5">
|
|
<h2 class="text-sm font-bold text-gray-700 mb-4 flex items-center gap-2">🎨 Invoice Header</h2>
|
|
|
|
@if($settings->header_logo)
|
|
<div class="mb-3 flex items-center gap-3">
|
|
<img src="{{ asset('storage/' . $settings->header_logo) }}"
|
|
alt="Logo" class="h-16 w-16 object-cover rounded-2xl border border-pink-100">
|
|
<div>
|
|
<p class="text-xs font-semibold text-gray-600">Current Logo</p>
|
|
<p class="text-xs text-gray-400 mt-0.5">Upload a new file to replace it</p>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
<div class="sm:col-span-2">
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Logo / Profile Picture</label>
|
|
<input type="file" name="header_logo" accept="image/*"
|
|
class="w-full text-sm text-gray-600
|
|
file:mr-3 file:py-1.5 file:px-4
|
|
file:rounded-full file:border-0
|
|
file:text-xs file:font-semibold
|
|
file:bg-pink-50 file:text-pink-600
|
|
hover:file:bg-pink-100 cursor-pointer">
|
|
<p class="text-xs text-gray-400 mt-1">Max 2 MB. Shown at the top-left of your invoice.</p>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Talent / Business Name</label>
|
|
<input type="text" name="header_name"
|
|
value="{{ old('header_name', $settings->header_name) }}"
|
|
class="input-soft text-sm" placeholder="Your name or brand">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Title / Tagline</label>
|
|
<input type="text" name="header_title"
|
|
value="{{ old('header_title', $settings->header_title) }}"
|
|
class="input-soft text-sm" placeholder="Content Creator · KOL">
|
|
</div>
|
|
<div x-data="{ color: '{{ old('accent_color', $settings->accent_color ?? '#FFB7C5') }}' }">
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Accent Color</label>
|
|
<div class="flex items-center gap-3 mt-1">
|
|
<input type="color" name="accent_color" x-model="color"
|
|
class="w-10 h-10 rounded-xl cursor-pointer border-2 border-pink-100 p-0.5">
|
|
<div class="flex gap-2 flex-wrap">
|
|
@foreach(['#FFB7C5','#B5EAD7','#FDFD96','#E8D5F5','#FFD5B8','#AEC6CF','#FF8FAD','#A8D8EA'] as $preset)
|
|
<button type="button"
|
|
class="w-7 h-7 rounded-full ring-2 ring-transparent hover:ring-gray-400 transition-all"
|
|
style="background:{{ $preset }}"
|
|
@click="color = '{{ $preset }}'"></button>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
<p class="text-xs text-gray-400 mt-1.5">Applied to your invoice header name and totals.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Invoice Defaults --}}
|
|
<div class="cat-card p-5">
|
|
<h2 class="text-sm font-bold text-gray-700 mb-4 flex items-center gap-2">📋 Invoice Defaults</h2>
|
|
<p class="text-xs text-gray-400 mb-4">These values will pre-fill every new invoice you create.</p>
|
|
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Tax Rate (%)</label>
|
|
<input type="number" name="default_tax_rate" step="0.01" min="0" max="100"
|
|
value="{{ old('default_tax_rate', $settings->default_tax_rate ?? 11) }}"
|
|
class="input-soft text-sm" placeholder="11">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Currency</label>
|
|
<select name="default_currency" class="input-soft text-sm">
|
|
@foreach(['IDR' => 'IDR (Rupiah)', 'USD' => 'USD (Dollar)', 'SGD' => 'SGD', 'MYR' => 'MYR (Ringgit)'] as $code => $label)
|
|
<option value="{{ $code }}" {{ old('default_currency', $settings->default_currency ?? 'IDR') === $code ? 'selected' : '' }}>
|
|
{{ $label }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="sm:col-span-2">
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Service Description</label>
|
|
<input type="text" name="default_service_description"
|
|
value="{{ old('default_service_description', $settings->default_service_description) }}"
|
|
class="input-soft text-sm" placeholder="e.g. Instagram Feed Post — 1 carousel">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Bank Name</label>
|
|
<input type="text" name="default_bank_name"
|
|
value="{{ old('default_bank_name', $settings->default_bank_name) }}"
|
|
class="input-soft text-sm" placeholder="BCA, Mandiri…">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Branch Name</label>
|
|
<input type="text" name="default_branch_name"
|
|
value="{{ old('default_branch_name', $settings->default_branch_name) }}"
|
|
class="input-soft text-sm" placeholder="KCP Sudirman">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Account Number</label>
|
|
<input type="text" name="default_bank_account"
|
|
value="{{ old('default_bank_account', $settings->default_bank_account) }}"
|
|
class="input-soft text-sm" placeholder="1234567890">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Account Holder</label>
|
|
<input type="text" name="default_bank_holder"
|
|
value="{{ old('default_bank_holder', $settings->default_bank_holder) }}"
|
|
class="input-soft text-sm" placeholder="Your full name">
|
|
</div>
|
|
<div class="sm:col-span-2">
|
|
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Notes / Payment Terms</label>
|
|
<textarea name="default_notes" rows="2" class="input-soft text-sm resize-none"
|
|
placeholder="e.g. Payment due within 14 days from invoice date.">{{ old('default_notes', $settings->default_notes) }}</textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn-sakura w-full py-3">💾 Save Settings</button>
|
|
</form>
|
|
</div>
|
|
|
|
@push('scripts')
|
|
<script>
|
|
function updatePreview() {
|
|
const prefix = document.getElementById('prefix-input').value.replace(/-+$/, '') || 'INV';
|
|
const num = parseInt(document.getElementById('number-input').value) || 1;
|
|
document.getElementById('number-preview').textContent = prefix + '-' + String(num).padStart(3, '0');
|
|
}
|
|
</script>
|
|
@endpush
|
|
@endsection
|