@php $action = $mode == 'edit' ? route('proforma-invoices.update', $invoice->id) : route('proforma-invoices.store'); $method = $mode == 'edit' ? 'PUT' : 'POST'; @endphp
@csrf @if($mode === 'edit') @method('PUT') @endif
@php $defaultInvoiceNo = $mode === 'create' ? 'P-INV-' . now()->format('dmY-His') // Format: ddmmyyyy-HHMMSS : ($invoice->invoice_number ?? ''); @endphp
{{-- Client Dropdown --}}
{{-- Items --}}
@if($mode === 'edit' && isset($invoice->items)) @foreach($invoice->items as $index => $item)
@if($item->module_id) {{-- Module-based Item --}}
@php $clientModules = $modules->filter(function ($module) use ($invoice, $item) { // Always include the module if it’s the one used in the item (even if client mismatch) return $module->id == $item->module_id || ($module->activity && $module->activity->client == $invoice->client_id); }); @endphp
@else {{-- Other Item --}}
description) }}" required>
@endif
rate) }}" required>
@endforeach @foreach($invoice->designations as $index => $designation)
name) }}" required>
pivot->count ?? 1) }}" required>
@endforeach @endif
@if($mode === 'create') @endif