Add edit actions for business branch and registration
This commit is contained in:
@@ -7,6 +7,13 @@
|
||||
<a href="/clients/{{ client.id }}" class="rounded-xl border border-slate-300 px-4 py-2 text-sm">Back to Client</a>
|
||||
</div>
|
||||
|
||||
{% if request.query_params.get('message') %}
|
||||
<div class="rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-800">{{ request.query_params.get('message') }}</div>
|
||||
{% endif %}
|
||||
{% if request.query_params.get('error') %}
|
||||
<div class="rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-800">{{ request.query_params.get('error') }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% if can_edit %}
|
||||
<div class="grid gap-5 xl:grid-cols-3">
|
||||
<form id="add-business" data-quick-action="business" method="post" action="/clients/{{ client.id }}/business-units" class="rounded-2xl bg-white p-5 shadow-soft space-y-3">
|
||||
@@ -45,7 +52,7 @@
|
||||
<select name="client_branch_id" class="w-full rounded-xl border px-3 py-2 text-sm"><option value="">No Client Branch</option>{% for row in branches if row.is_active %}<option value="{{ row.id }}" {% if request.query_params.get('client_branch_id') == row.id|string %}selected{% endif %}>{{ row.branch_name }}</option>{% endfor %}</select>
|
||||
<select name="registration_type_id" required class="w-full rounded-xl border px-3 py-2 text-sm">
|
||||
<option value="">Select Registration Type</option>
|
||||
{% for row in registration_types %}<option value="{{ row.id }}">{{ row.name }} ({{ row.code }})</option>{% endfor %}
|
||||
{% for row in registration_types if row.is_active %}<option value="{{ row.id }}">{{ row.name }} ({{ row.code }})</option>{% endfor %}
|
||||
</select>
|
||||
<input name="registration_number" required placeholder="Registration number" class="w-full rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="legal_name" placeholder="Legal name" class="w-full rounded-xl border px-3 py-2 text-sm">
|
||||
@@ -56,19 +63,96 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<section class="rounded-2xl bg-white shadow-soft overflow-hidden">
|
||||
{% if can_edit and request.query_params.get('edit_business') %}
|
||||
{% for edit_row in businesses if edit_row.id|string == request.query_params.get('edit_business') %}
|
||||
<section id="edit-business" class="rounded-2xl border border-brand-200 bg-white p-5 shadow-soft">
|
||||
<div class="mb-4 flex items-center justify-between gap-3">
|
||||
<div><h3 class="font-semibold text-slate-900">Edit Business Unit</h3><p class="text-xs text-slate-500">Updates this existing Business Unit; linked records remain attached.</p></div>
|
||||
<a href="/clients/{{ client.id }}/business-structure#business-units" class="rounded-lg border px-3 py-1.5 text-xs">Cancel</a>
|
||||
</div>
|
||||
<form method="post" action="/clients/{{ client.id }}/business-units/{{ edit_row.id }}/edit" class="grid gap-3 md:grid-cols-2 xl:grid-cols-4">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<input name="business_code" value="{{ edit_row.business_code }}" required placeholder="Business code" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="business_name" value="{{ edit_row.business_name }}" required placeholder="Business unit name" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="trade_name" value="{{ edit_row.trade_name or '' }}" placeholder="Trade name" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="nature_of_business" value="{{ edit_row.nature_of_business or '' }}" placeholder="Nature of business" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<label class="flex items-center gap-2 text-sm"><input type="checkbox" name="is_primary" {% if edit_row.is_primary %}checked{% endif %}> Primary Business Unit</label>
|
||||
<div class="md:col-span-2 xl:col-span-3"><button class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white">Save Business Changes</button></div>
|
||||
</form>
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if can_edit and request.query_params.get('edit_branch') %}
|
||||
{% for edit_row in branches if edit_row.id|string == request.query_params.get('edit_branch') %}
|
||||
<section id="edit-branch" class="rounded-2xl border border-brand-200 bg-white p-5 shadow-soft">
|
||||
<div class="mb-4 flex items-center justify-between gap-3">
|
||||
<div><h3 class="font-semibold text-slate-900">Edit Client Branch</h3><p class="text-xs text-slate-500">Updates this existing branch without changing its record ID.</p></div>
|
||||
<a href="/clients/{{ client.id }}/business-structure#client-branches" class="rounded-lg border px-3 py-1.5 text-xs">Cancel</a>
|
||||
</div>
|
||||
<form method="post" action="/clients/{{ client.id }}/branches/{{ edit_row.id }}/edit" class="grid gap-3 md:grid-cols-2 xl:grid-cols-4">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<select name="business_unit_id" required class="rounded-xl border px-3 py-2 text-sm">
|
||||
{% for business in businesses %}<option value="{{ business.id }}" {% if business.id == edit_row.business_unit_id %}selected{% endif %}>{{ business.business_name }}{% if not business.is_active %} (Inactive){% endif %}</option>{% endfor %}
|
||||
</select>
|
||||
<input name="branch_code" value="{{ edit_row.branch_code }}" required placeholder="Branch code" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="branch_name" value="{{ edit_row.branch_name }}" required placeholder="Client Branch name" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<select name="branch_type" class="rounded-xl border px-3 py-2 text-sm">
|
||||
{% for code, label in [('head_office','Head Office'),('branch','Branch'),('warehouse','Warehouse'),('unit','Unit')] %}<option value="{{ code }}" {% if edit_row.branch_type == code %}selected{% endif %}>{{ label }}</option>{% endfor %}
|
||||
</select>
|
||||
<input name="city" value="{{ edit_row.city or '' }}" placeholder="City" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="state" value="{{ edit_row.state or '' }}" placeholder="State" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="pincode" value="{{ edit_row.pincode or '' }}" placeholder="Pincode" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<label class="flex items-center gap-2 text-sm"><input type="checkbox" name="is_primary" {% if edit_row.is_primary %}checked{% endif %}> Primary Branch</label>
|
||||
<div class="md:col-span-2 xl:col-span-4"><button class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white">Save Branch Changes</button></div>
|
||||
</form>
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if can_edit and request.query_params.get('edit_registration') %}
|
||||
{% for edit_row in registrations if edit_row.id|string == request.query_params.get('edit_registration') %}
|
||||
<section id="edit-registration" class="rounded-2xl border border-brand-200 bg-white p-5 shadow-soft">
|
||||
<div class="mb-4 flex items-center justify-between gap-3">
|
||||
<div><h3 class="font-semibold text-slate-900">Edit Registration</h3><p class="text-xs text-slate-500">The existing registration ID and linked credentials remain unchanged.</p></div>
|
||||
<a href="/clients/{{ client.id }}/business-structure#registrations" class="rounded-lg border px-3 py-1.5 text-xs">Cancel</a>
|
||||
</div>
|
||||
<form method="post" action="/clients/{{ client.id }}/registrations/{{ edit_row.id }}/edit" class="grid gap-3 md:grid-cols-2 xl:grid-cols-4">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<select name="business_unit_id" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<option value="">Client level / derive from Branch</option>
|
||||
{% for business in businesses %}<option value="{{ business.id }}" {% if business.id == edit_row.business_unit_id %}selected{% endif %}>{{ business.business_name }}{% if not business.is_active %} (Inactive){% endif %}</option>{% endfor %}
|
||||
</select>
|
||||
<select name="client_branch_id" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<option value="">No Client Branch</option>
|
||||
{% for branch in branches %}<option value="{{ branch.id }}" {% if branch.id == edit_row.client_branch_id %}selected{% endif %}>{{ branch.branch_name }}{% if not branch.is_active %} (Inactive){% endif %}</option>{% endfor %}
|
||||
</select>
|
||||
<select name="registration_type_id" required class="rounded-xl border px-3 py-2 text-sm">
|
||||
{% for reg_type in registration_types if reg_type.is_active or reg_type.id == edit_row.registration_type_id %}<option value="{{ reg_type.id }}" {% if reg_type.id == edit_row.registration_type_id %}selected{% endif %}>{{ reg_type.name }} ({{ reg_type.code }}){% if not reg_type.is_active %} — Inactive{% endif %}</option>{% endfor %}
|
||||
</select>
|
||||
<input name="registration_number" value="{{ edit_row.registration_number }}" required placeholder="Registration number" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="legal_name" value="{{ edit_row.legal_name or '' }}" placeholder="Legal name" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="trade_name" value="{{ edit_row.trade_name or '' }}" placeholder="Trade / deductor unit name" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<input name="state" value="{{ edit_row.state or '' }}" placeholder="State" class="rounded-xl border px-3 py-2 text-sm">
|
||||
<div><button class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white">Save Registration Changes</button></div>
|
||||
</form>
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
<section id="business-units" class="rounded-2xl bg-white shadow-soft overflow-hidden">
|
||||
<div class="border-b p-4 font-semibold">Business Units</div>
|
||||
<table class="min-w-full text-sm"><thead class="bg-slate-50"><tr><th class="p-3 text-left">Code</th><th class="p-3 text-left">Business Unit</th><th class="p-3 text-left">Trade Name</th><th class="p-3 text-left">Nature</th><th class="p-3">Status</th><th></th></tr></thead>
|
||||
<tbody>{% for row in businesses %}<tr class="border-t"><td class="p-3">{{ row.business_code }}</td><td class="p-3 font-medium">{{ row.business_name }}{% if row.is_primary %} <span class="text-xs text-brand-700">Primary</span>{% endif %}</td><td class="p-3">{{ row.trade_name or '-' }}</td><td class="p-3">{{ row.nature_of_business or '-' }}</td><td class="p-3 text-center">{{ 'Active' if row.is_active else 'Inactive' }}</td><td class="p-3">{% if can_edit %}<form method="post" action="/clients/{{ client.id }}/business-structure/business/{{ row.id }}/toggle"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><button class="text-xs text-brand-700">{{ 'Deactivate' if row.is_active else 'Activate' }}</button></form>{% endif %}</td></tr>{% else %}<tr><td colspan="6" class="p-6 text-center text-slate-500">No Business Units added.</td></tr>{% endfor %}</tbody></table>
|
||||
<tbody>{% for row in businesses %}<tr class="border-t"><td class="p-3">{{ row.business_code }}</td><td class="p-3 font-medium">{{ row.business_name }}{% if row.is_primary %} <span class="text-xs text-brand-700">Primary</span>{% endif %}</td><td class="p-3">{{ row.trade_name or '-' }}</td><td class="p-3">{{ row.nature_of_business or '-' }}</td><td class="p-3 text-center">{{ 'Active' if row.is_active else 'Inactive' }}</td><td class="p-3">{% if can_edit %}<div class="flex items-center gap-3"><a href="/clients/{{ client.id }}/business-structure?edit_business={{ row.id }}#edit-business" class="text-xs font-semibold text-brand-700">Edit</a><form method="post" action="/clients/{{ client.id }}/business-structure/business/{{ row.id }}/toggle"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><button class="text-xs text-brand-700">{{ 'Deactivate' if row.is_active else 'Activate' }}</button></form></div>{% endif %}</td></tr>{% else %}<tr><td colspan="6" class="p-6 text-center text-slate-500">No Business Units added.</td></tr>{% endfor %}</tbody></table>
|
||||
</section>
|
||||
|
||||
<section class="rounded-2xl bg-white shadow-soft overflow-hidden">
|
||||
<section id="client-branches" class="rounded-2xl bg-white shadow-soft overflow-hidden">
|
||||
<div class="border-b p-4 font-semibold">Client Branches</div>
|
||||
<table class="min-w-full text-sm"><thead class="bg-slate-50"><tr><th class="p-3 text-left">Code</th><th class="p-3 text-left">Client Branch</th><th class="p-3 text-left">Type</th><th class="p-3 text-left">Location</th><th class="p-3">Status</th><th></th></tr></thead>
|
||||
<tbody>{% for row in branches %}<tr class="border-t"><td class="p-3">{{ row.branch_code }}</td><td class="p-3 font-medium">{{ row.branch_name }}{% if row.is_primary %} <span class="text-xs text-brand-700">Primary</span>{% endif %}</td><td class="p-3">{{ row.branch_type|replace('_',' ')|title }}</td><td class="p-3">{{ row.city or '' }}{% if row.city and row.state %}, {% endif %}{{ row.state or '-' }}</td><td class="p-3 text-center">{{ 'Active' if row.is_active else 'Inactive' }}</td><td class="p-3">{% if can_edit %}<form method="post" action="/clients/{{ client.id }}/business-structure/branch/{{ row.id }}/toggle"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><button class="text-xs text-brand-700">{{ 'Deactivate' if row.is_active else 'Activate' }}</button></form>{% endif %}</td></tr>{% else %}<tr><td colspan="6" class="p-6 text-center text-slate-500">No Client Branches added.</td></tr>{% endfor %}</tbody></table>
|
||||
<tbody>{% for row in branches %}<tr class="border-t"><td class="p-3">{{ row.branch_code }}</td><td class="p-3 font-medium">{{ row.branch_name }}{% if row.is_primary %} <span class="text-xs text-brand-700">Primary</span>{% endif %}</td><td class="p-3">{{ row.branch_type|replace('_',' ')|title }}</td><td class="p-3">{{ row.city or '' }}{% if row.city and row.state %}, {% endif %}{{ row.state or '-' }}</td><td class="p-3 text-center">{{ 'Active' if row.is_active else 'Inactive' }}</td><td class="p-3">{% if can_edit %}<div class="flex items-center gap-3"><a href="/clients/{{ client.id }}/business-structure?edit_branch={{ row.id }}#edit-branch" class="text-xs font-semibold text-brand-700">Edit</a><form method="post" action="/clients/{{ client.id }}/business-structure/branch/{{ row.id }}/toggle"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><button class="text-xs text-brand-700">{{ 'Deactivate' if row.is_active else 'Activate' }}</button></form></div>{% endif %}</td></tr>{% else %}<tr><td colspan="6" class="p-6 text-center text-slate-500">No Client Branches added.</td></tr>{% endfor %}</tbody></table>
|
||||
</section>
|
||||
|
||||
<section class="rounded-2xl bg-white shadow-soft overflow-hidden">
|
||||
<section id="registrations" class="rounded-2xl bg-white shadow-soft overflow-hidden">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 border-b p-4">
|
||||
<div>
|
||||
<div class="font-semibold">Registrations</div>
|
||||
@@ -129,6 +213,9 @@
|
||||
</td>
|
||||
<td class="p-3 min-w-[170px]">
|
||||
<div class="flex flex-wrap items-center gap-x-3 gap-y-2">
|
||||
{% if can_edit %}
|
||||
<a href="/clients/{{ client.id }}/business-structure?edit_registration={{ row.id }}#edit-registration" class="text-xs font-semibold text-brand-700">Edit</a>
|
||||
{% endif %}
|
||||
{% if can_manage_credentials %}
|
||||
<a href="/credential-vault/new?client_id={{ client.id }}®istration_id={{ row.id }}" class="text-xs font-semibold text-violet-700">{{ '+ Add Another Credential' if linked_credentials else '+ Add Credential' }}</a>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user