@extends('front.layouts.main') @section('title', 'Customer Details') @push('pageCss') @endpush @section('content') Customer Details @if (isset($customer->id)) @method('PUT') @else @endif @csrf {{-- @if ($errors->any()) @foreach ($errors->all() as $error) {{ $error }} @endforeach @endif --}} @if (request('lead_id')) @endif @php $leadType = $lead->lead_type ?? null; // null when not converting from a lead $isEditing = isset($customer) && isset($customer->id); // What should be selected $selectedType = old('customer_type', $customer->customer_type ?? ($leadType ?? 'individual')); // UI rules // - Converting from a lead: disable ONLY the other option // - Editing an existing customer: lock it completely (disable both) + submit hidden value $disableIndividual = ($leadType === 'business') || ($isEditing && $selectedType !== 'individual'); $disableBusiness = ($leadType === 'individual') || ($isEditing && $selectedType !== 'business'); $lockAll = $isEditing; // fully lock on edit @endphp @if(!$isEditing) Client Details Select @foreach ($clients as $client) client_id ?? '') == $client->id ? 'selected' : '' }}> {{ $client->name }} @endforeach Product Details Select @foreach ($products as $product) product_id ?? '') == $product->id ? 'selected' : '' }}> {{ $product->product_name }} @endforeach @endif Customer Type {{-- If fully locked (editing), submit value via hidden input because disabled inputs don't submit --}} @if ($lockAll) @endif Individual Business @if ($leadType) Customer type is fixed by the lead ({{ ucfirst($leadType) }}). @elseif($isEditing) Customer type is locked ({{ ucfirst($selectedType) }}). @endif @include( 'front.modules.kua_agent.customers.partials.individual-fields', [ 'customer' => $customer, 'nationalIdTypes' => $nationalIdTypes, 'isEditing' => $isEditing ] ) @include('front.modules.kua_agent.customers.partials.business-fields', [ 'businessTypes' => $businessTypes, 'industrySectors' => $industrySectors, 'businessSegments' => $businessSegments, 'regions' => $regions, 'customer' => $customer, 'isEditing' => $isEditing ]) Key Contact Persons @include('front.modules.kua_agent.customers.partials.key-contacts') Cancel {{ isset($customer->id) ? 'Update' : 'Save' }} @endsection {{-- @push('pageJs') @endpush --}} @push('pageJs') @endpush