feat: add custom signature image and signer details support to invoices and settings
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -31,6 +31,7 @@ RUN apk add --no-cache \
|
||||
libpng-dev \
|
||||
libjpeg-turbo-dev \
|
||||
freetype-dev \
|
||||
libwebp-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev \
|
||||
icu-dev \
|
||||
@@ -41,6 +42,7 @@ RUN apk add --no-cache \
|
||||
RUN docker-php-ext-configure gd \
|
||||
--with-freetype \
|
||||
--with-jpeg \
|
||||
--with-webp \
|
||||
&& docker-php-ext-install -j"$(nproc)" \
|
||||
pdo \
|
||||
pdo_sqlite \
|
||||
@@ -105,7 +107,7 @@ RUN mkdir -p \
|
||||
RUN sed -i 's/user = www-data/user = www-data/' /usr/local/etc/php-fpm.d/www.conf 2>/dev/null || true \
|
||||
&& sed -i 's/group = www-data/group = www-data/' /usr/local/etc/php-fpm.d/www.conf 2>/dev/null || true
|
||||
|
||||
# ── OPcache tuning ───────────────────────────
|
||||
# ── PHP Tuning & Upload Limits ─────────────────
|
||||
RUN { \
|
||||
echo "opcache.enable=1"; \
|
||||
echo "opcache.memory_consumption=128"; \
|
||||
@@ -115,6 +117,13 @@ RUN { \
|
||||
echo "opcache.fast_shutdown=1"; \
|
||||
} > /usr/local/etc/php/conf.d/opcache.ini
|
||||
|
||||
RUN { \
|
||||
echo "upload_max_filesize = 200M"; \
|
||||
echo "post_max_size = 200M"; \
|
||||
echo "memory_limit = 512M"; \
|
||||
echo "max_execution_time = 300"; \
|
||||
} > /usr/local/etc/php/conf.d/uploads.ini
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -45,6 +45,7 @@ class InvoiceController extends Controller
|
||||
'issue_date' => 'required|date',
|
||||
'due_date' => 'required|date|after_or_equal:issue_date',
|
||||
'notes' => 'nullable|string',
|
||||
'signature_image' => 'nullable|image|max:2048',
|
||||
'bank_name' => 'nullable|string|max:100',
|
||||
'bank_account' => 'nullable|string|max:50',
|
||||
'bank_holder' => 'nullable|string|max:100',
|
||||
@@ -60,6 +61,18 @@ class InvoiceController extends Controller
|
||||
unset($validated['items']);
|
||||
$validated['status'] = InvoiceStatus::Draft->value;
|
||||
|
||||
if ($request->hasFile('signature_image')) {
|
||||
$validated['signature_image'] = $request->file('signature_image')->store('invoice-signatures', 'public');
|
||||
} else {
|
||||
// Fallback to settings signature if none provided at creation
|
||||
$settings = InvoiceSettings::instance();
|
||||
if ($settings->signature_image) {
|
||||
// We reference the same image path, or copy it.
|
||||
// Assuming referencing the same public image is fine.
|
||||
$validated['signature_image'] = $settings->signature_image;
|
||||
}
|
||||
}
|
||||
|
||||
$invoice = $this->invoiceService->create($validated, $items);
|
||||
|
||||
return redirect()->route('invoices.show', $invoice)
|
||||
@@ -94,6 +107,7 @@ class InvoiceController extends Controller
|
||||
'due_date' => 'required|date',
|
||||
'paid_date' => 'nullable|date',
|
||||
'notes' => 'nullable|string',
|
||||
'signature_image' => 'nullable|image|max:2048',
|
||||
'bank_name' => 'nullable|string|max:100',
|
||||
'bank_account' => 'nullable|string|max:50',
|
||||
'bank_holder' => 'nullable|string|max:100',
|
||||
@@ -108,6 +122,18 @@ class InvoiceController extends Controller
|
||||
$items = $validated['items'];
|
||||
unset($validated['items']);
|
||||
|
||||
if ($request->hasFile('signature_image')) {
|
||||
if ($invoice->signature_image && \Illuminate\Support\Facades\Storage::disk('public')->exists($invoice->signature_image)) {
|
||||
\Illuminate\Support\Facades\Storage::disk('public')->delete($invoice->signature_image);
|
||||
}
|
||||
$validated['signature_image'] = $request->file('signature_image')->store('invoice-signatures', 'public');
|
||||
} elseif ($request->boolean('remove_signature')) {
|
||||
if ($invoice->signature_image && \Illuminate\Support\Facades\Storage::disk('public')->exists($invoice->signature_image)) {
|
||||
\Illuminate\Support\Facades\Storage::disk('public')->delete($invoice->signature_image);
|
||||
}
|
||||
$validated['signature_image'] = null;
|
||||
}
|
||||
|
||||
$this->invoiceService->update($invoice, $validated, $items);
|
||||
|
||||
return redirect()->route('invoices.show', $invoice)
|
||||
|
||||
@@ -36,19 +36,34 @@ class InvoiceSettingsController extends Controller
|
||||
'default_bank_account' => 'nullable|string|max:50',
|
||||
'default_bank_holder' => 'nullable|string|max:100',
|
||||
'default_notes' => 'nullable|string|max:1000',
|
||||
'signature_image' => 'nullable|image|max:2048',
|
||||
'signer_name' => 'nullable|string|max:100',
|
||||
'signer_title' => 'nullable|string|max:100',
|
||||
]);
|
||||
|
||||
$settings = InvoiceSettings::instance();
|
||||
|
||||
if ($request->hasFile('header_logo')) {
|
||||
// Delete old logo if exists
|
||||
if ($settings->header_logo) {
|
||||
if ($settings->header_logo && Storage::disk('public')->exists($settings->header_logo)) {
|
||||
Storage::disk('public')->delete($settings->header_logo);
|
||||
}
|
||||
$path = $request->file('header_logo')->store('invoice-logos', 'public');
|
||||
$validated['header_logo'] = $path;
|
||||
}
|
||||
|
||||
if ($request->hasFile('signature_image')) {
|
||||
if ($settings->signature_image && Storage::disk('public')->exists($settings->signature_image)) {
|
||||
Storage::disk('public')->delete($settings->signature_image);
|
||||
}
|
||||
$validated['signature_image'] = $request->file('signature_image')->store('invoice-signatures', 'public');
|
||||
} elseif ($request->boolean('remove_signature')) {
|
||||
if ($settings->signature_image && Storage::disk('public')->exists($settings->signature_image)) {
|
||||
Storage::disk('public')->delete($settings->signature_image);
|
||||
}
|
||||
$validated['signature_image'] = null;
|
||||
}
|
||||
|
||||
$settings->update($validated);
|
||||
|
||||
return redirect()->route('invoice-settings.edit')
|
||||
@@ -69,7 +84,7 @@ class InvoiceSettingsController extends Controller
|
||||
$settings->update(['header_logo' => $path]);
|
||||
|
||||
return response()->json([
|
||||
'url' => asset('storage/' . $path),
|
||||
'url' => '/storage/' . $path,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -85,4 +100,36 @@ class InvoiceSettingsController extends Controller
|
||||
return redirect()->route('invoice-settings.edit')
|
||||
->with('success', '🗑️ Logo removed.');
|
||||
}
|
||||
|
||||
public function uploadSignature(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'signature_image' => 'required|image|max:2048',
|
||||
]);
|
||||
|
||||
$settings = InvoiceSettings::instance();
|
||||
|
||||
// Delete old signature if exists
|
||||
if ($settings->signature_image && Storage::disk('public')->exists($settings->signature_image)) {
|
||||
Storage::disk('public')->delete($settings->signature_image);
|
||||
}
|
||||
|
||||
$path = $request->file('signature_image')->store('invoice-signatures', 'public');
|
||||
$settings->update(['signature_image' => $path]);
|
||||
|
||||
return response()->json([
|
||||
'url' => '/storage/' . $path,
|
||||
'path' => $path
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteSignature(Request $request): JsonResponse
|
||||
{
|
||||
$settings = InvoiceSettings::instance();
|
||||
if ($settings->signature_image && Storage::disk('public')->exists($settings->signature_image)) {
|
||||
Storage::disk('public')->delete($settings->signature_image);
|
||||
}
|
||||
$settings->update(['signature_image' => null]);
|
||||
return response()->json(['message' => 'Signature deleted']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class Invoice extends Model
|
||||
'subtotal', 'tax_rate', 'tax_amount', 'total', 'currency',
|
||||
'status', 'issue_date', 'due_date', 'paid_date', 'notes',
|
||||
'bank_name', 'bank_account', 'bank_holder', 'branch_name',
|
||||
'signature_image',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
@@ -25,6 +25,9 @@ class InvoiceSettings extends Model
|
||||
'default_bank_account',
|
||||
'default_bank_holder',
|
||||
'default_notes',
|
||||
'signature_image',
|
||||
'signer_name',
|
||||
'signer_title',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('invoice_settings', function (Blueprint $table) {
|
||||
$table->string('signature_image')->nullable()->after('header_logo');
|
||||
});
|
||||
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->string('signature_image')->nullable()->after('notes');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('invoice_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('signature_image');
|
||||
});
|
||||
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('signature_image');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('invoice_settings', function (Blueprint $table) {
|
||||
$table->string('signer_name')->nullable()->after('signature_image');
|
||||
$table->string('signer_title')->nullable()->after('signer_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('invoice_settings', function (Blueprint $table) {
|
||||
$table->dropColumn(['signer_name', 'signer_title']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -5,194 +5,202 @@
|
||||
@section('page-subtitle', 'Fill in the invoice details')
|
||||
|
||||
@section('content')
|
||||
<div class="max-w-3xl mx-auto">
|
||||
<div class="cat-card p-4 lg:p-8" x-data="invoiceForm()">
|
||||
<form action="{{ route('invoices.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="max-w-3xl mx-auto">
|
||||
<div class="cat-card p-4 lg:p-8" x-data="invoiceForm()">
|
||||
<form action="{{ route('invoices.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
{{-- Header fields --}}
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mb-5">
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Invoice Title <span class="text-pink-400">*</span></label>
|
||||
<input type="text" name="title" value="{{ old('title') }}" class="input-soft" required
|
||||
placeholder="e.g. Instagram Collaboration - Brand X">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Client</label>
|
||||
<select name="client_id" class="input-soft">
|
||||
<option value="">— No client —</option>
|
||||
@foreach($clients as $client)
|
||||
<option value="{{ $client->id }}" {{ request('client') == $client->id ? 'selected' : '' }}>
|
||||
{{ $client->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Currency</label>
|
||||
<select name="currency" class="input-soft">
|
||||
@foreach(['IDR' => 'IDR (Rupiah)', 'USD' => 'USD (Dollar)', 'SGD' => 'SGD', 'MYR' => 'MYR (Ringgit)'] as $code => $label)
|
||||
<option value="{{ $code }}" {{ old('currency', $invoiceSettings->default_currency ?? 'IDR') === $code ? 'selected' : '' }}>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Issue Date</label>
|
||||
<input type="date" name="issue_date" value="{{ old('issue_date', today()->toDateString()) }}"
|
||||
class="input-soft" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Due Date</label>
|
||||
<input type="date" name="due_date"
|
||||
value="{{ old('due_date', today()->addDays(14)->toDateString()) }}"
|
||||
class="input-soft" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Tax Rate (%)</label>
|
||||
<input type="number" name="tax_rate" x-model="taxRate" @input="recalc()"
|
||||
value="{{ old('tax_rate', $invoiceSettings->default_tax_rate ?? 11) }}" class="input-soft" step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Line Items --}}
|
||||
<div class="mb-5">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<h3 class="text-sm font-bold text-gray-700">Line Items</h3>
|
||||
<button type="button" @click="addItem()" class="btn-sakura text-xs py-1.5 px-4">+ Add Item</button>
|
||||
{{-- Header fields --}}
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mb-5">
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Invoice Title <span
|
||||
class="text-pink-400">*</span></label>
|
||||
<input type="text" name="title" value="{{ old('title') }}" class="input-soft" required
|
||||
placeholder="e.g. Instagram Collaboration - Brand X">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Client</label>
|
||||
<select name="client_id" class="input-soft">
|
||||
<option value="">— No client —</option>
|
||||
@foreach($clients as $client)
|
||||
<option value="{{ $client->id }}" {{ request('client') == $client->id ? 'selected' : '' }}>
|
||||
{{ $client->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Currency</label>
|
||||
<select name="currency" class="input-soft">
|
||||
@foreach(['IDR' => 'IDR (Rupiah)', 'USD' => 'USD (Dollar)', 'SGD' => 'SGD', 'MYR' => 'MYR (Ringgit)'] as $code => $label)
|
||||
<option value="{{ $code }}" {{ old('currency', $invoiceSettings->default_currency ?? 'IDR') === $code ? 'selected' : '' }}>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Issue Date</label>
|
||||
<input type="date" name="issue_date" value="{{ old('issue_date', today()->toDateString()) }}"
|
||||
class="input-soft" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Due Date</label>
|
||||
<input type="date" name="due_date"
|
||||
value="{{ old('due_date', today()->addDays(14)->toDateString()) }}" class="input-soft" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Tax Rate (%)</label>
|
||||
<input type="number" name="tax_rate" x-model="taxRate" @input="recalc()"
|
||||
value="{{ old('tax_rate', $invoiceSettings->default_tax_rate ?? 11) }}" class="input-soft"
|
||||
step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<template x-for="(item, index) in items" :key="index">
|
||||
<div class="bg-pink-50 rounded-2xl p-3">
|
||||
{{-- Description full width --}}
|
||||
<input type="text" :name="`items[${index}][description]`"
|
||||
x-model="item.description"
|
||||
class="input-soft text-sm mb-2 bg-white"
|
||||
placeholder="Service description" required>
|
||||
{{-- Qty / Price / Total in a row --}}
|
||||
<div class="flex gap-2 items-center">
|
||||
<div class="w-16 shrink-0">
|
||||
<label class="text-xs text-gray-400 block mb-0.5">Qty</label>
|
||||
<input type="number" :name="`items[${index}][quantity]`"
|
||||
x-model.number="item.quantity" @input="recalc()"
|
||||
class="input-soft text-sm text-center bg-white px-2" min="1">
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<label class="text-xs text-gray-400 block mb-0.5">Unit Price</label>
|
||||
<input type="number" :name="`items[${index}][unit_price]`"
|
||||
x-model.number="item.unit_price" @input="recalc()"
|
||||
class="input-soft text-sm bg-white" min="0" step="1000"
|
||||
placeholder="0">
|
||||
</div>
|
||||
<div class="w-24 shrink-0 text-right">
|
||||
<label class="text-xs text-gray-400 block mb-0.5">Total</label>
|
||||
<div class="text-sm font-bold text-gray-700 pt-2">
|
||||
Rp <span x-text="formatNum(item.quantity * item.unit_price)"></span>
|
||||
{{-- Line Items --}}
|
||||
<div class="mb-5">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<h3 class="text-sm font-bold text-gray-700">Line Items</h3>
|
||||
<button type="button" @click="addItem()" class="btn-sakura text-xs py-1.5 px-4">+ Add Item</button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<template x-for="(item, index) in items" :key="index">
|
||||
<div class="bg-pink-50 rounded-2xl p-3">
|
||||
{{-- Description full width --}}
|
||||
<input type="text" :name="`items[${index}][description]`" x-model="item.description"
|
||||
class="input-soft text-sm mb-2 bg-white" placeholder="Service description" required>
|
||||
{{-- Qty / Price / Total in a row --}}
|
||||
<div class="flex gap-2 items-center">
|
||||
<div class="w-16 shrink-0">
|
||||
<label class="text-xs text-gray-400 block mb-0.5">Qty</label>
|
||||
<input type="number" :name="`items[${index}][quantity]`"
|
||||
x-model.number="item.quantity" @input="recalc()"
|
||||
class="input-soft text-sm text-center bg-white px-2" min="1">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" @click="removeItem(index)"
|
||||
<div class="flex-1">
|
||||
<label class="text-xs text-gray-400 block mb-0.5">Unit Price</label>
|
||||
<input type="number" :name="`items[${index}][unit_price]`"
|
||||
x-model.number="item.unit_price" @input="recalc()"
|
||||
class="input-soft text-sm bg-white" min="0" step="1000" placeholder="0">
|
||||
</div>
|
||||
<div class="w-24 shrink-0 text-right">
|
||||
<label class="text-xs text-gray-400 block mb-0.5">Total</label>
|
||||
<div class="text-sm font-bold text-gray-700 pt-2">
|
||||
Rp <span x-text="formatNum(item.quantity * item.unit_price)"></span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" @click="removeItem(index)"
|
||||
class="text-red-400 hover:text-red-600 text-lg shrink-0 pt-4">✕</button>
|
||||
</div>
|
||||
{{-- Taxable checkbox --}}
|
||||
<div class="mt-2 flex items-center gap-2">
|
||||
<input type="hidden" :name="`items[${index}][is_taxable]`" value="0">
|
||||
<input type="checkbox" :name="`items[${index}][is_taxable]`" :id="`taxable_${index}`"
|
||||
x-model="item.is_taxable" @change="recalc()" value="1"
|
||||
class="w-3.5 h-3.5 accent-pink-400">
|
||||
<label :for="`taxable_${index}`"
|
||||
class="text-xs text-gray-500 cursor-pointer select-none">
|
||||
Taxable
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Taxable checkbox --}}
|
||||
<div class="mt-2 flex items-center gap-2">
|
||||
<input type="hidden" :name="`items[${index}][is_taxable]`" value="0">
|
||||
<input type="checkbox" :name="`items[${index}][is_taxable]`"
|
||||
:id="`taxable_${index}`"
|
||||
x-model="item.is_taxable" @change="recalc()"
|
||||
value="1"
|
||||
class="w-3.5 h-3.5 accent-pink-400">
|
||||
<label :for="`taxable_${index}`" class="text-xs text-gray-500 cursor-pointer select-none">
|
||||
Taxable
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Totals --}}
|
||||
<div class="bg-pink-50 rounded-2xl p-4 mb-5">
|
||||
<div class="flex justify-between text-sm py-1">
|
||||
<span class="text-gray-500">Subtotal (all items)</span>
|
||||
<span class="font-semibold">Rp <span x-text="formatNum(subtotal)"></span></span>
|
||||
{{-- Totals --}}
|
||||
<div class="bg-pink-50 rounded-2xl p-4 mb-5">
|
||||
<div class="flex justify-between text-sm py-1">
|
||||
<span class="text-gray-500">Subtotal (all items)</span>
|
||||
<span class="font-semibold">Rp <span x-text="formatNum(subtotal)"></span></span>
|
||||
</div>
|
||||
<div class="flex justify-between text-sm py-1 text-amber-600">
|
||||
<span>Tax (<span x-text="taxRate"></span>% — paid by client)</span>
|
||||
<span class="font-semibold">Rp <span x-text="formatNum(taxAmount)"></span></span>
|
||||
</div>
|
||||
<div class="flex justify-between text-base font-bold py-2 mt-1 border-t border-pink-200">
|
||||
<span class="text-gray-700">Grand Total</span>
|
||||
<span class="text-pink-600">Rp <span x-text="formatNum(total)"></span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between text-sm py-1 text-amber-600">
|
||||
<span>Tax (<span x-text="taxRate"></span>% — paid by client)</span>
|
||||
<span class="font-semibold">Rp <span x-text="formatNum(taxAmount)"></span></span>
|
||||
</div>
|
||||
<div class="flex justify-between text-base font-bold py-2 mt-1 border-t border-pink-200">
|
||||
<span class="text-gray-700">Grand Total</span>
|
||||
<span class="text-pink-600">Rp <span x-text="formatNum(total)"></span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Bank Info --}}
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mb-5">
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Bank Name</label>
|
||||
<input type="text" name="bank_name"
|
||||
value="{{ old('bank_name', $invoiceSettings->default_bank_name) }}"
|
||||
class="input-soft text-sm" placeholder="BCA, Mandiri...">
|
||||
{{-- Bank Info --}}
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 mb-5">
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Bank Name</label>
|
||||
<input type="text" name="bank_name"
|
||||
value="{{ old('bank_name', $invoiceSettings->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">Branch Name</label>
|
||||
<input type="text" name="branch_name"
|
||||
value="{{ old('branch_name', $invoiceSettings->default_branch_name) }}"
|
||||
class="input-soft text-sm" placeholder="e.g. KCP Sudirman">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Number</label>
|
||||
<input type="text" name="bank_account"
|
||||
value="{{ old('bank_account', $invoiceSettings->default_bank_account) }}"
|
||||
class="input-soft text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Holder</label>
|
||||
<input type="text" name="bank_holder"
|
||||
value="{{ old('bank_holder', $invoiceSettings->default_bank_holder) }}"
|
||||
class="input-soft text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Branch Name</label>
|
||||
<input type="text" name="branch_name"
|
||||
value="{{ old('branch_name', $invoiceSettings->default_branch_name) }}"
|
||||
class="input-soft text-sm" placeholder="e.g. KCP Sudirman">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Number</label>
|
||||
<input type="text" name="bank_account"
|
||||
value="{{ old('bank_account', $invoiceSettings->default_bank_account) }}"
|
||||
class="input-soft text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Account Holder</label>
|
||||
<input type="text" name="bank_holder"
|
||||
value="{{ old('bank_holder', $invoiceSettings->default_bank_holder) }}"
|
||||
class="input-soft text-sm">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-5">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes</label>
|
||||
<textarea name="notes" rows="2" class="input-soft resize-none"
|
||||
placeholder="Payment terms, etc.">{{ old('notes', $invoiceSettings->default_notes) }}</textarea>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes / Payment Terms</label>
|
||||
<textarea name="notes" rows="2" class="input-soft resize-none"
|
||||
placeholder="Payment terms, etc.">{{ old('notes', $invoiceSettings->default_notes) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col sm:flex-row gap-3">
|
||||
<button type="submit" class="btn-sakura flex-1 py-3">🧾 Create Invoice</button>
|
||||
<a href="{{ route('invoices.index') }}"
|
||||
class="flex-1 py-3 text-center rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold text-sm">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
<div class="mb-5">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Custom Signature Image (Optional)</label>
|
||||
<p class="text-xs text-gray-400 mb-2">Leave blank to use your default signature from settings.</p>
|
||||
<input type="file" name="signature_image" 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">
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col sm:flex-row gap-3">
|
||||
<button type="submit" class="btn-sakura flex-1 py-3">🧾 Create Invoice</button>
|
||||
<a href="{{ route('invoices.index') }}"
|
||||
class="flex-1 py-3 text-center rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold text-sm">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
function invoiceForm() {
|
||||
return {
|
||||
items: [{ description: @json($invoiceSettings->default_service_description ?? ''), quantity: 1, unit_price: 0, is_taxable: true }],
|
||||
taxRate: {{ $invoiceSettings->default_tax_rate ?? 11 }},
|
||||
get subtotal() {
|
||||
return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||
},
|
||||
get taxAmount() {
|
||||
const taxable = this.items
|
||||
.filter(i => i.is_taxable)
|
||||
.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||
return Math.round(taxable * this.taxRate / 100);
|
||||
},
|
||||
get total() { return this.subtotal; }, // grand total = pre-tax (tax borne by client)
|
||||
addItem() { this.items.push({ description: '', quantity: 1, unit_price: 0, is_taxable: true }); },
|
||||
removeItem(i) { if (this.items.length > 1) this.items.splice(i, 1); },
|
||||
recalc() {},
|
||||
formatNum(n) { return Number(n).toLocaleString('id-ID'); },
|
||||
};
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@push('scripts')
|
||||
<script>
|
||||
function invoiceForm() {
|
||||
return {
|
||||
items: [{ description: @json($invoiceSettings->default_service_description ?? ''), quantity: 1, unit_price: 0, is_taxable: true }],
|
||||
taxRate: {{ $invoiceSettings->default_tax_rate ?? 11 }},
|
||||
get subtotal() {
|
||||
return this.items.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||
},
|
||||
get taxAmount() {
|
||||
const taxable = this.items
|
||||
.filter(i => i.is_taxable)
|
||||
.reduce((s, i) => s + (i.quantity * i.unit_price), 0);
|
||||
return Math.round(taxable * this.taxRate / 100);
|
||||
},
|
||||
get total() { return this.subtotal; }, // grand total = pre-tax (tax borne by client)
|
||||
addItem() { this.items.push({ description: '', quantity: 1, unit_price: 0, is_taxable: true }); },
|
||||
removeItem(i) { if (this.items.length > 1) this.items.splice(i, 1); },
|
||||
recalc() { },
|
||||
formatNum(n) { return Number(n).toLocaleString('id-ID'); },
|
||||
};
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@endsection
|
||||
@@ -7,7 +7,7 @@
|
||||
@section('content')
|
||||
<div class="max-w-3xl mx-auto">
|
||||
<div class="cat-card p-4 lg:p-8" x-data="invoiceEditForm()">
|
||||
<form action="{{ route('invoices.update', $invoice) }}" method="POST">
|
||||
<form action="{{ route('invoices.update', $invoice) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf @method('PUT')
|
||||
|
||||
{{-- Header fields --}}
|
||||
@@ -146,10 +146,40 @@
|
||||
</div>
|
||||
|
||||
<div class="mb-5">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes</label>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Notes / Payment Terms</label>
|
||||
<textarea name="notes" rows="2" class="input-soft resize-none">{{ old('notes', $invoice->notes) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-5" x-data="{
|
||||
removeSign() {
|
||||
if (!confirm('Remove the signature from this invoice?')) return;
|
||||
$refs.removeSignInput.value = '1';
|
||||
this.$el.closest('form').submit();
|
||||
}
|
||||
}">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Custom Signature Image (Optional)</label>
|
||||
<p class="text-xs text-gray-400 mb-3">Upload a specific signature for this invoice. Leave blank to keep the current one.</p>
|
||||
|
||||
@if($invoice->signature_image)
|
||||
<div class="flex items-center gap-4 mb-3 p-3 bg-white rounded-xl border border-pink-100">
|
||||
<img src="{{ '/storage/' . $invoice->signature_image }}" alt="Signature" class="h-16 object-contain">
|
||||
<div>
|
||||
<input type="hidden" name="remove_signature" value="0" x-ref="removeSignInput">
|
||||
<button type="button" @click="removeSign()" class="text-xs px-3 py-1.5 rounded-full border border-red-200 text-red-400 hover:bg-red-50">
|
||||
🗑️ Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<input type="file" name="signature_image" 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">
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col sm:flex-row gap-3">
|
||||
<button type="submit" class="btn-sakura flex-1 py-3">💾 Save Changes</button>
|
||||
<a href="{{ route('invoices.show', $invoice) }}"
|
||||
|
||||
@@ -361,9 +361,30 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($invoice->notes)
|
||||
<div class="notes">{{ $invoice->notes }}</div>
|
||||
@endif
|
||||
<div style="margin-top: 40px;">
|
||||
@if($invoice->notes)
|
||||
<div class="notes" style="width: 50%; float: left; margin-top: 10px;">{{ $invoice->notes }}</div>
|
||||
@endif
|
||||
|
||||
@if($invoice->signature_image && file_exists(storage_path('app/public/' . $invoice->signature_image)))
|
||||
<div style="width: 200px; float: right; text-align: center;">
|
||||
<div style="font-size: 11px; color: #374151; margin-bottom: 12px;">
|
||||
Jakarta, {{ $invoice->issue_date->format('d F Y') }}
|
||||
</div>
|
||||
<img src="{{ storage_path('app/public/' . $invoice->signature_image) }}" style="max-height: 80px; max-width: 180px; object-fit: contain; margin-bottom: 8px;">
|
||||
<div style="font-size: 12px; font-weight: 800; color: #111827; text-transform: uppercase;">
|
||||
{{ $invoiceSettings->signer_name ?: ($invoiceSettings->header_name ?: 'Signature') }}
|
||||
</div>
|
||||
@if($invoiceSettings->signer_title || $invoiceSettings->header_title)
|
||||
<div style="font-size: 10px; color: #6B7280; text-transform: uppercase; margin-top: 3px;">
|
||||
{{ $invoiceSettings->signer_title ?: $invoiceSettings->header_title }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
||||
<div class="footer">Thank you for the collaboration!</div>
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<div class="mb-4" x-data="{
|
||||
uploading: false,
|
||||
errorMsg: '',
|
||||
logoUrl: '{{ $settings->header_logo ? asset('storage/' . $settings->header_logo) : '' }}',
|
||||
logoUrl: '{{ $settings->header_logo ? '/storage/' . $settings->header_logo : '' }}',
|
||||
|
||||
async pickFile(input) {
|
||||
if (!input.files.length) return;
|
||||
@@ -72,7 +72,7 @@
|
||||
fd.append('header_logo', input.files[0]);
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
try {
|
||||
const res = await fetch('{{ route('invoice-settings.upload-logo') }}', { method: 'POST', body: fd });
|
||||
const res = await fetch('{{ route('invoice-settings.upload-logo', [], false) }}', { method: 'POST', body: fd });
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
this.logoUrl = data.url + '?t=' + Date.now();
|
||||
@@ -91,7 +91,7 @@
|
||||
const fd = new FormData();
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
fd.append('_method', 'DELETE');
|
||||
await fetch('{{ route('invoice-settings.delete-logo') }}', { method: 'POST', body: fd });
|
||||
await fetch('{{ route('invoice-settings.delete-logo', [], false) }}', { method: 'POST', body: fd });
|
||||
this.logoUrl = '';
|
||||
}
|
||||
}">
|
||||
@@ -205,6 +205,82 @@
|
||||
<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 class="sm:col-span-2 mt-2 pt-4 border-t border-gray-100">
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Default Signature Image</label>
|
||||
<p class="text-xs text-gray-400 mb-3">Upload your signature here so it appears automatically on all new invoices.</p>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mb-4">
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Signer Name</label>
|
||||
<input type="text" name="signer_name" placeholder="e.g. {{ $settings->header_name ?: 'John Doe' }}" value="{{ old('signer_name', $settings->signer_name) }}" class="input-soft text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Signer Title</label>
|
||||
<input type="text" name="signer_title" placeholder="e.g. {{ $settings->header_title ?: 'Manager' }}" value="{{ old('signer_title', $settings->signer_title) }}" class="input-soft text-sm">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div x-data="{
|
||||
uploading: false,
|
||||
errorMsg: '',
|
||||
signatureUrl: '{{ $settings->signature_image ? '/storage/' . $settings->signature_image : '' }}',
|
||||
|
||||
async pickFile(input) {
|
||||
if (!input.files.length) return;
|
||||
this.uploading = true;
|
||||
this.errorMsg = '';
|
||||
const fd = new FormData();
|
||||
fd.append('signature_image', input.files[0]);
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
try {
|
||||
const res = await fetch('{{ route('invoice-settings.upload-signature', [], false) }}', { method: 'POST', body: fd });
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
this.signatureUrl = data.url + '?t=' + Date.now();
|
||||
} else {
|
||||
this.errorMsg = data.message ?? 'Upload failed.';
|
||||
}
|
||||
} catch {
|
||||
this.errorMsg = 'Network error. Please try again.';
|
||||
}
|
||||
this.uploading = false;
|
||||
input.value = '';
|
||||
},
|
||||
|
||||
async removeSignature() {
|
||||
if (!confirm('Remove this signature?')) return;
|
||||
const fd = new FormData();
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
fd.append('_method', 'DELETE');
|
||||
await fetch('{{ route('invoice-settings.delete-signature', [], false) }}', { method: 'POST', body: fd });
|
||||
this.signatureUrl = '';
|
||||
}
|
||||
}">
|
||||
|
||||
<template x-if="signatureUrl">
|
||||
<div class="flex items-center gap-4 mb-3 p-3 bg-white rounded-xl border border-pink-100">
|
||||
<img :src="signatureUrl" alt="Signature preview" class="h-16 object-contain">
|
||||
<div>
|
||||
<button type="button" @click="removeSignature()" class="text-xs px-3 py-1.5 rounded-full border border-red-200 text-red-400 hover:bg-red-50">
|
||||
🗑️ Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="relative">
|
||||
<input type="file" accept="image/*" @change="pickFile($event.target)" 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" :disabled="uploading">
|
||||
<span x-show="uploading" class="text-xs text-pink-500 mt-1 block">Uploading…</span>
|
||||
<span x-show="errorMsg" x-text="errorMsg" class="text-xs text-red-500 mt-1 block"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -147,9 +147,29 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($invoice->notes)
|
||||
<div class="mt-4 text-sm text-gray-500 italic">{{ $invoice->notes }}</div>
|
||||
@endif
|
||||
<div class="flex flex-col sm:flex-row justify-between items-start mt-10 gap-6">
|
||||
<div class="flex-1 text-left">
|
||||
@if($invoice->notes)
|
||||
<div class="text-sm text-gray-500 italic">{{ $invoice->notes }}</div>
|
||||
@endif
|
||||
</div>
|
||||
@if($invoice->signature_image)
|
||||
<div class="shrink-0 text-center w-full sm:w-auto">
|
||||
<div class="text-sm text-gray-500 mb-3">
|
||||
Jakarta, {{ $invoice->issue_date->format('d F Y') }}
|
||||
</div>
|
||||
<img src="{{ '/storage/' . $invoice->signature_image }}" alt="Signature" class="h-20 object-contain mb-3 mx-auto">
|
||||
<div class="text-sm font-extrabold text-gray-800 uppercase tracking-wide">
|
||||
{{ $invoiceSettings->signer_name ?: ($invoiceSettings->header_name ?: 'Signature') }}
|
||||
</div>
|
||||
@if($invoiceSettings->signer_title || $invoiceSettings->header_title)
|
||||
<div class="text-xs text-gray-400 uppercase mt-0.5 tracking-wider">
|
||||
{{ $invoiceSettings->signer_title ?: $invoiceSettings->header_title }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -33,10 +33,19 @@
|
||||
<input type="text" name="content_type" value="{{ old('content_type') }}" class="input-soft"
|
||||
placeholder="Reel, Story, Feed...">
|
||||
</div>
|
||||
<div>
|
||||
<div x-data="{
|
||||
rawPrice: '{{ old('price', '') }}',
|
||||
get formattedPrice() {
|
||||
if (!this.rawPrice) return '';
|
||||
return parseInt(this.rawPrice).toLocaleString('id-ID');
|
||||
},
|
||||
set formattedPrice(val) {
|
||||
this.rawPrice = val.replace(/\D/g, '');
|
||||
}
|
||||
}">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Price <span class="text-pink-400">*</span></label>
|
||||
<input type="number" name="price" value="{{ old('price') }}" class="input-soft"
|
||||
min="0" step="100000" required placeholder="0">
|
||||
<input type="hidden" name="price" :value="rawPrice">
|
||||
<input type="text" x-model="formattedPrice" class="input-soft" required placeholder="0">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Currency</label>
|
||||
|
||||
@@ -33,10 +33,19 @@
|
||||
<input type="text" name="content_type" value="{{ old('content_type', $rateCard->content_type) }}"
|
||||
class="input-soft" placeholder="Reel, Story...">
|
||||
</div>
|
||||
<div>
|
||||
<div x-data="{
|
||||
rawPrice: '{{ old('price', $rateCard->price) }}',
|
||||
get formattedPrice() {
|
||||
if (!this.rawPrice) return '';
|
||||
return parseInt(this.rawPrice).toLocaleString('id-ID');
|
||||
},
|
||||
set formattedPrice(val) {
|
||||
this.rawPrice = val.replace(/\D/g, '');
|
||||
}
|
||||
}">
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Price</label>
|
||||
<input type="number" name="price" value="{{ old('price', $rateCard->price) }}"
|
||||
class="input-soft" min="0" step="100000">
|
||||
<input type="hidden" name="price" :value="rawPrice">
|
||||
<input type="text" x-model="formattedPrice" class="input-soft" placeholder="0">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Currency</label>
|
||||
|
||||
@@ -76,6 +76,8 @@ Route::get('/invoice-settings', [InvoiceSettingsController::class, 'edit'])->nam
|
||||
Route::post('/invoice-settings', [InvoiceSettingsController::class, 'update'])->name('invoice-settings.update');
|
||||
Route::post('/invoice-settings/logo', [InvoiceSettingsController::class, 'uploadLogo'])->name('invoice-settings.upload-logo');
|
||||
Route::delete('/invoice-settings/logo', [InvoiceSettingsController::class, 'deleteLogo'])->name('invoice-settings.delete-logo');
|
||||
Route::post('/invoice-settings/signature', [InvoiceSettingsController::class, 'uploadSignature'])->name('invoice-settings.upload-signature');
|
||||
Route::delete('/invoice-settings/signature', [InvoiceSettingsController::class, 'deleteSignature'])->name('invoice-settings.delete-signature');
|
||||
|
||||
// Financial – Rate Cards
|
||||
Route::get('/rate-cards/public', [RateCardController::class, 'public'])->name('rate-cards.public');
|
||||
|
||||
Reference in New Issue
Block a user